toyon 0.23.0 → 0.25.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (108) hide show
  1. package/README.md +26 -21
  2. package/dist/CHANGELOG.md +68 -0
  3. package/dist/cli.js +1 -1
  4. package/dist/daemon.js +2389 -1563
  5. package/dist/shell/assets/{Editor-C2e_GpDQ.js → Editor-v7DPr3mY.js} +168 -168
  6. package/dist/shell/assets/Editor-v7DPr3mY.js.br +0 -0
  7. package/dist/shell/assets/Editor-v7DPr3mY.js.gz +0 -0
  8. package/dist/shell/assets/{XTerm-B84G0H5I.js → XTerm-CxU9R8q7.js} +2 -2
  9. package/dist/shell/assets/XTerm-CxU9R8q7.js.br +0 -0
  10. package/dist/shell/assets/XTerm-CxU9R8q7.js.gz +0 -0
  11. package/dist/shell/assets/{cssMode-DhDLwjyN.js → cssMode-DD5SBqGU.js} +1 -1
  12. package/dist/shell/assets/cssMode-DD5SBqGU.js.br +0 -0
  13. package/dist/shell/assets/cssMode-DD5SBqGU.js.gz +0 -0
  14. package/dist/shell/assets/{freemarker2-rc8sP22g.js → freemarker2-CZ3XZhjv.js} +1 -1
  15. package/dist/shell/assets/freemarker2-CZ3XZhjv.js.br +0 -0
  16. package/dist/shell/assets/freemarker2-CZ3XZhjv.js.gz +0 -0
  17. package/dist/shell/assets/{grammar-Cty-NAQC.js → grammar-DqAbMw7d.js} +1 -1
  18. package/dist/shell/assets/grammar-DqAbMw7d.js.br +0 -0
  19. package/dist/shell/assets/grammar-DqAbMw7d.js.gz +0 -0
  20. package/dist/shell/assets/{handlebars-BOQxV3p5.js → handlebars-CzZa_iMI.js} +1 -1
  21. package/dist/shell/assets/handlebars-CzZa_iMI.js.br +0 -0
  22. package/dist/shell/assets/handlebars-CzZa_iMI.js.gz +0 -0
  23. package/dist/shell/assets/{html-CxndUpse.js → html-uU_fKUCO.js} +1 -1
  24. package/dist/shell/assets/html-uU_fKUCO.js.br +0 -0
  25. package/dist/shell/assets/html-uU_fKUCO.js.gz +0 -0
  26. package/dist/shell/assets/{htmlMode-CG7eVDLo.js → htmlMode-DmuqvqLQ.js} +1 -1
  27. package/dist/shell/assets/htmlMode-DmuqvqLQ.js.br +0 -0
  28. package/dist/shell/assets/htmlMode-DmuqvqLQ.js.gz +0 -0
  29. package/dist/shell/assets/index-DMZqXgxq.js +295 -0
  30. package/dist/shell/assets/index-DMZqXgxq.js.br +0 -0
  31. package/dist/shell/assets/index-DMZqXgxq.js.gz +0 -0
  32. package/dist/shell/assets/index-LFCDUSQF.css +1 -0
  33. package/dist/shell/assets/index-LFCDUSQF.css.br +0 -0
  34. package/dist/shell/assets/index-LFCDUSQF.css.gz +0 -0
  35. package/dist/shell/assets/{javascript-CafoevnZ.js → javascript-CvDukmsa.js} +1 -1
  36. package/dist/shell/assets/{jsonMode-Cg_4sMB_.js → jsonMode-C8ZGvKb7.js} +1 -1
  37. package/dist/shell/assets/jsonMode-C8ZGvKb7.js.br +0 -0
  38. package/dist/shell/assets/jsonMode-C8ZGvKb7.js.gz +0 -0
  39. package/dist/shell/assets/{liquid-DxW_HNid.js → liquid-CSFER4cS.js} +1 -1
  40. package/dist/shell/assets/liquid-CSFER4cS.js.br +0 -0
  41. package/dist/shell/assets/liquid-CSFER4cS.js.gz +0 -0
  42. package/dist/shell/assets/{lspLanguageFeatures-Dhat9l4L.js → lspLanguageFeatures-Bnq8PCF_.js} +2 -2
  43. package/dist/shell/assets/lspLanguageFeatures-Bnq8PCF_.js.br +0 -0
  44. package/dist/shell/assets/lspLanguageFeatures-Bnq8PCF_.js.gz +0 -0
  45. package/dist/shell/assets/{mdx-ZdMhgPNL.js → mdx-DN7UGs67.js} +1 -1
  46. package/dist/shell/assets/mdx-DN7UGs67.js.br +0 -0
  47. package/dist/shell/assets/mdx-DN7UGs67.js.gz +0 -0
  48. package/dist/shell/assets/{python-Bae_7wMM.js → python-Cdtmy77f.js} +1 -1
  49. package/dist/shell/assets/python-Cdtmy77f.js.br +0 -0
  50. package/dist/shell/assets/python-Cdtmy77f.js.gz +0 -0
  51. package/dist/shell/assets/{razor-CtwiCIJH.js → razor-BzMJ8H5n.js} +1 -1
  52. package/dist/shell/assets/razor-BzMJ8H5n.js.br +0 -0
  53. package/dist/shell/assets/razor-BzMJ8H5n.js.gz +0 -0
  54. package/dist/shell/assets/toyon-mono-bold-1tbrivW1.woff2 +0 -0
  55. package/dist/shell/assets/toyon-mono-regular-BUtE4EFW.woff2 +0 -0
  56. package/dist/shell/assets/{tsMode-DH9rMbRS.js → tsMode-B_VeTgWt.js} +1 -1
  57. package/dist/shell/assets/tsMode-B_VeTgWt.js.br +0 -0
  58. package/dist/shell/assets/tsMode-B_VeTgWt.js.gz +0 -0
  59. package/dist/shell/assets/{xml-rA-vNTCn.js → xml-Cdv7rs1C.js} +1 -1
  60. package/dist/shell/assets/xml-Cdv7rs1C.js.br +0 -0
  61. package/dist/shell/assets/xml-Cdv7rs1C.js.gz +0 -0
  62. package/dist/shell/assets/{yaml-pOtRRozm.js → yaml-Co_E2Q5j.js} +1 -1
  63. package/dist/shell/assets/yaml-Co_E2Q5j.js.br +0 -0
  64. package/dist/shell/assets/yaml-Co_E2Q5j.js.gz +0 -0
  65. package/dist/shell/index.html +2 -2
  66. package/package.json +1 -1
  67. package/dist/shell/assets/Editor-C2e_GpDQ.js.br +0 -0
  68. package/dist/shell/assets/Editor-C2e_GpDQ.js.gz +0 -0
  69. package/dist/shell/assets/XTerm-B84G0H5I.js.br +0 -0
  70. package/dist/shell/assets/XTerm-B84G0H5I.js.gz +0 -0
  71. package/dist/shell/assets/cssMode-DhDLwjyN.js.br +0 -0
  72. package/dist/shell/assets/cssMode-DhDLwjyN.js.gz +0 -0
  73. package/dist/shell/assets/freemarker2-rc8sP22g.js.br +0 -0
  74. package/dist/shell/assets/freemarker2-rc8sP22g.js.gz +0 -0
  75. package/dist/shell/assets/grammar-Cty-NAQC.js.br +0 -0
  76. package/dist/shell/assets/grammar-Cty-NAQC.js.gz +0 -0
  77. package/dist/shell/assets/handlebars-BOQxV3p5.js.br +0 -0
  78. package/dist/shell/assets/handlebars-BOQxV3p5.js.gz +0 -0
  79. package/dist/shell/assets/html-CxndUpse.js.br +0 -0
  80. package/dist/shell/assets/html-CxndUpse.js.gz +0 -0
  81. package/dist/shell/assets/htmlMode-CG7eVDLo.js.br +0 -0
  82. package/dist/shell/assets/htmlMode-CG7eVDLo.js.gz +0 -0
  83. package/dist/shell/assets/index-DpSfPmkM.css +0 -1
  84. package/dist/shell/assets/index-DpSfPmkM.css.br +0 -0
  85. package/dist/shell/assets/index-DpSfPmkM.css.gz +0 -0
  86. package/dist/shell/assets/index-DzfHDra7.js +0 -294
  87. package/dist/shell/assets/index-DzfHDra7.js.br +0 -0
  88. package/dist/shell/assets/index-DzfHDra7.js.gz +0 -0
  89. package/dist/shell/assets/jsonMode-Cg_4sMB_.js.br +0 -0
  90. package/dist/shell/assets/jsonMode-Cg_4sMB_.js.gz +0 -0
  91. package/dist/shell/assets/liquid-DxW_HNid.js.br +0 -0
  92. package/dist/shell/assets/liquid-DxW_HNid.js.gz +0 -0
  93. package/dist/shell/assets/lspLanguageFeatures-Dhat9l4L.js.br +0 -0
  94. package/dist/shell/assets/lspLanguageFeatures-Dhat9l4L.js.gz +0 -0
  95. package/dist/shell/assets/mdx-ZdMhgPNL.js.br +0 -0
  96. package/dist/shell/assets/mdx-ZdMhgPNL.js.gz +0 -0
  97. package/dist/shell/assets/python-Bae_7wMM.js.br +0 -0
  98. package/dist/shell/assets/python-Bae_7wMM.js.gz +0 -0
  99. package/dist/shell/assets/razor-CtwiCIJH.js.br +0 -0
  100. package/dist/shell/assets/razor-CtwiCIJH.js.gz +0 -0
  101. package/dist/shell/assets/toyon-mono-bold-9c1iJO0D.woff2 +0 -0
  102. package/dist/shell/assets/toyon-mono-regular-BXyxgSUK.woff2 +0 -0
  103. package/dist/shell/assets/tsMode-DH9rMbRS.js.br +0 -0
  104. package/dist/shell/assets/tsMode-DH9rMbRS.js.gz +0 -0
  105. package/dist/shell/assets/xml-rA-vNTCn.js.br +0 -0
  106. package/dist/shell/assets/xml-rA-vNTCn.js.gz +0 -0
  107. package/dist/shell/assets/yaml-pOtRRozm.js.br +0 -0
  108. package/dist/shell/assets/yaml-pOtRRozm.js.gz +0 -0
@@ -1,294 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/Editor-C2e_GpDQ.js","assets/grammar-Cty-NAQC.js","assets/Editor-CB2SckMT.css","assets/XTerm-B84G0H5I.js","assets/XTerm-6GBZ9nXN.css"])))=>i.map(i=>d[i]);
2
- var UI=Object.defineProperty;var HI=(e,t,n)=>t in e?UI(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var jt=(e,t,n)=>HI(e,typeof t!="symbol"?t+"":t,n);(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))r(o);new MutationObserver(o=>{for(const s of o)if(s.type==="childList")for(const a of s.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&r(a)}).observe(document,{childList:!0,subtree:!0});function n(o){const s={};return o.integrity&&(s.integrity=o.integrity),o.referrerPolicy&&(s.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?s.credentials="include":o.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function r(o){if(o.ep)return;o.ep=!0;const s=n(o);fetch(o.href,s)}})();function QE(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Xm={exports:{}},Zc={},Qm={exports:{}},en={};/**
3
- * @license React
4
- * react.production.min.js
5
- *
6
- * Copyright (c) Facebook, Inc. and its affiliates.
7
- *
8
- * This source code is licensed under the MIT license found in the
9
- * LICENSE file in the root directory of this source tree.
10
- */var V0;function WI(){if(V0)return en;V0=1;var e=Symbol.for("react.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),o=Symbol.for("react.profiler"),s=Symbol.for("react.provider"),a=Symbol.for("react.context"),c=Symbol.for("react.forward_ref"),u=Symbol.for("react.suspense"),f=Symbol.for("react.memo"),h=Symbol.for("react.lazy"),m=Symbol.iterator;function g(W){return W===null||typeof W!="object"?null:(W=m&&W[m]||W["@@iterator"],typeof W=="function"?W:null)}var y={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},w=Object.assign,v={};function _(W,oe,de){this.props=W,this.context=oe,this.refs=v,this.updater=de||y}_.prototype.isReactComponent={},_.prototype.setState=function(W,oe){if(typeof W!="object"&&typeof W!="function"&&W!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,W,oe,"setState")},_.prototype.forceUpdate=function(W){this.updater.enqueueForceUpdate(this,W,"forceUpdate")};function x(){}x.prototype=_.prototype;function N(W,oe,de){this.props=W,this.context=oe,this.refs=v,this.updater=de||y}var T=N.prototype=new x;T.constructor=N,w(T,_.prototype),T.isPureReactComponent=!0;var j=Array.isArray,A=Object.prototype.hasOwnProperty,R={current:null},C={key:!0,ref:!0,__self:!0,__source:!0};function M(W,oe,de){var he,Ne={},Me=null,Be=null;if(oe!=null)for(he in oe.ref!==void 0&&(Be=oe.ref),oe.key!==void 0&&(Me=""+oe.key),oe)A.call(oe,he)&&!C.hasOwnProperty(he)&&(Ne[he]=oe[he]);var K=arguments.length-2;if(K===1)Ne.children=de;else if(1<K){for(var te=Array(K),pe=0;pe<K;pe++)te[pe]=arguments[pe+2];Ne.children=te}if(W&&W.defaultProps)for(he in K=W.defaultProps,K)Ne[he]===void 0&&(Ne[he]=K[he]);return{$$typeof:e,type:W,key:Me,ref:Be,props:Ne,_owner:R.current}}function I(W,oe){return{$$typeof:e,type:W.type,key:oe,ref:W.ref,props:W.props,_owner:W._owner}}function D(W){return typeof W=="object"&&W!==null&&W.$$typeof===e}function H(W){var oe={"=":"=0",":":"=2"};return"$"+W.replace(/[=:]/g,function(de){return oe[de]})}var Z=/\/+/g;function B(W,oe){return typeof W=="object"&&W!==null&&W.key!=null?H(""+W.key):oe.toString(36)}function J(W,oe,de,he,Ne){var Me=typeof W;(Me==="undefined"||Me==="boolean")&&(W=null);var Be=!1;if(W===null)Be=!0;else switch(Me){case"string":case"number":Be=!0;break;case"object":switch(W.$$typeof){case e:case t:Be=!0}}if(Be)return Be=W,Ne=Ne(Be),W=he===""?"."+B(Be,0):he,j(Ne)?(de="",W!=null&&(de=W.replace(Z,"$&/")+"/"),J(Ne,oe,de,"",function(pe){return pe})):Ne!=null&&(D(Ne)&&(Ne=I(Ne,de+(!Ne.key||Be&&Be.key===Ne.key?"":(""+Ne.key).replace(Z,"$&/")+"/")+W)),oe.push(Ne)),1;if(Be=0,he=he===""?".":he+":",j(W))for(var K=0;K<W.length;K++){Me=W[K];var te=he+B(Me,K);Be+=J(Me,oe,de,te,Ne)}else if(te=g(W),typeof te=="function")for(W=te.call(W),K=0;!(Me=W.next()).done;)Me=Me.value,te=he+B(Me,K++),Be+=J(Me,oe,de,te,Ne);else if(Me==="object")throw oe=String(W),Error("Objects are not valid as a React child (found: "+(oe==="[object Object]"?"object with keys {"+Object.keys(W).join(", ")+"}":oe)+"). If you meant to render a collection of children, use an array instead.");return Be}function V(W,oe,de){if(W==null)return W;var he=[],Ne=0;return J(W,he,"","",function(Me){return oe.call(de,Me,Ne++)}),he}function ee(W){if(W._status===-1){var oe=W._result;oe=oe(),oe.then(function(de){(W._status===0||W._status===-1)&&(W._status=1,W._result=de)},function(de){(W._status===0||W._status===-1)&&(W._status=2,W._result=de)}),W._status===-1&&(W._status=0,W._result=oe)}if(W._status===1)return W._result.default;throw W._result}var F={current:null},$={transition:null},Q={ReactCurrentDispatcher:F,ReactCurrentBatchConfig:$,ReactCurrentOwner:R};function q(){throw Error("act(...) is not supported in production builds of React.")}return en.Children={map:V,forEach:function(W,oe,de){V(W,function(){oe.apply(this,arguments)},de)},count:function(W){var oe=0;return V(W,function(){oe++}),oe},toArray:function(W){return V(W,function(oe){return oe})||[]},only:function(W){if(!D(W))throw Error("React.Children.only expected to receive a single React element child.");return W}},en.Component=_,en.Fragment=n,en.Profiler=o,en.PureComponent=N,en.StrictMode=r,en.Suspense=u,en.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=Q,en.act=q,en.cloneElement=function(W,oe,de){if(W==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+W+".");var he=w({},W.props),Ne=W.key,Me=W.ref,Be=W._owner;if(oe!=null){if(oe.ref!==void 0&&(Me=oe.ref,Be=R.current),oe.key!==void 0&&(Ne=""+oe.key),W.type&&W.type.defaultProps)var K=W.type.defaultProps;for(te in oe)A.call(oe,te)&&!C.hasOwnProperty(te)&&(he[te]=oe[te]===void 0&&K!==void 0?K[te]:oe[te])}var te=arguments.length-2;if(te===1)he.children=de;else if(1<te){K=Array(te);for(var pe=0;pe<te;pe++)K[pe]=arguments[pe+2];he.children=K}return{$$typeof:e,type:W.type,key:Ne,ref:Me,props:he,_owner:Be}},en.createContext=function(W){return W={$$typeof:a,_currentValue:W,_currentValue2:W,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},W.Provider={$$typeof:s,_context:W},W.Consumer=W},en.createElement=M,en.createFactory=function(W){var oe=M.bind(null,W);return oe.type=W,oe},en.createRef=function(){return{current:null}},en.forwardRef=function(W){return{$$typeof:c,render:W}},en.isValidElement=D,en.lazy=function(W){return{$$typeof:h,_payload:{_status:-1,_result:W},_init:ee}},en.memo=function(W,oe){return{$$typeof:f,type:W,compare:oe===void 0?null:oe}},en.startTransition=function(W){var oe=$.transition;$.transition={};try{W()}finally{$.transition=oe}},en.unstable_act=q,en.useCallback=function(W,oe){return F.current.useCallback(W,oe)},en.useContext=function(W){return F.current.useContext(W)},en.useDebugValue=function(){},en.useDeferredValue=function(W){return F.current.useDeferredValue(W)},en.useEffect=function(W,oe){return F.current.useEffect(W,oe)},en.useId=function(){return F.current.useId()},en.useImperativeHandle=function(W,oe,de){return F.current.useImperativeHandle(W,oe,de)},en.useInsertionEffect=function(W,oe){return F.current.useInsertionEffect(W,oe)},en.useLayoutEffect=function(W,oe){return F.current.useLayoutEffect(W,oe)},en.useMemo=function(W,oe){return F.current.useMemo(W,oe)},en.useReducer=function(W,oe,de){return F.current.useReducer(W,oe,de)},en.useRef=function(W){return F.current.useRef(W)},en.useState=function(W){return F.current.useState(W)},en.useSyncExternalStore=function(W,oe,de){return F.current.useSyncExternalStore(W,oe,de)},en.useTransition=function(){return F.current.useTransition()},en.version="18.3.1",en}var Y0;function lw(){return Y0||(Y0=1,Qm.exports=WI()),Qm.exports}/**
11
- * @license React
12
- * react-jsx-runtime.production.min.js
13
- *
14
- * Copyright (c) Facebook, Inc. and its affiliates.
15
- *
16
- * This source code is licensed under the MIT license found in the
17
- * LICENSE file in the root directory of this source tree.
18
- */var X0;function KI(){if(X0)return Zc;X0=1;var e=lw(),t=Symbol.for("react.element"),n=Symbol.for("react.fragment"),r=Object.prototype.hasOwnProperty,o=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,s={key:!0,ref:!0,__self:!0,__source:!0};function a(c,u,f){var h,m={},g=null,y=null;f!==void 0&&(g=""+f),u.key!==void 0&&(g=""+u.key),u.ref!==void 0&&(y=u.ref);for(h in u)r.call(u,h)&&!s.hasOwnProperty(h)&&(m[h]=u[h]);if(c&&c.defaultProps)for(h in u=c.defaultProps,u)m[h]===void 0&&(m[h]=u[h]);return{$$typeof:t,type:c,key:g,ref:y,props:m,_owner:o.current}}return Zc.Fragment=n,Zc.jsx=a,Zc.jsxs=a,Zc}var Q0;function qI(){return Q0||(Q0=1,Xm.exports=KI()),Xm.exports}var d=qI(),E=lw();const ZI=QE(E);var Jm={exports:{}},io={},eg={exports:{}},tg={};/**
19
- * @license React
20
- * scheduler.production.min.js
21
- *
22
- * Copyright (c) Facebook, Inc. and its affiliates.
23
- *
24
- * This source code is licensed under the MIT license found in the
25
- * LICENSE file in the root directory of this source tree.
26
- */var J0;function GI(){return J0||(J0=1,(function(e){function t($,Q){var q=$.length;$.push(Q);e:for(;0<q;){var W=q-1>>>1,oe=$[W];if(0<o(oe,Q))$[W]=Q,$[q]=oe,q=W;else break e}}function n($){return $.length===0?null:$[0]}function r($){if($.length===0)return null;var Q=$[0],q=$.pop();if(q!==Q){$[0]=q;e:for(var W=0,oe=$.length,de=oe>>>1;W<de;){var he=2*(W+1)-1,Ne=$[he],Me=he+1,Be=$[Me];if(0>o(Ne,q))Me<oe&&0>o(Be,Ne)?($[W]=Be,$[Me]=q,W=Me):($[W]=Ne,$[he]=q,W=he);else if(Me<oe&&0>o(Be,q))$[W]=Be,$[Me]=q,W=Me;else break e}}return Q}function o($,Q){var q=$.sortIndex-Q.sortIndex;return q!==0?q:$.id-Q.id}if(typeof performance=="object"&&typeof performance.now=="function"){var s=performance;e.unstable_now=function(){return s.now()}}else{var a=Date,c=a.now();e.unstable_now=function(){return a.now()-c}}var u=[],f=[],h=1,m=null,g=3,y=!1,w=!1,v=!1,_=typeof setTimeout=="function"?setTimeout:null,x=typeof clearTimeout=="function"?clearTimeout:null,N=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function T($){for(var Q=n(f);Q!==null;){if(Q.callback===null)r(f);else if(Q.startTime<=$)r(f),Q.sortIndex=Q.expirationTime,t(u,Q);else break;Q=n(f)}}function j($){if(v=!1,T($),!w)if(n(u)!==null)w=!0,ee(A);else{var Q=n(f);Q!==null&&F(j,Q.startTime-$)}}function A($,Q){w=!1,v&&(v=!1,x(M),M=-1),y=!0;var q=g;try{for(T(Q),m=n(u);m!==null&&(!(m.expirationTime>Q)||$&&!H());){var W=m.callback;if(typeof W=="function"){m.callback=null,g=m.priorityLevel;var oe=W(m.expirationTime<=Q);Q=e.unstable_now(),typeof oe=="function"?m.callback=oe:m===n(u)&&r(u),T(Q)}else r(u);m=n(u)}if(m!==null)var de=!0;else{var he=n(f);he!==null&&F(j,he.startTime-Q),de=!1}return de}finally{m=null,g=q,y=!1}}var R=!1,C=null,M=-1,I=5,D=-1;function H(){return!(e.unstable_now()-D<I)}function Z(){if(C!==null){var $=e.unstable_now();D=$;var Q=!0;try{Q=C(!0,$)}finally{Q?B():(R=!1,C=null)}}else R=!1}var B;if(typeof N=="function")B=function(){N(Z)};else if(typeof MessageChannel<"u"){var J=new MessageChannel,V=J.port2;J.port1.onmessage=Z,B=function(){V.postMessage(null)}}else B=function(){_(Z,0)};function ee($){C=$,R||(R=!0,B())}function F($,Q){M=_(function(){$(e.unstable_now())},Q)}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($){$.callback=null},e.unstable_continueExecution=function(){w||y||(w=!0,ee(A))},e.unstable_forceFrameRate=function($){0>$||125<$?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):I=0<$?Math.floor(1e3/$):5},e.unstable_getCurrentPriorityLevel=function(){return g},e.unstable_getFirstCallbackNode=function(){return n(u)},e.unstable_next=function($){switch(g){case 1:case 2:case 3:var Q=3;break;default:Q=g}var q=g;g=Q;try{return $()}finally{g=q}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function($,Q){switch($){case 1:case 2:case 3:case 4:case 5:break;default:$=3}var q=g;g=$;try{return Q()}finally{g=q}},e.unstable_scheduleCallback=function($,Q,q){var W=e.unstable_now();switch(typeof q=="object"&&q!==null?(q=q.delay,q=typeof q=="number"&&0<q?W+q:W):q=W,$){case 1:var oe=-1;break;case 2:oe=250;break;case 5:oe=1073741823;break;case 4:oe=1e4;break;default:oe=5e3}return oe=q+oe,$={id:h++,callback:Q,priorityLevel:$,startTime:q,expirationTime:oe,sortIndex:-1},q>W?($.sortIndex=q,t(f,$),n(u)===null&&$===n(f)&&(v?(x(M),M=-1):v=!0,F(j,q-W))):($.sortIndex=oe,t(u,$),w||y||(w=!0,ee(A))),$},e.unstable_shouldYield=H,e.unstable_wrapCallback=function($){var Q=g;return function(){var q=g;g=Q;try{return $.apply(this,arguments)}finally{g=q}}}})(tg)),tg}var eb;function VI(){return eb||(eb=1,eg.exports=GI()),eg.exports}/**
27
- * @license React
28
- * react-dom.production.min.js
29
- *
30
- * Copyright (c) Facebook, Inc. and its affiliates.
31
- *
32
- * This source code is licensed under the MIT license found in the
33
- * LICENSE file in the root directory of this source tree.
34
- */var tb;function YI(){if(tb)return io;tb=1;var e=lw(),t=VI();function n(i){for(var l="https://reactjs.org/docs/error-decoder.html?invariant="+i,p=1;p<arguments.length;p++)l+="&args[]="+encodeURIComponent(arguments[p]);return"Minified React error #"+i+"; visit "+l+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var r=new Set,o={};function s(i,l){a(i,l),a(i+"Capture",l)}function a(i,l){for(o[i]=l,i=0;i<l.length;i++)r.add(l[i])}var c=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),u=Object.prototype.hasOwnProperty,f=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,h={},m={};function g(i){return u.call(m,i)?!0:u.call(h,i)?!1:f.test(i)?m[i]=!0:(h[i]=!0,!1)}function y(i,l,p,k){if(p!==null&&p.type===0)return!1;switch(typeof l){case"function":case"symbol":return!0;case"boolean":return k?!1:p!==null?!p.acceptsBooleans:(i=i.toLowerCase().slice(0,5),i!=="data-"&&i!=="aria-");default:return!1}}function w(i,l,p,k){if(l===null||typeof l>"u"||y(i,l,p,k))return!0;if(k)return!1;if(p!==null)switch(p.type){case 3:return!l;case 4:return l===!1;case 5:return isNaN(l);case 6:return isNaN(l)||1>l}return!1}function v(i,l,p,k,b,S,O){this.acceptsBooleans=l===2||l===3||l===4,this.attributeName=k,this.attributeNamespace=b,this.mustUseProperty=p,this.propertyName=i,this.type=l,this.sanitizeURL=S,this.removeEmptyString=O}var _={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(i){_[i]=new v(i,0,!1,i,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(i){var l=i[0];_[l]=new v(l,1,!1,i[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(i){_[i]=new v(i,2,!1,i.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(i){_[i]=new v(i,2,!1,i,null,!1,!1)}),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(i){_[i]=new v(i,3,!1,i.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(i){_[i]=new v(i,3,!0,i,null,!1,!1)}),["capture","download"].forEach(function(i){_[i]=new v(i,4,!1,i,null,!1,!1)}),["cols","rows","size","span"].forEach(function(i){_[i]=new v(i,6,!1,i,null,!1,!1)}),["rowSpan","start"].forEach(function(i){_[i]=new v(i,5,!1,i.toLowerCase(),null,!1,!1)});var x=/[\-:]([a-z])/g;function N(i){return i[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(i){var l=i.replace(x,N);_[l]=new v(l,1,!1,i,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(i){var l=i.replace(x,N);_[l]=new v(l,1,!1,i,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(i){var l=i.replace(x,N);_[l]=new v(l,1,!1,i,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(i){_[i]=new v(i,1,!1,i.toLowerCase(),null,!1,!1)}),_.xlinkHref=new v("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(i){_[i]=new v(i,1,!1,i.toLowerCase(),null,!0,!0)});function T(i,l,p,k){var b=_.hasOwnProperty(l)?_[l]:null;(b!==null?b.type!==0:k||!(2<l.length)||l[0]!=="o"&&l[0]!=="O"||l[1]!=="n"&&l[1]!=="N")&&(w(l,p,b,k)&&(p=null),k||b===null?g(l)&&(p===null?i.removeAttribute(l):i.setAttribute(l,""+p)):b.mustUseProperty?i[b.propertyName]=p===null?b.type===3?!1:"":p:(l=b.attributeName,k=b.attributeNamespace,p===null?i.removeAttribute(l):(b=b.type,p=b===3||b===4&&p===!0?"":""+p,k?i.setAttributeNS(k,l,p):i.setAttribute(l,p))))}var j=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,A=Symbol.for("react.element"),R=Symbol.for("react.portal"),C=Symbol.for("react.fragment"),M=Symbol.for("react.strict_mode"),I=Symbol.for("react.profiler"),D=Symbol.for("react.provider"),H=Symbol.for("react.context"),Z=Symbol.for("react.forward_ref"),B=Symbol.for("react.suspense"),J=Symbol.for("react.suspense_list"),V=Symbol.for("react.memo"),ee=Symbol.for("react.lazy"),F=Symbol.for("react.offscreen"),$=Symbol.iterator;function Q(i){return i===null||typeof i!="object"?null:(i=$&&i[$]||i["@@iterator"],typeof i=="function"?i:null)}var q=Object.assign,W;function oe(i){if(W===void 0)try{throw Error()}catch(p){var l=p.stack.trim().match(/\n( *(at )?)/);W=l&&l[1]||""}return`
35
- `+W+i}var de=!1;function he(i,l){if(!i||de)return"";de=!0;var p=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(l)if(l=function(){throw Error()},Object.defineProperty(l.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(l,[])}catch(ke){var k=ke}Reflect.construct(i,[],l)}else{try{l.call()}catch(ke){k=ke}i.call(l.prototype)}else{try{throw Error()}catch(ke){k=ke}i()}}catch(ke){if(ke&&k&&typeof ke.stack=="string"){for(var b=ke.stack.split(`
36
- `),S=k.stack.split(`
37
- `),O=b.length-1,Y=S.length-1;1<=O&&0<=Y&&b[O]!==S[Y];)Y--;for(;1<=O&&0<=Y;O--,Y--)if(b[O]!==S[Y]){if(O!==1||Y!==1)do if(O--,Y--,0>Y||b[O]!==S[Y]){var re=`
38
- `+b[O].replace(" at new "," at ");return i.displayName&&re.includes("<anonymous>")&&(re=re.replace("<anonymous>",i.displayName)),re}while(1<=O&&0<=Y);break}}}finally{de=!1,Error.prepareStackTrace=p}return(i=i?i.displayName||i.name:"")?oe(i):""}function Ne(i){switch(i.tag){case 5:return oe(i.type);case 16:return oe("Lazy");case 13:return oe("Suspense");case 19:return oe("SuspenseList");case 0:case 2:case 15:return i=he(i.type,!1),i;case 11:return i=he(i.type.render,!1),i;case 1:return i=he(i.type,!0),i;default:return""}}function Me(i){if(i==null)return null;if(typeof i=="function")return i.displayName||i.name||null;if(typeof i=="string")return i;switch(i){case C:return"Fragment";case R:return"Portal";case I:return"Profiler";case M:return"StrictMode";case B:return"Suspense";case J:return"SuspenseList"}if(typeof i=="object")switch(i.$$typeof){case H:return(i.displayName||"Context")+".Consumer";case D:return(i._context.displayName||"Context")+".Provider";case Z:var l=i.render;return i=i.displayName,i||(i=l.displayName||l.name||"",i=i!==""?"ForwardRef("+i+")":"ForwardRef"),i;case V:return l=i.displayName||null,l!==null?l:Me(i.type)||"Memo";case ee:l=i._payload,i=i._init;try{return Me(i(l))}catch{}}return null}function Be(i){var l=i.type;switch(i.tag){case 24:return"Cache";case 9:return(l.displayName||"Context")+".Consumer";case 10:return(l._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return i=l.render,i=i.displayName||i.name||"",l.displayName||(i!==""?"ForwardRef("+i+")":"ForwardRef");case 7:return"Fragment";case 5:return l;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return Me(l);case 8:return l===M?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof l=="function")return l.displayName||l.name||null;if(typeof l=="string")return l}return null}function K(i){switch(typeof i){case"boolean":case"number":case"string":case"undefined":return i;case"object":return i;default:return""}}function te(i){var l=i.type;return(i=i.nodeName)&&i.toLowerCase()==="input"&&(l==="checkbox"||l==="radio")}function pe(i){var l=te(i)?"checked":"value",p=Object.getOwnPropertyDescriptor(i.constructor.prototype,l),k=""+i[l];if(!i.hasOwnProperty(l)&&typeof p<"u"&&typeof p.get=="function"&&typeof p.set=="function"){var b=p.get,S=p.set;return Object.defineProperty(i,l,{configurable:!0,get:function(){return b.call(this)},set:function(O){k=""+O,S.call(this,O)}}),Object.defineProperty(i,l,{enumerable:p.enumerable}),{getValue:function(){return k},setValue:function(O){k=""+O},stopTracking:function(){i._valueTracker=null,delete i[l]}}}}function ue(i){i._valueTracker||(i._valueTracker=pe(i))}function ie(i){if(!i)return!1;var l=i._valueTracker;if(!l)return!0;var p=l.getValue(),k="";return i&&(k=te(i)?i.checked?"true":"false":i.value),i=k,i!==p?(l.setValue(i),!0):!1}function ye(i){if(i=i||(typeof document<"u"?document:void 0),typeof i>"u")return null;try{return i.activeElement||i.body}catch{return i.body}}function Se(i,l){var p=l.checked;return q({},l,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:p??i._wrapperState.initialChecked})}function Ee(i,l){var p=l.defaultValue==null?"":l.defaultValue,k=l.checked!=null?l.checked:l.defaultChecked;p=K(l.value!=null?l.value:p),i._wrapperState={initialChecked:k,initialValue:p,controlled:l.type==="checkbox"||l.type==="radio"?l.checked!=null:l.value!=null}}function Le(i,l){l=l.checked,l!=null&&T(i,"checked",l,!1)}function Ue(i,l){Le(i,l);var p=K(l.value),k=l.type;if(p!=null)k==="number"?(p===0&&i.value===""||i.value!=p)&&(i.value=""+p):i.value!==""+p&&(i.value=""+p);else if(k==="submit"||k==="reset"){i.removeAttribute("value");return}l.hasOwnProperty("value")?Ht(i,l.type,p):l.hasOwnProperty("defaultValue")&&Ht(i,l.type,K(l.defaultValue)),l.checked==null&&l.defaultChecked!=null&&(i.defaultChecked=!!l.defaultChecked)}function Je(i,l,p){if(l.hasOwnProperty("value")||l.hasOwnProperty("defaultValue")){var k=l.type;if(!(k!=="submit"&&k!=="reset"||l.value!==void 0&&l.value!==null))return;l=""+i._wrapperState.initialValue,p||l===i.value||(i.value=l),i.defaultValue=l}p=i.name,p!==""&&(i.name=""),i.defaultChecked=!!i._wrapperState.initialChecked,p!==""&&(i.name=p)}function Ht(i,l,p){(l!=="number"||ye(i.ownerDocument)!==i)&&(p==null?i.defaultValue=""+i._wrapperState.initialValue:i.defaultValue!==""+p&&(i.defaultValue=""+p))}var qt=Array.isArray;function xt(i,l,p,k){if(i=i.options,l){l={};for(var b=0;b<p.length;b++)l["$"+p[b]]=!0;for(p=0;p<i.length;p++)b=l.hasOwnProperty("$"+i[p].value),i[p].selected!==b&&(i[p].selected=b),b&&k&&(i[p].defaultSelected=!0)}else{for(p=""+K(p),l=null,b=0;b<i.length;b++){if(i[b].value===p){i[b].selected=!0,k&&(i[b].defaultSelected=!0);return}l!==null||i[b].disabled||(l=i[b])}l!==null&&(l.selected=!0)}}function Ze(i,l){if(l.dangerouslySetInnerHTML!=null)throw Error(n(91));return q({},l,{value:void 0,defaultValue:void 0,children:""+i._wrapperState.initialValue})}function _t(i,l){var p=l.value;if(p==null){if(p=l.children,l=l.defaultValue,p!=null){if(l!=null)throw Error(n(92));if(qt(p)){if(1<p.length)throw Error(n(93));p=p[0]}l=p}l==null&&(l=""),p=l}i._wrapperState={initialValue:K(p)}}function mt(i,l){var p=K(l.value),k=K(l.defaultValue);p!=null&&(p=""+p,p!==i.value&&(i.value=p),l.defaultValue==null&&i.defaultValue!==p&&(i.defaultValue=p)),k!=null&&(i.defaultValue=""+k)}function De(i){var l=i.textContent;l===i._wrapperState.initialValue&&l!==""&&l!==null&&(i.value=l)}function nt(i){switch(i){case"svg":return"http://www.w3.org/2000/svg";case"math":return"http://www.w3.org/1998/Math/MathML";default:return"http://www.w3.org/1999/xhtml"}}function lt(i,l){return i==null||i==="http://www.w3.org/1999/xhtml"?nt(l):i==="http://www.w3.org/2000/svg"&&l==="foreignObject"?"http://www.w3.org/1999/xhtml":i}var Yt,$n=(function(i){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(l,p,k,b){MSApp.execUnsafeLocalFunction(function(){return i(l,p,k,b)})}:i})(function(i,l){if(i.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in i)i.innerHTML=l;else{for(Yt=Yt||document.createElement("div"),Yt.innerHTML="<svg>"+l.valueOf().toString()+"</svg>",l=Yt.firstChild;i.firstChild;)i.removeChild(i.firstChild);for(;l.firstChild;)i.appendChild(l.firstChild)}});function gt(i,l){if(l){var p=i.firstChild;if(p&&p===i.lastChild&&p.nodeType===3){p.nodeValue=l;return}}i.textContent=l}var rt={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},Kn=["Webkit","ms","Moz","O"];Object.keys(rt).forEach(function(i){Kn.forEach(function(l){l=l+i.charAt(0).toUpperCase()+i.substring(1),rt[l]=rt[i]})});function Qt(i,l,p){return l==null||typeof l=="boolean"||l===""?"":p||typeof l!="number"||l===0||rt.hasOwnProperty(i)&&rt[i]?(""+l).trim():l+"px"}function Cn(i,l){i=i.style;for(var p in l)if(l.hasOwnProperty(p)){var k=p.indexOf("--")===0,b=Qt(p,l[p],k);p==="float"&&(p="cssFloat"),k?i.setProperty(p,b):i[p]=b}}var qn=q({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function dn(i,l){if(l){if(qn[i]&&(l.children!=null||l.dangerouslySetInnerHTML!=null))throw Error(n(137,i));if(l.dangerouslySetInnerHTML!=null){if(l.children!=null)throw Error(n(60));if(typeof l.dangerouslySetInnerHTML!="object"||!("__html"in l.dangerouslySetInnerHTML))throw Error(n(61))}if(l.style!=null&&typeof l.style!="object")throw Error(n(62))}}function yn(i,l){if(i.indexOf("-")===-1)return typeof l.is=="string";switch(i){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var ne=null;function we(i){return i=i.target||i.srcElement||window,i.correspondingUseElement&&(i=i.correspondingUseElement),i.nodeType===3?i.parentNode:i}var qe=null,ot=null,Tt=null;function Dt(i){if(i=Ac(i)){if(typeof qe!="function")throw Error(n(280));var l=i.stateNode;l&&(l=Td(l),qe(i.stateNode,i.type,l))}}function P(i){ot?Tt?Tt.push(i):Tt=[i]:ot=i}function se(){if(ot){var i=ot,l=Tt;if(Tt=ot=null,Dt(i),l)for(i=0;i<l.length;i++)Dt(l[i])}}function je(i,l){return i(l)}function Fe(){}var Rt=!1;function Zt(i,l,p){if(Rt)return i(l,p);Rt=!0;try{return je(i,l,p)}finally{Rt=!1,(ot!==null||Tt!==null)&&(Fe(),se())}}function Ae(i,l){var p=i.stateNode;if(p===null)return null;var k=Td(p);if(k===null)return null;p=k[l];e:switch(l){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(k=!k.disabled)||(i=i.type,k=!(i==="button"||i==="input"||i==="select"||i==="textarea")),i=!k;break e;default:i=!1}if(i)return null;if(p&&typeof p!="function")throw Error(n(231,l,typeof p));return p}var We=!1;if(c)try{var Ve={};Object.defineProperty(Ve,"passive",{get:function(){We=!0}}),window.addEventListener("test",Ve,Ve),window.removeEventListener("test",Ve,Ve)}catch{We=!1}function Xt(i,l,p,k,b,S,O,Y,re){var ke=Array.prototype.slice.call(arguments,3);try{l.apply(p,ke)}catch(Re){this.onError(Re)}}var Wt=!1,bn=null,xn=!1,Ct=null,Jt={onError:function(i){Wt=!0,bn=i}};function sr(i,l,p,k,b,S,O,Y,re){Wt=!1,bn=null,Xt.apply(Jt,arguments)}function Gt(i,l,p,k,b,S,O,Y,re){if(sr.apply(this,arguments),Wt){if(Wt){var ke=bn;Wt=!1,bn=null}else throw Error(n(198));xn||(xn=!0,Ct=ke)}}function Rn(i){var l=i,p=i;if(i.alternate)for(;l.return;)l=l.return;else{i=l;do l=i,(l.flags&4098)!==0&&(p=l.return),i=l.return;while(i)}return l.tag===3?p:null}function fn(i){if(i.tag===13){var l=i.memoizedState;if(l===null&&(i=i.alternate,i!==null&&(l=i.memoizedState)),l!==null)return l.dehydrated}return null}function ae(i){if(Rn(i)!==i)throw Error(n(188))}function _e(i){var l=i.alternate;if(!l){if(l=Rn(i),l===null)throw Error(n(188));return l!==i?null:i}for(var p=i,k=l;;){var b=p.return;if(b===null)break;var S=b.alternate;if(S===null){if(k=b.return,k!==null){p=k;continue}break}if(b.child===S.child){for(S=b.child;S;){if(S===p)return ae(b),i;if(S===k)return ae(b),l;S=S.sibling}throw Error(n(188))}if(p.return!==k.return)p=b,k=S;else{for(var O=!1,Y=b.child;Y;){if(Y===p){O=!0,p=b,k=S;break}if(Y===k){O=!0,k=b,p=S;break}Y=Y.sibling}if(!O){for(Y=S.child;Y;){if(Y===p){O=!0,p=S,k=b;break}if(Y===k){O=!0,k=S,p=b;break}Y=Y.sibling}if(!O)throw Error(n(189))}}if(p.alternate!==k)throw Error(n(190))}if(p.tag!==3)throw Error(n(188));return p.stateNode.current===p?i:l}function ht(i){return i=_e(i),i!==null?ct(i):null}function ct(i){if(i.tag===5||i.tag===6)return i;for(i=i.child;i!==null;){var l=ct(i);if(l!==null)return l;i=i.sibling}return null}var zt=t.unstable_scheduleCallback,kn=t.unstable_cancelCallback,Pr=t.unstable_shouldYield,cr=t.unstable_requestPaint,ln=t.unstable_now,ur=t.unstable_getCurrentPriorityLevel,nn=t.unstable_ImmediatePriority,Bt=t.unstable_UserBlockingPriority,Ft=t.unstable_NormalPriority,be=t.unstable_LowPriority,Ye=t.unstable_IdlePriority,wt=null,yt=null;function cn(i){if(yt&&typeof yt.onCommitFiberRoot=="function")try{yt.onCommitFiberRoot(wt,i,void 0,(i.current.flags&128)===128)}catch{}}var hn=Math.clz32?Math.clz32:Ut,wr=Math.log,Zn=Math.LN2;function Ut(i){return i>>>=0,i===0?32:31-(wr(i)/Zn|0)|0}var pn=64,yr=4194304;function X(i){switch(i&-i){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return i&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return i&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return i}}function ge(i,l){var p=i.pendingLanes;if(p===0)return 0;var k=0,b=i.suspendedLanes,S=i.pingedLanes,O=p&268435455;if(O!==0){var Y=O&~b;Y!==0?k=X(Y):(S&=O,S!==0&&(k=X(S)))}else O=p&~b,O!==0?k=X(O):S!==0&&(k=X(S));if(k===0)return 0;if(l!==0&&l!==k&&(l&b)===0&&(b=k&-k,S=l&-l,b>=S||b===16&&(S&4194240)!==0))return l;if((k&4)!==0&&(k|=p&16),l=i.entangledLanes,l!==0)for(i=i.entanglements,l&=k;0<l;)p=31-hn(l),b=1<<p,k|=i[p],l&=~b;return k}function Ge(i,l){switch(i){case 1:case 2:case 4:return l+250;case 8:case 16:case 32:case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return l+5e3;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return-1;case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function Vt(i,l){for(var p=i.suspendedLanes,k=i.pingedLanes,b=i.expirationTimes,S=i.pendingLanes;0<S;){var O=31-hn(S),Y=1<<O,re=b[O];re===-1?((Y&p)===0||(Y&k)!==0)&&(b[O]=Ge(Y,l)):re<=l&&(i.expiredLanes|=Y),S&=~Y}}function Mt(i){return i=i.pendingLanes&-1073741825,i!==0?i:i&1073741824?1073741824:0}function On(){var i=pn;return pn<<=1,(pn&4194240)===0&&(pn=64),i}function Sn(i){for(var l=[],p=0;31>p;p++)l.push(i);return l}function zn(i,l,p){i.pendingLanes|=l,l!==536870912&&(i.suspendedLanes=0,i.pingedLanes=0),i=i.eventTimes,l=31-hn(l),i[l]=p}function ir(i,l){var p=i.pendingLanes&~l;i.pendingLanes=l,i.suspendedLanes=0,i.pingedLanes=0,i.expiredLanes&=l,i.mutableReadLanes&=l,i.entangledLanes&=l,l=i.entanglements;var k=i.eventTimes;for(i=i.expirationTimes;0<p;){var b=31-hn(p),S=1<<b;l[b]=0,k[b]=-1,i[b]=-1,p&=~S}}function go(i,l){var p=i.entangledLanes|=l;for(i=i.entanglements;p;){var k=31-hn(p),b=1<<k;b&l|i[k]&l&&(i[k]|=l),p&=~b}}var rn=0;function vt(i){return i&=-i,1<i?4<i?(i&268435455)!==0?16:536870912:4:1}var ko,Fn,on,Ar,dr,Ie=!1,U=[],G=null,ce=null,ve=null,Pe=new Map,Te=new Map,$t=[],sn="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset submit".split(" ");function nr(i,l){switch(i){case"focusin":case"focusout":G=null;break;case"dragenter":case"dragleave":ce=null;break;case"mouseover":case"mouseout":ve=null;break;case"pointerover":case"pointerout":Pe.delete(l.pointerId);break;case"gotpointercapture":case"lostpointercapture":Te.delete(l.pointerId)}}function Mn(i,l,p,k,b,S){return i===null||i.nativeEvent!==S?(i={blockedOn:l,domEventName:p,eventSystemFlags:k,nativeEvent:S,targetContainers:[b]},l!==null&&(l=Ac(l),l!==null&&Fn(l)),i):(i.eventSystemFlags|=k,l=i.targetContainers,b!==null&&l.indexOf(b)===-1&&l.push(b),i)}function qs(i,l,p,k,b){switch(l){case"focusin":return G=Mn(G,i,l,p,k,b),!0;case"dragenter":return ce=Mn(ce,i,l,p,k,b),!0;case"mouseover":return ve=Mn(ve,i,l,p,k,b),!0;case"pointerover":var S=b.pointerId;return Pe.set(S,Mn(Pe.get(S)||null,i,l,p,k,b)),!0;case"gotpointercapture":return S=b.pointerId,Te.set(S,Mn(Te.get(S)||null,i,l,p,k,b)),!0}return!1}function En(i){var l=Ji(i.target);if(l!==null){var p=Rn(l);if(p!==null){if(l=p.tag,l===13){if(l=fn(p),l!==null){i.blockedOn=l,dr(i.priority,function(){on(p)});return}}else if(l===3&&p.stateNode.current.memoizedState.isDehydrated){i.blockedOn=p.tag===3?p.stateNode.containerInfo:null;return}}}i.blockedOn=null}function Ui(i){if(i.blockedOn!==null)return!1;for(var l=i.targetContainers;0<l.length;){var p=Ys(i.domEventName,i.eventSystemFlags,l[0],i.nativeEvent);if(p===null){p=i.nativeEvent;var k=new p.constructor(p.type,p);ne=k,p.target.dispatchEvent(k),ne=null}else return l=Ac(p),l!==null&&Fn(l),i.blockedOn=p,!1;l.shift()}return!0}function Ua(i,l,p){Ui(i)&&p.delete(l)}function rd(){Ie=!1,G!==null&&Ui(G)&&(G=null),ce!==null&&Ui(ce)&&(ce=null),ve!==null&&Ui(ve)&&(ve=null),Pe.forEach(Ua),Te.forEach(Ua)}function Zs(i,l){i.blockedOn===l&&(i.blockedOn=null,Ie||(Ie=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,rd)))}function Hi(i){function l(b){return Zs(b,i)}if(0<U.length){Zs(U[0],i);for(var p=1;p<U.length;p++){var k=U[p];k.blockedOn===i&&(k.blockedOn=null)}}for(G!==null&&Zs(G,i),ce!==null&&Zs(ce,i),ve!==null&&Zs(ve,i),Pe.forEach(l),Te.forEach(l),p=0;p<$t.length;p++)k=$t[p],k.blockedOn===i&&(k.blockedOn=null);for(;0<$t.length&&(p=$t[0],p.blockedOn===null);)En(p),p.blockedOn===null&&$t.shift()}var Gs=j.ReactCurrentBatchConfig,Ha=!0;function Wa(i,l,p,k){var b=rn,S=Gs.transition;Gs.transition=null;try{rn=1,Vs(i,l,p,k)}finally{rn=b,Gs.transition=S}}function as(i,l,p,k){var b=rn,S=Gs.transition;Gs.transition=null;try{rn=4,Vs(i,l,p,k)}finally{rn=b,Gs.transition=S}}function Vs(i,l,p,k){if(Ha){var b=Ys(i,l,p,k);if(b===null)Bp(i,l,k,Wi,p),nr(i,k);else if(qs(b,i,l,p,k))k.stopPropagation();else if(nr(i,k),l&4&&-1<sn.indexOf(i)){for(;b!==null;){var S=Ac(b);if(S!==null&&ko(S),S=Ys(i,l,p,k),S===null&&Bp(i,l,k,Wi,p),S===b)break;b=S}b!==null&&k.stopPropagation()}else Bp(i,l,k,null,p)}}var Wi=null;function Ys(i,l,p,k){if(Wi=null,i=we(k),i=Ji(i),i!==null)if(l=Rn(i),l===null)i=null;else if(p=l.tag,p===13){if(i=fn(l),i!==null)return i;i=null}else if(p===3){if(l.stateNode.current.memoizedState.isDehydrated)return l.tag===3?l.stateNode.containerInfo:null;i=null}else l!==i&&(i=null);return Wi=i,null}function Ki(i){switch(i){case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 1;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"toggle":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 4;case"message":switch(ur()){case nn:return 1;case Bt:return 4;case Ft:case be:return 16;case Ye:return 536870912;default:return 16}default:return 16}}var Ko=null,Xs=null,qi=null;function Ka(){if(qi)return qi;var i,l=Xs,p=l.length,k,b="value"in Ko?Ko.value:Ko.textContent,S=b.length;for(i=0;i<p&&l[i]===b[i];i++);var O=p-i;for(k=1;k<=O&&l[p-k]===b[S-k];k++);return qi=b.slice(i,1<k?1-k:void 0)}function vr(i){var l=i.keyCode;return"charCode"in i?(i=i.charCode,i===0&&l===13&&(i=13)):i=l,i===10&&(i=13),32<=i||i===13?i:0}function qa(){return!0}function od(){return!1}function Zr(i){function l(p,k,b,S,O){this._reactName=p,this._targetInst=b,this.type=k,this.nativeEvent=S,this.target=O,this.currentTarget=null;for(var Y in i)i.hasOwnProperty(Y)&&(p=i[Y],this[Y]=p?p(S):S[Y]);return this.isDefaultPrevented=(S.defaultPrevented!=null?S.defaultPrevented:S.returnValue===!1)?qa:od,this.isPropagationStopped=od,this}return q(l.prototype,{preventDefault:function(){this.defaultPrevented=!0;var p=this.nativeEvent;p&&(p.preventDefault?p.preventDefault():typeof p.returnValue!="unknown"&&(p.returnValue=!1),this.isDefaultPrevented=qa)},stopPropagation:function(){var p=this.nativeEvent;p&&(p.stopPropagation?p.stopPropagation():typeof p.cancelBubble!="unknown"&&(p.cancelBubble=!0),this.isPropagationStopped=qa)},persist:function(){},isPersistent:qa}),l}var ls={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(i){return i.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Zi=Zr(ls),$o=q({},ls,{view:0,detail:0}),dc=Zr($o),Za,fc,bs,Ga=q({},$o,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Qs,button:0,buttons:0,relatedTarget:function(i){return i.relatedTarget===void 0?i.fromElement===i.srcElement?i.toElement:i.fromElement:i.relatedTarget},movementX:function(i){return"movementX"in i?i.movementX:(i!==bs&&(bs&&i.type==="mousemove"?(Za=i.screenX-bs.screenX,fc=i.screenY-bs.screenY):fc=Za=0,bs=i),Za)},movementY:function(i){return"movementY"in i?i.movementY:fc}}),hc=Zr(Ga),Rp=q({},Ga,{dataTransfer:0}),sd=Zr(Rp),Op=q({},$o,{relatedTarget:0}),Va=Zr(Op),Dr=q({},ls,{animationName:0,elapsedTime:0,pseudoElement:0}),id=Zr(Dr),ad=q({},ls,{clipboardData:function(i){return"clipboardData"in i?i.clipboardData:window.clipboardData}}),Ya=Zr(ad),Mp=q({},ls,{data:0}),Xa=Zr(Mp),pc={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Qa={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},Bn={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function ld(i){var l=this.nativeEvent;return l.getModifierState?l.getModifierState(i):(i=Bn[i])?!!l[i]:!1}function Qs(){return ld}var mc=q({},$o,{key:function(i){if(i.key){var l=pc[i.key]||i.key;if(l!=="Unidentified")return l}return i.type==="keypress"?(i=vr(i),i===13?"Enter":String.fromCharCode(i)):i.type==="keydown"||i.type==="keyup"?Qa[i.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Qs,charCode:function(i){return i.type==="keypress"?vr(i):0},keyCode:function(i){return i.type==="keydown"||i.type==="keyup"?i.keyCode:0},which:function(i){return i.type==="keypress"?vr(i):i.type==="keydown"||i.type==="keyup"?i.keyCode:0}}),Ja=Zr(mc),el=q({},Ga,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),xs=Zr(el),cd=q({},$o,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Qs}),gc=Zr(cd),kc=q({},ls,{propertyName:0,elapsedTime:0,pseudoElement:0}),ud=Zr(kc),cv=q({},Ga,{deltaX:function(i){return"deltaX"in i?i.deltaX:"wheelDeltaX"in i?-i.wheelDeltaX:0},deltaY:function(i){return"deltaY"in i?i.deltaY:"wheelDeltaY"in i?-i.wheelDeltaY:"wheelDelta"in i?-i.wheelDelta:0},deltaZ:0,deltaMode:0}),dd=Zr(cv),tl=[9,13,27,32],nl=c&&"CompositionEvent"in window,Js=null;c&&"documentMode"in document&&(Js=document.documentMode);var fd=c&&"TextEvent"in window&&!Js,fr=c&&(!nl||Js&&8<Js&&11>=Js),Gi=" ",hd=!1;function Vi(i,l){switch(i){case"keyup":return tl.indexOf(l.keyCode)!==-1;case"keydown":return l.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function wc(i){return i=i.detail,typeof i=="object"&&"data"in i?i.data:null}var Co=!1;function Yi(i,l){switch(i){case"compositionend":return wc(l);case"keypress":return l.which!==32?null:(hd=!0,Gi);case"textInput":return i=l.data,i===Gi&&hd?null:i;default:return null}}function yc(i,l){if(Co)return i==="compositionend"||!nl&&Vi(i,l)?(i=Ka(),qi=Xs=Ko=null,Co=!1,i):null;switch(i){case"paste":return null;case"keypress":if(!(l.ctrlKey||l.altKey||l.metaKey)||l.ctrlKey&&l.altKey){if(l.char&&1<l.char.length)return l.char;if(l.which)return String.fromCharCode(l.which)}return null;case"compositionend":return fr&&l.locale!=="ko"?null:l.data;default:return null}}var Lp={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function rl(i){var l=i&&i.nodeName&&i.nodeName.toLowerCase();return l==="input"?!!Lp[i.type]:l==="textarea"}function pd(i,l,p,k){P(k),l=_d(l,"onChange"),0<l.length&&(p=new Zi("onChange","change",null,p,k),i.push({event:p,listeners:l}))}var ei=null,ti=null;function md(i){dv(i,0)}function Xi(i){var l=ul(i);if(ie(l))return i}function Io(i,l){if(i==="change")return l}var gd=!1;if(c){var qo;if(c){var ni="oninput"in document;if(!ni){var kd=document.createElement("div");kd.setAttribute("oninput","return;"),ni=typeof kd.oninput=="function"}qo=ni}else qo=!1;gd=qo&&(!document.documentMode||9<document.documentMode)}function Qi(){ei&&(ei.detachEvent("onpropertychange",ol),ti=ei=null)}function ol(i){if(i.propertyName==="value"&&Xi(ti)){var l=[];pd(l,ti,i,we(i)),Zt(md,l)}}function vc(i,l,p){i==="focusin"?(Qi(),ei=l,ti=p,ei.attachEvent("onpropertychange",ol)):i==="focusout"&&Qi()}function wd(i){if(i==="selectionchange"||i==="keyup"||i==="keydown")return Xi(ti)}function Pp(i,l){if(i==="click")return Xi(l)}function bc(i,l){if(i==="input"||i==="change")return Xi(l)}function yd(i,l){return i===l&&(i!==0||1/i===1/l)||i!==i&&l!==l}var eo=typeof Object.is=="function"?Object.is:yd;function ri(i,l){if(eo(i,l))return!0;if(typeof i!="object"||i===null||typeof l!="object"||l===null)return!1;var p=Object.keys(i),k=Object.keys(l);if(p.length!==k.length)return!1;for(k=0;k<p.length;k++){var b=p[k];if(!u.call(l,b)||!eo(i[b],l[b]))return!1}return!0}function vd(i){for(;i&&i.firstChild;)i=i.firstChild;return i}function xc(i,l){var p=vd(i);i=0;for(var k;p;){if(p.nodeType===3){if(k=i+p.textContent.length,i<=l&&k>=l)return{node:p,offset:l-i};i=k}e:{for(;p;){if(p.nextSibling){p=p.nextSibling;break e}p=p.parentNode}p=void 0}p=vd(p)}}function Ec(i,l){return i&&l?i===l?!0:i&&i.nodeType===3?!1:l&&l.nodeType===3?Ec(i,l.parentNode):"contains"in i?i.contains(l):i.compareDocumentPosition?!!(i.compareDocumentPosition(l)&16):!1:!1}function Sc(){for(var i=window,l=ye();l instanceof i.HTMLIFrameElement;){try{var p=typeof l.contentWindow.location.href=="string"}catch{p=!1}if(p)i=l.contentWindow;else break;l=ye(i.document)}return l}function sl(i){var l=i&&i.nodeName&&i.nodeName.toLowerCase();return l&&(l==="input"&&(i.type==="text"||i.type==="search"||i.type==="tel"||i.type==="url"||i.type==="password")||l==="textarea"||i.contentEditable==="true")}function bd(i){var l=Sc(),p=i.focusedElem,k=i.selectionRange;if(l!==p&&p&&p.ownerDocument&&Ec(p.ownerDocument.documentElement,p)){if(k!==null&&sl(p)){if(l=k.start,i=k.end,i===void 0&&(i=l),"selectionStart"in p)p.selectionStart=l,p.selectionEnd=Math.min(i,p.value.length);else if(i=(l=p.ownerDocument||document)&&l.defaultView||window,i.getSelection){i=i.getSelection();var b=p.textContent.length,S=Math.min(k.start,b);k=k.end===void 0?S:Math.min(k.end,b),!i.extend&&S>k&&(b=k,k=S,S=b),b=xc(p,S);var O=xc(p,k);b&&O&&(i.rangeCount!==1||i.anchorNode!==b.node||i.anchorOffset!==b.offset||i.focusNode!==O.node||i.focusOffset!==O.offset)&&(l=l.createRange(),l.setStart(b.node,b.offset),i.removeAllRanges(),S>k?(i.addRange(l),i.extend(O.node,O.offset)):(l.setEnd(O.node,O.offset),i.addRange(l)))}}for(l=[],i=p;i=i.parentNode;)i.nodeType===1&&l.push({element:i,left:i.scrollLeft,top:i.scrollTop});for(typeof p.focus=="function"&&p.focus(),p=0;p<l.length;p++)i=l[p],i.element.scrollLeft=i.left,i.element.scrollTop=i.top}}var xd=c&&"documentMode"in document&&11>=document.documentMode,Es=null,il=null,oi=null,al=!1;function _c(i,l,p){var k=p.window===p?p.document:p.nodeType===9?p:p.ownerDocument;al||Es==null||Es!==ye(k)||(k=Es,"selectionStart"in k&&sl(k)?k={start:k.selectionStart,end:k.selectionEnd}:(k=(k.ownerDocument&&k.ownerDocument.defaultView||window).getSelection(),k={anchorNode:k.anchorNode,anchorOffset:k.anchorOffset,focusNode:k.focusNode,focusOffset:k.focusOffset}),oi&&ri(oi,k)||(oi=k,k=_d(il,"onSelect"),0<k.length&&(l=new Zi("onSelect","select",null,l,p),i.push({event:l,listeners:k}),l.target=Es)))}function z(i,l){var p={};return p[i.toLowerCase()]=l.toLowerCase(),p["Webkit"+i]="webkit"+l,p["Moz"+i]="moz"+l,p}var $e={animationend:z("Animation","AnimationEnd"),animationiteration:z("Animation","AnimationIteration"),animationstart:z("Animation","AnimationStart"),transitionend:z("Transition","TransitionEnd")},ft={},Nt={};c&&(Nt=document.createElement("div").style,"AnimationEvent"in window||(delete $e.animationend.animation,delete $e.animationiteration.animation,delete $e.animationstart.animation),"TransitionEvent"in window||delete $e.transitionend.transition);function Gn(i){if(ft[i])return ft[i];if(!$e[i])return i;var l=$e[i],p;for(p in l)if(l.hasOwnProperty(p)&&p in Nt)return ft[i]=l[p];return i}var rr=Gn("animationend"),si=Gn("animationiteration"),Nc=Gn("animationstart"),wo=Gn("transitionend"),Ed=new Map,jc="abort auxClick cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");function ii(i,l){Ed.set(i,l),s(l,[i])}for(var Dp=0;Dp<jc.length;Dp++){var zp=jc[Dp],XC=zp.toLowerCase(),QC=zp[0].toUpperCase()+zp.slice(1);ii(XC,"on"+QC)}ii(rr,"onAnimationEnd"),ii(si,"onAnimationIteration"),ii(Nc,"onAnimationStart"),ii("dblclick","onDoubleClick"),ii("focusin","onFocus"),ii("focusout","onBlur"),ii(wo,"onTransitionEnd"),a("onMouseEnter",["mouseout","mouseover"]),a("onMouseLeave",["mouseout","mouseover"]),a("onPointerEnter",["pointerout","pointerover"]),a("onPointerLeave",["pointerout","pointerover"]),s("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),s("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),s("onBeforeInput",["compositionend","keypress","textInput","paste"]),s("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),s("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),s("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Tc="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),JC=new Set("cancel close invalid load scroll toggle".split(" ").concat(Tc));function uv(i,l,p){var k=i.type||"unknown-event";i.currentTarget=p,Gt(k,l,void 0,i),i.currentTarget=null}function dv(i,l){l=(l&4)!==0;for(var p=0;p<i.length;p++){var k=i[p],b=k.event;k=k.listeners;e:{var S=void 0;if(l)for(var O=k.length-1;0<=O;O--){var Y=k[O],re=Y.instance,ke=Y.currentTarget;if(Y=Y.listener,re!==S&&b.isPropagationStopped())break e;uv(b,Y,ke),S=re}else for(O=0;O<k.length;O++){if(Y=k[O],re=Y.instance,ke=Y.currentTarget,Y=Y.listener,re!==S&&b.isPropagationStopped())break e;uv(b,Y,ke),S=re}}}if(xn)throw i=Ct,xn=!1,Ct=null,i}function Un(i,l){var p=l[Zp];p===void 0&&(p=l[Zp]=new Set);var k=i+"__bubble";p.has(k)||(fv(l,i,2,!1),p.add(k))}function Fp(i,l,p){var k=0;l&&(k|=4),fv(p,i,k,l)}var Sd="_reactListening"+Math.random().toString(36).slice(2);function $c(i){if(!i[Sd]){i[Sd]=!0,r.forEach(function(p){p!=="selectionchange"&&(JC.has(p)||Fp(p,!1,i),Fp(p,!0,i))});var l=i.nodeType===9?i:i.ownerDocument;l===null||l[Sd]||(l[Sd]=!0,Fp("selectionchange",!1,l))}}function fv(i,l,p,k){switch(Ki(l)){case 1:var b=Wa;break;case 4:b=as;break;default:b=Vs}p=b.bind(null,l,p,i),b=void 0,!We||l!=="touchstart"&&l!=="touchmove"&&l!=="wheel"||(b=!0),k?b!==void 0?i.addEventListener(l,p,{capture:!0,passive:b}):i.addEventListener(l,p,!0):b!==void 0?i.addEventListener(l,p,{passive:b}):i.addEventListener(l,p,!1)}function Bp(i,l,p,k,b){var S=k;if((l&1)===0&&(l&2)===0&&k!==null)e:for(;;){if(k===null)return;var O=k.tag;if(O===3||O===4){var Y=k.stateNode.containerInfo;if(Y===b||Y.nodeType===8&&Y.parentNode===b)break;if(O===4)for(O=k.return;O!==null;){var re=O.tag;if((re===3||re===4)&&(re=O.stateNode.containerInfo,re===b||re.nodeType===8&&re.parentNode===b))return;O=O.return}for(;Y!==null;){if(O=Ji(Y),O===null)return;if(re=O.tag,re===5||re===6){k=S=O;continue e}Y=Y.parentNode}}k=k.return}Zt(function(){var ke=S,Re=we(p),ze=[];e:{var Ce=Ed.get(i);if(Ce!==void 0){var Xe=Zi,st=i;switch(i){case"keypress":if(vr(p)===0)break e;case"keydown":case"keyup":Xe=Ja;break;case"focusin":st="focus",Xe=Va;break;case"focusout":st="blur",Xe=Va;break;case"beforeblur":case"afterblur":Xe=Va;break;case"click":if(p.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":Xe=hc;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":Xe=sd;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":Xe=gc;break;case rr:case si:case Nc:Xe=id;break;case wo:Xe=ud;break;case"scroll":Xe=dc;break;case"wheel":Xe=dd;break;case"copy":case"cut":case"paste":Xe=Ya;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":Xe=xs}var it=(l&4)!==0,ar=!it&&i==="scroll",fe=it?Ce!==null?Ce+"Capture":null:Ce;it=[];for(var le=ke,me;le!==null;){me=le;var He=me.stateNode;if(me.tag===5&&He!==null&&(me=He,fe!==null&&(He=Ae(le,fe),He!=null&&it.push(Cc(le,He,me)))),ar)break;le=le.return}0<it.length&&(Ce=new Xe(Ce,st,null,p,Re),ze.push({event:Ce,listeners:it}))}}if((l&7)===0){e:{if(Ce=i==="mouseover"||i==="pointerover",Xe=i==="mouseout"||i==="pointerout",Ce&&p!==ne&&(st=p.relatedTarget||p.fromElement)&&(Ji(st)||st[Ss]))break e;if((Xe||Ce)&&(Ce=Re.window===Re?Re:(Ce=Re.ownerDocument)?Ce.defaultView||Ce.parentWindow:window,Xe?(st=p.relatedTarget||p.toElement,Xe=ke,st=st?Ji(st):null,st!==null&&(ar=Rn(st),st!==ar||st.tag!==5&&st.tag!==6)&&(st=null)):(Xe=null,st=ke),Xe!==st)){if(it=hc,He="onMouseLeave",fe="onMouseEnter",le="mouse",(i==="pointerout"||i==="pointerover")&&(it=xs,He="onPointerLeave",fe="onPointerEnter",le="pointer"),ar=Xe==null?Ce:ul(Xe),me=st==null?Ce:ul(st),Ce=new it(He,le+"leave",Xe,p,Re),Ce.target=ar,Ce.relatedTarget=me,He=null,Ji(Re)===ke&&(it=new it(fe,le+"enter",st,p,Re),it.target=me,it.relatedTarget=ar,He=it),ar=He,Xe&&st)t:{for(it=Xe,fe=st,le=0,me=it;me;me=ll(me))le++;for(me=0,He=fe;He;He=ll(He))me++;for(;0<le-me;)it=ll(it),le--;for(;0<me-le;)fe=ll(fe),me--;for(;le--;){if(it===fe||fe!==null&&it===fe.alternate)break t;it=ll(it),fe=ll(fe)}it=null}else it=null;Xe!==null&&hv(ze,Ce,Xe,it,!1),st!==null&&ar!==null&&hv(ze,ar,st,it,!0)}}e:{if(Ce=ke?ul(ke):window,Xe=Ce.nodeName&&Ce.nodeName.toLowerCase(),Xe==="select"||Xe==="input"&&Ce.type==="file")var ut=Io;else if(rl(Ce))if(gd)ut=bc;else{ut=wd;var Et=vc}else(Xe=Ce.nodeName)&&Xe.toLowerCase()==="input"&&(Ce.type==="checkbox"||Ce.type==="radio")&&(ut=Pp);if(ut&&(ut=ut(i,ke))){pd(ze,ut,p,Re);break e}Et&&Et(i,Ce,ke),i==="focusout"&&(Et=Ce._wrapperState)&&Et.controlled&&Ce.type==="number"&&Ht(Ce,"number",Ce.value)}switch(Et=ke?ul(ke):window,i){case"focusin":(rl(Et)||Et.contentEditable==="true")&&(Es=Et,il=ke,oi=null);break;case"focusout":oi=il=Es=null;break;case"mousedown":al=!0;break;case"contextmenu":case"mouseup":case"dragend":al=!1,_c(ze,p,Re);break;case"selectionchange":if(xd)break;case"keydown":case"keyup":_c(ze,p,Re)}var St;if(nl)e:{switch(i){case"compositionstart":var Ot="onCompositionStart";break e;case"compositionend":Ot="onCompositionEnd";break e;case"compositionupdate":Ot="onCompositionUpdate";break e}Ot=void 0}else Co?Vi(i,p)&&(Ot="onCompositionEnd"):i==="keydown"&&p.keyCode===229&&(Ot="onCompositionStart");Ot&&(fr&&p.locale!=="ko"&&(Co||Ot!=="onCompositionStart"?Ot==="onCompositionEnd"&&Co&&(St=Ka()):(Ko=Re,Xs="value"in Ko?Ko.value:Ko.textContent,Co=!0)),Et=_d(ke,Ot),0<Et.length&&(Ot=new Xa(Ot,i,null,p,Re),ze.push({event:Ot,listeners:Et}),St?Ot.data=St:(St=wc(p),St!==null&&(Ot.data=St)))),(St=fd?Yi(i,p):yc(i,p))&&(ke=_d(ke,"onBeforeInput"),0<ke.length&&(Re=new Xa("onBeforeInput","beforeinput",null,p,Re),ze.push({event:Re,listeners:ke}),Re.data=St))}dv(ze,l)})}function Cc(i,l,p){return{instance:i,listener:l,currentTarget:p}}function _d(i,l){for(var p=l+"Capture",k=[];i!==null;){var b=i,S=b.stateNode;b.tag===5&&S!==null&&(b=S,S=Ae(i,p),S!=null&&k.unshift(Cc(i,S,b)),S=Ae(i,l),S!=null&&k.push(Cc(i,S,b))),i=i.return}return k}function ll(i){if(i===null)return null;do i=i.return;while(i&&i.tag!==5);return i||null}function hv(i,l,p,k,b){for(var S=l._reactName,O=[];p!==null&&p!==k;){var Y=p,re=Y.alternate,ke=Y.stateNode;if(re!==null&&re===k)break;Y.tag===5&&ke!==null&&(Y=ke,b?(re=Ae(p,S),re!=null&&O.unshift(Cc(p,re,Y))):b||(re=Ae(p,S),re!=null&&O.push(Cc(p,re,Y)))),p=p.return}O.length!==0&&i.push({event:l,listeners:O})}var eI=/\r\n?/g,tI=/\u0000|\uFFFD/g;function pv(i){return(typeof i=="string"?i:""+i).replace(eI,`
39
- `).replace(tI,"")}function Nd(i,l,p){if(l=pv(l),pv(i)!==l&&p)throw Error(n(425))}function jd(){}var Up=null,Hp=null;function Wp(i,l){return i==="textarea"||i==="noscript"||typeof l.children=="string"||typeof l.children=="number"||typeof l.dangerouslySetInnerHTML=="object"&&l.dangerouslySetInnerHTML!==null&&l.dangerouslySetInnerHTML.__html!=null}var Kp=typeof setTimeout=="function"?setTimeout:void 0,nI=typeof clearTimeout=="function"?clearTimeout:void 0,mv=typeof Promise=="function"?Promise:void 0,rI=typeof queueMicrotask=="function"?queueMicrotask:typeof mv<"u"?function(i){return mv.resolve(null).then(i).catch(oI)}:Kp;function oI(i){setTimeout(function(){throw i})}function qp(i,l){var p=l,k=0;do{var b=p.nextSibling;if(i.removeChild(p),b&&b.nodeType===8)if(p=b.data,p==="/$"){if(k===0){i.removeChild(b),Hi(l);return}k--}else p!=="$"&&p!=="$?"&&p!=="$!"||k++;p=b}while(p);Hi(l)}function ai(i){for(;i!=null;i=i.nextSibling){var l=i.nodeType;if(l===1||l===3)break;if(l===8){if(l=i.data,l==="$"||l==="$!"||l==="$?")break;if(l==="/$")return null}}return i}function gv(i){i=i.previousSibling;for(var l=0;i;){if(i.nodeType===8){var p=i.data;if(p==="$"||p==="$!"||p==="$?"){if(l===0)return i;l--}else p==="/$"&&l++}i=i.previousSibling}return null}var cl=Math.random().toString(36).slice(2),cs="__reactFiber$"+cl,Ic="__reactProps$"+cl,Ss="__reactContainer$"+cl,Zp="__reactEvents$"+cl,sI="__reactListeners$"+cl,iI="__reactHandles$"+cl;function Ji(i){var l=i[cs];if(l)return l;for(var p=i.parentNode;p;){if(l=p[Ss]||p[cs]){if(p=l.alternate,l.child!==null||p!==null&&p.child!==null)for(i=gv(i);i!==null;){if(p=i[cs])return p;i=gv(i)}return l}i=p,p=i.parentNode}return null}function Ac(i){return i=i[cs]||i[Ss],!i||i.tag!==5&&i.tag!==6&&i.tag!==13&&i.tag!==3?null:i}function ul(i){if(i.tag===5||i.tag===6)return i.stateNode;throw Error(n(33))}function Td(i){return i[Ic]||null}var Gp=[],dl=-1;function li(i){return{current:i}}function Hn(i){0>dl||(i.current=Gp[dl],Gp[dl]=null,dl--)}function Ln(i,l){dl++,Gp[dl]=i.current,i.current=l}var ci={},zr=li(ci),to=li(!1),ea=ci;function fl(i,l){var p=i.type.contextTypes;if(!p)return ci;var k=i.stateNode;if(k&&k.__reactInternalMemoizedUnmaskedChildContext===l)return k.__reactInternalMemoizedMaskedChildContext;var b={},S;for(S in p)b[S]=l[S];return k&&(i=i.stateNode,i.__reactInternalMemoizedUnmaskedChildContext=l,i.__reactInternalMemoizedMaskedChildContext=b),b}function no(i){return i=i.childContextTypes,i!=null}function $d(){Hn(to),Hn(zr)}function kv(i,l,p){if(zr.current!==ci)throw Error(n(168));Ln(zr,l),Ln(to,p)}function wv(i,l,p){var k=i.stateNode;if(l=l.childContextTypes,typeof k.getChildContext!="function")return p;k=k.getChildContext();for(var b in k)if(!(b in l))throw Error(n(108,Be(i)||"Unknown",b));return q({},p,k)}function Cd(i){return i=(i=i.stateNode)&&i.__reactInternalMemoizedMergedChildContext||ci,ea=zr.current,Ln(zr,i),Ln(to,to.current),!0}function yv(i,l,p){var k=i.stateNode;if(!k)throw Error(n(169));p?(i=wv(i,l,ea),k.__reactInternalMemoizedMergedChildContext=i,Hn(to),Hn(zr),Ln(zr,i)):Hn(to),Ln(to,p)}var _s=null,Id=!1,Vp=!1;function vv(i){_s===null?_s=[i]:_s.push(i)}function aI(i){Id=!0,vv(i)}function ui(){if(!Vp&&_s!==null){Vp=!0;var i=0,l=rn;try{var p=_s;for(rn=1;i<p.length;i++){var k=p[i];do k=k(!0);while(k!==null)}_s=null,Id=!1}catch(b){throw _s!==null&&(_s=_s.slice(i+1)),zt(nn,ui),b}finally{rn=l,Vp=!1}}return null}var hl=[],pl=0,Ad=null,Rd=0,Ao=[],Ro=0,ta=null,Ns=1,js="";function na(i,l){hl[pl++]=Rd,hl[pl++]=Ad,Ad=i,Rd=l}function bv(i,l,p){Ao[Ro++]=Ns,Ao[Ro++]=js,Ao[Ro++]=ta,ta=i;var k=Ns;i=js;var b=32-hn(k)-1;k&=~(1<<b),p+=1;var S=32-hn(l)+b;if(30<S){var O=b-b%5;S=(k&(1<<O)-1).toString(32),k>>=O,b-=O,Ns=1<<32-hn(l)+b|p<<b|k,js=S+i}else Ns=1<<S|p<<b|k,js=i}function Yp(i){i.return!==null&&(na(i,1),bv(i,1,0))}function Xp(i){for(;i===Ad;)Ad=hl[--pl],hl[pl]=null,Rd=hl[--pl],hl[pl]=null;for(;i===ta;)ta=Ao[--Ro],Ao[Ro]=null,js=Ao[--Ro],Ao[Ro]=null,Ns=Ao[--Ro],Ao[Ro]=null}var yo=null,vo=null,Vn=!1,Zo=null;function xv(i,l){var p=Po(5,null,null,0);p.elementType="DELETED",p.stateNode=l,p.return=i,l=i.deletions,l===null?(i.deletions=[p],i.flags|=16):l.push(p)}function Ev(i,l){switch(i.tag){case 5:var p=i.type;return l=l.nodeType!==1||p.toLowerCase()!==l.nodeName.toLowerCase()?null:l,l!==null?(i.stateNode=l,yo=i,vo=ai(l.firstChild),!0):!1;case 6:return l=i.pendingProps===""||l.nodeType!==3?null:l,l!==null?(i.stateNode=l,yo=i,vo=null,!0):!1;case 13:return l=l.nodeType!==8?null:l,l!==null?(p=ta!==null?{id:Ns,overflow:js}:null,i.memoizedState={dehydrated:l,treeContext:p,retryLane:1073741824},p=Po(18,null,null,0),p.stateNode=l,p.return=i,i.child=p,yo=i,vo=null,!0):!1;default:return!1}}function Qp(i){return(i.mode&1)!==0&&(i.flags&128)===0}function Jp(i){if(Vn){var l=vo;if(l){var p=l;if(!Ev(i,l)){if(Qp(i))throw Error(n(418));l=ai(p.nextSibling);var k=yo;l&&Ev(i,l)?xv(k,p):(i.flags=i.flags&-4097|2,Vn=!1,yo=i)}}else{if(Qp(i))throw Error(n(418));i.flags=i.flags&-4097|2,Vn=!1,yo=i}}}function Sv(i){for(i=i.return;i!==null&&i.tag!==5&&i.tag!==3&&i.tag!==13;)i=i.return;yo=i}function Od(i){if(i!==yo)return!1;if(!Vn)return Sv(i),Vn=!0,!1;var l;if((l=i.tag!==3)&&!(l=i.tag!==5)&&(l=i.type,l=l!=="head"&&l!=="body"&&!Wp(i.type,i.memoizedProps)),l&&(l=vo)){if(Qp(i))throw _v(),Error(n(418));for(;l;)xv(i,l),l=ai(l.nextSibling)}if(Sv(i),i.tag===13){if(i=i.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(n(317));e:{for(i=i.nextSibling,l=0;i;){if(i.nodeType===8){var p=i.data;if(p==="/$"){if(l===0){vo=ai(i.nextSibling);break e}l--}else p!=="$"&&p!=="$!"&&p!=="$?"||l++}i=i.nextSibling}vo=null}}else vo=yo?ai(i.stateNode.nextSibling):null;return!0}function _v(){for(var i=vo;i;)i=ai(i.nextSibling)}function ml(){vo=yo=null,Vn=!1}function em(i){Zo===null?Zo=[i]:Zo.push(i)}var lI=j.ReactCurrentBatchConfig;function Rc(i,l,p){if(i=p.ref,i!==null&&typeof i!="function"&&typeof i!="object"){if(p._owner){if(p=p._owner,p){if(p.tag!==1)throw Error(n(309));var k=p.stateNode}if(!k)throw Error(n(147,i));var b=k,S=""+i;return l!==null&&l.ref!==null&&typeof l.ref=="function"&&l.ref._stringRef===S?l.ref:(l=function(O){var Y=b.refs;O===null?delete Y[S]:Y[S]=O},l._stringRef=S,l)}if(typeof i!="string")throw Error(n(284));if(!p._owner)throw Error(n(290,i))}return i}function Md(i,l){throw i=Object.prototype.toString.call(l),Error(n(31,i==="[object Object]"?"object with keys {"+Object.keys(l).join(", ")+"}":i))}function Nv(i){var l=i._init;return l(i._payload)}function jv(i){function l(fe,le){if(i){var me=fe.deletions;me===null?(fe.deletions=[le],fe.flags|=16):me.push(le)}}function p(fe,le){if(!i)return null;for(;le!==null;)l(fe,le),le=le.sibling;return null}function k(fe,le){for(fe=new Map;le!==null;)le.key!==null?fe.set(le.key,le):fe.set(le.index,le),le=le.sibling;return fe}function b(fe,le){return fe=wi(fe,le),fe.index=0,fe.sibling=null,fe}function S(fe,le,me){return fe.index=me,i?(me=fe.alternate,me!==null?(me=me.index,me<le?(fe.flags|=2,le):me):(fe.flags|=2,le)):(fe.flags|=1048576,le)}function O(fe){return i&&fe.alternate===null&&(fe.flags|=2),fe}function Y(fe,le,me,He){return le===null||le.tag!==6?(le=Km(me,fe.mode,He),le.return=fe,le):(le=b(le,me),le.return=fe,le)}function re(fe,le,me,He){var ut=me.type;return ut===C?Re(fe,le,me.props.children,He,me.key):le!==null&&(le.elementType===ut||typeof ut=="object"&&ut!==null&&ut.$$typeof===ee&&Nv(ut)===le.type)?(He=b(le,me.props),He.ref=Rc(fe,le,me),He.return=fe,He):(He=sf(me.type,me.key,me.props,null,fe.mode,He),He.ref=Rc(fe,le,me),He.return=fe,He)}function ke(fe,le,me,He){return le===null||le.tag!==4||le.stateNode.containerInfo!==me.containerInfo||le.stateNode.implementation!==me.implementation?(le=qm(me,fe.mode,He),le.return=fe,le):(le=b(le,me.children||[]),le.return=fe,le)}function Re(fe,le,me,He,ut){return le===null||le.tag!==7?(le=ua(me,fe.mode,He,ut),le.return=fe,le):(le=b(le,me),le.return=fe,le)}function ze(fe,le,me){if(typeof le=="string"&&le!==""||typeof le=="number")return le=Km(""+le,fe.mode,me),le.return=fe,le;if(typeof le=="object"&&le!==null){switch(le.$$typeof){case A:return me=sf(le.type,le.key,le.props,null,fe.mode,me),me.ref=Rc(fe,null,le),me.return=fe,me;case R:return le=qm(le,fe.mode,me),le.return=fe,le;case ee:var He=le._init;return ze(fe,He(le._payload),me)}if(qt(le)||Q(le))return le=ua(le,fe.mode,me,null),le.return=fe,le;Md(fe,le)}return null}function Ce(fe,le,me,He){var ut=le!==null?le.key:null;if(typeof me=="string"&&me!==""||typeof me=="number")return ut!==null?null:Y(fe,le,""+me,He);if(typeof me=="object"&&me!==null){switch(me.$$typeof){case A:return me.key===ut?re(fe,le,me,He):null;case R:return me.key===ut?ke(fe,le,me,He):null;case ee:return ut=me._init,Ce(fe,le,ut(me._payload),He)}if(qt(me)||Q(me))return ut!==null?null:Re(fe,le,me,He,null);Md(fe,me)}return null}function Xe(fe,le,me,He,ut){if(typeof He=="string"&&He!==""||typeof He=="number")return fe=fe.get(me)||null,Y(le,fe,""+He,ut);if(typeof He=="object"&&He!==null){switch(He.$$typeof){case A:return fe=fe.get(He.key===null?me:He.key)||null,re(le,fe,He,ut);case R:return fe=fe.get(He.key===null?me:He.key)||null,ke(le,fe,He,ut);case ee:var Et=He._init;return Xe(fe,le,me,Et(He._payload),ut)}if(qt(He)||Q(He))return fe=fe.get(me)||null,Re(le,fe,He,ut,null);Md(le,He)}return null}function st(fe,le,me,He){for(var ut=null,Et=null,St=le,Ot=le=0,jr=null;St!==null&&Ot<me.length;Ot++){St.index>Ot?(jr=St,St=null):jr=St.sibling;var wn=Ce(fe,St,me[Ot],He);if(wn===null){St===null&&(St=jr);break}i&&St&&wn.alternate===null&&l(fe,St),le=S(wn,le,Ot),Et===null?ut=wn:Et.sibling=wn,Et=wn,St=jr}if(Ot===me.length)return p(fe,St),Vn&&na(fe,Ot),ut;if(St===null){for(;Ot<me.length;Ot++)St=ze(fe,me[Ot],He),St!==null&&(le=S(St,le,Ot),Et===null?ut=St:Et.sibling=St,Et=St);return Vn&&na(fe,Ot),ut}for(St=k(fe,St);Ot<me.length;Ot++)jr=Xe(St,fe,Ot,me[Ot],He),jr!==null&&(i&&jr.alternate!==null&&St.delete(jr.key===null?Ot:jr.key),le=S(jr,le,Ot),Et===null?ut=jr:Et.sibling=jr,Et=jr);return i&&St.forEach(function(yi){return l(fe,yi)}),Vn&&na(fe,Ot),ut}function it(fe,le,me,He){var ut=Q(me);if(typeof ut!="function")throw Error(n(150));if(me=ut.call(me),me==null)throw Error(n(151));for(var Et=ut=null,St=le,Ot=le=0,jr=null,wn=me.next();St!==null&&!wn.done;Ot++,wn=me.next()){St.index>Ot?(jr=St,St=null):jr=St.sibling;var yi=Ce(fe,St,wn.value,He);if(yi===null){St===null&&(St=jr);break}i&&St&&yi.alternate===null&&l(fe,St),le=S(yi,le,Ot),Et===null?ut=yi:Et.sibling=yi,Et=yi,St=jr}if(wn.done)return p(fe,St),Vn&&na(fe,Ot),ut;if(St===null){for(;!wn.done;Ot++,wn=me.next())wn=ze(fe,wn.value,He),wn!==null&&(le=S(wn,le,Ot),Et===null?ut=wn:Et.sibling=wn,Et=wn);return Vn&&na(fe,Ot),ut}for(St=k(fe,St);!wn.done;Ot++,wn=me.next())wn=Xe(St,fe,Ot,wn.value,He),wn!==null&&(i&&wn.alternate!==null&&St.delete(wn.key===null?Ot:wn.key),le=S(wn,le,Ot),Et===null?ut=wn:Et.sibling=wn,Et=wn);return i&&St.forEach(function(BI){return l(fe,BI)}),Vn&&na(fe,Ot),ut}function ar(fe,le,me,He){if(typeof me=="object"&&me!==null&&me.type===C&&me.key===null&&(me=me.props.children),typeof me=="object"&&me!==null){switch(me.$$typeof){case A:e:{for(var ut=me.key,Et=le;Et!==null;){if(Et.key===ut){if(ut=me.type,ut===C){if(Et.tag===7){p(fe,Et.sibling),le=b(Et,me.props.children),le.return=fe,fe=le;break e}}else if(Et.elementType===ut||typeof ut=="object"&&ut!==null&&ut.$$typeof===ee&&Nv(ut)===Et.type){p(fe,Et.sibling),le=b(Et,me.props),le.ref=Rc(fe,Et,me),le.return=fe,fe=le;break e}p(fe,Et);break}else l(fe,Et);Et=Et.sibling}me.type===C?(le=ua(me.props.children,fe.mode,He,me.key),le.return=fe,fe=le):(He=sf(me.type,me.key,me.props,null,fe.mode,He),He.ref=Rc(fe,le,me),He.return=fe,fe=He)}return O(fe);case R:e:{for(Et=me.key;le!==null;){if(le.key===Et)if(le.tag===4&&le.stateNode.containerInfo===me.containerInfo&&le.stateNode.implementation===me.implementation){p(fe,le.sibling),le=b(le,me.children||[]),le.return=fe,fe=le;break e}else{p(fe,le);break}else l(fe,le);le=le.sibling}le=qm(me,fe.mode,He),le.return=fe,fe=le}return O(fe);case ee:return Et=me._init,ar(fe,le,Et(me._payload),He)}if(qt(me))return st(fe,le,me,He);if(Q(me))return it(fe,le,me,He);Md(fe,me)}return typeof me=="string"&&me!==""||typeof me=="number"?(me=""+me,le!==null&&le.tag===6?(p(fe,le.sibling),le=b(le,me),le.return=fe,fe=le):(p(fe,le),le=Km(me,fe.mode,He),le.return=fe,fe=le),O(fe)):p(fe,le)}return ar}var gl=jv(!0),Tv=jv(!1),Ld=li(null),Pd=null,kl=null,tm=null;function nm(){tm=kl=Pd=null}function rm(i){var l=Ld.current;Hn(Ld),i._currentValue=l}function om(i,l,p){for(;i!==null;){var k=i.alternate;if((i.childLanes&l)!==l?(i.childLanes|=l,k!==null&&(k.childLanes|=l)):k!==null&&(k.childLanes&l)!==l&&(k.childLanes|=l),i===p)break;i=i.return}}function wl(i,l){Pd=i,tm=kl=null,i=i.dependencies,i!==null&&i.firstContext!==null&&((i.lanes&l)!==0&&(ro=!0),i.firstContext=null)}function Oo(i){var l=i._currentValue;if(tm!==i)if(i={context:i,memoizedValue:l,next:null},kl===null){if(Pd===null)throw Error(n(308));kl=i,Pd.dependencies={lanes:0,firstContext:i}}else kl=kl.next=i;return l}var ra=null;function sm(i){ra===null?ra=[i]:ra.push(i)}function $v(i,l,p,k){var b=l.interleaved;return b===null?(p.next=p,sm(l)):(p.next=b.next,b.next=p),l.interleaved=p,Ts(i,k)}function Ts(i,l){i.lanes|=l;var p=i.alternate;for(p!==null&&(p.lanes|=l),p=i,i=i.return;i!==null;)i.childLanes|=l,p=i.alternate,p!==null&&(p.childLanes|=l),p=i,i=i.return;return p.tag===3?p.stateNode:null}var di=!1;function im(i){i.updateQueue={baseState:i.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Cv(i,l){i=i.updateQueue,l.updateQueue===i&&(l.updateQueue={baseState:i.baseState,firstBaseUpdate:i.firstBaseUpdate,lastBaseUpdate:i.lastBaseUpdate,shared:i.shared,effects:i.effects})}function $s(i,l){return{eventTime:i,lane:l,tag:0,payload:null,callback:null,next:null}}function fi(i,l,p){var k=i.updateQueue;if(k===null)return null;if(k=k.shared,(mn&2)!==0){var b=k.pending;return b===null?l.next=l:(l.next=b.next,b.next=l),k.pending=l,Ts(i,p)}return b=k.interleaved,b===null?(l.next=l,sm(k)):(l.next=b.next,b.next=l),k.interleaved=l,Ts(i,p)}function Dd(i,l,p){if(l=l.updateQueue,l!==null&&(l=l.shared,(p&4194240)!==0)){var k=l.lanes;k&=i.pendingLanes,p|=k,l.lanes=p,go(i,p)}}function Iv(i,l){var p=i.updateQueue,k=i.alternate;if(k!==null&&(k=k.updateQueue,p===k)){var b=null,S=null;if(p=p.firstBaseUpdate,p!==null){do{var O={eventTime:p.eventTime,lane:p.lane,tag:p.tag,payload:p.payload,callback:p.callback,next:null};S===null?b=S=O:S=S.next=O,p=p.next}while(p!==null);S===null?b=S=l:S=S.next=l}else b=S=l;p={baseState:k.baseState,firstBaseUpdate:b,lastBaseUpdate:S,shared:k.shared,effects:k.effects},i.updateQueue=p;return}i=p.lastBaseUpdate,i===null?p.firstBaseUpdate=l:i.next=l,p.lastBaseUpdate=l}function zd(i,l,p,k){var b=i.updateQueue;di=!1;var S=b.firstBaseUpdate,O=b.lastBaseUpdate,Y=b.shared.pending;if(Y!==null){b.shared.pending=null;var re=Y,ke=re.next;re.next=null,O===null?S=ke:O.next=ke,O=re;var Re=i.alternate;Re!==null&&(Re=Re.updateQueue,Y=Re.lastBaseUpdate,Y!==O&&(Y===null?Re.firstBaseUpdate=ke:Y.next=ke,Re.lastBaseUpdate=re))}if(S!==null){var ze=b.baseState;O=0,Re=ke=re=null,Y=S;do{var Ce=Y.lane,Xe=Y.eventTime;if((k&Ce)===Ce){Re!==null&&(Re=Re.next={eventTime:Xe,lane:0,tag:Y.tag,payload:Y.payload,callback:Y.callback,next:null});e:{var st=i,it=Y;switch(Ce=l,Xe=p,it.tag){case 1:if(st=it.payload,typeof st=="function"){ze=st.call(Xe,ze,Ce);break e}ze=st;break e;case 3:st.flags=st.flags&-65537|128;case 0:if(st=it.payload,Ce=typeof st=="function"?st.call(Xe,ze,Ce):st,Ce==null)break e;ze=q({},ze,Ce);break e;case 2:di=!0}}Y.callback!==null&&Y.lane!==0&&(i.flags|=64,Ce=b.effects,Ce===null?b.effects=[Y]:Ce.push(Y))}else Xe={eventTime:Xe,lane:Ce,tag:Y.tag,payload:Y.payload,callback:Y.callback,next:null},Re===null?(ke=Re=Xe,re=ze):Re=Re.next=Xe,O|=Ce;if(Y=Y.next,Y===null){if(Y=b.shared.pending,Y===null)break;Ce=Y,Y=Ce.next,Ce.next=null,b.lastBaseUpdate=Ce,b.shared.pending=null}}while(!0);if(Re===null&&(re=ze),b.baseState=re,b.firstBaseUpdate=ke,b.lastBaseUpdate=Re,l=b.shared.interleaved,l!==null){b=l;do O|=b.lane,b=b.next;while(b!==l)}else S===null&&(b.shared.lanes=0);ia|=O,i.lanes=O,i.memoizedState=ze}}function Av(i,l,p){if(i=l.effects,l.effects=null,i!==null)for(l=0;l<i.length;l++){var k=i[l],b=k.callback;if(b!==null){if(k.callback=null,k=p,typeof b!="function")throw Error(n(191,b));b.call(k)}}}var Oc={},us=li(Oc),Mc=li(Oc),Lc=li(Oc);function oa(i){if(i===Oc)throw Error(n(174));return i}function am(i,l){switch(Ln(Lc,l),Ln(Mc,i),Ln(us,Oc),i=l.nodeType,i){case 9:case 11:l=(l=l.documentElement)?l.namespaceURI:lt(null,"");break;default:i=i===8?l.parentNode:l,l=i.namespaceURI||null,i=i.tagName,l=lt(l,i)}Hn(us),Ln(us,l)}function yl(){Hn(us),Hn(Mc),Hn(Lc)}function Rv(i){oa(Lc.current);var l=oa(us.current),p=lt(l,i.type);l!==p&&(Ln(Mc,i),Ln(us,p))}function lm(i){Mc.current===i&&(Hn(us),Hn(Mc))}var Qn=li(0);function Fd(i){for(var l=i;l!==null;){if(l.tag===13){var p=l.memoizedState;if(p!==null&&(p=p.dehydrated,p===null||p.data==="$?"||p.data==="$!"))return l}else if(l.tag===19&&l.memoizedProps.revealOrder!==void 0){if((l.flags&128)!==0)return l}else if(l.child!==null){l.child.return=l,l=l.child;continue}if(l===i)break;for(;l.sibling===null;){if(l.return===null||l.return===i)return null;l=l.return}l.sibling.return=l.return,l=l.sibling}return null}var cm=[];function um(){for(var i=0;i<cm.length;i++)cm[i]._workInProgressVersionPrimary=null;cm.length=0}var Bd=j.ReactCurrentDispatcher,dm=j.ReactCurrentBatchConfig,sa=0,Jn=null,br=null,_r=null,Ud=!1,Pc=!1,Dc=0,cI=0;function Fr(){throw Error(n(321))}function fm(i,l){if(l===null)return!1;for(var p=0;p<l.length&&p<i.length;p++)if(!eo(i[p],l[p]))return!1;return!0}function hm(i,l,p,k,b,S){if(sa=S,Jn=l,l.memoizedState=null,l.updateQueue=null,l.lanes=0,Bd.current=i===null||i.memoizedState===null?hI:pI,i=p(k,b),Pc){S=0;do{if(Pc=!1,Dc=0,25<=S)throw Error(n(301));S+=1,_r=br=null,l.updateQueue=null,Bd.current=mI,i=p(k,b)}while(Pc)}if(Bd.current=Kd,l=br!==null&&br.next!==null,sa=0,_r=br=Jn=null,Ud=!1,l)throw Error(n(300));return i}function pm(){var i=Dc!==0;return Dc=0,i}function ds(){var i={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return _r===null?Jn.memoizedState=_r=i:_r=_r.next=i,_r}function Mo(){if(br===null){var i=Jn.alternate;i=i!==null?i.memoizedState:null}else i=br.next;var l=_r===null?Jn.memoizedState:_r.next;if(l!==null)_r=l,br=i;else{if(i===null)throw Error(n(310));br=i,i={memoizedState:br.memoizedState,baseState:br.baseState,baseQueue:br.baseQueue,queue:br.queue,next:null},_r===null?Jn.memoizedState=_r=i:_r=_r.next=i}return _r}function zc(i,l){return typeof l=="function"?l(i):l}function mm(i){var l=Mo(),p=l.queue;if(p===null)throw Error(n(311));p.lastRenderedReducer=i;var k=br,b=k.baseQueue,S=p.pending;if(S!==null){if(b!==null){var O=b.next;b.next=S.next,S.next=O}k.baseQueue=b=S,p.pending=null}if(b!==null){S=b.next,k=k.baseState;var Y=O=null,re=null,ke=S;do{var Re=ke.lane;if((sa&Re)===Re)re!==null&&(re=re.next={lane:0,action:ke.action,hasEagerState:ke.hasEagerState,eagerState:ke.eagerState,next:null}),k=ke.hasEagerState?ke.eagerState:i(k,ke.action);else{var ze={lane:Re,action:ke.action,hasEagerState:ke.hasEagerState,eagerState:ke.eagerState,next:null};re===null?(Y=re=ze,O=k):re=re.next=ze,Jn.lanes|=Re,ia|=Re}ke=ke.next}while(ke!==null&&ke!==S);re===null?O=k:re.next=Y,eo(k,l.memoizedState)||(ro=!0),l.memoizedState=k,l.baseState=O,l.baseQueue=re,p.lastRenderedState=k}if(i=p.interleaved,i!==null){b=i;do S=b.lane,Jn.lanes|=S,ia|=S,b=b.next;while(b!==i)}else b===null&&(p.lanes=0);return[l.memoizedState,p.dispatch]}function gm(i){var l=Mo(),p=l.queue;if(p===null)throw Error(n(311));p.lastRenderedReducer=i;var k=p.dispatch,b=p.pending,S=l.memoizedState;if(b!==null){p.pending=null;var O=b=b.next;do S=i(S,O.action),O=O.next;while(O!==b);eo(S,l.memoizedState)||(ro=!0),l.memoizedState=S,l.baseQueue===null&&(l.baseState=S),p.lastRenderedState=S}return[S,k]}function Ov(){}function Mv(i,l){var p=Jn,k=Mo(),b=l(),S=!eo(k.memoizedState,b);if(S&&(k.memoizedState=b,ro=!0),k=k.queue,km(Dv.bind(null,p,k,i),[i]),k.getSnapshot!==l||S||_r!==null&&_r.memoizedState.tag&1){if(p.flags|=2048,Fc(9,Pv.bind(null,p,k,b,l),void 0,null),Nr===null)throw Error(n(349));(sa&30)!==0||Lv(p,l,b)}return b}function Lv(i,l,p){i.flags|=16384,i={getSnapshot:l,value:p},l=Jn.updateQueue,l===null?(l={lastEffect:null,stores:null},Jn.updateQueue=l,l.stores=[i]):(p=l.stores,p===null?l.stores=[i]:p.push(i))}function Pv(i,l,p,k){l.value=p,l.getSnapshot=k,zv(l)&&Fv(i)}function Dv(i,l,p){return p(function(){zv(l)&&Fv(i)})}function zv(i){var l=i.getSnapshot;i=i.value;try{var p=l();return!eo(i,p)}catch{return!0}}function Fv(i){var l=Ts(i,1);l!==null&&Xo(l,i,1,-1)}function Bv(i){var l=ds();return typeof i=="function"&&(i=i()),l.memoizedState=l.baseState=i,i={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:zc,lastRenderedState:i},l.queue=i,i=i.dispatch=fI.bind(null,Jn,i),[l.memoizedState,i]}function Fc(i,l,p,k){return i={tag:i,create:l,destroy:p,deps:k,next:null},l=Jn.updateQueue,l===null?(l={lastEffect:null,stores:null},Jn.updateQueue=l,l.lastEffect=i.next=i):(p=l.lastEffect,p===null?l.lastEffect=i.next=i:(k=p.next,p.next=i,i.next=k,l.lastEffect=i)),i}function Uv(){return Mo().memoizedState}function Hd(i,l,p,k){var b=ds();Jn.flags|=i,b.memoizedState=Fc(1|l,p,void 0,k===void 0?null:k)}function Wd(i,l,p,k){var b=Mo();k=k===void 0?null:k;var S=void 0;if(br!==null){var O=br.memoizedState;if(S=O.destroy,k!==null&&fm(k,O.deps)){b.memoizedState=Fc(l,p,S,k);return}}Jn.flags|=i,b.memoizedState=Fc(1|l,p,S,k)}function Hv(i,l){return Hd(8390656,8,i,l)}function km(i,l){return Wd(2048,8,i,l)}function Wv(i,l){return Wd(4,2,i,l)}function Kv(i,l){return Wd(4,4,i,l)}function qv(i,l){if(typeof l=="function")return i=i(),l(i),function(){l(null)};if(l!=null)return i=i(),l.current=i,function(){l.current=null}}function Zv(i,l,p){return p=p!=null?p.concat([i]):null,Wd(4,4,qv.bind(null,l,i),p)}function wm(){}function Gv(i,l){var p=Mo();l=l===void 0?null:l;var k=p.memoizedState;return k!==null&&l!==null&&fm(l,k[1])?k[0]:(p.memoizedState=[i,l],i)}function Vv(i,l){var p=Mo();l=l===void 0?null:l;var k=p.memoizedState;return k!==null&&l!==null&&fm(l,k[1])?k[0]:(i=i(),p.memoizedState=[i,l],i)}function Yv(i,l,p){return(sa&21)===0?(i.baseState&&(i.baseState=!1,ro=!0),i.memoizedState=p):(eo(p,l)||(p=On(),Jn.lanes|=p,ia|=p,i.baseState=!0),l)}function uI(i,l){var p=rn;rn=p!==0&&4>p?p:4,i(!0);var k=dm.transition;dm.transition={};try{i(!1),l()}finally{rn=p,dm.transition=k}}function Xv(){return Mo().memoizedState}function dI(i,l,p){var k=gi(i);if(p={lane:k,action:p,hasEagerState:!1,eagerState:null,next:null},Qv(i))Jv(l,p);else if(p=$v(i,l,p,k),p!==null){var b=Vr();Xo(p,i,k,b),e0(p,l,k)}}function fI(i,l,p){var k=gi(i),b={lane:k,action:p,hasEagerState:!1,eagerState:null,next:null};if(Qv(i))Jv(l,b);else{var S=i.alternate;if(i.lanes===0&&(S===null||S.lanes===0)&&(S=l.lastRenderedReducer,S!==null))try{var O=l.lastRenderedState,Y=S(O,p);if(b.hasEagerState=!0,b.eagerState=Y,eo(Y,O)){var re=l.interleaved;re===null?(b.next=b,sm(l)):(b.next=re.next,re.next=b),l.interleaved=b;return}}catch{}finally{}p=$v(i,l,b,k),p!==null&&(b=Vr(),Xo(p,i,k,b),e0(p,l,k))}}function Qv(i){var l=i.alternate;return i===Jn||l!==null&&l===Jn}function Jv(i,l){Pc=Ud=!0;var p=i.pending;p===null?l.next=l:(l.next=p.next,p.next=l),i.pending=l}function e0(i,l,p){if((p&4194240)!==0){var k=l.lanes;k&=i.pendingLanes,p|=k,l.lanes=p,go(i,p)}}var Kd={readContext:Oo,useCallback:Fr,useContext:Fr,useEffect:Fr,useImperativeHandle:Fr,useInsertionEffect:Fr,useLayoutEffect:Fr,useMemo:Fr,useReducer:Fr,useRef:Fr,useState:Fr,useDebugValue:Fr,useDeferredValue:Fr,useTransition:Fr,useMutableSource:Fr,useSyncExternalStore:Fr,useId:Fr,unstable_isNewReconciler:!1},hI={readContext:Oo,useCallback:function(i,l){return ds().memoizedState=[i,l===void 0?null:l],i},useContext:Oo,useEffect:Hv,useImperativeHandle:function(i,l,p){return p=p!=null?p.concat([i]):null,Hd(4194308,4,qv.bind(null,l,i),p)},useLayoutEffect:function(i,l){return Hd(4194308,4,i,l)},useInsertionEffect:function(i,l){return Hd(4,2,i,l)},useMemo:function(i,l){var p=ds();return l=l===void 0?null:l,i=i(),p.memoizedState=[i,l],i},useReducer:function(i,l,p){var k=ds();return l=p!==void 0?p(l):l,k.memoizedState=k.baseState=l,i={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:i,lastRenderedState:l},k.queue=i,i=i.dispatch=dI.bind(null,Jn,i),[k.memoizedState,i]},useRef:function(i){var l=ds();return i={current:i},l.memoizedState=i},useState:Bv,useDebugValue:wm,useDeferredValue:function(i){return ds().memoizedState=i},useTransition:function(){var i=Bv(!1),l=i[0];return i=uI.bind(null,i[1]),ds().memoizedState=i,[l,i]},useMutableSource:function(){},useSyncExternalStore:function(i,l,p){var k=Jn,b=ds();if(Vn){if(p===void 0)throw Error(n(407));p=p()}else{if(p=l(),Nr===null)throw Error(n(349));(sa&30)!==0||Lv(k,l,p)}b.memoizedState=p;var S={value:p,getSnapshot:l};return b.queue=S,Hv(Dv.bind(null,k,S,i),[i]),k.flags|=2048,Fc(9,Pv.bind(null,k,S,p,l),void 0,null),p},useId:function(){var i=ds(),l=Nr.identifierPrefix;if(Vn){var p=js,k=Ns;p=(k&~(1<<32-hn(k)-1)).toString(32)+p,l=":"+l+"R"+p,p=Dc++,0<p&&(l+="H"+p.toString(32)),l+=":"}else p=cI++,l=":"+l+"r"+p.toString(32)+":";return i.memoizedState=l},unstable_isNewReconciler:!1},pI={readContext:Oo,useCallback:Gv,useContext:Oo,useEffect:km,useImperativeHandle:Zv,useInsertionEffect:Wv,useLayoutEffect:Kv,useMemo:Vv,useReducer:mm,useRef:Uv,useState:function(){return mm(zc)},useDebugValue:wm,useDeferredValue:function(i){var l=Mo();return Yv(l,br.memoizedState,i)},useTransition:function(){var i=mm(zc)[0],l=Mo().memoizedState;return[i,l]},useMutableSource:Ov,useSyncExternalStore:Mv,useId:Xv,unstable_isNewReconciler:!1},mI={readContext:Oo,useCallback:Gv,useContext:Oo,useEffect:km,useImperativeHandle:Zv,useInsertionEffect:Wv,useLayoutEffect:Kv,useMemo:Vv,useReducer:gm,useRef:Uv,useState:function(){return gm(zc)},useDebugValue:wm,useDeferredValue:function(i){var l=Mo();return br===null?l.memoizedState=i:Yv(l,br.memoizedState,i)},useTransition:function(){var i=gm(zc)[0],l=Mo().memoizedState;return[i,l]},useMutableSource:Ov,useSyncExternalStore:Mv,useId:Xv,unstable_isNewReconciler:!1};function Go(i,l){if(i&&i.defaultProps){l=q({},l),i=i.defaultProps;for(var p in i)l[p]===void 0&&(l[p]=i[p]);return l}return l}function ym(i,l,p,k){l=i.memoizedState,p=p(k,l),p=p==null?l:q({},l,p),i.memoizedState=p,i.lanes===0&&(i.updateQueue.baseState=p)}var qd={isMounted:function(i){return(i=i._reactInternals)?Rn(i)===i:!1},enqueueSetState:function(i,l,p){i=i._reactInternals;var k=Vr(),b=gi(i),S=$s(k,b);S.payload=l,p!=null&&(S.callback=p),l=fi(i,S,b),l!==null&&(Xo(l,i,b,k),Dd(l,i,b))},enqueueReplaceState:function(i,l,p){i=i._reactInternals;var k=Vr(),b=gi(i),S=$s(k,b);S.tag=1,S.payload=l,p!=null&&(S.callback=p),l=fi(i,S,b),l!==null&&(Xo(l,i,b,k),Dd(l,i,b))},enqueueForceUpdate:function(i,l){i=i._reactInternals;var p=Vr(),k=gi(i),b=$s(p,k);b.tag=2,l!=null&&(b.callback=l),l=fi(i,b,k),l!==null&&(Xo(l,i,k,p),Dd(l,i,k))}};function t0(i,l,p,k,b,S,O){return i=i.stateNode,typeof i.shouldComponentUpdate=="function"?i.shouldComponentUpdate(k,S,O):l.prototype&&l.prototype.isPureReactComponent?!ri(p,k)||!ri(b,S):!0}function n0(i,l,p){var k=!1,b=ci,S=l.contextType;return typeof S=="object"&&S!==null?S=Oo(S):(b=no(l)?ea:zr.current,k=l.contextTypes,S=(k=k!=null)?fl(i,b):ci),l=new l(p,S),i.memoizedState=l.state!==null&&l.state!==void 0?l.state:null,l.updater=qd,i.stateNode=l,l._reactInternals=i,k&&(i=i.stateNode,i.__reactInternalMemoizedUnmaskedChildContext=b,i.__reactInternalMemoizedMaskedChildContext=S),l}function r0(i,l,p,k){i=l.state,typeof l.componentWillReceiveProps=="function"&&l.componentWillReceiveProps(p,k),typeof l.UNSAFE_componentWillReceiveProps=="function"&&l.UNSAFE_componentWillReceiveProps(p,k),l.state!==i&&qd.enqueueReplaceState(l,l.state,null)}function vm(i,l,p,k){var b=i.stateNode;b.props=p,b.state=i.memoizedState,b.refs={},im(i);var S=l.contextType;typeof S=="object"&&S!==null?b.context=Oo(S):(S=no(l)?ea:zr.current,b.context=fl(i,S)),b.state=i.memoizedState,S=l.getDerivedStateFromProps,typeof S=="function"&&(ym(i,l,S,p),b.state=i.memoizedState),typeof l.getDerivedStateFromProps=="function"||typeof b.getSnapshotBeforeUpdate=="function"||typeof b.UNSAFE_componentWillMount!="function"&&typeof b.componentWillMount!="function"||(l=b.state,typeof b.componentWillMount=="function"&&b.componentWillMount(),typeof b.UNSAFE_componentWillMount=="function"&&b.UNSAFE_componentWillMount(),l!==b.state&&qd.enqueueReplaceState(b,b.state,null),zd(i,p,b,k),b.state=i.memoizedState),typeof b.componentDidMount=="function"&&(i.flags|=4194308)}function vl(i,l){try{var p="",k=l;do p+=Ne(k),k=k.return;while(k);var b=p}catch(S){b=`
40
- Error generating stack: `+S.message+`
41
- `+S.stack}return{value:i,source:l,stack:b,digest:null}}function bm(i,l,p){return{value:i,source:null,stack:p??null,digest:l??null}}function xm(i,l){try{console.error(l.value)}catch(p){setTimeout(function(){throw p})}}var gI=typeof WeakMap=="function"?WeakMap:Map;function o0(i,l,p){p=$s(-1,p),p.tag=3,p.payload={element:null};var k=l.value;return p.callback=function(){Jd||(Jd=!0,Pm=k),xm(i,l)},p}function s0(i,l,p){p=$s(-1,p),p.tag=3;var k=i.type.getDerivedStateFromError;if(typeof k=="function"){var b=l.value;p.payload=function(){return k(b)},p.callback=function(){xm(i,l)}}var S=i.stateNode;return S!==null&&typeof S.componentDidCatch=="function"&&(p.callback=function(){xm(i,l),typeof k!="function"&&(pi===null?pi=new Set([this]):pi.add(this));var O=l.stack;this.componentDidCatch(l.value,{componentStack:O!==null?O:""})}),p}function i0(i,l,p){var k=i.pingCache;if(k===null){k=i.pingCache=new gI;var b=new Set;k.set(l,b)}else b=k.get(l),b===void 0&&(b=new Set,k.set(l,b));b.has(p)||(b.add(p),i=CI.bind(null,i,l,p),l.then(i,i))}function a0(i){do{var l;if((l=i.tag===13)&&(l=i.memoizedState,l=l!==null?l.dehydrated!==null:!0),l)return i;i=i.return}while(i!==null);return null}function l0(i,l,p,k,b){return(i.mode&1)===0?(i===l?i.flags|=65536:(i.flags|=128,p.flags|=131072,p.flags&=-52805,p.tag===1&&(p.alternate===null?p.tag=17:(l=$s(-1,1),l.tag=2,fi(p,l,1))),p.lanes|=1),i):(i.flags|=65536,i.lanes=b,i)}var kI=j.ReactCurrentOwner,ro=!1;function Gr(i,l,p,k){l.child=i===null?Tv(l,null,p,k):gl(l,i.child,p,k)}function c0(i,l,p,k,b){p=p.render;var S=l.ref;return wl(l,b),k=hm(i,l,p,k,S,b),p=pm(),i!==null&&!ro?(l.updateQueue=i.updateQueue,l.flags&=-2053,i.lanes&=~b,Cs(i,l,b)):(Vn&&p&&Yp(l),l.flags|=1,Gr(i,l,k,b),l.child)}function u0(i,l,p,k,b){if(i===null){var S=p.type;return typeof S=="function"&&!Wm(S)&&S.defaultProps===void 0&&p.compare===null&&p.defaultProps===void 0?(l.tag=15,l.type=S,d0(i,l,S,k,b)):(i=sf(p.type,null,k,l,l.mode,b),i.ref=l.ref,i.return=l,l.child=i)}if(S=i.child,(i.lanes&b)===0){var O=S.memoizedProps;if(p=p.compare,p=p!==null?p:ri,p(O,k)&&i.ref===l.ref)return Cs(i,l,b)}return l.flags|=1,i=wi(S,k),i.ref=l.ref,i.return=l,l.child=i}function d0(i,l,p,k,b){if(i!==null){var S=i.memoizedProps;if(ri(S,k)&&i.ref===l.ref)if(ro=!1,l.pendingProps=k=S,(i.lanes&b)!==0)(i.flags&131072)!==0&&(ro=!0);else return l.lanes=i.lanes,Cs(i,l,b)}return Em(i,l,p,k,b)}function f0(i,l,p){var k=l.pendingProps,b=k.children,S=i!==null?i.memoizedState:null;if(k.mode==="hidden")if((l.mode&1)===0)l.memoizedState={baseLanes:0,cachePool:null,transitions:null},Ln(xl,bo),bo|=p;else{if((p&1073741824)===0)return i=S!==null?S.baseLanes|p:p,l.lanes=l.childLanes=1073741824,l.memoizedState={baseLanes:i,cachePool:null,transitions:null},l.updateQueue=null,Ln(xl,bo),bo|=i,null;l.memoizedState={baseLanes:0,cachePool:null,transitions:null},k=S!==null?S.baseLanes:p,Ln(xl,bo),bo|=k}else S!==null?(k=S.baseLanes|p,l.memoizedState=null):k=p,Ln(xl,bo),bo|=k;return Gr(i,l,b,p),l.child}function h0(i,l){var p=l.ref;(i===null&&p!==null||i!==null&&i.ref!==p)&&(l.flags|=512,l.flags|=2097152)}function Em(i,l,p,k,b){var S=no(p)?ea:zr.current;return S=fl(l,S),wl(l,b),p=hm(i,l,p,k,S,b),k=pm(),i!==null&&!ro?(l.updateQueue=i.updateQueue,l.flags&=-2053,i.lanes&=~b,Cs(i,l,b)):(Vn&&k&&Yp(l),l.flags|=1,Gr(i,l,p,b),l.child)}function p0(i,l,p,k,b){if(no(p)){var S=!0;Cd(l)}else S=!1;if(wl(l,b),l.stateNode===null)Gd(i,l),n0(l,p,k),vm(l,p,k,b),k=!0;else if(i===null){var O=l.stateNode,Y=l.memoizedProps;O.props=Y;var re=O.context,ke=p.contextType;typeof ke=="object"&&ke!==null?ke=Oo(ke):(ke=no(p)?ea:zr.current,ke=fl(l,ke));var Re=p.getDerivedStateFromProps,ze=typeof Re=="function"||typeof O.getSnapshotBeforeUpdate=="function";ze||typeof O.UNSAFE_componentWillReceiveProps!="function"&&typeof O.componentWillReceiveProps!="function"||(Y!==k||re!==ke)&&r0(l,O,k,ke),di=!1;var Ce=l.memoizedState;O.state=Ce,zd(l,k,O,b),re=l.memoizedState,Y!==k||Ce!==re||to.current||di?(typeof Re=="function"&&(ym(l,p,Re,k),re=l.memoizedState),(Y=di||t0(l,p,Y,k,Ce,re,ke))?(ze||typeof O.UNSAFE_componentWillMount!="function"&&typeof O.componentWillMount!="function"||(typeof O.componentWillMount=="function"&&O.componentWillMount(),typeof O.UNSAFE_componentWillMount=="function"&&O.UNSAFE_componentWillMount()),typeof O.componentDidMount=="function"&&(l.flags|=4194308)):(typeof O.componentDidMount=="function"&&(l.flags|=4194308),l.memoizedProps=k,l.memoizedState=re),O.props=k,O.state=re,O.context=ke,k=Y):(typeof O.componentDidMount=="function"&&(l.flags|=4194308),k=!1)}else{O=l.stateNode,Cv(i,l),Y=l.memoizedProps,ke=l.type===l.elementType?Y:Go(l.type,Y),O.props=ke,ze=l.pendingProps,Ce=O.context,re=p.contextType,typeof re=="object"&&re!==null?re=Oo(re):(re=no(p)?ea:zr.current,re=fl(l,re));var Xe=p.getDerivedStateFromProps;(Re=typeof Xe=="function"||typeof O.getSnapshotBeforeUpdate=="function")||typeof O.UNSAFE_componentWillReceiveProps!="function"&&typeof O.componentWillReceiveProps!="function"||(Y!==ze||Ce!==re)&&r0(l,O,k,re),di=!1,Ce=l.memoizedState,O.state=Ce,zd(l,k,O,b);var st=l.memoizedState;Y!==ze||Ce!==st||to.current||di?(typeof Xe=="function"&&(ym(l,p,Xe,k),st=l.memoizedState),(ke=di||t0(l,p,ke,k,Ce,st,re)||!1)?(Re||typeof O.UNSAFE_componentWillUpdate!="function"&&typeof O.componentWillUpdate!="function"||(typeof O.componentWillUpdate=="function"&&O.componentWillUpdate(k,st,re),typeof O.UNSAFE_componentWillUpdate=="function"&&O.UNSAFE_componentWillUpdate(k,st,re)),typeof O.componentDidUpdate=="function"&&(l.flags|=4),typeof O.getSnapshotBeforeUpdate=="function"&&(l.flags|=1024)):(typeof O.componentDidUpdate!="function"||Y===i.memoizedProps&&Ce===i.memoizedState||(l.flags|=4),typeof O.getSnapshotBeforeUpdate!="function"||Y===i.memoizedProps&&Ce===i.memoizedState||(l.flags|=1024),l.memoizedProps=k,l.memoizedState=st),O.props=k,O.state=st,O.context=re,k=ke):(typeof O.componentDidUpdate!="function"||Y===i.memoizedProps&&Ce===i.memoizedState||(l.flags|=4),typeof O.getSnapshotBeforeUpdate!="function"||Y===i.memoizedProps&&Ce===i.memoizedState||(l.flags|=1024),k=!1)}return Sm(i,l,p,k,S,b)}function Sm(i,l,p,k,b,S){h0(i,l);var O=(l.flags&128)!==0;if(!k&&!O)return b&&yv(l,p,!1),Cs(i,l,S);k=l.stateNode,kI.current=l;var Y=O&&typeof p.getDerivedStateFromError!="function"?null:k.render();return l.flags|=1,i!==null&&O?(l.child=gl(l,i.child,null,S),l.child=gl(l,null,Y,S)):Gr(i,l,Y,S),l.memoizedState=k.state,b&&yv(l,p,!0),l.child}function m0(i){var l=i.stateNode;l.pendingContext?kv(i,l.pendingContext,l.pendingContext!==l.context):l.context&&kv(i,l.context,!1),am(i,l.containerInfo)}function g0(i,l,p,k,b){return ml(),em(b),l.flags|=256,Gr(i,l,p,k),l.child}var _m={dehydrated:null,treeContext:null,retryLane:0};function Nm(i){return{baseLanes:i,cachePool:null,transitions:null}}function k0(i,l,p){var k=l.pendingProps,b=Qn.current,S=!1,O=(l.flags&128)!==0,Y;if((Y=O)||(Y=i!==null&&i.memoizedState===null?!1:(b&2)!==0),Y?(S=!0,l.flags&=-129):(i===null||i.memoizedState!==null)&&(b|=1),Ln(Qn,b&1),i===null)return Jp(l),i=l.memoizedState,i!==null&&(i=i.dehydrated,i!==null)?((l.mode&1)===0?l.lanes=1:i.data==="$!"?l.lanes=8:l.lanes=1073741824,null):(O=k.children,i=k.fallback,S?(k=l.mode,S=l.child,O={mode:"hidden",children:O},(k&1)===0&&S!==null?(S.childLanes=0,S.pendingProps=O):S=af(O,k,0,null),i=ua(i,k,p,null),S.return=l,i.return=l,S.sibling=i,l.child=S,l.child.memoizedState=Nm(p),l.memoizedState=_m,i):jm(l,O));if(b=i.memoizedState,b!==null&&(Y=b.dehydrated,Y!==null))return wI(i,l,O,k,Y,b,p);if(S){S=k.fallback,O=l.mode,b=i.child,Y=b.sibling;var re={mode:"hidden",children:k.children};return(O&1)===0&&l.child!==b?(k=l.child,k.childLanes=0,k.pendingProps=re,l.deletions=null):(k=wi(b,re),k.subtreeFlags=b.subtreeFlags&14680064),Y!==null?S=wi(Y,S):(S=ua(S,O,p,null),S.flags|=2),S.return=l,k.return=l,k.sibling=S,l.child=k,k=S,S=l.child,O=i.child.memoizedState,O=O===null?Nm(p):{baseLanes:O.baseLanes|p,cachePool:null,transitions:O.transitions},S.memoizedState=O,S.childLanes=i.childLanes&~p,l.memoizedState=_m,k}return S=i.child,i=S.sibling,k=wi(S,{mode:"visible",children:k.children}),(l.mode&1)===0&&(k.lanes=p),k.return=l,k.sibling=null,i!==null&&(p=l.deletions,p===null?(l.deletions=[i],l.flags|=16):p.push(i)),l.child=k,l.memoizedState=null,k}function jm(i,l){return l=af({mode:"visible",children:l},i.mode,0,null),l.return=i,i.child=l}function Zd(i,l,p,k){return k!==null&&em(k),gl(l,i.child,null,p),i=jm(l,l.pendingProps.children),i.flags|=2,l.memoizedState=null,i}function wI(i,l,p,k,b,S,O){if(p)return l.flags&256?(l.flags&=-257,k=bm(Error(n(422))),Zd(i,l,O,k)):l.memoizedState!==null?(l.child=i.child,l.flags|=128,null):(S=k.fallback,b=l.mode,k=af({mode:"visible",children:k.children},b,0,null),S=ua(S,b,O,null),S.flags|=2,k.return=l,S.return=l,k.sibling=S,l.child=k,(l.mode&1)!==0&&gl(l,i.child,null,O),l.child.memoizedState=Nm(O),l.memoizedState=_m,S);if((l.mode&1)===0)return Zd(i,l,O,null);if(b.data==="$!"){if(k=b.nextSibling&&b.nextSibling.dataset,k)var Y=k.dgst;return k=Y,S=Error(n(419)),k=bm(S,k,void 0),Zd(i,l,O,k)}if(Y=(O&i.childLanes)!==0,ro||Y){if(k=Nr,k!==null){switch(O&-O){case 4:b=2;break;case 16:b=8;break;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:b=32;break;case 536870912:b=268435456;break;default:b=0}b=(b&(k.suspendedLanes|O))!==0?0:b,b!==0&&b!==S.retryLane&&(S.retryLane=b,Ts(i,b),Xo(k,i,b,-1))}return Hm(),k=bm(Error(n(421))),Zd(i,l,O,k)}return b.data==="$?"?(l.flags|=128,l.child=i.child,l=II.bind(null,i),b._reactRetry=l,null):(i=S.treeContext,vo=ai(b.nextSibling),yo=l,Vn=!0,Zo=null,i!==null&&(Ao[Ro++]=Ns,Ao[Ro++]=js,Ao[Ro++]=ta,Ns=i.id,js=i.overflow,ta=l),l=jm(l,k.children),l.flags|=4096,l)}function w0(i,l,p){i.lanes|=l;var k=i.alternate;k!==null&&(k.lanes|=l),om(i.return,l,p)}function Tm(i,l,p,k,b){var S=i.memoizedState;S===null?i.memoizedState={isBackwards:l,rendering:null,renderingStartTime:0,last:k,tail:p,tailMode:b}:(S.isBackwards=l,S.rendering=null,S.renderingStartTime=0,S.last=k,S.tail=p,S.tailMode=b)}function y0(i,l,p){var k=l.pendingProps,b=k.revealOrder,S=k.tail;if(Gr(i,l,k.children,p),k=Qn.current,(k&2)!==0)k=k&1|2,l.flags|=128;else{if(i!==null&&(i.flags&128)!==0)e:for(i=l.child;i!==null;){if(i.tag===13)i.memoizedState!==null&&w0(i,p,l);else if(i.tag===19)w0(i,p,l);else if(i.child!==null){i.child.return=i,i=i.child;continue}if(i===l)break e;for(;i.sibling===null;){if(i.return===null||i.return===l)break e;i=i.return}i.sibling.return=i.return,i=i.sibling}k&=1}if(Ln(Qn,k),(l.mode&1)===0)l.memoizedState=null;else switch(b){case"forwards":for(p=l.child,b=null;p!==null;)i=p.alternate,i!==null&&Fd(i)===null&&(b=p),p=p.sibling;p=b,p===null?(b=l.child,l.child=null):(b=p.sibling,p.sibling=null),Tm(l,!1,b,p,S);break;case"backwards":for(p=null,b=l.child,l.child=null;b!==null;){if(i=b.alternate,i!==null&&Fd(i)===null){l.child=b;break}i=b.sibling,b.sibling=p,p=b,b=i}Tm(l,!0,p,null,S);break;case"together":Tm(l,!1,null,null,void 0);break;default:l.memoizedState=null}return l.child}function Gd(i,l){(l.mode&1)===0&&i!==null&&(i.alternate=null,l.alternate=null,l.flags|=2)}function Cs(i,l,p){if(i!==null&&(l.dependencies=i.dependencies),ia|=l.lanes,(p&l.childLanes)===0)return null;if(i!==null&&l.child!==i.child)throw Error(n(153));if(l.child!==null){for(i=l.child,p=wi(i,i.pendingProps),l.child=p,p.return=l;i.sibling!==null;)i=i.sibling,p=p.sibling=wi(i,i.pendingProps),p.return=l;p.sibling=null}return l.child}function yI(i,l,p){switch(l.tag){case 3:m0(l),ml();break;case 5:Rv(l);break;case 1:no(l.type)&&Cd(l);break;case 4:am(l,l.stateNode.containerInfo);break;case 10:var k=l.type._context,b=l.memoizedProps.value;Ln(Ld,k._currentValue),k._currentValue=b;break;case 13:if(k=l.memoizedState,k!==null)return k.dehydrated!==null?(Ln(Qn,Qn.current&1),l.flags|=128,null):(p&l.child.childLanes)!==0?k0(i,l,p):(Ln(Qn,Qn.current&1),i=Cs(i,l,p),i!==null?i.sibling:null);Ln(Qn,Qn.current&1);break;case 19:if(k=(p&l.childLanes)!==0,(i.flags&128)!==0){if(k)return y0(i,l,p);l.flags|=128}if(b=l.memoizedState,b!==null&&(b.rendering=null,b.tail=null,b.lastEffect=null),Ln(Qn,Qn.current),k)break;return null;case 22:case 23:return l.lanes=0,f0(i,l,p)}return Cs(i,l,p)}var v0,$m,b0,x0;v0=function(i,l){for(var p=l.child;p!==null;){if(p.tag===5||p.tag===6)i.appendChild(p.stateNode);else if(p.tag!==4&&p.child!==null){p.child.return=p,p=p.child;continue}if(p===l)break;for(;p.sibling===null;){if(p.return===null||p.return===l)return;p=p.return}p.sibling.return=p.return,p=p.sibling}},$m=function(){},b0=function(i,l,p,k){var b=i.memoizedProps;if(b!==k){i=l.stateNode,oa(us.current);var S=null;switch(p){case"input":b=Se(i,b),k=Se(i,k),S=[];break;case"select":b=q({},b,{value:void 0}),k=q({},k,{value:void 0}),S=[];break;case"textarea":b=Ze(i,b),k=Ze(i,k),S=[];break;default:typeof b.onClick!="function"&&typeof k.onClick=="function"&&(i.onclick=jd)}dn(p,k);var O;p=null;for(ke in b)if(!k.hasOwnProperty(ke)&&b.hasOwnProperty(ke)&&b[ke]!=null)if(ke==="style"){var Y=b[ke];for(O in Y)Y.hasOwnProperty(O)&&(p||(p={}),p[O]="")}else ke!=="dangerouslySetInnerHTML"&&ke!=="children"&&ke!=="suppressContentEditableWarning"&&ke!=="suppressHydrationWarning"&&ke!=="autoFocus"&&(o.hasOwnProperty(ke)?S||(S=[]):(S=S||[]).push(ke,null));for(ke in k){var re=k[ke];if(Y=b!=null?b[ke]:void 0,k.hasOwnProperty(ke)&&re!==Y&&(re!=null||Y!=null))if(ke==="style")if(Y){for(O in Y)!Y.hasOwnProperty(O)||re&&re.hasOwnProperty(O)||(p||(p={}),p[O]="");for(O in re)re.hasOwnProperty(O)&&Y[O]!==re[O]&&(p||(p={}),p[O]=re[O])}else p||(S||(S=[]),S.push(ke,p)),p=re;else ke==="dangerouslySetInnerHTML"?(re=re?re.__html:void 0,Y=Y?Y.__html:void 0,re!=null&&Y!==re&&(S=S||[]).push(ke,re)):ke==="children"?typeof re!="string"&&typeof re!="number"||(S=S||[]).push(ke,""+re):ke!=="suppressContentEditableWarning"&&ke!=="suppressHydrationWarning"&&(o.hasOwnProperty(ke)?(re!=null&&ke==="onScroll"&&Un("scroll",i),S||Y===re||(S=[])):(S=S||[]).push(ke,re))}p&&(S=S||[]).push("style",p);var ke=S;(l.updateQueue=ke)&&(l.flags|=4)}},x0=function(i,l,p,k){p!==k&&(l.flags|=4)};function Bc(i,l){if(!Vn)switch(i.tailMode){case"hidden":l=i.tail;for(var p=null;l!==null;)l.alternate!==null&&(p=l),l=l.sibling;p===null?i.tail=null:p.sibling=null;break;case"collapsed":p=i.tail;for(var k=null;p!==null;)p.alternate!==null&&(k=p),p=p.sibling;k===null?l||i.tail===null?i.tail=null:i.tail.sibling=null:k.sibling=null}}function Br(i){var l=i.alternate!==null&&i.alternate.child===i.child,p=0,k=0;if(l)for(var b=i.child;b!==null;)p|=b.lanes|b.childLanes,k|=b.subtreeFlags&14680064,k|=b.flags&14680064,b.return=i,b=b.sibling;else for(b=i.child;b!==null;)p|=b.lanes|b.childLanes,k|=b.subtreeFlags,k|=b.flags,b.return=i,b=b.sibling;return i.subtreeFlags|=k,i.childLanes=p,l}function vI(i,l,p){var k=l.pendingProps;switch(Xp(l),l.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Br(l),null;case 1:return no(l.type)&&$d(),Br(l),null;case 3:return k=l.stateNode,yl(),Hn(to),Hn(zr),um(),k.pendingContext&&(k.context=k.pendingContext,k.pendingContext=null),(i===null||i.child===null)&&(Od(l)?l.flags|=4:i===null||i.memoizedState.isDehydrated&&(l.flags&256)===0||(l.flags|=1024,Zo!==null&&(Fm(Zo),Zo=null))),$m(i,l),Br(l),null;case 5:lm(l);var b=oa(Lc.current);if(p=l.type,i!==null&&l.stateNode!=null)b0(i,l,p,k,b),i.ref!==l.ref&&(l.flags|=512,l.flags|=2097152);else{if(!k){if(l.stateNode===null)throw Error(n(166));return Br(l),null}if(i=oa(us.current),Od(l)){k=l.stateNode,p=l.type;var S=l.memoizedProps;switch(k[cs]=l,k[Ic]=S,i=(l.mode&1)!==0,p){case"dialog":Un("cancel",k),Un("close",k);break;case"iframe":case"object":case"embed":Un("load",k);break;case"video":case"audio":for(b=0;b<Tc.length;b++)Un(Tc[b],k);break;case"source":Un("error",k);break;case"img":case"image":case"link":Un("error",k),Un("load",k);break;case"details":Un("toggle",k);break;case"input":Ee(k,S),Un("invalid",k);break;case"select":k._wrapperState={wasMultiple:!!S.multiple},Un("invalid",k);break;case"textarea":_t(k,S),Un("invalid",k)}dn(p,S),b=null;for(var O in S)if(S.hasOwnProperty(O)){var Y=S[O];O==="children"?typeof Y=="string"?k.textContent!==Y&&(S.suppressHydrationWarning!==!0&&Nd(k.textContent,Y,i),b=["children",Y]):typeof Y=="number"&&k.textContent!==""+Y&&(S.suppressHydrationWarning!==!0&&Nd(k.textContent,Y,i),b=["children",""+Y]):o.hasOwnProperty(O)&&Y!=null&&O==="onScroll"&&Un("scroll",k)}switch(p){case"input":ue(k),Je(k,S,!0);break;case"textarea":ue(k),De(k);break;case"select":case"option":break;default:typeof S.onClick=="function"&&(k.onclick=jd)}k=b,l.updateQueue=k,k!==null&&(l.flags|=4)}else{O=b.nodeType===9?b:b.ownerDocument,i==="http://www.w3.org/1999/xhtml"&&(i=nt(p)),i==="http://www.w3.org/1999/xhtml"?p==="script"?(i=O.createElement("div"),i.innerHTML="<script><\/script>",i=i.removeChild(i.firstChild)):typeof k.is=="string"?i=O.createElement(p,{is:k.is}):(i=O.createElement(p),p==="select"&&(O=i,k.multiple?O.multiple=!0:k.size&&(O.size=k.size))):i=O.createElementNS(i,p),i[cs]=l,i[Ic]=k,v0(i,l,!1,!1),l.stateNode=i;e:{switch(O=yn(p,k),p){case"dialog":Un("cancel",i),Un("close",i),b=k;break;case"iframe":case"object":case"embed":Un("load",i),b=k;break;case"video":case"audio":for(b=0;b<Tc.length;b++)Un(Tc[b],i);b=k;break;case"source":Un("error",i),b=k;break;case"img":case"image":case"link":Un("error",i),Un("load",i),b=k;break;case"details":Un("toggle",i),b=k;break;case"input":Ee(i,k),b=Se(i,k),Un("invalid",i);break;case"option":b=k;break;case"select":i._wrapperState={wasMultiple:!!k.multiple},b=q({},k,{value:void 0}),Un("invalid",i);break;case"textarea":_t(i,k),b=Ze(i,k),Un("invalid",i);break;default:b=k}dn(p,b),Y=b;for(S in Y)if(Y.hasOwnProperty(S)){var re=Y[S];S==="style"?Cn(i,re):S==="dangerouslySetInnerHTML"?(re=re?re.__html:void 0,re!=null&&$n(i,re)):S==="children"?typeof re=="string"?(p!=="textarea"||re!=="")&&gt(i,re):typeof re=="number"&&gt(i,""+re):S!=="suppressContentEditableWarning"&&S!=="suppressHydrationWarning"&&S!=="autoFocus"&&(o.hasOwnProperty(S)?re!=null&&S==="onScroll"&&Un("scroll",i):re!=null&&T(i,S,re,O))}switch(p){case"input":ue(i),Je(i,k,!1);break;case"textarea":ue(i),De(i);break;case"option":k.value!=null&&i.setAttribute("value",""+K(k.value));break;case"select":i.multiple=!!k.multiple,S=k.value,S!=null?xt(i,!!k.multiple,S,!1):k.defaultValue!=null&&xt(i,!!k.multiple,k.defaultValue,!0);break;default:typeof b.onClick=="function"&&(i.onclick=jd)}switch(p){case"button":case"input":case"select":case"textarea":k=!!k.autoFocus;break e;case"img":k=!0;break e;default:k=!1}}k&&(l.flags|=4)}l.ref!==null&&(l.flags|=512,l.flags|=2097152)}return Br(l),null;case 6:if(i&&l.stateNode!=null)x0(i,l,i.memoizedProps,k);else{if(typeof k!="string"&&l.stateNode===null)throw Error(n(166));if(p=oa(Lc.current),oa(us.current),Od(l)){if(k=l.stateNode,p=l.memoizedProps,k[cs]=l,(S=k.nodeValue!==p)&&(i=yo,i!==null))switch(i.tag){case 3:Nd(k.nodeValue,p,(i.mode&1)!==0);break;case 5:i.memoizedProps.suppressHydrationWarning!==!0&&Nd(k.nodeValue,p,(i.mode&1)!==0)}S&&(l.flags|=4)}else k=(p.nodeType===9?p:p.ownerDocument).createTextNode(k),k[cs]=l,l.stateNode=k}return Br(l),null;case 13:if(Hn(Qn),k=l.memoizedState,i===null||i.memoizedState!==null&&i.memoizedState.dehydrated!==null){if(Vn&&vo!==null&&(l.mode&1)!==0&&(l.flags&128)===0)_v(),ml(),l.flags|=98560,S=!1;else if(S=Od(l),k!==null&&k.dehydrated!==null){if(i===null){if(!S)throw Error(n(318));if(S=l.memoizedState,S=S!==null?S.dehydrated:null,!S)throw Error(n(317));S[cs]=l}else ml(),(l.flags&128)===0&&(l.memoizedState=null),l.flags|=4;Br(l),S=!1}else Zo!==null&&(Fm(Zo),Zo=null),S=!0;if(!S)return l.flags&65536?l:null}return(l.flags&128)!==0?(l.lanes=p,l):(k=k!==null,k!==(i!==null&&i.memoizedState!==null)&&k&&(l.child.flags|=8192,(l.mode&1)!==0&&(i===null||(Qn.current&1)!==0?xr===0&&(xr=3):Hm())),l.updateQueue!==null&&(l.flags|=4),Br(l),null);case 4:return yl(),$m(i,l),i===null&&$c(l.stateNode.containerInfo),Br(l),null;case 10:return rm(l.type._context),Br(l),null;case 17:return no(l.type)&&$d(),Br(l),null;case 19:if(Hn(Qn),S=l.memoizedState,S===null)return Br(l),null;if(k=(l.flags&128)!==0,O=S.rendering,O===null)if(k)Bc(S,!1);else{if(xr!==0||i!==null&&(i.flags&128)!==0)for(i=l.child;i!==null;){if(O=Fd(i),O!==null){for(l.flags|=128,Bc(S,!1),k=O.updateQueue,k!==null&&(l.updateQueue=k,l.flags|=4),l.subtreeFlags=0,k=p,p=l.child;p!==null;)S=p,i=k,S.flags&=14680066,O=S.alternate,O===null?(S.childLanes=0,S.lanes=i,S.child=null,S.subtreeFlags=0,S.memoizedProps=null,S.memoizedState=null,S.updateQueue=null,S.dependencies=null,S.stateNode=null):(S.childLanes=O.childLanes,S.lanes=O.lanes,S.child=O.child,S.subtreeFlags=0,S.deletions=null,S.memoizedProps=O.memoizedProps,S.memoizedState=O.memoizedState,S.updateQueue=O.updateQueue,S.type=O.type,i=O.dependencies,S.dependencies=i===null?null:{lanes:i.lanes,firstContext:i.firstContext}),p=p.sibling;return Ln(Qn,Qn.current&1|2),l.child}i=i.sibling}S.tail!==null&&ln()>El&&(l.flags|=128,k=!0,Bc(S,!1),l.lanes=4194304)}else{if(!k)if(i=Fd(O),i!==null){if(l.flags|=128,k=!0,p=i.updateQueue,p!==null&&(l.updateQueue=p,l.flags|=4),Bc(S,!0),S.tail===null&&S.tailMode==="hidden"&&!O.alternate&&!Vn)return Br(l),null}else 2*ln()-S.renderingStartTime>El&&p!==1073741824&&(l.flags|=128,k=!0,Bc(S,!1),l.lanes=4194304);S.isBackwards?(O.sibling=l.child,l.child=O):(p=S.last,p!==null?p.sibling=O:l.child=O,S.last=O)}return S.tail!==null?(l=S.tail,S.rendering=l,S.tail=l.sibling,S.renderingStartTime=ln(),l.sibling=null,p=Qn.current,Ln(Qn,k?p&1|2:p&1),l):(Br(l),null);case 22:case 23:return Um(),k=l.memoizedState!==null,i!==null&&i.memoizedState!==null!==k&&(l.flags|=8192),k&&(l.mode&1)!==0?(bo&1073741824)!==0&&(Br(l),l.subtreeFlags&6&&(l.flags|=8192)):Br(l),null;case 24:return null;case 25:return null}throw Error(n(156,l.tag))}function bI(i,l){switch(Xp(l),l.tag){case 1:return no(l.type)&&$d(),i=l.flags,i&65536?(l.flags=i&-65537|128,l):null;case 3:return yl(),Hn(to),Hn(zr),um(),i=l.flags,(i&65536)!==0&&(i&128)===0?(l.flags=i&-65537|128,l):null;case 5:return lm(l),null;case 13:if(Hn(Qn),i=l.memoizedState,i!==null&&i.dehydrated!==null){if(l.alternate===null)throw Error(n(340));ml()}return i=l.flags,i&65536?(l.flags=i&-65537|128,l):null;case 19:return Hn(Qn),null;case 4:return yl(),null;case 10:return rm(l.type._context),null;case 22:case 23:return Um(),null;case 24:return null;default:return null}}var Vd=!1,Ur=!1,xI=typeof WeakSet=="function"?WeakSet:Set,et=null;function bl(i,l){var p=i.ref;if(p!==null)if(typeof p=="function")try{p(null)}catch(k){or(i,l,k)}else p.current=null}function Cm(i,l,p){try{p()}catch(k){or(i,l,k)}}var E0=!1;function EI(i,l){if(Up=Ha,i=Sc(),sl(i)){if("selectionStart"in i)var p={start:i.selectionStart,end:i.selectionEnd};else e:{p=(p=i.ownerDocument)&&p.defaultView||window;var k=p.getSelection&&p.getSelection();if(k&&k.rangeCount!==0){p=k.anchorNode;var b=k.anchorOffset,S=k.focusNode;k=k.focusOffset;try{p.nodeType,S.nodeType}catch{p=null;break e}var O=0,Y=-1,re=-1,ke=0,Re=0,ze=i,Ce=null;t:for(;;){for(var Xe;ze!==p||b!==0&&ze.nodeType!==3||(Y=O+b),ze!==S||k!==0&&ze.nodeType!==3||(re=O+k),ze.nodeType===3&&(O+=ze.nodeValue.length),(Xe=ze.firstChild)!==null;)Ce=ze,ze=Xe;for(;;){if(ze===i)break t;if(Ce===p&&++ke===b&&(Y=O),Ce===S&&++Re===k&&(re=O),(Xe=ze.nextSibling)!==null)break;ze=Ce,Ce=ze.parentNode}ze=Xe}p=Y===-1||re===-1?null:{start:Y,end:re}}else p=null}p=p||{start:0,end:0}}else p=null;for(Hp={focusedElem:i,selectionRange:p},Ha=!1,et=l;et!==null;)if(l=et,i=l.child,(l.subtreeFlags&1028)!==0&&i!==null)i.return=l,et=i;else for(;et!==null;){l=et;try{var st=l.alternate;if((l.flags&1024)!==0)switch(l.tag){case 0:case 11:case 15:break;case 1:if(st!==null){var it=st.memoizedProps,ar=st.memoizedState,fe=l.stateNode,le=fe.getSnapshotBeforeUpdate(l.elementType===l.type?it:Go(l.type,it),ar);fe.__reactInternalSnapshotBeforeUpdate=le}break;case 3:var me=l.stateNode.containerInfo;me.nodeType===1?me.textContent="":me.nodeType===9&&me.documentElement&&me.removeChild(me.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(n(163))}}catch(He){or(l,l.return,He)}if(i=l.sibling,i!==null){i.return=l.return,et=i;break}et=l.return}return st=E0,E0=!1,st}function Uc(i,l,p){var k=l.updateQueue;if(k=k!==null?k.lastEffect:null,k!==null){var b=k=k.next;do{if((b.tag&i)===i){var S=b.destroy;b.destroy=void 0,S!==void 0&&Cm(l,p,S)}b=b.next}while(b!==k)}}function Yd(i,l){if(l=l.updateQueue,l=l!==null?l.lastEffect:null,l!==null){var p=l=l.next;do{if((p.tag&i)===i){var k=p.create;p.destroy=k()}p=p.next}while(p!==l)}}function Im(i){var l=i.ref;if(l!==null){var p=i.stateNode;switch(i.tag){case 5:i=p;break;default:i=p}typeof l=="function"?l(i):l.current=i}}function S0(i){var l=i.alternate;l!==null&&(i.alternate=null,S0(l)),i.child=null,i.deletions=null,i.sibling=null,i.tag===5&&(l=i.stateNode,l!==null&&(delete l[cs],delete l[Ic],delete l[Zp],delete l[sI],delete l[iI])),i.stateNode=null,i.return=null,i.dependencies=null,i.memoizedProps=null,i.memoizedState=null,i.pendingProps=null,i.stateNode=null,i.updateQueue=null}function _0(i){return i.tag===5||i.tag===3||i.tag===4}function N0(i){e:for(;;){for(;i.sibling===null;){if(i.return===null||_0(i.return))return null;i=i.return}for(i.sibling.return=i.return,i=i.sibling;i.tag!==5&&i.tag!==6&&i.tag!==18;){if(i.flags&2||i.child===null||i.tag===4)continue e;i.child.return=i,i=i.child}if(!(i.flags&2))return i.stateNode}}function Am(i,l,p){var k=i.tag;if(k===5||k===6)i=i.stateNode,l?p.nodeType===8?p.parentNode.insertBefore(i,l):p.insertBefore(i,l):(p.nodeType===8?(l=p.parentNode,l.insertBefore(i,p)):(l=p,l.appendChild(i)),p=p._reactRootContainer,p!=null||l.onclick!==null||(l.onclick=jd));else if(k!==4&&(i=i.child,i!==null))for(Am(i,l,p),i=i.sibling;i!==null;)Am(i,l,p),i=i.sibling}function Rm(i,l,p){var k=i.tag;if(k===5||k===6)i=i.stateNode,l?p.insertBefore(i,l):p.appendChild(i);else if(k!==4&&(i=i.child,i!==null))for(Rm(i,l,p),i=i.sibling;i!==null;)Rm(i,l,p),i=i.sibling}var Rr=null,Vo=!1;function hi(i,l,p){for(p=p.child;p!==null;)j0(i,l,p),p=p.sibling}function j0(i,l,p){if(yt&&typeof yt.onCommitFiberUnmount=="function")try{yt.onCommitFiberUnmount(wt,p)}catch{}switch(p.tag){case 5:Ur||bl(p,l);case 6:var k=Rr,b=Vo;Rr=null,hi(i,l,p),Rr=k,Vo=b,Rr!==null&&(Vo?(i=Rr,p=p.stateNode,i.nodeType===8?i.parentNode.removeChild(p):i.removeChild(p)):Rr.removeChild(p.stateNode));break;case 18:Rr!==null&&(Vo?(i=Rr,p=p.stateNode,i.nodeType===8?qp(i.parentNode,p):i.nodeType===1&&qp(i,p),Hi(i)):qp(Rr,p.stateNode));break;case 4:k=Rr,b=Vo,Rr=p.stateNode.containerInfo,Vo=!0,hi(i,l,p),Rr=k,Vo=b;break;case 0:case 11:case 14:case 15:if(!Ur&&(k=p.updateQueue,k!==null&&(k=k.lastEffect,k!==null))){b=k=k.next;do{var S=b,O=S.destroy;S=S.tag,O!==void 0&&((S&2)!==0||(S&4)!==0)&&Cm(p,l,O),b=b.next}while(b!==k)}hi(i,l,p);break;case 1:if(!Ur&&(bl(p,l),k=p.stateNode,typeof k.componentWillUnmount=="function"))try{k.props=p.memoizedProps,k.state=p.memoizedState,k.componentWillUnmount()}catch(Y){or(p,l,Y)}hi(i,l,p);break;case 21:hi(i,l,p);break;case 22:p.mode&1?(Ur=(k=Ur)||p.memoizedState!==null,hi(i,l,p),Ur=k):hi(i,l,p);break;default:hi(i,l,p)}}function T0(i){var l=i.updateQueue;if(l!==null){i.updateQueue=null;var p=i.stateNode;p===null&&(p=i.stateNode=new xI),l.forEach(function(k){var b=AI.bind(null,i,k);p.has(k)||(p.add(k),k.then(b,b))})}}function Yo(i,l){var p=l.deletions;if(p!==null)for(var k=0;k<p.length;k++){var b=p[k];try{var S=i,O=l,Y=O;e:for(;Y!==null;){switch(Y.tag){case 5:Rr=Y.stateNode,Vo=!1;break e;case 3:Rr=Y.stateNode.containerInfo,Vo=!0;break e;case 4:Rr=Y.stateNode.containerInfo,Vo=!0;break e}Y=Y.return}if(Rr===null)throw Error(n(160));j0(S,O,b),Rr=null,Vo=!1;var re=b.alternate;re!==null&&(re.return=null),b.return=null}catch(ke){or(b,l,ke)}}if(l.subtreeFlags&12854)for(l=l.child;l!==null;)$0(l,i),l=l.sibling}function $0(i,l){var p=i.alternate,k=i.flags;switch(i.tag){case 0:case 11:case 14:case 15:if(Yo(l,i),fs(i),k&4){try{Uc(3,i,i.return),Yd(3,i)}catch(it){or(i,i.return,it)}try{Uc(5,i,i.return)}catch(it){or(i,i.return,it)}}break;case 1:Yo(l,i),fs(i),k&512&&p!==null&&bl(p,p.return);break;case 5:if(Yo(l,i),fs(i),k&512&&p!==null&&bl(p,p.return),i.flags&32){var b=i.stateNode;try{gt(b,"")}catch(it){or(i,i.return,it)}}if(k&4&&(b=i.stateNode,b!=null)){var S=i.memoizedProps,O=p!==null?p.memoizedProps:S,Y=i.type,re=i.updateQueue;if(i.updateQueue=null,re!==null)try{Y==="input"&&S.type==="radio"&&S.name!=null&&Le(b,S),yn(Y,O);var ke=yn(Y,S);for(O=0;O<re.length;O+=2){var Re=re[O],ze=re[O+1];Re==="style"?Cn(b,ze):Re==="dangerouslySetInnerHTML"?$n(b,ze):Re==="children"?gt(b,ze):T(b,Re,ze,ke)}switch(Y){case"input":Ue(b,S);break;case"textarea":mt(b,S);break;case"select":var Ce=b._wrapperState.wasMultiple;b._wrapperState.wasMultiple=!!S.multiple;var Xe=S.value;Xe!=null?xt(b,!!S.multiple,Xe,!1):Ce!==!!S.multiple&&(S.defaultValue!=null?xt(b,!!S.multiple,S.defaultValue,!0):xt(b,!!S.multiple,S.multiple?[]:"",!1))}b[Ic]=S}catch(it){or(i,i.return,it)}}break;case 6:if(Yo(l,i),fs(i),k&4){if(i.stateNode===null)throw Error(n(162));b=i.stateNode,S=i.memoizedProps;try{b.nodeValue=S}catch(it){or(i,i.return,it)}}break;case 3:if(Yo(l,i),fs(i),k&4&&p!==null&&p.memoizedState.isDehydrated)try{Hi(l.containerInfo)}catch(it){or(i,i.return,it)}break;case 4:Yo(l,i),fs(i);break;case 13:Yo(l,i),fs(i),b=i.child,b.flags&8192&&(S=b.memoizedState!==null,b.stateNode.isHidden=S,!S||b.alternate!==null&&b.alternate.memoizedState!==null||(Lm=ln())),k&4&&T0(i);break;case 22:if(Re=p!==null&&p.memoizedState!==null,i.mode&1?(Ur=(ke=Ur)||Re,Yo(l,i),Ur=ke):Yo(l,i),fs(i),k&8192){if(ke=i.memoizedState!==null,(i.stateNode.isHidden=ke)&&!Re&&(i.mode&1)!==0)for(et=i,Re=i.child;Re!==null;){for(ze=et=Re;et!==null;){switch(Ce=et,Xe=Ce.child,Ce.tag){case 0:case 11:case 14:case 15:Uc(4,Ce,Ce.return);break;case 1:bl(Ce,Ce.return);var st=Ce.stateNode;if(typeof st.componentWillUnmount=="function"){k=Ce,p=Ce.return;try{l=k,st.props=l.memoizedProps,st.state=l.memoizedState,st.componentWillUnmount()}catch(it){or(k,p,it)}}break;case 5:bl(Ce,Ce.return);break;case 22:if(Ce.memoizedState!==null){A0(ze);continue}}Xe!==null?(Xe.return=Ce,et=Xe):A0(ze)}Re=Re.sibling}e:for(Re=null,ze=i;;){if(ze.tag===5){if(Re===null){Re=ze;try{b=ze.stateNode,ke?(S=b.style,typeof S.setProperty=="function"?S.setProperty("display","none","important"):S.display="none"):(Y=ze.stateNode,re=ze.memoizedProps.style,O=re!=null&&re.hasOwnProperty("display")?re.display:null,Y.style.display=Qt("display",O))}catch(it){or(i,i.return,it)}}}else if(ze.tag===6){if(Re===null)try{ze.stateNode.nodeValue=ke?"":ze.memoizedProps}catch(it){or(i,i.return,it)}}else if((ze.tag!==22&&ze.tag!==23||ze.memoizedState===null||ze===i)&&ze.child!==null){ze.child.return=ze,ze=ze.child;continue}if(ze===i)break e;for(;ze.sibling===null;){if(ze.return===null||ze.return===i)break e;Re===ze&&(Re=null),ze=ze.return}Re===ze&&(Re=null),ze.sibling.return=ze.return,ze=ze.sibling}}break;case 19:Yo(l,i),fs(i),k&4&&T0(i);break;case 21:break;default:Yo(l,i),fs(i)}}function fs(i){var l=i.flags;if(l&2){try{e:{for(var p=i.return;p!==null;){if(_0(p)){var k=p;break e}p=p.return}throw Error(n(160))}switch(k.tag){case 5:var b=k.stateNode;k.flags&32&&(gt(b,""),k.flags&=-33);var S=N0(i);Rm(i,S,b);break;case 3:case 4:var O=k.stateNode.containerInfo,Y=N0(i);Am(i,Y,O);break;default:throw Error(n(161))}}catch(re){or(i,i.return,re)}i.flags&=-3}l&4096&&(i.flags&=-4097)}function SI(i,l,p){et=i,C0(i)}function C0(i,l,p){for(var k=(i.mode&1)!==0;et!==null;){var b=et,S=b.child;if(b.tag===22&&k){var O=b.memoizedState!==null||Vd;if(!O){var Y=b.alternate,re=Y!==null&&Y.memoizedState!==null||Ur;Y=Vd;var ke=Ur;if(Vd=O,(Ur=re)&&!ke)for(et=b;et!==null;)O=et,re=O.child,O.tag===22&&O.memoizedState!==null?R0(b):re!==null?(re.return=O,et=re):R0(b);for(;S!==null;)et=S,C0(S),S=S.sibling;et=b,Vd=Y,Ur=ke}I0(i)}else(b.subtreeFlags&8772)!==0&&S!==null?(S.return=b,et=S):I0(i)}}function I0(i){for(;et!==null;){var l=et;if((l.flags&8772)!==0){var p=l.alternate;try{if((l.flags&8772)!==0)switch(l.tag){case 0:case 11:case 15:Ur||Yd(5,l);break;case 1:var k=l.stateNode;if(l.flags&4&&!Ur)if(p===null)k.componentDidMount();else{var b=l.elementType===l.type?p.memoizedProps:Go(l.type,p.memoizedProps);k.componentDidUpdate(b,p.memoizedState,k.__reactInternalSnapshotBeforeUpdate)}var S=l.updateQueue;S!==null&&Av(l,S,k);break;case 3:var O=l.updateQueue;if(O!==null){if(p=null,l.child!==null)switch(l.child.tag){case 5:p=l.child.stateNode;break;case 1:p=l.child.stateNode}Av(l,O,p)}break;case 5:var Y=l.stateNode;if(p===null&&l.flags&4){p=Y;var re=l.memoizedProps;switch(l.type){case"button":case"input":case"select":case"textarea":re.autoFocus&&p.focus();break;case"img":re.src&&(p.src=re.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(l.memoizedState===null){var ke=l.alternate;if(ke!==null){var Re=ke.memoizedState;if(Re!==null){var ze=Re.dehydrated;ze!==null&&Hi(ze)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(n(163))}Ur||l.flags&512&&Im(l)}catch(Ce){or(l,l.return,Ce)}}if(l===i){et=null;break}if(p=l.sibling,p!==null){p.return=l.return,et=p;break}et=l.return}}function A0(i){for(;et!==null;){var l=et;if(l===i){et=null;break}var p=l.sibling;if(p!==null){p.return=l.return,et=p;break}et=l.return}}function R0(i){for(;et!==null;){var l=et;try{switch(l.tag){case 0:case 11:case 15:var p=l.return;try{Yd(4,l)}catch(re){or(l,p,re)}break;case 1:var k=l.stateNode;if(typeof k.componentDidMount=="function"){var b=l.return;try{k.componentDidMount()}catch(re){or(l,b,re)}}var S=l.return;try{Im(l)}catch(re){or(l,S,re)}break;case 5:var O=l.return;try{Im(l)}catch(re){or(l,O,re)}}}catch(re){or(l,l.return,re)}if(l===i){et=null;break}var Y=l.sibling;if(Y!==null){Y.return=l.return,et=Y;break}et=l.return}}var _I=Math.ceil,Xd=j.ReactCurrentDispatcher,Om=j.ReactCurrentOwner,Lo=j.ReactCurrentBatchConfig,mn=0,Nr=null,hr=null,Or=0,bo=0,xl=li(0),xr=0,Hc=null,ia=0,Qd=0,Mm=0,Wc=null,oo=null,Lm=0,El=1/0,Is=null,Jd=!1,Pm=null,pi=null,ef=!1,mi=null,tf=0,Kc=0,Dm=null,nf=-1,rf=0;function Vr(){return(mn&6)!==0?ln():nf!==-1?nf:nf=ln()}function gi(i){return(i.mode&1)===0?1:(mn&2)!==0&&Or!==0?Or&-Or:lI.transition!==null?(rf===0&&(rf=On()),rf):(i=rn,i!==0||(i=window.event,i=i===void 0?16:Ki(i.type)),i)}function Xo(i,l,p,k){if(50<Kc)throw Kc=0,Dm=null,Error(n(185));zn(i,p,k),((mn&2)===0||i!==Nr)&&(i===Nr&&((mn&2)===0&&(Qd|=p),xr===4&&ki(i,Or)),so(i,k),p===1&&mn===0&&(l.mode&1)===0&&(El=ln()+500,Id&&ui()))}function so(i,l){var p=i.callbackNode;Vt(i,l);var k=ge(i,i===Nr?Or:0);if(k===0)p!==null&&kn(p),i.callbackNode=null,i.callbackPriority=0;else if(l=k&-k,i.callbackPriority!==l){if(p!=null&&kn(p),l===1)i.tag===0?aI(M0.bind(null,i)):vv(M0.bind(null,i)),rI(function(){(mn&6)===0&&ui()}),p=null;else{switch(vt(k)){case 1:p=nn;break;case 4:p=Bt;break;case 16:p=Ft;break;case 536870912:p=Ye;break;default:p=Ft}p=H0(p,O0.bind(null,i))}i.callbackPriority=l,i.callbackNode=p}}function O0(i,l){if(nf=-1,rf=0,(mn&6)!==0)throw Error(n(327));var p=i.callbackNode;if(Sl()&&i.callbackNode!==p)return null;var k=ge(i,i===Nr?Or:0);if(k===0)return null;if((k&30)!==0||(k&i.expiredLanes)!==0||l)l=of(i,k);else{l=k;var b=mn;mn|=2;var S=P0();(Nr!==i||Or!==l)&&(Is=null,El=ln()+500,la(i,l));do try{TI();break}catch(Y){L0(i,Y)}while(!0);nm(),Xd.current=S,mn=b,hr!==null?l=0:(Nr=null,Or=0,l=xr)}if(l!==0){if(l===2&&(b=Mt(i),b!==0&&(k=b,l=zm(i,b))),l===1)throw p=Hc,la(i,0),ki(i,k),so(i,ln()),p;if(l===6)ki(i,k);else{if(b=i.current.alternate,(k&30)===0&&!NI(b)&&(l=of(i,k),l===2&&(S=Mt(i),S!==0&&(k=S,l=zm(i,S))),l===1))throw p=Hc,la(i,0),ki(i,k),so(i,ln()),p;switch(i.finishedWork=b,i.finishedLanes=k,l){case 0:case 1:throw Error(n(345));case 2:ca(i,oo,Is);break;case 3:if(ki(i,k),(k&130023424)===k&&(l=Lm+500-ln(),10<l)){if(ge(i,0)!==0)break;if(b=i.suspendedLanes,(b&k)!==k){Vr(),i.pingedLanes|=i.suspendedLanes&b;break}i.timeoutHandle=Kp(ca.bind(null,i,oo,Is),l);break}ca(i,oo,Is);break;case 4:if(ki(i,k),(k&4194240)===k)break;for(l=i.eventTimes,b=-1;0<k;){var O=31-hn(k);S=1<<O,O=l[O],O>b&&(b=O),k&=~S}if(k=b,k=ln()-k,k=(120>k?120:480>k?480:1080>k?1080:1920>k?1920:3e3>k?3e3:4320>k?4320:1960*_I(k/1960))-k,10<k){i.timeoutHandle=Kp(ca.bind(null,i,oo,Is),k);break}ca(i,oo,Is);break;case 5:ca(i,oo,Is);break;default:throw Error(n(329))}}}return so(i,ln()),i.callbackNode===p?O0.bind(null,i):null}function zm(i,l){var p=Wc;return i.current.memoizedState.isDehydrated&&(la(i,l).flags|=256),i=of(i,l),i!==2&&(l=oo,oo=p,l!==null&&Fm(l)),i}function Fm(i){oo===null?oo=i:oo.push.apply(oo,i)}function NI(i){for(var l=i;;){if(l.flags&16384){var p=l.updateQueue;if(p!==null&&(p=p.stores,p!==null))for(var k=0;k<p.length;k++){var b=p[k],S=b.getSnapshot;b=b.value;try{if(!eo(S(),b))return!1}catch{return!1}}}if(p=l.child,l.subtreeFlags&16384&&p!==null)p.return=l,l=p;else{if(l===i)break;for(;l.sibling===null;){if(l.return===null||l.return===i)return!0;l=l.return}l.sibling.return=l.return,l=l.sibling}}return!0}function ki(i,l){for(l&=~Mm,l&=~Qd,i.suspendedLanes|=l,i.pingedLanes&=~l,i=i.expirationTimes;0<l;){var p=31-hn(l),k=1<<p;i[p]=-1,l&=~k}}function M0(i){if((mn&6)!==0)throw Error(n(327));Sl();var l=ge(i,0);if((l&1)===0)return so(i,ln()),null;var p=of(i,l);if(i.tag!==0&&p===2){var k=Mt(i);k!==0&&(l=k,p=zm(i,k))}if(p===1)throw p=Hc,la(i,0),ki(i,l),so(i,ln()),p;if(p===6)throw Error(n(345));return i.finishedWork=i.current.alternate,i.finishedLanes=l,ca(i,oo,Is),so(i,ln()),null}function Bm(i,l){var p=mn;mn|=1;try{return i(l)}finally{mn=p,mn===0&&(El=ln()+500,Id&&ui())}}function aa(i){mi!==null&&mi.tag===0&&(mn&6)===0&&Sl();var l=mn;mn|=1;var p=Lo.transition,k=rn;try{if(Lo.transition=null,rn=1,i)return i()}finally{rn=k,Lo.transition=p,mn=l,(mn&6)===0&&ui()}}function Um(){bo=xl.current,Hn(xl)}function la(i,l){i.finishedWork=null,i.finishedLanes=0;var p=i.timeoutHandle;if(p!==-1&&(i.timeoutHandle=-1,nI(p)),hr!==null)for(p=hr.return;p!==null;){var k=p;switch(Xp(k),k.tag){case 1:k=k.type.childContextTypes,k!=null&&$d();break;case 3:yl(),Hn(to),Hn(zr),um();break;case 5:lm(k);break;case 4:yl();break;case 13:Hn(Qn);break;case 19:Hn(Qn);break;case 10:rm(k.type._context);break;case 22:case 23:Um()}p=p.return}if(Nr=i,hr=i=wi(i.current,null),Or=bo=l,xr=0,Hc=null,Mm=Qd=ia=0,oo=Wc=null,ra!==null){for(l=0;l<ra.length;l++)if(p=ra[l],k=p.interleaved,k!==null){p.interleaved=null;var b=k.next,S=p.pending;if(S!==null){var O=S.next;S.next=b,k.next=O}p.pending=k}ra=null}return i}function L0(i,l){do{var p=hr;try{if(nm(),Bd.current=Kd,Ud){for(var k=Jn.memoizedState;k!==null;){var b=k.queue;b!==null&&(b.pending=null),k=k.next}Ud=!1}if(sa=0,_r=br=Jn=null,Pc=!1,Dc=0,Om.current=null,p===null||p.return===null){xr=1,Hc=l,hr=null;break}e:{var S=i,O=p.return,Y=p,re=l;if(l=Or,Y.flags|=32768,re!==null&&typeof re=="object"&&typeof re.then=="function"){var ke=re,Re=Y,ze=Re.tag;if((Re.mode&1)===0&&(ze===0||ze===11||ze===15)){var Ce=Re.alternate;Ce?(Re.updateQueue=Ce.updateQueue,Re.memoizedState=Ce.memoizedState,Re.lanes=Ce.lanes):(Re.updateQueue=null,Re.memoizedState=null)}var Xe=a0(O);if(Xe!==null){Xe.flags&=-257,l0(Xe,O,Y,S,l),Xe.mode&1&&i0(S,ke,l),l=Xe,re=ke;var st=l.updateQueue;if(st===null){var it=new Set;it.add(re),l.updateQueue=it}else st.add(re);break e}else{if((l&1)===0){i0(S,ke,l),Hm();break e}re=Error(n(426))}}else if(Vn&&Y.mode&1){var ar=a0(O);if(ar!==null){(ar.flags&65536)===0&&(ar.flags|=256),l0(ar,O,Y,S,l),em(vl(re,Y));break e}}S=re=vl(re,Y),xr!==4&&(xr=2),Wc===null?Wc=[S]:Wc.push(S),S=O;do{switch(S.tag){case 3:S.flags|=65536,l&=-l,S.lanes|=l;var fe=o0(S,re,l);Iv(S,fe);break e;case 1:Y=re;var le=S.type,me=S.stateNode;if((S.flags&128)===0&&(typeof le.getDerivedStateFromError=="function"||me!==null&&typeof me.componentDidCatch=="function"&&(pi===null||!pi.has(me)))){S.flags|=65536,l&=-l,S.lanes|=l;var He=s0(S,Y,l);Iv(S,He);break e}}S=S.return}while(S!==null)}z0(p)}catch(ut){l=ut,hr===p&&p!==null&&(hr=p=p.return);continue}break}while(!0)}function P0(){var i=Xd.current;return Xd.current=Kd,i===null?Kd:i}function Hm(){(xr===0||xr===3||xr===2)&&(xr=4),Nr===null||(ia&268435455)===0&&(Qd&268435455)===0||ki(Nr,Or)}function of(i,l){var p=mn;mn|=2;var k=P0();(Nr!==i||Or!==l)&&(Is=null,la(i,l));do try{jI();break}catch(b){L0(i,b)}while(!0);if(nm(),mn=p,Xd.current=k,hr!==null)throw Error(n(261));return Nr=null,Or=0,xr}function jI(){for(;hr!==null;)D0(hr)}function TI(){for(;hr!==null&&!Pr();)D0(hr)}function D0(i){var l=U0(i.alternate,i,bo);i.memoizedProps=i.pendingProps,l===null?z0(i):hr=l,Om.current=null}function z0(i){var l=i;do{var p=l.alternate;if(i=l.return,(l.flags&32768)===0){if(p=vI(p,l,bo),p!==null){hr=p;return}}else{if(p=bI(p,l),p!==null){p.flags&=32767,hr=p;return}if(i!==null)i.flags|=32768,i.subtreeFlags=0,i.deletions=null;else{xr=6,hr=null;return}}if(l=l.sibling,l!==null){hr=l;return}hr=l=i}while(l!==null);xr===0&&(xr=5)}function ca(i,l,p){var k=rn,b=Lo.transition;try{Lo.transition=null,rn=1,$I(i,l,p,k)}finally{Lo.transition=b,rn=k}return null}function $I(i,l,p,k){do Sl();while(mi!==null);if((mn&6)!==0)throw Error(n(327));p=i.finishedWork;var b=i.finishedLanes;if(p===null)return null;if(i.finishedWork=null,i.finishedLanes=0,p===i.current)throw Error(n(177));i.callbackNode=null,i.callbackPriority=0;var S=p.lanes|p.childLanes;if(ir(i,S),i===Nr&&(hr=Nr=null,Or=0),(p.subtreeFlags&2064)===0&&(p.flags&2064)===0||ef||(ef=!0,H0(Ft,function(){return Sl(),null})),S=(p.flags&15990)!==0,(p.subtreeFlags&15990)!==0||S){S=Lo.transition,Lo.transition=null;var O=rn;rn=1;var Y=mn;mn|=4,Om.current=null,EI(i,p),$0(p,i),bd(Hp),Ha=!!Up,Hp=Up=null,i.current=p,SI(p),cr(),mn=Y,rn=O,Lo.transition=S}else i.current=p;if(ef&&(ef=!1,mi=i,tf=b),S=i.pendingLanes,S===0&&(pi=null),cn(p.stateNode),so(i,ln()),l!==null)for(k=i.onRecoverableError,p=0;p<l.length;p++)b=l[p],k(b.value,{componentStack:b.stack,digest:b.digest});if(Jd)throw Jd=!1,i=Pm,Pm=null,i;return(tf&1)!==0&&i.tag!==0&&Sl(),S=i.pendingLanes,(S&1)!==0?i===Dm?Kc++:(Kc=0,Dm=i):Kc=0,ui(),null}function Sl(){if(mi!==null){var i=vt(tf),l=Lo.transition,p=rn;try{if(Lo.transition=null,rn=16>i?16:i,mi===null)var k=!1;else{if(i=mi,mi=null,tf=0,(mn&6)!==0)throw Error(n(331));var b=mn;for(mn|=4,et=i.current;et!==null;){var S=et,O=S.child;if((et.flags&16)!==0){var Y=S.deletions;if(Y!==null){for(var re=0;re<Y.length;re++){var ke=Y[re];for(et=ke;et!==null;){var Re=et;switch(Re.tag){case 0:case 11:case 15:Uc(8,Re,S)}var ze=Re.child;if(ze!==null)ze.return=Re,et=ze;else for(;et!==null;){Re=et;var Ce=Re.sibling,Xe=Re.return;if(S0(Re),Re===ke){et=null;break}if(Ce!==null){Ce.return=Xe,et=Ce;break}et=Xe}}}var st=S.alternate;if(st!==null){var it=st.child;if(it!==null){st.child=null;do{var ar=it.sibling;it.sibling=null,it=ar}while(it!==null)}}et=S}}if((S.subtreeFlags&2064)!==0&&O!==null)O.return=S,et=O;else e:for(;et!==null;){if(S=et,(S.flags&2048)!==0)switch(S.tag){case 0:case 11:case 15:Uc(9,S,S.return)}var fe=S.sibling;if(fe!==null){fe.return=S.return,et=fe;break e}et=S.return}}var le=i.current;for(et=le;et!==null;){O=et;var me=O.child;if((O.subtreeFlags&2064)!==0&&me!==null)me.return=O,et=me;else e:for(O=le;et!==null;){if(Y=et,(Y.flags&2048)!==0)try{switch(Y.tag){case 0:case 11:case 15:Yd(9,Y)}}catch(ut){or(Y,Y.return,ut)}if(Y===O){et=null;break e}var He=Y.sibling;if(He!==null){He.return=Y.return,et=He;break e}et=Y.return}}if(mn=b,ui(),yt&&typeof yt.onPostCommitFiberRoot=="function")try{yt.onPostCommitFiberRoot(wt,i)}catch{}k=!0}return k}finally{rn=p,Lo.transition=l}}return!1}function F0(i,l,p){l=vl(p,l),l=o0(i,l,1),i=fi(i,l,1),l=Vr(),i!==null&&(zn(i,1,l),so(i,l))}function or(i,l,p){if(i.tag===3)F0(i,i,p);else for(;l!==null;){if(l.tag===3){F0(l,i,p);break}else if(l.tag===1){var k=l.stateNode;if(typeof l.type.getDerivedStateFromError=="function"||typeof k.componentDidCatch=="function"&&(pi===null||!pi.has(k))){i=vl(p,i),i=s0(l,i,1),l=fi(l,i,1),i=Vr(),l!==null&&(zn(l,1,i),so(l,i));break}}l=l.return}}function CI(i,l,p){var k=i.pingCache;k!==null&&k.delete(l),l=Vr(),i.pingedLanes|=i.suspendedLanes&p,Nr===i&&(Or&p)===p&&(xr===4||xr===3&&(Or&130023424)===Or&&500>ln()-Lm?la(i,0):Mm|=p),so(i,l)}function B0(i,l){l===0&&((i.mode&1)===0?l=1:(l=yr,yr<<=1,(yr&130023424)===0&&(yr=4194304)));var p=Vr();i=Ts(i,l),i!==null&&(zn(i,l,p),so(i,p))}function II(i){var l=i.memoizedState,p=0;l!==null&&(p=l.retryLane),B0(i,p)}function AI(i,l){var p=0;switch(i.tag){case 13:var k=i.stateNode,b=i.memoizedState;b!==null&&(p=b.retryLane);break;case 19:k=i.stateNode;break;default:throw Error(n(314))}k!==null&&k.delete(l),B0(i,p)}var U0;U0=function(i,l,p){if(i!==null)if(i.memoizedProps!==l.pendingProps||to.current)ro=!0;else{if((i.lanes&p)===0&&(l.flags&128)===0)return ro=!1,yI(i,l,p);ro=(i.flags&131072)!==0}else ro=!1,Vn&&(l.flags&1048576)!==0&&bv(l,Rd,l.index);switch(l.lanes=0,l.tag){case 2:var k=l.type;Gd(i,l),i=l.pendingProps;var b=fl(l,zr.current);wl(l,p),b=hm(null,l,k,i,b,p);var S=pm();return l.flags|=1,typeof b=="object"&&b!==null&&typeof b.render=="function"&&b.$$typeof===void 0?(l.tag=1,l.memoizedState=null,l.updateQueue=null,no(k)?(S=!0,Cd(l)):S=!1,l.memoizedState=b.state!==null&&b.state!==void 0?b.state:null,im(l),b.updater=qd,l.stateNode=b,b._reactInternals=l,vm(l,k,i,p),l=Sm(null,l,k,!0,S,p)):(l.tag=0,Vn&&S&&Yp(l),Gr(null,l,b,p),l=l.child),l;case 16:k=l.elementType;e:{switch(Gd(i,l),i=l.pendingProps,b=k._init,k=b(k._payload),l.type=k,b=l.tag=OI(k),i=Go(k,i),b){case 0:l=Em(null,l,k,i,p);break e;case 1:l=p0(null,l,k,i,p);break e;case 11:l=c0(null,l,k,i,p);break e;case 14:l=u0(null,l,k,Go(k.type,i),p);break e}throw Error(n(306,k,""))}return l;case 0:return k=l.type,b=l.pendingProps,b=l.elementType===k?b:Go(k,b),Em(i,l,k,b,p);case 1:return k=l.type,b=l.pendingProps,b=l.elementType===k?b:Go(k,b),p0(i,l,k,b,p);case 3:e:{if(m0(l),i===null)throw Error(n(387));k=l.pendingProps,S=l.memoizedState,b=S.element,Cv(i,l),zd(l,k,null,p);var O=l.memoizedState;if(k=O.element,S.isDehydrated)if(S={element:k,isDehydrated:!1,cache:O.cache,pendingSuspenseBoundaries:O.pendingSuspenseBoundaries,transitions:O.transitions},l.updateQueue.baseState=S,l.memoizedState=S,l.flags&256){b=vl(Error(n(423)),l),l=g0(i,l,k,p,b);break e}else if(k!==b){b=vl(Error(n(424)),l),l=g0(i,l,k,p,b);break e}else for(vo=ai(l.stateNode.containerInfo.firstChild),yo=l,Vn=!0,Zo=null,p=Tv(l,null,k,p),l.child=p;p;)p.flags=p.flags&-3|4096,p=p.sibling;else{if(ml(),k===b){l=Cs(i,l,p);break e}Gr(i,l,k,p)}l=l.child}return l;case 5:return Rv(l),i===null&&Jp(l),k=l.type,b=l.pendingProps,S=i!==null?i.memoizedProps:null,O=b.children,Wp(k,b)?O=null:S!==null&&Wp(k,S)&&(l.flags|=32),h0(i,l),Gr(i,l,O,p),l.child;case 6:return i===null&&Jp(l),null;case 13:return k0(i,l,p);case 4:return am(l,l.stateNode.containerInfo),k=l.pendingProps,i===null?l.child=gl(l,null,k,p):Gr(i,l,k,p),l.child;case 11:return k=l.type,b=l.pendingProps,b=l.elementType===k?b:Go(k,b),c0(i,l,k,b,p);case 7:return Gr(i,l,l.pendingProps,p),l.child;case 8:return Gr(i,l,l.pendingProps.children,p),l.child;case 12:return Gr(i,l,l.pendingProps.children,p),l.child;case 10:e:{if(k=l.type._context,b=l.pendingProps,S=l.memoizedProps,O=b.value,Ln(Ld,k._currentValue),k._currentValue=O,S!==null)if(eo(S.value,O)){if(S.children===b.children&&!to.current){l=Cs(i,l,p);break e}}else for(S=l.child,S!==null&&(S.return=l);S!==null;){var Y=S.dependencies;if(Y!==null){O=S.child;for(var re=Y.firstContext;re!==null;){if(re.context===k){if(S.tag===1){re=$s(-1,p&-p),re.tag=2;var ke=S.updateQueue;if(ke!==null){ke=ke.shared;var Re=ke.pending;Re===null?re.next=re:(re.next=Re.next,Re.next=re),ke.pending=re}}S.lanes|=p,re=S.alternate,re!==null&&(re.lanes|=p),om(S.return,p,l),Y.lanes|=p;break}re=re.next}}else if(S.tag===10)O=S.type===l.type?null:S.child;else if(S.tag===18){if(O=S.return,O===null)throw Error(n(341));O.lanes|=p,Y=O.alternate,Y!==null&&(Y.lanes|=p),om(O,p,l),O=S.sibling}else O=S.child;if(O!==null)O.return=S;else for(O=S;O!==null;){if(O===l){O=null;break}if(S=O.sibling,S!==null){S.return=O.return,O=S;break}O=O.return}S=O}Gr(i,l,b.children,p),l=l.child}return l;case 9:return b=l.type,k=l.pendingProps.children,wl(l,p),b=Oo(b),k=k(b),l.flags|=1,Gr(i,l,k,p),l.child;case 14:return k=l.type,b=Go(k,l.pendingProps),b=Go(k.type,b),u0(i,l,k,b,p);case 15:return d0(i,l,l.type,l.pendingProps,p);case 17:return k=l.type,b=l.pendingProps,b=l.elementType===k?b:Go(k,b),Gd(i,l),l.tag=1,no(k)?(i=!0,Cd(l)):i=!1,wl(l,p),n0(l,k,b),vm(l,k,b,p),Sm(null,l,k,!0,i,p);case 19:return y0(i,l,p);case 22:return f0(i,l,p)}throw Error(n(156,l.tag))};function H0(i,l){return zt(i,l)}function RI(i,l,p,k){this.tag=i,this.key=p,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=l,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=k,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Po(i,l,p,k){return new RI(i,l,p,k)}function Wm(i){return i=i.prototype,!(!i||!i.isReactComponent)}function OI(i){if(typeof i=="function")return Wm(i)?1:0;if(i!=null){if(i=i.$$typeof,i===Z)return 11;if(i===V)return 14}return 2}function wi(i,l){var p=i.alternate;return p===null?(p=Po(i.tag,l,i.key,i.mode),p.elementType=i.elementType,p.type=i.type,p.stateNode=i.stateNode,p.alternate=i,i.alternate=p):(p.pendingProps=l,p.type=i.type,p.flags=0,p.subtreeFlags=0,p.deletions=null),p.flags=i.flags&14680064,p.childLanes=i.childLanes,p.lanes=i.lanes,p.child=i.child,p.memoizedProps=i.memoizedProps,p.memoizedState=i.memoizedState,p.updateQueue=i.updateQueue,l=i.dependencies,p.dependencies=l===null?null:{lanes:l.lanes,firstContext:l.firstContext},p.sibling=i.sibling,p.index=i.index,p.ref=i.ref,p}function sf(i,l,p,k,b,S){var O=2;if(k=i,typeof i=="function")Wm(i)&&(O=1);else if(typeof i=="string")O=5;else e:switch(i){case C:return ua(p.children,b,S,l);case M:O=8,b|=8;break;case I:return i=Po(12,p,l,b|2),i.elementType=I,i.lanes=S,i;case B:return i=Po(13,p,l,b),i.elementType=B,i.lanes=S,i;case J:return i=Po(19,p,l,b),i.elementType=J,i.lanes=S,i;case F:return af(p,b,S,l);default:if(typeof i=="object"&&i!==null)switch(i.$$typeof){case D:O=10;break e;case H:O=9;break e;case Z:O=11;break e;case V:O=14;break e;case ee:O=16,k=null;break e}throw Error(n(130,i==null?i:typeof i,""))}return l=Po(O,p,l,b),l.elementType=i,l.type=k,l.lanes=S,l}function ua(i,l,p,k){return i=Po(7,i,k,l),i.lanes=p,i}function af(i,l,p,k){return i=Po(22,i,k,l),i.elementType=F,i.lanes=p,i.stateNode={isHidden:!1},i}function Km(i,l,p){return i=Po(6,i,null,l),i.lanes=p,i}function qm(i,l,p){return l=Po(4,i.children!==null?i.children:[],i.key,l),l.lanes=p,l.stateNode={containerInfo:i.containerInfo,pendingChildren:null,implementation:i.implementation},l}function MI(i,l,p,k,b){this.tag=l,this.containerInfo=i,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Sn(0),this.expirationTimes=Sn(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Sn(0),this.identifierPrefix=k,this.onRecoverableError=b,this.mutableSourceEagerHydrationData=null}function Zm(i,l,p,k,b,S,O,Y,re){return i=new MI(i,l,p,Y,re),l===1?(l=1,S===!0&&(l|=8)):l=0,S=Po(3,null,null,l),i.current=S,S.stateNode=i,S.memoizedState={element:k,isDehydrated:p,cache:null,transitions:null,pendingSuspenseBoundaries:null},im(S),i}function LI(i,l,p){var k=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:R,key:k==null?null:""+k,children:i,containerInfo:l,implementation:p}}function W0(i){if(!i)return ci;i=i._reactInternals;e:{if(Rn(i)!==i||i.tag!==1)throw Error(n(170));var l=i;do{switch(l.tag){case 3:l=l.stateNode.context;break e;case 1:if(no(l.type)){l=l.stateNode.__reactInternalMemoizedMergedChildContext;break e}}l=l.return}while(l!==null);throw Error(n(171))}if(i.tag===1){var p=i.type;if(no(p))return wv(i,p,l)}return l}function K0(i,l,p,k,b,S,O,Y,re){return i=Zm(p,k,!0,i,b,S,O,Y,re),i.context=W0(null),p=i.current,k=Vr(),b=gi(p),S=$s(k,b),S.callback=l??null,fi(p,S,b),i.current.lanes=b,zn(i,b,k),so(i,k),i}function lf(i,l,p,k){var b=l.current,S=Vr(),O=gi(b);return p=W0(p),l.context===null?l.context=p:l.pendingContext=p,l=$s(S,O),l.payload={element:i},k=k===void 0?null:k,k!==null&&(l.callback=k),i=fi(b,l,O),i!==null&&(Xo(i,b,O,S),Dd(i,b,O)),O}function cf(i){if(i=i.current,!i.child)return null;switch(i.child.tag){case 5:return i.child.stateNode;default:return i.child.stateNode}}function q0(i,l){if(i=i.memoizedState,i!==null&&i.dehydrated!==null){var p=i.retryLane;i.retryLane=p!==0&&p<l?p:l}}function Gm(i,l){q0(i,l),(i=i.alternate)&&q0(i,l)}function PI(){return null}var Z0=typeof reportError=="function"?reportError:function(i){console.error(i)};function Vm(i){this._internalRoot=i}uf.prototype.render=Vm.prototype.render=function(i){var l=this._internalRoot;if(l===null)throw Error(n(409));lf(i,l,null,null)},uf.prototype.unmount=Vm.prototype.unmount=function(){var i=this._internalRoot;if(i!==null){this._internalRoot=null;var l=i.containerInfo;aa(function(){lf(null,i,null,null)}),l[Ss]=null}};function uf(i){this._internalRoot=i}uf.prototype.unstable_scheduleHydration=function(i){if(i){var l=Ar();i={blockedOn:null,target:i,priority:l};for(var p=0;p<$t.length&&l!==0&&l<$t[p].priority;p++);$t.splice(p,0,i),p===0&&En(i)}};function Ym(i){return!(!i||i.nodeType!==1&&i.nodeType!==9&&i.nodeType!==11)}function df(i){return!(!i||i.nodeType!==1&&i.nodeType!==9&&i.nodeType!==11&&(i.nodeType!==8||i.nodeValue!==" react-mount-point-unstable "))}function G0(){}function DI(i,l,p,k,b){if(b){if(typeof k=="function"){var S=k;k=function(){var ke=cf(O);S.call(ke)}}var O=K0(l,k,i,0,null,!1,!1,"",G0);return i._reactRootContainer=O,i[Ss]=O.current,$c(i.nodeType===8?i.parentNode:i),aa(),O}for(;b=i.lastChild;)i.removeChild(b);if(typeof k=="function"){var Y=k;k=function(){var ke=cf(re);Y.call(ke)}}var re=Zm(i,0,!1,null,null,!1,!1,"",G0);return i._reactRootContainer=re,i[Ss]=re.current,$c(i.nodeType===8?i.parentNode:i),aa(function(){lf(l,re,p,k)}),re}function ff(i,l,p,k,b){var S=p._reactRootContainer;if(S){var O=S;if(typeof b=="function"){var Y=b;b=function(){var re=cf(O);Y.call(re)}}lf(l,O,i,b)}else O=DI(p,l,i,b,k);return cf(O)}ko=function(i){switch(i.tag){case 3:var l=i.stateNode;if(l.current.memoizedState.isDehydrated){var p=X(l.pendingLanes);p!==0&&(go(l,p|1),so(l,ln()),(mn&6)===0&&(El=ln()+500,ui()))}break;case 13:aa(function(){var k=Ts(i,1);if(k!==null){var b=Vr();Xo(k,i,1,b)}}),Gm(i,1)}},Fn=function(i){if(i.tag===13){var l=Ts(i,134217728);if(l!==null){var p=Vr();Xo(l,i,134217728,p)}Gm(i,134217728)}},on=function(i){if(i.tag===13){var l=gi(i),p=Ts(i,l);if(p!==null){var k=Vr();Xo(p,i,l,k)}Gm(i,l)}},Ar=function(){return rn},dr=function(i,l){var p=rn;try{return rn=i,l()}finally{rn=p}},qe=function(i,l,p){switch(l){case"input":if(Ue(i,p),l=p.name,p.type==="radio"&&l!=null){for(p=i;p.parentNode;)p=p.parentNode;for(p=p.querySelectorAll("input[name="+JSON.stringify(""+l)+'][type="radio"]'),l=0;l<p.length;l++){var k=p[l];if(k!==i&&k.form===i.form){var b=Td(k);if(!b)throw Error(n(90));ie(k),Ue(k,b)}}}break;case"textarea":mt(i,p);break;case"select":l=p.value,l!=null&&xt(i,!!p.multiple,l,!1)}},je=Bm,Fe=aa;var zI={usingClientEntryPoint:!1,Events:[Ac,ul,Td,P,se,Bm]},qc={findFiberByHostInstance:Ji,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},FI={bundleType:qc.bundleType,version:qc.version,rendererPackageName:qc.rendererPackageName,rendererConfig:qc.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:j.ReactCurrentDispatcher,findHostInstanceByFiber:function(i){return i=ht(i),i===null?null:i.stateNode},findFiberByHostInstance:qc.findFiberByHostInstance||PI,findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null,reconcilerVersion:"18.3.1-next-f1338f8080-20240426"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var hf=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!hf.isDisabled&&hf.supportsFiber)try{wt=hf.inject(FI),yt=hf}catch{}}return io.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=zI,io.createPortal=function(i,l){var p=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!Ym(l))throw Error(n(200));return LI(i,l,null,p)},io.createRoot=function(i,l){if(!Ym(i))throw Error(n(299));var p=!1,k="",b=Z0;return l!=null&&(l.unstable_strictMode===!0&&(p=!0),l.identifierPrefix!==void 0&&(k=l.identifierPrefix),l.onRecoverableError!==void 0&&(b=l.onRecoverableError)),l=Zm(i,1,!1,null,null,p,!1,k,b),i[Ss]=l.current,$c(i.nodeType===8?i.parentNode:i),new Vm(l)},io.findDOMNode=function(i){if(i==null)return null;if(i.nodeType===1)return i;var l=i._reactInternals;if(l===void 0)throw typeof i.render=="function"?Error(n(188)):(i=Object.keys(i).join(","),Error(n(268,i)));return i=ht(l),i=i===null?null:i.stateNode,i},io.flushSync=function(i){return aa(i)},io.hydrate=function(i,l,p){if(!df(l))throw Error(n(200));return ff(null,i,l,!0,p)},io.hydrateRoot=function(i,l,p){if(!Ym(i))throw Error(n(405));var k=p!=null&&p.hydratedSources||null,b=!1,S="",O=Z0;if(p!=null&&(p.unstable_strictMode===!0&&(b=!0),p.identifierPrefix!==void 0&&(S=p.identifierPrefix),p.onRecoverableError!==void 0&&(O=p.onRecoverableError)),l=K0(l,null,i,1,p??null,b,!1,S,O),i[Ss]=l.current,$c(i),k)for(i=0;i<k.length;i++)p=k[i],b=p._getVersion,b=b(p._source),l.mutableSourceEagerHydrationData==null?l.mutableSourceEagerHydrationData=[p,b]:l.mutableSourceEagerHydrationData.push(p,b);return new uf(l)},io.render=function(i,l,p){if(!df(l))throw Error(n(200));return ff(null,i,l,!1,p)},io.unmountComponentAtNode=function(i){if(!df(i))throw Error(n(40));return i._reactRootContainer?(aa(function(){ff(null,null,i,!1,function(){i._reactRootContainer=null,i[Ss]=null})}),!0):!1},io.unstable_batchedUpdates=Bm,io.unstable_renderSubtreeIntoContainer=function(i,l,p,k){if(!df(p))throw Error(n(200));if(i==null||i._reactInternals===void 0)throw Error(n(38));return ff(i,l,p,!1,k)},io.version="18.3.1-next-f1338f8080-20240426",io}var nb;function JE(){if(nb)return Jm.exports;nb=1;function e(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}return e(),Jm.exports=YI(),Jm.exports}var eS=JE(),pf={},rb;function XI(){if(rb)return pf;rb=1;var e=JE();return pf.createRoot=e.createRoot,pf.hydrateRoot=e.hydrateRoot,pf}var QI=XI();const Ai="shell",tS="check",$a="ToolSearch",cw="AskUserQuestion",uw="handoff",nS="worktrees",rS="own";function mf(e){const t=[];for(const n of e){const r=t.at(-1),{event:o}=n;o.type==="text-delta"&&(r==null?void 0:r.event.type)==="text-delta"&&r.event.messageId===o.messageId?t[t.length-1]={seq:r.seq,event:{...r.event,text:r.event.text+o.text}}:o.type==="thinking-delta"&&(r==null?void 0:r.event.type)==="thinking-delta"?t[t.length-1]={seq:r.seq,event:{type:"thinking-delta",text:r.event.text+o.text}}:o.type==="tool-delta"&&(r==null?void 0:r.event.type)==="tool-delta"&&r.event.toolId===o.toolId?t[t.length-1]={seq:r.seq,event:{...o,text:r.event.text+o.text}}:t.push(n)}return t}const JI=new Set(["edit","delete","move","execute"]),eA=new Set(["Edit","Write","MultiEdit","NotebookEdit","Bash"]);function oS(e){return e.kind?JI.has(e.kind):eA.has(e.name)}const tA=["read","edit","delete","move","search","execute","fetch"];function dw(e){return tA.includes(e??"")}function sS(e,t){return(dw(e.kind)||e.name===cw||e.name===$a)&&Ch(t)}const nA=/^(?:mcp__(.+?)__(.+)|([A-Za-z0-9_-]+)\/([A-Za-z0-9_-]+))$/;function rA(e){const t=nA.exec(e);if(!t)return null;const n=t[1]??t[3]??"",r=t[2]??t[4]??"";return{server:n,tool:r.replace(/[_-]+/g," ").trim()}}function Ch(e){if(!e||typeof e!="object")return!0;const t=e;return Object.keys(t).every(n=>n==="locations"&&Array.isArray(t[n])&&t[n].length===0)}const Ih=[{id:"auto",name:"auto",description:"edits and sandboxed commands run; a plan still asks"},{id:"ask",name:"ask",description:"every edit and command is a card before it runs"},{id:"plan",name:"plan",description:"read and propose only; approving the plan starts the work"}],Wg="auto";function oA(e){return e.branch.startsWith("toyon/")}function sA(e){return e.unread===!0||e.lastTurn!=null&&(e.seenAt==null||e.seenAt<e.lastTurn.at)}const Ah=e=>e==="running"||e==="starting"||e==="preparing"||e==="cold",zo="shell",Ds="login";function iA(e,t){return`${e}/${t}`}function aA(e,t,n,r=0){var s;let o=e;for(let a=r;a>0;a--){let c=o.length-1;for(;c>=0&&((s=o[c])==null?void 0:s.proc)!==t;)c--;if(c<0)break;o=o===e?[...o]:o,o.splice(c,1)}return n?[...o,{proc:t,line:n}]:o}const ss=e=>e==="working"||e==="waiting",lA=["use","always","off"];function iS(e){return e.find(t=>t.id==="default")}function cA(e,t){const n=iS(e);if(n){if(t!==void 0&&t!==n.id){const r=e.find(o=>o.id===t);if(r)return r}if(n.description)return e.find(r=>r!==n&&r.name===n.description)}}function uA(e,t){if(t.some(o=>o.id===e))return e;const n=ob(e);if(n===void 0)return;if(t.some(o=>o.id===n))return n;if(n!==fw(e))return;let r;for(const o of t){if(ob(o.id)!==n)continue;const s=dA(o.id);s!==void 0&&(r===void 0||s>r.version)&&(r={id:o.id,version:s})}return r==null?void 0:r.id}const aS=/(?:^|[./])claude-(?:(\d{1,2})(?:-(\d{1,2})(?!\d))?-)?([a-z]+)(?:-(\d{1,2})(?!\d)(?:-(\d{1,2})(?!\d))?)?/;function fw(e){return e.replace(/\[[^\]]*\]$/,"")}function ob(e){var r;const t=fw(e),n=(r=t.match(aS))==null?void 0:r[3];return n||(/^[a-z]+$/.test(t)?t:void 0)}function dA(e){const t=fw(e).match(aS);if(!t)return;const n=t[1]??t[4];if(n===void 0)return;const r=t[1]!==void 0?t[2]:t[5];return Number(n)+Number(r??0)/100}function Nn(e){return e.worktree!==void 0}function Ri(e){return e.kind==="main"}function Rh(e){return e.kind==="spare"}function Cr(e){return Rh(e)||Ri(e)}function Oh(e){return e.kind==="worktree"}function lS(e){return e.kind==="worktree"&&oA(e)}function ya(e){var t;return e.kind==="worktree"&&((t=e.from)==null?void 0:t.kind)!=="pr"}function Df(e){return e.kind==="worktree"}function Mh(e){return!!e.branch&&!e.locked&&!(e.worktree&&Cr(e.worktree))}const Ca=e=>{var t;return e.promptedAt??((t=e.lastTurn)==null?void 0:t.at)??e.createdAt},sb=e=>Cr(e)?0:1;function fA(e){return[...e].sort((t,n)=>sb(t.worktree)-sb(n.worktree)||Ca(n.worktree)-Ca(t.worktree))}function ib(e,t){const n=new Map;for(const r of e)n.set(r.id,r.promptedAt??0);for(const r of t){if(!Nn(r)||r.worktree.kind==="spare")continue;const o=r.worktree.repoId;n.set(o,Math.max(n.get(o)??0,Ca(r.worktree)))}return[...e].sort((r,o)=>(n.get(o.id)??0)-(n.get(r.id)??0))}function hA(e,t){var o,s;const n=t.counts(e.id);if(n.dirty===void 0||n.ahead===void 0)return"its changes are not counted yet";if(n.dirty>0)return"it has uncommitted changes";if(n.ahead>0)return"it has commits not on main";if(t.drafted(e.id))return"unsent text waits in its composer";if(t.pending(e.id))return"its agent is still busy";if(e.landed)return null;const r=(o=e.lastTurn)==null?void 0:o.end;return r?r==="stopped"?"its last turn was stopped":r==="failed"?"its last turn failed":r==="asking"?"its agent is waiting on an answer":sA(e)?"its last reply is unread":e.planned?"it showed a plan":((s=e.pr)==null?void 0:s.state)==="open"?"its pull request is still open":null:"its agent has not run yet"}const ab="not opened in ";function pA(e){const t=e.lastIndexOf(ab);return t<0?{what:e}:{what:e.slice(0,t).replace(/,\s*$/,""),idle:e.slice(t+ab.length)}}const cS={image:6,paste:4,file:8,pick:8},mA={image:"image",paste:"paste",file:"file",pick:"element"},gA={image:"Image",paste:"Pasted text"},uS=(e,t)=>`${gA[e]} ${t}`,hw=e=>`at most ${cS[e]} ${mA[e]}s per message`,kA=(e,t)=>e.filter(n=>n.kind===t).length,wA=(e,t)=>Math.max(0,cS[t]-kA(e,t));function Kg(e){const t={image:1,paste:1,file:1,pick:1};for(const n of e)for(const r of n??[])t[r.kind]=Math.max(t[r.kind],r.n+1);return t}function pw(e,t){const n={...t};return e.map(r=>[r,n[r.kind]++])}function du(e,t){const n={...e};for(const r of t)n[r.kind]++;return n}function mw(e){return e>=1024*1024?`${(e/1024/1024).toFixed(1)} MB`:`${Math.max(1,Math.round(e/1024))} KB`}const Fl=e=>`card:${e}`,zf=[{id:"quick-open",key:"p"},{id:"commands",key:"p",shift:!0,bareAlias:"F1"},{id:"search",key:"f",shift:!0},{id:"chats",key:"g"},{id:"changes",key:"b",ctrlAlias:{key:"g",shift:!0}},{id:"files",key:"e",shift:!0},{id:"panel-tab-prev",key:"ArrowLeft",alt:!0,textKeeps:!0,emptyGives:!0},{id:"panel-tab-next",key:"ArrowRight",alt:!0,textKeeps:!0,emptyGives:!0},{id:"composer",key:"l"},{id:"rail",key:"k",shift:!0},{id:"keys",key:","},{id:"terminal",key:"j",ctrlAlias:{key:"`"}},{id:"design",key:"d"},{id:"term-tab",key:"`",ctrl:!0,shift:!0},{id:"pick",key:"e"},{id:"inspect",key:"i"},{id:"zen",key:"."},{id:"new",key:"k",aliases:["n"]},{id:"worktree",key:"1-9"},{id:"wt-prev",key:"ArrowUp",alt:!0,ctrlAlias:{key:"Tab",shift:!0},cmdShiftAlias:["[","{"]},{id:"wt-next",key:"ArrowDown",alt:!0,ctrlAlias:{key:"Tab"},cmdShiftAlias:["]","}"]},{id:"wt-unseen-prev",key:"ArrowUp",alt:!0,shift:!0},{id:"wt-unseen-next",key:"ArrowDown",alt:!0,shift:!0},{id:"wt-back",key:"ArrowLeft",textKeeps:!0,emptyGives:!0},{id:"wt-forward",key:"ArrowRight",textKeeps:!0,emptyGives:!0},{id:"wt-archive",key:"Backspace",alt:!0,textKeeps:!0,emptyGives:!0},{id:"mark-unread",key:"u",alt:!0,textKeeps:!0},{id:"project",key:"o",ctrlAlias:{key:"r",hostOnly:!0},cmdShiftAlias:["o"]},{id:"refs",key:"g",shift:!0},{id:"routes",key:"u"},{id:"reload",key:"r"},{id:"back",key:"["},{id:"forward",key:"]"},{id:"close",key:"w"}],yA=new Set(["zen","close","back","forward","wt-back","wt-forward"]),vA={"wt-back":"back","wt-forward":"forward"};function bA(e){if(!e||e.id==="worktree")return e;const t=vA[e.id];return t?{id:t}:e}function dS(e,{guest:t=!1}={}){var r,o;if(e.altKey){if(e.metaKey||e.ctrlKey)return null;const s=zf.find(a=>a.alt&&!!a.shift===e.shiftKey&&(a.key===e.key||a.key.length===1&&e.code===`Key${a.key.toUpperCase()}`));return s&&s.id!=="worktree"?{id:s.id}:null}if(!e.metaKey&&!e.ctrlKey){if(e.shiftKey||t)return null;const s=zf.find(a=>a.bareAlias===e.key);return s&&s.id!=="worktree"?{id:s.id}:null}if(!!e.ctrlKey===e.metaKey)return null;const n=e.key.length===1?e.key.toLowerCase():e.key;if(e.metaKey&&!e.shiftKey&&n>="1"&&n<="9")return{id:"worktree",digit:Number(n)};for(const s of zf){if(s.id==="worktree")continue;const a=s.ctrlAlias;if(a&&e.ctrlKey&&a.key===n&&!!a.shift===e.shiftKey&&!(t&&a.hostOnly))return{id:s.id};if(e.metaKey&&e.shiftKey&&((r=s.cmdShiftAlias)!=null&&r.includes(n)))return{id:s.id};if(!s.alt&&!(e.ctrlKey&&!s.ctrl||!!s.shift!==e.shiftKey)&&(s.key===n||(o=s.aliases)!=null&&o.includes(n)))return{id:s.id}}return null}function xA(e){return e.altKey||e.key.toLowerCase()!=="s"?!1:!!e.ctrlKey!==e.metaKey}function fS(e){const t=zf.find(n=>n.id===e);if(!t)throw new Error(`unknown chord ${e}`);return t}function EA(e,t){return e===t-1?"⌘9":e<8?`⌘${e+1}`:void 0}function SA(e,t){return t===0?null:e===9?t-1:e-1<t?e-1:null}function _A(e){const t=e;return t!=null&&t.tagName?t.isContentEditable||t.tagName==="TEXTAREA"?!0:t.tagName==="INPUT"&&!["button","checkbox","radio","range","submit","reset"].includes(t.type??""):!1}function NA(e){var n;const t=e;return(t==null?void 0:t.tagName)!=="TEXTAREA"&&(t==null?void 0:t.tagName)!=="INPUT"?!1:t.value===""&&!((n=t.closest)!=null&&n.call(t,".monaco-editor, .xterm"))}function jA(e,t){const n=fS(e);return!!n.textKeeps&&_A(t)&&!(n.emptyGives&&NA(t))}const TA=["Find","Preview","Panels","Worktrees"],fu={"quick-open":{label:"jump to file",section:"Find"},commands:{label:"command palette",section:"Find",advertise:{key:"F1",when:"firefox"}},search:{label:"search in files",section:"Find"},chats:{label:"search in chats",section:"Find"},pick:{label:"element to chat",section:"Preview"},inspect:{label:"element to code",section:"Preview"},zen:{label:"full-bleed preview",section:"Preview"},routes:{label:"go to page",section:"Preview"},reload:{label:"reload the preview",section:"Preview"},back:{label:"back in the preview",section:"Preview",hidden:!0},forward:{label:"forward in the preview",section:"Preview",hidden:!0},composer:{label:"chat panel, with the editor's selection",section:"Panels"},changes:{label:"changes panel",section:"Panels"},files:{label:"files panel",section:"Panels"},terminal:{label:"terminal",section:"Panels"},rail:{label:"worktree panel",section:"Panels"},"panel-tab-next":{label:"next panel tab",section:"Panels"},"panel-tab-prev":{label:"previous panel tab",section:"Panels",hidden:!0},"term-tab":{label:"next terminal tab",section:"Panels"},design:{label:"design system",section:"Panels"},keys:{label:"settings & shortcuts",section:"Panels"},close:{label:"close the pane",section:"Panels",hidden:!0},new:{label:"new worktree",section:"Worktrees",advertise:{key:"n",when:"pwa"}},worktree:{label:"switch worktree",section:"Worktrees"},"wt-prev":{label:"previous worktree",section:"Worktrees",advertise:{key:"Tab",when:"pwa"}},"wt-next":{label:"next worktree",section:"Worktrees",advertise:{key:"Tab",when:"pwa"}},"wt-back":{label:"back to the last worktree viewed",section:"Worktrees"},"wt-forward":{label:"forward through viewed worktrees",section:"Worktrees",hidden:!0},"wt-unseen-prev":{label:"previous worktree worth a look",section:"Worktrees",hidden:!0},"wt-unseen-next":{label:"next worktree worth a look",section:"Worktrees"},"wt-archive":{label:"archive worktree",section:"Worktrees"},"mark-unread":{label:"mark worktree unread",section:"Worktrees"},project:{label:"open project",section:"Worktrees"},refs:{label:"open a branch or PR",section:"Worktrees"}},$A={ArrowUp:"↑",ArrowDown:"↓",ArrowLeft:"←",ArrowRight:"→",Backspace:"⌫",Tab:"Tab"};function CA(e,t={}){var c;const n=fS(e),r=fu[e],o=r.advertise&&t[r.advertise.when]?r.advertise.key:n.key;if(o===n.bareAlias)return o;const s=o==="1-9"?"1-9":$A[o]??o.toUpperCase(),a=o!==n.key&&o===((c=n.ctrlAlias)==null?void 0:c.key)?n.ctrlAlias:void 0;return a?`⌃${a.shift?"⇧":""}${s}`:`${n.alt?"⌥":n.ctrl?"⌃":"⌘"}${n.shift?"⇧":""}${s}`}function IA(e){return Object.keys(fu).filter(t=>fu[t].section===e&&!fu[t].hidden)}const lb={m:6e4,h:60*6e4};function AA(e){const[t,n]=RA(e);return`${t}${n.charAt(0)}`}function RA(e){const t=e/lb.h;if(t>=1&&Number.isInteger(t))return[t,"hour"];const n=e/lb.m;return n>=1&&Number.isInteger(n)?[n,"minute"]:n>=60?[Math.round(n),"minute"]:[Math.max(1,Math.round(e/1e3)),"second"]}const yu={folder:{shared:".toyon/settings.json",local:".toyon/settings.local.json"},root:{shared:"toyon.json",local:"toyon.local.json"}};function hS(e){return typeof e=="string"?e:e.cmd}function OA(e){return typeof e=="string"?[]:e.setup??[]}function MA(e){return typeof e=="string"?[]:e.teardown??[]}function pS(e){return typeof e=="string"?{}:e.remotes??{}}function mS(e){return e&&"remote"in e?e.remote:void 0}function Lh(e){return e&&"by"in e?e:void 0}function LA(e){return[...e.setup??[],...e.teardown??[],...Object.values(e.run).flatMap(n=>[hS(n),...OA(n),...MA(n)])].some(n=>n.includes("TOYON_WORKTREE"))}function PA(e){return e===yu.folder.local||e===yu.root.local}function DA(e){return PA(e)?"local":"shared"}function zA(e,t){return(Object.values(yu).find(r=>r.shared===e||r.local===e)??yu.folder)[t]}const FA=e=>`https://${e}/`;function BA(e){let t=e.trim();if(t==="")return null;/^[a-z]+:\/\//i.test(t)||(t=`https://${t}`);let n;try{n=new URL(t)}catch{return null}return HA(n.origin)?n.origin:null}function UA(e){return e.toLowerCase().endsWith(".fly.dev")}function HA(e){let t;try{t=new URL(e)}catch{return!1}return t.origin!==e?!1:t.protocol==="https:"||t.protocol==="http:"&&Ph(t.hostname)}const WA="toyon_grant";function Ph(e){return e==="127.0.0.1"||e==="::1"||e==="[::1]"||e==="localhost"||e.endsWith(".localhost")}function KA(e,t,n){return e.replace("{id}",t).replace("{port}",String(n))}const qA=4401,ZA=25e4;function GA(e,t){let n=0;for(;n<e.length&&n<t.length&&e[n]===t[n];)n++;let r=0;for(;r<e.length-n&&r<t.length-n&&e[e.length-1-r]===t[t.length-1-r];)r++;const o=e.slice(0,n).map(s=>({mark:" ",value:s}));return o.push(...VA(e.slice(n,e.length-r),t.slice(n,t.length-r))),o.push(...e.slice(e.length-r).map(s=>({mark:" ",value:s}))),o}function VA(e,t){if(e.length===0)return t.map(c=>({mark:"+",value:c}));if(t.length===0)return e.map(c=>({mark:"-",value:c}));if((e.length+1)*(t.length+1)>ZA)return[...e.map(c=>({mark:"-",value:c})),...t.map(c=>({mark:"+",value:c}))];const n=t.length+1,r=new Uint32Array((e.length+1)*n);for(let c=e.length-1;c>=0;c--)for(let u=t.length-1;u>=0;u--)r[c*n+u]=e[c]===t[u]?(r[(c+1)*n+u+1]??0)+1:Math.max(r[(c+1)*n+u]??0,r[c*n+u+1]??0);const o=[];let s=0,a=0;for(;s<e.length&&a<t.length;)e[s]===t[a]?(o.push({mark:" ",value:e[s]}),s++,a++):(r[(s+1)*n+a]??0)>=(r[s*n+a+1]??0)?(o.push({mark:"-",value:e[s]}),s++):(o.push({mark:"+",value:t[a]}),a++);for(;s<e.length;)o.push({mark:"-",value:e[s++]});for(;a<t.length;)o.push({mark:"+",value:t[a++]});return o}const YA=/[\p{L}\p{N}_$]+|\s+|[^\s\p{L}\p{N}_$]/gu;function cb(e){return e.match(YA)??[]}const XA=.4;function QA(e,t){if(e===t)return null;const n=GA(cb(e),cb(t));let r=0;for(const o of n)o.mark===" "&&(r+=o.value.length);return r<XA*Math.max(e.length,t.length)?null:{before:ub(n,"-"),after:ub(n,"+")}}function ub(e,t){const n=[];for(const r of e){if(r.mark!==" "&&r.mark!==t)continue;const o=r.mark===t,s=n[n.length-1];s&&s.changed===o?s.text+=r.value:n.push({text:r.value,changed:o})}for(let r=1;r<n.length-1;r++){const o=n[r];o&&(o.changed?o.changed=o.text.trim()!=="":o.changed=o.text.length<=2)}return gS(n)}function db(e){const t=[[]];for(const n of e){const r=n.text.split(`
42
- `);for(const[o,s]of r.entries())o>0&&t.push([]),s&&t[t.length-1].push({text:s,changed:n.changed})}return t.map(gS)}function gS(e){const t=[];for(const n of e){const r=t[t.length-1];r&&r.changed===n.changed?r.text+=n.text:t.push({...n})}return t}const JA=[{id:"merge",name:"here",description:"onto main in this checkout; nothing is pushed"},{id:"push",name:"push",description:"onto main on origin, straight from the worktree; main here follows"},{id:"pr",name:"pull request",description:"the branch is pushed and a pull request opened on GitHub"}],eR=[{id:"merge",name:"merge commit",description:"the commits stay as they are, under one merge commit"},{id:"squash",name:"squash",description:"the work becomes one commit on main"},{id:"rebase",name:"rebase",description:"the commits go on main as they are, no merge commit"}],tR=[{id:"you",name:"you merge it",description:"the chat offers merge once GitHub would take the PR"},{id:"github",name:"GitHub merges it",description:"auto-merge: GitHub merges the PR itself once its rules allow (checks, reviewers, or nothing); where main has a merge queue, it queues the PR instead"}],qg="merge",Zg="merge";function Ti(e){var n,r,o;const t=((n=e.land)==null?void 0:n.route)??qg;return{land:t,automerge:t==="pr"&&((r=e.land)==null?void 0:r.automerge)===!0,...(o=e.land)!=null&&o.method?{merge:e.land.method}:{}}}function Dh(e){return e.base??e.defaultBranch}function nR(e){return e.base!==void 0&&e.base!==e.defaultBranch}function rR(e){return!!e.pr&&(e.lands??[]).some(t=>{var n;return t.pr===((n=e.pr)==null?void 0:n.number)})}function oR(e){return{land:"a land",commit:"a commit","sync-main":"a sync","pull-main":"a pull"}[e]}function gw(e,t){return e.landed&&(t??0)>0?{...e,landed:!1}:e}function zh(e){return rR(e)&&!e.landed?void 0:e.pr}function kw(e,t){const n=zh(t);return e.land==="pr"&&(!n||n.state==="closed")?"create pr":"land"}function Xf(e,t="main"){const n={merge:"merge into",squash:"squash onto",rebase:"rebase onto"}[e.merge??Zg];switch(e.land){case"merge":return`Commit and ${n} ${t} here`;case"push":return`Commit, ${n} ${t} on origin and push it`;case"pr":return e.automerge?"Commit, push the branch and create a PR that GitHub merges when its rules allow":"Commit, push the branch and create a PR"}}function kS(e){const t=Object.values(e).filter(r=>typeof r=="number");return Object.entries(e).filter(([r,o])=>t.indexOf(+r)===-1).map(([r,o])=>o)}function fb(e,t="|"){return e.map(n=>vS(n)).join(t)}function Gg(e,t){return typeof t=="bigint"?t.toString():t}function Fh(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function sR(e){return e==null}function ww(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function iR(e,t){const n=e/t,r=Math.round(n),o=4*Number.EPSILON*Math.max(Math.abs(n),1);return Math.abs(n-r)<o?0:n-r}function ho(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function Di(...e){const t={};for(const n of e){const r=Object.getOwnPropertyDescriptors(n);Object.assign(t,r)}return Object.defineProperties({},t)}function aR(e){return JSON.stringify(e)}function lR(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const wS="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function vu(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const cR=Fh(()=>{var e;if(is.jitless||typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)!=null&&e.includes("Cloudflare")))return!1;try{const t=Function;return new t(""),!0}catch{return!1}});function bu(e){if(vu(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!(vu(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function yS(e){return bu(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}const uR=new Set(["string","number","symbol"]);function Zl(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function zi(e,t,n){const r=new e._zod.constr(t??e._zod.def);return(!t||n!=null&&n.parent)&&(r._zod.parent=e),r}function pt(e){const t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if((t==null?void 0:t.message)!==void 0){if((t==null?void 0:t.error)!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function vS(e){return typeof e=="bigint"?e.toString()+"n":typeof e=="string"?`"${e}"`:`${e}`}function dR(e){return Object.keys(e).filter(t=>e[t]._zod.optin!==void 0&&e[t]._zod.optout==="optional")}const fR={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function hR(e,t){const n=e._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const s=Di(e._zod.def,{get shape(){const a={};for(const c of Reflect.ownKeys(t)){if(!Object.prototype.hasOwnProperty.call(n.shape,c))throw new Error(`Unrecognized key: "${String(c)}"`);t[c]&&ho(a,c,n.shape[c])}return ho(this,"shape",a),a},checks:[]});return zi(e,s)}function pR(e,t){const n=e._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const s=Di(e._zod.def,{get shape(){const a={...e._zod.def.shape};for(const c of Reflect.ownKeys(t)){if(!Object.prototype.hasOwnProperty.call(n.shape,c))throw new Error(`Unrecognized key: "${String(c)}"`);t[c]&&delete a[c]}return ho(this,"shape",a),a},checks:[]});return zi(e,s)}function mR(e,t){if(!bu(t))throw new Error("Invalid input to extend: expected a plain object");const n=e._zod.def.checks;if(n&&n.length>0){const s=e._zod.def.shape;for(const a of Reflect.ownKeys(t))if(Object.getOwnPropertyDescriptor(s,a)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}const o=Di(e._zod.def,{get shape(){const s={...e._zod.def.shape,...t};return ho(this,"shape",s),s}});return zi(e,o)}function gR(e,t){if(!bu(t))throw new Error("Invalid input to safeExtend: expected a plain object");const n=Di(e._zod.def,{get shape(){const r={...e._zod.def.shape,...t};return ho(this,"shape",r),r}});return zi(e,n)}function kR(e,t){var r,o;if(!((r=t==null?void 0:t._zod)!=null&&r.def))throw new Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if((o=e._zod.def.checks)!=null&&o.length)throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");const n=Di(e._zod.def,{get shape(){const s={...e._zod.def.shape,...t._zod.def.shape};return ho(this,"shape",s),s},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return zi(e,n)}function hb(e,t,n,r="partial"){const s=t._zod.def.checks;if(s&&s.length>0)throw new Error(`.${r}() cannot be used on object schemas containing refinements`);const c=Di(t._zod.def,{get shape(){const u=t._zod.def.shape,f={...u};if(n)for(const h of Reflect.ownKeys(n)){if(!Object.prototype.hasOwnProperty.call(u,h))throw new Error(`Unrecognized key: "${String(h)}"`);n[h]&&(f[h]=e?new e({type:"optional",innerType:u[h]}):u[h])}else for(const h of Reflect.ownKeys(u))f[h]=e?new e({type:"optional",innerType:u[h]}):u[h];return ho(this,"shape",f),f},checks:[]});return zi(t,c)}function wR(e,t,n){const r=Di(t._zod.def,{get shape(){const o=t._zod.def.shape,s={...o};if(n)for(const a of Reflect.ownKeys(n)){if(!Object.prototype.hasOwnProperty.call(s,a))throw new Error(`Unrecognized key: "${String(a)}"`);n[a]&&(s[a]=new e({type:"nonoptional",innerType:o[a]}))}else for(const a of Reflect.ownKeys(o))s[a]=new e({type:"nonoptional",innerType:o[a]});return ho(this,"shape",s),s}});return zi(t,r)}function Al(e,t=0){var n;if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(((n=e.issues[r])==null?void 0:n.continue)!==!0)return!0;return!1}function yR(e,t=0){var n;if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(((n=e.issues[r])==null?void 0:n.continue)===!1)return!0;return!1}function Bh(e,t){return t.map(n=>{var r;return(r=n).path??(r.path=[]),n.path.unshift(e),n})}function Gc(e){return typeof e=="string"?e:e==null?void 0:e.message}function pb(e,t,n){var r;for(let o=t;o<e.length;o++)(r=e[o]).schema??(r.schema=n)}function sc(e,t,n){var g,y,w,v,_,x,N,T,j,A;var r;const o=(y=(g=e.inst)==null?void 0:g._zod)==null?void 0:y.traits;o!=null&&o.has("$ZodType")&&(o.has("$ZodCheck")?(r=e).schema??(r.schema=e.inst):e.schema=e.inst);const s=e.schema!==e.inst?(v=(w=e.schema)==null?void 0:w._zod.def)==null?void 0:v.error:void 0,a=e.message?e.message:Gc((N=(x=(_=e.inst)==null?void 0:_._zod.def)==null?void 0:x.error)==null?void 0:N.call(x,e))??Gc(s==null?void 0:s(e))??Gc((T=t==null?void 0:t.error)==null?void 0:T.call(t,e))??Gc((j=n.customError)==null?void 0:j.call(n,e))??Gc((A=n.localeError)==null?void 0:A.call(n,e))??"Invalid input",{inst:c,schema:u,continue:f,input:h,...m}=e;return m.path??(m.path=[]),m.message=a,t!=null&&t.reportInput&&(m.input=h),m}const vR=/[\uD800-\uDBFF]/;function yw(e){const t=e.length;if(!vR.test(e))return t;let n=t;for(let r=0;r<t-1;r++)(e.charCodeAt(r)&64512)===55296&&(e.charCodeAt(r+1)&64512)===56320&&(n--,r++);return n}function vw(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function bR(e){const t=typeof e;switch(t){case"number":return Number.isNaN(e)?"nan":"number";case"object":{if(e===null)return"null";if(Array.isArray(e))return"array";const n=e;if(n&&Object.getPrototypeOf(n)!==Object.prototype&&"constructor"in n&&n.constructor)return n.constructor.name}}return t}function xu(...e){const[t,n,r]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:r}:{...t}}function xR(e,t){for(const n in t){const r=Object.getOwnPropertyDescriptor(t,n);r.get?Object.defineProperty(e,n,{...r,enumerable:!1}):ER(e,n,r.value)}}function Gl(e,t,n,r=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:r,value:n}),n}function bS(e,t,n){return Gl(e,t,n,!1)}function ER(e,t,n){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?n:Gl(this,t,n.bind(this))},set(r){Gl(this,t,r)}})}function SR(e,t){const n=Object.getPrototypeOf(e);return t in n?void 0:n}let ng,_i=!1;const _R={configurable:!0,get(){_i=!0}};function jn(e,t,n){const r=Object.getPrototypeOf(e._zod);if(t in r&&ng!==e._zod){ng=void 0;return}ng=e._zod,Object.defineProperty(r,t,{configurable:!0,get(){Object.defineProperty(this,t,_R);const o=_i;_i=!1;try{const s=n(this);return _i?delete this[t]:Object.defineProperty(this,t,{configurable:!0,writable:!0,value:s}),_i=_i||o,s}catch(s){throw delete this[t],_i=_i||o,s}},set(o){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:o})}})}function NR(e,t,n,r){const o=SR(e,t);o&&Object.defineProperty(o,t,{configurable:!0,get(){const s={configurable:!0,writable:!0,enumerable:r,value:void 0};return Object.defineProperty(this,t,s),s.value=n(this),Object.defineProperty(this,t,s),s.value},set(s){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:r,value:s})}})}const jR="~constantCatch";function TR(e){const t=()=>e;return t[jR]=!0,t}var mb;const rg={value:void 0,enumerable:!1};let gb="captureStackTrace"in Error?Error:null;function $R(e){const t=gb;if(t){const n=t.stackTraceLimit;if(typeof n=="number"){try{t.stackTraceLimit=0}catch{return gb=null,new e}try{return new e}finally{t.stackTraceLimit=n}}}return new e}function xe(e,t,n,r){const o={};function s(g){this.def=g,this.constr=m,this.traits=new Set}s.prototype=o;const a=n,c=a&&new WeakSet;function u(g,y){if(!g._zod){rg.value=new s(y);try{Object.defineProperty(g,"_zod",rg)}finally{rg.value=void 0}}if(g._zod.traits.has(e))return;if(g._zod.traits.add(e),t(g,y),c){const v=Object.getPrototypeOf(g),_=g._zod.constr.prototype;let x=v;for(;x&&x!==_;)x=Object.getPrototypeOf(x);const N=x??v;c.has(N)||(c.add(N),xR(N,a))}const w=m.prototype;for(const v in w)Object.prototype.hasOwnProperty.call(w,v)&&(v in g||(g[v]=w[v].bind(g)))}const f=(r==null?void 0:r.Parent)??Object;class h extends f{}Object.defineProperty(h,"name",{value:e});function m(g){var _;const y=r!=null&&r.Parent?$R(h):this;u(y,g);const w=y._zod.deferred;if(w){for(const x of w)x();y._zod.deferred=void 0}const v=(_=globalThis.__zod_globalConfig)==null?void 0:_.postProcessor;return v&&v(y),y}return Object.defineProperty(m,"init",{value:u}),Object.defineProperty(m,Symbol.hasInstance,{value:g=>{var y,w;return r!=null&&r.Parent&&g instanceof r.Parent?!0:(w=(y=g==null?void 0:g._zod)==null?void 0:y.traits)==null?void 0:w.has(e)}}),Object.defineProperty(m,"name",{value:e}),m}class Bl extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class xS extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}(mb=globalThis).__zod_globalConfig??(mb.__zod_globalConfig={});const is=globalThis.__zod_globalConfig;function Fi(e){return e&&Object.assign(is,e),is}function CR(){const e=this._zod;return e.message??(e.message=JSON.stringify(e.def,Gg,2)),e.message}function IR(e){this._zod.message=e}const AR={get:CR,set:IR,enumerable:!0,configurable:!0},og={value:void 0,enumerable:!1},sg={value:void 0,enumerable:!1},kb=new WeakSet([Object.prototype,Error.prototype]),ES=(e,t)=>{e.name="$ZodError",og.value=e._zod,Object.defineProperty(e,"_zod",og),sg.value=t,Object.defineProperty(e,"issues",sg),og.value=void 0,sg.value=void 0,Object.defineProperty(e,"message",AR);const n=Object.getPrototypeOf(e);kb.has(n)||(kb.add(n),Object.defineProperty(n,"toString",{configurable:!0,enumerable:!1,get(){const r=()=>this.message;return Object.defineProperty(this,"toString",{value:r,configurable:!0,writable:!0}),r},set(r){Object.defineProperty(this,"toString",{value:r,configurable:!0,writable:!0})}}))},SS=xe("$ZodError",ES),_S=xe("$ZodError",ES,void 0,{Parent:Error});function RR(e,t,n){return Object.prototype.hasOwnProperty.call(e,t)||(t==="__proto__"?Object.defineProperty(e,t,{value:n(),writable:!0,enumerable:!0,configurable:!0}):e[t]=n()),e[t]}function OR(e,t=n=>n.message){const n={},r=[];for(const o of e.issues)o.path.length>0?RR(n,o.path[0],()=>[]).push(t(o)):r.push(t(o));return{formErrors:r,fieldErrors:n}}function MR(e,t=n=>n.message){const n={_errors:[]},r=(o,s=[])=>{for(const a of o.issues)if(a.code==="invalid_union"&&a.errors.length)a.errors.map(c=>r({issues:c},[...s,...a.path]));else if(a.code==="invalid_key")r({issues:a.issues},[...s,...a.path]);else if(a.code==="invalid_element")r({issues:a.issues},[...s,...a.path]);else{const c=[...s,...a.path];if(c.length===0)n._errors.push(t(a));else{let u=n,f=0;for(;f<c.length;){const h=c[f],m=f===c.length-1;if(h==="_errors"){m&&u._errors.push(t(a)),f++;continue}Object.prototype.hasOwnProperty.call(u,h)||Object.defineProperty(u,h,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});const g=u[h];m&&g._errors.push(t(a)),u=g,f++}}}};return r(e),n}function Uh(e,t){return{callee:(t==null?void 0:t.callee)??e,Err:t==null?void 0:t.Err}}const bw=e=>{const t=(n,r,o,s)=>{const a=o?{...o,async:!1}:{async:!1},c=n._zod.run({value:r,issues:[]},a);if(c instanceof Promise)throw new Bl;if(c.issues.length){const u=new((s==null?void 0:s.Err)??e)(c.issues.map(f=>sc(f,a,Fi())));throw wS(u,(s==null?void 0:s.callee)??t),u}return c.value};return t},xw=e=>{const t=async(n,r,o,s)=>{const a=o?{...o,async:!0}:{async:!0};let c=n._zod.run({value:r,issues:[]},a);if(c instanceof Promise&&(c=await c),c.issues.length){const u=new((s==null?void 0:s.Err)??e)(c.issues.map(f=>sc(f,a,Fi())));throw wS(u,(s==null?void 0:s.callee)??t),u}return c.value};return t},Hh=e=>(t,n,r)=>{const o=r?{...r,async:!1}:{async:!1},s=t._zod.run({value:n,issues:[]},o);if(s instanceof Promise)throw new Bl;return s.issues.length?{success:!1,error:new(e??SS)(s.issues.map(a=>sc(a,o,Fi())))}:{success:!0,data:s.value}},LR=Hh(_S),Wh=e=>async(t,n,r)=>{const o=r?{...r,async:!0}:{async:!0};let s=t._zod.run({value:n,issues:[]},o);return s instanceof Promise&&(s=await s),s.issues.length?{success:!1,error:new e(s.issues.map(a=>sc(a,o,Fi())))}:{success:!0,data:s.value}},PR=Wh(_S),DR=e=>{const t=bw(e),n=(r,o,s,a)=>{const c=s?{...s,direction:"backward"}:{direction:"backward"};return t(r,o,c,Uh(n,a))};return n},zR=e=>{const t=bw(e),n=(r,o,s,a)=>t(r,o,s,Uh(n,a));return n},FR=e=>{const t=xw(e),n=async(r,o,s,a)=>{const c=s?{...s,direction:"backward"}:{direction:"backward"};return await t(r,o,c,Uh(n,a))};return n},BR=e=>{const t=xw(e),n=async(r,o,s,a)=>await t(r,o,s,Uh(n,a));return n},UR=e=>(t,n,r)=>{const o=r?{...r,direction:"backward"}:{direction:"backward"};return Hh(e)(t,n,o)},HR=e=>(t,n,r)=>Hh(e)(t,n,r),WR=e=>async(t,n,r)=>{const o=r?{...r,direction:"backward"}:{direction:"backward"};return Wh(e)(t,n,o)},KR=e=>async(t,n,r)=>Wh(e)(t,n,r),qR=/^[cC][0-9a-z]{6,}$/,ZR=/^[0-9a-z]+$/,GR=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,VR=/^[0-9a-vA-V]{20}$/,YR=/^[A-Za-z0-9]{27}$/,XR=/^[a-zA-Z0-9_-]{21}$/;function QR(e){return new RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}const JR=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,eO=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,wb=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,tO=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,nO="^[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$";function rO(){return new RegExp(nO,"u")}const oO=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,sO=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,iO=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,aO=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,lO=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,NS=/^[A-Za-z0-9_-]*$/,cO=/^https?$/,uO=/^\+[1-9]\d{6,14}$/,jS="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))";function dO(e){return new RegExp(`^${e}$`)}const fO=dO(jS);function Vg(e){const t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof e.precision=="number"?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:e.seconds?`${t}:[0-5]\\d(?:\\.\\d+)?`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function hO(e){return new RegExp(`^${Vg(e)}$`)}function pO(e){const t=["Z"];e.offset&&t.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const n=`${Vg({precision:e.precision,seconds:!0})}(?:${t.join("|")})`,r=e.local?`${n}|${Vg({precision:e.precision})}`:n;return new RegExp(`^${jS}T(?:${r})$`)}const mO=e=>{const t=e?`[\\s\\S]{${(e==null?void 0:e.minimum)??0},${(e==null?void 0:e.maximum)??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},gO=/^-?\d+$/,kO=/^-?\d+(?:\.\d+)?$/,wO=/^(?:true|false)$/i,yO=/^[^A-Z]*$/,vO=/^[^a-z]*$/,mo=xe("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),Ew=e=>{const t=e.value;return!sR(t)&&t.length!==void 0},Qf={number:"number",bigint:"bigint",object:"date"},TS=xe("$ZodCheckLessThan",(e,t)=>{mo.init(e,t);const n=Qf[typeof t.value];e._zod.onattach.push(r=>{const o=r._zod.bag,s=(t.inclusive?o.maximum:o.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<s&&(t.inclusive?o.maximum=t.value:o.exclusiveMaximum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:Qf[typeof r.value]??n,code:"too_big",maximum:typeof t.value=="object"?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),$S=xe("$ZodCheckGreaterThan",(e,t)=>{mo.init(e,t);const n=Qf[typeof t.value];e._zod.onattach.push(r=>{const o=r._zod.bag,s=(t.inclusive?o.minimum:o.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>s&&(t.inclusive?o.minimum=t.value:o.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:Qf[typeof r.value]??n,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),bO=xe("$ZodCheckMultipleOf",(e,t)=>{mo.init(e,t),e._zod.onattach.push(n=>{var r;(r=n._zod.bag).multipleOf??(r.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof n.value=="bigint"?t.value!==BigInt(0)&&n.value%t.value===BigInt(0):iR(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:"not_multiple_of",divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),xO=xe("$ZodCheckNumberFormat",(e,t)=>{var a;mo.init(e,t),t.format=t.format||"float64";const n=(a=t.format)==null?void 0:a.includes("int"),r=n?"int":"number",[o,s]=fR[t.format];e._zod.onattach.push(c=>{const u=c._zod.bag;u.format=t.format,u.minimum=o,u.maximum=s,n&&(u.pattern=gO)}),e._zod.check=c=>{const u=c.value;if(n){if(!Number.isInteger(u)){c.issues.push({expected:r,format:t.format,code:"invalid_type",continue:!1,input:u,inst:e});return}if(!Number.isSafeInteger(u)){u>0?c.issues.push({input:u,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,inclusive:!0,continue:!t.abort}):c.issues.push({input:u,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}u<o&&c.issues.push({origin:"number",input:u,code:"too_small",minimum:o,inclusive:!0,inst:e,continue:!t.abort}),u>s&&c.issues.push({origin:"number",input:u,code:"too_big",maximum:s,inclusive:!0,inst:e,continue:!t.abort})}}),EO=xe("$ZodCheckMaxLength",(e,t)=>{var n;mo.init(e,t),(n=e._zod.def).when??(n.when=Ew),e._zod.onattach.push(r=>{const o=r._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<o&&(r._zod.bag.maximum=t.maximum)}),e._zod.check=r=>{const o=r.value,s=o.length;if((typeof o=="string"&&s>t.maximum?yw(o):s)<=t.maximum)return;const c=vw(o);r.issues.push({origin:c,code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),SO=xe("$ZodCheckMinLength",(e,t)=>{var n;mo.init(e,t),(n=e._zod.def).when??(n.when=Ew),e._zod.onattach.push(r=>{const o=r._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>o&&(r._zod.bag.minimum=t.minimum)}),e._zod.check=r=>{const o=r.value,s=o.length;if((typeof o=="string"&&s>=t.minimum&&s<t.minimum*2?yw(o):s)>=t.minimum)return;const c=vw(o);r.issues.push({origin:c,code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),_O=xe("$ZodCheckLengthEquals",(e,t)=>{var n;mo.init(e,t),(n=e._zod.def).when??(n.when=Ew),e._zod.onattach.push(r=>{const o=r._zod.bag;o.minimum=t.length,o.maximum=t.length,o.length=t.length}),e._zod.check=r=>{const o=r.value,s=o.length,a=typeof o=="string"&&s>=t.length&&s<=t.length*2?yw(o):s;if(a===t.length)return;const c=vw(o),u=a>t.length;r.issues.push({origin:c,...u?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!t.abort})}}),Kh=xe("$ZodCheckStringFormat",(e,t)=>{var n,r;mo.init(e,t),e._zod.onattach.push(o=>{const s=o._zod.bag;s.format=t.format,t.pattern&&(s.patterns??(s.patterns=new Set),s.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=o=>{t.pattern.lastIndex=0,!t.pattern.test(o.value)&&o.issues.push({origin:"string",code:"invalid_format",format:t.format,input:o.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),NO=xe("$ZodCheckRegex",(e,t)=>{Kh.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),jO=xe("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=yO),Kh.init(e,t)}),TO=xe("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=vO),Kh.init(e,t)}),$O=xe("$ZodCheckIncludes",(e,t)=>{mo.init(e,t);const n=Zl(t.includes),r=new RegExp(typeof t.position=="number"?`^.{${t.position},}${n}`:n);t.pattern=r,e._zod.onattach.push(o=>{const s=o._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(r)}),e._zod.check=o=>{o.value.includes(t.includes,t.position)||o.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:o.value,inst:e,continue:!t.abort})}}),CO=xe("$ZodCheckStartsWith",(e,t)=>{mo.init(e,t);const n=new RegExp(`^${Zl(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.onattach.push(r=>{const o=r._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(n)}),e._zod.check=r=>{r.value.startsWith(t.prefix)||r.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:r.value,inst:e,continue:!t.abort})}}),IO=xe("$ZodCheckEndsWith",(e,t)=>{mo.init(e,t);const n=new RegExp(`.*${Zl(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.onattach.push(r=>{const o=r._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(n)}),e._zod.check=r=>{r.value.endsWith(t.suffix)||r.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:r.value,inst:e,continue:!t.abort})}}),AO=xe("$ZodCheckOverwrite",(e,t)=>{mo.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});class RO{constructor(t=[],n={}){this.content=[],this.indent=0,this.args=t,this.closed=n}indented(t){this.indent+=1,t(this),this.indent-=1}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}const r=t.split(`
43
- `).filter(a=>a),o=Math.min(...r.map(a=>a.length-a.trimStart().length)),s=r.map(a=>a.slice(o)).map(a=>" ".repeat(this.indent*2)+a);for(const a of s)this.content.push(a)}compile(){const t=Function,n=(this==null?void 0:this.content)??[""];return new t(...Object.keys(this.closed),`return function (${this.args.join(", ")}) {
44
- ${n.join(`
45
- `)}
46
- };`)(...Object.values(this.closed))}}const OO={major:4,minor:5,patch:4},Yn=xe("$ZodType",(e,t)=>{var s;var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=OO;const r=e._zod.def.checks,o=e._zod.traits.has("$ZodCheck")?[e,...r??[]]:r!=null&&r.length?[...r]:[];for(const a of o)for(const c of a._zod.onattach)c(e);if(o.length===0)(n=e._zod).deferred??(n.deferred=[]),(s=e._zod.deferred)==null||s.push(()=>{e._zod.run=e._zod.parse});else{const a=(u,f,h)=>{if(u.memo)return u;let m=Al(u),g;for(const y of f){if(y._zod.def.when){if(yR(u)||!y._zod.def.when(u))continue}else if(m)continue;const w=u.issues.length,v=y._zod.check(u);if(v instanceof Promise&&(h==null?void 0:h.async)===!1)throw new Bl;if(g||v instanceof Promise)g=(g??Promise.resolve()).then(async()=>{await v,u.issues.length!==w&&(pb(u.issues,w,e),m||(m=Al(u,w)))});else{if(u.issues.length===w)continue;pb(u.issues,w,e),m||(m=Al(u,w))}}return g?g.then(()=>u):u},c=(u,f,h)=>{if(Al(u))return u.aborted=!0,u;const m=a(f,o,h);if(m instanceof Promise){if(h.async===!1)throw new Bl;return m.then(g=>e._zod.parse(g,h))}return e._zod.parse(m,h)};e._zod.run=(u,f)=>{if(f.skipChecks)return e._zod.parse(u,f);if(f.direction==="backward"){const m=e._zod.parse({value:u.value,issues:[]},{...f,skipChecks:!0});return m instanceof Promise?m.then(g=>c(g,u,f)):c(m,u,f)}const h=e._zod.parse(u,f);if(h instanceof Promise){if(f.async===!1)throw new Bl;return h.then(m=>a(m,o,f))}return a(h,o,f)}}},{get"~standard"(){return bS(this,"~standard",CS(this))},set"~standard"(e){Gl(this,"~standard",e)}}),yb=e=>{var t;return e.success?{value:e.data}:{issues:(t=e.error)==null?void 0:t.issues}};function CS(e){return{validate:t=>{try{return yb(LR(e,t))}catch{return PR(e,t).then(yb)}},vendor:"zod",version:1}}const Sw=xe("$ZodString",(e,t)=>{var n;Yn.init(e,t),e._zod.pattern=[...((n=e==null?void 0:e._zod.bag)==null?void 0:n.patterns)??[]].pop()??mO(e._zod.bag),e._zod.parse=(r,o)=>{if(t.coerce)try{r.value=String(r.value)}catch{}return typeof r.value=="string"||r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:e}),r}}),Xn=xe("$ZodStringFormat",(e,t)=>{Kh.init(e,t),Sw.init(e,t)}),MO=xe("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=eO),Xn.init(e,t)}),LO=xe("$ZodUUID",(e,t)=>{if(t.version){const r={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(r===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=wb(r))}else t.pattern??(t.pattern=wb());Xn.init(e,t)}),PO=xe("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=tO),Xn.init(e,t)}),IS=1,AS=2;function DO(e,t){var n;if(!t.normalize&&((n=t.protocol)==null?void 0:n.source)===cO.source&&!/^https?:\/\//i.test(e))return IS;try{return new URL(e)}catch{return AS}}const zO=/[\t\n\r]/g;function FO(e){return e.replace(zO,"")}function BO(e,t){return t.lastIndex=0,t.test(e.hostname)}function UO(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(":")?e.protocol.slice(0,-1):e.protocol)}const HO=xe("$ZodURL",(e,t)=>{Xn.init(e,t),e._zod.check=n=>{try{const r=n.value.trim(),o=DO(r,t);if(o===IS){n.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:n.value,inst:e,continue:!t.abort});return}if(o===AS){n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort});return}t.hostname&&!BO(o,t.hostname)&&n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort}),t.protocol&&!UO(o,t.protocol)&&n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort}),n.value=t.normalize?o.href:FO(r);return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),WO=xe("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=rO()),Xn.init(e,t)}),KO=xe("$ZodNanoID",(e,t)=>{if(t.length!==void 0&&(!Number.isInteger(t.length)||t.length<1))throw new Error(`Invalid nanoid length: ${t.length}`);t.pattern??(t.pattern=t.length===void 0?XR:QR(t.length)),Xn.init(e,t)}),qO=xe("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=qR),Xn.init(e,t)}),ZO=xe("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=ZR),Xn.init(e,t)}),GO=xe("$ZodULID",(e,t)=>{t.pattern??(t.pattern=GR),Xn.init(e,t)}),VO=xe("$ZodXID",(e,t)=>{t.pattern??(t.pattern=VR),Xn.init(e,t)}),YO=xe("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=YR),Xn.init(e,t)}),XO=xe("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=pO(t)),Xn.init(e,t),(t.local||t.precision===-1)&&(e._zod.bag.laxFormat=!0,e._zod.onattach.push(n=>{n._zod.bag.laxFormat=!0}))}),QO=xe("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=fO),Xn.init(e,t)}),JO=xe("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=hO(t)),Xn.init(e,t)}),e2=xe("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=JR),Xn.init(e,t)}),t2=xe("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=oO),Xn.init(e,t),e._zod.bag.format="ipv4"}),n2=/^[0-9a-fA-F:.]+$/;function RS(e){if(!n2.test(e))return!1;try{return new URL(`http://[${e}]`),!0}catch{return!1}}const r2=xe("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=sO),Xn.init(e,t),e._zod.bag.format="ipv6",e._zod.check=n=>{RS(n.value)||n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}}),o2=xe("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=iO),Xn.init(e,t)});function s2(e){const t=e.split("/");if(t.length!==2)return!1;const[n,r]=t;if(!r)return!1;const o=Number(r);return`${o}`!==r||o<0||o>128?!1:RS(n)}const i2=xe("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=aO),Xn.init(e,t),e._zod.check=n=>{s2(n.value)||n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}});function OS(e){if(e==="")return!0;if(/\s/.test(e)||e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const a2=xe("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=lO),Xn.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{OS(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});function l2(e){if(!NS.test(e))return!1;const t=e.replace(/[-_]/g,r=>r==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return OS(n)}const c2=xe("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=NS),Xn.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{l2(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),u2=xe("$ZodE164",(e,t)=>{t.pattern??(t.pattern=uO),Xn.init(e,t)});function d2(e,t=null){try{const n=e.split(".");if(n.length!==3)return!1;const[r]=n;if(!r)return!1;const o=JSON.parse(atob(r));return!("typ"in o&&(o==null?void 0:o.typ)!=="JWT"||!o.alg||t&&(!("alg"in o)||o.alg!==t))}catch{return!1}}const f2=xe("$ZodJWT",(e,t)=>{Xn.init(e,t),e._zod.check=n=>{d2(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),MS=xe("$ZodNumber",(e,t)=>{Yn.init(e,t),e._zod.pattern=e._zod.bag.pattern??kO,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}const o=n.value;if(typeof o=="number"&&!Number.isNaN(o)&&Number.isFinite(o))return n;const s=typeof o=="number"?Number.isNaN(o)?"NaN":Number.isFinite(o)?void 0:String(o):void 0;return n.issues.push({expected:"number",code:"invalid_type",input:o,inst:e,...s?{received:s}:{}}),n}}),h2=xe("$ZodNumberFormat",(e,t)=>{xO.init(e,t),MS.init(e,t)}),p2=xe("$ZodBoolean",(e,t)=>{Yn.init(e,t),e._zod.pattern=wO,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}const o=n.value;return typeof o=="boolean"||n.issues.push({expected:"boolean",code:"invalid_type",input:o,inst:e}),n}}),m2=xe("$ZodUnknown",(e,t)=>{Yn.init(e,t),e._zod.parse=n=>n}),g2=xe("$ZodNever",(e,t)=>{Yn.init(e,t),e._zod.parse=(n,r)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)});function vb(e,t,n){e.issues.length&&t.issues.push(...Bh(n,e.issues)),t.value[n]=e.value}const k2=xe("$ZodArray",(e,t)=>{Yn.init(e,t);const n=is.memoizer;n==null||n.attach(e),e._zod.parse=(r,o)=>{const s=r.value;if(!Array.isArray(s))return r.issues.push({expected:"array",code:"invalid_type",input:s,inst:e}),r;r.value=n?n.alloc(e,r,Array(s.length),o):Array(s.length);const a=[];for(let c=0;c<s.length;c++){const u=s[c],f=t.element._zod.run({value:u,issues:[]},o);f instanceof Promise?a.push(f.then(h=>vb(h,r,c))):vb(f,r,c)}return a.length?Promise.all(a).then(()=>r):r}});function Jf(e,t,n,r,o,s){const a=n in r,c=s==="optional";if(!(!a&&c&&o==="optional")){if(e.issues.length){if(o!==void 0&&c&&!a)return;t.issues.push(...Bh(n,e.issues))}if(!a&&o===void 0){e.issues.length||t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[n]});return}e.value===void 0?a&&(t.value[n]=void 0):t.value[n]=e.value}}const w2=[];function LS(e){var a,c,u,f;const t=Object.keys(e.shape),n=Object.getOwnPropertySymbols(e.shape),r=n.length?n:w2,o=r.length?[...t,...r]:t;for(const h of o)if(!((f=(u=(c=(a=e.shape)==null?void 0:a[h])==null?void 0:c._zod)==null?void 0:u.traits)!=null&&f.has("$ZodType")))throw new Error(`Invalid element at key "${String(h)}": expected a Zod schema`);const s=dR(e.shape);return{...e,allKeys:o,symbolKeys:r,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(s)}}function PS(e,t,n,r,o,s){const a=[],c=o.keySet,u=o.catchall._zod,f=u.def.type,h=u.optin,m=u.optout;for(const g in t){if(c.has(g))continue;if(g==="__proto__"){f==="never"&&a.push(g);continue}if(f==="never"){a.push(g);continue}const y=u.run({value:t[g],issues:[]},r);y instanceof Promise?e.push(y.then(w=>Jf(w,n,g,t,h,m))):Jf(y,n,g,t,h,m)}return a.length&&n.issues.push({code:"unrecognized_keys",keys:a,input:t,inst:s,continue:!0}),e.length?Promise.all(e).then(()=>n):n}const Yg=new WeakMap,y2=xe("$ZodObject",(e,t)=>{Yn.init(e,t);const n=Object.getOwnPropertyDescriptor(t,"shape");if(!(n!=null&&n.get)){const u=t.shape;Yg.set(t,u),Object.defineProperty(t,"shape",{get:()=>{const f={...u};return Object.defineProperty(t,"shape",{value:f}),Yg.set(t,f),f}})}const r=Fh(()=>LS(t));jn(e,"propValues",u=>{const f=u.def.shape,h={};for(const m in f){const g=f[m]._zod;if(g.values){Object.prototype.hasOwnProperty.call(h,m)||ho(h,m,new Set);for(const y of g.values)h[m].add(y);g.optin!==void 0&&h[m].add(void 0)}}return h});const o=vu,s=t.catchall;let a;const c=is.memoizer;c==null||c.attach(e),e._zod.parse=(u,f)=>{a??(a=r.value);const h=u.value;if(!o(h))return u.issues.push({expected:"object",code:"invalid_type",input:h,inst:e}),u;u.value=c?c.alloc(e,u,{},f):{};const m=[],g=a.shape;for(const y of a.allKeys){if(y==="__proto__")continue;const w=g[y],v=w._zod.optin,_=w._zod.optout,x=w._zod.run({value:h[y],issues:[]},f);x instanceof Promise?m.push(x.then(N=>Jf(N,u,y,h,v,_))):Jf(x,u,y,h,v,_)}return s?PS(m,h,u,f,r.value,e):m.length?Promise.all(m).then(()=>u):u}}),v2=xe("$ZodObjectJIT",(e,t)=>{y2.init(e,t);const n=e._zod.parse,r=Fh(()=>LS(t)),o=is.memoizer,s=y=>{var A,R;const w=r.value,v=w.symbolKeys,_=new RO(["payload","ctx"],{shape:y,inst:e,memo:o,syms:v}),x=C=>`shape[${C}]._zod.run({ value: input[${C}], issues: [] }, ctx)`,N=(C,M)=>`
47
- for (let i = 0; i < ${C}.issues.length; i++) {
48
- const iss = ${C}.issues[i];
49
- iss.path = iss.path ? [${M}, ...iss.path] : [${M}];
50
- payload.issues.push(iss);
51
- }`;_.write("const input = payload.value;");const T=Object.create(null);let j=0;for(const C of w.allKeys)T[C]=`key_${j++}`;_.write(o?"const newResult = memo.alloc(inst, payload, {}, ctx);":"const newResult = {};");for(const C of w.allKeys){if(C==="__proto__")continue;const M=T[C],I=typeof C=="symbol"?`syms[${v.indexOf(C)}]`:aR(C),D=`${I} in input`,H=y[C],Z=(A=H==null?void 0:H._zod)==null?void 0:A.optin,B=Z!==void 0,J=((R=H==null?void 0:H._zod)==null?void 0:R.optout)==="optional";if(_.write(`const ${M} = ${x(I)};`),B&&J){const V=Z==="optional"?`${M}_present`:`${M}.value !== undefined || ${M}_present`;_.write(`
52
- const ${M}_present = ${D};
53
- if (!${M}.issues.length || ${M}_present) {
54
- if (${M}.issues.length) {${N(M,I)}
55
- }
56
-
57
- if (${V}) {
58
- newResult[${I}] = ${M}.value;
59
- }
60
- }
61
-
62
- `)}else B?_.write(`
63
- if (${M}.issues.length) {${N(M,I)}
64
- }
65
-
66
- if (${M}.value === undefined) {
67
- if (${D}) {
68
- newResult[${I}] = undefined;
69
- }
70
- } else {
71
- newResult[${I}] = ${M}.value;
72
- }
73
-
74
- `):_.write(`
75
- const ${M}_present = ${D};
76
- if (${M}.issues.length) {${N(M,I)}
77
- }
78
- if (!${M}_present && !${M}.issues.length) {
79
- payload.issues.push({
80
- code: "invalid_type",
81
- expected: "nonoptional",
82
- input: undefined,
83
- path: [${I}]
84
- });
85
- }
86
-
87
- if (${M}_present) {
88
- newResult[${I}] = ${M}.value;
89
- }
90
-
91
- `)}return _.write("payload.value = newResult;"),_.write("return payload;"),_.compile()};let a;const c=vu,u=!is.jitless,h=u&&cR.value,m=t.catchall;let g;e._zod.parse=(y,w)=>{g??(g=r.value);const v=y.value;return c(v)?u&&h&&(w==null?void 0:w.async)===!1&&w.jitless!==!0?(a||(a=s(t.shape)),y=a(y,w),m?PS([],v,y,w,g,e):y):n(y,w):(y.issues.push({expected:"object",code:"invalid_type",input:v,inst:e}),y)}});function bb(e,t,n,r){for(const s of e)if(s.issues.length===0)return t.value=s.value,t;const o=e.filter(s=>!Al(s));return o.length===1?(t.value=o[0].value,o[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(s=>s.issues.map(a=>sc(a,r,Fi())))}),t)}const DS=xe("$ZodUnion",(e,t)=>{Yn.init(e,t),jn(e,"optin",r=>r.def.options.some(o=>o._zod.optin==="defaulted")?"defaulted":r.def.options.some(o=>o._zod.optin!==void 0)?"optional":void 0),jn(e,"optout",r=>r.def.options.some(o=>o._zod.optout==="optional")?"optional":void 0),jn(e,"values",r=>{if(r.def.options.every(o=>o._zod.values))return new Set(r.def.options.flatMap(o=>Array.from(o._zod.values)))}),jn(e,"pattern",r=>{if(r.def.options.every(o=>o._zod.pattern)){const o=r.def.options.map(s=>s._zod.pattern);return new RegExp(`^(${o.map(s=>ww(s.source)).join("|")})$`)}});const n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,o)=>{if(n)return n(r,o);let s=!1;const a=[];for(const c of t.options){const u=c._zod.run({value:r.value,issues:[]},o);if(u instanceof Promise)a.push(u),s=!0;else{if(u.issues.length===0)return u;a.push(u)}}return s?Promise.all(a).then(c=>bb(c,r,e,o)):bb(a,r,e,o)}}),b2=xe("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,DS.init(e,t);const n=e._zod.parse;jn(e,"propValues",o=>{const s={};for(const a of o.def.options){const c=a._zod.propValues;if(!c||Object.keys(c).length===0)throw new Error(`Invalid discriminated union option at index "${o.def.options.indexOf(a)}"`);for(const[u,f]of Object.entries(c)){Object.prototype.hasOwnProperty.call(s,u)||ho(s,u,new Set);for(const h of f)s[u].add(h)}}return s}),t.options.forEach((o,s)=>{const a=Yg.get(o._zod.def);if(a&&!Object.prototype.hasOwnProperty.call(a,t.discriminator))throw new Error(`Invalid discriminated union option at index "${s}"`)});const r=Fh(()=>{var a;const o=t.options,s=new Map;for(const c of o){const u=(a=c._zod.propValues)==null?void 0:a[t.discriminator];if(!u||u.size===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(c)}"`);for(const f of u){if(s.has(f))throw new Error(`Duplicate discriminator value "${String(f)}"`);s.set(f,c)}}return s});e._zod.parse=(o,s)=>{const a=o.value;if(!vu(a))return o.issues.push({code:"invalid_type",expected:"object",input:a,inst:e}),o;const c=r.value.get(a==null?void 0:a[t.discriminator]);return c?c._zod.run(o,s):t.unionFallback||s.direction==="backward"?n(o,s):(o.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,options:Array.from(r.value.keys()),input:a,path:[t.discriminator],inst:e}),o)}}),x2=xe("$ZodIntersection",(e,t)=>{Yn.init(e,t),e._zod.parse=(n,r)=>{const o=n.value,s=t.left._zod.run({value:o,issues:[]},r),a=t.right._zod.run({value:o,issues:[]},r);return s instanceof Promise||a instanceof Promise?Promise.all([s,a]).then(([u,f])=>xb(n,u,f)):xb(n,s,a)}});function Xg(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(bu(e)&&bu(t)){const n=Object.keys(t),r=Object.keys(e).filter(s=>n.indexOf(s)!==-1),o={...e,...t};Object.prototype.hasOwnProperty.call(o,"__proto__")&&delete o.__proto__;for(const s of r){if(s==="__proto__")continue;const a=Xg(e[s],t[s]);if(!a.valid)return{valid:!1,mergeErrorPath:[s,...a.mergeErrorPath]};o[s]=a.data}return{valid:!0,data:o}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const n=[];for(let r=0;r<e.length;r++){const o=e[r],s=t[r],a=Xg(o,s);if(!a.valid)return{valid:!1,mergeErrorPath:[r,...a.mergeErrorPath]};n.push(a.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function xb(e,t,n){const r=new Map;let o;const s=new Map,a=(f,h)=>{var g,y;let m;if(f.code==="unrecognized_keys"&&!((g=f.path)!=null&&g.length))o??(o=f),m=f.keys;else if(f.code==="invalid_key"&&f.origin==="record"&&((y=f.path)==null?void 0:y.length)===1){const w=String(f.path[0]);s.has(w)||s.set(w,f),m=[w]}else return!1;for(const w of m)r.has(w)||r.set(w,{}),r.get(w)[h]=!0;return!0};for(const f of t.issues)a(f,"l")||e.issues.push(f);for(const f of n.issues)a(f,"r")||e.issues.push(f);const c=[...r].filter(([,f])=>f.l&&f.r).map(([f])=>f);if(c.length){const f=o?c.filter(h=>o.keys.includes(h)):[];f.length&&e.issues.push({...o,keys:f});for(const h of c)!f.includes(h)&&s.has(h)&&e.issues.push(s.get(h))}const u=Xg(t.value,n.value);if(!u.valid){if(Al(e))return e;throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(u.mergeErrorPath)}`)}return e.value=u.data,e}const E2=xe("$ZodTuple",(e,t)=>{Yn.init(e,t);const n=t.items,r=is.memoizer;r==null||r.attach(e),e._zod.parse=(o,s)=>{const a=o.value;if(!Array.isArray(a))return o.issues.push({input:a,inst:e,expected:"tuple",code:"invalid_type"}),o;o.value=r?r.alloc(e,o,[],s):[];const c=[],u=Eb(n,"optin"),f=Eb(n,"optout");if(!t.rest){if(a.length<u)return o.issues.push({code:"too_small",minimum:u,inclusive:!0,input:a,inst:e,origin:"array"}),o;a.length>n.length&&o.issues.push({code:"too_big",maximum:n.length,inclusive:!0,input:a,inst:e,origin:"array"})}const h=new Array(n.length);for(let m=0;m<n.length;m++){const g=n[m]._zod.run({value:a[m],issues:[]},s);g instanceof Promise?c.push(g.then(y=>{h[m]=y})):h[m]=g}if(t.rest){let m=n.length-1;const g=a.slice(n.length);for(const y of g){m++;const w=t.rest._zod.run({value:y,issues:[]},s);w instanceof Promise?c.push(w.then(v=>Sb(v,o,m))):Sb(w,o,m)}}return c.length?Promise.all(c).then(()=>_b(h,o,n,a,f)):_b(h,o,n,a,f)}});function Eb(e,t){for(let n=e.length-1;n>=0;n--)if(!(t==="optin"?e[n]._zod.optin!==void 0:e[n]._zod.optout==="optional"))return n+1;return 0}function Sb(e,t,n){e.issues.length&&t.issues.push(...Bh(n,e.issues)),t.value[n]=e.value}function _b(e,t,n,r,o){for(let s=0;s<n.length;s++){const a=e[s],c=s<r.length;if(!c&&s>=o&&n[s]._zod.optin==="optional"){t.value.length=s;break}if(a.issues.length){if(!c&&s>=o){t.value.length=s;break}t.issues.push(...Bh(s,a.issues))}t.value[s]=a.value}for(let s=t.value.length-1;s>=r.length&&(n[s]._zod.optout==="optional"&&t.value[s]===void 0);s--)t.value.length=s;return t}const S2=xe("$ZodEnum",(e,t)=>{Yn.init(e,t);const n=kS(t.entries),r=new Set(n);e._zod.values=r;const o=n.filter(s=>uR.has(typeof s));e._zod.pattern=new RegExp(o.length?`^(${o.map(s=>Zl(s.toString())).join("|")})$`:"^[^\\s\\S]$"),e._zod.parse=(s,a)=>{const c=s.value;return r.has(c)||s.issues.push({code:"invalid_value",values:n,input:c,inst:e}),s}}),_2=xe("$ZodLiteral",(e,t)=>{Yn.init(e,t);const n=new Set(t.values);e._zod.values=n,e._zod.pattern=new RegExp(t.values.length?`^(${t.values.map(r=>typeof r=="string"?Zl(r):r?Zl(r.toString()):String(r)).join("|")})$`:"^[^\\s\\S]$"),e._zod.parse=(r,o)=>{const s=r.value;return n.has(s)||r.issues.push({code:"invalid_value",values:t.values,input:s,inst:e}),r}}),N2=xe("$ZodTransform",(e,t)=>{var n;Yn.init(e,t),e._zod.optin="optional",(n=is.memoizer)==null||n.guard(e),e._zod.parse=(r,o)=>{if(o.direction==="backward")throw new xS(e.constructor.name);const s=t.transform(r.value,r);if(o.async)return(s instanceof Promise?s:Promise.resolve(s)).then(c=>(r.value=c,r));if(s instanceof Promise)throw new Bl;return r.value=s,r}});function Nb(e,t){return e.value=t.issues.length?void 0:t.value,e}const zS=xe("$ZodOptional",(e,t)=>{Yn.init(e,t),jn(e,"optin",n=>n.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),e._zod.optout="optional",jn(e,"values",n=>{const r=n.def.innerType._zod.values;return r?new Set([...r,void 0]):void 0}),jn(e,"pattern",n=>{const r=n.def.innerType._zod.pattern;return r?new RegExp(`^(${ww(r.source)})?$`):void 0}),e._zod.parse=(n,r)=>{if(n.value===void 0){if(t.innerType._zod.optin!=="defaulted")return n;const o=t.innerType._zod.run({value:n.value,issues:[]},r);return o instanceof Promise?o.then(s=>Nb(n,s)):Nb(n,o)}return t.innerType._zod.run(n,r)}}),j2=xe("$ZodExactOptional",(e,t)=>{zS.init(e,t),jn(e,"values",n=>n.def.innerType._zod.values),jn(e,"pattern",n=>n.def.innerType._zod.pattern),e._zod.parse=(n,r)=>t.innerType._zod.run(n,r)}),T2=xe("$ZodNullable",(e,t)=>{Yn.init(e,t),jn(e,"optin",n=>n.def.innerType._zod.optin),jn(e,"optout",n=>n.def.innerType._zod.optout),jn(e,"pattern",n=>{const r=n.def.innerType._zod.pattern;return r?new RegExp(`^(${ww(r.source)}|null)$`):void 0}),jn(e,"values",n=>n.def.innerType._zod.values?new Set([...n.def.innerType._zod.values,null]):void 0),e._zod.parse=(n,r)=>n.value===null?n:t.innerType._zod.run(n,r)}),$2=xe("$ZodDefault",(e,t)=>{Yn.init(e,t),e._zod.optin="defaulted",jn(e,"values",n=>n.def.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);if(n.value===void 0)return n.value=t.defaultValue,n;const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(s=>jb(s,t)):jb(o,t)}});function jb(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const C2=xe("$ZodPrefault",(e,t)=>{Yn.init(e,t),e._zod.optin="defaulted",jn(e,"values",n=>n.def.innerType._zod.values),e._zod.parse=(n,r)=>(r.direction==="backward"||n.value===void 0&&(n.value=t.defaultValue),t.innerType._zod.run(n,r))}),I2=xe("$ZodNonOptional",(e,t)=>{Yn.init(e,t),jn(e,"values",n=>{const r=n.def.innerType._zod.values;return r?new Set([...r].filter(o=>o!==void 0)):void 0}),e._zod.parse=(n,r)=>{const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(s=>Tb(s,e)):Tb(o,e)}});function Tb(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}function $b(e,t,n,r){return t.issues.length?(e.value=n.catchValue({...t,value:e.value,error:{issues:t.issues.map(o=>sc(o,r,Fi()))},input:e.value}),e):(e.value=t.value,t.memo&&(e.memo=!0),e)}const A2=xe("$ZodCatch",(e,t)=>{Yn.init(e,t),jn(e,"optin",n=>n.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),jn(e,"optout",n=>n.def.innerType._zod.optout),jn(e,"values",n=>n.def.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);const o=t.innerType._zod.run({value:n.value,issues:[]},r);return o instanceof Promise?o.then(s=>$b(n,s,t,r)):$b(n,o,t,r)}}),R2=xe("$ZodPipe",(e,t)=>{Yn.init(e,t),jn(e,"values",n=>n.def.in._zod.values),jn(e,"optin",n=>n.def.in._zod.optin),jn(e,"optout",n=>n.def.out._zod.optout),jn(e,"propValues",n=>n.def.in._zod.propValues),e._zod.parse=(n,r)=>{if(r.direction==="backward"){const s=t.out._zod.run(n,r);return s instanceof Promise?s.then(a=>gf(a,t.in,r)):gf(s,t.in,r)}const o=t.in._zod.run(n,r);return o instanceof Promise?o.then(s=>gf(s,t.out,r)):gf(o,t.out,r)}});function gf(e,t,n){return e.issues.some(r=>r.code!=="unrecognized_keys")?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}const O2=xe("$ZodReadonly",(e,t)=>{Yn.init(e,t),jn(e,"propValues",n=>n.def.innerType._zod.propValues),jn(e,"values",n=>n.def.innerType._zod.values),jn(e,"optin",n=>{var r,o;return(o=(r=n.def.innerType)==null?void 0:r._zod)==null?void 0:o.optin}),jn(e,"optout",n=>{var r,o;return(o=(r=n.def.innerType)==null?void 0:r._zod)==null?void 0:o.optout}),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(Cb):Cb(o)}});function Cb(e){return e.memo||(e.value=Object.freeze(e.value)),e}const M2=xe("$ZodCustom",(e,t)=>{mo.init(e,t),Yn.init(e,t),e._zod.parse=(n,r)=>n,e._zod.check=n=>{const r=n.value,o=t.fn(r);if(o instanceof Promise)return o.then(s=>Ib(s,n,r,e));Ib(o,n,r,e)}});function Ib(e,t,n,r){if(!e){const o={code:"custom",input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(o.params=r._zod.def.params),t.issues.push(xu(o))}}class L2 extends Error{constructor(){super("Cannot parse a reference cycle that closes through a transform"),this.name="ZodCyclicError"}}const Qg="~memo",Ab=[];function ig(e){return e.map(t=>t.path?{...t,path:t.path.slice()}:{...t})}const Rb=new WeakMap;function FS(e,t){const n=Rb.get(e);if(n!==void 0)return n;if(t.has(e))return!0;t.add(e);let r=!1;const o=c=>{!r&&(c!=null&&c._zod)&&FS(c,t)&&(r=!0)},s=e._zod.def;switch(s.type){case"object":{for(const c of Reflect.ownKeys(s.shape))o(s.shape[c]);o(s.catchall);break}case"array":o(s.element);break;case"tuple":for(const c of s.items)o(c);o(s.rest);break;case"record":case"map":o(s.keyType),o(s.valueType);break;case"set":o(s.valueType);break;case"union":for(const c of s.options)o(c);break;case"intersection":o(s.left),o(s.right);break;case"optional":case"nullable":case"default":case"prefault":case"catch":case"readonly":case"nonoptional":case"promise":case"success":o(s.innerType);break;case"pipe":o(s.in),o(s.out);break;case"function":o(s.input),o(s.output);break;case"lazy":o(e._zod.innerType);break;case"template_literal":case"string":case"number":case"int":case"boolean":case"bigint":case"symbol":case"undefined":case"null":case"void":case"never":case"any":case"unknown":case"date":case"nan":case"enum":case"literal":case"file":case"transform":case"custom":break;default:for(const c in s){const u=Object.getOwnPropertyDescriptor(s,c);if(!u||u.get)continue;const f=u.value;if(!(!f||typeof f!="object")){if(f._zod)o(f);else if(Array.isArray(f))for(const h of f)o(h)}}}return t.delete(e),Rb.set(e,r),r}function P2(e,t){let n=e.buckets.get(t);return n||(n=new Map,e.buckets.set(t,n)),n}let kf;const wf=[],D2={alloc(e,t,n){const r=kf;if(!r)return n;kf=void 0;const o={value:n,issues:null};return r.set(t.value,o),wf.push(o),n},guard(e){var t;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{const n=e._zod.parse,r=(o,s)=>{if(s.direction!=="backward"&&F2(s,o.value))throw new L2;return n(o,s)};e._zod.parse=r,e._zod.run===n&&(e._zod.run=r)})},attach(e){var t;let n,r,o;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{const s=e._zod.parse,a=(c,u)=>{if(n===void 0&&(n=FS(e,new Set),!n))return e._zod.parse=s,e._zod.run===a&&(e._zod.run=s),s(c,u);const f=c.value;if(f===null||typeof f!="object")return s(c,u);let h=u[Qg];h||(h={buckets:new Map,backEdges:void 0},u[Qg]=h);let m;r===u?m=o:(m=P2(h,e),r=u,o=m);const g=m.get(f);if(g)return c.value=g.value,g.issues?g.issues.length&&c.issues.push(...ig(g.issues)):(c.memo=!0,h.backEdges??(h.backEdges=new Set),h.backEdges.add(g.value)),c;kf=m;const y=wf.length,w=s(c,u);kf=void 0;const v=wf.length>y?wf.pop():void 0;return w instanceof Promise?w.then(_=>(v&&(v.issues=_.issues.length?ig(_.issues):Ab),_)):(v&&(v.issues=w.issues.length?ig(w.issues):Ab),w)};e._zod.parse=a,e._zod.run===s&&(e._zod.run=a)})}};function z2(){return D2}function F2(e,t){var r;const n=(r=e[Qg])==null?void 0:r.backEdges;return n!==void 0&&t!==null&&typeof t=="object"&&n.has(t)}const B2=()=>{const e={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"},map:{unit:"entries",verb:"to have"}};function t(s){return e[s]??null}const n={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",mac:"MAC address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",credit_card:"credit card number",jwt:"JWT",template_literal:"input"},r={nan:"NaN"};function o(s,a){return s==="number"&&typeof a=="number"&&!Number.isFinite(a)?String(a):r[s]??s}return s=>{switch(s.code){case"invalid_type":{const a=o(s.expected),c=bR(s.input),u=o(c,s.input);return`Invalid input: expected ${a}, received ${u}`}case"invalid_value":return s.values.length===1?`Invalid input: expected ${vS(s.values[0])}`:`Invalid option: expected one of ${fb(s.values,"|")}`;case"too_big":{const a=s.exact?"exactly ":s.inclusive?"<=":"<",c=t(s.origin);return c?`Too big: expected ${s.origin??"value"} to have ${a}${s.maximum.toString()} ${c.unit??"elements"}`:`Too big: expected ${s.origin??"value"} to be ${a}${s.maximum.toString()}`}case"too_small":{const a=s.exact?"exactly ":s.inclusive?">=":">",c=t(s.origin);return c?`Too small: expected ${s.origin} to have ${a}${s.minimum.toString()} ${c.unit}`:`Too small: expected ${s.origin} to be ${a}${s.minimum.toString()}`}case"invalid_format":{const a=s;return a.format==="starts_with"?`Invalid string: must start with "${a.prefix}"`:a.format==="ends_with"?`Invalid string: must end with "${a.suffix}"`:a.format==="includes"?`Invalid string: must include "${a.includes}"`:a.format==="regex"?`Invalid string: must match pattern ${a.pattern}`:`Invalid ${n[a.format]??s.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${s.divisor}`;case"unrecognized_keys":return`Unrecognized key${s.keys.length>1?"s":""}: ${fb(s.keys,", ")}`;case"invalid_key":return`Invalid key in ${s.origin}`;case"invalid_union":return s.options&&Array.isArray(s.options)&&s.options.length>0?`Invalid discriminator value. Expected ${s.options.map(c=>`'${c}'`).join(" | ")}`:s.inclusive===!1?"Invalid input: more than one option matched":"Invalid input";case"invalid_element":return`Invalid value in ${s.origin}`;default:return"Invalid input"}}};function U2(){return{localeError:B2()}}var Ob;class H2{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...n){const r=n[0];return this._map.set(t,r),r&&typeof r=="object"&&"id"in r&&this._idmap.set(r.id,t),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(t){const n=this._map.get(t);return n&&typeof n=="object"&&"id"in n&&this._idmap.delete(n.id),this._map.delete(t),this}get(t){const n=t._zod.parent;if(n){const r={...this.get(n)??{}};delete r.id;const o={...r,...this._map.get(t)};return Object.keys(o).length?o:void 0}return this._map.get(t)}has(t){return this._map.has(t)}}function W2(){return new H2}(Ob=globalThis).__zod_globalRegistry??(Ob.__zod_globalRegistry=W2());const ru=globalThis.__zod_globalRegistry;function K2(e,t){return new e({type:"string",...pt(t)})}function q2(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...pt(t)})}function Z2(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...pt(t)})}function G2(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...pt(t)})}function V2(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...pt(t)})}function Y2(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...pt(t)})}function X2(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...pt(t)})}function Q2(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...pt(t)})}function J2(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...pt(t)})}function eM(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...pt(t)})}function tM(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...pt(t)})}function nM(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...pt(t)})}function rM(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...pt(t)})}function oM(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...pt(t)})}function sM(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...pt(t)})}function iM(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...pt(t)})}function aM(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...pt(t)})}function lM(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...pt(t)})}function cM(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...pt(t)})}function uM(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...pt(t)})}function dM(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...pt(t)})}function fM(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...pt(t)})}function hM(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...pt(t)})}function pM(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...pt(t)})}function mM(e,t){return new e({type:"string",format:"date",check:"string_format",...pt(t)})}function gM(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...pt(t)})}function kM(e,t){return new e({type:"string",format:"duration",check:"string_format",...pt(t)})}function wM(e,t){return new e({type:"number",checks:[],...pt(t)})}function yM(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...pt(t)})}function vM(e,t){return new e({type:"boolean",...pt(t)})}function bM(e){return new e({type:"unknown"})}function xM(e,t){return new e({type:"never",...pt(t)})}function Mb(e,t){return new TS({check:"less_than",...pt(t),value:e,inclusive:!1})}function ag(e,t){return new TS({check:"less_than",...pt(t),value:e,inclusive:!0})}function Lb(e,t){return new $S({check:"greater_than",...pt(t),value:e,inclusive:!1})}function lg(e,t){return new $S({check:"greater_than",...pt(t),value:e,inclusive:!0})}function Pb(e,t){return new bO({check:"multiple_of",...pt(t),value:e})}function BS(e,t){return new EO({check:"max_length",...pt(t),maximum:e})}function eh(e,t){return new SO({check:"min_length",...pt(t),minimum:e})}function US(e,t){return new _O({check:"length_equals",...pt(t),length:e})}function EM(e,t){return new NO({check:"string_format",format:"regex",...pt(t),pattern:e})}function SM(e){return new jO({check:"string_format",format:"lowercase",...pt(e)})}function _M(e){return new TO({check:"string_format",format:"uppercase",...pt(e)})}function NM(e,t){return new $O({check:"string_format",format:"includes",...pt(t),includes:e})}function jM(e,t){return new CO({check:"string_format",format:"starts_with",...pt(t),prefix:e})}function TM(e,t){return new IO({check:"string_format",format:"ends_with",...pt(t),suffix:e})}function ic(e){return new AO({check:"overwrite",tx:e})}function $M(e){return ic(t=>t.normalize(e))}function CM(){return ic(e=>e.trim())}function IM(){return ic(e=>e.toLowerCase())}function AM(){return ic(e=>e.toUpperCase())}function RM(){return ic(e=>lR(e))}function OM(e,t,n){return new e({type:"array",element:t,...pt(n)})}function MM(e,t,n){return new e({type:"custom",check:"custom",fn:t,...pt(n)})}function LM(e,t){const n=PM(r=>(r.addIssue=o=>{if(typeof o=="string")r.issues.push(xu(o,r.value,n._zod.def));else{const s=o;s.fatal&&(s.continue=!1),s.code??(s.code="custom"),"input"in s||(s.input=r.value),s.inst??(s.inst=n),s.continue??(s.continue=!n._zod.def.abort),r.issues.push(xu(s))}},e(r.value,r)),t);return n}function PM(e,t){const n=new mo({check:"custom",...pt(t)});return n._zod.check=e,n}function hu(e,...t){for(const n of t)for(const r of Reflect.ownKeys(n))Object.prototype.propertyIsEnumerable.call(n,r)&&ho(e,r,n[r]);return e}function HS(e){let t=(e==null?void 0:e.target)??"draft-2020-12";return t==="draft-4"&&(t="draft-04"),t==="draft-7"&&(t="draft-07"),{processors:e.processors??{},metadataRegistry:(e==null?void 0:e.metadata)??ru,target:t,unrepresentable:(e==null?void 0:e.unrepresentable)??"throw",override:(e==null?void 0:e.override)??(()=>{}),io:(e==null?void 0:e.io)??"output",counter:0,seen:new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:(e==null?void 0:e.cycles)??"ref",reused:(e==null?void 0:e.reused)??"inline",intersections:[],deferred:[],external:(e==null?void 0:e.external)??void 0}}function Oi(e,t,n,r,o){const s=typeof t.unrepresentable=="function"?t.unrepresentable({zodSchema:e,path:r.path,message:o}):t.unrepresentable;if(s==="any")return!1;if(s===void 0||s==="throw")throw new Error(o);return Object.assign(n,s),!0}function Sr(e,t,n={path:[],schemaPath:[]}){var h,m;var r;const o=e._zod.def,s=t.seen.get(e);if(s)return s.count++,n.schemaPath.includes(e)&&(s.cycle=n.path),s.schema;const a={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,a),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;const c=(m=(h=e._zod).toJSONSchema)==null?void 0:m.call(h);if(c)a.schema=c;else{const g={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,a.schema,g);else{const w=a.schema,v=t.processors[o.type];if(!v)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${o.type}`);v(e,t,w,g)}const y=e._zod.parent;y&&(a.ref||(a.ref=y),Sr(y,t,g),t.seen.get(y).isParent=!0)}const u=t.metadataRegistry.get(e);return u&&hu(a.schema,u),t.io==="input"&&Xr(e)&&(delete a.schema.examples,delete a.schema.default),t.io==="input"&&"_prefault"in a.schema&&((r=a.schema).default??(r.default=a.schema._prefault)),delete a.schema._prefault,t.seen.get(e).schema}function Db(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function WS(e,t){var a,c,u,f;const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");if(e.external&&e.sharedDefsExtractedFor===e.external)return;const r=new Map;for(const h of e.seen.entries()){const m=(a=e.metadataRegistry.get(h[0]))==null?void 0:a.id;if(m){const g=r.get(m);if(g&&g!==h[0])throw new Error(`Duplicate schema id "${m}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(m,h[0])}}const o=h=>{var v;const m=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){const _=(v=e.external.registry.get(h[0]))==null?void 0:v.id,x=e.external.uri??(T=>T);if(_)return{ref:x(_)};const N=h[1].defId??h[1].schema.id??`schema${e.counter++}`;return h[1].defId=N,{defId:N,ref:`${x("__shared")}#/${m}/${Db(N)}`}}const g="#",y=`${g}/${m}/`;if(h[1]===n&&!h[1].schema.id)return{ref:g};const w=h[1].schema.id??`__schema${e.counter++}`;return{defId:w,ref:y+Db(w)}},s=h=>{if(h[1].schema.$ref)return;const m=h[1],{ref:g,defId:y}=o(h);m.def={...m.schema},y&&(m.defId=y);const w=m.schema;for(const v in w)delete w[v];w.$ref=g};if(e.cycles==="throw")for(const h of e.seen.entries()){const m=h[1];if(m.cycle)throw new Error(`Cycle detected: #/${(c=m.cycle)==null?void 0:c.join("/")}/<root>
92
-
93
- Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const h of e.seen.entries()){const m=h[1];if(t===h[0]){s(h);continue}if(e.external){const y=(u=e.external.registry.get(h[0]))==null?void 0:u.id;if(t!==h[0]&&y){s(h);continue}}if((f=e.metadataRegistry.get(h[0]))==null?void 0:f.id){s(h);continue}if(m.cycle){s(h);continue}if(m.count>1&&e.reused==="ref"){s(h);continue}}e.external&&(e.sharedDefsExtractedFor=e.external)}function KS(e){const t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;const n=[];for(const r of t){if(!r||typeof r!="object")return;KS(r);const o=Object.keys(r);if(o.length!==1||o[0]!=="type")return;const s=r.type;for(const a of Array.isArray(s)?s:[s]){if(typeof a!="string")return;n.includes(a)||n.push(a)}}delete e.anyOf,e.type=n.length===1?n[0]:n}const qS=new Set(["type","properties","required","additionalProperties"]),zb=["oneOf","anyOf"];function Fb(e){const t=e.additionalProperties;return t===void 0||t===!1||typeof t!="object"||t===null?null:Object.keys(t).length?t:null}function Jg(e){var s;const t=[];for(const a of e){if(typeof a!="object"||a.type!=="object")return null;for(const c in a)if(!qS.has(c))return null;t.push(a)}const n={},r=new Set;for(const a of t){for(const c in a.properties){if(Object.prototype.hasOwnProperty.call(n,c))continue;const u=[];for(const h of t){const m=((s=h.properties)==null?void 0:s[c])??Fb(h);m!=null&&(u.some(g=>JSON.stringify(g)===JSON.stringify(m))||u.push(m))}const f=u.length===1?u[0]:Jg(u)??{allOf:u};ho(n,c,f)}for(const c of a.required??[])r.add(c)}const o={type:"object",properties:n};if(r.size&&(o.required=[...r]),t.every(a=>a.additionalProperties===!1))o.additionalProperties=!1;else{const a=[];for(const c of t){const u=Fb(c);u&&!a.some(f=>JSON.stringify(f)===JSON.stringify(u))&&a.push(u)}a.length===1?o.additionalProperties=a[0]:a.length>1&&(o.additionalProperties={allOf:a})}return o}function DM(e){const t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(const o of qS)if(o in e)return;const n=t.filter(o=>zb.some(s=>Array.isArray(o[s])));let r=null;if(!n.length)r=Jg(t);else{const o=n[0],s=zb.find(u=>Array.isArray(o[u]));if(Object.keys(o).length!==1)return;const a=t.filter(u=>u!==o),c=o[s].map(u=>Jg([...a,u]));if(c.some(u=>!u))return;r={[s]:c}}r&&(delete e.allOf,hu(e,r))}function ZS(e,t){var c,u,f,h;const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=m=>{const g=e.seen.get(m);if(g.ref===null)return;const y=g.def??g.schema,w={...y},v=g.ref;if(g.ref=null,v){r(v);const x=e.seen.get(v),N=x.schema;if(N.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(y.allOf=y.allOf??[],y.allOf.push(N)):hu(y,N),hu(y,w),m._zod.parent===v)for(const j in y)j==="$ref"||j==="allOf"||j in w||delete y[j];if(N.$ref&&x.def)for(const j in y)j==="$ref"||j==="allOf"||j in x.def&&JSON.stringify(y[j])===JSON.stringify(x.def[j])&&delete y[j]}const _=m._zod.parent;if(_&&_!==v){r(_);const x=e.seen.get(_);if(x!=null&&x.schema.$ref&&(y.$ref=x.schema.$ref,x.def))for(const N in y)N==="$ref"||N==="allOf"||N in x.def&&JSON.stringify(y[N])===JSON.stringify(x.def[N])&&delete y[N]}e.override({zodSchema:m,jsonSchema:y,path:g.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(const m of[...e.seen.entries()].reverse())r(m[0]);if(e.target!=="openapi-3.0")for(const m of e.seen.entries())KS(m[1].def??m[1].schema);for(const m of e.deferred)m();if(e.intersections.length){const m=new Map;for(const g of e.seen.values())for(const y of[g.schema,g.def]){const w=y==null?void 0:y.allOf;if(!Array.isArray(w))continue;const v=m.get(w);v?v.push(y):m.set(w,[y])}for(const g of e.intersections)for(const y of m.get(g)??[])DM(y)}}const o={};if(e.target==="draft-2020-12"?o.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?o.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?o.$schema="http://json-schema.org/draft-04/schema#":e.target,(c=e.external)!=null&&c.uri){const m=(u=e.external.registry.get(t))==null?void 0:u.id;if(!m)throw new Error("Schema is missing an `id` property");o.$id=e.external.uri(m)}hu(o,n.defId?n.schema:n.def??n.schema);const s=(f=e.metadataRegistry.get(t))==null?void 0:f.id;s!==void 0&&o.id===s&&delete o.id;const a=((h=e.external)==null?void 0:h.defs)??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(const m of e.seen.entries()){const g=m[1];g.def&&g.defId&&(g.def.id===g.defId&&delete g.def.id,ho(a,g.defId,g.def))}e.external&&(e.sharedEmitDoneFor=e.external),e.external||Object.keys(a).length>0&&(e.target==="draft-2020-12"?o.$defs=a:o.definitions=a);try{const m=JSON.parse(JSON.stringify(o));return Object.defineProperty(m,"~standard",{value:{...t["~standard"],jsonSchema:{input:th(t,"input",e.processors),output:th(t,"output",e.processors)}},enumerable:!1,writable:!1}),m}catch{throw new Error("Error converting schema to JSON.")}}function Xr(e,t){const n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);const r=e._zod.def;if(r.type==="transform")return!0;if(r.type==="array")return Xr(r.element,n);if(r.type==="set")return Xr(r.valueType,n);if(r.type==="lazy")return Xr(r.getter(),n);if(r.type==="promise"||r.type==="optional"||r.type==="nonoptional"||r.type==="nullable"||r.type==="readonly"||r.type==="default"||r.type==="prefault"||r.type==="catch")return Xr(r.innerType,n);if(r.type==="intersection")return Xr(r.left,n)||Xr(r.right,n);if(r.type==="record"||r.type==="map")return Xr(r.keyType,n)||Xr(r.valueType,n);if(r.type==="pipe")return e._zod.traits.has("$ZodCodec")?!0:Xr(r.in,n)||Xr(r.out,n);if(r.type==="object"){for(const o in r.shape)if(Xr(r.shape[o],n))return!0;return!1}if(r.type==="union"){for(const o of r.options)if(Xr(o,n))return!0;return!1}if(r.type==="tuple"){for(const o of r.items)if(Xr(o,n))return!0;return!!(r.rest&&Xr(r.rest,n))}return!1}const zM=(e,t={})=>n=>{const r=HS({...n,processors:t});return Sr(e,r),WS(r,e),ZS(r,e)},th=(e,t,n={})=>r=>{const{libraryOptions:o,target:s}=r??{},a=HS({...o??{},target:s,io:t,processors:n});return Sr(e,a),WS(a,e),ZS(a,e)},FM={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},BM=(e,t,n,r)=>{const o=n;o.type="string";const{minimum:s,maximum:a,format:c,patterns:u,contentEncoding:f,laxFormat:h}=e._zod.bag;if(typeof s=="number"&&(o.minLength=s),typeof a=="number"&&(o.maxLength=a),c&&(o.format=FM[c]??c,o.format===""&&delete o.format,(c==="time"||h)&&delete o.format),f&&(o.contentEncoding=f),u&&u.size>0){const m=[...u];m.length===1?o.pattern=m[0].source:m.length>1&&(o.allOf=[...m.map(g=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:g.source}))])}},UM=(e,t,n,r)=>{const o=n,{minimum:s,maximum:a,format:c,multipleOf:u,exclusiveMaximum:f,exclusiveMinimum:h}=e._zod.bag;typeof c=="string"&&c.includes("int")?o.type="integer":o.type="number";const m=typeof h=="number"&&h>=(s??Number.NEGATIVE_INFINITY),g=typeof f=="number"&&f<=(a??Number.POSITIVE_INFINITY),y=t.target==="draft-04"||t.target==="openapi-3.0";m?y?(o.minimum=h,o.exclusiveMinimum=!0):o.exclusiveMinimum=h:typeof s=="number"&&(o.minimum=s),g?y?(o.maximum=f,o.exclusiveMaximum=!0):o.exclusiveMaximum=f:typeof a=="number"&&(o.maximum=a),typeof u=="number"&&(Number.isFinite(u)&&u!==0?o.multipleOf=Math.abs(u):Oi(e,t,o,r,`A multipleOf divisor of ${u} cannot be represented in JSON Schema`))},HM=(e,t,n,r)=>{n.type="boolean"},WM=(e,t,n,r)=>{n.not={}},KM=(e,t,n,r)=>{},qM=(e,t,n,r)=>{const o=e._zod.def,s=kS(o.entries);if(s.length===0){n.not={};return}s.every(a=>typeof a=="number")&&(n.type="number"),s.every(a=>typeof a=="string")&&(n.type="string"),n.enum=s},ZM=(e,t,n,r)=>{const o=e._zod.def;if(o.values.length===0){n.not={};return}const s=[];for(const a of o.values)if(a===void 0){if(Oi(e,t,n,r,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof a=="bigint"){if(Oi(e,t,n,r,"BigInt literals cannot be represented in JSON Schema"))return;s.push(Number(a))}else s.push(a);if(s.length!==0)if(s.length===1){const a=s[0];n.type=a===null?"null":typeof a,t.target==="draft-04"||t.target==="openapi-3.0"?n.enum=[a]:n.const=a}else s.every(a=>typeof a=="number")&&(n.type="number"),s.every(a=>typeof a=="string")&&(n.type="string"),s.every(a=>typeof a=="boolean")&&(n.type="boolean"),s.every(a=>a===null)&&(n.type="null"),n.enum=s},GM=(e,t,n,r)=>{Oi(e,t,n,r,"Custom types cannot be represented in JSON Schema")},VM=(e,t,n,r)=>{Oi(e,t,n,r,"Transforms cannot be represented in JSON Schema")},YM=(e,t,n,r)=>{const o=n,s=e._zod.def,{minimum:a,maximum:c}=e._zod.bag;typeof a=="number"&&(o.minItems=a),typeof c=="number"&&(o.maxItems=c),o.type="array",o.items=Sr(s.element,t,{...r,path:[...r.path,"items"]})};function nh(e){const t=e._zod.def;return t.type==="pipe"&&t.in._zod.traits.has("$ZodTransform")?nh(t.out):t.type==="catch"?nh(t.innerType):e._zod.optin}const XM=(e,t,n,r)=>{var h;const o=n,s=e._zod.def,a=s.shape;if(Object.getOwnPropertySymbols(a).length&&Oi(e,t,o,r,"Symbol keys cannot be represented in JSON Schema"))return;o.type="object",o.properties={};for(const m in a)ho(o.properties,m,Sr(a[m],t,{...r,path:[...r.path,"properties",m]}));const u=new Set(Object.keys(a)),f=new Set([...u].filter(m=>{const g=s.shape[m];return t.io==="input"?nh(g)===void 0:g._zod.optout===void 0}));f.size>0&&(o.required=Array.from(f)),((h=s.catchall)==null?void 0:h._zod.def.type)==="never"?o.additionalProperties=!1:s.catchall?s.catchall&&(o.additionalProperties=Sr(s.catchall,t,{...r,path:[...r.path,"additionalProperties"]})):t.io==="output"&&(o.additionalProperties=!1)},QM=(e,t,n,r)=>{const o=e._zod.def,s=o.inclusive===!1,a=o.options.map((c,u)=>Sr(c,t,{...r,path:[...r.path,s?"oneOf":"anyOf",u]}));s?n.oneOf=a:n.anyOf=a},JM=(e,t,n,r)=>{const o=e._zod.def,s=Sr(o.left,t,{...r,path:[...r.path,"allOf",0]}),a=Sr(o.right,t,{...r,path:[...r.path,"allOf",1]}),c=f=>"allOf"in f&&Object.keys(f).length===1,u=[...c(s)?s.allOf:[s],...c(a)?a.allOf:[a]];n.allOf=u,t.intersections.push(u)},eL=(e,t,n,r)=>{const o=n,s=e._zod.def;o.type="array";const a=t.target==="draft-2020-12"?"prefixItems":"items",c=t.target==="draft-2020-12"||t.target==="openapi-3.0"?"items":"additionalItems",u=s.items.map((v,_)=>Sr(v,t,{...r,path:[...r.path,a,_]})),f=s.rest?Sr(s.rest,t,{...r,path:[...r.path,c,...t.target==="openapi-3.0"?[s.items.length]:[]]}):null;let h=s.items.length;for(;h>0;){const v=s.items[h-1];if(!(t.io==="input"?nh(v)!==void 0:v._zod.optout==="optional"))break;h--}const m=s.items.length,g=!s.rest;t.target==="draft-2020-12"?(o.prefixItems=u,g?o.items=!1:f&&(o.items=f),h>0&&(o.minItems=h),g&&(o.maxItems=m)):t.target==="openapi-3.0"?(o.items={anyOf:u},f&&o.items.anyOf.push(f),h>0&&(o.minItems=h),g&&(o.maxItems=m)):(o.items=u,g?o.additionalItems=!1:f&&(o.additionalItems=f),h>0&&(o.minItems=h),g&&(o.maxItems=m));const{minimum:y,maximum:w}=e._zod.bag;typeof y=="number"&&(o.minItems=y),typeof w=="number"&&(o.maxItems=w)},tL=(e,t,n,r)=>{const o=e._zod.def,s=Sr(o.innerType,t,r),a=t.seen.get(e);t.target==="openapi-3.0"?(a.ref=o.innerType,n.nullable=!0):n.anyOf=[s,{type:"null"}]},nL=(e,t,n,r)=>{const o=e._zod.def;Sr(o.innerType,t,r);const s=t.seen.get(e);s.ref=o.innerType},_w=Symbol();function GS(e,t,n,r,o){let s=!1;const a=JSON.stringify(e,(c,u)=>typeof u!="bigint"?u:(s=!0,null));return s?(Oi(t,n,r,o,"BigInt defaults cannot be represented in JSON Schema"),_w):JSON.parse(a)}const rL=(e,t,n,r)=>{const o=e._zod.def;Sr(o.innerType,t,r);const s=t.seen.get(e);s.ref=o.innerType;const a=GS(o.defaultValue,e,t,n,r);a!==_w&&(n.default=a)},oL=(e,t,n,r)=>{const o=e._zod.def;Sr(o.innerType,t,r);const s=t.seen.get(e);if(s.ref=o.innerType,t.io!=="input")return;const a=GS(o.defaultValue,e,t,n,r);a!==_w&&(n._prefault=a)},sL=(e,t,n,r)=>{const o=e._zod.def;Sr(o.innerType,t,r);const s=t.seen.get(e);s.ref=o.innerType;let a;try{a=o.catchValue(void 0)}catch{Oi(e,t,n,r,"Dynamic catch values are not supported in JSON Schema");return}n.default=a},iL=(e,t,n,r)=>{const o=e._zod.def,s=o.in._zod.traits.has("$ZodTransform"),a=t.io==="input"?s?o.out:o.in:o.out;Sr(a,t,r);const c=t.seen.get(e);c.ref=a},aL=(e,t,n,r)=>{const o=e._zod.def;Sr(o.innerType,t,r);const s=t.seen.get(e);s.ref=o.innerType,n.readOnly=!0},VS=(e,t,n,r)=>{const o=e._zod.def;Sr(o.innerType,t,r);const s=t.seen.get(e);s.ref=o.innerType},Bb=new WeakSet([Object.prototype,Error.prototype]);function yf(e,t,n){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){const r=n(this);return Object.defineProperty(this,t,{value:r,configurable:!0,writable:!0}),r},set(r){Object.defineProperty(this,t,{value:r,configurable:!0,writable:!0})}})}const lL=(e,t)=>{SS.init(e,t),e.name="ZodError";const n=Object.getPrototypeOf(e);Bb.has(n)||(Bb.add(n),yf(n,"format",r=>o=>MR(r,o)),yf(n,"flatten",r=>o=>OR(r,o)),yf(n,"addIssue",r=>o=>{r.issues.push(o),r.message=JSON.stringify(r.issues,Gg,2)}),yf(n,"addIssues",r=>o=>{r.issues.push(...o),r.message=JSON.stringify(r.issues,Gg,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},Wo=xe("ZodError",lL,void 0,{Parent:Error}),cL=bw(Wo),uL=xw(Wo),dL=Hh(Wo),fL=Wh(Wo),hL=DR(Wo),pL=zR(Wo),mL=FR(Wo),gL=BR(Wo),kL=UR(Wo),wL=HR(Wo),yL=WR(Wo),vL=KR(Wo);function bL(){is.localeError||Fi(U2())}function qh(){is.memoizer||Fi({memoizer:z2()})}const er=xe("ZodType",(e,t)=>(bL(),Yn.init(e,t),e.def=t,e.type=t.type,e),{check(...e){const t=this.def;return this.clone(Di(t,{checks:[...t.checks??[],...e.map(n=>typeof n=="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return zi(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(yP(e,t))},superRefine(e,t){return this.check(vP(e,t))},overwrite(e){return this.check(ic(e))},optional(){return Wb(this)},exactOptional(){return aP(this)},nullable(){return Kb(this)},nullish(){return Wb(Kb(this))},nonoptional(e){return hP(this,e)},array(){return Sa(this)},or(e){return QL([this,e])},and(e){return nP(this,e)},transform(e){return qb(this,iP(e))},default(e){return uP(this,e)},prefault(e){return fP(this,e)},catch(e){return mP(this,e)},pipe(e){return qb(this,e)},readonly(){return wP(this)},describe(e){const t=this.clone();return ru.add(t,{description:e}),t},meta(...e){if(e.length===0)return ru.get(this);const t=this.clone();return ru.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return t.length===0?e(this):e(this,...t)},get"~standard"(){return bS(this,"~standard",{...CS(this),jsonSchema:{input:th(this,"input"),output:th(this,"output")}})},set"~standard"(e){Gl(this,"~standard",e)},parse:function e(t,n){return cL(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await uL(this,t,n,{callee:e})},safeParse(e,t){return dL(this,e,t)},async safeParseAsync(e,t){return fL(this,e,t)},get spa(){return this==null?void 0:this.safeParseAsync},set spa(e){Gl(this,"spa",e)},encode:function e(t,n){return hL(this,t,n,{callee:e})},decode:function e(t,n){return pL(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await mL(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await gL(this,t,n,{callee:e})},safeEncode(e,t){return kL(this,e,t)},safeDecode(e,t){return wL(this,e,t)},async safeEncodeAsync(e,t){return yL(this,e,t)},async safeDecodeAsync(e,t){return vL(this,e,t)},toJSONSchema(e){return zM(this,{})(e)},get description(){var e;return(e=ru.get(this))==null?void 0:e.description},get _def(){return this._zod.def}}),YS=xe("_ZodString",(e,t)=>{Sw.init(e,t),er.init(e,t),e._zod.processJSONSchema=(r,o,s)=>BM(e,r,o);const n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null},{regex(...e){return this.check(EM(...e))},includes(...e){return this.check(NM(...e))},startsWith(...e){return this.check(jM(...e))},endsWith(...e){return this.check(TM(...e))},min(...e){return this.check(eh(...e))},max(...e){return this.check(BS(...e))},length(...e){return this.check(US(...e))},nonempty(...e){return this.check(eh(1,...e))},lowercase(e){return this.check(SM(e))},uppercase(e){return this.check(_M(e))},trim(){return this.check(CM())},normalize(...e){return this.check($M(...e))},toLowerCase(){return this.check(IM())},toUpperCase(){return this.check(AM())},slugify(){return this.check(RM())}}),xL=xe("ZodString",(e,t)=>{Sw.init(e,t),YS.init(e,t)},{email(e){return this.check(q2(jL,e))},url(e){return this.check(Q2($L,e))},jwt(e){return this.check(hM(WL,e))},emoji(e){return this.check(J2(CL,e))},guid(e){return this.check(Z2(TL,e))},uuid(e){return this.check(G2(vf,e))},uuidv4(e){return this.check(V2(vf,e))},uuidv6(e){return this.check(Y2(vf,e))},uuidv7(e){return this.check(X2(vf,e))},nanoid(e){return this.check(eM(IL,e))},cuid(e){return this.check(tM(AL,e))},cuid2(e){return this.check(nM(RL,e))},ulid(e){return this.check(rM(OL,e))},base64(e){return this.check(uM(BL,e))},base64url(e){return this.check(dM(UL,e))},xid(e){return this.check(oM(ML,e))},ksuid(e){return this.check(sM(LL,e))},ipv4(e){return this.check(iM(PL,e))},ipv6(e){return this.check(aM(DL,e))},cidrv4(e){return this.check(lM(zL,e))},cidrv6(e){return this.check(cM(FL,e))},e164(e){return this.check(fM(HL,e))},datetime(e){return this.check(pM(EL,e))},date(e){return this.check(mM(SL,e))},time(e){return this.check(gM(_L,e))},duration(e){return this.check(kM(NL,e))}});function Tn(e){return K2(xL,e)}const tr=xe("ZodStringFormat",(e,t)=>{Xn.init(e,t),YS.init(e,t)}),EL=xe("ZodISODateTime",(e,t)=>{XO.init(e,t),tr.init(e,t)}),SL=xe("ZodISODate",(e,t)=>{QO.init(e,t),tr.init(e,t)}),_L=xe("ZodISOTime",(e,t)=>{JO.init(e,t),tr.init(e,t)}),NL=xe("ZodISODuration",(e,t)=>{e2.init(e,t),tr.init(e,t)}),jL=xe("ZodEmail",(e,t)=>{PO.init(e,t),tr.init(e,t)}),TL=xe("ZodGUID",(e,t)=>{MO.init(e,t),tr.init(e,t)}),vf=xe("ZodUUID",(e,t)=>{LO.init(e,t),tr.init(e,t)}),$L=xe("ZodURL",(e,t)=>{HO.init(e,t),tr.init(e,t)}),CL=xe("ZodEmoji",(e,t)=>{WO.init(e,t),tr.init(e,t)}),IL=xe("ZodNanoID",(e,t)=>{KO.init(e,t),tr.init(e,t)}),AL=xe("ZodCUID",(e,t)=>{qO.init(e,t),tr.init(e,t)}),RL=xe("ZodCUID2",(e,t)=>{ZO.init(e,t),tr.init(e,t)}),OL=xe("ZodULID",(e,t)=>{GO.init(e,t),tr.init(e,t)}),ML=xe("ZodXID",(e,t)=>{VO.init(e,t),tr.init(e,t)}),LL=xe("ZodKSUID",(e,t)=>{YO.init(e,t),tr.init(e,t)}),PL=xe("ZodIPv4",(e,t)=>{t2.init(e,t),tr.init(e,t)}),DL=xe("ZodIPv6",(e,t)=>{r2.init(e,t),tr.init(e,t)}),zL=xe("ZodCIDRv4",(e,t)=>{o2.init(e,t),tr.init(e,t)}),FL=xe("ZodCIDRv6",(e,t)=>{i2.init(e,t),tr.init(e,t)}),BL=xe("ZodBase64",(e,t)=>{a2.init(e,t),tr.init(e,t)}),UL=xe("ZodBase64URL",(e,t)=>{c2.init(e,t),tr.init(e,t)}),HL=xe("ZodE164",(e,t)=>{u2.init(e,t),tr.init(e,t)}),WL=xe("ZodJWT",(e,t)=>{f2.init(e,t),tr.init(e,t)}),XS=xe("ZodNumber",(e,t)=>{MS.init(e,t),er.init(e,t),e._zod.processJSONSchema=(r,o,s)=>UM(e,r,o,s);const n=e._zod.bag;e.minValue=Math.max(n.minimum??Number.NEGATIVE_INFINITY,n.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(n.maximum??Number.POSITIVE_INFINITY,n.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(n.format??"").includes("int")||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null},{gt(e,t){return this.check(Lb(e,t))},gte(e,t){return this.check(lg(e,t))},min(e,t){return this.check(lg(e,t))},lt(e,t){return this.check(Mb(e,t))},lte(e,t){return this.check(ag(e,t))},max(e,t){return this.check(ag(e,t))},int(e){return this.check(Ub(e))},safe(e){return this.check(Ub(e))},positive(e){return this.check(Lb(0,e))},nonnegative(e){return this.check(lg(0,e))},negative(e){return this.check(Mb(0,e))},nonpositive(e){return this.check(ag(0,e))},multipleOf(e,t){return this.check(Pb(e,t))},step(e,t){return this.check(Pb(e,t))},finite(){return this}});function Rs(e){return wM(XS,e)}const KL=xe("ZodNumberFormat",(e,t)=>{h2.init(e,t),XS.init(e,t)});function Ub(e){return yM(KL,e)}const qL=xe("ZodBoolean",(e,t)=>{p2.init(e,t),er.init(e,t),e._zod.processJSONSchema=(n,r,o)=>HM(e,n,r)});function Do(e){return vM(qL,e)}const ZL=xe("ZodUnknown",(e,t)=>{m2.init(e,t),er.init(e,t),e._zod.processJSONSchema=(n,r,o)=>KM()});function Hb(){return bM(ZL)}const GL=xe("ZodNever",(e,t)=>{g2.init(e,t),er.init(e,t),e._zod.processJSONSchema=(n,r,o)=>WM(e,n,r)});function VL(e){return xM(GL,e)}const YL=xe("ZodArray",(e,t)=>{qh(),k2.init(e,t),er.init(e,t),e._zod.processJSONSchema=(n,r,o)=>YM(e,n,r,o),e.element=t.element},{min(e,t){return this.check(eh(e,t))},nonempty(e){return this.check(eh(1,e))},max(e,t){return this.check(BS(e,t))},length(e,t){return this.check(US(e,t))},unwrap(){return this.element}});function Sa(e,t){return OM(YL,e,t)}const XL=xe("ZodObject",(e,t)=>{qh(),v2.init(e,t),er.init(e,t),e._zod.processJSONSchema=(n,r,o)=>XM(e,n,r,o),NR(e,"shape",n=>n._zod.def.shape,!1)},{keyof(){return Rl(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:Hb()})},loose(){return this.clone({...this._zod.def,catchall:Hb()})},strict(){return this.clone({...this._zod.def,catchall:VL()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return mR(this,e)},safeExtend(e){return gR(this,e)},merge(e){return kR(this,e)},pick(e){return hR(this,e)},omit(e){return pR(this,e)},partial(...e){return hb(Nw,this,e[0])},exactPartial(...e){return hb(e_,this,e[0],"exactPartial")},required(...e){return wR(t_,this,e[0])}});function Tr(e,t){const n={type:"object",shape:e??{},...pt(t)};return new XL(n)}const QS=xe("ZodUnion",(e,t)=>{DS.init(e,t),er.init(e,t),e._zod.processJSONSchema=(n,r,o)=>QM(e,n,r,o),e.options=t.options});function QL(e,t){return new QS({type:"union",options:e,...pt(t)})}const JL=xe("ZodDiscriminatedUnion",(e,t)=>{QS.init(e,t),b2.init(e,t)});function eP(e,t,n){return new JL({type:"union",options:t,discriminator:e,...pt(n)})}const tP=xe("ZodIntersection",(e,t)=>{x2.init(e,t),er.init(e,t),e._zod.processJSONSchema=(n,r,o)=>JM(e,n,r,o)});function nP(e,t){return new tP({type:"intersection",left:e,right:t})}const rP=xe("ZodTuple",(e,t)=>{qh(),E2.init(e,t),er.init(e,t),e._zod.processJSONSchema=(n,r,o)=>eL(e,n,r,o)},{rest(e){return this.clone({...this._zod.def,rest:e})},partial(){var t;const e=this._zod.def;if((t=e.checks)!=null&&t.length)throw new Error(".partial() cannot be used on tuple schemas containing refinements");return this.clone({...e,items:e.items.map(n=>new Nw({type:"optional",innerType:n}))})}});function JS(e,t,n){const r=t instanceof Yn,o=r?n:t,s=r?t:null;return new rP({type:"tuple",items:e,rest:s,...pt(o)})}const ek=xe("ZodEnum",(e,t)=>{S2.init(e,t),er.init(e,t),e._zod.processJSONSchema=(r,o,s)=>qM(e,r,o),e.enum=t.entries,e.options=Object.values(t.entries);const n=new Set(Object.keys(t.entries));e.extract=(r,o)=>{const s={};for(const a of r)if(n.has(a))s[a]=t.entries[a];else throw new Error(`Key ${a} not found in enum`);return new ek({...t,checks:[],...pt(o),entries:s})},e.exclude=(r,o)=>{const s={...t.entries};for(const a of r)if(n.has(a))delete s[a];else throw new Error(`Key ${a} not found in enum`);return new ek({...t,checks:[],...pt(o),entries:s})}});function Rl(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(r=>[r,r])):e;return new ek({type:"enum",entries:n,...pt(t)})}const oP=xe("ZodLiteral",(e,t)=>{_2.init(e,t),er.init(e,t),e._zod.processJSONSchema=(n,r,o)=>ZM(e,n,r,o),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function Yr(e,t){return new oP({type:"literal",values:Array.isArray(e)?e:[e],...pt(t)})}const sP=xe("ZodTransform",(e,t)=>{qh(),N2.init(e,t),er.init(e,t),e._zod.processJSONSchema=(n,r,o)=>VM(e,n,r,o),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new xS(e.constructor.name);n.addIssue=s=>{if(typeof s=="string")n.issues.push(xu(s,n.value,t));else{const a=s;a.fatal&&(a.continue=!1),a.code??(a.code="custom"),"input"in a||(a.input=n.value),a.inst??(a.inst=e),n.issues.push(xu(a))}};const o=t.transform(n.value,n);return o instanceof Promise?o.then(s=>(n.value=s,n)):(n.value=o,n)}});function iP(e){return new sP({type:"transform",transform:e})}const Nw=xe("ZodOptional",(e,t)=>{zS.init(e,t),er.init(e,t),e._zod.processJSONSchema=(n,r,o)=>VS(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function Wb(e){return new Nw({type:"optional",innerType:e})}const e_=xe("ZodExactOptional",(e,t)=>{j2.init(e,t),er.init(e,t),e._zod.processJSONSchema=(n,r,o)=>VS(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function aP(e){return new e_({type:"optional",innerType:e})}const lP=xe("ZodNullable",(e,t)=>{T2.init(e,t),er.init(e,t),e._zod.processJSONSchema=(n,r,o)=>tL(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function Kb(e){return new lP({type:"nullable",innerType:e})}const cP=xe("ZodDefault",(e,t)=>{$2.init(e,t),er.init(e,t),e._zod.processJSONSchema=(n,r,o)=>rL(e,n,r,o),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function uP(e,t){return new cP({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():yS(t)}})}const dP=xe("ZodPrefault",(e,t)=>{C2.init(e,t),er.init(e,t),e._zod.processJSONSchema=(n,r,o)=>oL(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function fP(e,t){return new dP({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():yS(t)}})}const t_=xe("ZodNonOptional",(e,t)=>{I2.init(e,t),er.init(e,t),e._zod.processJSONSchema=(n,r,o)=>nL(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function hP(e,t){return new t_({type:"nonoptional",innerType:e,...pt(t)})}const pP=xe("ZodCatch",(e,t)=>{A2.init(e,t),er.init(e,t),e._zod.processJSONSchema=(n,r,o)=>sL(e,n,r,o),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function mP(e,t){return new pP({type:"catch",innerType:e,catchValue:typeof t=="function"?t:TR(t)})}const gP=xe("ZodPipe",(e,t)=>{R2.init(e,t),er.init(e,t),e._zod.processJSONSchema=(n,r,o)=>iL(e,n,r,o),e.in=t.in,e.out=t.out});function qb(e,t){return new gP({type:"pipe",in:e,out:t})}const kP=xe("ZodReadonly",(e,t)=>{O2.init(e,t),er.init(e,t),e._zod.processJSONSchema=(n,r,o)=>aL(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function wP(e){return new kP({type:"readonly",innerType:e})}const n_=xe("ZodCustom",(e,t)=>{M2.init(e,t),er.init(e,t),e._zod.processJSONSchema=(n,r,o)=>GM(e,n,r,o)});function yP(e,t={}){return MM(n_,e,t)}function vP(e,t){return LM(e,t)}function bP(e,t={}){const n=new n_({type:"custom",check:"custom",fn:r=>r instanceof e,abort:!0,...pt(t)});return n._zod.bag.Class=e,n._zod.check=r=>{r.value instanceof e||r.issues.push({code:"invalid_type",expected:e.name,input:r.value,inst:n,path:[...n._zod.def.path??[]]})},n}const xP=["off","tailscale","any"],EP={updates:!0,deploy:!0,remote:"any",agents:null,customAgents:!0,brandedListener:!0,planSignIn:!0};Tr({updates:Do().optional(),deploy:Do().optional(),remote:Rl(xP).optional(),agents:Sa(Tn()).optional(),customAgents:Do().optional(),brandedListener:Do().optional(),planSignIn:Do().optional()});const SP={...EP,source:null,problem:null};function _P(e){const t=[];return e.updates||t.push("updates off"),e.deploy||t.push("deploy off"),e.remote!=="any"&&t.push(`remote ${e.remote}`),e.agents!==null&&t.push(`agents ${e.agents.join(", ")||"none"}`),e.customAgents||t.push("custom agents off"),e.brandedListener||t.push("toyon.localhost listener off"),e.planSignIn||t.push("plan sign-in off"),t}const cg=6e3,Zb=1500;function NP(e){if(e.length<=cg)return e;const t=e.length-cg;return`${e.slice(0,Zb)}
94
- [${t} characters cut here]
95
- ${e.slice(e.length-(cg-Zb))}`}const va=148,jP=2e3,rh=5e6,TP=["image/png","image/jpeg","image/gif","image/webp"],Gb=2576,ug=5*1024*1024,$P=1200,CP=10,IP=1e5,Vb=100*1024*1024,AP="pasted-text.txt";function RP(e){return e.t==="term-data"||e.t==="term-snapshot"||e.t==="term-exit"}function OP(e){return e.t==="file-read"||e.t==="file-written"||e.t==="file-blame"}const MP=80;function jw(e){var r;const t=e.split(`
96
- `),n=((r=t.find(o=>o.trim().length>0))==null?void 0:r.trim())??"";return{chars:e.length,lines:t.length,preview:n.slice(0,MP)}}function r_(e){return e.length>=$P||e.split(`
97
- `).length>=CP}function LP({startLine:e,endLine:t}){return e===t?`${e}`:`${e}-${t}`}function PP(e){return`${e.path.slice(e.path.lastIndexOf("/")+1)} (${LP(e)})`}const DP=/\u001B(?:\[[0-?]*[ -/]*[@-~]|\][^\u0007]*(?:\u0007|\u001B\\))/g;function zP(e){return e.replace(DP,"")}function o_(e){const t=/^\s*#{1,6}[ \t]+(.+?)[ \t#]*(?:\r?\n|$)/.exec(e);return t?{title:t[1].trim(),rest:e.slice(t[0].length)}:{title:null,rest:e}}function FP(e){const t=e.plan.trim();return o_(t).title===null?`# ${e.title}
98
-
99
- ${t}
100
- `:`${t}
101
- `}const s_="Projects";function BP(e){for(const t of e){const n=t.codePointAt(0)??0;if(n<32||n===127)return!0}return!1}function Eu(e){const t=e.trim();return t?t.length>100?"that name is too long: keep it under 100 characters":t.includes("/")||t.includes("\\")?"a project name cannot contain a slash":/\s/.test(t)?"a project name cannot contain spaces":BP(t)?"a project name cannot contain control characters":t==="."||t===".."?`"${t}" is not a project name`:t.startsWith("-")||t.startsWith(".")?"a project name cannot start with a dot or a dash":null:"a project name is required"}const UP=/^(?:https?|ssh|git|file):\/\/\S+$/i,i_=/^[\w.-]+@[\w.-]+:\S+$/,HP=/^[\w-]+(?:\.[\w-]+)+\/\S+$/;function Yb(e){const t=e.trim(),n=HP.test(t)?`https://${t}`:t;if(!UP.test(n)&&!i_.test(n))return null;const r=WP(n),o=qP((r==null?void 0:r.url)??n);return!o||Eu(o)?null:r?{url:r.url,name:o,...r.branch?{branch:r.branch}:{}}:{url:n,name:o}}const dg={"github.com":e=>{if(e.length<2)return null;const[t,...n]=e.slice(2),r=t==="tree"?n.join("/"):t==="blob"||t==="commits"?n[0]:void 0;return{repo:e.slice(0,2),branch:r}},"gitlab.com":e=>{const t=e.indexOf("-");if(t<2)return e.length>=2&&t<0?{repo:e}:null;const[n,...r]=e.slice(t+1),o=n==="tree"?r.join("/"):n==="blob"||n==="commits"?r[0]:void 0;return{repo:e.slice(0,t),branch:o}},"codeberg.org":e=>{if(e.length<2)return null;const[t,n,...r]=e.slice(2),o=t==="src"&&n==="branch"?r[0]:void 0;return{repo:e.slice(0,2),branch:o}}};function WP(e){var o;if(!/^https?:\/\//i.test(e))return null;let t;try{t=new URL(e)}catch{return null}const n=(o=dg[t.hostname.toLowerCase()])==null?void 0:o.call(dg,t.pathname.split("/").filter(Boolean));if(!n)return null;const r=n.branch?KP(n.branch).replace(/\/+$/,""):"";return{url:`${t.protocol}//${t.host}/${n.repo.join("/")}`,...r?{branch:r}:{}}}function KP(e){try{return decodeURIComponent(e)}catch{return e}}function qP(e){var o;const t=((o=e.split(/[?#]/)[0])==null?void 0:o.replace(/\/+$/,""))??"";return((i_.test(t)?t.split(":")[1]??"":t).split("/").pop()??"").replace(/\.git$/i,"")}const ZP=Tr({component:Tn().nullable(),file:Tn().nullable(),line:Rs().nullable(),callFile:Tn().nullable().default(null),callLine:Rs().nullable().default(null),tag:Tn(),selector:Tn()}),GP=Tr({tag:Tn().max(40),id:Tn().max(200),classes:Sa(Tn().max(120)).max(16),text:Tn().max(200),attrs:Sa(JS([Tn().max(40),Tn().max(200)])).max(12)}),VP=JS([Rs(),Rs()]),YP=ZP.extend({classes:Tn(),text:Tn(),html:Tn(),route:Tn(),element:GP}),XP=eP("type",[Tr({type:Yr("loaded"),url:Tn(),title:Tn()}),Tr({type:Yr("navigated"),url:Tn(),title:Tn().optional()}),Tr({type:Yr("traversed"),dir:Rl(["back","forward"]).optional()}),Tr({type:Yr("title"),title:Tn()}),Tr({type:Yr("links"),links:Sa(Tr({path:Tn().max(2048),text:Tn().max(120)})).max(200)}),Tr({type:Yr("hmr")}),Tr({type:Yr("touch"),phase:Rl(["start","move","end","cancel"]),x:Rs(),y:Rs()}),Tr({type:Yr("page-error"),message:Tn(),source:Tn().optional(),line:Rs().optional()}),YP.extend({type:Yr("picked"),verb:Rl(["chat","code"]).default("chat"),site:Rl(["call","source"]).default("source")}),Tr({type:Yr("pick-cancel")}),Tr({type:Yr("highlight-miss"),path:Tn(),fileMatched:Rs(),withSource:Rs(),ranges:Sa(VP).nullable()}),Tr({type:Yr("drag-files"),over:Do().default(!0)}),Tr({type:Yr("drop-files"),files:Sa(bP(File))}),Tr({type:Yr("focus"),gesture:Do()}),Tr({type:Yr("key"),key:Tn(),code:Tn().optional(),meta:Do(),ctrl:Do().optional(),shift:Do().optional(),alt:Do().optional(),up:Do().optional()})]);function a_(e){const t=XP.safeParse(e);return t.success?t.data:null}const QP=["rows","repos","visits","themes"];function JP(e){return QP.map(t=>e[t]??"").join(".")}const eD=/["“”]([^"“”]*)["“”]?|(\S+)/g;function l_(e){const t=new Set;for(const n of e.matchAll(eD)){const r=(n[1]??n[2]??"").replace(/\s+/g," ").trim().toLowerCase();r&&t.add(r)}return[...t]}const tD="now",nD="http://preview.invalid",rD=200;function Xb(e){const t=e==null?void 0:e.replace(/\s+/g," ").trim().slice(0,rD).trim();return t||void 0}function Zh(e){let t;try{t=new URL(e,nD)}catch{return null}if(t.pathname.startsWith("/__toyon"))return null;const n=Qb(t.pathname)||"/",r=t.hash.startsWith("#/")?Qb(t.hash.split("?")[0]??""):"";return r.length>1?`${n}${r}`:n}const Qb=e=>e.replace(/\/+$/,""),oD={static:4,mixed:3.5,param:3,optional:2,"optional-static":2,splat:1},oh=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");function c_(e){const t=/^\[\[\.\.\.([^\]]*)\]\]$/.exec(e);if(t)return{kind:"splat",name:t[1]||"path",min:0};const n=/^\[\.\.\.([^\]]*)\]$/.exec(e);if(n)return{kind:"splat",name:n[1]||"path",min:1};const r=/^\[\[([^\]]+)\]\]$/.exec(e)??/^:([\w-]+)\?$/.exec(e)??/^\{-\$([\w-]+)\}$/.exec(e);if(r)return{kind:"optional",name:r[1]};const o=/^\[([^\]=]+)(?:=[^\]]*)?\]$/.exec(e)??/^:([\w-]+)$/.exec(e)??/^\$([\w-]+)$/.exec(e);if(o)return{kind:"param",name:o[1]};if(e==="*"||e==="$")return{kind:"splat",name:"path",min:0};if(/^[^[{:$*?]+\?$/.test(e))return{kind:"optional-static",text:e.slice(0,-1)};if(/[[{]/.test(e)){const s=[];let a="",c=0;for(const f of e.matchAll(/\[([^\]=]+)(?:=[^\]]*)?\]|\{\$([\w-]+)\}/g)){const h=e.slice(c,f.index);h&&(s.push({text:h}),a+=oh(h)),s.push({name:f[1]??f[2]??"param"}),a+="[^/]+?",c=(f.index??0)+f[0].length}const u=e.slice(c);if(u&&(s.push({text:u}),a+=oh(u)),s.some(f=>"name"in f))return{kind:"mixed",pattern:a,parts:s}}return{kind:"static",text:e}}function sD(e){const t=e.split("/").filter(Boolean).map(c_);if(t.every(r=>r.kind==="static"))return null;let n="";for(const r of t)r.kind==="static"?n+=`/${oh(r.text)}`:r.kind==="optional-static"?n+=`(?:/${oh(r.text)})?`:r.kind==="param"?n+="/[^/]+":r.kind==="optional"?n+="(?:/[^/]+)?":r.kind==="splat"?n+=r.min?"/.+":"(?:/.*)?":n+=`/${r.pattern}`;return{path:e,re:new RegExp(`^${n}$`),specificity:t.reduce((r,o)=>r+oD[o.kind],0),statics:t.filter(r=>r.kind==="static").length}}function iD(e,t){let n=null;for(const r of e)r.statics===0||!r.re.test(t)||(!n||r.specificity>n.specificity)&&(n=r);return n}function Gh(e){let t="";const n=[],r=o=>{n.push([t.length,t.length+o.length]),t+=o};for(const o of e.split("/").filter(Boolean).map(c_))if(t+="/",o.kind==="static"||o.kind==="optional-static")t+=o.text;else if(o.kind==="mixed")for(const s of o.parts)"name"in s?r(s.name):t+=s.text;else r(o.name);return t||(t="/"),{text:t,params:n,literal:n.length>0?t.slice(0,n[0][0]):t}}const Uu={id:"toyon-dark",family:"Toyon",name:"Toyon Dark",kind:"dark",source:"builtin",pair:"toyon-light",colors:{surface0:"#32302d",surface1:"#3d3835",surface2:"#504943",element0:"#504943",element1:"#675c55",border0:"#504943",border1:"#675c55",text0:"#e6dcb6",text1:"#9e927e",text2:"#6a6055",red:"#ff4929",orange:"#fa891e",yellow:"#fcbe03",green:"#78c945",aqua:"#4dc7a7",blue:"#69a9e8",purple:"#ca94ca",diffAdd:"#6fae5f29",diffDel:"#c07f6a29"},syntax:{comment:"#6a6055",keyword:"#df714e",string:"#a5bd4d",number:"#ca94ca",type:"#f5bf3a",function:"#6bc198",variable:"#81a99d"},link:"#83a9cf"},u_={id:"toyon-light",family:"Toyon",name:"Toyon Light",kind:"light",source:"builtin",pair:"toyon-dark",colors:{surface0:"#f8f2e8",surface1:"#efe8dc",surface2:"#dfd7c9",element0:"#dfd7c9",element1:"#c7bdac",border0:"#dfd7c9",border1:"#c7bdac",text0:"#463627",text1:"#6e5e51",text2:"#b4aa9f",red:"#b02e15",orange:"#b15b02",yellow:"#ac7e02",green:"#3c8c03",aqua:"#01775c",blue:"#12689e",purple:"#865889",diffAdd:"#4f7a3d2e",diffDel:"#9c5a452e"},syntax:{comment:"#b4aa9f",keyword:"#b54d2d",string:"#697f1e",number:"#865889",type:"#ac7e02",function:"#397f5f",variable:"#57796f"},link:"#3e6888"},aD={id:"gruvbox-dark-soft",family:"Gruvbox",name:"Gruvbox Dark Soft",kind:"dark",source:"builtin",pair:"gruvbox-light",colors:{surface0:"#32302f",surface1:"#3c3836",surface2:"#504945",element0:"#504945",element1:"#665c54",border0:"#504945",border1:"#665c54",text0:"#ebdbb2",text1:"#a89984",text2:"#928374",red:"#fb4934",orange:"#fe8019",yellow:"#fabd2f",green:"#b8bb26",aqua:"#8ec07c",blue:"#83a598",purple:"#d3869b",diffAdd:"#b8bb261f",diffDel:"#fb49341f"},syntax:{comment:"#928374",keyword:"#fb4934",string:"#b8bb26",number:"#d3869b",type:"#fabd2f",function:"#8ec07c",variable:"#83a598"}},lD={id:"gruvbox-light",family:"Gruvbox",name:"Gruvbox Light",kind:"light",source:"builtin",pair:"gruvbox-dark-soft",colors:{surface0:"#f4f2ee",surface1:"#ebe8e2",surface2:"#dcd8d0",element0:"#dcd8d0",element1:"#c3beb4",border0:"#dcd8d0",border1:"#c3beb4",text0:"#3c3836",text1:"#655f5a",text2:"#837c74",red:"#9d0006",orange:"#af3a03",yellow:"#b57614",green:"#79740e",aqua:"#427b58",blue:"#076678",purple:"#8f3f71",diffAdd:"#79740e26",diffDel:"#9d000626"},syntax:{comment:"#837c74",keyword:"#9d0006",string:"#79740e",number:"#8f3f71",type:"#b57614",function:"#427b58",variable:"#076678"}},cD={id:"vscode-dark-modern",family:"VS Code Modern",pair:"vscode-light-modern",name:"VS Code Dark Modern",kind:"dark",source:"builtin",colors:{surface0:"#1f1f1f",surface1:"#181818",surface2:"#2a2d2e",element0:"#2a2d2e",element1:"#2b2b2b",border0:"#2a2d2e",border1:"#2b2b2b",text0:"#cccccc",text1:"#9d9d9d",text2:"#6e7681",red:"#f85149",orange:"#0078d4",yellow:"#f5f543",green:"#23d18b",aqua:"#29b8db",blue:"#4daafc",purple:"#d670d6",diffAdd:"#23d18b1f",diffDel:"#f851491f"},syntax:{comment:"#6a9955",keyword:"#569cd6",string:"#ce9178",number:"#b5cea8",type:"#4ec9b0",function:"#dcdcaa",variable:"#9cdcfe"}},uD={id:"vscode-light-modern",family:"VS Code Modern",pair:"vscode-dark-modern",name:"VS Code Light Modern",kind:"light",source:"builtin",colors:{surface0:"#ffffff",surface1:"#f8f8f8",surface2:"#f2f2f2",element0:"#f2f2f2",element1:"#e5e5e5",border0:"#f2f2f2",border1:"#e5e5e5",text0:"#3b3b3b",text1:"#3b3b3b",text2:"#6e7681",red:"#f85149",orange:"#005fb8",yellow:"#949800",green:"#00bc00",aqua:"#0598bc",blue:"#005fb8",purple:"#bc05bc",diffAdd:"#00bc001f",diffDel:"#f851491f"},syntax:{comment:"#008000",keyword:"#0000ff",string:"#a31515",number:"#098658",type:"#267f99",function:"#795e26",variable:"#001080"}},dD={id:"vscode-2026-dark",family:"VS Code 2026",pair:"vscode-2026-light",name:"VS Code Dark 2026",kind:"dark",source:"builtin",colors:{surface0:"#121314",surface1:"#191a1b",surface2:"#2b2c2d",element0:"#2b2c2d",element1:"#2a2b2c",border0:"#2b2c2d",border1:"#2a2b2c",text0:"#bbbebf",text1:"#8c8c8c",text2:"#555555",red:"#f48771",orange:"#2d6e8a",yellow:"#e5ba7d",green:"#73c991",aqua:"#29b8db",blue:"#48a0c7",purple:"#d670d6",diffAdd:"#347d3926",diffDel:"#c93c3726"},syntax:{comment:"#8b949e",keyword:"#ff7b72",string:"#a5d6ff",number:"#b5cea8",type:"#4ec9b0",function:"#dcdcaa",variable:"#ffa657"}},fD={id:"vscode-2026-light",family:"VS Code 2026",pair:"vscode-2026-dark",name:"VS Code Light 2026",kind:"light",source:"builtin",colors:{surface0:"#ffffff",surface1:"#fafafd",surface2:"#e6e6e9",element0:"#e6e6e9",element1:"#f0f1f2",border0:"#e6e6e9",border1:"#f0f1f2",text0:"#202020",text1:"#606060",text2:"#bbbbbb",red:"#ad0707",orange:"#0069cc",yellow:"#667309",green:"#587c0c",aqua:"#0598bc",blue:"#0069cc",purple:"#bc05bc",diffAdd:"#587c0c26",diffDel:"#ad070726"},syntax:{comment:"#6e7781",keyword:"#cf222e",string:"#0a3069",number:"#098658",type:"#267f99",function:"#795e26",variable:"#953800"}},hD={id:"tokyo-night",family:"Tokyo Night",name:"Tokyo Night",kind:"dark",source:"builtin",pair:"tokyo-night-light",colors:{surface0:"#1a1b26",surface1:"#16161e",surface2:"#13131a",element0:"#13131a",element1:"#101014",border0:"#13131a",border1:"#101014",text0:"#a9b1d6",text1:"#515670",text2:"#545c7e",red:"#f7768e",orange:"#3d59a1",yellow:"#e0af68",green:"#73daca",aqua:"#7dcfff",blue:"#7aa2f7",purple:"#bb9af7",diffAdd:"#41a6b520",diffDel:"#db4b4b22"},syntax:{comment:"#51597d",keyword:"#bb9af7",string:"#9ece6a",number:"#ff9e64",type:"#0db9d7",function:"#0db9d7",variable:"#c0caf5"}},pD={id:"tokyo-night-light",family:"Tokyo Night",name:"Tokyo Night Light",kind:"light",source:"builtin",pair:"tokyo-night",colors:{surface0:"#e6e7ed",surface1:"#d6d8df",surface2:"#e1e2e8",element0:"#e1e2e8",element1:"#c1c2c7",border0:"#e1e2e8",border1:"#c1c2c7",text0:"#343b59",text1:"#707280",text2:"#707280",red:"#8c4351",orange:"#2959aa",yellow:"#8f5e15",green:"#33635c",aqua:"#006c86",blue:"#2959aa",purple:"#7b43ba",diffAdd:"#2d9c9120",diffDel:"#e8686812"},syntax:{comment:"#888b94",keyword:"#65359d",string:"#385f0d",number:"#965027",type:"#006c86",function:"#006c86",variable:"#343b58"}},mD={id:"rose-pine",family:"Rosé Pine",name:"Rosé Pine",kind:"dark",source:"builtin",pair:"rose-pine-dawn",colors:{surface0:"#191724",surface1:"#191724",surface2:"#221f2e",element0:"#221f2e",element1:"#191724",border0:"#221f2e",border1:"#191724",text0:"#e0def4",text1:"#908caa",text2:"#908caa",red:"#eb6f92",orange:"#ebbcba",yellow:"#f6c177",green:"#31748f",aqua:"#ebbcba",blue:"#9ccfd8",purple:"#c4a7e7",diffAdd:"#9ccfd826",diffDel:"#eb6f9226"},syntax:{comment:"#6e6a86",keyword:"#31748f",string:"#f6c177",number:"#ebbcba",type:"#9ccfd8",function:"#eb6f92",variable:"#ebbcba"}},gD={id:"rose-pine-dawn",family:"Rosé Pine",name:"Rosé Pine Dawn",kind:"light",source:"builtin",pair:"rose-pine",colors:{surface0:"#faf4ed",surface1:"#faf4ed",surface2:"#f3ede8",element0:"#f3ede8",element1:"#faf4ed",border0:"#f3ede8",border1:"#faf4ed",text0:"#575279",text1:"#797593",text2:"#797593",red:"#b4637a",orange:"#d7827e",yellow:"#ea9d34",green:"#286983",aqua:"#d7827e",blue:"#56949f",purple:"#907aa9",diffAdd:"#56949f26",diffDel:"#b4637a26"},syntax:{comment:"#9893a5",keyword:"#286983",string:"#ea9d34",number:"#d7827e",type:"#56949f",function:"#b4637a",variable:"#d7827e"}},kD={id:"one-dark-pro",family:"One Dark Pro",name:"One Dark Pro",kind:"dark",source:"builtin",pair:"one-light",colors:{surface0:"#282c34",surface1:"#21252b",surface2:"#2c313a",element0:"#2c313a",element1:"#3e4452",border0:"#2c313a",border1:"#3e4452",text0:"#abb2bf",text1:"#abb2bf",text2:"#495162",red:"#e05561",orange:"#4d78cc",yellow:"#d18f52",green:"#8cc265",aqua:"#42b3c2",blue:"#4aa5f0",purple:"#c162de",diffAdd:"#00809b33",diffDel:"#e055611f"},syntax:{comment:"#7f848e",keyword:"#c678dd",string:"#98c379",number:"#d19a66",type:"#e5c07b",function:"#56b6c2",variable:"#e06c75"}},wD={id:"one-light",family:"One Dark Pro",name:"One Light",kind:"light",source:"builtin",pair:"one-dark-pro",colors:{surface0:"#fafafa",surface1:"#eaeaeb",surface2:"#e4e4e5",element0:"#e4e4e5",element1:"#e5e5e6",border0:"#e4e4e5",border1:"#e5e5e6",text0:"#383a42",text1:"#3b3b3b",text2:"#9d9d9f",red:"#cd3131",orange:"#526fff",yellow:"#949800",green:"#00bc00",aqua:"#0598bc",blue:"#0451a5",purple:"#bc05bc",diffAdd:"#00809b33",diffDel:"#cd31311f"},syntax:{comment:"#a0a1a7",keyword:"#a626a4",string:"#50a14f",number:"#986801",type:"#0184bc",function:"#0184bc",variable:"#e45649"}},yD={id:"solarized-dark",family:"Solarized",name:"Solarized Dark",kind:"dark",source:"builtin",pair:"solarized-light",colors:{surface0:"#002b36",surface1:"#00212b",surface2:"#003846",element0:"#003846",element1:"#2b2b4a",border0:"#003846",border1:"#2b2b4a",text0:"#839496",text1:"#93a1a1",text2:"#4a6166",red:"#dc322f",orange:"#197271",yellow:"#b58900",green:"#859900",aqua:"#2aa198",blue:"#268bd2",purple:"#d33682",diffAdd:"#8599001f",diffDel:"#dc322f1f"},syntax:{comment:"#586e75",keyword:"#859900",string:"#2aa198",number:"#d33682",type:"#859900",function:"#268bd2",variable:"#268bd2"}},vD={id:"solarized-light",family:"Solarized",name:"Solarized Light",kind:"light",source:"builtin",pair:"solarized-dark",colors:{surface0:"#fdf6e3",surface1:"#eee8d5",surface2:"#eae0c0",element0:"#eae0c0",element1:"#ddd6c1",border0:"#eae0c0",border1:"#ddd6c1",text0:"#657b83",text1:"#586e75",text2:"#a3aba5",red:"#dc322f",orange:"#b58900",yellow:"#b58900",green:"#859900",aqua:"#2aa198",blue:"#268bd2",purple:"#d33682",diffAdd:"#8599001f",diffDel:"#dc322f1f"},syntax:{comment:"#93a1a1",keyword:"#859900",string:"#2aa198",number:"#d33682",type:"#859900",function:"#268bd2",variable:"#268bd2"}},bD={id:"nord",family:"Nord",name:"Nord",kind:"dark",source:"builtin",colors:{surface0:"#2e3440",surface1:"#2e3440",surface2:"#3b4252",element0:"#3b4252",element1:"#3b4252",border0:"#3b4252",border1:"#3b4252",text0:"#d8dee9",text1:"#c7cdd8",text2:"#4c566a",red:"#bf616a",orange:"#88c0d0",yellow:"#ebcb8b",green:"#a3be8c",aqua:"#88c0d0",blue:"#81a1c1",purple:"#b48ead",diffAdd:"#81a1c133",diffDel:"#bf616a4d"},syntax:{comment:"#616e88",keyword:"#81a1c1",string:"#a3be8c",number:"#b48ead",type:"#8fbcbb",function:"#88c0d0",variable:"#d8dee9"}},xD={id:"catppuccin-mocha",family:"Catppuccin",name:"Catppuccin Mocha",kind:"dark",source:"builtin",pair:"catppuccin-latte",colors:{surface0:"#1e1e2e",surface1:"#181825",surface2:"#313244",element0:"#313244",element1:"#45475a",border0:"#313244",border1:"#45475a",text0:"#cdd6f4",text1:"#a6adc8",text2:"#7f849c",red:"#f38ba8",orange:"#fab387",yellow:"#f9e2af",green:"#a6e3a1",aqua:"#94e2d5",blue:"#89b4fa",purple:"#cba6f7",diffAdd:"#a6e3a11f",diffDel:"#f38ba81f"},syntax:{comment:"#9399b2",keyword:"#cba6f7",string:"#a6e3a1",number:"#fab387",type:"#f9e2af",function:"#89b4fa",variable:"#cdd6f4"}},ED={id:"catppuccin-latte",family:"Catppuccin",name:"Catppuccin Latte",kind:"light",source:"builtin",pair:"catppuccin-mocha",colors:{surface0:"#eff1f5",surface1:"#e6e9ef",surface2:"#ccd0da",element0:"#ccd0da",element1:"#bcc0cc",border0:"#ccd0da",border1:"#bcc0cc",text0:"#4c4f69",text1:"#6c6f85",text2:"#8c8fa1",red:"#d20f39",orange:"#fe640b",yellow:"#df8e1d",green:"#40a02b",aqua:"#179299",blue:"#1e66f5",purple:"#8839ef",diffAdd:"#40a02b1f",diffDel:"#d20f391f"},syntax:{comment:"#7c7f93",keyword:"#8839ef",string:"#40a02b",number:"#fe640b",type:"#df8e1d",function:"#1e66f5",variable:"#4c4f69"}},SD=[hD,pD,mD,gD,kD,wD,yD,vD,bD,xD,ED],Ff=[Uu,u_,aD,lD,cD,uD,dD,fD,...SD],_D={mode:"dark",light:u_.id,dark:Uu.id},ND=["surface0","surface1","surface2","element0","element1","border0","border1","text0","text1","text2","red","orange","yellow","green","aqua","blue","purple","diffAdd","diffDel"];function jD(e){return`--${e.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`)}`}function tk(e){return d_(_a(e))}function d_(e){return e>.008856?116*e**(1/3)-16:903.3*e}function Tw(e,t){const n=tk(e)+t,r=Ia(e);if(!r)return e;let o=0,s=2;for(let a=0;a<24;a++){const c=(o+s)/2,u=Vl(Math.min(255,r[0]*c),Math.min(255,r[1]*c),Math.min(255,r[2]*c));tk(u)<n?o=c:s=c}return Vl(Math.min(255,r[0]*o),Math.min(255,r[1]*o),Math.min(255,r[2]*o))}function TD(e){return Tw(e.colors.surface1,-4)}function $D(e){return Tw(e.colors.surface0,-4)}const Jb=["surface0","surface1","surface2","element0","element1","border0","border1"];function CD(e){if(e.kind!=="dark")return e;const t=Jb.reduce((o,s)=>_a(e.colors[s])<_a(e.colors[o])?s:o),n=e.colors[t];if(_a(n)<=0)return e;const r={...e.colors};for(const o of[...Jb,"text1","text2"]){const s=BD(e.colors[o],n)*.05-.05;r[o]=Tw(r[o],d_(s)-tk(r[o]))}return r.surface0="#000000",r.surface1="#000000",{...e,colors:r}}function ex(e){return FD(e,.55)}function ID(e){const t=e.colors,n=e.syntax??{};return{comment:n.comment??t.text2,keyword:n.keyword??t.orange,string:n.string??t.green,number:n.number??t.purple,type:n.type??t.yellow,function:n.function??t.aqua,variable:n.variable??t.blue}}function AD(e){const t={};for(const n of ND)t[jD(n)]=e.colors[n];t["--ink0"]=e.colors.text0,t["--ink1"]=e.colors.text1,t["--ink2"]=e.colors.text2;for(const[n,r]of Object.entries(ID(e)))t[`--syntax-${n}`]=r;return t["--accent"]=$w(e),t["--fault"]=RD(e),t["--link"]=OD(e),t["--sunken"]=TD(e),t["--sunken-floor"]=$D(e),t["--scrim"]=zD(e.colors.surface0,.7),t["--shadow"]=e.kind==="dark"?"#00000066":"#0000002e",t["--diff-add-word"]=ex(e.colors.diffAdd),t["--diff-del-word"]=ex(e.colors.diffDel),t}function $w(e){return Iw(e.accent??"")??e.colors.orange}function RD(e){return $w(e)===Iw(e.colors.orange)?e.colors.red:e.colors.orange}function OD(e){return Iw(e.link??"")??e.colors.blue}function MD(e){return e==="system"||e==="daylight"}function Cw(e,t){return e.mode==="system"?t.system?"dark":"light":e.mode==="daylight"?t.daylight?"dark":"light":e.mode}function Vh(e,t,n){const r=Cw(e,n);return t.find(o=>o.id===e[r])??Ff.find(o=>o.kind===r)??Uu}function LD(e,t){if(e.pair){const a=t.find(c=>c.id===e.pair);if(a&&a.kind!==e.kind)return a}const n=e.kind==="dark"?"light":"dark",r=a=>a.toLowerCase().replace(/\b(dark|light)\b/g,"*").replace(/\s+/g," ").trim(),o=r(e.name);if(!o.includes("*"))return null;const s=e.id.startsWith("vscode:")?e.id.slice(0,e.id.lastIndexOf(":")+1):null;return t.find(a=>a.kind===n&&a.source===e.source&&(!s||a.id.startsWith(s))&&r(a.name)===o)??null}function PD(e){const t=[],n=new Set,r=o=>o.family??(o.name.replace(/\b(dark|light)\b/gi,"").replace(/\s+/g," ").trim()||o.name);for(const o of e){if(n.has(o.id))continue;const s=LD(o,e),a={name:r(o)};a[o.kind]=o,n.add(o.id),s&&(a[s.kind]=s,n.add(s.id)),t.push(a)}return t}function DD(e,t){const n={...e};return t.dark&&(n.dark=t.dark.id),t.light&&(n.light=t.light.id),!MD(n.mode)&&!t[n.mode]&&(n.mode=t.dark?"dark":"light"),n}function Ia(e){const t=/^#([0-9a-f]{3,8})$/i.exec(e.trim());if(!t)return null;let n=t[1];if((n.length===3||n.length===4)&&(n=[...n].map(o=>o+o).join("")),n.length!==6&&n.length!==8)return null;const r=o=>parseInt(n.slice(o,o+2),16);return[r(0),r(2),r(4),n.length===8?r(6)/255:1]}function Iw(e){const t=Ia(e);return t?Vl(t[0],t[1],t[2],t[3]):null}function Vl(e,t,n,r=1){const o=s=>Math.round(Math.max(0,Math.min(255,s))).toString(16).padStart(2,"0");return`#${o(e)}${o(t)}${o(n)}${r>=1?"":o(r*255)}`}function zD(e,t){const n=Ia(e);return n?Vl(n[0],n[1],n[2],t):e}function FD(e,t){const n=Ia(e);return n?Vl(n[0],n[1],n[2],Math.min(1,n[3]*t)):e}function WY(e,t){const n=Ia(e),r=Ia(t);if(!n||!r)return e;const o=n[3];return Vl(n[0]*o+r[0]*(1-o),n[1]*o+r[1]*(1-o),n[2]*o+r[2]*(1-o))}function _a(e){const t=Ia(e);if(!t)return 0;const n=r=>{const o=r/255;return o<=.03928?o/12.92:((o+.055)/1.055)**2.4};return .2126*n(t[0])+.7152*n(t[1])+.0722*n(t[2])}function BD(e,t){const n=_a(e),r=_a(t);return(Math.max(n,r)+.05)/(Math.min(n,r)+.05)}function UD(e){return _a(e)>.179?"#1d2021":"#fbf1c7"}function nk(e){if(e===null||e==="")return"the npm registry";try{return new URL(e).host}catch{return e}}function f_(e,t){const n=tx(e),r=tx(t);if(!n||!r)return!1;for(let o=0;o<3;o++){const s=n.nums[o]??0,a=r.nums[o]??0;if(s!==a)return s>a}return n.pre===r.pre?!1:n.pre===null?!0:r.pre===null?!1:n.pre>r.pre}function tx(e){const t=/^(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?$/.exec(e.trim());return t?{nums:[Number(t[1]),Number(t[2]),Number(t[3])],pre:t[4]??null}:null}const HD=[[/\.(png|jpe?g|gif|webp|avif|bmp|ico)$/i,"image"],[/\.(mp4|m4v|webm|mov)$/i,"video"]];function WD(e){var t;return((t=HD.find(([n])=>n.test(e)))==null?void 0:t[1])??null}const KD=[[/\.(md|markdown)$/i,"markdown"],[/\.html?$/i,"html"],[/\.svg$/i,"svg"]];function Yh(e){var t;return((t=KD.find(([n])=>n.test(e)))==null?void 0:t[1])??null}const tt={active:"toyon-active",phoneRow:"toyon-phone-row",repo:"toyon-repo",lastActive:"toyon-last",discoveredOpen:"toyon-disc",archivedOpen:"toyon-arch",committedShut:"toyon-committed-shut",turnOpen:"toyon-turn-open",treeOpen:"toyon-tree",token:"toyon-token",theme:"toyon-theme",daylight:"toyon-sun",changesWidth:"toyon-changes-w",chatWidth:"toyon-chat-w",editorHeight:"toyon-dh",editorFull:"toyon-dfull",editorWrap:"toyon-dwrap",editorSplit:"toyon-dsplit",designHeight:"toyon-dsh",designFull:"toyon-dsfull",termHeight:"toyon-th",rail:"toyon-rail",railWidth:"toyon-rail-w",chatSide:"toyon-chat-side",clipboardOffer:"toyon-clipboard-offer",blackGround:"toyon-black",installOffered:"toyon-install-offered",layouts:"toyon-layouts",client:"toyon-client",ground:"toyon-ground",version:"toyon-version"},qD=[tt.active,tt.repo,tt.lastActive,tt.discoveredOpen,tt.archivedOpen,tt.committedShut,tt.turnOpen,tt.treeOpen,tt.phoneRow,tt.version],Bf=(e,t)=>`${e}@${t}`,ZD="toyon",Vc="snapshots",co={hello:e=>`hello@${e}`,chat:(e,t)=>`chat@${e}/${t}`,chats:e=>`chat@${e}/`};function GD(e,t=typeof localStorage>"u"?null:localStorage,n=typeof sessionStorage>"u"?null:sessionStorage){const r=a=>({get(c){try{return(a==null?void 0:a.getItem(Bf(c,e)))??null}catch{return null}},set(c,u){try{a==null||a.setItem(Bf(c,e),u)}catch{}},remove(c){try{a==null||a.removeItem(Bf(c,e))}catch{}}}),o=r(t),s=r(n);return{...o,session:{get:s.get,set:s.set},clear(){for(const a of[t,n])for(const c of rk(a).filter(u=>u.endsWith(`@${e}`)))try{a==null||a.removeItem(c)}catch{}}}}function rk(e){const t=[];try{for(let n=0;n<((e==null?void 0:e.length)??0);n++){const r=e==null?void 0:e.key(n);r!=null&&t.push(r)}}catch{}return t}const VD="orch-";function YD(e,t=typeof localStorage>"u"?null:localStorage,n=typeof sessionStorage>"u"?null:sessionStorage){for(const[r,o]of[[t,["active","token","theme","editorHeight","editorFull"]],[n,["client"]]])for(const s of o){const a=tt[s],c=VD+a.slice(6);nx(r,c,a)}for(const[r,o]of[[t,qD.filter(s=>s!==tt.phoneRow)],[n,[tt.phoneRow]]]){const s=rk(r).filter(a=>!a.includes("@"));for(const a of o)for(const c of s.filter(u=>u===a))nx(r,c,Bf(c,e))}for(const r of rk(t))XD.some(o=>r.startsWith(o))&&QD(t,r)}const XD=["toyon-profile-","toyon-mode-","toyon-model-","toyon-effort-","toyon-mono-face"];function QD(e,t){try{e==null||e.removeItem(t)}catch{}}function nx(e,t,n){try{const r=e==null?void 0:e.getItem(t);if(r==null)return;(e==null?void 0:e.getItem(n))===null&&e.setItem(n,r),e==null||e.removeItem(t)}catch{}}function h_(){const e=location.hash.match(/token=([a-f0-9]+)/);if(e!=null&&e[1])return p_(e[1]),e[1];try{return localStorage.getItem(tt.token)??sessionStorage.getItem(tt.token)??""}catch{return""}}function p_(e){try{localStorage.setItem(tt.token,e)}catch{}}function sh(){return h_()!==""}function Aw(e,t){const n=new URL(e),r=`token=${t}`,o=s=>`&v=${encodeURIComponent(s??"")}`;return{origin:n.origin,host:n.hostname,token:t,ws:`${n.protocol==="https:"?"wss":"ws"}://${n.host}/ws?${r}`,attachment:(s,a)=>`${n.origin}/attachments/${s}/${a}?${r}`,attachmentWhere:(s,a)=>`${n.origin}/attachments/${s}/${a}?${r}&where`,upload:s=>`${n.origin}/uploads/${s}?${r}`,worktreeFile:(s,a,c)=>`${n.origin}/files/${s}/${a.split("/").map(encodeURIComponent).join("/")}?${r}${o(c)}`,loose:(s,a)=>`${n.origin}/loose/${encodeURIComponent(s)}?${r}${o(a)}`,health:`${n.origin}/health`,restart:s=>`${n.origin}/restart?${r}${s?`&${tD}`:""}`,uploads:s=>`${n.origin}/uploads?kind=${s}`,tailnet:`${n.origin}/tailnet`,remote:`${n.origin}/remote`,tailscale:`${n.origin}/tailscale`,machines:`${n.origin}/machines`,knockAnswer:s=>`${n.origin}/knock/${s}/answer`,previewGrant:`${n.origin}/preview-grant`,frame:`${n.origin}/frame`,changelog:`${n.origin}/changelog`}}const La=e=>({authorization:`Bearer ${e.token}`});async function JD(e,t,n,r){try{await n.slice(0,1).arrayBuffer()}catch{return"could not be read"}return new Promise(o=>{const s=new XMLHttpRequest;s.open("POST",e.uploads(t)),s.setRequestHeader("authorization",La(e).authorization),s.setRequestHeader("content-type",n.type||"application/octet-stream"),r&&(s.upload.onprogress=a=>a.lengthComputable&&r(a.loaded/a.total)),s.onload=()=>{if(s.status>=502&&s.status<=504)return o(null);if(s.status<200||s.status>=300)return o(s.responseText||"could not be attached");try{o(JSON.parse(s.responseText))}catch{o("could not be attached")}},s.onerror=()=>o(null),s.onabort=()=>o(null),s.send(n)})}async function e4(e,t=!1){try{const n=await fetch(e.restart(t),{method:"POST"});return n.ok?null:await n.text()||"Toyon did not restart"}catch{return null}}async function m_(e){try{const t=await fetch(e.restart(!1),{signal:AbortSignal.timeout(2e3)});if(!t.ok)return null;const{waiting:n,asking:r}=await t.json();return Array.isArray(n)?{waiting:n,asking:Array.isArray(r)?r:[]}:null}catch{return null}}async function t4(e){var t;try{const n=await fetch(e.changelog,{headers:La(e)});return!n.ok||!((t=n.headers.get("content-type"))!=null&&t.startsWith("text/markdown"))?null:await n.text()}catch{return null}}async function n4(e,t){try{const n=await fetch(t,{headers:La(e)});return n.ok?await n.json():null}catch{return null}}async function Xh(e,t,n,r){try{const o=await fetch(t,{method:"POST",headers:{...La(e),"content-type":"application/json"},body:JSON.stringify(n)});return o.ok?null:await o.text()||`refused (${o.status})`}catch{return r}}const r4=e=>n4(e,e.tailnet),o4=e=>Xh(e,e.remote,{tailscale:!0},"Toyon is not answering; try again once it is back."),s4=e=>Xh(e,e.remote,{off:!0},"Toyon is not answering; try again once it is back.");async function g_(e,t,n){try{const r=await fetch(t,{method:"POST",headers:{...La(e),"content-type":"application/json"},body:JSON.stringify(n)});return r.ok?await r.json():null}catch{return null}}const k_="Toyon is not answering; try again once it is back.",i4=async e=>{const t=await g_(e,e.tailscale,{up:!0});return t===null?k_:t.refused},a4=async e=>await g_(e,e.tailscale,{login:!0})??{why:k_},l4=(e,t,n)=>Xh(e,e.machines,{origin:t,token:n},"Toyon here is not answering; the machine is not listed yet."),c4=(e,t,n)=>Xh(e,e.knockAnswer(t),{letIn:n},"Toyon is not answering");async function w_(e){try{const t=await fetch(e.previewGrant,{method:"POST",headers:La(e)});return t.ok?await t.json():null}catch{return null}}async function u4(e,t){try{const n=await fetch(e.frame,{method:"POST",headers:{...La(e),"content-type":"application/json"},body:JSON.stringify(t)});return n.ok?await n.json():n.status===400||n.status===503?await n.text():null}catch{return null}}const d4=2e3;async function y_(e,t,n){let r;try{const o=await fetch(`${e}/knock`,{method:"POST",signal:t});if(o.status===429)return"full";if(!o.ok)return"not-toyon";r=await o.json()}catch{return t.aborted?"gone":"unreachable"}if(typeof r.id!="string"||typeof r.word!="string")return"not-toyon";for(n(r.word);!t.aborted;){try{const o=await fetch(`${e}/knock/${r.id}`,{cache:"no-store",signal:t});if(o.status===404)return"gone";if(o.ok){const s=await o.json();if(s.state==="let-in"&&typeof s.token=="string"&&s.token)return{token:s.token};if(s.state==="refused")return"refused"}}catch{}await new Promise(o=>setTimeout(o,d4))}return"gone"}async function ok(e){try{const t=await fetch(e.health,{signal:AbortSignal.timeout(2e3)});return t.ok?(await t.json()).pid??null:null}catch{return null}}const f4=1e3,h4=3e4,p4=1500,m4=5e3,rx=50,g4=e=>e.t==="chat"||e.t==="create-worktree"||e.t==="restore-worktree";class k4{constructor(t,n,r,o={},s={}){jt(this,"ws",null);jt(this,"queue",[]);jt(this,"closed",!1);jt(this,"attempt",0);jt(this,"timer",null);jt(this,"downAt",null);jt(this,"downCode",0);jt(this,"sayTimer",null);jt(this,"sentDown",new Set);jt(this,"drops",0);jt(this,"urls");jt(this,"suspended",!1);jt(this,"connectDeadline");jt(this,"settle");jt(this,"backoffMin");jt(this,"wake",()=>{var n;if(this.closed||this.suspended||document.visibilityState!=="visible"||((n=this.ws)==null?void 0:n.readyState)===WebSocket.OPEN)return;this.timer&&clearTimeout(this.timer),this.timer=null,this.attempt=0,this.drops=0,this.downAt!==null&&(this.downAt=Date.now(),this.onStatus(!1,null),this.armSay());const t=this.ws;this.connect(),t==null||t.close()});this.onMsg=n,this.onStatus=r,this.hooks=s,this.connectDeadline=o.connectDeadline??m4,this.settle=o.settle??p4,this.backoffMin=o.backoffMin??f4,this.urls=Aw(t.origin,t.token),this.suspended=s.held??!1,this.connect(),document.addEventListener("visibilitychange",this.wake),window.addEventListener("online",this.wake)}suspend(){if(this.suspended||this.closed)return;this.suspended=!0,this.timer&&clearTimeout(this.timer),this.timer=null;const t=this.ws;this.ws=null,t==null||t.close(),this.onStatus(!1,null)}resume(){!this.suspended||this.closed||(this.suspended=!1,this.attempt=0,this.connect())}async diagnose(t){if(t===qA)return"unauthorized";if(this.drops<2)return null;try{return(await fetch(this.urls.health,{signal:AbortSignal.timeout(2e3)})).ok?"blocked":"down"}catch{return"down"}}say(t){this.downAt??(this.downAt=Date.now()),this.downCode=t,this.armSay()}armSay(){if(this.downAt===null)return;const t=this.downAt,n=()=>!this.closed&&this.downAt===t&&document.visibilityState==="visible";this.sayTimer&&clearTimeout(this.sayTimer),this.sayTimer=setTimeout(()=>{n()&&this.diagnose(this.downCode).then(r=>{n()&&this.onStatus(!1,r)})},Math.max(0,t+this.settle-Date.now()))}connect(){var s,a;if(this.closed||this.suspended)return;const t=((a=(s=this.hooks).known)==null?void 0:a.call(s))??null,n=new WebSocket(t===null?this.urls.ws:`${this.urls.ws}&known=${t}`);this.ws=n;let r=!1;const o=setTimeout(()=>{n.readyState===WebSocket.CONNECTING&&n.close()},this.connectDeadline);n.onmessage=c=>{if(!r){r=!0,clearTimeout(o),this.attempt=0,this.drops=0,this.downAt=null,this.sayTimer&&clearTimeout(this.sayTimer),this.sayTimer=null,this.onStatus(!0);for(const u of this.queue)n.send(u.raw);this.queue=[]}try{this.onMsg(JSON.parse(c.data))}catch{}},n.onclose=c=>{if(clearTimeout(o),this.ws!==n||(this.onStatus(!1),this.closed||this.suspended))return;this.drops++,this.say(c.code);const u=Math.min(h4,this.backoffMin*2**this.attempt++);this.timer=setTimeout(()=>this.connect(),u/2+Math.random()*(u/2))},n.onerror=()=>n.close()}send(t){const n=JSON.stringify(t);if(this.ws&&this.ws.readyState===WebSocket.OPEN){this.ws.send(n);return}if(t.t.startsWith("term-"))return;const r=t.t==="subscribe"||t.t==="unsubscribe"?`sub:${t.worktreeId}`:t.t==="view"?"view":null;r&&(this.queue=this.queue.filter(o=>o.key!==r)),g4(t)&&t.boxId&&this.sentDown.add(t.boxId),this.queue.push({key:r,raw:n}),this.queue.length>rx&&this.queue.splice(0,this.queue.length-rx)}sentWhileDown(){const t=[...this.sentDown];return this.sentDown.clear(),t}dispose(){var t;this.closed=!0,this.timer&&clearTimeout(this.timer),this.sayTimer&&clearTimeout(this.sayTimer),document.removeEventListener("visibilitychange",this.wake),window.removeEventListener("online",this.wake),(t=this.ws)==null||t.close()}}function Rw(e){return e==="cancelled"||e==="expired"}function v_(e){const t=e.findLast(n=>n.kind==="ask"||Hu(n));return(t==null?void 0:t.kind)!=="ask"||t.ask.kind!=="question"?null:Rw(t.outcome)?t:null}function w4(e){if(e.ask.kind==="permission")return e.ask.title;const t=e.ask.questions.map(n=>n.header).filter(n=>!!n);return t.length>0?t.join(", "):e.ask.message}function y4(e){return e.map(()=>({selected:[]}))}function ox(e,t,n,r){return e.map((o,s)=>{if(s!==t)return o;const a=o.selected.includes(n);return r?{...o,selected:a?o.selected.filter(c=>c!==n):[...o.selected,n]}:{...o,selected:[n]}})}function ih(e,t,n){return e.map((r,o)=>{if(o!==t)return r;const{note:s,...a}=r;return n===void 0?a:{...a,note:n}})}function sx(e,t,n,r){return e.map((o,s)=>s!==t?o:{selected:n&&!r?[]:o.selected,note:o.note??""})}function ou(e,t){const n=e[t];return n&&n.note!==void 0&&!n.note.trim()?ih(e,t,void 0):e}function v4(e){return e?e.options.length+(e.note?1:0):0}function ix(e,t){return!!(e!=null&&e.note)&&t===e.options.length}function b_(e,t){return!!e&&e.note!==void 0&&(t||e.selected.length===0)}function Na(e){var t;return!!e&&(e.selected.length>0||!!((t=e.note)!=null&&t.trim()))}function b4(e,t){return!!(e!=null&&e.multi)&&Na(t)}function fg(e,t){return e.every((n,r)=>!n.required||Na(t[r]))}function x_(e,t){var o;const n=((t==null?void 0:t.selected)??[]).map(s=>{var a;return Mw(((a=e.options.find(c=>c.value===s))==null?void 0:a.label)??s)}),r=(o=t==null?void 0:t.note)==null?void 0:o.trim();return n.length===0?r||"skipped":r?`${n.join(", ")}: ${r}`:n.join(", ")}function E_(e,t){var o;const n=((t==null?void 0:t.selected)??[]).map(s=>{var a;return Mw(((a=e.options.find(c=>c.value===s))==null?void 0:a.label)??s)}),r=((o=t==null?void 0:t.note)==null?void 0:o.trim())||void 0;return n.length>0?r?{pick:n.join(", "),note:r}:{pick:n.join(", ")}:r&&e.note?{pick:e.note.label,note:r}:{pick:r??"skipped"}}function Ow(e,t){return e.map((n,r)=>sk(e,n,x_(n,t==null?void 0:t[r])))}function sk(e,t,n){return e.length>1&&t.header?`${t.header} · ${n}`:n}function x4(e,t){return e.map((n,r)=>{const o=t==null?void 0:t[r],s=E4(n,o);if(s.length===0)return{pick:sk(e,n,x_(n,o)),descriptions:s};const a=E_(n,o);return{pick:sk(e,n,a.pick),descriptions:s,note:a.note}})}function E4(e,t){return((t==null?void 0:t.selected)??[]).map(n=>{var r,o;return((o=(r=e.options.find(s=>s.value===n))==null?void 0:r.description)==null?void 0:o.trim())??""}).filter(Boolean)}function S4(e){return e.outcome!=="answered"||e.ask.kind!=="question"?null:{message:e.ask.message,questions:e.ask.questions,answers:e.answers}}function _4(e){if(e.outcome!=="answered")return null;const t=(e.answers??[]).map(n=>{var r;return((r=n.note)==null?void 0:r.trim())??""}).filter(Boolean);return t.length>0?t.join(`
102
- `):null}function N4(e){if(e.outcome!=="answered"||e.ask.kind!=="permission"||e.toolId)return null;const t=e.ask.choices.find(r=>r.id===e.choiceId);if(!t)return null;const n=e.ask.plan??null;return{file:n,text:n?"":e.ask.detail??"",choice:t.name}}function Ol(e,t){if(!e)return 0;if(b_(t,!!e.multi)&&e.note)return e.options.length;const n=t!=null&&t.selected[0]?e.options.findIndex(r=>r.value===t.selected[0]):-1;return n===-1?0:n}function j4(e,t,n){return Math.max(0,Math.min(n-1,e+t))}function T4(e,t,n){const r=e.length;for(let o=1;o<=r;o++){const s=(n+o)%r;if(!Na(t[s]))return s}return-1}function Ml(e){return e.length>1?e.length:-1}function $4(e){return e.length+(Ml(e)===-1?0:1)}function C4(e,t,n){const r=T4(e,t,n);if(r!==-1)return{current:r,cursor:Ol(e[r],t[r]),send:!1};const o=Ml(e);return o!==-1?{current:o,cursor:0,send:!1}:{current:n,cursor:Ol(e[n],t[n]),send:!0}}const S_=/\s*\(recommended\)\s*$/i;function I4(e){return S_.test(e)}function Mw(e){return e.replace(S_,"")}const A4={skipped:"you skipped this",cancelled:"the turn was stopped before you answered",expired:"Toyon restarted before you answered"};function R4(e,t){const n=t??0;return n===0?null:`${n} behind ${e}`}function Qh(e){const t=new Date(e);return`${String(t.getHours()).padStart(2,"0")}:${String(t.getMinutes()).padStart(2,"0")}`}function __(e,t){if(t.fetchFailed)return`could not reach origin${t.fetchedAt?` since ${Qh(t.fetchedAt)}`:""}: ${t.fetchFailed}`;const n=t.behind??0;return n===0?null:t.stale==="diverged"?`${e} has diverged from origin`:t.stale==="dirty"&&t.dirty>0?`${n} behind origin; an uncommitted file on ${e} is in the pull's way`:`${n} behind origin`}function O4(e){return e.stale!=="diverged"}function Yl(e,t){return`main has ${e} uncommitted ${e===1?"file":"files"}; ${t} runs on them too`}function N_(e,t,n,r){return n!==null&&r===n.host?`${KA(n.previews,e,t)}/`:r.endsWith(".localhost")?`http://w${e}.${r}:${t}/`:Ph(r)?`http://${r==="localhost"?"127.0.0.1":r}:${t}/`:`https://${r}:${t}/`}function ax(e){return e.ranges.map(([t,n])=>[t+e.offset,n+e.offset])}function j_(e,t){if(t&&e.startsWith(`${t}/`))return e.slice(t.length+1);const n=e.lastIndexOf("/src/");return n>=0?e.slice(n+1):e}function M4(e){var r;const t=(r=e.source)==null?void 0:r.replace(/[?#].*$/,""),n=t?` (${j_(t)}:${e.line??"?"})`:"";return`${e.message}${n}`.slice(0,jP)}function bf(e,t){return!Number.isFinite(e)||e<=0?t:Math.min(Math.max(e,170),Math.floor(window.innerWidth*.5))}const L4=new Set(["running","starting","preparing","crashed","unreachable"]);function Fs(e){var n,r,o;if(e.agent==="waiting")return"waiting";if(e.agent==="working"&&e.stopping)return"stopping";if(e.agent==="working")return"working";const t=e.procs.some(s=>L4.has(s.status));return t&&(e.agent==="error"||((r=(n=e.worktree)==null?void 0:n.lastTurn)==null?void 0:r.end)==="failed")?"failed":e.background?"background":t&&((o=e.worktree)!=null&&o.landed)&&!e.dirty?"landed":e.procs.some(s=>s.status==="crashed"||s.status==="unreachable")?"crashed":e.procs.some(s=>s.status==="running")?"running":e.procs.some(s=>s.status==="starting")?"starting":e.procs.some(s=>s.status==="preparing")?"preparing":e.procs.some(s=>s.status==="asleep")?"asleep":"idle"}const P4={waiting:"Waiting for you",stopping:"Agent stopping",working:"Agent working",background:"Running in the background",failed:"Agent failed",landed:"Landed",crashed:"Crashed",running:"Running",starting:"Starting",preparing:"Setting up",asleep:"Asleep",idle:"Idle"};function Lw(e,t=!1){const n=Fs(e);return n==="idle"&&t?"Not set up":n==="background"&&e.wakes?`Wakes ${Qh(e.wakes)}`:P4[n]}const D4={preparing:"Setting up",starting:"Starting",running:"Running",unreachable:"Not answering",crashed:"Crashed",stopped:"Stopped",asleep:"Asleep"};function Pw(e){return D4[e]}const z4=new Set(["idle","asleep","running","starting","preparing","background","landed"]);function Jh(e,t){return t&&z4.has(Fs(e))?t:null}const F4={land:"Landing",commit:"Committing","sync-main":"Syncing with main","pull-main":"Pulling"};function Dw(e){return F4[e]}function T_(e,t){return Jh(e,t??void 0)?"background":Fs(e)}function $_(e,t,n=!1){const r=Jh(e,t??void 0);return r?Dw(r):Lw(e,n)}function C_(e){const t=e.filter(o=>o.status==="crashed"||o.status==="unreachable"),n=t[0];if(!n)return null;const r=t.map(o=>o.status==="unreachable"?`${o.name} never answered on :${o.port}`:`${o.name} crashed on :${o.port}`).join(", ");return{dead:t,tip:`${r} · click to open its tab`,stream:n.name}}function I_(e){const t=e.lastIndexOf("/");return t<0?{name:e,dir:""}:{name:e.slice(t+1),dir:e.slice(0,t)}}const A_=new Intl.Collator(void 0,{numeric:!0,sensitivity:"base"}).compare;function ah(e){const t=[];for(let n=e.indexOf("/");n!==-1;n=e.indexOf("/",n+1))t.push(e.slice(0,n));return t}function R_(e){const t=new Set;for(const n of e)for(const r of ah(n))t.add(r);return[...t].sort(A_)}function zw(e){return e.includes("A")||e==="??"?"added":e.includes("D")?"deleted":""}function Fw(e){if(e==="??")return"A";if(e==="UU"||e==="AA"||e==="DD"||e.includes("U"))return"C";const t=e.trim()[0]??"";return t==="T"?"M":t||"·"}const B4=/Firefox\//.test(navigator.userAgent);function Bw(){const e=t=>{var n;return((n=globalThis.matchMedia)==null?void 0:n.call(globalThis,`(display-mode: ${t})`).matches)??!1};return e("standalone")||e("window-controls-overlay")}const U4=/Chrome\//.test(navigator.userAgent)&&Bw(),Pt=e=>CA(e,{firefox:B4,pwa:U4});function Uw(e){return e.component?`<${e.component} />`:`<${e.tag}>`}function ik(e,t){return e.worktree&&Cr(e.worktree)&&t?t.defaultBranch:e.name}function Hw(e){const t=Math.max(0,e/1e3),n=(a,c)=>`${a} ${c}${a===1?"":"s"}`;if(t<60)return"a moment";const r=t/60;if(r<60)return n(Math.floor(r),"minute");const o=r/60;if(o<24)return n(Math.floor(o),"hour");const s=o/24;return s<7?n(Math.floor(s),"day"):s<365?n(Math.floor(s/7),"week"):n(Math.floor(s/365),"year")}function mr(e){const t=Math.max(0,(Date.now()-e)/1e3);if(t<60)return"now";const n=t/60;if(n<60)return`${Math.floor(n)}m`;const r=n/60;if(r<24)return`${Math.floor(r)}h`;const o=r/24;return o<7?`${Math.floor(o)}d`:o<365?`${Math.floor(o/7)}w`:`${Math.floor(o/365)}y`}function ba(e){const t=Math.max(0,Math.floor(e));return t<100?`${t}s`:`${Math.floor(t/60)}m ${t%60}s`}function H4(e,t,n,r){var a;if(!t)return null;const o=e.filter(Nn).filter(c=>c.repoId===t&&(c.worktree.agent??r)===n);return((a=o.find(c=>Cr(c.worktree))??o[0])==null?void 0:a.id)??null}const W4=200;function K4(e,t){const n=new Map(e.map(r=>[r.path,r]));for(const r of t){if(n.size>=W4)break;const o=Zh(r.path);o&&!n.has(o)&&n.set(o,{path:o,text:r.text})}return n.size===e.length?e:[...n.values()]}function O_(e){return e!==void 0&&!e.routes.some(t=>!t.endpoint)}const Mi=e=>"uploading"in e&&e.uploading===!0;function Ul(e){switch(e.kind){case"image":case"file":{const{key:t,local:n,uploading:r,progress:o,...s}=e;return s}case"paste":{const{key:t,chars:n,lines:r,preview:o,...s}=e;return s}case"pick":{const{key:t,...n}=e;return n}}}const Ww=e=>e.filter(t=>!Mi(t)).map(Ul);let q4=0;function ak(e,t){const n=new Map(t.filter(o=>!Mi(o)).map(o=>[JSON.stringify(Ul(o)),o]));return[...e.map(o=>{const s=JSON.stringify(o),a=n.get(s);if(a)return n.delete(s),a;const c=`d${++q4}`;return o.kind==="paste"?{...o,key:c,...jw(o.text)}:{...o,key:c}}),...t.filter(Mi)]}const lk="out:",Z4=(e,t,n)=>`${lk}${e}:${t}:${n}`;function ms(e){if(!e.startsWith(lk))return null;const t=e.slice(lk.length),n=t.indexOf(":"),r=t.indexOf(":",n+1);return n<0||r<0?null:{clientId:t.slice(0,n),source:t.slice(r+1)}}function su(e,t,n,r){const o=r.length?Ww(r):void 0;switch(e.t){case"chat":return{...e,text:n,attachments:o,boxId:t};case"create-worktree":return{...e,prompt:n,attachments:o,boxId:t};case"restore-worktree":case"adopt-worktree":return{...e,message:{text:n,attachments:o},boxId:t};case"agent-answer":return{...e,attachments:o,boxId:t}}}function G4(e,t){const n=new Set,r=[];for(const o of e){if(n.has(o.log))continue;const s=t[o.id];if(!s||s.attachments.some(Mi)){n.add(o.log);continue}r.push(o.id)}return r}const M_=e=>e.flatMap(t=>"upload"in t&&t.upload?[t.upload]:[]);function V4(e){const t=n=>M_(n.items).some(r=>!n.before.includes(r));return[...e.filter(t),...e.filter(n=>!t(n))]}function Y4(e,t){const n=new Map(t.rows.map(a=>[a.id,a])),r=new Map(e.map(a=>[a.id,a])),o=[];let s=!0;for(const a of t.ids){const c=n.get(a)??r.get(a);c?o.push(c):s=!1}return{rows:o,complete:s}}const _l=300,X4=20;function Q4(e,t){return e.rows.length===0&&e.repos.length===0?null:{protocol:va,at:t,version:e.version,machine:e.machine??"",install:e.install,registry:e.registry,repos:e.repos,rows:e.rows,trunks:e.trunks,themePrefs:e.themePrefs,agents:e.agents,defaultAgent:e.defaultAgent,agentChosen:e.agentChosen,home:e.home,folderDialog:e.folderDialog,keepAwake:e.keepAwake,remote:e.remote,tailscale:e.tailscale,machines:e.handed,gitIdentity:e.gitIdentity,visits:e.visits,managed:e.managed}}const lx=e=>(e==null?void 0:e.protocol)===va,J4={rows:"",repos:"",visits:"",themes:""};function ez(e){const{at:t,...n}=e;return{t:"hello",...n,rows:e.rows.map(tz),trunks:Object.fromEntries(Object.entries(e.trunks).map(([r,o])=>[r,nz(o)])),stamps:J4,themes:[],drafts:{},attachments:{},knocks:[],letIn:!1,self:null,update:null,globalInstall:null,pending:[]}}function tz(e){const{stopping:t,shipping:n,queued:r,syncQueued:o,...s}=e;return{...s,agent:e.agent==="working"?"idle":e.agent,procs:[],login:!1}}function nz(e){const{shipping:t,...n}=e;return n}function rz(e){let t=null;for(const{event:n}of e){const r=n.ts;typeof r=="number"&&(t===null||r>t)&&(t=r)}return t}function xf(e,t){return e.length>t?e.slice(e.length-t):[...e]}function oz(e,t,n=X4){const r=new Set(t.map(a=>a.id)),o=Object.keys(e).filter(a=>!r.has(a)),s=Object.entries(e).filter(([a])=>r.has(a)).sort((a,c)=>c[1].at-a[1].at);return[...o,...s.slice(n).map(([a])=>a)]}class sz{constructor(){jt(this,"events",[]);jt(this,"seq",-1);jt(this,"whole",!1)}reset(t,n,r){this.events=xf(mf(t),_l),this.seq=n,this.whole=r}extend(t,n){this.events.push(...t),n>this.seq&&(this.seq=n),this.events.length>_l*2&&(this.events=xf(mf(this.events),_l))}since(){return this.whole&&this.seq>=0?this.seq:void 0}add(t,n){this.events.push({seq:t,event:n}),t>this.seq&&(this.seq=t),this.events.length>_l*2&&(this.events=xf(mf(this.events),_l))}snapshot(t,n){return this.events=xf(mf(this.events),_l),{protocol:va,at:n,events:[...this.events],seq:this.seq,...t?{draft:t}:{}}}}const iz={ids:[],at:-1};function cx(e,t,n){if(e.ids[e.at]===n)return e;const o=[...e.ids.length?e.ids.slice(0,e.at+1):t?[t]:[],n].slice(-50);return{ids:o,at:o.length-1}}function az(e,t,n,r){for(let o=e.at+r;o>=0&&o<e.ids.length;o+=r){const s=e.ids[o];if(s!==void 0&&s!==n&&t.has(s))return{at:o,activate:s}}return null}function L_(e,t){if(e.ids.every(o=>t.has(o)))return e;const n=[];let r=-1;return e.ids.forEach((o,s)=>{t.has(o)&&(n[n.length-1]!==o&&n.push(o),s<=e.at&&(r=n.length-1))}),{ids:n,at:n.length?Math.max(r,0):-1}}function Hu(e){return e.kind==="user"||e.kind==="handed"}function P_(e){return e.map(t=>Hu(t)?t.attachments:void 0)}const Uf=["files","changes","history"],lz=e=>Uf.includes(e),Pa=e=>(e==null?void 0:e.worktree.id)??null,Xl="new-project",Da=Object.freeze({chat:[],log:[],queue:[],page:{},turn:{edits:!1,hmr:!1},changedRanges:{},commitFiles:{},search:null,design:null,draft:"",attachments:[],commands:[],termStream:zo}),ep=e=>({...e,phase:"editing",repoId:null}),D_=()=>ep({mode:"create",name:"",parent:`~/${s_}`}),cz=Object.freeze({changes:!1,changesTab:"files",chat:!0,term:!1,design:!1});function uz(e){if(!e||typeof e!="object")return!1;const t=e;return typeof t.changes=="boolean"&&lz(t.changesTab)&&typeof t.chat=="boolean"&&typeof t.term=="boolean"&&typeof t.design=="boolean"}function ao(e,t){const n=e.layout;let r=!1;for(const o of Object.keys(t))t[o]!==n[o]&&(r=!0);return r?{...e,layout:{...n,...t}}:e}function Kw(e,t){return{...e,layout:t,changesAuto:!1}}const Li=e=>Yh(e)?"preview":"file",dz=(e,t)=>e===t||!!e&&!!t&&e.at===t.at&&(e.at!=="tree"||t.at!=="tree"||e.worktreeId===t.worktreeId&&e.dir===t.dir)&&(e.at!=="rail"||t.at!=="rail"||e.worktreeId===t.worktreeId),Yc=(e,t)=>e.worktreeId===t.worktreeId&&e.path===t.path&&e.ref===t.ref&&e.since===t.since;function z_(e,t,n,r){var s;if(!r.fiber)return r;const o=(s=Mr(e,t).changedRanges[n])==null?void 0:s.offset;return o===void 0?r:{n:r.n-o}}function fz(e){const t=e.cached??Uu,n={connected:!1,connectFailure:null,repos:[],rows:[],activeRepoId:null,visible:[],lent:null,archiving:[],shipping:{},visibleDiscovered:[],discoveredOpen:e.storedDiscoveredOpen??{},archivedOpen:e.storedArchivedOpen??{},committedShut:e.storedCommittedShut??{},turnOpen:e.storedTurnOpen??{},treeOpen:e.storedTreeOpen??{},treeReveal:null,refs:{},chats:{},archived:{},archivedPage:null,lastActive:e.storedLastActive??{},pendingOpen:!1,activeId:null,viewed:iz,carryTo:null,clientId:e.clientId,storedActive:e.storedActive??null,storedRepo:e.storedRepo??null,heard:!1,heardAt:null,recalledAt:null,stamps:null,local:{},editor:null,openUrl:null,reloadReq:null,dragFiles:null,sharing:null,picking:!1,overlay:null,paletteReturn:null,incompatible:!1,layout:cz,focusChanges:0,editCommit:0,focusChat:0,walked:0,railOpen:e.storedRailOpen??!1,chatSide:e.storedChatSide??"left",blackGround:e.storedBlackGround??!1,focusRail:0,railPeek:!1,unreadHold:null,layouts:e.storedLayouts??{},screen:e.storedActive&&e.storedPhoneRow?"chat":"home",left:null,frame:e.frame??"desk",touch:e.touch??!1,reading:!1,typing:!1,changesAuto:!0,zen:!1,focusTerm:0,termRun:null,termTall:0,previewSize:null,themes:Ff.some(o=>o.id===t.id)?Ff:[...Ff,t],themePrefs:{..._D,mode:t.kind,[t.kind]:t.id},previewTheme:null,systemDark:e.systemDark??!0,daylight:e.daylight??null,paths:{query:"",entries:[],target:null},home:"",folderDialog:!1,keepAwake:null,remote:null,machine:null,managed:SP,letIn:!1,knocks:[],tailscale:null,handed:[],gitIdentity:!0,self:null,rebuilt:!1,update:null,globalInstall:null,updateCheck:null,version:"",install:"none",registry:null,ranBefore:e.storedVersion??null,notesPage:!1,notesSeen:!1,choosingFolder:!1,newProject:null,autoSend:null,outbox:[],chosenFolder:null,pending:[],activeImportId:null,agents:[],defaultAgent:"claude",agentChosen:!1,agentConfigs:{},draft:null,trunks:{},visits:{}},r=e.storedRepo?n.layouts[e.storedRepo]:void 0;return r?Kw(n,r):n}function F_(e){var t;return{system:e.systemDark,daylight:((t=e.daylight)==null?void 0:t.dark)??e.systemDark}}function hz(e){return e.previewTheme??Vh(e.themePrefs,e.themes,F_(e))}function Mr(e,t){return t&&e.local[t]||Da}function qw(e,t){const n=Mr(e,t);return n.draft.trim()!==""||n.attachments.length>0}function uo(e,t){return t&&e.rows.find(n=>n.id===t)||null}function B_(e,t){const n=uo(e,t);return n?ss(n.agent)||!!e.shipping[n.id]||(n.queued??0)>0:!1}function Kt(e,t){const n=uo(e,t);return n&&Nn(n)?n:null}function U_(e){var o;const t=Kt(e,e.activeId);if(!t||!Ri(t.worktree)||t.agent!=="idle"||!((o=Pi(e,t.repoId))!=null&&o.empty))return!1;const n=ws(e,t.repoId),r=e.rows.some(s=>{var a;return s.repoId===t.repoId&&((a=s.worktree)==null?void 0:a.kind)==="worktree"});return!!(n!=null&&n.needsSetup)&&!r&&Mr(e,t.id).chat.length===0}function tp(e){return e.newProject!==null||U_(e)}function pz(e){return e.incompatible||tp(e)}function mz(e){return(!e.needsSetup||!!e.assumed)&&Object.keys(e.config.run).length===0}function lh(e){return!!(e!=null&&e.needsSetup)&&!e.assumed}function Zw(e){const t=e.archivedPage?null:uo(e,e.activeId);return(t==null?void 0:t.repoId)??e.activeRepoId}function No(e){const t=ws(e,Zw(e));return!!t&&mz(t)}function H_(e){return e.layout.chat&&!No(e)&&!e.archivedPage&&!Vw(e)?{a:"toggle-chat"}:{a:"focus-chat"}}function W_(e,t){var n;return!e.activeRepoId||!((n=e.archived[e.activeRepoId])!=null&&n.some(r=>r.id===t))?e:{...e,archivedPage:t,notesPage:!1,editor:null,screen:"chat"}}function es(e){return No(e)?e:ao(e,{chat:!0})}function ws(e,t){return t&&e.repos.find(n=>n.id===t)||null}function K_(e,t){if(!t)return null;const n=e.rows.filter(Nn).filter(r=>r.repoId===t);return n.find(r=>Rh(r.worktree))??n.find(r=>Ri(r.worktree))??null}function Pi(e,t){return t&&e.trunks[t]||null}function Ll(e){return No(e)||e.archivedPage||e.notesPage?null:e.activeId}function np(e){return e.procs.some(t=>t.status==="running"||t.status==="starting"||t.status==="preparing")}function Su(e){if(e.archivedPage||e.notesPage)return null;const t=Kt(e,e.activeId);return t&&np(t)?{worktreeId:t.worktree.id,repoId:t.repoId}:null}function ck(e){const t=Ll(e),n=Kt(e,t);return n?{id:n.worktree.id,act:np(n)?"frame":"start"}:null}function Gw(e,t,n){const r=e.worktree.from;if(e.repoId===t||(r==null?void 0:r.kind)!=="worktree"||r.origin.repoId!==t)return null;const o=n.find(s=>s.id===r.origin.id);return o&&Nn(o)&&o.repoId===t?o:null}function gz(e,t,n){var s;const r=e.worktree.from;if((r==null?void 0:r.kind)!=="worktree")return null;const o=t.find(a=>a.id===r.origin.id);return o&&Nn(o)?o.worktree.title:((s=n.find(a=>a.id===r.origin.id))==null?void 0:s.title)??null}function q_(e,t){return e.repoId!==t&&(e.agent==="waiting"||!!e.unseen)}function rp(e,t,n,r){return e.repoId===t||Gw(e,t,n)!==null||q_(e,t)||e.id===r}function Z_(e,t,n){return!e||!t||!Nn(e)||e.repoId===t||Gw(e,t,n)?null:q_(e,t)?e.id:null}function G_(e,t){return t.length?e.filter(n=>!t.includes(n.id)):e}function kz(e,t,n,r){const o=G_(e,n).filter(Nn);return fA(t?o.filter(s=>rp(s,t,o,r)):o)}function wz(e,t){const n=e.filter(r=>!Nn(r));return t?n.filter(r=>r.repoId===t):n}function Ql(e,t,n=e.rows){var c;const r=n.filter(Nn),o=e.archiving.length?r.filter(u=>!e.archiving.includes(u.id)):r,s=t?e.lastActive[t]:void 0;if(s&&o.some(u=>u.id===s))return s;const a=t?o.filter(u=>u.repoId===t):o;return((c=a.find(u=>Rh(u.worktree))??a.find(u=>Ri(u.worktree))??a[0])==null?void 0:c.id)??null}function ux(e,t){const n=Object.entries(e),r=n.filter(([o])=>!t(o));return r.length===n.length?e:Object.fromEntries(r)}function V_(e,t,n){const r={};for(const a of t)a.shipping&&(r[a.id]=a.shipping);for(const a of Object.values(n))a.shipping&&(r[a.id]=a.shipping);for(const[a,c]of Object.entries(e))!c.sent||r[a]||(t.some(u=>u.id===a)||oN({trunks:n},a))&&(r[a]=c);const o=Object.keys(r);return o.length===Object.keys(e).length&&o.every(a=>yz(e[a],r[a]))?e:r}const yz=(e,t)=>!!e&&!!t&&e.op===t.op&&e.step===t.step&&e.sent===t.sent;function ga(e,t){var m;const n=uo(e,t),r=!!n&&Nn(n)&&!!e.activeRepoId&&rp(n,e.activeRepoId,e.rows,e.lent),o=r&&e.lent!==t?Z_(n,e.activeRepoId,e.rows):r?e.lent:null,s=r?e.activeRepoId:(n==null?void 0:n.repoId)??e.activeRepoId,a=n&&Nn(n)?{...e.lastActive,[n.repoId]:n.id}:e.lastActive,c=e.activeId!==t?e.activeId:null,u=c?e.local[c]:void 0,f=u&&((m=u.mark)==null?void 0:m.by)==="reveal"?Pl(u,"reveal"):null,h=c&&f?{...e.local,[c]:f}:e.local;return{...e,activeId:t,activeRepoId:s,lent:o,lastActive:a,editor:null,archivedPage:null,notesPage:!1,local:h}}function Jl(e){return Uo(e)?"history":e.layout.changesTab}function vz(e,t){const n=Jl(e);if(Uo(e))return n;const r=Uf.length;return Uf[(Uf.indexOf(n)+t+r)%r]??"changes"}function Vw(e){if(e.archivedPage)return null;const t=uo(e,e.activeId);return t&&!Nn(t)?t:null}function bz(e){return e.notesSeen||e.ranBefore===null||!f_(e.version,e.ranBefore)?null:e.version}const xz=800;function Y_(e,t){return e.left&&t-e.left.at<xz?e.left.face:null}function Ez(e,t){var n,r;return{id:e.id,repoId:e.repoId,title:e.worktree.title,branch:e.worktree.branch,path:e.path,createdAt:e.worktree.createdAt,archivedAt:t,restorable:!0,transcript:e.transcript??"",...e.sessionId?{sessionId:e.sessionId}:{},...e.dirty?{uncommitted:!0,dirty:e.dirty}:{},...e.worktree.landed?{landed:!0}:{},...(n=e.worktree.lands)!=null&&n.length?{lands:e.worktree.lands}:{},...((r=e.usage)==null?void 0:r.cost)!==void 0?{cost:e.usage.cost}:{}}}function Sz(e,t){let n=e;for(const[r,o]of Object.entries(e))o.some(s=>t.includes(s.id))&&(n={...n,[r]:o.filter(s=>!t.includes(s.id))});return n}function Uo(e){var t;return!e.archivedPage||!e.activeRepoId?null:((t=e.archived[e.activeRepoId])==null?void 0:t.find(n=>n.id===e.archivedPage))??null}function Pl(e,t){var o;if(((o=e.mark)==null?void 0:o.by)!==t)return e;const{mark:n,...r}=e;return r}const X_=e=>e.kind==="theme"||e.kind==="appearance"||e.kind==="keep-awake"||e.kind==="agent"||e.kind==="agent-page"||e.kind==="choose-folder"||e.kind==="handoff";let _z=0;function _u(e){if(!e.sending)return e;const{sending:t,...n}=e;return n}function Nz(e,t){const n=Object.keys(e.local).filter(o=>{var s;return((s=e.local[o])==null?void 0:s.sending)&&(!t||o===t)});if(n.length===0)return e;const r={...e.local};for(const o of n)r[o]=_u(r[o]);return{...e,local:r}}function jz(e,t,n,r){var a;let o=e;const s=n?(a=o[n])==null?void 0:a.sending:void 0;if(s&&n&&r&&r!==n){const c=o[r]??Da,u=c.chat.some(f=>f.kind==="user")?{at:s.at}:s;o={...o,[n]:_u(o[n]),[r]:{...c,sending:u}}}for(const c of t){const u=o[c.id];u!=null&&u.sending&&!u.sending.message&&ss(c.agent)&&(o={...o,[c.id]:_u(u)})}return o}function bt(e,t,n){return{...e,local:{...e.local,[t]:n(e.local[t]??Da)}}}function dx(e,t){const n=e.find(r=>r.kind==="tool"&&!r.done&&!r.parentToolId&&!r.background);if(n)return(t==null?void 0:t.id)===n.id?t:{id:n.id,at:Date.now()}}function Tz(e,t){const n=t.type==="agent-question"||t.type==="agent-permission"||t.type==="handoff-proposed"&&!t.held||t.type==="handoff-shown",r=t.type==="agent-ask-end"||t.type==="handoff-go"||t.type==="handoff-declined"?t.id:null;if(!n&&!r)return e;const o=t.type==="agent-ask-end"&&Rw(t.outcome),s=t.type==="agent-ask-end"&&t.outcome==="expired"?t.id:null,{card:a,cardParked:c,askRevived:u,...f}=e;return{...f,...a&&!n&&(a.id!==r||o)?{card:a}:{},...c&&!n&&c!==r?{cardParked:c}:{},...s?{askRevived:s}:u&&!n?{askRevived:u}:{}}}function $z(e,t,n){return bt(e,t,r=>({...r,chat:[...r.chat,n],chatAt:Date.now()}))}function Q_(e,t,n){return $z(es(e),t,{kind:"error",text:n})}function uk(e,t){const n=Pa(Kt(e,e.activeId));return n?bt(es(e),n,r=>({...r,notice:t})):e}function fx(e,t,n){return Kt(e,t)?Q_(e,t,n):uk(e,n)}function Cz(e,t){const n=e.paletteReturn;return!t||!n?{overlay:null,paletteReturn:null}:{overlay:{kind:n.mode},paletteReturn:n}}function Iz(e){const t=e.activeRepoId;if(!t)return e;const n=e.layouts[t];return n?Kw(e,n):e.frame==="desk"?{...e,layouts:{...e.layouts,[t]:e.layout}}:e}function Az(e){return e.a==="server"&&e.msg.t==="git-status"}function Rz(e){return{agent:e.defaultAgent}}function Oz(e){const t=Kt(e,e.activeId);return!!t&&Cr(t.worktree)&&!e.archivedPage&&!tp(e)?e.draft?e:{...e,draft:Rz(e)}:e.draft?{...e,draft:null}:e}function J_(e){var r;const t=e.archivedPage,n=t!==null&&((r=e.editor)==null?void 0:r.worktreeId)===t&&Kt(e,t)===null;return{...e,archivedPage:null,...n?{editor:null}:{}}}function Mz(e){const t=e.activeRepoId;if(!t)return e;const n=Kt(e,e.activeId);return!n||n.repoId===t||rp(n,t,G_(e.rows,e.archiving),e.lent)?e:ga(e,Ql(e,t))}function eN(e,t,n){const r=t.some(s=>!e.knocks.some(a=>a.id===s.id)),o={...e,knocks:t,letIn:n};return r&&o.overlay===null?$i(o,{a:"open",overlay:{kind:"devices"}}):o}const Lz=e=>{var t;return e.frame==="desk"&&(e.remote!==null||((t=e.tailscale)==null?void 0:t.state)==="ready")};function $i(e,t){let n=Oz(Mz(Pz(e,t)));return n.unreadHold!==null&&n.activeId!==n.unreadHold&&(n={...n,unreadHold:null}),n.archivedPage!==null&&(Uo(n)===null||Kt(n,n.archivedPage)!==null)&&(n=J_(n)),n.activeRepoId!==e.activeRepoId?n=Iz(n):n.frame==="desk"&&n.activeRepoId&&!Az(t)&&n.layout!==e.layout&&(n={...n,layouts:{...n.layouts,[n.activeRepoId]:n.layout}}),n.rows===e.rows&&n.activeRepoId===e.activeRepoId&&n.archiving===e.archiving&&n.lent===e.lent?n:{...n,visible:kz(n.rows,n.activeRepoId,n.archiving,n.lent),visibleDiscovered:wz(n.rows,n.activeRepoId)}}function Pz(e,t){var n,r,o,s,a,c,u,f;switch(t.a){case"connected":return{...e,connected:t.v,connectFailure:t.v?null:t.failure===void 0?e.connectFailure:t.failure,local:t.v?e.local:Uz(e.local)};case"activate":return{...ga(e,t.id),viewed:cx(e.viewed,e.activeId,t.id),carryTo:null,screen:t.id?"chat":"home"};case"viewed-land":{const h=e.viewed.ids[t.at];return h===void 0||!e.rows.some(m=>m.id===h)?e:{...ga(e,h),viewed:{...e.viewed,at:t.at},carryTo:null,screen:"chat"}}case"open-draft":{if(tp(e))return e;const h=((n=K_(e,e.activeRepoId))==null?void 0:n.id)??null;return h?es({...ga(e,h),viewed:cx(e.viewed,e.activeId,h),carryTo:h,overlay:null,paletteReturn:null,focusChat:e.focusChat+1,screen:"chat"}):e}case"draft-carry":return e.draft?{...e,draft:{...e.draft,carry:t.v}}:e;case"draft-agent":return e.draft?{...e,draft:{...e.draft,agent:t.id}}:e;case"open-archived":return W_(e,t.id);case"close-archived":return e.archivedPage?J_(e):e;case"open-release-notes":return e.newProject?e:{...e,notesPage:!0,notesSeen:!0,overlay:null,paletteReturn:null,editor:null};case"close-release-notes":return e.notesPage?{...e,notesPage:!1}:e;case"sending":return bt(e,t.id,h=>({...h,sending:{message:t.message,at:Date.now()}}));case"sent-box":return bt(e,t.id,({notice:h,...m})=>({...Pl(m,"walk"),draft:"",attachments:[],sent:(m.sent??0)+1}));case"answered":return bt(e,t.id,h=>({...h,sent:(h.sent??0)+1}));case"hold-send":{const h=e.local[t.id];if(!h)return e;const m=Z4(e.clientId,++_z,t.id),g={...Da,draft:t.text,attachments:h.attachments,outgoing:{frame:t.frame,log:t.log}},y=bt(e,t.id,({notice:w,...v})=>({...Pl(v,"walk"),draft:"",attachments:[]}));return{...y,local:{...y.local,[m]:g},outbox:[...e.outbox,{id:m,log:t.log,kinds:h.attachments.map(w=>w.kind)}]}}case"sent-out":{const h=e.local[t.id],m=h==null?void 0:h.outgoing;if(!h||!m)return e;const{[t.id]:g,...y}=e.local,w={...e,local:y,outbox:e.outbox.filter(T=>T.id!==t.id)},v=h.draft,_=h.attachments.length?Ww(h.attachments):void 0,x=T=>({...T,sent:(T.sent??0)+1});if(m.frame.t==="restore-worktree"||m.frame.t==="adopt-worktree")return bt(w,m.log,T=>({...x(T),sending:{message:{text:v,attachments:_},at:Date.now()}}));if(m.frame.t==="agent-answer")return bt(w,m.log,x);const N=m.frame.t==="chat"&&B_(e,m.log);return bt(w,m.log,T=>N?x(T):{...x(T),sending:{message:{text:v,attachments:_},at:Date.now()}})}case"unsend":{const h=e.local[t.id],m=(r=ms(t.id))==null?void 0:r.source;if(!(h!=null&&h.outgoing)||!m)return e;const{[t.id]:g,...y}=e.local,w={...e,local:y,outbox:e.outbox.filter(v=>v.id!==t.id)};return bt(es(w),m,v=>({...v,draft:v.draft||h.draft,attachments:[...h.attachments,...v.attachments],...t.notice?{notice:t.notice}:{}}))}case"drop-out":{if(!((o=e.local[t.id])!=null&&o.outgoing))return e;const{[t.id]:h,...m}=e.local;return{...e,local:m,outbox:e.outbox.filter(g=>g.id!==t.id)}}case"archive-worktrees":{const h=t.ids.filter(A=>!e.archiving.includes(A)&&Kt(e,A));if(h.length===0)return e;const m=Date.now();let g=e.archived;for(const A of h){const R=Kt(e,A);R&&(g={...g,[R.repoId]:[Ez(R,m),...g[R.repoId]??[]]})}const y={...e,archiving:[...e.archiving,...h],archived:g};if(!e.activeId||!h.includes(e.activeId))return y;const w=e.visible.filter(A=>A.id===e.activeId||!y.archiving.includes(A.id)),v=w.findIndex(A=>A.id===e.activeId),_=[A=>A.agent==="waiting",A=>Oh(A.worktree)&&!!A.worktree.landed&&A.agent==="idle",A=>!!A.unseen,A=>A.agent==="working",A=>!Cr(A.worktree)&&Fs(A)==="running"],x=A=>{for(const R of _){const C=A(R);if(C)return C.id}},N=x(A=>w.findLast((R,C)=>C<v&&A(R))),j=ga(y,N??x(A=>w.find((R,C)=>C>v&&A(R)))??Ql(y,e.activeRepoId));return e.frame==="phone"?{...j,screen:"home"}:j}case"shipping":return e.shipping[t.id]||!(uo(e,t.id)||oN(e,t.id))?e:{...e,shipping:{...e.shipping,[t.id]:{op:t.op,sent:!0}}};case"activate-repo":{if(!ws(e,t.id))return e;const h=e.newProject?{...e,newProject:null}:e;if(t.id===e.activeRepoId)return h;const m=Ql(h,t.id);return{...ga(h,m),carryTo:null,activeRepoId:t.id,lent:null,pendingOpen:!1}}case"open-repo":return{...e,pendingOpen:!0};case"new-project":return{...e,newProject:t.v,overlay:null,paletteReturn:null,previewTheme:null,editor:null,notesPage:!1};case"new-project-set":{if(!e.newProject)return e;const h="name"in t.v||"parent"in t.v||"url"in t.v||"mode"in t.v,{error:m,...g}=e.newProject;return{...e,newProject:{...h?g:e.newProject,...t.v}}}case"close-new-project":return e.newProject&&e.repos.length>0?{...e,newProject:null,choosingFolder:!1}:e;case"auto-sent":return e.autoSend?{...e,autoSend:null}:e;case"watch-import":return{...e,activeImportId:t.id};case"close-editor":return{...e,editor:null};case"open-file":{const h=t.v,m=e.editor,g=m&&Yc(m,h)?m:null,y=h.line&&z_(e,h.worktreeId,h.path,h.line);return{...e,editor:{worktreeId:h.worktreeId,path:h.path,...h.ref?{ref:h.ref}:{},...h.since?{since:h.since}:{},view:h.view??(g==null?void 0:g.view)??null,seq:h.seq,disk:(g==null?void 0:g.disk)??null,...y?{line:y}:{},...h.piece?{piece:h.piece}:{},focus:h.focus,conflict:(g==null?void 0:g.conflict)??null,blame:(g==null?void 0:g.blame)??null}}}case"open-loose":{const h=t.v,m={before:h.text,after:h.text,version:null,writable:(h.source.kind==="handle"||h.source.kind==="grant")&&!h.tooLarge&&!h.binary,binary:h.binary,tooLarge:h.tooLarge};return{...e,editor:{worktreeId:h.worktreeId,path:h.name,view:Li(h.name),seq:h.seq,disk:m,focus:!0,conflict:null,blame:null,loose:{source:h.source}}}}case"editor-read":{const h=e.editor;if(!h||h.loose||!Yc(h,t.file))return e;const m=t.disk;if(!m){const w=Q_(e,h.worktreeId,t.error??`could not read ${h.path}`);return h.disk?w:{...w,editor:null}}const g=Li(h.path),y=m.before===""?h.view&&h.view!=="diff"?h.view:g:h.view??(m.before===m.after?g:"diff");return{...e,editor:{...h,view:y,disk:m}}}case"editor-conflict":{const h=e.editor;return h&&!h.loose&&Yc(h,t.file)?{...e,editor:{...h,conflict:t.theirs}}:e}case"editor-view":return e.editor?{...e,editor:{...e.editor,view:t.v,line:void 0}}:e;case"editor-refused":{const h=e.editor;if(!h||!Yc(h,t.file))return e;const m=h.loose&&h.disk?{...h.disk,writable:!1}:h.disk;return{...e,editor:{...h,refused:t.message,disk:m}}}case"editor-blame":{const h=e.editor;return h&&!h.loose&&Yc(h,t.file)?{...e,editor:{...h,blame:t.blame}}:e}case"notice":return bt(es(e),((s=ms(t.id))==null?void 0:s.source)??t.id,h=>({...h,notice:t.text}));case"link-refused":return bt(e,t.id,({refusedLink:h,...m})=>t.v?{...m,refusedLink:t.v}:m);case"card-draft":return bt(e,t.id,h=>({...h,card:t.card}));case"card-park":return bt(e,t.id,h=>({...h,cardParked:t.cardId}));case"card-unpark":return bt(e,t.id,({cardParked:h,...m})=>m);case"ask-revive":return bt(e,t.id,({askRevived:h,...m})=>t.askId?{...m,askRevived:t.askId}:m);case"opened-url":return e.openUrl?{...e,openUrl:null}:e;case"set-draft":return bt(e,t.id,h=>{const{notice:m,...g}=Pl(h,"walk");return{...g,draft:t.text,...m!==void 0&&t.text===""?{notice:m}:{}}});case"move-box":return rN(e,t.from,t.to);case"walk":return bt(e,t.id,h=>({...Pl(h,"walk"),draft:t.text,...t.walk?{mark:{by:"walk",at:t.walk.at,from:t.walk.from}}:{}}));case"reveal":return bt(es(e),t.id,h=>{var m;return{...h,mark:{by:"reveal",seq:t.seq,n:((m=h.mark)==null?void 0:m.by)==="reveal"?h.mark.n+1:1}}});case"attach":return bt(es(e),t.id,({notice:h,...m})=>({...m,attachments:[...m.attachments,...t.items]}));case"upload-progress":return(a=e.local[t.id])!=null&&a.attachments.some(h=>h.key===t.key&&Mi(h))?bt(e,t.id,h=>({...h,attachments:h.attachments.map(m=>m.key===t.key?{...m,progress:t.progress}:m)})):e;case"attached":return(c=e.local[t.id])!=null&&c.attachments.some(h=>h.key===t.key)?bt(e,t.id,h=>({...h,attachments:h.attachments.map(m=>m.key===t.key?t.item:m)})):e;case"detach":{const h=bt(e,t.id,({notice:m,...g})=>({...g,attachments:g.attachments.filter(y=>y.key!==t.key)}));return(u=e.local[t.id])!=null&&u.outgoing?$i(h,{a:"unsend",id:t.id}):h}case"clear-attachments":return bt(e,t.id,({notice:h,...m})=>m.attachments.length?{...m,attachments:[]}:m);case"hmr":return bt(e,t.id,h=>({...h,turn:{...h.turn,hmr:!0}}));case"page":return bt(e,t.id,h=>({...h,page:{url:t.url??h.page.url,title:t.title??h.page.title}}));case"links":return bt(e,t.id,h=>{const m=K4(h.links??[],t.links);return m===h.links?h:{...h,links:m}});case"drag-files":return dz(e.dragFiles,t.v)?e:{...e,dragFiles:t.v};case"sharing":return e.sharing===t.v?e:{...e,sharing:t.v};case"set-picking":return{...e,picking:t.v};case"preview-size":return e.previewSize===t.text?e:{...e,previewSize:t.text};case"open":return{...e,overlay:t.overlay,previewTheme:null,paletteReturn:X_(t.overlay)?e.paletteReturn:null};case"choosing-folder":return{...e,choosingFolder:t.v};case"close":return{...e,previewTheme:null,...Cz(e,t.back)};case"toggle":return((f=e.overlay)==null?void 0:f.kind)===t.overlay.kind?$i(e,{a:"close"}):$i(e,{a:"open",overlay:t.overlay});case"palette-return":return{...e,paletteReturn:t.v};case"toggle-changes":return{...ao(e,{changes:!e.layout.changes}),changesAuto:!1};case"focus-changes":return{...ao(e,{changes:!0,changesTab:t.tab&&!Uo(e)?t.tab:e.layout.changesTab}),changesAuto:!1,focusChanges:e.focusChanges+1};case"changes-tab":return ao(e,{changesTab:t.v});case"edit-commit":return{...ao(e,{changes:!0}),changesAuto:!1,editCommit:e.editCommit+1};case"toggle-chat":return No(e)?e:ao(e,{chat:!e.layout.chat});case"focus-chat":return{...es(e),focusChat:e.focusChat+1};case"walked":return{...e,walked:e.walked+1};case"show-chat":return es(e);case"hold-unread":return{...e,unreadHold:t.id};case"toggle-rail":return{...e,railOpen:!e.railOpen};case"toggle-chat-side":return{...e,chatSide:e.chatSide==="left"?"right":"left"};case"toggle-black-ground":return{...e,blackGround:!e.blackGround};case"update-check":return{...e,updateCheck:"asking"};case"update-check-settle":return e.updateCheck===t.check?{...e,updateCheck:null}:e;case"focus-rail":return{...e,railOpen:!0,focusRail:e.focusRail+1,screen:"home"};case"screen":return e.screen===t.to&&!e.editor?e:{...t.to==="changes"&&e.screen!=="changes"?ao(e,{changesTab:"changes"}):e,screen:t.to,editor:null,left:t.to==="home"&&e.screen!=="home"?{face:e.screen,at:Date.now()}:e.left};case"frame":{if(e.frame===t.v)return e;const h={...e,frame:t.v};if(t.v!=="desk"||!h.activeRepoId)return h;const m=h.layouts[h.activeRepoId];return m?Kw(h,m):h}case"touch":return e.touch===t.v?e:{...e,touch:t.v};case"reading":return e.reading===t.on?e:{...e,reading:t.on};case"typing":return e.typing===t.on?e:{...e,typing:t.on};case"rail-peek":return e.railPeek===t.on?e:{...e,railPeek:t.on};case"toggle-discovered":{const h=e.activeRepoId;return h?{...e,discoveredOpen:{...e.discoveredOpen,[h]:!e.discoveredOpen[h]}}:e}case"toggle-archived":{const h=e.activeRepoId;return h?{...e,archivedOpen:{...e.archivedOpen,[h]:!e.archivedOpen[h]}}:e}case"toggle-committed":{const h=e.activeRepoId;return h?{...e,committedShut:{...e.committedShut,[h]:!e.committedShut[h]}}:e}case"toggle-turn":{const h=e.activeRepoId;return h?{...e,turnOpen:{...e.turnOpen,[h]:!e.turnOpen[h]}}:e}case"tree-folder":{const h=e.treeOpen[t.worktreeId]??[];if(h.includes(t.path)===t.open)return e;const m=t.open?[...h,t.path]:h.filter(y=>y!==t.path),g={...e.treeOpen};return m.length>0?g[t.worktreeId]=m:delete g[t.worktreeId],{...e,treeOpen:g}}case"tree-reveal":{const h=e.treeOpen[t.worktreeId]??[],m=[];for(let w=t.path.indexOf("/");w!==-1;w=t.path.indexOf("/",w+1))m.push(t.path.slice(0,w));m.push(t.path);const g=m.filter(w=>!h.includes(w)),y=g.length?{...e.treeOpen,[t.worktreeId]:[...h,...g]}:e.treeOpen;return{...ao(e,{changes:!0,changesTab:"files"}),changesAuto:!1,focusChanges:e.focusChanges+1,treeOpen:y,treeReveal:{worktreeId:t.worktreeId,path:t.path}}}case"files-asked":return bt(e,t.worktreeId,h=>({...h,filesFor:t.key}));case"toggle-zen":return No(e)?e:{...e,zen:!e.zen};case"toggle-terminal":return ao(e,{term:!e.layout.term});case"focus-terminal":return{...ao(e,{term:!0}),focusTerm:e.focusTerm+1};case"toggle-design":return No(e)?e:ao(e,{design:!e.layout.design});case"term-stream":return bt({...ao(e,{term:!0}),termTall:t.tall?e.termTall+1:e.termTall},t.id,h=>({...h,termStream:t.stream}));case"term-run":return bt({...ao(e,{term:!0}),focusTerm:e.focusTerm+1,termRun:{id:t.id,command:t.command}},t.id,h=>({...h,termStream:zo}));case"term-ran":return e.termRun?{...e,termRun:null}:e;case"preview-theme":return{...e,previewTheme:t.theme};case"system-dark":return{...e,systemDark:t.v};case"incompatible":return t.v===!1?{...e,incompatible:!1}:{...e,incompatible:!0,connected:!1};case"server":return Gz(e,t.msg);case"recall":return Zz(e,t.hello,t.chats)}}function tN(e,t){const n=Object.entries(e),r=n.filter(([o])=>t.some(s=>s.id===o));return r.length===n.length?e:Object.fromEntries(r)}function nN(e,t,n){const r=new Set(t.map(a=>a.id));n&&r.add(n);const o=([a,c])=>r.has(a)||!!c.draft||c.attachments.length>0,s=Object.entries(e);return s.every(o)?e:Object.fromEntries(s.filter(o))}function Dz(e,t,n){var o;let r=e;for(const s of n){if(!((o=s.worktree)!=null&&o.landed)||s.dirty!==0||t.some(f=>{var h;return f.id===s.id&&((h=f.worktree)==null?void 0:h.landed)}))continue;const a=r[s.id];if(!(a!=null&&a.git)||a.git.files.length===0)continue;r===e&&(r={...e});const{extras:c,...u}=a.git;r[s.id]={...a,git:{...u,files:[]}}}return r}function zz(e,t){const{version:n,files:r,ahead:o,behind:s,unpushed:a,head:c}=t,u={version:n,files:r,...o===void 0?{}:{ahead:o},...s===void 0?{}:{behind:s},...a===void 0?{}:{unpushed:a},...c===void 0?{}:{head:c}};if(t.extras)return{...u,extras:t.extras};const f=new Map(e==null?void 0:e.files.map(y=>[y.path,y])),h=r.map(y=>{const w=f.get(y.path);return w&&w.xy===y.xy&&w.add!==void 0?{...y,add:w.add,del:w.del}:y}),m=e!=null&&e.extras&&e.head===c?e.extras:void 0,g=m&&r.length===0&&m.turn?{committed:m.committed}:m;return{...u,files:h,...g?{extras:g}:{}}}function Fz(e,t,n){if(!e||e.head!==t.head)return{};if(e.version===t.version)return n;const r=new Set([...e.files,...t.files].map(s=>s.path));let o=n;for(const s of Object.keys(n))r.has(s)&&(o===n&&(o={...n}),delete o[s]);return o}function Bz(e){let t=e;for(const[n,r]of Object.entries(e))!r.git||r.git.version===0||(t===e&&(t={...e}),t[n]={...r,git:{...r.git,version:0}});return t}function Uz(e){let t=e;for(const[n,r]of Object.entries(e)){if(r.filesFor===void 0)continue;t===e&&(t={...e});const{filesFor:o,...s}=r;t[n]=s}return t}function Hz(e,t){let n=e;for(const[r,o]of Object.entries(t)){const s=n[r];s!=null&&s.draft||ms(r)||(n===e&&(n={...e}),n[r]={...s??Da,draft:o})}return n}function Wz(e,t){let n=e;for(const[r,o]of Object.entries(t)){const s=n[r];s!=null&&s.attachments.length||ms(r)||(n===e&&(n={...e}),n[r]={...s??Da,attachments:ak(o,[])})}return n}function Kz(e,t){const n=new Set(t.map(r=>r.id));return Object.values(e).every(r=>n.has(r))?e:Object.fromEntries(Object.entries(e).filter(([,r])=>n.has(r)))}function Ni(e,t){const n=new Set(t.map(r=>r.id));return Object.keys(e).every(r=>n.has(r))?e:Object.fromEntries(Object.entries(e).filter(([r])=>n.has(r)))}function hx(e){const t=e.newProject;if((t==null?void 0:t.phase)!=="creating"||!t.repoId)return e;const n=K_(e,t.repoId);if(!n)return e;const r=Mr(e,Xl);return!r.draft.trim()&&r.attachments.length===0?{...e,newProject:null}:{...rN(e,Xl,n.id),newProject:null,autoSend:n.id}}function rN(e,t,n){const r=e.local[t];if(!r)return e;const o=bt(e,n,s=>({...s,draft:r.draft,attachments:r.attachments}));return bt(o,t,s=>({...s,draft:"",attachments:[]}))}function Ef(e,t,n){return e.stamps?{...e.stamps,[t]:n}:null}function qz(e){return e.stamps?JP(e.stamps):null}function oN(e,t){return Object.values(e.trunks).some(n=>n.id===t)}function sN(e,t,n){var w;const{rows:r,repos:o,trunks:s,visits:a}=t.same?e:t,c=v=>!!v&&r.some(_=>_.id===v),u=v=>!!v&&o.some(_=>_.id===v),f=u(e.activeRepoId)?e.activeRepoId:u(e.storedRepo)?e.storedRepo:null,h=c(e.activeId)?e.activeId:c(e.storedActive)?e.storedActive:Ql(e,f,r),m=r.find(v=>v.id===h),g=!!f&&!!m&&Nn(m)&&rp(m,f,r,e.lent),y={...e,heard:!n,heardAt:n?e.heardAt:Date.now(),recalledAt:n?e.recalledAt:null,stamps:n?null:t.stamps,repos:o,rows:r,activeId:h,lent:g?e.lent===h?e.lent:Z_(m??null,f,r):null,activeRepoId:g?f:(m==null?void 0:m.repoId)??f??((w=o[0])==null?void 0:w.id)??null,trunks:s,archiving:e.archiving.length?[]:e.archiving,shipping:V_({},r,s),local:Bz(nN(Wz(Hz(e.local,t.drafts),t.attachments),r,e.archivedPage)),lastActive:Kz(e.lastActive,r),viewed:L_(e.viewed,new Set(r.map(v=>v.id))),treeOpen:tN(e.treeOpen,r),discoveredOpen:Ni(e.discoveredOpen,o),archivedOpen:Ni(e.archivedOpen,o),committedShut:Ni(e.committedShut,o),turnOpen:Ni(e.turnOpen,o),refs:Ni(e.refs,o),chats:Ni(e.chats,o),archived:Ni(e.archived,o),themes:!n&&t.themes?t.themes:e.themes,themePrefs:!n&&t.themePrefs?t.themePrefs:e.themePrefs,agents:t.agents,defaultAgent:t.defaultAgent,agentChosen:t.agentChosen,home:t.home,folderDialog:t.folderDialog,keepAwake:t.keepAwake,remote:t.remote,machine:t.machine,managed:t.managed,tailscale:t.tailscale,handed:t.machines,gitIdentity:t.gitIdentity,newProject:e.newProject??(!n&&o.length===0&&r.length===0&&t.pending.length===0?D_():null),pending:n?e.pending:t.pending,visits:a,self:n?e.self:t.self,update:n?e.update:t.update,globalInstall:n?e.globalInstall:t.globalInstall,updateCheck:!n&&e.updateCheck==="asking"?null:e.updateCheck,version:n?e.version:t.version,install:n?e.install:t.install,registry:n?e.registry:t.registry,activeImportId:t.pending.some(v=>v.id===e.activeImportId)?e.activeImportId:null};return n?y:eN(y,t.knocks,t.letIn)}function dk(e,t=[]){let n=t,r;for(const{seq:o,event:s}of e)n=aN(n,s,o),s.type==="usage"&&(r=iN(s));return r?{chat:n,usage:r}:{chat:n}}function Zz(e,t,n){var s;let r=sN(e,ez(t),!0);r={...r,recalledAt:t.at};for(const[a,c]of Object.entries(n))if(r.rows.some(u=>u.id===a))try{const{chat:u,usage:f}=dk(c.events);r=bt(r,a,h=>({...h,chat:lN(u),chatAt:rz(c.events)??t.at,running:void 0,...f?{usage:f}:{},...c.draft&&!h.draft?{draft:c.draft}:{}}))}catch{}const o=r.activeId;return o&&r.screen!=="home"&&!(((s=r.local[o])==null?void 0:s.chat.length)??0)&&(r={...r,screen:"home"}),r}function Gz(e,t){var n,r,o,s,a,c,u,f,h,m,g,y,w,v,_;switch(t.t){case"hello":return sN(e,t,!1);case"self":{const x=((n=e.self)==null?void 0:n.building)===!0&&e.self.rebuild&&!((r=t.self)!=null&&r.building);return{...e,self:t.self,rebuilt:e.rebuilt||x&&((o=t.self)==null?void 0:o.buildFailed)===void 0}}case"remote":return{...e,remote:t.remote,machine:t.machine};case"machines":return{...e,handed:t.machines};case"tailscale":return{...e,tailscale:t.tailscale};case"knocks":return eN(e,t.knocks,t.letIn);case"update":return{...e,update:t.update};case"global-install":return{...e,globalInstall:t.globalInstall};case"update-checked":return{...e,updateCheck:t.check};case"visits":return{...e,visits:{...e.visits,[t.repoId]:t.pages},stamps:Ef(e,"visits",t.stamp)};case"themes":return{...e,themes:t.themes,themePrefs:t.prefs,stamps:Ef(e,"themes",t.stamp)};case"daylight":return{...e,daylight:{dark:t.dark,until:t.until}};case"keep-awake":return{...e,keepAwake:t.mode};case"agents":return{...e,agents:t.agents,defaultAgent:t.defaultAgent,agentChosen:t.agentChosen};case"agent-config":{const{t:x,...N}=t;return{...e,agentConfigs:{...e.agentConfigs,[N.agent]:N}}}case"pending-repos":{const x=new Set(e.pending.map(R=>R.id)),N=t.pending.find(R=>!x.has(R.id)),T=N&&e.pendingOpen?N.id:e.activeImportId,j=t.pending.some(R=>R.id===T),A=t.pending.some(R=>R.id===T&&R.error);return{...e,pending:t.pending,activeImportId:j?T:null,pendingOpen:A?!1:e.pendingOpen,newProject:N&&e.pendingOpen&&((s=e.newProject)==null?void 0:s.phase)==="creating"?null:e.newProject}}case"path-entries":return{...e,paths:{query:t.query,entries:t.entries,target:t.target}};case"folder-chosen":return{...e,chosenFolder:{seq:(((a=e.chosenFolder)==null?void 0:a.seq)??0)+1,folder:t.folder}};case"refs":return{...e,refs:{...e.refs,[t.repoId]:{query:t.query,refs:t.refs}}};case"chat-hits":return{...e,chats:{...e.chats,[t.repoId]:{query:t.query,hits:t.hits,truncated:t.truncated,asks:t.asks}}};case"archived":{const x=(e.archived[t.repoId]??[]).filter(N=>e.archiving.includes(N.id)&&!t.items.some(T=>T.id===N.id));return{...e,archived:{...e.archived,[t.repoId]:x.length?[...x,...t.items]:t.items}}}case"draft":return t.clientId===e.clientId||ms(t.boxId)?e:bt(e,t.boxId,x=>{var N;return x.draft===t.text||((N=x.mark)==null?void 0:N.by)==="walk"?x:{...x,draft:t.text}});case"attachments":return t.clientId===e.clientId||ms(t.boxId)?e:bt(e,t.boxId,x=>({...x,attachments:ak(t.items,x.attachments)}));case"repos":{const x=new Set(e.repos.map(I=>I.id)),N=t.repos.find(I=>!x.has(I.id));let T=e.activeRepoId,j=e.pendingOpen,A=e.newProject;N&&(j||!T)?(T=N.id,j=!1,A&&A.phase!=="unmaking"&&(A={...A,phase:"creating",repoId:N.id})):t.repos.some(I=>I.id===T)||(T=((c=t.repos[0])==null?void 0:c.id)??null),(A==null?void 0:A.phase)==="unmaking"&&!t.repos.some(I=>I.id===(A==null?void 0:A.repoId))&&(A={...A,phase:"editing",repoId:null}),t.repos.length===0&&!A&&(A=D_());const R=e.gitIdentity||t.repos.some(I=>I.made&&!x.has(I.id)),C=Ef(e,"repos",t.stamp),M=Ni(e.visits,t.repos);return T===e.activeRepoId?{...e,repos:t.repos,stamps:C,visits:M,pendingOpen:j,newProject:A,gitIdentity:R}:hx({...e,repos:t.repos,stamps:C,visits:M,pendingOpen:j,newProject:A,gitIdentity:R,activeRepoId:T,activeId:Ql(e,T),editor:null})}case"worktrees":{const{rows:x,complete:N}=Y4(e.rows,t),T=t.trunks??e.trunks;let j=e.activeId;(!j||!x.some(I=>I.id===j))&&(j=Ql(e,e.activeRepoId,x));const A=new Set(e.rows.map(I=>I.id)),R=I=>{var D;return((D=I.worktree)==null?void 0:D.kind)==="worktree"&&I.worktree.createdBy===e.clientId},C=x.find(I=>!A.has(I.id)&&R(I));C&&e.rows.length>0&&(j=C.id);const M=e.archiving.filter(I=>x.some(D=>D.id===I));return hx({...ga({...e,rows:x,trunks:T,stamps:Ef(e,"rows",N?t.stamp:""),archiving:M.length===e.archiving.length?e.archiving:M,shipping:V_(e.shipping,x,T),local:nN(jz(Dz(e.local,e.rows,x),x,e.activeId,j===(C==null?void 0:C.id)?C.id:void 0),x,e.archivedPage),treeOpen:tN(e.treeOpen,x),viewed:L_(e.viewed,new Set(x.map(I=>I.id)))},j),editor:j===e.activeId?e.editor:null,...C&&j===C.id?{carryTo:C.id}:{},...j===e.activeId?{activeRepoId:e.activeRepoId}:{},archivedPage:C?null:e.archivedPage,notesPage:C?!1:e.notesPage})}case"log":return bt(e,t.worktreeId,x=>({...x,log:aA(x.log.slice(-400),t.proc,t.line,t.retract)}));case"agent":{const x=t.event,N=t.worktreeId;let T=bt(e,N,j=>{const A=aN(j.chat,x,t.seq),R=x.type==="turn-end",C=R||x.type==="agent-error"||x.type==="agent-auth-required",I=x.type==="tool-start"||x.type==="tool-end"||R||x.type==="tool-update"&&x.background?dx(A,j.running):j.running;let D=j.turn;x.type==="turn-start"?D={edits:!1,hmr:!1}:x.type==="tool-start"&&oS(x)&&(D={...D,edits:!0});const H=x.type==="session-info"&&x.model?x.model:j.model,Z=x.type==="session-info"&&x.effort?x.effort:j.effort,B=x.type==="usage"?{...iN(x),heard:Date.now()}:j.usage,J=e.rows.find($=>$.id===N),V=ss(J==null?void 0:J.agent),ee=j.sending?V?_u(j):{...j,sending:{at:j.sending.at}}:j,F=Tz(x.type==="user-message"?ee:C?_u(j):j,x);return{...x.type==="user-message"?Pl(F,"reveal"):F,chat:A,...A!==j.chat?{chatAt:Date.now()}:{},...I!==j.running?{running:I}:{},turn:D,...H!==j.model?{model:H}:{},...Z!==j.effort?{effort:Z}:{},...B!==j.usage?{usage:B}:{}}});if(x.type==="agent-ask-end"&&!Rw(x.outcome)&&((u=T.local[Fl(x.id)])!=null&&u.attachments.length)&&(T=bt(T,Fl(x.id),j=>({...j,attachments:[]}))),x.type==="user-message"){const j=v_(((f=e.local[N])==null?void 0:f.chat)??[]),A=j?Fl(j.id):null,R=A?((h=T.local[A])==null?void 0:h.attachments)??[]:[];A&&R.length&&(T=bt(T,A,C=>({...C,attachments:[]})),T=bt(T,N,C=>({...C,attachments:[...C.attachments,...R]})))}if(x.type==="turn-end"){const j=T.local[N].turn;j.edits&&!j.hmr&&(T={...T,reloadReq:{id:N,n:(((m=T.reloadReq)==null?void 0:m.n)??0)+1}})}return(x.type==="agent-question"||x.type==="agent-permission"||x.type==="handoff-proposed"&&!x.held||x.type==="handoff-shown")&&N===e.activeId&&(T=es(T)),T}case"backfill":{const x=N=>t.events.some(({event:T})=>T.type==="user-message"&&T.text===N);return bt(e,t.worktreeId,({sending:N,...T})=>{const{chat:j,usage:A}=t.after!==void 0?dk(t.events,T.chat):dk(t.events);return{...T,...N&&!(N.message&&x(N.message.text))?{sending:N}:{},chat:j,chatAt:Date.now(),running:dx(j,T.running),log:t.log??T.log,...A?{usage:A}:{}}})}case"git-status":{const x=(g=e.local[t.worktreeId])==null?void 0:g.git;if(t.version>0&&x&&t.version<x.version||t.version>0&&x&&t.version===x.version&&!t.extras)return e;let N=e.layout.changes,T=e.changesAuto;const j=((y=t.extras)==null?void 0:y.committed.length)??0;e.changesAuto&&t.worktreeId===e.activeId&&!N&&(t.files.length>0||j>0)&&(N=!0,T=!1);const A=t.worktreeId===e.archivedPage?Uo(e):null;A&&(t.files.length>0||j>0||A.landed)&&(N=!0);const R=bt(e,t.worktreeId,C=>{const M=zz(C.git,t);return{...C,git:M,changedRanges:Fz(C.git,M,C.changedRanges)}});return{...ao(R,{changes:N}),changesAuto:T}}case"pr-comments":return bt(e,t.worktreeId,x=>({...x,prComments:t.comments}));case"changed-ranges":{const x=bt(e,t.worktreeId,T=>({...T,changedRanges:{...T.changedRanges,[t.path]:{ranges:t.ranges,offset:t.lineOffset}}})),N=x.editor;return!((w=N==null?void 0:N.line)!=null&&w.fiber)||N.worktreeId!==t.worktreeId||N.path!==t.path?x:{...x,editor:{...N,line:z_(x,N.worktreeId,N.path,N.line)}}}case"shipped":{const x=t.worktreeId,N={...e,shipping:ux(e.shipping,T=>{var j;return T===x&&((j=e.shipping[T])==null?void 0:j.sent)===!0}),openUrl:t.ok&&t.url?t.url:e.openUrl};return!t.ok&&!t.asked?x?fx(N,x,t.message):uk(N,t.message):N}case"files":return bt(e,t.worktreeId,x=>({...x,files:t.paths,submodules:t.submodules,ignored:t.ignored}));case"search-results":return bt(e,t.worktreeId,x=>({...x,search:{query:t.query,hits:t.hits,truncated:t.truncated}}));case"element-sources":{if(e.editor&&e.editor.seq>t.seq)return e;const[x]=t.hits;if(!x)return bt(e,t.worktreeId,T=>({...T,notice:"nothing in the source matches this element"}));if(!t.sure)return $i(e,{a:"open",overlay:{kind:"element-sources",worktreeId:t.worktreeId,hits:t.hits}});const N=$i(e,{a:"open-file",v:{worktreeId:t.worktreeId,path:x.path,view:"file",line:{n:x.line},focus:!0,seq:t.seq}});return N.layout.changes?N:$i(N,{a:"toggle-changes"})}case"design-index":return bt(e,t.worktreeId,x=>({...x,design:t.index}));case"routes":return bt(e,t.worktreeId,x=>({...x,pages:{routes:t.routes,unseen:t.unseen}}));case"queue":return bt(e,t.worktreeId,x=>({...x,queue:t.items}));case"agent-commands":return bt(e,t.worktreeId,x=>({...x,commands:t.commands}));case"git-log":return bt(e,t.worktreeId,x=>({...x,commits:t.commits}));case"git-commit":return bt(e,t.worktreeId,x=>({...x,commitFiles:{...x.commitFiles,[t.sha]:t.files}}));case"error":{const x=t.worktreeId,N=e.newProject,T=(N==null?void 0:N.phase)==="creating"&&!N.repoId,j=x?e.archiving.includes(x)?[x]:[]:e.archiving,A={...Nz(e,x),archiving:j.length?e.archiving.filter(R=>!j.includes(R)):e.archiving,archived:j.length?Sz(e.archived,j):e.archived,shipping:ux(e.shipping,R=>!x||R===x),newProject:T?{...N,phase:"editing",error:t.message}:(N==null?void 0:N.phase)==="unmaking"?null:N,pendingOpen:T?!1:e.pendingOpen,updateCheck:!x&&e.updateCheck==="asking"?null:e.updateCheck};return T?A:x?fx(A,x,t.message):uk(A,t.message)}case"unsent":{const x=((v=ms(t.boxId))==null?void 0:v.source)??t.boxId,N=!uo(e,x)&&!!e.activeRepoId&&((_=e.archived[e.activeRepoId])==null?void 0:_.some(T=>T.id===x));return bt(es(N?W_(e,x):e),x,({sending:T,...j})=>({...j,draft:j.draft||t.text,attachments:[...ak(t.items,[]),...j.attachments],notice:t.message}))}default:return e}}function iN(e){return{used:e.used,size:e.size,...e.cost!==void 0?{cost:e.cost}:{}}}function Vz(e,t){const n=t.trim();return n!==""&&(e.trim()===n||e.trim().endsWith(`: ${n}`))}function aN(e,t,n){var s,a,c,u;const r=e[e.length-1],o=n===void 0?{}:{seq:n};switch(t.type){case"fix-asked":return[...e,{kind:"asked",about:t.kind,why:t.why,...t.toolId?{toolId:t.toolId}:{}}];case"user-message":return[...e,{kind:"user",text:t.text,...(s=t.attachments)!=null&&s.length?{attachments:t.attachments}:{},...o}];case"handed":return[...e,{kind:"handed",via:t.via,...t.body?{body:t.body}:{},...t.path?{path:t.path}:{},...t.note?{note:t.note}:{},origin:t.origin,...(a=t.attachments)!=null&&a.length?{attachments:t.attachments}:{},...o,ts:t.ts}];case"text-delta":{const f=t.messageId?{messageId:t.messageId}:{};if((r==null?void 0:r.kind)==="assistant"&&r.messageId===t.messageId)return[...e.slice(0,-1),{...r,text:r.text+t.text}];const h=t.messageId===void 0?-1:Yz(e,t.messageId);if(h!==-1){const m=e.slice(),g=m[h];return m[h]={...g,text:g.text+t.text},m}return[...e,{kind:"assistant",text:t.text,...o,...f}]}case"picture":{const{type:f,...h}=t;let m=e.findLastIndex(w=>w.kind==="assistant"&&w.text.includes(h.path));if(m===-1&&(m=e.findLastIndex(w=>w.kind==="assistant")),m===-1)return e;const g=e.slice(),y=g[m];return g[m]={...y,pictures:[...(y.pictures??[]).filter(w=>w.path!==h.path),h]},g}case"thinking-delta":return(r==null?void 0:r.kind)==="thinking"?[...e.slice(0,-1),{...r,text:r.text+t.text}]:[...e,{kind:"thinking",text:t.text}];case"tool-start":return[...e,{kind:"tool",id:t.toolId,name:t.name,input:t.input,done:!1,...t.kind?{toolKind:t.kind}:{},...t.title?{title:t.title}:{},...t.parentToolId?{parentToolId:t.parentToolId}:{},...t.subagent?{subagent:!0}:{}}];case"tool-update":{const f=e.findLastIndex(g=>g.kind==="tool"&&g.id===t.toolId);if(f===-1)return e;const h=e.slice(),m=h[f];return h[f]={...m,...t.name?{name:t.name}:{},...t.title?{title:t.title}:{},...t.input!==void 0?{input:t.input}:{},...t.kind?{toolKind:t.kind}:{},...t.background?{background:!0}:{},...t.until?{until:t.until}:{}},h}case"tool-delta":{const f=e.findLastIndex(g=>g.kind==="tool"&&g.id===t.toolId);if(f===-1)return e;const h=e.slice(),m=h[f];return h[f]={...m,output:(m.output??"")+t.text},h}case"tool-end":{const f=e.findLastIndex(g=>g.kind==="tool"&&g.id===t.toolId);if(f===-1)return e;const h=e.slice(),m=h[f];return h[f]={...m,output:t.output,isError:t.isError,...(c=t.images)!=null&&c.length?{images:t.images}:{},...t.detached?{detached:!0}:{},...t.fixable?{fixable:t.fixable}:{},...t.cut?{cut:!0}:{},done:!0},h}case"agent-error":return(r==null?void 0:r.kind)==="assistant"&&Vz(t.message,r.text)?[...e.slice(0,-1),{kind:"error",text:t.message,...o}]:[...e,{kind:"error",text:t.message,...o}];case"agent-blocked":return[...e,{kind:"blocked",tool:t.tool,path:t.path,reason:t.reason}];case"grafted":return[...e,{kind:"grafted",title:t.title,branch:t.branch}];case"model-switched":return[...e,{kind:"switched",name:t.name,...t.asked?{asked:t.asked}:{}}];case"landed":return[...e,{kind:"landed",text:t.message,...t.mark?{mark:t.mark}:{},...t.url?{url:t.url}:{},...t.held?{held:t.held}:{},ts:t.ts}];case"piece-landed":return[...e,{kind:"piece-landed",worktreeId:t.worktreeId,repoName:t.repoName,title:t.title,...t.url?{url:t.url}:{},...t.same?{same:!0}:{},...t.again?{again:!0}:{},...t.awaited?{awaited:!0}:{},ts:t.ts}];case"handoff-proposed":{const f=t.held?e.findLast(m=>m.kind==="ask"&&!m.outcome&&m.ask.kind==="permission"&&!!m.ask.plan):void 0,h=(f==null?void 0:f.kind)==="ask"&&f.ask.kind==="permission"?{companion:f.id,plan:f.ask.plan}:{};return[...e,{kind:"handoff",id:t.id,pieces:t.pieces,fates:Object.fromEntries(t.pieces.map(m=>[m.id,m.fate])),mode:t.mode,...t.held?{held:!0}:{},...t.plan?{plan:t.plan}:{},...t.by?{by:t.by}:{},...h,state:t.held?"held":"proposed",outcomes:[],later:[],ts:t.ts}]}case"handoff-stale":{const f=da(e,t.id,["held","proposed"]);return f===-1?e:e.with(f,{...e[f],stale:!0})}case"handoff-shown":{const f=da(e,t.id,["held","proposed"]);if(f===-1)return e;const h=e[f];return e.with(f,{...h,state:"proposed",...t.plan?{plan:t.plan}:{}})}case"handoff-fate":{const f=da(e,t.id,["held","proposed"]);if(f===-1)return e;const h=e[f];return e.with(f,{...h,fates:{...h.fates,[t.pieceId]:t.fate}})}case"handoff-go":{const f=da(e,t.id,["held","proposed"]);if(f===-1)return e;const h=e[f];if(h.state!=="proposed")return e.with(f,{...h,state:"going"});const m={go:!0,...t.note?{note:t.note}:{}};return px(e,f,{...h,state:"going",answered:m,ts:t.ts})}case"handoff-piece":{const f=da(e,t.id,["going"]);if(f===-1)return e;const h=e[f];return e.with(f,{...h,outcomes:[...h.outcomes,t.outcome]})}case"handoff":{const f=da(e,t.id,["held","proposed","going"]);return f===-1?[...e,{kind:"handoff",id:t.id,pieces:[],fates:{},mode:Wg,state:"done",outcomes:t.outcomes,later:[],ts:t.ts}]:e.with(f,{...e[f],state:"done",outcomes:t.outcomes})}case"handoff-declined":{const f=da(e,t.id,["held","proposed","going"]);if(f===-1)return e;const h=e[f],{companion:m,...g}=h,y=t.plan?{...g,plan:t.plan}:h;return y.state==="proposed"&&!t.reason?px(e,f,{...y,state:"declined",answered:{go:!1},ts:t.ts}):e.with(f,{...y,state:"declined",...t.reason?{reason:t.reason}:{}})}case"piece-made":case"piece-dropped":{const f=e.findLastIndex(v=>v.kind==="handoff"&&v.id===t.id),h=f===-1?void 0:e[f],m=t.type==="piece-made"?{pieceId:t.pieceId,worktreeId:t.worktreeId,title:t.title}:{pieceId:t.pieceId,reason:t.reason},g=t.type==="piece-made"?t.title:(u=h==null?void 0:h.pieces.find(v=>v.id===t.pieceId))==null?void 0:u.title,y={kind:"piece-later",id:t.id,...g?{title:g}:{},...m,ts:t.ts};return[...h?e.with(f,{...h,later:[...h.later,m]}):e,y]}case"restored":return[...e,{kind:"restored",archivedAt:t.archivedAt,branch:t.branch,uncommitted:t.uncommitted,ts:t.ts}];case"adopted":return[...e,{kind:"adopted",branch:t.branch,ts:t.ts}];case"owned":return[...e,{kind:"owned",names:t.names,by:t.by,...t.file?{file:t.file}:{},ts:t.ts}];case"own-failed":return[...e,{kind:"own-failed",name:t.name,cmd:t.cmd,exit:t.exit,ts:t.ts}];case"agent-auth-required":return[...e,{kind:"auth",agent:t.agent,agentName:t.agentName,methods:t.methods,...t.rejected?{rejected:!0}:{},...t.withheld?{withheld:!0}:{},...t.provider?{provider:t.provider}:{},...t.detail?{detail:t.detail}:{},...t.refresh?{refresh:t.refresh}:{},done:!1}];case"agent-auth-ok":return e.some(f=>f.kind==="auth"&&!f.done)?e.map(f=>f.kind==="auth"&&!f.done?{...f,done:!0}:f):e;case"agent-question":return mx(e,t.toolId,{kind:"ask",id:t.id,ask:{kind:"question",message:t.message,questions:t.questions}});case"agent-permission":{const f={kind:"ask",id:t.id,ask:{kind:"permission",title:t.title,...t.command?{command:t.command}:{},...t.detail?{detail:t.detail}:{},...t.plan?{plan:t.plan}:{},...t.handoff?{handoff:t.handoff}:{},choices:t.choices}},h=t.handoff?e.findLastIndex(y=>y.kind==="handoff"&&y.id===t.handoff):-1,m=h===-1?e:e.with(h,{...e[h],companion:t.id,...t.plan&&!e[h].plan?{plan:t.plan}:{}}),g=m.findLast(y=>y.kind==="tool"&&y.id===t.toolId);return(g==null?void 0:g.kind)!=="tool"||t.plan||g.toolKind==="switch_mode"?mx(m,t.toolId,f):[...m,{...f,toolId:g.id}]}case"agent-ask-end":{const f=e.findLastIndex(g=>g.kind==="ask"&&g.id===t.id&&!g.outcome);if(f===-1)return e;const h=e[f];if(h.toolId&&Xz(h,t.choiceId))return[...e.slice(0,f),...e.slice(f+1)];const m=e.slice();return m[f]={...m[f],outcome:t.outcome,...t.answers?{answers:t.answers}:{},...t.choiceId?{choiceId:t.choiceId}:{}},m}case"turn-end":{const f=lN(e);return t.stopReason==="interrupted"?[...f,{kind:"stopped",...o}]:f}default:return e}}function lN(e){const t=n=>n.kind==="tool"&&!n.done&&!n.background;return e.some(t)?e.map(n=>t(n)?{...n,done:!0}:n):e}function Yz(e,t){const n=s=>Hu(s)||s.kind==="handoff"&&!!s.answered;let r=e.length-1;for(;r>=0&&n(e[r]);)r--;const o=e[r];return(o==null?void 0:o.kind)==="assistant"&&o.messageId===t?r:-1}function da(e,t,n){return e.findLastIndex(r=>r.kind==="handoff"&&r.id===t&&n.includes(r.state))}function px(e,t,n){return[...e.slice(0,t),...e.slice(t+1),n]}function Xz(e,t){var n;return e.ask.kind!=="permission"||!t?!1:!!((n=e.ask.choices.find(r=>r.id===t))!=null&&n.kind.startsWith("allow"))}function mx(e,t,n){const r=t?e.findLastIndex(o=>o.kind==="tool"&&o.id===t):-1;return r===-1?[...e,n]:[...e.slice(0,r),...e.slice(r+1),n]}function Qz(e){let t=e;const n=new Set;return{getState:()=>t,dispatch(r){const o=$i(t,r);if(o!==t){t=o;for(const s of n)s()}},subscribe(r){return n.add(r),()=>n.delete(r)}}}const cN=E.createContext(null),Yw=E.createContext(null),uN=E.createContext(null);function Jz({store:e,sock:t,files:n,children:r}){return d.jsx(cN.Provider,{value:e,children:d.jsx(Yw.Provider,{value:t,children:d.jsx(uN.Provider,{value:n,children:r})})})}const dN=E.createContext(null),fN=E.createContext(null);function e3({machines:e,children:t}){const n=E.useSyncExternalStore(e.subscribe,e.active);return d.jsx(dN.Provider,{value:e,children:d.jsx(fN.Provider,{value:n,children:d.jsx(Jz,{store:n.store,sock:n.sock,files:n.files,children:d.jsx(E.Fragment,{children:t},n.origin)})})})}function ys(){const e=E.useContext(dN);if(!e)throw new Error("useMachines outside <MachinesProvider>");return e}function Bs(){const e=E.useContext(fN);if(!e)throw new Error("useMachine outside <MachinesProvider>");return e}function Xw(){const e=ys();return E.useSyncExternalStore(e.subscribe,e.list)}function Xc(e,t){return E.useSyncExternalStore(e.store.subscribe,()=>t(e.store.getState()))}const fk=(e,t)=>e.length===t.length&&e.every((n,r)=>n===t[r]);function hN(){const e=ys(),t=Bs(),n=Xw(),r=E.useMemo(()=>n.filter(c=>c!==t),[n,t]),o=E.useRef(null),s=E.useCallback(c=>{const u=r.map(f=>f.store.subscribe(c));return()=>{for(const f of u)f()}},[r]),a=E.useCallback(()=>{const c=r.map(m=>e.displayName(m.origin)),u=r.map(m=>m.store.getState().repos),f=o.current;if(f&&f.others===r&&fk(f.names,c)&&fk(f.repos,u))return f.value;const h=r.map((m,g)=>({origin:m.origin,name:c[g]??m.origin,repos:u[g]??[]}));return o.current={others:r,names:c,repos:u,value:h},h},[r,e]);return E.useSyncExternalStore(s,a)}function pN(){const e=Bs(),t=Xw(),n=E.useMemo(()=>t.filter(a=>a!==e),[t,e]),r=E.useRef(null),o=E.useCallback(a=>{const c=n.map(u=>u.store.subscribe(a));return()=>{for(const u of c)u()}},[n]),s=E.useCallback(()=>{const a=n.map(f=>{const h=f.store.getState();return h.connected&&!h.incompatible?h.rows:gx}),c=r.current;if(c&&c.others===n&&fk(c.rows,a))return c.value;const u=n.map((f,h)=>({origin:f.origin,rows:(a[h]??gx).filter(Nn)}));return r.current={others:n,rows:a,value:u},u},[n]);return E.useSyncExternalStore(o,s)}const gx=[];function KY(){return Bs().terminals}function Dn(){const e=E.useContext(cN);if(!e)throw new Error("useStore outside <StoreProvider>");return e}function L(e){const t=Dn();return E.useSyncExternalStore(t.subscribe,()=>e(t.getState()))}function Qw(){const e=L(n=>n.systemDark),t=L(n=>{var r;return(r=n.daylight)==null?void 0:r.dark});return{system:e,daylight:t??e}}function dt(){return Dn().dispatch}function Qe(){return E.useContext(Yw)}function Lr(){const e=E.useContext(Yw);return(e==null?void 0:e.urls)??Aw(location.origin,"")}function Jw(){return E.useContext(uN)}function t3(e=!1,t=!0){const n=E.useRef(null);return E.useEffect(()=>{if(!t)return;const r=()=>{const s=n.current;!s||document.activeElement===s||(s.focus(),e&&s instanceof HTMLInputElement&&s.select())};r();const o=requestAnimationFrame(r);return()=>cancelAnimationFrame(o)},[e,t]),n}function ps(e,t,n,r=n3){const o=()=>{try{return n(r.get(e))??t}catch{return t}},[s,a]=E.useState(()=>({key:e,value:o()}));return s.key!==e&&a({key:e,value:o()}),[s.key===e?s.value:o(),f=>{a({key:e,value:f});try{r.set(e,typeof f=="boolean"?f?"1":"0":String(f))}catch{}}]}const n3={get:e=>localStorage.getItem(e),set:(e,t)=>localStorage.setItem(e,t)};function Hl(e,t){return n=>{n.preventDefault(),document.body.classList.add("resizing");const r=n.currentTarget;r.classList.add("active");const o=a=>{const c=e(a,r);c!==null&&t(c)},s=()=>{document.body.classList.remove("resizing"),r.classList.remove("active"),window.removeEventListener("pointermove",o),window.removeEventListener("pointerup",s)};window.addEventListener("pointermove",o),window.addEventListener("pointerup",s)}}function mN(e,t){const[n,r]=E.useState(!1);return E.useEffect(()=>{if(!e){r(!1);return}const o=setTimeout(()=>r(!0),t);return()=>clearTimeout(o)},[e,t]),n}function ey(e,t){const[n,r]=E.useState(void 0);return E.useEffect(()=>{if(e===void 0){r(void 0);return}const o=setTimeout(()=>r(e),t);return()=>clearTimeout(o)},[e,t]),n}function qY(){const[e,t]=E.useState(!1);return E.useEffect(()=>{var r;let n=!0;return(r=document.fonts)==null||r.ready.then(()=>{n&&t(!0)}),()=>{n=!1}},[]),e}const ty=1500;function Ci(e){const[t,n]=E.useState(()=>Date.now()),r=e!==void 0;return E.useEffect(()=>{if(!r)return;n(Date.now());const o=setInterval(()=>n(Date.now()),1e3);return()=>clearInterval(o)},[r]),r?Math.max(0,Math.floor((t-e)/1e3)):0}function r3(){const[e,t]=E.useState(window.innerWidth);return E.useEffect(()=>{const n=()=>t(window.innerWidth);return window.addEventListener("resize",n),()=>window.removeEventListener("resize",n)},[]),e}function o3(e){const t=E.useRef(null);return E.useLayoutEffect(()=>{const n=t.current;if(!n)return;t.current=null;const r=n.closest(e);if(!r)return;const o=r.getBoundingClientRect(),s=n.getBoundingClientRect(),a=parseFloat(getComputedStyle(r).getPropertyValue("--scroll-foot"))||0,c=s.bottom-(o.bottom-a);if(c<=0)return;const u=parseFloat(getComputedStyle(r).paddingTop)||0;r.scrollTop+=Math.min(c,Math.max(0,s.top-o.top-u))}),n=>{t.current=n}}const hg=40,s3=1200,i3=150,a3=new Set(["ArrowUp","ArrowDown","PageUp","PageDown","Home","End"," "]);function gN(e,t){const n=E.useRef(!0),r=E.useRef(Number.NEGATIVE_INFINITY),o=E.useRef(!1),[s,a]=E.useState(!1),[c,u]=E.useState(!1),[f,h]=E.useState(!1),[m,g]=E.useState(null),y=E.useCallback(A=>{n.current=A,e.current&&(e.current.style.overflowAnchor=A?"none":"")},[e]),w=E.useRef(null),v=E.useRef(null);at([t],()=>{n.current||h(!0)});const _=E.useCallback(()=>n.current,[]),x=E.useCallback(()=>{const A=e.current;A&&(y(A.scrollHeight-A.scrollTop-A.clientHeight<hg),a(!n.current),u(A.scrollTop>=hg),n.current&&h(!1))},[e,y]),N=E.useCallback(A=>{Math.abs(A)<4||(g(A<0?"up":"down"),v.current&&clearTimeout(v.current),v.current=setTimeout(()=>g(null),s3))},[]),T=E.useCallback(()=>{const A=e.current;A&&(A.scrollTop=A.scrollHeight,y(!0),a(!1),h(!1))},[e,y]),j=E.useCallback(()=>{const A=e.current;A&&(r.current=performance.now(),A.scrollTop=0)},[e]);return E.useEffect(()=>{const A=e.current;if(!A)return;y(n.current);const R=()=>o.current||performance.now()-r.current<i3,C=()=>{n.current&&!R()?u(A.scrollTop>=hg):x()};A.addEventListener("scroll",C,{passive:!0});const M=()=>{r.current=performance.now()},I=$=>{M(),N($.deltaY)},D=$=>{var Q;M(),w.current=((Q=$.touches[0])==null?void 0:Q.clientY)??null},H=$=>{var q;M();const Q=(q=$.touches[0])==null?void 0:q.clientY;Q===void 0||w.current===null||(N(w.current-Q),w.current=Q)},Z=()=>{o.current=!0},B=()=>{o.current=!1},J=$=>{if(!a3.has($.key))return;const Q=$.target;(Q===document.body||Q instanceof Node&&A.contains(Q))&&M()};A.addEventListener("wheel",I,{passive:!0}),A.addEventListener("touchstart",D,{passive:!0}),A.addEventListener("touchmove",H,{passive:!0}),A.addEventListener("pointerdown",Z,{passive:!0}),window.addEventListener("pointerup",B,{passive:!0}),window.addEventListener("pointercancel",B,{passive:!0}),document.addEventListener("keydown",J);const V=()=>{A.scrollTop=A.scrollHeight},ee=new ResizeObserver(()=>{n.current&&V()});ee.observe(A);for(const $ of A.children)ee.observe($);const F=new MutationObserver($=>{for(const Q of $){for(const q of Q.addedNodes)q instanceof Element&&ee.observe(q);for(const q of Q.removedNodes)q instanceof Element&&ee.unobserve(q)}n.current&&V()});return F.observe(A,{childList:!0}),()=>{A.removeEventListener("scroll",C),A.removeEventListener("wheel",I),A.removeEventListener("touchstart",D),A.removeEventListener("touchmove",H),A.removeEventListener("pointerdown",Z),window.removeEventListener("pointerup",B),window.removeEventListener("pointercancel",B),document.removeEventListener("keydown",J),F.disconnect(),ee.disconnect(),v.current&&clearTimeout(v.current)}},[e,x,N,y]),{offEnd:s,offStart:c,away:f,moving:m,pinned:_,jump:T,start:j,read:x}}function kx(e,t,n){const r=document.createRange();return r.selectNodeContents(e),r.setEnd(t,n),r.toString().length}function wx(e,t){const n=document.createTreeWalker(e,NodeFilter.SHOW_TEXT);let r=0,o=null;for(let s=n.nextNode();s;s=n.nextNode()){if(r+s.data.length>=t)return[s,t-r];r+=s.data.length,o=s}return o?[o,o.data.length]:[e,0]}function kN(e,t){E.useLayoutEffect(()=>{const n=e.current;if(!n)return;const r=window.getSelection(),o=g=>!!g&&n.contains(g),s=r&&r.rangeCount>0&&o(r.anchorNode)?kx(n,r.anchorNode,r.anchorOffset):null,a=r&&r.rangeCount>0&&o(r.focusNode)?kx(n,r.focusNode,r.focusOffset):null,c=r&&(s!==null||a!==null)?[r.anchorNode,r.anchorOffset,r.focusNode,r.focusOffset]:null;if(n.innerHTML=t,!r||!c)return;const[u,f]=s===null?[c[0],c[1]]:wx(n,s),[h,m]=a===null?[c[2],c[3]]:wx(n,a);u&&h&&r.setBaseAndExtent(u,f,h,m)},[e,t])}function at(e,t){const n=E.useRef(t);n.current=t,E.useEffect(()=>n.current(),e)}function wN(e){const[t,n]=E.useState({left:0,right:0});return E.useLayoutEffect(()=>{if(!e)return;const r=()=>{const s=e.getBoundingClientRect();let{left:a,right:c}=s;const u=e.closest("[data-pinned]");if(u){const h=u.getBoundingClientRect(),m=u.offsetWidth/h.width;a=u.offsetLeft+(a-h.left)*m,c=u.offsetLeft+(c-h.left)*m}const f={left:Math.round(a),right:Math.round(c)};n(h=>h.left===f.left&&h.right===f.right?h:f)};r();const o=new ResizeObserver(r);return o.observe(e),window.addEventListener("resize",r),()=>{o.disconnect(),window.removeEventListener("resize",r)}},[e]),t}function yx(){const[e,t]=E.useState(null);return[t,wN(e)]}function ZY(e){e.ctrlKey&&e.stopPropagation()}function yN(e,t){return e.defaultPrevented||e.ctrlKey?!1:t<1.01}function GY(e){E.useEffect(()=>{const t=e.current;if(!t)return;const n=r=>{var o;yN(r,((o=window.visualViewport)==null?void 0:o.scale)??1)&&r.preventDefault()};return t.addEventListener("wheel",n,{passive:!1}),()=>t.removeEventListener("wheel",n)},[e])}const vN={axis:null,dx:0,dy:0,at:Number.NEGATIVE_INFINITY},l3=2,c3=4,u3=300;function d3(e,t,n){const r=Math.abs(t.deltaX),o=Math.abs(t.deltaY),s=r>o?"x":"y",a=n-e.at<=u3?e:vN;if(a.axis===null){const u=a.dx+r,f=a.dy+o,h=Math.max(u,f)>=l3?u>f?"x":"y":null;return{scrolls:h!==null&&h===s,next:{axis:h,dx:u,dy:f,at:n}}}return s===a.axis?{scrolls:!0,next:{...a,at:n}}:(s==="x"?r:o)>=c3?{scrolls:!0,next:{...a,axis:s,at:n}}:{scrolls:!1,next:{...a,at:n}}}function VY(e){E.useEffect(()=>{const t=e.current;if(!t)return;let n=vN;const r=o=>{var c;if(o.ctrlKey)return;const{scrolls:s,next:a}=d3(n,o,o.timeStamp);n=a,!s&&(o.stopPropagation(),yN(o,((c=window.visualViewport)==null?void 0:c.scale)??1)&&o.preventDefault())};return t.addEventListener("wheel",r,{capture:!0,passive:!1}),()=>t.removeEventListener("wheel",r,{capture:!0})},[e])}function f3(e){E.useEffect(()=>{const t=window.visualViewport;if(!t)return;const n=()=>{const r=e.current;r&&(t.scale<1.01?delete r.dataset.zoomed:r.dataset.zoomed="")};return n(),t.addEventListener("resize",n),()=>t.removeEventListener("resize",n)},[e])}function h3(e){E.useEffect(()=>{const t=window.visualViewport;if(!t)return;const n=()=>{var r;(r=e.current)==null||r.style.setProperty("--visible-height",`${Math.round(t.height)}px`)};return n(),t.addEventListener("resize",n),()=>t.removeEventListener("resize",n)},[e])}function p3(e){E.useEffect(()=>{const t=window.visualViewport;if(!t)return;const n=()=>{const r=e.current;if(r){if(t.scale<1.01){delete r.dataset.pinned;return}r.dataset.pinned="",r.style.setProperty("--pin-x",`${t.offsetLeft}px`),r.style.setProperty("--pin-y",`${t.offsetTop}px`),r.style.setProperty("--pin-scale",String(1/t.scale))}};return n(),t.addEventListener("resize",n),t.addEventListener("scroll",n),()=>{t.removeEventListener("resize",n),t.removeEventListener("scroll",n)}},[e])}function m3(e,t,n){const[r,o]=E.useState(),s=E.useRef(e);return s.current=e,E.useEffect(()=>{if(!n)return;let a=!0,c;const u=()=>void s.current().then(f=>{a&&(o(f),c=setTimeout(u,t))});return u(),()=>{a=!1,clearTimeout(c)}},[t,n]),r}const ac=()=>L(e=>e.activeId),bN=()=>mN(!L(e=>e.connected),900),g3=e=>!e.connected&&(e.connectFailure==="down"||e.connectFailure==="blocked"),xN=()=>L(g3),Us=()=>L(e=>Kt(e,e.activeId)),ny=()=>L(e=>uo(e,e.activeId)),EN=()=>L(e=>e.rows),ry=()=>L(e=>e.visible),k3=()=>L(e=>e.visibleDiscovered),w3=()=>L(e=>e.activeRepoId?e.discoveredOpen[e.activeRepoId]??!1:!1),vx=[],y3=()=>L(e=>e.activeRepoId?e.archived[e.activeRepoId]??vx:vx),v3=()=>L(e=>e.activeRepoId?e.archivedOpen[e.activeRepoId]??!1:!1),b3=()=>L(e=>!(e.activeRepoId&&e.committedShut[e.activeRepoId])),x3=()=>L(e=>!!(e.activeRepoId&&e.turnOpen[e.activeRepoId])),za=()=>L(Uo),oy=()=>L(Vw),E3=()=>L(e=>ws(e,e.activeRepoId)),lc=()=>L(e=>ws(e,Zw(e))),SN=e=>L(t=>Mr(t,e)),It=(e,t)=>L(n=>Mr(n,e)[t]),S3=()=>L(e=>e.overlay),op=()=>L(hz),_N=()=>L(U_),Wu=()=>L(pz),Ku=()=>L(No),_3=()=>L(e=>e.newProject),Bi=()=>L(e=>e.touch),qu=e=>L(t=>t.chatSide==="left"==(e==="chat")?"right":"left"),N3=()=>L(e=>e.draft),sy=()=>L(Ll),j3=()=>L(e=>{const t=uo(e,e.activeId),n=t?e.repos.find(r=>r.id===t.repoId):null;return lh(n)?n:null});function T3(e){return e.image?{kind:"image",blob:e.image,sig:`image:${e.image.type}:${e.image.size}`}:e.text&&r_(e.text)?{kind:"text",text:e.text,sig:`text:${e.text}`}:null}function $3(){try{return localStorage.getItem(tt.clipboardOffer)==="1"}catch{return!1}}let zs={access:"none",on:typeof localStorage<"u"&&$3(),offer:null},hk="";const pk=new Set;function sp(e){zs={...zs,...e};for(const t of pk)t()}async function C3(){let e,t;for(const n of await navigator.clipboard.read()){const r=n.types.find(o=>o.startsWith("image/"));r?e??(e=await n.getType(r)):n.types.includes("text/plain")&&(t??(t=await(await n.getType("text/plain")).text()))}return T3({image:e,text:t})}async function ip({taken:e=!1,asking:t=!1}={}){if(!zs.on||!(zs.access==="granted"||t&&zs.access==="prompt"))return;let n;try{n=await C3()}catch{return}e&&(hk=(n==null?void 0:n.sig)??""),sp({offer:n&&n.sig!==hk?n:null})}const I3=()=>void ip();let bx=!1;function A3(){var e,t;bx||(bx=!0,!(!((e=navigator.clipboard)!=null&&e.read)||!((t=navigator.permissions)!=null&&t.query))&&navigator.permissions.query({name:"clipboard-read"}).then(n=>{const r=()=>{sp({access:n.state,...n.state==="denied"?{offer:null}:{}})};n.onchange=r,r(),window.addEventListener("focus",I3),document.hasFocus()&&ip()},()=>{}))}function R3(e){return pk.add(e),A3(),()=>{pk.delete(e)}}const O3=()=>zs;function M3(e){try{localStorage.setItem(tt.clipboardOffer,e?"1":"0")}catch{}sp({on:e,offer:null}),e&&ip({asking:!0})}function NN(){zs.offer&&(hk=zs.offer.sig),sp({offer:null})}const L3=()=>void ip({taken:!0});function P3(){return E.useSyncExternalStore(R3,()=>zs.offer)}const jN="application/x-toyon-source";function YY(e){const t=e.endColumn===1&&e.endLineNumber>e.startLineNumber?e.endLineNumber-1:e.endLineNumber;return{startLine:e.startLineNumber,endLine:t}}function D3(e,t){e.setData(jN,JSON.stringify(t))}const xx=e=>typeof e=="number"&&Number.isInteger(e)&&e>=1;function z3(e,t){const n=e.getData(jN);if(!n||!t)return null;let r;try{r=JSON.parse(n)}catch{return null}if(!r||r.worktreeId!==t||typeof r.path!="string"||!r.path)return null;const{startLine:o,endLine:s,ref:a}=r;return!xx(o)||!xx(s)||s<o?null:{path:r.path,startLine:o,endLine:s,...typeof a=="string"?{ref:a}:{}}}const TN=e=>({left:e.x,top:e.y,right:e.x,bottom:e.y});function F3(e,t){return t.matchWidth===void 0?void 0:Math.max(0,e.right-e.left+t.matchWidth)}const B3=new Set(["top","bottom"]),pg={top:"bottom",bottom:"top",left:"right",right:"left"};function mg(e,t,n,r,o){const s=n==="top"||n==="left";return o?s?e.end+r-t:e.start-r:s?e.start-r-t:e.end+r}function Ex(e,t,n,r,o){return n==="top"||n==="left"?e>=o:e+t<=r-o}function gg(e,t,n,r){return n==="center"?e.start+(e.end-e.start)/2-t/2:n==="start"?e.start-r:e.end+r-t}function Sx(e,t,n,r,o){return n==="start"?e+t<=r-o:e>=o}const _x=(e,t,n,r)=>n||!r?e:t,Nx=(e,t,n,r)=>Math.max(r,Math.min(e,n-r-t));function U3(e,t,n,r){const{offset:o=0,alignOffset:s=0,cover:a=!1,flip:c="none",margin:u=8}=r,f=B3.has(r.side),h=f?{a:{start:e.top,end:e.bottom},size:t.h,limit:n.h}:{a:{start:e.left,end:e.right},size:t.w,limit:n.w},m=f?{a:{start:e.left,end:e.right},size:t.w,limit:n.w}:{a:{start:e.top,end:e.bottom},size:t.h,limit:n.h};let g=r.side;if(c==="side"||c==="both"){const _=mg(h.a,h.size,g,o,a),x=mg(h.a,h.size,pg[g],o,a);g=_x(g,pg[g],Ex(_,h.size,g,h.limit,u),Ex(x,h.size,pg[g],h.limit,u))}let y=r.align??"center";if((c==="align"||c==="both")&&y!=="center"){const _=y==="start"?"end":"start",x=gg(m.a,m.size,y,s),N=gg(m.a,m.size,_,s);y=_x(y,_,Sx(x,m.size,y,m.limit,u),Sx(N,m.size,_,m.limit,u))}const w=Nx(mg(h.a,h.size,g,o,a),h.size,h.limit,u),v=Nx(gg(m.a,m.size,y,s),m.size,m.limit,u);return f?{x:v,y:w,side:g,align:y}:{x:w,y:v,side:g,align:y}}function H3(e,t,n){var s,a;const r=e.length;if(r===0)return-1;let o=t<0?n===1?0:r-1:(t+n+r)%r;for(let c=0;c<r&&((s=e[o])!=null&&s.disabled);c++)o=(o+n+r)%r;return(a=e[o])!=null&&a.disabled?-1:o}const $N={sep:!0},gs=e=>!("sep"in e);function ap(e){const t=[];for(const n of e)(gs(n)||t.length>0&&gs(t[t.length-1]))&&t.push(n);for(;t.length>0&&!gs(t[t.length-1]);)t.pop();return t}const Wn=e=>ap(e.flatMap((t,n)=>n?[$N,...t]:t));let Nl=null,W3=0;const mk=new Set,jx=()=>{for(const e of mk)e()},fo={get:()=>Nl,subscribe(e){return mk.add(e),()=>{mk.delete(e)}},open(e){const t=ap(e.items);if(t.length===0)return fo.close();Nl={...e,items:t,id:++W3},jx()},close(){Nl&&(Nl=null,jx())},toggle(e){Nl&&Nl.target===e.target?fo.close():fo.open(e)}};function iy(){return E.useSyncExternalStore(fo.subscribe,fo.get)}function CN(e){const t=e.nativeEvent;return t&&"pointerType"in t?t.pointerType==="":e.clientX===0&&e.clientY===0}function K3(e,t){return CN(e)?{anchor:(t.querySelector('[data-state~="cursor"]')??t).getBoundingClientRect()}:{at:{x:e.clientX,y:e.clientY}}}function q3(e){const t=e.anchor;return t?{rect:t,placement:{side:"bottom",align:e.align==="right"?"end":"start",offset:4,margin:4,...e.toggles?{flip:"side"}:{}}}:{rect:TN(e.at??{x:0,y:0}),placement:{side:"bottom",align:"start",margin:4}}}function Z3(e){if(CN(e))return"keyboard";const t=e.nativeEvent;return t&&"pointerType"in t&&t.pointerType==="touch"?"touch":"pointer"}function vn(e){return E.useMemo(()=>({contextMenu(t,n){return{onContextMenu:r=>{const o=t(Z3(r),r.target);if(o===null){r.stopPropagation();return}const s=ap(o);if(s.length===0)return;r.preventDefault(),r.stopPropagation();const a=r.currentTarget;fo.open({items:s,owner:e,key:n,target:a,...K3(r,a)})}}},dropdown(t,n="left",r,o){return{"aria-haspopup":"menu",onClick:s=>{s.stopPropagation();const a=s.currentTarget;fo.toggle({items:t(),...o?{head:o()}:{},owner:e,key:r,target:a,toggles:!0,anchor:a.getBoundingClientRect(),align:n})}}},openUnder(t,n,r){fo.open({items:n(),owner:e,key:r,target:t,toggles:!0,anchor:t.getBoundingClientRect(),align:"left"})}}),[e])}const IN=e=>({id:"open-out",label:Bw()?"open in the browser":"open in a new tab",onClick:()=>window.open(e,"_blank")}),tn=e=>{var t;return void((t=navigator.clipboard)==null?void 0:t.writeText(e).catch(()=>{}))};function AN(e,t){const n=navigator.clipboard;if(n){if(typeof ClipboardItem>"u"||!n.write){e==="text/plain"&&t.then(r=>r.text()).then(tn,()=>{});return}n.write([new ClipboardItem({[e]:t})]).catch(()=>{})}}const RN=e=>AN("text/plain",fetch(e).then(t=>t.blob())),G3=e=>AN("image/png",V3(e));async function V3(e){const t=await(await fetch(e)).blob();if(t.type==="image/png")return t;const n=await createImageBitmap(t);try{const r=document.createElement("canvas");return r.width=n.width,r.height=n.height,r.getContext("2d").drawImage(n,0,0),await new Promise((o,s)=>r.toBlob(a=>a?o(a):s(new Error("could not encode image")),"image/png"))}finally{n.close()}}function lp(e){return Ph(e)}function po(e){return(e==null?void 0:e.urls.host)??(typeof location=="object"?location.hostname:"127.0.0.1")}function Ho(e,t,n="reveal in Finder"){return!e||!lp(t)?[]:[{id:"reveal",label:n,onClick:e}]}function Y3(e,t){const n=[];for(const r of t)r.xy.includes("D")?n.push(`-${r.path}`):/[?ARC]/.test(r.xy)&&n.push(`+${r.path}`);return`${e??""}
103
- ${n.sort().join(`
104
- `)}`}function cp(e,t,{sock:n,dispatch:r}){var a,c;if(!n)return;const o=t.local[e]??Da,s=Y3((a=o.git)==null?void 0:a.head,((c=o.git)==null?void 0:c.files)??[]);o.filesFor!==s&&(r({a:"files-asked",worktreeId:e,key:s}),n.send({t:"list-files",worktreeId:e}))}const X3=["diff","file","preview"],ON=(e,t)=>X3.filter(n=>!(n==="preview"&&!Yh(e))&&!(n==="diff"&&t));let Q3=0;const _o=()=>++Q3;function Pn({dispatch:e},{focus:t=!0,...n}){e({a:"open-file",v:{...n,focus:t,seq:_o()}})}function J3({dispatch:e},t,n){e({a:"open-loose",v:{worktreeId:t,name:`PR #${n} comments`,text:"",binary:!1,tooLarge:!1,source:{kind:"pr-comments"},seq:_o()}})}const gk=new Map;function MN(e,t,n=""){const{sock:r}=e;if(!r)return Promise.resolve("not connected to the daemon");const o=_o();return new Promise(s=>{gk.set(o,a=>{a.ok?(Pn(e,{...t,view:Li(t.path)}),s(null)):s(a.reason==="changed"?"a file is already there":a.message??"the file was not made")}),r.send({t:"write-file",...t,content:n,base:null,seq:o})})}function e6(e){const t=gk.get(e.seq);return t?(gk.delete(e.seq),t(e),!0):!1}function t6({dispatch:e},t){e({a:"tree-reveal",...t})}function Ls(e,t,{discard:n=!1,ref:r,since:o,showing:s,noDiff:a=!1,kept:c=!1,select:u},f){const{sock:h,dispatch:m}=f,g=ON(t,a).filter(N=>N!==s).map(N=>({id:`view:${N}`,label:`view ${N}`,onClick:()=>s?m({a:"editor-view",v:N}):Pn(f,{worktreeId:e.id,path:t,view:N,ref:r,since:o})})),y=`${e.dir}/${t}`,w=c?[]:Ho(()=>h==null?void 0:h.send({t:"reveal",worktreeId:e.id,path:t}),po(h));return Wn([g,[{id:"copy-path",label:"copy path",onClick:()=>tn(y)}],w,u?[{id:"select",label:"select…",onClick:()=>u(t)}]:[],n?[{id:"discard",label:"discard changes…",danger:!0,onClick:()=>{window.confirm(LN([t]))&&(h==null||h.send({t:"discard-files",worktreeId:e.id,paths:[t]}))}}]:[]])}function LN(e){if(e.length===1)return`Discard uncommitted changes to ${e[0]}?`;const t=e.slice(0,12),n=e.length-t.length,r=[...t,...n>0?[`and ${n} more`]:[]].join(`
105
- `);return`Discard uncommitted changes to ${e.length} files?
106
-
107
- ${r}`}const jo=(e,t,n)=>e.dispatch({a:"notice",id:t,text:n});function up(e,t,n){var o;const r=wA(((o=e.getState().local[t])==null?void 0:o.attachments)??[],n);return r===0&&jo(e,t,hw(n)),r}const n6=1e3,r6=1e4,PN=new WeakMap;function o6(e,t){PN.set(e,t)}async function DN(e,t,n,r){var w,v;const{local:o,...s}=n;e.dispatch({a:"attach",id:t,items:[{...n,upload:"",uploading:!0}]});const a=()=>{var _;return(_=Object.entries(e.getState().local).find(([,x])=>x.attachments.some(N=>N.key===n.key)))==null?void 0:_[0]},c=PN.get(e);let u=-1;const f=_=>{const x=Math.min(99,Math.floor(_*100)),N=a();x===u||N===void 0||(u=x,e.dispatch({a:"upload-progress",id:N,key:n.key,progress:x}))},h=()=>(u=-1,c?JD(c,n.kind,r,f):Promise.resolve(null));let m=await h();const g=m===null;g&&jo(e,a()??t,`${n.name}: Toyon is not answering; it attaches once it is back`);for(let _=n6;m===null&&a()!==void 0;_=Math.min(_*2,r6))await new Promise(x=>setTimeout(x,_)),a()!==void 0&&(m=await h());const y=a();if(!(m===null||y===void 0))if(typeof m=="string")e.dispatch({a:"detach",id:y,key:n.key}),jo(e,y,`${n.name}: ${m}`);else{const _=s.kind==="file"?{...s,...m}:{...s,upload:m.upload,bytes:m.bytes};e.dispatch({a:"attached",id:y,key:n.key,item:_});const x=(v=e.getState().local[((w=ms(y))==null?void 0:w.source)??y])==null?void 0:v.notice;g&&(x!=null&&x.startsWith(`${n.name}: Toyon is not answering`))&&jo(e,y,"")}o&&URL.revokeObjectURL(o)}function ay(e,t,n){if(!t||n.length===0)return;const r=up(e,t,"file");if(r!==0){for(const o of n.slice(0,r)){const s=o.name||"file";if(o.size>Vb){jo(e,t,`${s}: larger than ${mw(Vb)}`);continue}const a={kind:"file",key:crypto.randomUUID(),upload:"",name:s,bytes:o.size,text:!1};DN(e,t,a,o)}n.length>r&&jo(e,t,`kept ${r} of ${n.length}: ${hw("file")}`)}}function ly(e,t,n,r={}){if(!t)return;const o=zP(r.source?n.replace(/\r?\n$/,""):n);if(o.length>IP)return r.source?jo(e,t,"that paste is too large; save it in the worktree and reference it with @path"):ay(e,t,[new File([o],AP,{type:"text/plain"})]);up(e,t,"paste")!==0&&e.dispatch({a:"attach",id:t,items:[{kind:"paste",key:crypto.randomUUID(),text:o,...r,...jw(o)}]})}function zN(e,t,n,r){e.dispatch({a:"set-draft",id:n,text:""}),t==null||t.send({t:"unqueue",worktreeId:n,index:r,edit:!0})}function Hf(e,t){var s;const n=e.getState(),r=Kt(n,n.activeId),o=Pa(r);if(t&&o&&t.worktreeId===(r==null?void 0:r.worktree.id)&&t.text.trim()){const a="source"in t?{source:t.source}:{name:t.name};(((s=n.local[o])==null?void 0:s.attachments)??[]).some(u=>{var y;if(u.kind!=="paste")return!1;if(!("source"in t))return u.name===t.name&&u.text===t.text;const{path:f,startLine:h,endLine:m,ref:g}=t.source;return((y=u.source)==null?void 0:y.path)===f&&u.source.startLine===h&&u.source.endLine===m&&u.source.ref===g})||ly(e,o,t.text,a)}e.dispatch(t?{a:"focus-chat"}:H_(n))}function cy(e,t){return t!==e.activeId?null:Pa(Kt(e,t))}const FN=(e,t)=>`@${e}${t?"/":""}`,uy=e=>`${e.map(t=>FN(t.path,t.folder)).join(" ")} `;function BN(e,t,n){const r=t>0&&!/\s/.test(e[t-1]??"")?" ":"";return{text:`${e.slice(0,t)}${r}${n}${e.slice(t)}`,caret:t+r.length+n.length}}function UN(e,t,n){var o;const r=((o=e.getState().local[t])==null?void 0:o.draft)??"";e.dispatch({a:"set-draft",id:t,text:BN(r,r.length,n).text}),e.dispatch({a:"focus-chat"})}function dy(e,t,n){const r=cy(e.getState(),t);r&&UN(e,r,n)}function s6(e,t,n,r){dy(e,t,uy([{path:n,folder:r}]))}function i6(e,t,n){n.length!==0&&dy(e,t,uy(n.map(r=>({path:r,folder:!1}))))}function Tx(e,t,n){dy(e,t,n)}function a6(e,t){return Kt(e,t)?t:null}function l6(e,t){var r;const n=(r=Kt(e,t))==null?void 0:r.worktree;return n?[n.path]:[]}function $x(e,t){if(!e)return e;const n=t.find(r=>e.startsWith(`${r}/`));return n?e.slice(n.length+1):e}function c6(e,t,n){var g;e.dispatch({a:"set-picking",v:!1});const r=e.getState(),o=a6(r,t);if(!o)return;const{classes:s,route:a,element:c,...u}=n,f=l6(r,t),h={...u,file:$x(u.file,f),callFile:$x(u.callFile,f)};!(((g=r.local[o])==null?void 0:g.attachments)??[]).some(y=>y.kind==="pick"&&y.selector===h.selector)&&up(e,o,"pick")>0&&e.dispatch({a:"attach",id:o,items:[{kind:"pick",key:crypto.randomUUID(),...h}]}),e.dispatch({a:"focus-chat"})}function u6(e,t=[],n=[]){const r={path:"",name:"",kind:"folder",children:[],ignored:!1},o=new Map([["",r]]),s=u=>{const f=o.get(u);if(f)return f;const h=u.lastIndexOf("/"),m={path:u,name:u.slice(h+1),kind:"folder",children:[],ignored:!1};return s(h===-1?"":u.slice(0,h)).children.push(m),o.set(u,m),m},a=(u,f,h=!1)=>{const m=u.lastIndexOf("/");s(m===-1?"":u.slice(0,m)).children.push({path:u,name:u.slice(m+1),kind:f,children:[],ignored:h})};for(const u of e)a(u,"file");for(const u of t)a(u,"submodule");for(const u of n)u.endsWith("/")?a(u.slice(0,-1),"ignored",!0):a(u,"file",!0);const c=u=>{const f=h=>h.kind==="file"?1:0;u.children.sort((h,m)=>f(h)-f(m)||A_(h.name,m.name));for(const h of u.children)h.kind==="folder"&&c(h)};return c(r),r.children}function d6(e,t){const n=[],r=(o,s)=>{for(const a of o){const c=a.kind==="folder"&&t(a.path);n.push({path:a.path,name:a.name,depth:s,kind:a.kind,open:c,ignored:a.ignored}),c&&r(a.children,s+1)}};return r(e,0),n}const HN=e=>{const t=e.lastIndexOf("/");return t===-1?"":e.slice(0,t)};function f6(e,t){const n=t.trim().replace(/^(\.\/|\/)+/,"");return n===""?{error:"name the file"}:n.endsWith("/")?{error:"name a file: its folders are made with it"}:n.split("/").some(o=>o===""||o==="."||o==="..")?{error:"a plain path, inside the worktree"}:{path:e?`${e}/${n}`:n}}function h6(e){const t=new Map,n=new Set;for(const r of e){const o=r.path.endsWith("/")?r.path.slice(0,-1):r.path;o===r.path?t.set(o,r):n.add(o);for(const s of ah(o))n.add(s)}return{files:t,folders:n}}function p6(e){const t=e.findLast(n=>n.kind==="handoff"&&n.state!=="declined");return(t==null?void 0:t.kind)==="handoff"?t:null}function m6(e,t,n){const r=e.findLast(o=>o.kind==="handoff"&&o.state!=="declined"&&(o.plan??n)===t);return(r==null?void 0:r.kind)==="handoff"?r:null}function g6(e){return e.pieces.flatMap(t=>{const n=e.outcomes.find(o=>o.pieceId===t.id),r=(n==null?void 0:n.fate)==="worktree"?n.worktreeId:void 0;return!r&&(Hs(e,t)!=="worktree"||t.after)?[]:[{pieceId:t.id,title:(n==null?void 0:n.title)??t.title,...r?{worktreeId:r}:{},...n!=null&&n.repoName?{repoName:n.repoName}:{}}]})}function k6(e){return!!e.plan&&!e.companion}function w6(e,t){const n=e.findIndex(o=>o.kind==="tool"&&o.id===t);if(n<0)return;const r=e.slice(n+1).find(o=>o.kind==="handoff");return(r==null?void 0:r.kind)==="handoff"?r.plan:void 0}function Hs(e,t){return e.fates[t.id]??t.fate}function Zu(e,t){var r;const n=t.after;return n?"piece"in n?{kind:"piece",title:((r=e.pieces.find(o=>o.id===n.piece))==null?void 0:r.title)??"another piece"}:{kind:"branch",...n}:null}function WN(e){const t={worktrees:0,queued:0,sent:0,here:0,skipped:0};for(const n of e.pieces){const r=Hs(e,n);r==="worktree"?n.after?t.queued++:t.worktrees++:r==="send"?t.sent++:r==="here"?t.here++:t.skipped++}return t}const KN=(e,t,n=`${t}s`)=>`${e} ${e===1?t:n}`,y6=e=>e.length<=1?e[0]??"":`${e.slice(0,-1).join(", ")} and ${e.at(-1)}`;function v6(e,t){const n=WN(e),r=[];if(n.here&&r.push("this plan here"),n.worktrees&&r.push(`${KN(n.worktrees,"worktree")} now`),n.queued){const s=e.pieces.filter(u=>Hs(e,u)==="worktree"&&u.after),a=s.every(u=>u.after&&"id"in u.after&&u.after.id===t),c=s.length===1?Zu(e,s[0]):null;r.push(a?`${n.queued} when this branch lands`:c?`1 when ${c.kind==="branch"?c.branch:c.title} lands`:`${n.queued} queued`)}n.sent&&r.push(`${n.sent} sent on`);const o=n.skipped?`; ${n.skipped} skipped`:"";return r.length===0?`Starts nothing${o}.`:`Starts ${y6(r)}${o}.`}function kk(e){var s;const t=e.pieces.length===1?e.pieces[0]:void 0;if(t)return t.fate==="send"?`Send ${t.title} to ${((s=t.to)==null?void 0:s.title)??"the worktree"}?`:t.fate==="here"?`Keep ${t.title} here?`:t.project?`Continue in ${t.project.name}?`:t.after?`Queue a worktree for ${t.title}?`:`Start a worktree for ${t.title}?`;const n=WN(e),o=[n.worktrees?`start ${KN(n.worktrees,"worktree")}`:"",n.queued?`queue ${n.queued}`:"",n.sent?`send ${n.sent}`:"",n.here?`do ${n.here} here`:"",n.skipped?`skip ${n.skipped}`:""].filter(Boolean).join(", ");return`${o.charAt(0).toUpperCase()}${o.slice(1)}?`}function qN(e,t){var c;const n=Zu(e,t),r=n?` once ${n.kind==="branch"?n.branch:n.title} lands`:"",o=t.project?{fate:"worktree",label:`start a worktree in ${t.project.name}`,description:`a copy of that project, with this text as its plan${r}`}:{fate:"worktree",label:n?"queue a worktree":"start a worktree",description:`a copy of this project, with this text as its plan${r}`},s={fate:"here",label:"do it here",description:"this worktree's agent, after its turn"},a={fate:null,label:"not now"};return t.fate==="send"?[{fate:"send",label:`send to ${((c=t.to)==null?void 0:c.title)??"the worktree"}`,description:"that worktree's agent, as a message"},a]:t.fate==="here"?[s,o,a]:t.project?[o,a]:[o,s,a]}function b6(e,t){var n;return t==="worktree"?e.project?`new worktree in ${e.project.name}`:"new worktree":t==="here"?"here":t==="skip"?"skip":`sent to ${((n=e.to)==null?void 0:n.title)??"the worktree"}`}function x6(e,t,n){var r;if(t==="worktree"){const o=e.project?` in ${e.project.name}`:"",s=n?`, once ${n.kind==="branch"?n.branch:n.title} lands`:"";return`Starts as a new worktree${o}${s}, with this text as its plan.`}return t==="here"?"This worktree's agent does it.":t==="send"?`Goes to ${((r=e.to)==null?void 0:r.title)??"that worktree"}'s agent as a message.`:"Skipped: nothing happens to it."}function E6(e){var s;const t=e.answered;if(!t)return null;if(!t.go)return"not now";const n=e.pieces.length===1?e.pieces[0]:void 0,o=(n?(s=qN(e,n).find(a=>a.fate===Hs(e,n)))==null?void 0:s.label:void 0)??"go";return t.note?`${o}
108
- ${t.note}`:o}function Cx(e,t,n,r){const o=n?r==null?void 0:r.trim():void 0;return{t:"handoff-answer",worktreeId:t,id:e.id,go:n,...o?{note:o}:{}}}function ZN(e,t,n,r){return{t:"handoff-fate",worktreeId:t,id:e.id,pieceId:n,fate:r}}function S6(e,t=[]){if(e.fate==="send")return["send","skip"];const n=e.after;return!!n&&"piece"in n&&t.findIndex(o=>o.id===n.piece)>t.findIndex(o=>o.id===e.id)?["here","skip"]:e.project?["worktree","skip"]:["here","worktree","skip"]}const Nu=e=>e.state==="held"||e.state==="proposed";function GN(e){const t=n=>n.fate==="here"?0:n.fate==="worktree"?n.after?2:1:3;return[...e.pieces].sort((n,r)=>t(n)-t(r))}function _6(e,t){const n=Zu(e,t),r=n?{word:`after ${n.title}`}:null;if(Nu(e)){const s=Hs(e,t);return s==="worktree"?{word:t.after?"queued":"worktree"}:s==="send"?{word:"sent"}:s==="here"&&r?r:{word:s}}const o=ju(e,t);return o.kind==="worktree"||o.kind==="sent"&&o.worktreeId?{worktreeId:o.worktreeId,...o.title?{title:o.title}:{}}:o.kind==="here"&&r?r:{word:o.kind==="sent"?"sent":o.kind}}function N6(e,t,n){if(n||Nu(e))return!0;const r=ju(e,t);return r.kind==="here"?!!t.after:r.kind!=="skipped"&&r.kind!=="starting"}function ju(e,t){if(e.state==="going")return{kind:"starting"};const n=e.outcomes.find(a=>a.pieceId===t.id),r=e.later.findLast(a=>a.pieceId===t.id);if(!n)return{kind:"skipped"};if(n.error)return{kind:"failed",error:n.error};if(n.fate==="here")return{kind:"here"};if(n.fate==="skip")return{kind:"skipped"};const o=n.repoName?{repoName:n.repoName}:{};if(n.fate==="send")return{kind:"sent",...n.worktreeId?{worktreeId:n.worktreeId}:{},...n.title?{title:n.title}:{},...o};const s=n.worktreeId?n:r!=null&&r.worktreeId?r:null;return s!=null&&s.worktreeId?{kind:"worktree",worktreeId:s.worktreeId,...s.title?{title:s.title}:{},..."repoName"in s&&s.repoName?{repoName:s.repoName}:{}}:r!=null&&r.reason?{kind:"dropped",reason:r.reason}:{kind:"queued",after:Zu(e,t),...n.after?{said:n.after}:{}}}function j6(e,t){var o;if(t)return"plan";const n=GN(e),r=Nu(e)?void 0:n.find(s=>Hs(e,s)==="here");return(r==null?void 0:r.id)??((o=n[0])==null?void 0:o.id)??"plan"}function T6(e){if(e.state!=="done")return[];const t=new Map;for(const n of e.pieces){const r=n.after;if(!r||Hs(e,n)!=="here")continue;if("id"in r){t.set(r.id,r.title);continue}const o=e.pieces.find(a=>a.id===r.piece),s=o?ju(e,o):null;((s==null?void 0:s.kind)==="worktree"||(s==null?void 0:s.kind)==="sent"&&s.worktreeId)&&t.set(s.worktreeId,s.title??(o==null?void 0:o.title)??"the worktree")}return[...t].map(([n,r])=>({id:n,title:r}))}function fy(e){const t=e.findLast(n=>n.kind==="ask"&&!n.outcome||n.kind==="handoff"&&n.state==="proposed");return(t==null?void 0:t.kind)==="ask"||(t==null?void 0:t.kind)==="handoff"?t:null}function $6(e){const t=e?fy(e.chat):null;return(t==null?void 0:t.kind)!=="ask"||t.ask.kind!=="question"||(e==null?void 0:e.cardParked)===t.id?null:Fl(t.id)}function C6(e){return e.kind==="ask"?w4(e):kk(e)}const VN=new Set(TP),I6=/^image\.[a-z0-9]+$/i,A6=e=>I6.test(e.name),R6=(e,t)=>e===t||e.name===t.name&&e.size===t.size&&e.type===t.type&&e.lastModified===t.lastModified;function O6(e){if(!e)return[];const t=[];for(const s of Array.from(e.items??[])){if(s.kind!=="file"||!s.type.startsWith("image/"))continue;const a=s.getAsFile();a&&t.push(a)}if(t.length===0)for(const s of Array.from(e.files??[]))s.type.startsWith("image/")&&t.push(s);const n=[];for(const s of t)n.some(a=>R6(a,s))||n.push(s);const r=n.filter(s=>!A6(s));if(r.length>0)return r;const o=n.find(s=>VN.has(s.type))??n[0];return o?[o]:[]}function M6(e){if(!e)return[];const t=[];for(const n of Array.from(e.items??[])){if(n.kind!=="file"||n.type.startsWith("image/"))continue;const r=n.getAsFile();r&&t.push(r)}if(t.length===0)for(const n of Array.from(e.files??[]))n.type.startsWith("image/")||t.push(n);return t}async function L6(e,t){if(e.size>t)return null;try{return new TextDecoder("utf-8",{fatal:!0}).decode(await e.arrayBuffer())}catch{return null}}async function P6(e){try{return await createImageBitmap(e)}catch{throw new Error(`${e.name||"image"}: not a readable image`)}}function Ix(e,t,n){const r=document.createElement("canvas");return r.width=Math.max(1,Math.round(e.width*t)),r.height=Math.max(1,Math.round(e.height*t)),r.getContext("2d").drawImage(e,0,0,r.width,r.height),new Promise((o,s)=>r.toBlob(a=>a?o(a):s(new Error("could not encode image")),n,.9))}async function D6(e){const t=await P6(e);try{const n=Math.max(t.width,t.height);let r=e,o=e.type,s=t.width,a=t.height;if(!VN.has(o)||n>Gb||e.size>ug){const c=o==="image/jpeg"?"image/jpeg":"image/png";let u=Math.min(1,Gb/n);for(r=await Ix(t,u,c);r.size>ug&&u>.1;)u*=.7,r=await Ix(t,u,c);if(r.size>ug)throw new Error(`${e.name||"image"}: too large even after downscaling`);o=c,s=Math.max(1,Math.round(t.width*u)),a=Math.max(1,Math.round(t.height*u))}return{blob:r,name:e.name||`pasted.${o==="image/jpeg"?"jpg":"png"}`,mimeType:o,width:s,height:a}}finally{t.close()}}const pu={el:null},z6=80,F6=2e3;let To=null,wk;const YN=(e,t)=>{clearTimeout(wk),wk=setTimeout(()=>py(e),t)};function hy(e,t){To??(To={refused:!1}),e.dispatch({a:"drag-files",v:To.refused?null:t}),YN(e,F6)}function XN(e){To&&YN(e,z6)}const B6=()=>(To==null?void 0:To.refused)??!1;function py(e){To&&(clearTimeout(wk),To=null,e.dispatch({a:"drag-files",v:null}))}function U6(e){To&&(To.refused=!0,e.dispatch({a:"drag-files",v:null}))}let H6=0;function W6(e){const{blob:t,...n}=e;return{kind:"image",key:`img${++H6}`,...n,upload:"",bytes:t.size,local:URL.createObjectURL(t)}}async function dp(e,t,n){var a;if(!t||n.length===0)return;const r=up(e,t,"image");if(r===0)return;const o=await Promise.allSettled(n.slice(0,r).map(D6));for(const c of o)c.status==="fulfilled"&&DN(e,t,W6(c.value),c.value.blob);const s=o.find(c=>c.status==="rejected");s?jo(e,t,String(((a=s.reason)==null?void 0:a.message)??s.reason)):n.length>r&&jo(e,t,`kept ${r} of ${n.length}: ${hw("image")}`)}function K6(e,t,n){n.kind==="image"?dp(e,t,[new File([n.blob],"image.png",{type:n.blob.type})]):ly(e,t,n.text),NN()}function ch(e,t,n){const r=o=>o.type.startsWith("image/");dp(e,t,n.filter(r)),ay(e,t,n.filter(o=>!r(o)))}function QN(e,t){const n=document.createElement("input");n.type="file",n.multiple=!0,n.onchange=()=>ch(e,t,Array.from(n.files??[])),n.click()}function Fa(e){const t=e.getState();if(t.newProject)return Xl;const n=Uo(t)??Vw(t);if(n)return n.id;const r=Kt(t,t.activeId);return $6(r?t.local[r.worktree.id]:void 0)??Pa(r)}function JN(e,t,n=Fa(e)){ch(e,n,t.filter(o=>!o.folder).map(o=>o.file));const r=t.find(o=>o.folder);n&&r&&jo(e,n,`${r.file.name}: a folder cannot be attached; drop its files`)}const yk=Promise.resolve(null);function q6(e){var n,r,o;if(!e)return[];const t=[];for(const s of Array.from(e.items)){if(s.kind!=="file")continue;const a=s.getAsFile();if(!a)continue;const c=((n=s.getAsFileSystemHandle)==null?void 0:n.call(s).then(u=>(u==null?void 0:u.kind)==="file"?u:null,()=>null))??yk;t.push({file:a,handle:c,folder:((o=(r=s.webkitGetAsEntry)==null?void 0:r.call(s))==null?void 0:o.isDirectory)===!0})}if(t.length===0)for(const s of Array.from(e.files))t.push({file:s,handle:yk});return t}const Z6=e=>e.map(t=>({file:t,handle:yk}));async function ej(e){const t=rh*4;if(e.size>t)return{text:"",tooLarge:!0};const n=await L6(e,t);return n===null?null:n.length>rh?{text:"",tooLarge:!0}:{text:n,tooLarge:!1}}async function G6(e,t){const n=Fa(e),r=e.getState().activeId,o=h=>n&&jo(e,n,h),s=t.filter(h=>h.file.type.startsWith("image/")).map(h=>h.file);s.length&&dp(e,n,s);const a=t.filter(h=>!h.file.type.startsWith("image/")),c=a[0];if(!c||!r)return;const u=await ej(c.file);if(!u)return void o(`${c.file.name}: not a text file`);const f=await c.handle;e.dispatch({a:"open-loose",v:{worktreeId:r,name:c.file.name,...u,binary:!1,source:f?{kind:"handle",handle:f}:{kind:"bytes"},seq:_o()}}),a.length>1&&o(`opened ${c.file.name}; one file opens at a time`)}async function V6(e,t,n,r){const o=cy(e.getState(),n.worktreeId)??Fa(e),s=c=>o&&jo(e,o,c),a={sock:t,dispatch:c=>e.dispatch(c)};for(const{file:c}of r){const u=await ej(c);if(!u){s(`${c.name}: not a text file`);continue}if(u.tooLarge){s(`${c.name}: too large to add here`);continue}const f=n.dir?`${n.dir}/${c.name}`:c.name,h=await MN(a,{worktreeId:n.worktreeId,path:f},u.text);h&&s(`${c.name}: ${h}`)}}function Y6(e){const t=Fa(e);t&&jo(e,t,"drop a file on the chat to attach it, on the preview to open it, or on a folder to add it")}function tj(e,t,n,r){const o=(To==null?void 0:To.refused)??!1;py(e),!(o||r.length===0)&&(n?n.at==="chat"||n.at==="centre"&&e.getState().newProject?JN(e,r):n.at==="centre"?G6(e,r):n.at==="rail"?X6(e,n,r):V6(e,t,n,r):Y6(e))}function X6(e,t,n){const r=Kt(e.getState(),t.worktreeId);r&&(e.dispatch(Cr(r.worktree)?{a:"open-draft"}:{a:"activate",id:r.worktree.id}),JN(e,n,Pa(r)))}const vk=e=>!!e&&Array.from(e.types).includes("Files");function Ax(e,t){var c,u;const n=t instanceof Element?t:t instanceof Node?t.parentElement:null;if(!n)return null;if((c=pu.el)!=null&&c.contains(n))return Fa(e)?{at:"chat"}:null;const r=(u=n.closest(".rail [data-wt]"))==null?void 0:u.dataset.wt;if(r)return Kt(e.getState(),r)?{at:"rail",worktreeId:r}:null;const o=n.closest(".tree"),s=o==null?void 0:o.dataset.worktree;if(o&&s){const f=n.closest("[data-path]"),h=f==null?void 0:f.dataset.kind;if(h==="submodule")return null;const m=(f==null?void 0:f.dataset.path)??"";return{at:"tree",worktreeId:s,dir:h==="file"?HN(m):m}}if(!n.closest(".center-root")||n.closest('[data-pane="terminal"], [data-pane="design"]'))return null;const a=e.getState();return a.activeId||a.newProject?{at:"centre"}:null}function Q6(){const e=Dn(),t=Qe();E.useEffect(()=>{const n=a=>{a.defaultPrevented||!vk(a.dataTransfer)||(a.preventDefault(),hy(e,Ax(e,a.target)),a.dataTransfer&&(a.dataTransfer.dropEffect=e.getState().dragFiles?"copy":"none"))},r=a=>{a.defaultPrevented||!vk(a.dataTransfer)||(a.preventDefault(),tj(e,t,Ax(e,a.target),q6(a.dataTransfer)))},o=()=>XN(e),s=a=>{a.key==="Escape"&&U6(e)};return window.addEventListener("dragover",n),window.addEventListener("drop",r),window.addEventListener("dragleave",o),window.addEventListener("keydown",s,!0),()=>{window.removeEventListener("dragover",n),window.removeEventListener("drop",r),window.removeEventListener("dragleave",o),window.removeEventListener("keydown",s,!0)}},[e,t])}function nj(e,t,n){const r=Dn(),o=E.useRef(!1);return{onPaste:u=>{L3();const f=O6(u.clipboardData);if(f.length>0)return u.preventDefault(),void dp(r,e,f);const h=M6(u.clipboardData);if(h.length>0)return u.preventDefault(),ay(r,e,h);if(o.current)return;const m=u.clipboardData.getData("text/plain");if(m.trim()&&(n!=null&&n(m))){u.preventDefault();return}const g=m.trim()?z3(u.clipboardData,t):null;!(g&&m.includes(`
109
- `))&&!r_(m)||(u.preventDefault(),ly(r,e,m,g?{source:g}:{}))},onPasteKey:u=>{o.current=(u.metaKey||u.ctrlKey)&&u.shiftKey&&u.key.toLowerCase()==="v"},onPasteKeyUp:()=>{o.current=!1}}}function J6(e,t,n){const r=E.useRef(n);r.current=n,E.useEffect(()=>{const o=e.current;if(!o)return;const s=a=>{const{inputType:c,data:u,isComposing:f}=a;a.target!==t.current||f||!u||c!=="insertText"&&c!=="insertFromPaste"||r.current(u)&&a.preventDefault()};return o.addEventListener("beforeinput",s),()=>o.removeEventListener("beforeinput",s)},[e,t])}const e5=640,t5=1e3,rj=`(max-width: ${e5}px), ((hover: none) and (max-width: ${t5}px))`,oj="(hover: none)",my=()=>{var e;return(e=window.matchMedia)!=null&&e.call(window,rj).matches?"phone":"desk"},n5=()=>{var e;return((e=window.matchMedia)==null?void 0:e.call(window,oj).matches)??!1},sj=()=>window.top!==window;function r5(e){const t=(o,s)=>{var u;const a=(u=window.matchMedia)==null?void 0:u.call(window,o);if(!a)return()=>{};const c=f=>s(f.matches);return a.addEventListener("change",c),()=>a.removeEventListener("change",c)},n=t(rj,o=>e.dispatch({a:"frame",v:o?"phone":"desk"})),r=t(oj,o=>e.dispatch({a:"touch",v:o}));return()=>{n(),r()}}const ij=(e,t)=>{const n=e.indexOf("#"),[r,o]=n===-1?[e,""]:[e.slice(0,n),e.slice(n)];return`${r}${r.includes("?")?"&":"?"}${WA}=${encodeURIComponent(t)}${o}`},bk=(e,t)=>!e.serving&&t!==null,o5=3e3;function aj(e,t,n){const[r,o]=E.useState(()=>new Map),s=E.useRef(new Set),a=E.useRef(t);a.current=t;const c=E.useRef(new Map),u=E.useCallback((f,h)=>{s.current.has(f)||(s.current.add(f),w_(e.sock.urls).then(m=>{if(s.current.delete(f),!!a.current.some(y=>y.id===f&&y.url===h)){if(!m){c.current.set(f,setTimeout(()=>{c.current.delete(f),a.current.some(y=>y.id===f&&y.url===h)&&u(f,h)},o5));return}o(y=>new Map(y).set(f,{url:h,src:ij(h,m.code)}))}}))},[e]);return E.useEffect(()=>{const f=c.current;return()=>{for(const h of f.values())clearTimeout(h);f.clear()}},[]),E.useEffect(()=>{var h;if(!n)return;for(const m of t)((h=r.get(m.id))==null?void 0:h.url)!==m.url&&u(m.id,m.url);const f=new Set(t.map(m=>m.id));[...r.keys()].some(m=>!f.has(m))&&o(m=>new Map([...m].filter(([g])=>f.has(g))))},[n,t,r,u]),{urlOf:f=>{var h,m;return n?((h=r.get(f))==null?void 0:h.src)??null:((m=t.find(g=>g.id===f))==null?void 0:m.url)??null},renew:f=>{const h=t.find(m=>m.id===f);!h||!n||(o(m=>{const g=new Map(m);return g.delete(f),g}),u(f,h.url))}}}function s5(e,t,n){var o;const r=E.useRef([]);return t===null?r.current.length>0&&(r.current=[]):((o=r.current[0])==null?void 0:o.url)!==t&&(r.current=[{id:"one",url:t}]),aj(e,r.current,n).urlOf("one")}function i5(e,t,n){if(!n){window.open(t,"_blank");return}const r=window.open("","_blank");w_(e.sock.urls).then(o=>{const s=o?ij(t,o.code):t;r?r.location.href=s:window.open(s,"_blank")})}function Ke(...e){return e.filter(Boolean).join(" ")}const a5={branch:"M4.5 5.1v5.8 M11.5 6.6c0 2.6-7 1.6-7 4.3 M4.5 1.9a1.6 1.6 0 1 0 0 3.2 1.6 1.6 0 1 0 0-3.2z M4.5 10.9a1.6 1.6 0 1 0 0 3.2 1.6 1.6 0 1 0 0-3.2z M11.5 3.4a1.6 1.6 0 1 0 0 3.2 1.6 1.6 0 1 0 0-3.2z",chat:"M2.5 3.5a1.5 1.5 0 0 1 1.5-1.5h8a1.5 1.5 0 0 1 1.5 1.5v6a1.5 1.5 0 0 1-1.5 1.5H7l-3.2 2.6V11H4a1.5 1.5 0 0 1-1.5-1.5z",settings:"M12.38 6.99 14.05 7.26 14.05 8.74 12.38 9.01 11.82 10.38 12.81 11.76 11.76 12.81 10.38 11.82 9.01 12.38 8.74 14.05 7.26 14.05 6.99 12.38 5.62 11.82 4.24 12.81 3.19 11.76 4.18 10.38 3.62 9.01 1.95 8.74 1.95 7.26 3.62 6.99 4.18 5.62 3.19 4.24 4.24 3.19 5.62 4.18 6.99 3.62 7.26 1.95 8.74 1.95 9.01 3.62 10.38 4.18 11.76 3.19 12.81 4.24 11.82 5.62z M8 6.4a1.6 1.6 0 1 0 0 3.2 1.6 1.6 0 1 0 0-3.2z",zen:"M2 6V3a1 1 0 0 1 1-1h3 M10 2h3a1 1 0 0 1 1 1v3 M14 10v3a1 1 0 0 1-1 1h-3 M6 14H3a1 1 0 0 1-1-1v-3",back:"M9.5 3.5 5 8l4.5 4.5",forward:"M6.5 3.5 11 8l-4.5 4.5",reload:"M13.5 2.5v3.5H10 M12.4 9.2a4.8 4.8 0 1 1-1-4.9l2.1 1.7",pick:"M8 4.2a3.8 3.8 0 1 0 0 7.6 3.8 3.8 0 1 0 0-7.6z M8 1.5v2.7 M8 11.8v2.7 M1.5 8h2.7 M11.8 8h2.7",inspect:"M6.5 13.5h-3a1 1 0 0 1-1-1v-9a1 1 0 0 1 1-1h9a1 1 0 0 1 1 1v3 M8.2 8.2l5.3 2-2.3.9-.9 2.3z",terminal:"M2 3a1 1 0 0 1 1-1h10a1 1 0 0 1 1 1v10a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1z M4.8 5.6 7.4 8l-2.6 2.4 M8.6 10.6h2.8",close:"M4.2 4.2 11.8 11.8 M11.8 4.2 4.2 11.8",edit:"M10.6 2.6 13.4 5.4 5.8 13H3v-2.8z M9.2 4l2.8 2.8 M3 10.2l2.8 2.8",check:"M3.4 8.4 6.4 11.4 12.6 4.6",split:"M2.5 2.5h11v11h-11z M2.5 8h11",columns:"M2.5 2.5h11v11h-11z M8 2.5v11",full:"M2.5 2.5h11v11h-11z",more:"M3.55 8a.45 .45 0 1 0 .9 0a.45 .45 0 1 0-.9 0z M7.55 8a.45 .45 0 1 0 .9 0a.45 .45 0 1 0-.9 0z M11.55 8a.45 .45 0 1 0 .9 0a.45 .45 0 1 0-.9 0z",caret:"M4.5 6.5 8 10l3.5-3.5","caret-up":"M4.5 9.5 8 6l3.5 3.5",stop:"M4.5 4.5h7v7h-7z",send:"M8 13V3.2 M4 7.2 8 3.2l4 4",external:"M9 3h4v4 M13 3 8 8 M11.5 9.5V13H3V4.5h3.5",plus:"M8 3.5v9 M3.5 8h9",download:"M8 2.5v7.4 M4.9 6.8 8 9.9l3.1-3.1 M3 13h10",copy:"M5.5 5.5h8v8h-8z M10.5 5.5v-3h-8v8h3",pull:"M8 3.2v7.4 M4.9 7.4 8 10.6l3.1-3.2",text:"M3.5 3.5h9 M3.5 6.5h9 M3.5 9.5h9 M3.5 12.5h5",wrap:"M3.5 4h9 M3.5 8h7a2 2 0 0 1 0 4H8 M9.5 10.5 8 12l1.5 1.5 M3.5 12h2.5",file:"M4.5 2.5h4.5l2.5 2.5v8.5h-7z M9 2.5V5h2.5",diff:"M8 2.8v5 M5.5 5.3h5 M5.5 11.2h5",folder:"M2.2 3.9a1 1 0 0 1 1-1h2.9l1.5 1.7h5.2a1 1 0 0 1 1 1v5.9a1 1 0 0 1-1 1H3.2a1 1 0 0 1-1-1z",book:"M8 4.6c-1.2-1-2.7-1.4-4.4-1.3v7.6c1.7-.1 3.2.3 4.4 1.3 1.2-1 2.7-1.4 4.4-1.3V3.3c-1.7-.1-3.2.3-4.4 1.3z M8 4.6v8.6",eye:"M2 8c1.6-2.9 3.6-4.3 6-4.3s4.4 1.4 6 4.3c-1.6 2.9-3.6 4.3-6 4.3S3.6 10.9 2 8z M8 6.1a1.9 1.9 0 1 0 0 3.8 1.9 1.9 0 1 0 0-3.8z",trash:"M3.6 4.6h8.8 M6.4 4.6V3.2a.7.7 0 0 1 .7-.7h1.8a.7.7 0 0 1 .7.7v1.4 M5 4.6l.55 8.1a.9.9 0 0 0 .9.84h3.1a.9.9 0 0 0 .9-.84L11 4.6",move:"M2.8 8h9.2 M8.9 4.9 12 8l-3.1 3.1",search:"M7.2 2.6a4.6 4.6 0 1 0 0 9.2 4.6 4.6 0 1 0 0-9.2z M10.5 10.5 13.5 13.5",run:"M3.4 4.2 7.6 8l-4.2 3.8 M9 11.8h4",slash:"M8.4 3.2 4.6 12.2 M9.6 11.8h3.4",bulb:"M4.8 8.8a4 4 0 1 1 6.4 0L9.5 10.6v1.4H6.5v-1.4z M6.7 13.8h2.6",spawn:"M2.3 5.8a3 3 0 1 0 6 0a3 3 0 1 0-6 0z M9.4 11.4a1.9 1.9 0 1 0 3.8 0a1.9 1.9 0 1 0-3.8 0z",handoff:"M1.7 4.5a1.6 1.6 0 1 0 3.2 0a1.6 1.6 0 1 0-3.2 0z M4.9 4.5h4.6 M9.4 4.5a1.6 1.6 0 1 0 3.2 0a1.6 1.6 0 1 0-3.2 0z M4.9 4.5c2.6 0 1.6 7 4.3 7h4 M12.1 9.7l1.8 1.8-1.8 1.8",globe:"M8 2.2a5.8 5.8 0 1 0 0 11.6 5.8 5.8 0 1 0 0-11.6z M2.2 8h11.6 M8 2.2c-3 3.4-3 8.2 0 11.6 3-3.4 3-8.2 0-11.6z",worktrees:"M3.15 4a.65 .65 0 1 0 1.3 0a.65 .65 0 1 0-1.3 0z M7.4 4h5.4 M3.15 8a.65 .65 0 1 0 1.3 0a.65 .65 0 1 0-1.3 0z M7.4 8h5.4 M3.15 12a.65 .65 0 1 0 1.3 0a.65 .65 0 1 0-1.3 0z M7.4 12h5.4",swap:"M3 6.2h9.2 M9.7 3.7 12.2 6.2 9.7 8.7 M13 10.2H3.8 M6.3 7.7 3.8 10.2l2.5 2.5",palette:"M2.3 8.4C2.3 4.7 5 2.2 8.5 2.2c3.4 0 5.2 2.2 5.2 4.6 0 1.9-1.4 2.6-2.7 2.8-.9.15-1.3.7-1.1 1.4.2.9-.5 2.2-2.1 2.2-3.2 0-5.5-2-5.5-4.8z M5 6.2a.5.5 0 1 0 0 1 .5.5 0 1 0 0-1z M7.8 4.9a.5.5 0 1 0 0 1 .5.5 0 1 0 0-1z M11 5.8a.5.5 0 1 0 0 1 .5.5 0 1 0 0-1z",lock:"M4.4 7.3h7.2v6.1H4.4z M6.2 7.3V5.5a1.8 1.8 0 0 1 3.6 0v1.8",phone:"M5.4 2.2h5.2a1.2 1.2 0 0 1 1.2 1.2v9.2a1.2 1.2 0 0 1-1.2 1.2H5.4a1.2 1.2 0 0 1-1.2-1.2V3.4a1.2 1.2 0 0 1 1.2-1.2z M7.1 11.6h1.8",laptop:"M3.4 3.4h9.2a1 1 0 0 1 1 1v6.2H2.4V4.4a1 1 0 0 1 1-1z M1.5 12.6h13",devices:"M8.8 11.2H3.2a1 1 0 0 1-1-1V4.2a1 1 0 0 1 1-1h8.8a1 1 0 0 1 1 1v1.3 M4.6 13.6h4.2 M10.6 6.9h3a.9.9 0 0 1 .9.9v5a.9.9 0 0 1-.9.9h-3a.9.9 0 0 1-.9-.9v-5a.9.9 0 0 1 .9-.9z M11.6 12.1h1",pr:"M4.5 5.1v5.8 M4.5 1.9a1.6 1.6 0 1 0 0 3.2 1.6 1.6 0 1 0 0-3.2z M4.5 10.9a1.6 1.6 0 1 0 0 3.2 1.6 1.6 0 1 0 0-3.2z M11.5 10.9a1.6 1.6 0 1 0 0 3.2 1.6 1.6 0 1 0 0-3.2z M11.5 10.9V6.6a2 2 0 0 0-2-2H8 M9.6 2.9 7.9 4.6l1.7 1.7",clock:"M8 2.2a5.8 5.8 0 1 0 0 11.6 5.8 5.8 0 1 0 0-11.6z M8 4.8V8l2.2 1.4",archive:"M2.4 3.2h11.2v2.8H2.4z M3.4 6v6.1a.9.9 0 0 0 .9.9h7.4a.9.9 0 0 0 .9-.9V6 M6.6 8.6h2.8",attach:"M13.7 7.4 8.2 12.9a3.6 3.6 0 0 1-5.1-5.1l5.5-5.5a2.4 2.4 0 0 1 3.4 3.4l-5.5 5.5a1.2 1.2 0 0 1-1.7-1.7l5.1-5.1",cube:"M8 2.4 13.2 5.2v5.6L8 13.6 2.8 10.8V5.2z M2.8 5.2 8 8l5.2-2.8 M8 8v5.6",dot:"M8 4.6a3.4 3.4 0 1 0 0 6.8 3.4 3.4 0 1 0 0-6.8z"};function kt({name:e,className:t}){return d.jsx("svg",{className:t,width:"16",height:"16",viewBox:"0 0 16 16","aria-hidden":"true",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round",children:d.jsx("path",{d:a5[e]})})}function uh({className:e}){return d.jsxs("span",{className:Ke("spinner",e),"aria-hidden":"true",children:[d.jsx("span",{}),d.jsx("span",{}),d.jsx("span",{}),d.jsx("span",{})]})}const l5='button, a[href], input, textarea, select, summary, label, [role="button"], [role="menuitem"]';function Rx(e){var n;const t=e;return((n=t==null?void 0:t.closest)==null?void 0:n.call(t,l5))??t??null}function c5(e,t){var r,o,s;if(e.box.contains(t)||(r=e.trigger)!=null&&r.contains(t))return!0;const n=(s=(o=t.closest)==null?void 0:o.call(t,"[aria-controls]"))==null?void 0:s.getAttribute("aria-controls");return!!n&&n===e.box.id}function u5(e,t){if(!t)return null;for(let n=e.length-1;n>=0;n--){const r=e[n];if(r!=null&&r.box.contains(t))return r}return null}function d5(e,t){const n=new Set;for(const r of e)if(c5(r,t))for(let o=r;o;o=o.parent)n.add(o);return e.filter(r=>!n.has(r)&&r.dismiss).reverse()}const f5=e=>{setTimeout(e,0)};function h5({schedule:e=f5}={}){let t=[],n=null,r=!1;const o=new Set,s=()=>{for(const c of[...o])c()},a=c=>{var u;for(const f of[...t].reverse())(u=f.dismiss)==null||u.call(f,c)};return{register(c){const u=c.trigger??(c.from===void 0?n:null),f={box:c.box,trigger:u,parent:u5(t,c.from??u),dismiss:c.dismiss,onKey:c.onKey,back:c.back};return t=[...t,f],s(),f},unregister(c){t=t.filter(u=>u!==c),s()},top:()=>t[t.length-1]??null,open:()=>t,watch(c){return o.add(c),()=>o.delete(c)},shut(c){var u;c.back?c.back():(u=c.dismiss)==null||u.call(c,"outside")},install(c){const u=c.document,f=v=>{var N;const _=v.target,x=_?d5(t,_):[];for(const T of x)(N=T.dismiss)==null||N.call(T,"outside");r=x.length>0&&v.pointerType==="touch",r&&v.preventDefault(),n=Rx(v.target)},h=()=>e(()=>n=null),m=()=>{r=!1,h()},g=v=>{if(r){r=!1,v.preventDefault(),v.stopPropagation();return}n||(n=Rx(v.target),h())},y=v=>{var x;const _=t[t.length-1];(x=_==null?void 0:_.onKey)==null||x.call(_,v)},w=()=>e(()=>{var v;((v=u.activeElement)==null?void 0:v.tagName)==="IFRAME"&&a("frame")});return u.addEventListener("pointerdown",f,!0),u.addEventListener("pointerup",h,!0),u.addEventListener("pointercancel",m,!0),u.addEventListener("click",g,!0),c.addEventListener("keydown",y,!0),c.addEventListener("blur",w),()=>{u.removeEventListener("pointerdown",f,!0),u.removeEventListener("pointerup",h,!0),u.removeEventListener("pointercancel",m,!0),u.removeEventListener("click",g,!0),c.removeEventListener("keydown",y,!0),c.removeEventListener("blur",w)}}}}const ec=h5(),p5=()=>ec.open().some(e=>!!e.dismiss);function m5(){return E.useSyncExternalStore(ec.watch,p5,()=>!1)}const kg=typeof HTMLElement<"u"&&"showPopover"in HTMLElement.prototype,Ox=e=>(e==null?void 0:e.getBoundingClientRect())??null;function g5(e,t,n,r){const o=e.querySelector(t);if(!o)return null;const s=e.getBoundingClientRect(),a=o.getBoundingClientRect();return{offset:n==="top"?s.bottom-a.bottom:a.top-s.top,alignOffset:r==="end"?s.right-a.right:a.left-s.left}}function Ws({className:e,anchor:t,placement:n,coverBy:r,track:o=t==="parent",raiseKey:s,onDismiss:a,onKey:c,onBack:u,trigger:f,from:h,boxRef:m,handle:g,children:y,...w}){const v=E.useRef(null),_=E.useRef({anchor:t,placement:n,coverBy:r,onDismiss:a,onKey:c,onBack:u,trigger:f,from:h});_.current={anchor:t,placement:n,coverBy:r,onDismiss:a,onKey:c,onBack:u,trigger:f,from:h};const x=E.useCallback(()=>{const T=v.current,{anchor:j,placement:A,coverBy:R}=_.current;if(!T||!j||!A)return;const C=j==="parent"?Ox(T.parentElement):j();if(!C)return;const M=F3(C,A);M!==void 0&&(T.style.width=`${M}px`);for(let I=0;I<2;I++){const D=R?g5(T,R,T.dataset.side??"",T.dataset.align??""):null,H=U3(C,{w:T.offsetWidth,h:T.offsetHeight},{w:window.innerWidth,h:window.innerHeight},D?{...A,...D}:A);T.style.left=`${H.x}px`,T.style.top=`${H.y}px`;const Z=T.dataset.side!==H.side||T.dataset.align!==H.align;if(T.dataset.side=H.side,T.dataset.align=H.align,!Z)break}},[]);E.useImperativeHandle(g,()=>({update:x}),[x]),E.useLayoutEffect(()=>{const T=v.current;if(!T)return;m&&(m.current=T),kg&&(T.popover="manual",T.matches(":popover-open")||T.showPopover());const{onDismiss:j,onKey:A,onBack:R,trigger:C,from:M}=_.current,I=j||A?ec.register({box:T,trigger:C,from:M,dismiss:j?D=>{var H,Z;return(Z=(H=_.current).onDismiss)==null?void 0:Z.call(H,D)}:void 0,onKey:A?D=>{var H,Z;return(Z=(H=_.current).onKey)==null?void 0:Z.call(H,D)}:void 0,back:R?()=>{var D,H;return(H=(D=_.current).onBack)==null?void 0:H.call(D)}:void 0}):null;return()=>{I&&ec.unregister(I),m&&(m.current=null),kg&&T.isConnected&&T.matches(":popover-open")&&T.hidePopover()}},[m]),E.useLayoutEffect(x),E.useLayoutEffect(()=>{if(!o)return;let T=0,j="";const A=()=>{const R=v.current,{anchor:C}=_.current,M=R&&C?C==="parent"?Ox(R.parentElement):C():null;if(R&&M){const I=`${M.left},${M.top},${M.right},${M.bottom},${R.offsetWidth},${R.offsetHeight},${window.innerWidth},${window.innerHeight}`;I!==j&&(j=I,x())}T=requestAnimationFrame(A)};return T=requestAnimationFrame(A),()=>cancelAnimationFrame(T)},[o,x]);const N=E.useRef(!0);return at([s],()=>{if(N.current){N.current=!1;return}const T=v.current;!kg||!(T!=null&&T.matches(":popover-open"))||(T.hidePopover(),T.showPopover(),x())}),d.jsx("div",{ref:v,className:Ke("float",e),...w,children:y})}const k5=/^[⌘⇧⌥⌃]+/;function os({k:e,chip:t=!1,className:n}){var a;const r=(a=e.match(k5))==null?void 0:a[0],o=r?e.slice(r.length):e,s=["kbd",t?"kbd-chip":"",n??""].filter(Boolean).join(" ");return d.jsxs("kbd",{className:s,children:[r&&d.jsx("span",{className:"kbd-mod",children:r}),o]})}function Lt(e,t,{placement:n,align:r,detail:o,card:s,dot:a,name:c,aside:u,also:f}={}){const h=c?`${e}: ${c}`:e,m=(Array.isArray(o)?o:[o]).filter(y=>!!y),g=[h,...m,...u??[]].join(", ");return{"data-tip":e,"data-tip-key":t,"data-tip-placement":n,"data-tip-align":r,"data-tip-detail":m.length?m.join(`
110
- `):void 0,"data-tip-card":s||c||u!=null&&u.length?"":void 0,"data-tip-dot":a,"data-tip-name":c,"data-tip-aside":u!=null&&u.length?u.join(`
111
- `):void 0,"data-tip-also":f==null?void 0:f.text,"data-tip-also-key":f==null?void 0:f.key,"aria-label":t?`${g} (${t})`:g}}const w5=120,y5=600,v5=150,Mx=6,b5=18,wg=8;function Lx(e){const t=e.dataset.tipPlacement;return t==="follow"||t==="top"||t==="bottom"||t==="left"||t==="right"?t:"bottom"}function x5(e){const t=e.dataset.tipAlign;return t==="start"||t==="center"||t==="end"?t:void 0}function lj(e,t){return e==="follow"?{side:"bottom",align:"start",offset:b5,alignOffset:-12,flip:"both",margin:wg}:e==="left"||e==="right"?{side:e,align:t??"start",offset:Mx,flip:"both",margin:wg}:{side:e,align:t??"center",offset:Mx,flip:"both",margin:wg}}function E5(e,t){return e.placement==="follow"?TN(t):e.el.getBoundingClientRect()}function cj(){var u;const[e,t]=E.useState(null),n=E.useRef(null),r=E.useRef(null),o=E.useRef({x:0,y:0}),s=Bi();if(E.useEffect(()=>{if(s)return;let f=0,h=0,m=null,g=!1,y=0;const w=()=>{window.clearTimeout(f),window.clearTimeout(h)},v=()=>{w(),g&&(y=Date.now()),g=!1,m=null,t(null)},_=(M,I)=>{var H,Z;const D=M.dataset.tip;if(!D)return v();w(),g=!0,t({el:M,text:D,key:M.dataset.tipKey,detail:(H=M.dataset.tipDetail)==null?void 0:H.split(`
112
- `),card:M.dataset.tipCard!==void 0,dot:M.dataset.tipDot,name:M.dataset.tipName,aside:(Z=M.dataset.tipAside)==null?void 0:Z.split(`
113
- `),also:M.dataset.tipAlso&&M.dataset.tipAlsoKey?{text:M.dataset.tipAlso,key:M.dataset.tipAlsoKey}:void 0,placement:I,align:x5(M)})},x=M=>{const I=M.target;if(!(I instanceof Element))return null;const D=I.closest("[data-tip], .float");return(D==null?void 0:D.dataset.tip)!==void 0?D:null},N=M=>{o.current={x:M.clientX,y:M.clientY};const I=x(M);if(I===m)return;if(w(),m=I,!I){g&&(h=window.setTimeout(v,v5));return}const D=Lx(I);if(g||Date.now()-y<y5)return _(I,D);f=window.setTimeout(()=>_(I,D),w5)},T=M=>{M.relatedTarget||v()},j=M=>{const I=x(M);if(I!=null&&I.matches(":focus-visible")){w(),m=I;const D=Lx(I);_(I,D==="follow"?"bottom":D)}},A=()=>v(),R=M=>{M.key!=="Shift"&&M.key!=="Control"&&M.key!=="Alt"&&M.key!=="Meta"&&v()},C=M=>{m&&M.target instanceof Node&&M.target.contains(m)&&v()};return document.addEventListener("mouseover",N),document.addEventListener("mouseout",T),document.addEventListener("mousedown",v),document.addEventListener("keydown",R),document.addEventListener("scroll",C,!0),document.addEventListener("focusin",j),document.addEventListener("focusout",A),window.addEventListener("blur",v),()=>{w(),document.removeEventListener("mouseover",N),document.removeEventListener("mouseout",T),document.removeEventListener("mousedown",v),document.removeEventListener("keydown",R),document.removeEventListener("scroll",C,!0),document.removeEventListener("focusin",j),document.removeEventListener("focusout",A),window.removeEventListener("blur",v)}},[s]),E.useLayoutEffect(()=>{e&&!e.el.isConnected&&t(null)},[e]),E.useEffect(()=>{if((e==null?void 0:e.placement)!=="follow")return;const f=h=>{var m;o.current={x:h.clientX,y:h.clientY},(m=r.current)==null||m.update()};return document.addEventListener("mousemove",f),()=>document.removeEventListener("mousemove",f)},[e]),!e)return null;const a=e.dot?d.jsxs("span",{className:"tooltip-words",children:[d.jsx("span",{className:`dot ${e.dot} tooltip-dot`}),e.text]}):e.text,c=d.jsxs(d.Fragment,{children:[a,e.key&&d.jsx(os,{k:e.key,className:"tooltip-key"})]});return d.jsxs(Ws,{className:Ke("tooltip",e.card&&"tooltip-card"),role:"tooltip",boxRef:n,handle:r,anchor:()=>E5(e,o.current),placement:lj(e.placement,e.align),track:!1,raiseKey:e,children:[e.also?d.jsxs("div",{className:"tooltip-pair",children:[d.jsx("span",{children:a}),e.key?d.jsx(os,{k:e.key,className:"tooltip-key"}):d.jsx("span",{}),d.jsx("span",{className:"tooltip-also",children:e.also.text}),d.jsx(os,{k:e.also.key,className:"tooltip-key"})]}):e.name?d.jsxs("div",{className:"tooltip-head",children:[d.jsx("span",{children:c}),d.jsx("span",{className:"tooltip-name",children:e.name})]}):c,(u=e.detail)==null?void 0:u.map((f,h)=>d.jsx("div",{className:"tooltip-detail",children:f},h)),e.aside&&d.jsx("div",{className:"tooltip-foot",children:e.aside.map(f=>d.jsx("span",{children:f},f))})]})}const S5={sm:"",md:"btn-md",lg:"btn-lg"},_5={ghost:"",outline:"btn-outline",field:"btn-outline btn-field",inline:"btn-inline"},uj={primary:"tone-primary",quiet:"tone-quiet",danger:"tone-danger",strong:"tone-strong",chrome:"tone-chrome"};function Oe({variant:e="ghost",size:t="sm",tone:n,on:r,mono:o,busy:s,className:a,type:c="button",disabled:u,children:f,...h}){const m=Ke("btn",_5[e],S5[t],n&&uj[n],r&&"on",o&&"btn-mono",s&&"btn-busy",a);return d.jsxs("button",{className:m,type:c,disabled:s||u,"aria-busy":s||void 0,...h,children:[s&&d.jsx(uh,{}),f]})}function At({icon:e,label:t,hint:n,detail:r,also:o,placement:s,tipAlign:a,silent:c,badge:u,tone:f,on:h,className:m,type:g="button",...y}){const w=Ke("btn-icon",f&&uj[f],h&&"on",m),v=Lt(t,n,{detail:r,also:o,placement:s,align:a});return d.jsxs("button",{className:w,type:g,...c?{"aria-label":v["aria-label"]}:v,...y,children:[typeof e=="string"?d.jsx(kt,{name:e}):e,u]})}function Gu(e,t,n){return n===0?0:(e+t+n)%n}function Px(e,t,n){return e>=0?Gu(e,t,n):n===0?-1:t>0?0:n-1}function dj(e,t,n){var s;const r=e.length,o=n.toLowerCase();for(let a=1;a<=r;a++){const c=(Math.max(t,-1)+a)%r;if((s=e[c])!=null&&s.trim().toLowerCase().startsWith(o))return c}return-1}function yg(e,t){return e&&e.length>t.length&&e.toLowerCase().startsWith(t.toLowerCase())?e.slice(t.length):null}function N5(e,t){if(e==null)return null;if(typeof e=="string"){const o=yg(e,t);return o?{text:o,accept:o,params:[]}:null}const n=yg(e.show,t);if(!n)return null;const r=(e.params??[]).map(([o,s])=>[Math.max(o,t.length)-t.length,s-t.length]).filter(([o,s])=>s>o);return{text:n,accept:yg(e.accept,t),params:r}}function fj(e){const{results:t,keyOf:n,q:r,onPick:o,listRef:s,onActive:a,onSide:c,completionOf:u,narrowTo:f,setQ:h,tabPicks:m,onIdlePick:g}=e,[y,w]=E.useState(()=>{var R;return e.idle?-1:Math.max(0,((R=e.initialIndex)==null?void 0:R.call(e,t))??0)}),v=y>=0&&t[y]?n(t[y]):null,_=E.useRef(a);_.current=a,at([v],()=>{var R,C,M;(C=(R=s.current)==null?void 0:R.querySelector('.picker-item[data-state~="cursor"]'))==null||C.scrollIntoView({block:"nearest"}),(M=_.current)==null||M.call(_,y>=0?t[y]??null:null)});const x=y<0?-1:Math.min(y,Math.max(0,t.length-1)),N=x>=0?t[x]??null:null,T=N?N5(u==null?void 0:u(N,r),r):null,j=R=>{const C=f==null?void 0:f(R,r);if(C==null)return o(R,r);h==null||h(C),w(0)};return{index:x,active:N,ghost:T,setIndex:w,pick:j,onKeyDown:R=>{if(R.key==="ArrowDown")R.preventDefault(),w(Px(x,1,t.length));else if(R.key==="ArrowUp")R.preventDefault(),w(Px(x,-1,t.length));else if((R.key==="ArrowLeft"||R.key==="ArrowRight")&&c&&N)R.preventDefault(),c(N,R.key==="ArrowLeft"?-1:1);else if(R.key==="Tab"&&(T!=null&&T.accept))R.preventDefault(),h==null||h(r+T.accept),w(0);else if(R.key==="Tab"&&m&&N)R.preventDefault(),j(N);else if(R.key==="Enter"&&N)R.preventDefault(),j(N);else if(R.key==="Enter"&&x<0&&g)R.preventDefault(),g(r);else return!1;return!0}}}function gr(e){const t=Object.keys(e).filter(n=>e[n]);return t.length>0?t.join(" "):void 0}const j5=new Set(["Shift","Meta","Control","Alt","CapsLock","Fn"]);function hj(){const e=iy(),t=Dn();return E.useEffect(()=>{if(!e)return;const n=()=>{e.target.isConnected||fo.close()},r=new MutationObserver(n);r.observe(document.body,{childList:!0,subtree:!0});const o=t.subscribe(n);return()=>{r.disconnect(),o()}},[e,t]),e?d.jsx(T5,{spec:e},e.id):null}function T5({spec:e}){const t=e.items,n=t.filter(gs),[r,o]=E.useState(-1),s=E.useRef({idx:r,items:n});s.current={idx:r,items:n};const a=E.useRef(null),c=m=>{var g,y;{const w=()=>fo.close(),{idx:v,items:_}=s.current;if(j5.has(m.key))return;if(m.key==="ArrowDown"||m.key==="ArrowUp"){m.preventDefault(),m.stopPropagation();const x=m.key==="ArrowDown"?1:-1;o(H3(_,v,x));return}if((m.key==="Enter"||m.key===" ")&&v>=0&&_[v]&&!_[v].disabled){m.preventDefault(),m.stopPropagation(),_[v].onClick(),w();return}if(m.key==="Escape"){m.stopPropagation(),w();return}if(m.key.length===1&&!m.metaKey&&!m.ctrlKey&&!m.altKey){m.preventDefault(),m.stopPropagation();const x=Array.from(((g=a.current)==null?void 0:g.querySelectorAll(".menu-label"))??[],T=>T.textContent??""),N=dj(x,v,m.key);N>=0&&!((y=_[N])!=null&&y.disabled)&&o(N);return}w()}};E.useEffect(()=>{const m=()=>fo.close();return window.addEventListener("blur",m),window.addEventListener("resize",m),document.addEventListener("scroll",m,!0),()=>{window.removeEventListener("blur",m),window.removeEventListener("resize",m),document.removeEventListener("scroll",m,!0)}},[]);const{rect:u,placement:f}=q3(e),h=n.some(m=>m.checked);return d.jsxs(Ws,{className:Ke("menu",e.head!==void 0&&"menu-headed"),role:"menu",boxRef:a,anchor:()=>u,placement:f,track:!1,from:e.target,trigger:e.toggles?e.target:null,onDismiss:()=>fo.close(),onKey:c,onContextMenu:m=>m.preventDefault(),children:[e.head!==void 0&&d.jsx("div",{className:"menu-head",children:e.head}),t.map((m,g)=>{if(!gs(m))return d.jsx("hr",{className:"menu-sep"},`sep-${g}`);const y=n.indexOf(m);return d.jsx($5,{item:m,gutter:h,cursor:y===r,onEnter:()=>o(y)},m.id)})]})}function $5({item:e,gutter:t,cursor:n,onEnter:r}){const o=e.disabled!==void 0,s=e.detail??e.disabled;return d.jsxs("button",{...e.checked===void 0?{role:"menuitem"}:{role:"menuitemcheckbox","aria-checked":e.checked},"aria-disabled":o||void 0,className:Ke("row row-keyed",e.danger&&"danger",s!==void 0&&"row-tall",o&&"disabled"),"data-state":gr({cursor:n,checked:e.checked}),onMouseMove:o||n?void 0:r,onClick:()=>{o||(e.onClick(),fo.close())},children:[t&&d.jsx("span",{className:"menu-check",children:e.checked&&d.jsx(kt,{name:"check",className:"icon-inline"})}),d.jsxs("span",{className:"menu-text",children:[d.jsx("span",{className:"menu-label",children:e.label}),s!==void 0&&d.jsx("span",{className:"menu-detail row-dim",children:s})]}),e.key&&d.jsx(os,{k:e.key,className:"menu-key row-dim"})]})}const dh=8,C5=104,I5=.25,pj=220,xk=.5,A5=100;function R5(e,t){return Math.max(0,-mj(e,t))}function mj(e,t){const n=e.filter(a=>t-a.t<=A5);if(n.length<2)return 0;const r=n[0],o=n[n.length-1],s=o.t-r.t;return s>0?(o.x-r.x)/s:0}function O5(e,t,n){return e>0?e:n>0&&t>=xk?1:0}function M5({dx:e,dy:t}){return Math.abs(e)<dh&&Math.abs(t)<dh?null:Math.abs(e)>Math.abs(t)&&e<0?"slide":"other"}function L5(e,t,n=C5){const r=Math.max(0,-e),o=t*n,s=Math.min(t,Math.floor(r/n)),a=r<=o?r:o+(r-o)*I5,c=Math.min(1,r/(n/2));return{step:s,x:-a,well:c}}function gj(e,t){const n=E.useRef(t);n.current=t,E.useEffect(()=>{const r=e.current;if(!r)return;let o=null,s=null,a=!1,c=0,u=[],f=0,h=0;const m=(T,j,A,R)=>{T.el.dataset.slide!==R&&(T.el.dataset.slide=R,T.el.offsetWidth),T.el.style.setProperty("--slide-x",`${j}px`),T.el.style.setProperty("--slide-well",`${Math.round(A*100)}%`)},g=T=>{T.el.style.removeProperty("--slide-x"),T.el.style.removeProperty("--slide-well"),delete T.el.dataset.slide},y=(T=0)=>{var M;const j=o,A=a,R=j?O5(c,T,j.rungs):0,C=R!==c;o=null,s=null,a=!1,c=0,u=[],!(!j||!A)&&(C&&(n.current.onSlide({key:j.key,step:R}),(M=navigator.vibrate)==null||M.call(navigator,8)),m(j,0,0,"settle"),R>0&&n.current.onPick(j.key,R),f=window.setTimeout(()=>{g(j),n.current.onSlide(null)},pj))};let w=null;const v=T=>{if(!T.isPrimary||T.pointerType==="mouse"&&T.button!==0)return y();const j=T.target instanceof Element?n.current.rowOf(T.target):null;!j||j.el.dataset.slide||(window.clearTimeout(f),o=j,w=T.pointerId,s={x:T.clientX,y:T.clientY})},_=T=>{var M;const j=o;if(!j||!s||T.pointerId!==w)return;const A=T.clientX-s.x,R=T.clientY-s.y;if(!a){const I=M5({dx:A,dy:R});if(I==="other"&&(o=null,s=null,w=null),I!=="slide")return;a=!0;try{j.el.setPointerCapture(T.pointerId)}catch{}n.current.onSlide({key:j.key,step:0})}u.push({x:T.clientX,t:T.timeStamp}),u.length>8&&u.shift();const C=L5(A,j.rungs,j.rung);m(j,C.x,C.well,"drag"),C.step!==c&&(c=C.step,n.current.onSlide({key:j.key,step:c}),c>0&&((M=navigator.vibrate)==null||M.call(navigator,8)))},x=T=>{T.pointerId===w&&(a&&(h=T.timeStamp+400),w=null,y(T.type==="pointerup"?R5(u,T.timeStamp):0))},N=T=>{T.timeStamp>=h||(T.preventDefault(),T.stopPropagation())};return r.addEventListener("pointerdown",v),r.addEventListener("pointermove",_),r.addEventListener("pointerup",x),r.addEventListener("pointercancel",x),r.addEventListener("click",N,!0),()=>{window.clearTimeout(f),r.removeEventListener("pointerdown",v),r.removeEventListener("pointermove",_),r.removeEventListener("pointerup",x),r.removeEventListener("pointercancel",x),r.removeEventListener("click",N,!0)}},[e])}const kj=1/3,P5=220;function D5({dx:e,dy:t}){return Math.abs(e)<dh&&Math.abs(t)<dh?null:Math.abs(e)<=Math.abs(t)?"other":e<0?"left":"right"}function z5(e,t,n){return n==="left"?Math.min(0,Math.max(-t,e)):Math.max(0,Math.min(t,e))}function F5(e,t,n,r){const o=n==="left"?-r:r;return o>=xk?!0:o<=-xk?!1:Math.abs(e)>=t*kj}function B5(e,t){for(let n=e;n!==t&&n instanceof HTMLElement;n=n.parentElement){const r=getComputedStyle(n).overflowX;if((r==="auto"||r==="scroll")&&n.scrollWidth>n.clientWidth+1)return n}return null}const Dx=-1;function U5(e,t){const n=E.useRef(t);n.current=t;const r=E.useRef(()=>{});return E.useEffect(()=>{const o=e.current;if(!o)return;let s=null,a=null,c=null,u=!1,f=0,h=null,m=null,g=0,y=null,w=[],v=0,_=0;const x=(Z,B)=>{const J=m;J&&(J.dataset.swipe!==B&&(J.dataset.swipe=B,J.offsetWidth),J.style.translate=`${Z}px`)},N=()=>{const Z=m;m=null,Z&&(delete Z.dataset.swipe,Z.offsetWidth,Z.style.removeProperty("translate"))},T=()=>{s=null,a=null,c=null,u=!1,h=null,g=0,y=null,w=[]},j=Z=>{try{o.setPointerCapture(Z.pointerId)}catch{}},A=Z=>{var V,ee;const B=h,J=(m==null?void 0:m.clientWidth)??0;T(),B&&(x(Z?B==="left"?-J:J:0,"settle"),(ee=(V=n.current).onSettle)==null||ee.call(V,Z),v=window.setTimeout(()=>{eS.flushSync(()=>n.current.onEnd(Z)),N()},P5))},R=Z=>{var J;if(Z.pointerType==="mouse")return;if(!Z.isPrimary)return h?A(!1):T();if(m||(((J=window.visualViewport)==null?void 0:J.scale)??1)>1.01)return;const B=Z.target instanceof Element?Z.target:null;!B||B.closest("textarea, input, [contenteditable], iframe, .float")||(window.clearTimeout(v),s={x:Z.clientX,y:Z.clientY},a=B,c=B5(B,o),y=Z.pointerId,f=Z.clientX)},C=(Z,B,J,V)=>{if(!s||!a)return;const ee=Z-s.x,F=B-s.y;if(u&&c){c.scrollLeft-=Z-f,f=Z;return}if(!h){const $=D5({dx:ee,dy:F});if($===null)return;if($==="other")return T();if(c){u=!0,f=Z,V&&j(V);return}const Q=n.current.take(a,$);if(!Q)return T();m=Q,h=$,V&&j(V)}w.push({x:Z,t:J}),w.length>8&&w.shift(),g=z5(ee,(m==null?void 0:m.clientWidth)??0,h),x(g,"drag")},M=(Z,B)=>{var F;if(!h)return T();const J=(m==null?void 0:m.clientWidth)??0,V=B?mj(w,Z):0,ee=B&&F5(g,J,h,V);ee&&Math.abs(g)<J*kj&&((F=navigator.vibrate)==null||F.call(navigator,8)),A(ee)},I=Z=>{Z.pointerId===y&&C(Z.clientX,Z.clientY,Z.timeStamp,Z)},D=Z=>{Z.pointerId===y&&((h||u)&&(_=Z.timeStamp+400),M(Z.timeStamp,Z.type==="pointerup"))};r.current=Z=>{const B=performance.now();if(Z.phase==="start"){if(m||s)return;s={x:Z.x,y:Z.y},a=o,c=null,y=Dx;return}if(y===Dx){if(Z.phase==="move")return C(Z.x+g,Z.y,B);M(B,Z.phase==="end")}};const H=Z=>{Z.timeStamp>=_||(Z.preventDefault(),Z.stopPropagation())};return o.addEventListener("pointerdown",R),o.addEventListener("pointermove",I),o.addEventListener("pointerup",D),o.addEventListener("pointercancel",D),o.addEventListener("click",H,!0),()=>{r.current=()=>{},window.clearTimeout(v),o.removeEventListener("pointerdown",R),o.removeEventListener("pointermove",I),o.removeEventListener("pointerup",D),o.removeEventListener("pointercancel",D),o.removeEventListener("click",H,!0)}},[e]),E.useCallback(o=>r.current(o),[])}function Vu({items:e,current:t,onPick:n,fill:r,font:o,segmented:s,quiet:a,end:c,label:u,owner:f}){const h=vn(f),m=E.useRef(null),g=Math.max(0,e.findIndex(w=>w.id===t)),y=w=>{var x,N;if(w.key!=="ArrowLeft"&&w.key!=="ArrowRight")return;w.preventDefault();const v=e.findIndex(T=>T.id===t),_=e[Gu(v,w.key==="ArrowRight"?1:-1,e.length)];_&&(n(_.id),(N=(x=m.current)==null?void 0:x.querySelectorAll('[role="tab"]')[e.indexOf(_)])==null||N.focus())};return d.jsxs("div",{className:Ke("tabs",r&&"tabs-fill",o==="mono"&&"tabs-mono",s&&"tabs-segmented",a&&"tabs-quiet"),children:[d.jsx("div",{className:"tabs-list",role:"tablist","aria-label":u,ref:m,onKeyDown:y,style:s?{"--tabs-at":g,"--tabs-count":e.length}:void 0,children:e.map(w=>{const v=w.id===t;return d.jsxs("div",{className:Ke("tab",v&&!!w.trail&&"tab-trailed",w.fit&&"tab-fit",w.far&&"tab-far"),"data-state":gr({current:v}),...w.menu?h.contextMenu(w.menu):{},children:[d.jsxs("button",{type:"button",className:"tab-btn",role:"tab","aria-selected":v,tabIndex:v?0:-1,onClick:()=>n(w.id),...w.tip,...w.ariaLabel?{"aria-label":w.ariaLabel}:{},children:[w.lead,w.label]}),v&&w.trail&&d.jsx("span",{className:"tab-trail",children:w.trail})]},w.id)})}),c&&d.jsx("span",{className:"tabs-end",children:c})]})}function vs({anchor:e="top",wide:t,foot:n,children:r}){const o=d.jsx("div",{className:Ke("view",e==="line"&&"view-anchored",t&&"view-wide"),children:r});return n?d.jsxs("div",{className:"view-stack",children:[o,n]}):o}const wj=e=>`Toyon restarts once ${e.join(", ")} ${e.length===1?"finishes":"finish"}`,H5=(e,t)=>[...e,...t.filter(n=>!e.includes(n))];function W5(e,t,n){const r=[...t],o=[...n],s=(c,u)=>{const f=c.indexOf(u);return f===-1?!1:(c.splice(f,1),!0)};return[...e.map(c=>s(r,c)?{name:c,dot:"working",note:null}:s(o,c)?{name:c,dot:"waiting",note:"asking you"}:{name:c,dot:"idle",note:"finished"}),...o.map(c=>({name:c,dot:"waiting",note:"asking you"}))]}function K5(e,t){return`${e>=t?`Toyon restarts once ${e===1?"this chat finishes its reply":`these ${e} chats finish their replies`}`:`${t-e} of ${t} chats have finished; Toyon restarts after the ${e===1?"last one":`other ${e}`}`}, and this page reloads when it is back. Restarting now stops ${e===1?"it":"them"} mid-reply.`}function q5(e){if(!e)return null;if(e.restarting&&e.restarting.length>0){const t=e.restarting.length;return{word:t===1?"restarts after a reply":`restarts after ${t} replies`,text:wj(e.restarting),retry:!1,busy:!0}}if(e.failed){const t=e.failed.line.replace(/\.$/,"");return{word:"update failed",text:`Installing Toyon ${e.failed.version} stopped: ${t}. To update by hand, run ${e.failed.command}`,retry:!0,busy:!1}}return null}let Ek=!1;function Z5(){Ek=!0}function Wl({title:e,body:t,action:n,pane:r,children:o}){return d.jsxs("div",{className:Ke("crash",r&&"in-pane"),children:[d.jsx("div",{className:"crash-title",children:e}),t&&d.jsx("div",{className:"crash-body",children:t}),o,n]})}const zx={title:"Toyon was updated",body:"This page is still running the old build. Reload to pick up the new one."};class gy extends E.Component{constructor(){super(...arguments);jt(this,"state",{error:null})}static getDerivedStateFromError(n){return{error:n}}componentDidCatch(n,r){console.error("[toyon] render error",n,r.componentStack)}render(){const{error:n}=this.state;return n?d.jsx(Wl,{pane:this.props.pane,title:Ek?zx.title:"Toyon hit an error",body:Ek?zx.body:n.message||String(n),action:d.jsx(Oe,{variant:"outline",onClick:()=>window.location.reload(),children:"reload"})}):this.props.children}}const Sk={title:"Toyon was updated",waiting:"Restarting Toyon. This page reloads when it is back.",foreign:e=>`Toyon on ${e} speaks another version than this app. Update Toyon there; this page needs no reload.`},G5=1e3,Fx={held:[],asking:[],seen:[]};async function Bx(e,t,n){for(;;){await new Promise(s=>setTimeout(s,G5));const[r,o]=await Promise.all([ok(e),m_(e)]);if(r!==null&&r!==t)break;n(o??{waiting:[],asking:[]})}window.location.reload()}function yj({foreign:e}={}){return e?d.jsx(V5,{name:e}):d.jsx(Y5,{})}function V5({name:e}){const t=ys(),n=t.list()[0];return d.jsx(Wl,{title:`Toyon on ${e} was updated`,body:Sk.foreign(e),action:n&&d.jsxs(Oe,{variant:"outline",onClick:()=>t.activate(n.origin),children:["back to ",t.displayName(n.origin)]})})}function Y5(){const e=Lr(),[t,n]=E.useState(!0),[r,o]=E.useState(null),[s,a]=E.useState(Fx),c=E.useRef(null),u=E.useCallback(w=>a(v=>({held:w.waiting,asking:w.asking,seen:H5(v.seen,w.waiting)})),[]),f=E.useCallback(async w=>{n(!0),o(null);const v=c.current??{pid:await ok(e)},_=await e4(e,w);if(_){n(c.current!==null),o(_);return}w&&a(Fx),!c.current&&(c.current=v,Bx(e,v.pid,u))},[u,e]);E.useEffect(()=>{let w=!0;return(async()=>{const[v,_]=await Promise.all([ok(e),m_(e)]);if(!(!w||c.current)){if(_===null){f(!1);return}c.current={pid:v},u(_),Bx(e,v,u)}})(),()=>{w=!1}},[u,f,e]);const h=t&&s.held.length>0,m=h?W5(s.seen,s.held,s.asking):[],g=m.filter(w=>w.dot==="working").length,y=m.filter(w=>w.dot!=="waiting").length;return d.jsx(Wl,{title:Sk.title,body:r??(h?K5(g,y):Sk.waiting),action:h?d.jsx(Oe,{variant:"outline",onClick:()=>void f(!0),children:"restart now"}):d.jsx(Oe,{variant:"outline",busy:t,onClick:()=>void f(!1),children:"restart"}),children:m.length>0&&d.jsx("ul",{className:"crash-list",children:m.map((w,v)=>d.jsxs("li",{className:Ke("crash-row",w.dot!=="working"&&"row-dim"),children:[d.jsx("span",{className:Ke("dot",w.dot)}),d.jsx("span",{className:"crash-row-name",children:w.name}),w.note&&d.jsx("span",{className:"crash-row-note",children:w.note})]},v))})})}const xa=(e,t=!1)=>({text:e,live:t}),X5={probing:"connecting to daemon",down:"the daemon is not running.\nrun `toyon` in your repo to start it; `toyon doctor` says what it can see",blocked:"the daemon is up, but this page's websocket never connected.\na proxy, VPN or browser extension is the usual cause; `toyon doctor` checks from the terminal",unauthorized:"this page's token is not the running daemon's.\nrun `toyon` again and open the link it prints"},Q5={probing:e=>`connecting to ${e}`,down:e=>`Toyon on ${e} is not answering.
114
- is Tailscale on here, and is Toyon running there?`,blocked:e=>`Toyon on ${e} is up, but this page's websocket to it never connected.
115
- a proxy, VPN or browser extension is the usual cause`,unauthorized:e=>`this page's token for ${e} is not the one running there.
116
- forget ${e} here and pair it again`},J5="no access token for this address.\nrun `toyon` or `toyon open` in your repo to get a signed-in page";function vj(e){if(e.standing&&!e.connected&&e.connectFailure!=="unauthorized")return null;if(!e.connected&&(!e.heard||e.connectFailure)){const t=e.connectFailure===null;return e.machine?xa(Q5[e.connectFailure??"probing"](e.machine),t):e.hasToken?xa(X5[e.connectFailure??"probing"],t):xa(J5)}return e.title===null?xa(e.heard?`nothing open yet.
117
- press ${e.projectChord} to open a project, or type a name there to start a new one`:""):null}function eF(e){const t=vj(e);return t!==null?t:e.needsSetup&&e.busy?xa(`building in ${e.title}; the preview appears once it starts`,!0):e.needsSetup&&e.treeEmpty?xa(`${e.title} is empty so far; say what to build`):e.treeEmpty&&e.landsFrom?xa(`nothing runs on main until ${e.landsFrom} lands`):null}const un={post:(e,t)=>{},broadcast:e=>{}};function Tu(e,t,n,r){const o=t===r;un.post(e,o?{type:"pick-cancel"}:{type:"pick-start",verb:r}),n({a:"set-picking",v:o?!1:r})}function bj(e){return[{id:"copy-sha",label:`copy ${e.short}`,onClick:()=>tn(e.sha)},{id:"copy-subject",label:"copy subject",onClick:()=>tn(e.subject)}]}function fp(e,t,n){var o,s;const r=e[t];if(!r)return null;if(n==="ArrowRight")return r.open===void 0?null:r.open?(((o=e[t+1])==null?void 0:o.depth)??-1)>r.depth?{do:"to",at:t+1}:null:{do:"open",at:t};if(r.open)return{do:"close",at:t};for(let a=t-1;a>=0;a--)if((((s=e[a])==null?void 0:s.depth)??0)<r.depth)return{do:"to",at:a};return null}const xj="application/x-toyon-mention";let Aa=null;const hp=()=>!Bi();function tF(e){return e.kind==="worktree"?`@${e.title} `:uy(e.items)}function nF(e){return e.kind==="worktree"?e.branch:e.items.map(t=>t.path).join(" ")}function $u(e,t){e.dataTransfer.setData(xj,"1"),e.dataTransfer.setData("text/plain",nF(t)),e.dataTransfer.effectAllowed="copy",Aa=t}function Yu(e){Aa=null,py(e)}function Ej(e,t){const n=e.getState().activeId;return(t.kind==="paths"?t.worktreeId===n:t.worktreeId!==n)?Fa(e):null}const Sj=e=>Aa!==null&&Array.from(e.dataTransfer.types).includes(xj);function rF(e,t){if(!Sj(t)||!Aa)return;t.preventDefault();const n=Ej(e,Aa)!==null;t.dataTransfer.dropEffect=n?"copy":"none",n&&hy(e,{at:"chat"})}function _j(e,t){if(!Sj(t)||!Aa)return null;t.preventDefault();const n=Aa,r=B6();if(Yu(e),r)return null;const o=Ej(e,n);return o?{boxId:o,words:tF(n)}:null}function oF(e,t,n){const r=e.ownerDocument;if(typeof r.caretPositionFromPoint!="function")return null;const o=r.caretPositionFromPoint(t,n);return(o==null?void 0:o.offsetNode)===e?o.offset:null}const Nj=e=>Object.entries(e.worktree.sources??{}).filter(([,t])=>Lh(t.at)).map(([t])=>t),sF=e=>Xf(Ti((e==null?void 0:e.config)??{}),e==null?void 0:e.defaultBranch).toLowerCase();function Ii(e,t,n){t({a:"shipping",id:n.worktreeId,op:n.t}),e==null||e.send(n)}const jj=(e,t)=>hA(e.worktree,{pending:()=>e.agent!=="idle"||(e.queued??0)>0||!!e.shipping,drafted:t,counts:()=>({dirty:e.dirty,ahead:e.ahead})});function Kl(e,t,n){if(n.length!==0){t({a:"archive-worktrees",ids:n});for(const r of n)e==null||e.send({t:"archive-worktree",worktreeId:r})}}function Tj(e,t,n){t({a:"hold-unread",id:n}),e==null||e.send({t:"mark-unread",worktreeId:n})}function $j(e,t,n){return{rename(r){if(!lS(r.worktree))return;const o=window.prompt("Rename worktree (its branch follows as a slug):",r.worktree.title);o!=null&&o.trim()&&(e==null||e.send({t:"rename-worktree",worktreeId:r.worktree.id,title:o.trim()}))},ownProcs(r){for(const o of r.borrowed??[])e==null||e.send({t:"set-proc-source",worktreeId:r.worktree.id,name:o.name,source:"here"})},shareProcs(r){const o=Nj(r);if(window.confirm(`Stop this worktree's own ${o.join(", ")} and use main's?
118
-
119
- What they hold that main's do not (a database of their own) is not carried over.`))for(const a of o)e==null||e.send({t:"set-proc-source",worktreeId:r.worktree.id,name:a,source:"main"})},archive(r){var a;if(!Oh(r.worktree))return;const o=jj(r,n);if(!o)return Kl(e,t,[r.worktree.id]);window.confirm(`Archive worktree "${r.worktree.title}"? ${(a=o[0])==null?void 0:a.toUpperCase()}${o.slice(1)}.
120
-
121
- Its directory and branch (${r.worktree.branch}) go. The chat, its draft, the commits and any uncommitted changes are kept, and the project menu can restore it.`)&&Kl(e,t,[r.worktree.id])}}}function Cj(e,t,n,{sock:r,dispatch:o},s){var R;const a=e.worktree.id,c=$j(r,o,n.drafted),u=[],f=[],h=[],m=[],g=[],y=[];ss(e.agent)&&u.push({id:"stop",label:"stop agent",onClick:()=>r==null?void 0:r.send({t:"stop-agent",worktreeId:a})});const w=!n.shipping[a],v=n.frame==="phone";((e.dirty??0)>0||(e.ahead??0)>0||!v&&!n.layout.changes)&&u.push({id:"changes",label:`view changes${(e.dirty??0)>0?` (${e.dirty})`:""}`,onClick:()=>{o({a:"activate",id:a}),v?o({a:"screen",to:"changes"}):n.layout.changes||o({a:"toggle-changes"})}}),f.push({id:"copy-branch",label:"copy branch name",onClick:()=>tn(e.worktree.branch)}),f.push(...Ho(()=>r==null?void 0:r.send({t:"reveal",worktreeId:a}),s.hostname)),v||f.push({id:"copy-path",label:"copy path",onClick:()=>tn(e.path)});const{transcript:_,sessionId:x}=e,N=!!_&&!Cr(e.worktree);N&&lp(s.hostname)&&f.push({id:"reveal-transcript",label:"reveal transcript in Finder",onClick:()=>r==null?void 0:r.send({t:"reveal-transcript",worktreeId:a})});const T=!v&&!!s.palette;T&&N&&f.push({id:"copy-transcript",label:"copy transcript path",onClick:()=>tn(_)}),T&&x&&f.push({id:"copy-session",label:"copy session id",onClick:()=>tn(x)}),!Ri(e.worktree)&&((R=e.borrowed)!=null&&R.length)&&g.push({id:"own-procs",label:`run ${e.borrowed.map(C=>C.name).join(", ")} here`,detail:"on main now",onClick:()=>c.ownProcs(e)});const j=Nj(e);if(!Ri(e.worktree)&&j.length>0&&g.push({id:"share-procs",label:`use main's ${j.join(", ")}…`,detail:"runs here now",danger:!0,onClick:()=>c.shareProcs(e)}),lS(e.worktree)&&h.push({id:"rename",label:"rename…",onClick:()=>c.rename(e)}),s.graft&&Df(e.worktree)){const C=s.graft;h.push({id:"graft",label:"graft with…",onClick:()=>C(a)})}h.push({id:"unread",label:"mark as unread",key:Pt("mark-unread"),disabled:e.unseen?"already unread":void 0,onClick:()=>Tj(r,o,a)});const A=w?void 0:"waiting on the one in progress";if(e.syncQueued)m.push({id:"sync",label:"call off the sync from main",onClick:()=>r==null?void 0:r.send({t:"unqueue-sync",worktreeId:a})});else if(Mh(e)&&(e.behind??0)>0){const C=ss(e.agent)&&(e.dirty??0)>0;m.push({id:"sync",label:`sync from main${C?" after the turn":""} (${e.behind} behind)`,disabled:A,onClick:()=>Ii(r,o,{t:"sync-main",worktreeId:a})})}return ya(e.worktree)&&!(e.worktree.landed&&e.dirty===0)&&m.push({id:"land",label:kw(Ti((t==null?void 0:t.config)??{}),gw(e.worktree,e.dirty)),detail:sF(t),disabled:A,onClick:()=>Ii(r,o,{t:"land",worktreeId:a})}),e.worktree.kind==="worktree"&&m.push({id:"handoff",label:"continue elsewhere…",sub:!0,onClick:()=>o({a:"open",overlay:{kind:"handoff",worktreeId:a}})}),Oh(e.worktree)&&y.push({id:"archive",label:jj(e,n.drafted)?"archive…":"archive",key:Pt("wt-archive"),danger:!0,onClick:()=>c.archive(e)}),Wn([u,f,h,m,g,y])}function iF(e,t,{sock:n,dispatch:r},o){const s=[],a=t.frame==="phone",c=[{id:"adopt",label:"take over",disabled:e.locked?`held by ${e.lockReason??"another tool"}`:void 0,onClick:()=>n==null?void 0:n.send({t:"adopt-worktree",worktreeId:e.id,clientId:t.clientId})}];return Mh(e)&&(e.behind??0)>0&&s.push({id:"sync",label:`sync from main (${e.behind} behind)`,onClick:()=>n==null?void 0:n.send({t:"sync-main",worktreeId:e.id})}),a||s.push({id:"shell",label:"open a shell here",onClick:()=>{r({a:"activate",id:e.id}),r({a:"focus-terminal"})}}),s.push(...Ho(()=>n==null?void 0:n.send({t:"reveal",worktreeId:e.id}),o)),Wn([c,s,a?[]:[{id:"copy-path",label:"copy path",onClick:()=>tn(e.path)}]])}const aF={sm:"",md:"field-md",lg:"field-lg"};function Ij({size:e="sm",font:t,bare:n,rule:r,className:o}){const s=t??(e==="lg"?"ui":"mono");return Ke("field",aF[e],s==="ui"&&"field-ui",s==="lead"&&"field-lead",n&&"field-bare",r&&"field-rule",o)}const Bo=E.forwardRef(function({size:t,font:n,bare:r,rule:o,className:s,...a},c){return d.jsx("input",{ref:c,className:Ij({size:t,font:n,bare:r,rule:o,className:s}),...a})}),Cu=E.forwardRef(function({size:t,font:n,bare:r,rule:o,className:s,...a},c){return d.jsx("textarea",{ref:c,className:Ij({size:t,font:n,bare:r,rule:o,className:s}),...a})}),Jr=e=>/[.!?…]$/.test(e)?e:`${e}.`,Aj=160;function pp(e,t=Aj){const n=e.replace(/\s+/g," ").trim();if(n.length<=t)return n;const r=n.slice(0,t);return`${r.slice(0,Math.max(r.lastIndexOf(" "),1)).trimEnd()}…`}function ky(e){return e.subjects.length?pp(e.subjects.join("; ")):void 0}function Rj(e){const t=ky(e);if(t)return e.pr===void 0?t:pp(`PR #${e.pr}: ${t}`)}function wy(e,t=3){const n=[];for(const a of e??[]){const c=Rj(a);c&&n.push({at:a.at,line:c})}if(n.length===0)return[];const r=n.slice(-t),o=n.length-r.length,s=r.map(({at:a,line:c})=>n.length===1?Jr(c):`${yy(So(mr(a)))}: ${Jr(c)}`);return o>0?[`${o} earlier landing${o===1?"":"s"}.`,...s]:s}const lF="checks running",cF="checks failed",Oj="preview up";function uF(e){if(e.state!=="open")return[];const t=[];return(e.checks==="pending"||e.checks==="fail")&&t.push({text:e.checks==="fail"?cF:lF,url:`${e.url}/checks`,tip:"Open the checks on GitHub",open:"open the checks"}),e.preview&&t.push({text:Oj,url:e.preview,tip:`Open the branch on ${new URL(e.preview).hostname}`,open:"open the preview"}),t}function dF(e,t){const n=[];let r=e;for(const o of t){const s=new RegExp(`(^|; |, )${o.text.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}(?=;|\\.|$)`).exec(r);if(!s)continue;const a=s.index+(s[1]??"").length;a>0&&n.push(r.slice(0,a)),n.push(o),r=r.slice(a+o.text.length)}return r&&n.push(r),n}function As(e){const t=`PR #${e.number}`;if(e.state==="merged")return`${t} merged.`;if(e.state==="closed")return`${t} was closed without merging.`;const n=e.preview?`; ${Oj}.`:".";if(e.queued){if(e.queued==="failed")return`${t} failed in the merge queue${n}`;const r={waiting:"",checking:"; the queue's checks are running",merging:"; merging now"}[e.queued];return`${t} in the merge queue${r}${n}`}if(e.automerge){const r=e.review==="review_required"?"it is approved and checks pass":"checks pass";return`${t} open; GitHub ${e.queue?"queues":"merges"} it when ${r}${n}`}return e.mergeable===!1?`${t} open; it conflicts with main${n}`:e.review==="changes_requested"?`${t} open; changes requested${n}`:e.checks==="fail"?`${t} open; checks failed${n}`:e.checks==="pending"?`${t} open; checks running${n}`:e.review==="review_required"?`${t} open; waiting on review${n}`:e.review==="approved"?`${t} approved${e.checks==="pass"?", checks pass":""}${n}`:`${t} open and ready to merge${n}`}function Mj(e){return e.queue?"Add the PR to the merge queue; GitHub merges it in turn":"Merge the PR now, by the method the repo allows"}function Lj(e){return e.state==="open"&&!e.automerge&&!e.queued&&e.mergeable!==!1&&e.review!=="changes_requested"&&e.review!=="review_required"&&e.checks!=="fail"&&e.checks!=="pending"}const yy=e=>`${e.charAt(0).toUpperCase()}${e.slice(1)}`;function vy(e,t,n){return t===0||e!=null&&e.subject?null:!e||e.stale?"unwritten":e.check==="pending"?"pending":e.check==="fail"?null:e.unanswered||n?"unanswered":"unasked"}function Pj(e,t,n=null){return e!=null&&e.stale?`The work changed since this was written. ${t?"Run the check again and refresh":"Refresh"} the message.`:n==="unanswered"?`The model did not answer with a message. ${t?"Run the check again and ask":"Ask"} for it again.`:`${t?"Run the repo's check here and write":"Write"} the recap and the commit message.`}function fF(e){return e?`No commit message: ${e} has no quick model to write one. Write it in the changes panel.`:"No commit message yet: write one in the changes panel."}function Sf(e,t=0,n=!0,r){var o,s;if(e.check==="pending")return"Checking the work…";if(e.check==="fail"){const a=(s=(o=e.checkTail)==null?void 0:o.split(`
122
- `).find(c=>c.trim()))==null?void 0:s.trim();return`Check failed${a?`: ${Jr(a)}`:"."}`}return vy(e,t,n)==="unasked"?fF(r):null}function Ux(e,t){const n=hF(e,t);return n?Jr(yy(n)):""}function hF(e,t){const n=t>0?`${t} ${t===1?"file":"files"} changed`:"",r=e.check==="pass"?"check passed":"";return[n,r].filter(Boolean).join(", ")}const Dj=e=>/^[A-Z][a-z]+(\s|$)/.test(e)?`${e.charAt(0).toLowerCase()}${e.slice(1)}`:e;function pF(e,t){const n=t??0;return n>0?`${n} behind ${e}; land takes it in first.`:""}function mF(e){return e>0?Jr(yy(`${e} ${e===1?"file":"files"} changed`)):""}function gF(e,t=null){return e.stale?"Changed since this was written.":t==="unanswered"?"No message yet: the model did not answer.":e.why?`Not ready: ${Jr(Dj(e.why))}`:null}function _f(e){return Jr(e)}const So=e=>e==="now"?"just now":`${e} ago`;function kF(e,t,n){switch(e){case"asking":return`Waiting on you${n==="now"?"":` for ${n}`}${t.ask?`: ${Jr(t.ask)}`:"."}`;case"failed":return t.auth?`Stopped ${So(n)}: not logged in.`:t.error?`Failed ${So(n)}: ${Jr(t.error)}`:`Failed ${So(n)}.`;case"stopped":return t.planBack?`Sent the plan back ${So(n)}. Say what to change.`:`Stopped ${So(n)}.`;case"done":return t.cut?`Ended early ${So(n)} (${t.cut}).`:`Finished ${So(n)}.`}}function by(e){var n;const t=(n=e.recap)==null?void 0:n.text;return t?Jr(t):kF(e.end,e.facts,mr(e.at))}function wF(e){var n;const t=(n=e.recap)==null?void 0:n.text;return t?`Last stop, ${So(mr(e.at))}: ${Jr(Dj(t))}`:void 0}function Iu(e,t){var n,r;return(r=(n=e==null?void 0:e.worktree)==null?void 0:n.runs)==null?void 0:r.find(o=>o.kind===t)}function xy(e){return(e==null?void 0:e.status)==="running"||(e==null?void 0:e.status)==="detached"}function zj(e){const t=e&&e.status!=="terminated"?e.since:void 0,n=ey(t,ty);return t!==void 0&&n===t?e:void 0}function Fj(e,t){const n=e.stage?[e.stage]:[];switch(e.status){case"queued":return[...n,"queued"];case"running":return[...n,`${ba(t)} of ${AA(e.timeoutMs)}`];case"detached":return[...n,ba(t),"detached"];case"terminated":return[e.why??"stopped"]}}function fh(e,t,n){return[e,...Fj(t,n)].join(" · ")}const _k={queued:"Asked for, not started yet.",running:"Running under the daemon's watch. It is killed at the ceiling.",detached:"The daemon restarted under it. It runs on, unwatched, until it ends or is stopped.",terminated:"Killed: at its ceiling, or by a stop."};function Bj(e){switch(e){case"setup":return"Stop this setup command; the next one runs";case"check":return"Stop the check; it reads as failed until it runs again";case"commit":return"Stop the commit and the hooks it is running; nothing is committed"}}function yF({active:e,ahead:t,behind:n,unpushed:r,dirty:o}){var lt,Yt,$n;const s=Qe(),a=dt(),c=vn("changes"),u=Nn(e)?e.worktree:null,f=e.id,h=L(gt=>{var rt;return(rt=gt.shipping[f])==null?void 0:rt.op}),m=L(gt=>{var rt;return(rt=gt.shipping[f])==null?void 0:rt.step}),g=ey(m,ty),y=Iu(e,"commit"),w=Iu(e,"check"),v=h?y:w,_=zj(v),x=Ci(xy(_)?_==null?void 0:_.since:void 0),[N,T]=E.useState("");at([f],()=>T("")),at([o],()=>{o||T("")});const j=E.useRef(null),A=(lt=u==null?void 0:u.landing)!=null&&lt.subject?u.landing.body?`${u.landing.subject}
123
-
124
- ${u.landing.body}`:u.landing.subject:null,R=()=>{N===""&&A&&T(A);const gt=j.current;gt&&(gt.focus(),requestAnimationFrame(()=>gt.setSelectionRange(gt.value.length,gt.value.length)))},C=L(gt=>gt.editCommit);at([C],()=>{C&&R()});const M=N.trim()||void 0,I=L(gt=>{var rt;return!!((rt=gt.agents.find(Kn=>Kn.id===((u==null?void 0:u.agent)??gt.defaultAgent)))!=null&&rt.quick)}),D=u==null?void 0:u.landing,H=M?null:vy(D,o?1:0,I),Z=(D==null?void 0:D.check)==="pending",B=!!(D!=null&&D.stale),J=()=>{h||s==null||s.send({t:"judge",worktreeId:f})},V=()=>{h||!M&&!A||Ii(s,a,{t:"commit",worktreeId:f,message:M??A??""})},ee=()=>{h||Ii(s,a,{t:"land",worktreeId:f,...M?{message:M}:{}})},F=((Yt=u==null?void 0:u.landing)==null?void 0:Yt.check)==="fail",$=!!(u!=null&&u.landed)&&!o,Q=u?gw(u,o?1:0):void 0,q=Q?zh(Q):void 0,W=(q==null?void 0:q.state)==="open",oe=W&&(o||r>0),de=Z||B||!!H,he=!!u&&ya(u)&&!$&&(o||t>0)&&!F&&!W&&!de,Ne=!!u&&oe&&!F&&!de,Me=!!u&&ya(u)&&!Z&&(B||H==="unwritten"||H==="unanswered")&&!ss(e.agent),Be=L(gt=>gt.repos.find(rt=>rt.id===e.repoId)??null),K=Ti((Be==null?void 0:Be.config)??{}),te=Xf(K,Be==null?void 0:Be.defaultBranch),pe=kw(K,Q??{}),ue=Be?Dh(Be):"main",ie=Mh(e)?R4(ue,n):null,ye=ss(e.agent),Se=o&&!u?"commit or discard the changes here first":void 0,Ee=!!e.syncQueued,Le=o&&ye?`Merge ${ue} into this worktree once the turn ends, uncommitted changes kept`:`Merge ${ue} into this worktree${o?", uncommitted changes kept":""}`,Ue=W&&!oe&&Lj(q),Je=he?pe:Ne?"update":Ue?"land":(q==null?void 0:q.state)==="merged"?"pull":"land",Ht=h==="commit"?g??"commit":h==="land"?g?`${Je}: ${g}`:Je:null,qt=Ht&&_?fh(Ht,_,x):Ht,xt=E.useRef(!1);qt?o&&(xt.current=!0):xt.current=!1;const Ze=!!u&&(o||xt.current),_t=Ze&&!!qt,mt=h?null:v?_?Fj(_,x).join(" · "):null:Z?"writing the message":null,De=_&&(_.status==="running"||_.status==="detached")?_:null,nt=De&&d.jsx(At,{icon:"stop",tone:"danger",label:Bj(De.kind),onClick:()=>s==null?void 0:s.send({t:"run-stop",worktreeId:f,kind:De.kind})});return d.jsxs("div",{className:"composer commit-box",children:[Ze&&d.jsx("div",{className:"composer-field",children:_t?d.jsx("div",{className:"commit-running live-text","data-tip":_?_k[_.status]:void 0,children:qt}):d.jsx(Cu,{size:"lg",bare:!0,ref:j,value:N,onChange:gt=>T(gt.target.value),onKeyDown:gt=>{gt.key==="Enter"&&(gt.metaKey||gt.ctrlKey)?(gt.preventDefault(),V()):gt.key==="Tab"&&!gt.shiftKey&&N===""&&A&&(gt.preventDefault(),R())},placeholder:A??(H==="unanswered"?"no message yet: the model did not answer. Check again, or write one here":H==="unasked"?"no message yet: write one here to commit or land":"commit message…")})}),d.jsxs("div",{className:"hint composer-knobs",children:[d.jsxs("span",{className:"commit-where",children:[d.jsx(kt,{name:"branch",className:"icon-inline"}),d.jsx("span",{className:"branch-name",children:e.branch??"detached"}),t>0&&d.jsxs("span",{className:"badge-ahead","data-tip":`${t} commit(s) ahead of ${ue}`,children:[t," ahead"]}),$&&d.jsxs("span",{className:"badge-landed","data-tip":`Merged into ${ue}`,children:[d.jsx(kt,{name:"check",className:"icon-inline"})," landed"]})]}),d.jsxs("span",{className:"commit-acts",children:[qt?d.jsxs(d.Fragment,{children:[!_t&&d.jsx("span",{className:"live-text",children:qt}),nt]}):d.jsxs(d.Fragment,{children:[u&&o&&d.jsx(Oe,{disabled:!M&&!A||!!h,onClick:V,...Lt(A&&!M?"Commit with the suggested message":"git add -A && git commit","⌘⏎"),children:"commit"}),u&&he&&d.jsx(Oe,{tone:"primary",disabled:!!h,"data-tip":te,onClick:ee,children:pe}),Me&&d.jsx(Oe,{tone:"primary",disabled:!!h,"data-tip":Pj(D,!!(($n=Be==null?void 0:Be.config.check)!=null&&$n.trim()),H),onClick:J,children:"check"}),Z&&d.jsx("span",{className:"live-text",children:"check"}),Ne&&q&&d.jsx(Oe,{tone:"primary",disabled:!!h,"data-tip":`Commit, take ${ue} in and push the branch; PR #${q.number} takes the new commits`,onClick:ee,children:"update"}),Ue&&d.jsx(Oe,{tone:"primary",disabled:!!h,"data-tip":Mj(q),onClick:ee,children:"land"})]}),q&&d.jsxs(Oe,{"data-tip":`Open PR #${q.number} on GitHub`,onClick:()=>window.open(q.url,"_blank"),...c.contextMenu(()=>[{id:"open-pr",label:"open on GitHub",onClick:()=>window.open(q.url,"_blank")},{id:"copy-link",label:"copy link",onClick:()=>tn(q.url)}]),children:["view ",d.jsx(kt,{name:"external",className:"icon-inline"})]}),(q==null?void 0:q.preview)&&d.jsxs(Oe,{"data-tip":`Open the branch on ${new URL(q.preview).hostname}`,onClick:()=>window.open(q.preview,"_blank"),...c.contextMenu(()=>[{id:"open-preview",label:"open the preview",onClick:()=>window.open(q.preview,"_blank")},{id:"copy-preview",label:"copy link",onClick:()=>tn(q.preview??"")}]),children:["preview ",d.jsx(kt,{name:"external",className:"icon-inline"})]})]})]}),(ie||mt)&&d.jsxs("div",{className:"composer-notes",children:[mt&&d.jsxs("div",{className:"hint composer-note","data-tip":_?_k[_.status]:void 0,children:[d.jsx("span",{children:mt}),nt]}),ie&&d.jsxs("div",{className:"hint composer-note",children:[d.jsx("span",{children:ie}),h==="sync-main"?d.jsx("span",{className:"live-text",children:g?`sync: ${g}`:"sync"}):Ee?d.jsx("span",{className:"live-text","data-tip":"Runs once the turn ends, the uncommitted changes kept. The row's menu calls it off",children:"syncing after next turn"}):d.jsx(Oe,{variant:"outline",disabled:!!h||!!Se,"data-tip":Se??Le,onClick:()=>Ii(s,a,{t:"sync-main",worktreeId:f}),children:"sync"})]})]})]})}const vF=E.memo(function({c:t,id:n,selected:r,onToggle:o}){const s=vn("changes"),a=qu("changes");return d.jsxs("button",{className:"row row-sm log-row row-edge",id:n,"data-state":gr({current:r,cursor:r}),role:"option","aria-selected":r,tabIndex:-1,onClick:()=>o(t.sha),...s.contextMenu(()=>bj(t)),"data-tip":`${t.subject}
125
- ${t.short} · ${t.author}`,"data-tip-placement":a,children:[d.jsx("span",{className:"subject",children:t.subject}),d.jsx("span",{className:"at row-dim",children:mr(t.at)})]})});function bF(e,t){const n=uo(e,t);if(!n||!Nn(n))return"take this worktree over to change files here";if(Ri(n.worktree))return"start a worktree to change files"}function Uj(e,t,n,r){return{id:"new-file",label:"new file…",disabled:bF(e.getState(),t),onClick:()=>r(n)}}function xF(e,t,n,r){const{worktreeId:o,dir:s,path:a,folder:c,newIn:u}=e,f=cy(t.getState(),o)?void 0:"take this worktree over to talk to an agent here",h=FN(a,c),m=[...c?[]:[{id:"open",label:"open",onClick:()=>Pn(n,{worktreeId:o,path:a,view:Li(a)})}],{id:"add-to-chat",label:"add to chat",disabled:f,onClick:()=>s6(t,o,a,c)}],g=[Uj(t,o,u,r),{id:"ask-rename",label:"ask the agent to rename…",disabled:f,onClick:()=>Tx(t,o,`Rename ${h} to `)},{id:"ask-delete",label:"ask the agent to delete…",disabled:f,onClick:()=>Tx(t,o,`Delete ${h} and update whatever still uses it`)}],y=[...Ho(()=>{var w;return(w=n.sock)==null?void 0:w.send({t:"reveal",worktreeId:o,path:a})},po(n.sock)),{id:"copy-path",label:"copy path",onClick:()=>tn(`${s}/${a}`)},{id:"copy-relative-path",label:"copy relative path",onClick:()=>tn(a)}];return Wn([m,y,g])}function EF(e,t,n,r){return Wn([[Uj(t,e.worktreeId,"",r)],Ho(()=>{var o;return(o=n.sock)==null?void 0:o.send({t:"reveal",worktreeId:e.worktreeId})},po(n.sock))])}const Nf=[],SF=[],Hx=new Set,Wx=e=>`tree-row-${e}`;function _F({worktreeId:e,dir:t,openPath:n,openRef:r,rootRef:o}){const s=Dn(),a=Qe(),c=dt(),u=It(e,"files"),f=It(e,"submodules"),h=It(e,"ignored"),m=It(e,"git"),g=(m==null?void 0:m.files)??SF,y=m==null?void 0:m.version,w=L(ie=>ie.connected);at([e,y,w,a],()=>cp(e,s.getState(),{sock:a,dispatch:c}));const v=L(ie=>{var ye;return((ye=ie.dragFiles)==null?void 0:ye.at)==="tree"&&ie.dragFiles.worktreeId===e?ie.dragFiles.dir:null}),_=L(ie=>ie.treeOpen[e]??Nf),x=E.useMemo(()=>new Set(_),[_]),[N,T]=E.useState(Hx);at([e,n,r],()=>T(n&&!r?new Set(ah(n).filter(ie=>!x.has(ie))):Hx));const j=E.useCallback(ie=>x.has(ie)||N.has(ie),[x,N]),A=E.useCallback(ie=>{const ye=x.has(ie)||N.has(ie);if(ye&&N.has(ie)){const Se=new Set(N);Se.delete(ie),T(Se)}c({a:"tree-folder",worktreeId:e,path:ie,open:!ye})},[x,N,e,c]),R=E.useMemo(()=>u6(u??Nf,f??Nf,h??Nf),[u,f,h]),C=E.useMemo(()=>d6(R,j),[R,j]),M=E.useMemo(()=>h6(g),[g]),I=L(ie=>ie.treeReveal),D=I&&I.worktreeId===e?I:null,[H,Z]=E.useState(()=>(D==null?void 0:D.path)??null),[B,J]=E.useState({worktreeId:e,linked:D});(B.worktreeId!==e||B.linked!==D)&&(J({worktreeId:e,linked:D}),Z((D==null?void 0:D.path)??null));const[V,ee]=E.useState(!1),F=E.useMemo(()=>{if(H===null)return-1;const ie=C.findIndex(ye=>ye.path===H);if(ie>=0)return ie;for(const ye of ah(H).reverse()){const Se=C.findIndex(Ee=>Ee.path===ye);if(Se>=0)return Se}return-1},[C,H]);at([F,V],()=>{var ie,ye;V&&((ye=(ie=o.current)==null?void 0:ie.querySelector('[data-state~="cursor"]'))==null||ye.scrollIntoView({block:"nearest"}))});const $=E.useCallback((ie,ye)=>Pn({dispatch:c},{worktreeId:e,path:ie,view:Li(ie),focus:ye}),[e,a,c]),Q=E.useCallback(ie=>{Z(ie.path),ie.kind==="folder"?A(ie.path):ie.kind==="file"&&$(ie.path,!1)},[A,$]),q=ie=>{var Ee;if(ie.metaKey||ie.ctrlKey||ie.altKey)return;const ye=C[F],Se=Le=>{const Ue=C[Le];Ue&&(Z(Ue.path),Ue.kind==="file"&&$(Ue.path,!1))};switch(ie.key){case"ArrowDown":case"ArrowUp":ie.preventDefault(),Se(F<0?0:Gu(F,ie.key==="ArrowDown"?1:-1,C.length));return;case" ":ie.preventDefault(),(ye==null?void 0:ye.kind)==="file"?$(ye.path,!1):(ye==null?void 0:ye.kind)==="folder"&&A(ye.path);return;case"Enter":ie.preventDefault(),(ye==null?void 0:ye.kind)==="file"?$(ye.path,!0):(ye==null?void 0:ye.kind)==="folder"&&A(ye.path);return;case"ArrowRight":case"ArrowLeft":{ie.preventDefault();const Le=C.map(Je=>Je.kind==="folder"?{depth:Je.depth,open:Je.open}:{depth:Je.depth}),Ue=fp(Le,F,ie.key);(Ue==null?void 0:Ue.do)==="to"?Se(Ue.at):Ue&&ye&&A(ye.path);return}case"Escape":ie.stopPropagation(),n!==null?c({a:"close-editor"}):(Ee=document.activeElement)==null||Ee.blur();return}if(ie.key.length===1){const Le=dj(C.map(Ue=>Ue.name),F,ie.key);Le>=0&&(ie.preventDefault(),Se(Le))}},[W,oe]=E.useState(null),de=E.useRef(0),he=E.useCallback(ie=>{ie&&!j(ie)&&A(ie),de.current++,oe({dir:ie,error:null,busy:!1})},[j,A]),Ne=E.useCallback(()=>{de.current++,oe(null)},[]),Me=E.useCallback(ie=>{if(!W||W.busy)return;const ye=f6(W.dir,ie);if("error"in ye){oe({...W,error:ye.error});return}const Se=++de.current;oe({...W,error:null,busy:!0}),MN({sock:a,dispatch:c},{worktreeId:e,path:ye.path}).then(Ee=>{Ee===null&&Z(ye.path),Se===de.current&&oe(Ee===null?null:{...W,error:Ee,busy:!1})})},[W,e,a,c]),Be=vn("tree"),K=E.useCallback(ie=>xF({worktreeId:e,dir:t,path:ie.path,folder:ie.kind!=="file",newIn:ie.kind==="folder"||ie.kind==="ignored"?ie.path:HN(ie.path)},s,{sock:a,dispatch:c},he),[e,t,s,a,c,he]),te=E.useCallback((ie,ye)=>{ie.kind==="file"&&un.post(e,ye?{type:"highlight-file",path:ie.path,ranges:null}:{type:"highlight-clear"})},[e]),pe=E.useCallback((ie,ye)=>$u(ye,{kind:"paths",worktreeId:e,items:[{path:ie.path,folder:ie.kind!=="file"}]}),[e]),ue=E.useCallback(()=>Yu(s),[s]);return d.jsx("div",{className:Ke("tree",v===""&&"drop-over"),role:"tree","aria-label":"files","data-worktree":e,"aria-activedescendant":V&&F>=0?Wx(F):void 0,tabIndex:0,ref:o,onKeyDown:q,onFocus:()=>{var ie;ee(!0),H===null&&Z(n&&C.some(ye=>ye.path===n)?n:((ie=C[0])==null?void 0:ie.path)??null)},onBlur:ie=>!ie.currentTarget.contains(ie.relatedTarget)&&ee(!1),onMouseDown:ie=>{if(ie.button!==0)return;const ye=ie.target.closest("[data-path]");(ye==null?void 0:ye.dataset.path)!==void 0&&Z(ye.dataset.path)},...Be.contextMenu(ie=>{const ye=C[F];return ie==="keyboard"&&ye?K(ye):EF({worktreeId:e},s,{sock:a},he)}),children:u===void 0?d.jsx("div",{className:"empty",children:d.jsx("span",{className:"live-text",children:"listing files"})}):C.length===0&&!W?d.jsx("div",{className:"empty",children:"no files"}):NF(C.map((ie,ye)=>d.jsx(TF,{row:ie,id:Wx(ye),status:M.files.get(ie.path),changedInside:ie.kind!=="file"&&M.folders.has(ie.path),current:V?ye===F:!r&&ie.path===n,cursor:V&&ye===F,dropOver:v===ie.path,onPress:Q,menu:K,onHover:te,onDragStart:pe,onDragEnd:ue},ie.path)),W&&(()=>{var ye;const ie=W.dir===""?-1:C.findIndex(Se=>Se.path===W.dir);return{at:ie,node:d.jsx(jF,{depth:ie>=0?(((ye=C[ie])==null?void 0:ye.depth)??0)+1:0,error:W.error,onSubmit:Me,onCancel:Ne},"new-file")}})())})}function NF(e,t){return t?[...e.slice(0,t.at+1),t.node,...e.slice(t.at+1)]:e}function jF({depth:e,error:t,onSubmit:n,onCancel:r}){const[o,s]=E.useState(""),a={"--tree-depth":e},c=e===0||void 0;return d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"row row-sm tree-row row-rails","data-kind":"file","data-root":c,style:a,children:[d.jsx("span",{className:"tree-caret row-dim"}),d.jsx(Bo,{bare:!0,font:"mono",autoFocus:!0,className:"tree-new-name","aria-label":"new file name","aria-invalid":t!==null||void 0,placeholder:"name",value:o,onChange:u=>s(u.target.value),onKeyDown:u=>{u.stopPropagation(),u.key==="Enter"?(u.preventDefault(),n(o)):u.key==="Escape"&&(u.preventDefault(),r())},onBlur:r})]}),t&&d.jsxs("div",{className:"tree-row tree-new-error row-rails","data-root":c,style:a,children:[d.jsx("span",{className:"tree-caret"}),d.jsx("span",{className:"hint",children:t})]})]})}const TF=E.memo(function({row:t,id:n,status:r,changedInside:o,current:s,cursor:a,dropOver:c,onPress:u,menu:f,onHover:h,onDragStart:m,onDragEnd:g}){const y=vn("tree"),w=hp(),v=qu("changes"),_=t.kind==="submodule",x=_?"A submodule: its files belong to its own repository":t.kind==="ignored"?"Ignored by git, so what is inside is not listed":null;return d.jsxs("div",{role:"treeitem",id:n,"aria-level":t.depth+1,"aria-expanded":t.kind==="folder"?t.open:void 0,"aria-selected":a,className:Ke("row row-sm tree-row row-rails row-edge",c&&"drop-over"),"data-state":gr({current:s,cursor:a}),"data-kind":t.kind,"data-path":t.path,style:{"--tree-depth":t.depth},draggable:w&&!_,onDragStart:N=>m(t,N),onDragEnd:g,onClick:()=>u(t),onMouseEnter:()=>h(t,!0),onMouseLeave:()=>h(t,!1),...y.contextMenu(()=>f(t)),...x?Lt(x,void 0,{placement:v}):{},children:[d.jsx("span",{className:"tree-caret row-dim",children:t.kind==="folder"&&d.jsx(kt,{name:"caret",className:Ke("icon-inline disc-caret",!t.open&&"shut")})}),d.jsx("span",{className:Ke("tree-name",(_||t.ignored)&&"row-dim"),children:t.name}),r?d.jsx("span",{className:`xy ${zw(r.xy)}`,children:Fw(r.xy)}):o&&d.jsx("span",{className:"dot tree-changed"})]})});function Hj({f:e}){return e.add===void 0&&e.del===void 0?null:d.jsxs("span",{className:"counts",children:[e.add?d.jsxs("span",{className:"add",children:["+",e.add]}):null,e.del?d.jsxs("span",{className:"del",children:["−",e.del]}):null]})}const jf=E.memo(function({f:t,id:n,active:r,selected:o,checking:s=!1,checked:a=!1,onOpen:c,onCheck:u,menu:f,onHover:h,onDragStart:m,onDragEnd:g}){const y=vn("changes"),w=hp(),v=qu("changes"),{name:_,dir:x}=I_(t.path);return d.jsxs("button",{className:"row row-sm git-file row-edge",id:n,"data-state":gr({current:r,cursor:o,checked:a}),role:"option","aria-selected":o,tabIndex:-1,onClick:N=>u&&(s||N.shiftKey)?u(t.path):c(t.path),draggable:w&&!!m,onDragStart:m&&(N=>m(t.path,N)),onDragEnd:g,...y.contextMenu(()=>f(t.path)),onMouseEnter:()=>h(t.path,!0),onMouseLeave:()=>h(t.path,!1),"data-tip":x?t.path:void 0,"data-tip-placement":v,children:[s&&d.jsx("input",{type:"checkbox",className:"changes-check",checked:a,readOnly:!0,tabIndex:-1}),d.jsx("span",{className:`xy ${zw(t.xy)}`,children:Fw(t.xy)}),d.jsxs("span",{className:"path",children:[d.jsx("span",{className:"name",children:_}),x&&d.jsx("span",{className:"dir row-dim",children:x})]}),d.jsx(Hj,{f:t})]})}),Kx=new Set(["test","tests","__tests__","spec","e2e","__snapshots__","__mocks__","fixtures","testdata"]),$F=/([._-]tests?\.[^.]+$)|([._]specs?\.[^.]+$)|(^tests?[._-])|(^conftest\.py$)|(\.snap$)|([a-z0-9](Tests?|Spec)\.[^.]+$)/;function hh(e){const t=(e.endsWith("/")?e.slice(0,-1):e).split("/"),n=t.pop()??"";return e.endsWith("/")&&Kx.has(n.toLowerCase())?!0:t.some(r=>Kx.has(r.toLowerCase()))||$F.test(n)}function Wf(e){const t=e.filter(n=>!hh(n.path));return t.length===0||t.length===e.length?{files:e,source:t.length}:{files:[...t,...e.filter(n=>hh(n.path))],source:t.length}}const Tf=[];function CF(e,t){var a,c;const n=Wf((e==null?void 0:e.files)??Tf),r=(a=e==null?void 0:e.extras)==null?void 0:a.turn,o=Wf(r&&t.turn?r.files:Tf),s=Wf(t.committed?((c=e==null?void 0:e.extras)==null?void 0:c.committed)??Tf:Tf);return{files:n.files,fileSource:n.source,turned:o.files,turnedSource:o.source,turnBase:r==null?void 0:r.base,committed:s.files,committedSource:s.source}}const IF={added:"A",changed:"M",removed:"D"},AF={added:"added",changed:"",removed:"deleted"},RF=E.memo(function({tests:t,id:n,cursor:r,onPick:o}){return t.map((s,a)=>d.jsxs("button",{className:"row row-sm changes-test row-rails row-edge",id:`${n}-t${a}`,"data-state":gr({current:r===a,cursor:r===a}),"data-sub":!0,role:"option","aria-selected":r===a,tabIndex:-1,onClick:()=>o(a),"data-tip":[...s.group,s.name].join(" · "),"data-tip-placement":"follow",children:[d.jsx("span",{className:`xy ${AF[s.change]}`,children:IF[s.change]}),d.jsx("span",{className:"name",children:s.name})]},a))}),Nk="(?<q>[\"'`])(?<name>(?:\\\\.|(?!\\k<q>).)*)\\k<q>",qx={tests:[new RegExp(`^\\s*(?:test|it)(?:\\.(?!each\\b)\\w+)*(?:\\.each\\(.*\\))?\\(\\s*${Nk}`)],groups:[new RegExp(`^\\s*describe(?:\\.(?!each\\b)\\w+)*(?:\\.each\\(.*\\))?\\(\\s*${Nk}`)]},OF={js:qx,py:{tests:[/^\s*(?:async\s+)?def\s+(?<name>test\w*)\s*\(/],groups:[/^\s*class\s+(?<name>Test\w*)/]},go:{tests:[/^func\s+(?<name>(?:Test|Benchmark|Fuzz|Example)\w*)\s*\(/,/^\s+\w+\.Run\(\s*"(?<name>(?:\\.|[^"\\])*)"/]},rs:{mark:/^\s*#\[(?:\w+::)*(?:test|rstest|test_case)\b/,tests:[/\bfn\s+(?<name>\w+)/]},jvm:{mark:/^\s*@(?:Test|ParameterizedTest|RepeatedTest|TestFactory)\b/,tests:[/\b(?:void|fun)\s+(?<name>`[^`]+`|\w+)\s*\(/]},cs:{mark:/^\s*\[(?:Test|TestCase|Fact|Theory|TestMethod)\b/,tests:[/\b(?:void|Task)\s+(?<name>\w+)\s*\(/]},rb:{tests:[new RegExp(`^\\s*(?:it|specify|test|scenario)\\s*\\(?\\s*${Nk}`),/^\s*def\s+(?<name>test_\w+)/],groups:[/^\s*(?:RSpec\.)?(?:describe|context|feature)\s*\(?\s*(?<name>"[^"]*"|'[^']*'|[\w:]+)/]},exs:{tests:[/^\s*test\s+"(?<name>(?:\\.|[^"\\])*)"/],groups:[/^\s*describe\s+"(?<name>(?:\\.|[^"\\])*)"/]},swift:{tests:[/^\s*(?:@Test\s+)?func\s+(?<name>test\w*)\s*\(/]},php:{tests:[/\bfunction\s+(?<name>test\w*)\s*\(/,...qx.tests]}},MF={js:"js",jsx:"js",mjs:"js",cjs:"js",ts:"js",tsx:"js",mts:"js",cts:"js",py:"py",go:"go",rs:"rs",java:"jvm",kt:"jvm",cs:"cs",rb:"rb",exs:"exs",swift:"swift",php:"php"},LF=3,PF=/^\s*(?:[)}\]]|end\b)/,vg=e=>e.length-e.trimStart().length;function Zx(e,t){var n,r;for(const o of t??[]){const s=(r=(n=o.exec(e))==null?void 0:n.groups)==null?void 0:r.name;if(s!==void 0)return s.replace(/^(["'`])(.*)\1$/,"$2")}return null}function Gx(e,t){const n=t.split(`
126
- `),r=[],o=[];let s=Number.NEGATIVE_INFINITY;return n.forEach((a,c)=>{var g,y,w;if(a.trim()==="")return;const u=vg(a);for(;o.length>0&&(((g=o.at(-1))==null?void 0:g.indent)??0)>=u;)o.pop();(y=e.mark)!=null&&y.test(a)&&(s=c);const h=!e.mark||c-s<=LF?Zx(a,e.tests):null,m=h??Zx(a,e.groups);if(m!==null){if(h!==null){s=Number.NEGATIVE_INFINITY;let v=c+1;for(;v<n.length&&(((w=n[v])==null?void 0:w.trim())===""||vg(n[v]??"")>u);)v++;v<n.length&&vg(n[v]??"")===u&&PF.test(n[v]??"")&&v++;const _=n.slice(c,v).map(x=>x.trim()).join(`
127
- `).trim();r.push({group:o.map(x=>x.name),name:m,line:c,end:v,body:_})}o.push({indent:u,name:m})}}),r}function Vx(e){const t=new Map;for(const n of e){const r=[...n.group,n.name].join(`
128
- `);let o=0;for(;t.has(`${r}
129
- ${o}`);)o++;t.set(`${r}
130
- ${o}`,n)}return t}function DF(e,t,n){const r=OF[MF[e.slice(e.lastIndexOf(".")+1).toLowerCase()]??""];if(!r)return[];const o=Vx(Gx(r,t)),s=Vx(Gx(r,n)),a=[];for(const[h,m]of s){const g=o.get(h);(g==null?void 0:g.body)!==m.body&&a.push({name:m.name,group:m.group,change:g?"changed":"added",line:m.line+1})}const c=n.split(`
131
- `).length;let u=1;for(const[h,m]of o){const g=s.get(h);g?u=Math.min(g.end+1,c):a.push({name:m.name,group:m.group,change:"removed",line:u})}const f=h=>h.change==="removed"?0:1;return a.sort((h,m)=>h.line-m.line||f(h)-f(m))}const zF=[];function FF(e,t,n,r){const o=t?n>0?"no changes of its own":`same as ${e}`:"no changes";if(!r)return o;const s=mr(r.at);return`${o}, last commit ${s==="now"?"just now":`${s} ago`}`}const Yx='[role="option"]:not([data-sub])',Xx=[];function Wj({width:e,placement:t="dock"}){var pn,yr;const n=t==="screen",r=Qe(),o=dt(),s=Dn(),a=ac(),c=za(),u=(c==null?void 0:c.id)??a,f=Us(),h=L(X=>X.layout.changes),m=Wu(),g=L(X=>X.focusChanges),y=It(u,"git"),w=L(X=>X.editor&&X.editor.worktreeId===u?X.editor.path:null),v=L(X=>X.editor&&X.editor.worktreeId===u?X.editor.ref??null:null),_=L(X=>X.editor&&X.editor.worktreeId===u?X.editor.since??null:null),x=(((pn=y==null?void 0:y.extras)==null?void 0:pn.committed)??zF).length>0,N=b3(),T=(yr=y==null?void 0:y.extras)==null?void 0:yr.turn,j=x3(),A=E.useMemo(()=>CF(y,{turn:j,committed:N}),[y,j,N]),{files:R,fileSource:C,turned:M,turnedSource:I,turnBase:D,committed:H,committedSource:Z}=A,B=R.length,J=R.length+M.length,V=L(X=>X.editor&&X.editor.worktreeId===u?X.editor.disk:null),ee=E.useMemo(()=>w!==null&&V&&hh(w)?DF(w,V.before,V.after):Xx,[w,V]),[F,$]=E.useState(!1);at([w,v,_],()=>$(!1));const Q=C>0?R.length-C:0,q=Z>0?H.length-Z:0,W=I>0?M.length-I:0,oe=R.length===0,de=E.useMemo(()=>{if(R.length===0)return;const X=R.reduce((Mt,On)=>Mt+(On.add??0),0),ge=R.reduce((Mt,On)=>Mt+(On.del??0),0),Ge=[X>0&&`+${X}`,ge>0&&`−${ge}`].filter(Boolean).join(" "),Vt=`${R.length} uncommitted ${R.length===1?"file":"files"}`;return Ge?`${Vt}, ${Ge}`:Vt},[R]),he=!!y&&oe&&(y.ahead??0)===0,Ne=L(Jl),Me=c!==null||Ne==="changes",Be=c!==null||Ne==="history",K=E.useCallback(X=>o({a:"changes-tab",v:X}),[o]),te=E.useRef(Ne);te.current=Ne;const pe=E.useRef(null),ue=ny(),ie=L(X=>{const ge=ws(X,ue==null?void 0:ue.repoId);return ge?Dh(ge):"main"}),ye=It(u,"commits"),Se=It(u,"commitFiles"),[Ee,Le]=E.useState(null),Ue=E.useRef(null);Ue.current=Ee;const Je=E.useRef(null),Ht=It(u,"changedRanges"),qt=E.useCallback((X,ge)=>{if(!u||c)return;if(!ge){Je.current=null,un.post(u,{type:"highlight-clear"});return}Je.current=X;const Ge=Ht[X];Ge?un.post(u,{type:"highlight-file",path:X,ranges:ax(Ge)}):r==null||r.send({t:"changed-ranges",worktreeId:u,path:X})},[u,c,Ht,r]);E.useEffect(()=>{const X=Je.current;if(!X||!u)return;const ge=Ht[X];ge&&un.post(u,{type:"highlight-file",path:X,ranges:ax(ge)})},[Ht,u]);const xt=c&&R.length>0?(y==null?void 0:y.head)??null:null,Ze=E.useCallback((X,ge=!1,Ge)=>u&&Pn({dispatch:o},{worktreeId:u,path:X,focus:ge,ref:xt??void 0,since:Ge}),[u,xt,r,o]),_t=E.useMemo(()=>c?R:[...R,...M,...H],[c,R,M,H]),mt=E.useMemo(()=>{const X=[];for(const ge of ye??[])if(X.push({commit:ge}),ge.sha===Ee)for(const Ge of Wf(Se[ge.sha]??[]).files)X.push({commit:ge,file:Ge});return X},[ye,Ee,Se]),De=E.useMemo(()=>mt.filter(X=>!X.file&&X.commit.ahead).length,[mt]),nt=E.useMemo(()=>mt.findIndex(X=>!X.file&&!X.commit.ahead),[mt]),lt=c?_t.length:0,Yt=(Me?_t.length:0)+(Be?mt.length:0),$n=E.useMemo(()=>{const X=new Map;if(!c||R.length===0&&mt.every(Ge=>Ge.commit.landedAt))return X;let ge;return mt.forEach((Ge,Vt)=>{const Mt=!!Ge.commit.landedAt;Mt!==ge&&(ge=Mt,X.set(Vt,Mt?"landed":"not landed"))}),X},[c,R,mt]),gt=E.useRef(null),[{row:rt,at:Kn},Qt]=E.useReducer((X,ge)=>typeof ge=="number"?{row:ge,at:-1}:ge,{row:0,at:-1}),[Cn,qn]=E.useState(!1),dn=(X,ge)=>Cn?sr(X):ge,yn=X=>`changes-row-${X}`,[ne,we]=E.useState(!1),[qe,ot]=E.useState([]),Tt=E.useCallback(()=>{we(!1),ot([])},[]),Dt=E.useCallback(X=>{we(!0),ot(ge=>ge.includes(X)?ge.filter(Ge=>Ge!==X):[...ge,X])},[]),P=E.useMemo(()=>R.filter(X=>qe.includes(X.path)).map(X=>X.path),[R,qe]);at([R],()=>ot(X=>{const ge=X.filter(Ge=>R.some(Vt=>Vt.path===Ge));return ge.length===X.length?X:ge})),at([ne],()=>{if(!ne)return;const X=ge=>ge.key==="Escape"&&Tt();return window.addEventListener("keydown",X),()=>window.removeEventListener("keydown",X)}),at([u,Ne],()=>{Qt(0),Tt()});const se=y==null?void 0:y.head,je=E.useRef("");E.useEffect(()=>{if(!(Be||he)||!u)return;const X=`${u}:${se??""}`;je.current!==X&&(je.current=X,r==null||r.send({t:"git-log",worktreeId:u}))},[Be,he,u,se,r]);const Fe=E.useCallback(X=>{Le(ge=>ge===X?null:X),u&&!Se[X]&&(r==null||r.send({t:"git-commit",worktreeId:u,sha:X}))},[u,Se,r]);at([rt,Kn,Cn],()=>{var X,ge;Cn&&((ge=(X=gt.current)==null?void 0:X.querySelector('[data-state~="cursor"]'))==null||ge.scrollIntoView({block:"nearest"}))});const Rt=E.useRef(-1),Zt=X=>X>=B&&X<J?D:void 0,Ae=X=>{var ge;return((ge=_t[X])==null?void 0:ge.path)===w&&(_??void 0)===Zt(X)&&(X<B?v===xt:!v)};Rt.current=Me?_t.findIndex((X,ge)=>Ae(ge)):-1,E.useEffect(()=>{if(!g)return;const X=te.current==="files";Rt.current>=0&&Qt(Rt.current);const ge=requestAnimationFrame(()=>{var Ge;return(Ge=(X?pe:gt).current)==null?void 0:Ge.focus()});return()=>cancelAnimationFrame(ge)},[g]);const We=E.useCallback((X,ge=!1)=>{const Ge=_t[X];Ge&&(Qt(X),Ze(Ge.path,ge,X>=B&&X<J?D:void 0),qt(Ge.path,!0))},[_t,Ze,qt,B,J,D]),Ve=E.useCallback((X,ge=!1)=>{const Ge=Ue.current;u&&Ge&&Pn({dispatch:o},{worktreeId:u,path:X,ref:Ge,focus:ge})},[u,r,o]),Xt=E.useCallback(X=>{const ge=mt[X-lt];ge&&(Qt(X),ge.file&&Ve(ge.file.path))},[mt,lt,Ve]),Wt=E.useCallback(X=>{const ge=mt[X-lt];ge&&(Qt(X),ge.file?Ve(ge.file.path,!0):Fe(ge.commit.sha))},[mt,lt,Ve,Fe]),bn=X=>Be&&X>=lt,xn=X=>{if(w===null)return!1;if(Me&&X<_t.length)return Ae(X);const ge=bn(X)?mt[X-lt]:void 0;return!!(ge!=null&&ge.file)&&v===ge.commit.sha&&ge.file.path===w},Ct=X=>xn(X)&&!F?ee:Xx,Jt=Kn<Ct(rt).length?Kn:-1,sr=X=>Cn&&rt===X&&Jt<0,Gt=()=>{var ge,Ge;const X=[];for(let Vt=0;Vt<Yt;Vt++){const Mt=bn(Vt)?mt[Vt-lt]:void 0,On=Mt?(ge=Mt.file)==null?void 0:ge.path:(Ge=_t[Vt])==null?void 0:Ge.path,Sn=Mt!=null&&Mt.file?1:0,zn=Ct(Vt);Mt&&!Mt.file?X.push({row:Vt,at:-1,depth:Sn,open:Mt.commit.sha===Ee}):On!==void 0&&hh(On)?X.push({row:Vt,at:-1,depth:Sn,open:zn.length>0}):X.push({row:Vt,at:-1,depth:Sn});for(let ir=0;ir<zn.length;ir++)X.push({row:Vt,at:ir,depth:Sn+1})}return X},Rn=(X,ge=!1)=>{const Ge=ee[X];!Ge||!u||w===null||Pn({dispatch:o},{worktreeId:u,path:w,ref:v??void 0,since:_??void 0,line:{n:Ge.line},focus:ge})},fn=X=>Ct(X).length>0&&d.jsx(RF,{tests:ee,id:yn(X),cursor:Cn&&rt===X?Jt:-1,onPick:ge=>{Qt({row:X,at:ge}),Rn(ge)}}),ae=X=>{var ge;if(ne&&X.key==="Escape")X.preventDefault(),X.stopPropagation(),Tt();else if(ne&&X.key===" "){X.preventDefault();const Ge=Me&&rt<R.length?R[rt]:void 0;Ge&&Dt(Ge.path)}else if(X.key==="ArrowDown"&&Jt+1<Ct(rt).length)X.preventDefault(),Qt({row:rt,at:Jt+1}),Rn(Jt+1);else if(X.key==="ArrowUp"&&Jt>=0)X.preventDefault(),Jt===0?Qt(rt):(Qt({row:rt,at:Jt-1}),Rn(Jt-1));else if(X.key==="Enter"&&Jt>=0)X.preventDefault(),Rn(Jt,!0);else if(X.key==="ArrowDown"||X.key==="ArrowUp"){X.preventDefault();const Ge=Gu(rt,X.key==="ArrowDown"?1:-1,Yt);bn(Ge)?Xt(Ge):We(Ge)}else if(X.key==="Enter")X.preventDefault(),bn(rt)?Wt(rt):We(rt,!0);else if(X.key==="ArrowRight"||X.key==="ArrowLeft"){X.preventDefault();const Ge=Gt(),Vt=fp(Ge,Ge.findIndex(Sn=>Sn.row===rt&&Sn.at===Jt),X.key),Mt=Vt&&Ge[Vt.at];if(!Vt||!Mt)return;const On=bn(Mt.row)?mt[Mt.row-lt]:void 0;Vt.do==="to"?Mt.at>=0?(Qt({row:Mt.row,at:Mt.at}),Rn(Mt.at)):On!=null&&On.file&&Mt.row>rt?Xt(Mt.row):Qt(Mt.row):On&&!On.file?Fe(On.commit.sha):Vt.do==="close"?$(!0):xn(Mt.row)?$(!1):On!=null&&On.file?Xt(Mt.row):We(Mt.row)}else X.key==="Escape"&&(X.stopPropagation(),w!==null?o({a:"close-editor"}):(ge=document.activeElement)==null||ge.blur())},_e=c?c.id:f==null?void 0:f.worktree.id,ht=c?c.path:f?f.worktree.path:"",ct=c!==null,zt=E.useMemo(()=>_e?(X,ge)=>$u(ge,{kind:"paths",worktreeId:_e,items:[{path:X,folder:!1}]}):void 0,[_e]),kn=E.useRef(P);kn.current=P;const Pr=E.useMemo(()=>_e?(X,ge)=>{const Ge=kn.current;if(!Ge.includes(X))return zt==null?void 0:zt(X,ge);$u(ge,{kind:"paths",worktreeId:_e,items:Ge.map(Vt=>({path:Vt,folder:!1}))})}:void 0,[_e,zt]),cr=E.useCallback(()=>Yu(s),[s]),ln=E.useCallback(X=>_e?Ls({id:_e,dir:ht},X,{discard:!ct,kept:ct,ref:xt??void 0,select:ct?void 0:Dt},{sock:r,dispatch:o}):[],[_e,ht,ct,xt,Dt,r,o]),ur=E.useCallback(X=>_e?Ls({id:_e,dir:ht},X,{kept:ct},{sock:r,dispatch:o}):[],[_e,ht,ct,r,o]),nn=E.useCallback(X=>_e?Ls({id:_e,dir:ht},X,{kept:ct,since:D},{sock:r,dispatch:o}):[],[_e,ht,ct,D,r,o]),Bt=E.useCallback(X=>_e?Ls({id:_e,dir:ht},X,{ref:Ue.current??void 0,kept:ct},{sock:r,dispatch:o}):[],[_e,ht,ct,r,o]),Ft=vn("changes"),be=()=>{if(Me&&rt<_t.length){const ge=_t[rt];return ge?(rt<B?ln:rt<J?nn:ur)(ge.path):[]}const X=bn(rt)?mt[rt-lt]:void 0;return X?X.file?Bt(X.file.path):bj(X.commit):[]},Ye=(X,ge)=>{const Ge=_t.findIndex((Vt,Mt)=>Mt>=X&&Vt.path===ge);Qt(Ge),Ae(Ge)&&ee.length>0?$(Vt=>!Vt):Ze(ge,!1,Zt(Ge))},wt=E.useRef(Ye);wt.current=Ye;const yt=E.useCallback(X=>wt.current(0,X),[]),cn=E.useCallback(X=>wt.current(B,X),[B]),hn=E.useCallback(X=>wt.current(J,X),[J]),wr=E.useCallback(X=>{Qt(lt+mt.findIndex(ge=>!ge.file&&ge.commit.sha===X)),Fe(X)},[mt,lt,Fe]),Zn=E.useCallback(X=>{Qt(lt+mt.findIndex(ge=>{var Ge;return((Ge=ge.file)==null?void 0:Ge.path)===X})),X===w&&v===Ue.current&&ee.length>0?$(ge=>!ge):Ve(X)},[mt,lt,Ve,w,v,ee]),Ut=E.useCallback(()=>{},[]);return d.jsxs("div",{className:Ke("changes-dock",n&&"changes-screen",!n&&(!h||m)&&"collapsed"),style:n?void 0:{width:e},children:[!c&&d.jsx(Vu,{fill:!n,quiet:n,owner:"changes-tabs",label:"changes panel",items:[{id:"files",label:d.jsx(kt,{name:"folder",className:"icon-inline"}),fit:!0,ariaLabel:"files",tip:Lt("files",Pt("files"))},{id:"changes",label:"changes",tip:Lt("changes",Pt("changes"),{detail:de})},{id:"history",label:"history"}],current:Ne,onPick:K}),Ne==="files"&&u?d.jsx(_F,{worktreeId:u,dir:f?f.worktree.path:(ue==null?void 0:ue.path)??"",openPath:w,openRef:v,rootRef:pe}):d.jsxs("div",{className:Ke("changes-list",Be&&"history"),role:"listbox","aria-label":c?"kept work":Be?"commits":"changed files","aria-activedescendant":Cn&&rt>=0&&rt<Yt?Jt<0?yn(rt):`${yn(rt)}-t${Jt}`:void 0,tabIndex:0,ref:gt,onKeyDown:ae,onFocus:()=>qn(!0),onMouseDown:X=>{var Vt;if(X.button!==0)return;X.preventDefault();const ge=X.target.closest(Yx),Ge=ge?Array.from(X.currentTarget.querySelectorAll(Yx)).indexOf(ge):-1;Ge>=0&&Qt(Ge),(Vt=gt.current)==null||Vt.focus()},onBlur:X=>!X.currentTarget.contains(X.relatedTarget)&&qn(!1),...Ft.contextMenu(X=>X==="keyboard"?be():[]),children:[Me&&R.length>0&&d.jsxs(d.Fragment,{children:[(x||((y==null?void 0:y.ahead)??0)>0||c)&&d.jsx("div",{className:"section-title section-row",children:"uncommitted"}),R.map((X,ge)=>d.jsxs(E.Fragment,{children:[Q>0&&ge===C&&d.jsx("div",{className:"section-title changes-sub",children:"tests"}),d.jsx(jf,{f:X,id:yn(ge),active:dn(ge,xn(ge)),selected:sr(ge),checking:ne,checked:qe.includes(X.path),onOpen:yt,onCheck:ct?void 0:Dt,menu:ln,onHover:qt,onDragStart:Pr,onDragEnd:cr}),fn(ge)]},`${X.xy}:${X.path}`))]}),Me&&!c&&T&&d.jsxs(d.Fragment,{children:[d.jsxs("button",{type:"button",className:"section-title section-row section-fold","aria-expanded":j,"data-tip":"What changed since your last message","data-tip-placement":"follow",onClick:()=>o({a:"toggle-turn"}),onKeyDown:X=>(X.key==="Enter"||X.key===" ")&&X.stopPropagation(),children:["last turn",d.jsx(kt,{name:"caret",className:Ke("icon-inline disc-caret",!j&&"shut")})]}),M.map((X,ge)=>d.jsxs(E.Fragment,{children:[W>0&&ge===I&&d.jsx("div",{className:"section-title changes-sub",children:"tests"}),d.jsx(jf,{f:X,id:yn(B+ge),active:dn(B+ge,xn(B+ge)),selected:sr(B+ge),onOpen:cn,menu:nn,onHover:qt,onDragStart:zt,onDragEnd:cr}),fn(B+ge)]},`t-${X.path}`))]}),Me&&!c&&x&&d.jsxs(d.Fragment,{children:[d.jsxs("button",{type:"button",className:"section-title section-row section-fold","aria-expanded":N,"data-tip":`Committed on this branch, not yet on ${ie}`,"data-tip-placement":"follow",onClick:()=>o({a:"toggle-committed"}),onKeyDown:X=>(X.key==="Enter"||X.key===" ")&&X.stopPropagation(),children:["committed",d.jsx(kt,{name:"caret",className:Ke("icon-inline disc-caret",!N&&"shut")})]}),H.map((X,ge)=>d.jsxs(E.Fragment,{children:[q>0&&ge===Z&&d.jsx("div",{className:"section-title changes-sub",children:"tests"}),d.jsx(jf,{f:X,id:yn(J+ge),active:dn(J+ge,xn(J+ge)),selected:sr(J+ge),onOpen:hn,menu:ur,onHover:qt,onDragStart:zt,onDragEnd:cr}),fn(J+ge)]},`c-${X.path}`))]}),Me&&!c&&he&&d.jsx("div",{className:"empty",children:FF(ie,!!ue&&Mh(ue),(y==null?void 0:y.behind)??0,ye==null?void 0:ye[0])}),Be&&mt.map((X,ge)=>d.jsxs(E.Fragment,{children:[c&&$n.has(ge)&&d.jsx("div",{className:"section-title section-row",children:$n.get(ge)}),!c&&De>0&&ge===0&&d.jsx("div",{className:"section-title section-row",children:"on this branch"}),!c&&De>0&&ge===nt&&d.jsx("div",{className:"section-title section-row",children:ie}),X.file?d.jsxs(d.Fragment,{children:[d.jsx(jf,{f:X.file,id:yn(lt+ge),active:dn(lt+ge,xn(lt+ge)),selected:sr(lt+ge),onOpen:Zn,menu:Bt,onHover:Ut,onDragStart:zt,onDragEnd:cr}),fn(lt+ge)]}):d.jsx(vF,{c:X.commit,id:yn(lt+ge),selected:sr(lt+ge),onToggle:wr})]},X.file?`${X.commit.sha}:${X.file.path}`:X.commit.sha)),Be&&ye===void 0&&d.jsx("div",{className:"empty",children:d.jsx("span",{className:"live-text",children:"reading history"})}),Be&&(ye==null?void 0:ye.length)===0&&R.length===0&&d.jsx("div",{className:"empty",children:"no commits yet"})]}),ne&&d.jsxs("div",{className:"changes-pick",children:[d.jsxs(Oe,{size:"md",tone:"danger",disabled:P.length===0,"data-tip":"Throw away the uncommitted changes to every checked file",onClick:()=>{!_e||P.length===0||window.confirm(LN(P))&&(r==null||r.send({t:"discard-files",worktreeId:_e,paths:P}),Tt())},children:["discard ",P.length,"…"]}),d.jsx(Oe,{size:"md",disabled:P.length===0,"data-tip":"Name every checked file in the chat",onClick:()=>{_e&&i6(s,_e,P),Tt()},children:"add to chat"}),d.jsx(At,{icon:"close",label:"Cancel",hint:"esc",onClick:Tt})]}),ue&&!c&&d.jsx(yF,{active:ue,ahead:(y==null?void 0:y.ahead)??ue.ahead??0,behind:(y==null?void 0:y.behind)??ue.behind??0,unpushed:(y==null?void 0:y.unpushed)??ue.unpushed??0,dirty:!oe})]})}function BF(e){var t;if((e==null?void 0:e.kind)==="account")return[(t=e.account)==null?void 0:t.email,e.label].filter(Boolean).join(" · ")}function Qx(e){if(e<1e3)return String(Math.round(e));const t=e/1e3;return`${t<10?t.toFixed(1).replace(/\.0$/,""):Math.round(t)}k`}function Xu(e){return e>0&&e<.005?"<$0.01":`$${e.toFixed(2)}`}function UF(e){const t=`${Math.round(100*e)}% full`;return e<.5?`${t}: plenty of room, no need yet`:e<.8?`${t}: worth doing between tasks`:`${t}: do it before the next task`}function HF(e){if(!(e<.5))return e<.8?"worth compacting between tasks":"compact before the next task"}const Kj=["five_hour","seven_day","seven_day_overage_included"],WF={five_hour:"the 5-hour window",seven_day:"the week",seven_day_overage_included:"the Fable week"},KF={five_hour:"5-hour",seven_day:"this week",seven_day_overage_included:"Fable week"};function qj(e,t){return Kj.flatMap(n=>{const r=e.windows[n];return r&&r.resetsAt>t?[{key:n,used:r.used,resetsAt:r.resetsAt}]:[]})}function qF(e,t){return Math.min(1,Math.max(0,...qj(e,t).map(n=>n.used)))}const ZF=e=>`${Math.round(100*e)}%`;function Jx(e,t){const n=qj(e,t).map(r=>`${ZF(r.used)} of ${WF[r.key]}`);return n.length?n.join(", "):"plan windows reset"}function GF(e,t,n){const r=new Date(e),o=new Date(t),s=r.toDateString()===o.toDateString();return new Intl.DateTimeFormat(n,{...s?{}:{month:"short",day:"numeric"},hour:"numeric",minute:"2-digit"}).format(r)}function VF(e,t,n=r=>GF(r,t)){return Kj.flatMap(r=>{const o=e.windows[r];if(!o)return[];const s=KF[r];if(o.resetsAt<=t)return[{key:r,name:s,used:0,sub:`reset ${n(o.resetsAt)}, read again on the next reply`}];const a=e.binding===r&&e.status==="rejected"?", out until then":e.binding===r&&e.status==="allowed_warning"?", nearly out":"";return[{key:r,name:s,used:o.used,sub:`resets ${n(o.resetsAt)}${a}`}]})}function YF(e){const t=e.auto?"Auto archived":"Archived",n=e.auto?"Merged, auto archived":"Merged",r=e.landed?n:e.uncommitted?`${t} with uncommitted changes`:t;return e.restorable?r:`${r}, commits not kept`}function Zj(e){const t=[e.landed?"merged":e.uncommitted?"uncommitted changes":null];return e.restorable||t.push("commits not kept"),e.cost!==void 0&&t.push(Xu(e.cost)),t.push(mr(e.archivedAt)),t.filter(Boolean).join(" · ")}function Gj({sock:e},t,n){e==null||e.send({t:"restore-worktree",archiveId:t,clientId:n})}function Kf(e,t,{sock:n,dispatch:r}){const o=[{id:"restore",label:"restore",disabled:e.restorable?void 0:"its commits were not kept",onClick:()=>{Gj({sock:n},e.id,t.clientId),r({a:"close"})}}],s=[{id:"copy-branch",label:"copy branch name",onClick:()=>tn(e.branch)}];s.push(...Ho(()=>n==null?void 0:n.send({t:"reveal-transcript",worktreeId:e.id}),po(n),"reveal transcript in Finder"));const{sessionId:a}=e;return t.frame!=="phone"&&a&&s.push({id:"copy-session",label:"copy session id",onClick:()=>tn(a)}),Wn([o,s,[{id:"delete",label:"delete…",danger:!0,onClick:()=>{window.confirm(`Delete "${e.title}"?
132
-
133
- Its chat, attachments and kept commits go with it, and it cannot be restored.`)&&(n==null||n.send({t:"delete-archived",archiveId:e.id}))}}]])}const XF=new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"});function Vj(e){const[t,n]=E.useState(()=>Date.now());return E.useEffect(()=>{const r=setInterval(()=>n(Date.now()),6e4);return()=>clearInterval(r)},[]),`${Hw(t-e)} ago`}function lr({icon:e,word:t,tone:n,at:r,below:o,under:s,children:a,...c}){const u=r!==void 0?{"data-tip":`${t} ${XF.format(r)}`,"data-tip-placement":"top"}:null,f=(Array.isArray(o)?o:[o]).filter(h=>h!=null&&h!==!1);return d.jsx("div",{...c,className:"daemon-row row-edge","data-tone":n,children:d.jsxs("div",{className:"daemon-head",children:[d.jsxs("span",{...u,className:"daemon-tag",children:[d.jsx(kt,{name:e,className:"icon-inline"}),t]}),d.jsxs("div",{className:"daemon-body",children:[d.jsx("div",{className:"daemon-line",children:a}),f.map((h,m)=>d.jsx("div",{className:"daemon-below row-dim",children:h},m)),s]})]})})}function QF({item:e}){const t=Qe(),n=L(u=>u.clientId),r=e.uncommitted?"its chat, commits and uncommitted changes":"its chat and commits",o=e.cost!==void 0?`; the session cost ${Xu(e.cost)}`:"",s=e.restorable?`Toyon kept ${r}${o}. A message sent below restores it first.`:`Its commits were not kept, so there is nothing to restore${o}; its row's menu on the rail can delete it.`,a=Vj(e.archivedAt),c=wy(e.lands);return d.jsxs(lr,{icon:"archive",word:"archived",tone:"quiet",at:e.archivedAt,below:[...c,s],children:[d.jsxs("span",{className:"daemon-text",children:[a,e.landed?", after it was merged into main":""]}),e.restorable&&d.jsx(Oe,{variant:"inline",tone:"strong",onClick:()=>Gj({sock:t},e.id,n),children:"restore"})]})}function ja(e,t,n,r,o){const{layout:s}=e.getState();Pn({dispatch:e.dispatch},{worktreeId:n,path:r,view:"file",line:{n:o,fiber:!0}}),s.changes||e.dispatch({a:"toggle-changes"})}function JF(e){let t=0;return e.map(n=>{const r={start:t,len:n};return t+=n,r})}function e8(e,t){if(!t)return[];const n=new RegExp(t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"giu"),r=[];for(const o of e.matchAll(n))r.push({start:o.index,end:o.index+o[0].length});return r}function e1(e,t,n){let r=0,o=e.length-1;for(;r<o;){const a=r+o>>1,c=e[a];(n?t>c.start+c.len:t>=c.start+c.len)?r=a+1:o=a}const s=e[r];return{i:r,at:t-s.start}}function t8(e,t){return{from:e1(e,t.start,!1),to:e1(e,t.end,!0)}}function t1(e,t){if(e.length===0)return-1;const n=e.findIndex(r=>r.start>=t);return n===-1?0:n}function n8(e,t,n){return t===0?-1:(e+n+t)%t}function Ey(e){return e.key==="f"&&(e.metaKey||e.ctrlKey)&&!e.altKey&&!e.shiftKey}function r8({label:e,query:t,onQuery:n,seed:r,seq:o,status:s,none:a,onStep:c,onClose:u}){const f=E.useRef(null);return at([o],()=>{var h,m;r&&n(r),(h=f.current)==null||h.focus(),(m=f.current)==null||m.select()}),d.jsxs("div",{className:"find",children:[d.jsx(Bo,{ref:f,autoFocus:!0,value:t,onChange:h=>n(h.target.value),placeholder:"find…","aria-label":e,className:"find-field",spellCheck:!1,onKeyDown:h=>{if(h.key==="Escape"){h.preventDefault(),h.stopPropagation(),u();return}if(h.key==="Enter"){h.preventDefault(),c(h.shiftKey?-1:1);return}if(Ey(h)){h.preventDefault(),h.stopPropagation(),h.currentTarget.select();return}h.key.toLowerCase()==="g"&&(h.metaKey||h.ctrlKey)&&!h.altKey&&(h.preventDefault(),h.stopPropagation(),c(h.shiftKey?-1:1))}}),d.jsx("span",{className:"find-count","aria-live":"polite",children:s}),d.jsx(At,{icon:"caret",label:"Previous match",hint:"⇧↩",className:"find-prev",disabled:a,onClick:()=>c(-1)}),d.jsx(At,{icon:"caret",label:"Next match",hint:"↩",disabled:a,onClick:()=>c(1)}),d.jsx(At,{icon:"close",label:"Close",hint:"esc",onClick:u})]})}const Yj="find",Xj="find-current",Qj=typeof CSS<"u"&&"highlights"in CSS;function o8(e){const t=e.parentElement;return t?typeof t.checkVisibility=="function"?t.checkVisibility():!0:!1}function s8(e,t){const n=e instanceof Element?e:e.parentElement;return!!(n!=null&&n.closest(t))}function i8(e,t){const n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_TEXT,o=>o instanceof Element?t&&o.matches(t)?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_SKIP:NodeFilter.FILTER_ACCEPT),r=[];for(let o=n.nextNode();o;o=n.nextNode()){const s=o;s.data.length>0&&o8(s)&&r.push(s)}return r}const jk={matches:[],ranges:[]};function a8(e,t,n){if(!t)return jk;const r=i8(e,n),o=e8(r.map(c=>c.data).join(""),t),s=JF(r.map(c=>c.data.length)),a=o.map(c=>{const{from:u,to:f}=t8(s,c),h=document.createRange();return h.setStart(r[u.i],u.at),h.setEnd(r[f.i],f.at),h});return{matches:o,ranges:a}}function l8(e,t){Qj&&(CSS.highlights.set(Yj,new Highlight(...e.filter((n,r)=>r!==t))),CSS.highlights.set(Xj,new Highlight(...e[t]?[e[t]]:[])))}function c8(){Qj&&(CSS.highlights.delete(Yj),CSS.highlights.delete(Xj))}function u8(e,t){if(e.length===0)return-1;const n=t.getBoundingClientRect().top,r=e.findIndex(o=>o.getBoundingClientRect().bottom>=n);return r===-1?0:r}const n1=48;function d8(e,t){const n=t.getBoundingClientRect(),r=e.getBoundingClientRect(),o=parseFloat(getComputedStyle(e).getPropertyValue("--scroll-foot"))||0;n.top>=r.top+n1&&n.bottom<=r.bottom-o-n1||(e.scrollTop+=n.top-r.top-r.height/3)}function Jj({root:e,body:t,seed:n,seq:r,onClose:o,onReveal:s,skip:a}){const[c,u]=E.useState(n),[f,h]=E.useState(jk),[m,g]=E.useState(-1),y=E.useRef({found:jk,at:-1}),w=E.useRef(""),v=E.useRef(!1),[_,x]=E.useState(0);E.useLayoutEffect(()=>{const A=t.current;if(!A)return;let R=0;const C=new MutationObserver(M=>{a&&M.every(I=>s8(I.target,a))||R||(R=requestAnimationFrame(()=>{R=0,x(I=>I+1)}))});return C.observe(A,{childList:!0,characterData:!0,subtree:!0,attributes:!0}),()=>{C.disconnect(),R&&cancelAnimationFrame(R)}},[t,a]),E.useLayoutEffect(()=>{const A=t.current;if(!A)return;const R=a8(A,c,a),C=c!==w.current;w.current=c,C&&(v.current=!0);const{found:M,at:I}=y.current;let D;C?M.matches[I]?D=t1(R.matches,M.matches[I].start):D=e.current?u8(R.ranges,e.current):t1(R.matches,0):D=Math.min(I,R.matches.length-1),y.current={found:R,at:D},h(R),g(D)},[c,_,a]),E.useLayoutEffect(()=>{l8(f.ranges,m);const A=f.ranges[m];A&&(v.current&&e.current&&(d8(e.current,A),s==null||s()),v.current=!1)},[f,m,e,s]),E.useLayoutEffect(()=>c8,[]);const N=f.matches.length,T=A=>{if(N===0)return;v.current=!0;const R=n8(y.current.at,N,A);y.current={...y.current,at:R},g(R)},j=()=>o(f.ranges[m]??null);return d.jsx(r8,{label:"find in this document",query:c,onQuery:u,seed:n,seq:r,status:c?N===0?"no matches":`${m+1}/${N}`:"",none:N===0,onStep:T,onClose:j})}function eT(e){return e.key==="a"&&(e.metaKey||e.ctrlKey)&&!e.altKey&&!e.shiftKey}function tT(e,t,n,r,o){E.useEffect(()=>{let s=!1;const a=u=>{const f=u.target instanceof Element?u.target:null;s=!!e.current&&!!f&&e.current.contains(f)&&!(o&&f.closest(o))},c=u=>{const f=e.current;if(!f||u.defaultPrevented||!t(u))return;const h=document.activeElement;o&&(h!=null&&h.closest(o))||!(h&&h!==document.body?f.contains(h):s)&&!(r!=null&&r(h))||(u.preventDefault(),n(f,u))};return window.addEventListener("pointerdown",a,!0),window.addEventListener("keydown",c),()=>{window.removeEventListener("pointerdown",a,!0),window.removeEventListener("keydown",c)}},[e,t,n,r,o])}function f8(e,t){const n=E.useCallback(r=>{var o;return nT(r,(o=t==null?void 0:t.upTo)==null?void 0:o.call(t,r))},[t]);tT(e,eT,n,void 0,t==null?void 0:t.except)}function Tk(e){const t=window.getSelection();if(!t||t.isCollapsed||t.rangeCount===0||!e.contains(t.getRangeAt(0).commonAncestorContainer))return null;const n=t.toString().replace(/^\n+|\n+$/g,"");return n.trim()?n:null}function nT(e,t){const n=document.createRange();n.selectNodeContents(e),t&&n.setEndBefore(t);const r=window.getSelection();r&&(r.removeAllRanges(),r.addRange(n))}function h8(e){return e.shiftKey||e.altKey||e.metaKey||e.ctrlKey?null:e.key==="ArrowLeft"?-1:e.key==="ArrowRight"?1:null}function p8(e,t,n){const r=e+n;return r<0||r>=t?null:r}const rT=E.createContext(null),m8="input, textarea, [contenteditable]";function r1(e){return[...e.values()].filter(t=>{var n;return(n=t.el())==null?void 0:n.isConnected}).sort((t,n)=>{const r=t.el(),o=n.el();return!r||!o||r===o?0:r.compareDocumentPosition(o)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1})}function mp({children:e}){const t=E.useRef(new Map),[n,r]=E.useState(null),o=E.useRef(n);o.current=n;const s=E.useMemo(()=>{const c=u=>{const f=r1(t.current),h=f.findIndex(m=>m.id===u);r(h<0?null:{id:u,at:h,of:f.length})};return{register(u){return t.current.set(u.id,u),()=>{var f;t.current.delete(u.id),((f=o.current)==null?void 0:f.id)===u.id&&r(null)}},open:c,step(u){const f=o.current;if(!f)return;const h=r1(t.current),m=h.findIndex(w=>w.id===f.id),g=m<0?null:p8(m,h.length,u),y=g===null?void 0:h[g];y&&c(y.id)},close(){var h,m,g;const u=o.current;if(r(null),!u)return;const f=document.activeElement;f!=null&&f.matches(m8)||(g=(m=(h=t.current.get(u.id))==null?void 0:h.el())==null?void 0:m.querySelector(".chip-link"))==null||g.focus({preventScroll:!0})}}},[]),a=E.useMemo(()=>({api:s,shown:n}),[s,n]);return d.jsx(rT.Provider,{value:a,children:e})}function g8(e,t){const n=E.useContext(rT),r=E.useId(),[o,s]=E.useState(!1),a=n==null?void 0:n.api;if(E.useLayoutEffect(()=>{if(!(!a||!t))return a.register({id:r,el:()=>e.current})},[a,r,t,e]),!a)return{open:o,show:()=>s(!0),close:()=>s(!1),nav:void 0};const c=(n==null?void 0:n.shown)??null,u=(c==null?void 0:c.id)===r;return{open:u,show:()=>a.open(r),close:a.close,nav:u&&c?{at:c.at,of:c.of,step:a.step}:void 0}}function $k(e,t){const n=e.filter(o=>o.id!==t),r=n.filter(o=>o.agent==="waiting"||o.unseen).length;return r===0?null:{n:r,tier:n.some(o=>o.agent==="waiting")?"waiting":"unseen"}}function oT(e,t,n){const r=f=>e.map((h,m)=>f(h)&&h.id!==t?m:-1).filter(h=>h>=0),s=[()=>r(f=>f.agent==="waiting"),()=>r(f=>!!f.unseen),()=>r(f=>f.agent==="working")].reduce((f,h)=>f.length>0?f:h(),[]),a=e.findIndex(f=>f.id===t),c=n>0?s.find(f=>f>a)??s[0]:s.findLast(f=>f<a)??s[s.length-1],u=c===void 0?void 0:e[c];return u?{activate:u.id}:null}function Sy(e,t,n){const r=oT(e,t,n);if(r)return r;const o=e[0];return o&&o.id!==t?{activate:o.id}:null}function k8(e,t,n){const r=[$k(e,t),...n.map(o=>$k(o.rows,null))].filter(o=>o!==null);return r.length===0?null:{n:r.reduce((o,s)=>o+s.n,0),tier:r.some(o=>o.tier==="waiting")?"waiting":"unseen"}}function w8(e,t,n){const r=[s=>s.agent==="waiting",s=>!!s.unseen];for(const s of r){if(e.some(a=>s(a)&&a.id!==t)){const a=oT(e,t,1);return a&&{origin:null,activate:a.activate}}for(const a of n){const c=a.rows.find(s);if(c)return{origin:a.origin,activate:c.id}}}const o=Sy(e,t,1);return o&&{origin:null,activate:o.activate}}function sT(e,{sock:t,dispatch:n}){var m,g;const r=y=>y?"hide":"show",o=e.repos.some(y=>y.id===e.activeRepoId),s=(m=Kt(e,e.activeId))==null?void 0:m.worktree.id,a=[];o&&(a.push({id:"new",label:"new worktree…",key:Pt("new"),onClick:()=>n({a:"open-draft"})}),a.push({id:"refs",label:"open a branch or PR…",key:Pt("refs"),onClick:()=>n({a:"open",overlay:{kind:"refs"}})})),s&&(a.push({id:"jump",label:"jump to file…",key:Pt("quick-open"),onClick:()=>n({a:"open",overlay:{kind:"quick-open"}})}),a.push({id:"search",label:"search in files…",key:Pt("search"),onClick:()=>n({a:"open",overlay:{kind:"search"}})})),Su(e)&&a.push({id:"routes",label:"go to page…",key:Pt("routes"),onClick:()=>n({a:"open",overlay:{kind:"routes"}})}),o&&a.push({id:"chats",label:"search chats…",key:Pt("chats"),onClick:()=>n({a:"open",overlay:{kind:"chats"}})});const c=Sy(e.visible,e.activeId,1);c&&a.push({id:"wt-unseen-next",label:"next that needs you",key:Pt("wt-unseen-next"),onClick:()=>n({a:"activate",id:c.activate})}),a.push({id:"project",label:e.repos.length>1?"switch project…":"open project…",key:Pt("project"),onClick:()=>n({a:"open",overlay:{kind:"projects",form:"center"}})});const u=[{id:"changes",label:`${r(e.layout.changes)} changes panel`,key:Pt("changes"),onClick:()=>n({a:"toggle-changes"})},{id:"files",label:`${r(e.layout.changes&&Jl(e)==="files")} files`,key:Pt("files"),onClick:()=>n(e.layout.changes&&Jl(e)==="files"?{a:"toggle-changes"}:{a:"focus-changes",tab:"files"})},{id:"chat",label:`${r(e.layout.chat)} chat panel`,key:Pt("composer"),onClick:()=>n({a:"toggle-chat"})},{id:"terminal",label:`${r(e.layout.term)} terminal`,key:Pt("terminal"),onClick:()=>n({a:"toggle-terminal"})},{id:"rail",label:`${r(e.railOpen)} worktree panel`,key:Pt("rail"),onClick:()=>n({a:"toggle-rail"})},{id:"design",label:`${r(e.layout.design)} design system`,key:Pt("design"),onClick:()=>n({a:"toggle-design"})},{id:"zen",label:"full-bleed preview",key:Pt("zen"),onClick:()=>n({a:"toggle-zen"})}],f=[{id:"commands",label:"command palette",key:Pt("commands"),onClick:()=>n({a:"open",overlay:{kind:"commands"}})},{id:"keys",label:"settings & shortcuts",key:Pt("keys"),onClick:()=>n({a:"open",overlay:{kind:"keys"}})}];(g=e.self)!=null&&g.restart&&f.push({id:"restart-daemon",label:"restart Toyon",onClick:()=>t==null?void 0:t.send({t:"restart-daemon"})}),f.push({id:"devices",label:e.knocks.length>0?`let a device in (${e.knocks.length})`:"your devices",onClick:()=>n({a:"open",overlay:{kind:"devices"}})});const h=No(e)?new Set(["chat","design","zen"]):null;return Wn([a,h?u.filter(y=>!h.has(y.id)):u,f])}function Ck(e,t){const n=e.get(t);if(!n||n.serving)return[];const r=e.displayName(t),o=[];e.active().origin!==t&&o.push({id:`machine:${t}`,label:`switch to ${r}`,onClick:()=>e.activate(t)});const s=[{id:`forget-machine:${t}`,label:`forget ${r}…`,danger:!0,onClick:()=>{window.confirm(`Forget ${r}?
134
-
135
- It leaves your list, here and in every browser Toyon on this machine serves, and this browser forgets what it had selected there. Toyon on that machine is not touched; pair again to list it.`)&&e.serving().sock.send({t:"forget-machine",origin:t})}}];return Wn([o,s])}function _y(e,t,{sock:n}){return[{id:`restart:${e.name}`,label:`restart ${e.name}`,detail:`${e.status} on :${e.port}`,onClick:()=>n==null?void 0:n.send({t:"term-restart",worktreeId:t,stream:e.name})}]}function iT(e,{sock:t}){return[{id:"restart:shell",label:"restart shell",onClick:()=>t==null?void 0:t.send({t:"term-restart",worktreeId:e,stream:zo})}]}function y8(e,t,n,r){return Wn([[...e.flatMap(o=>_y(o,t,r)),...iT(t,r)],[{id:"terminal",label:`${n?"hide":"show"} terminal`,onClick:()=>r.dispatch({a:"toggle-terminal"})}]])}function Au({sock:e,dispatch:t},n){t({a:"open-repo"}),e==null||e.send(n)}function aT(e,t){const{parent:n,name:r}=jy(t);Au(e,{t:"create-repo",mode:"init",parent:n,name:r})}function v8(e,{sock:t,dispatch:n}){return[{id:`cancel-import:${e.id}`,label:e.error?"dismiss":"stop the clone",danger:!e.error,onClick:()=>{t==null||t.send({t:"cancel-import",id:e.id}),n({a:"watch-import",id:null})}}]}function gp(e,t,{sock:n,dispatch:r},o){const s=o.filter(u=>Nn(u)&&u.worktree.repoId===e.id&&Oh(u.worktree)).length,a=[];e.id!==t&&a.push({id:`repo:${e.id}`,label:`switch to ${e.name}`,onClick:()=>r({a:"activate-repo",id:e.id})});const c=[{id:`setup:${e.id}`,label:"project settings…",detail:e.configFile,onClick:()=>r({a:"open",overlay:{kind:"setup",repoId:e.id}})},{id:`forget:${e.id}`,label:"forget project…",danger:!0,onClick:()=>{window.confirm(b8(e.name,s))&&(n==null||n.send({t:"forget-repo",repoId:e.id}))}}];return Wn([a,c])}function b8(e,t){const n=t===0?"":`Its ${t===1?"worktree is":`${t} worktrees are`} archived first, with the chats, commits and uncommitted changes kept. `;return`Forget ${e}?
136
-
137
- ${n}Its procs stop, it leaves the project list, and the chat on main is deleted. The checkout is not touched, and archived worktrees come back when you open it again.`}const ph={dark:"dark",light:"light",system:"follow system",daylight:"follow daylight"},mh={use:"while in use",always:"always",off:"off"};function x8(e){const t=document.createElement("input");t.type="file",t.accept=".json,.jsonc,application/json",t.onchange=()=>{var r;const n=(r=t.files)==null?void 0:r[0];n&&n.text().then(o=>e(n.name,o))},t.click()}function lT(e,{sock:t,dispatch:n}){var a;const r=e.themePrefs,o=c=>{var u;return((u=e.themes.find(f=>f.id===c))==null?void 0:u.name)??c},s=O3();return Wn([[{id:"theme",label:"theme…",detail:Vh(r,e.themes,F_(e)).name,sub:!0,onClick:()=>n({a:"open",overlay:{kind:"theme",slot:"theme"}})},{id:"appearance",topic:"theme",label:"light or dark…",detail:ph[r.mode],sub:!0,onClick:()=>n({a:"open",overlay:{kind:"appearance"}})}],[{id:"agent",label:"default agent…",detail:((a=e.agents.find(c=>c.id===e.defaultAgent))==null?void 0:a.name)??e.defaultAgent,sub:!0,onClick:()=>n({a:"open",overlay:{kind:"agent"}})}],[{id:"chat-side",label:"chat side",detail:e.chatSide,onClick:()=>n({a:"toggle-chat-side"})},...e.frame==="phone"?[{id:"black-ground",topic:"theme",label:"OLED black",detail:e.blackGround?"on":"off",onClick:()=>n({a:"toggle-black-ground"})}]:[],...s.access==="none"?[]:[{id:"clipboard-offer",label:"offer what is copied",detail:s.access==="denied"?"blocked in site settings":s.on?"on":"off",onClick:()=>M3(!s.on)}]],...e.keepAwake===null?[]:[[{id:"keep-awake",label:"keep awake…",detail:mh[e.keepAwake],sub:!0,onClick:()=>n({a:"open",overlay:{kind:"keep-awake"}})}]],[{id:"theme-import",topic:"theme",label:"import a VS Code theme…",onClick:()=>x8((c,u)=>t==null?void 0:t.send({t:"import-theme",name:c,source:u}))},{id:"theme-rescan",topic:"theme",label:"rescan editor themes",onClick:()=>t==null?void 0:t.send({t:"rescan-themes"})}],[{id:"theme-dark",topic:"theme",label:"dark slot override…",detail:o(r.dark),sub:!0,onClick:()=>n({a:"open",overlay:{kind:"theme",slot:"dark"}})},{id:"theme-light",topic:"theme",label:"light slot override…",detail:o(r.light),sub:!0,onClick:()=>n({a:"open",overlay:{kind:"theme",slot:"light"}})}]])}function E8(e,t,n,r,o,s={machines:[],switchTo:()=>{},forget:()=>{}}){const a=[],c=(g,y,w,v,_)=>a.push({id:g,label:y,hint:v,run:w,sub:_}),u=(g,y)=>{for(const w of g){if(!gs(w)||w.disabled!==void 0||w.checked)continue;const v=w.key??(typeof w.detail=="string"?w.detail:void 0),_=y?`${y.scope}:${w.id}`:w.id,x=w.topic?`${w.topic}: ${w.label}`:w.label;c(_,y?`${x} · ${y.name}`:x,w.onClick,v,w.sub)}},f={sock:n,dispatch:t},h=r,m=h==null?void 0:h.worktree.id;if(u(sT(e,f).filter(g=>!gs(g)||g.id!=="commands")),o&&u(gp(o,o.id,f,e.rows),{scope:"project",name:o.name}),m&&!No(e)){c("pick",e.picking==="chat"?"cancel element picker":"pick an element for the chat",()=>Tu(m,e.picking,t,"chat"),Pt("pick")),c("inspect",e.picking==="code"?"cancel element picker":"pick an element to open its code",()=>Tu(m,e.picking,t,"code"),Pt("inspect"));const g=ck(e);(g==null?void 0:g.act)==="start"?c("reload","start the preview",()=>n==null?void 0:n.send({t:"preview-start",worktreeId:g.id})):c("reload","reload preview",()=>un.post(m,{type:"reload"}))}if(u(lT(e,f)),h&&m){const g=e.repos.find(y=>y.id===h.worktree.repoId)??null;u(Cj(h,g,e,f,{hostname:e.hostname,palette:!0}),{scope:"wt",name:ik(h,g)});for(const y of h.procs)u(_y(y,m,f))}e.visible.forEach((g,y)=>{var _;if(g.worktree.id===m)return;const v=!!e.activeRepoId&&g.repoId!==e.activeRepoId?` in ${((_=e.repos.find(x=>x.id===g.repoId))==null?void 0:_.name)??g.repoId}`:"";c(`go:${g.worktree.id}`,`switch to ${ik(g,o)}${v}`,()=>t({a:"activate",id:g.worktree.id}),EA(y,e.visible.length))});for(const g of e.repos)g.id!==(o==null?void 0:o.id)&&c(`repo:${g.id}`,`switch to project ${g.name}`,()=>t({a:"activate-repo",id:g.id}));for(const g of s.machines){for(const y of g.repos)c(`machine:${g.origin}:${y.id}`,`switch to project ${y.name} on ${g.name}`,()=>s.switchTo(g.origin,y.id));c(`forget-machine:${g.origin}`,`forget ${g.name}`,()=>s.forget(g.origin))}return a}function cT(){const e=dt(),t=Qe(),{host:n}=Lr(),r=Dn(),o=ys(),s=hN(),a=L(F=>F.picking),c=L(F=>F.layout),u=L(F=>F.chatSide),f=L(F=>F.blackGround),h=L(F=>F.keepAwake),m=L(F=>F.railOpen),g=L(F=>F.themePrefs),y=L(F=>F.themes),w=L(F=>F.systemDark),v=L(F=>F.daylight),_=L(F=>F.rows),x=L(F=>F.visible),N=L(F=>F.activeId),T=L(F=>F.activeRepoId),j=L(F=>F.repos),A=L(F=>F.agents),R=L(F=>F.defaultAgent),C=L(F=>F.shipping),M=L(F=>F.remote),I=L(F=>F.managed),D=L(F=>F.frame),H=L(F=>F.self),Z=L(F=>F.archivedPage),B=L(F=>F.notesPage),J=L(F=>F.archived),V=L(F=>F.knocks),ee=L(F=>F.tailscale);return E.useMemo(()=>{const F={picking:a,layout:c,chatSide:u,blackGround:f,keepAwake:h,railOpen:m,themePrefs:g,themes:y,systemDark:w,daylight:v,rows:_,visible:x,activeId:N,activeRepoId:T,repos:j,agents:A,defaultAgent:R,shipping:C,frame:D,self:H,archivedPage:Z,notesPage:B,archived:J,knocks:V,hostname:n,drafted:Q=>qw(r.getState(),Q)},$={machines:s,switchTo:(Q,q)=>{var W;(W=o.get(Q))==null||W.store.dispatch({a:"activate-repo",id:q}),o.activate(Q)},forget:Q=>{const q=Ck(o,Q).find(W=>gs(W)&&W.id.startsWith("forget-machine:"));q&&gs(q)&&q.onClick()}};return E8(F,e,t,Kt(F,N),ws(F,T),$)},[a,c,u,f,h,m,g,y,w,v,_,x,N,T,j,A,R,C,M,I,D,H,Z,B,J,V,ee,e,t,n,r,o,s])}function uT(e,t){const n=t.trim().toLowerCase();if(!n)return e;const r=[];for(const o of e){const s=Ik(o.label.toLowerCase(),n);s>0&&r.push({c:o,score:s})}return r.sort((o,s)=>s.score-o.score),r.map(o=>o.c)}function Ik(e,t){const n=Ny(e,t);if(!n)return 0;let r=0,o=0,s=-1;for(const a of n)o=a===s+1?o+1:1,r+=o+(dT(e,a)?3:0),s=a;return r+Math.max(0,40-e.length/4)}const dT=(e,t)=>t===0||/[\s:\-–—·/.(]/.test(e[t-1]);function Ny(e,t){const n=e.toLowerCase(),r=[];let o=0;for(const s of t.toLowerCase()){let a=-1;if(n[o]===s)a=o;else if(s===" ")a=n.indexOf(" ",o);else for(let c=n.indexOf(s,o);c!==-1;c=n.indexOf(s,c+1))if(dT(n,c)){a=c;break}if(a===-1)return null;r.push(a),o=a+1}return r}const rs=(e,...t)=>{const n=e.trim().toLowerCase();return!n||t.some(r=>r==null?void 0:r.toLowerCase().includes(n))},Ru=e=>/^(~|\/|\.\.?\/)/.test(e.trim());function jy(e){const t=e.trim().replace(/\/+$/,""),n=t.lastIndexOf("/");return n<0?{parent:"",name:t}:{parent:t.slice(0,n)||"/",name:t.slice(n+1)}}function S8(e,t,n){const r=e.map(f=>f.path.slice(0,f.path.lastIndexOf("/"))).filter(Boolean),o=e.find(f=>f.id===t),s=o==null?void 0:o.path.slice(0,o.path.lastIndexOf("/")),a=new Map;for(const f of r)a.set(f,(a.get(f)??0)+1);let c="",u=0;for(const[f,h]of[...a].sort(([m],[g])=>m.localeCompare(g)))(h>u||h===u&&f===s)&&(c=f,u=h);return c?Ty(c,n):`~/${s_}`}function Ty(e,t){return t&&(e===t||e.startsWith(`${t}/`))?`~${e.slice(t.length)}`:e}function fT(e,t){return`${e.replace(/\/+$/,"")}/${t.trim()}`}function _8(e){const t=e.query.trim();if(e.urlOnly){const a=Yb(t);return a?[{kind:"clone",...a}]:[]}const n=()=>e.entries.map(a=>({kind:a.isFile?"file":"dir",entry:a}));if(!Ru(t)){const a=e.repos.filter(g=>rs(t,g.name,g.path)).map(g=>({kind:"repo",repo:g})),c=e.pending.filter(g=>rs(t,g.name,g.url)).map(g=>({kind:"pending",pending:g})),u=[...a,...c],f=(e.others??[]).flatMap(g=>g.repos.length===0?rs(t,g.name)?[{kind:"machine",machine:g}]:[]:g.repos.filter(y=>rs(t,y.name,y.path,g.name)).map(y=>({kind:"repo",repo:y,machine:g})));if(!t){const g=a.find(w=>w.kind==="repo"&&w.repo.id===e.current);return[...g?[g,...a.filter(w=>w!==g)]:a,...c,{kind:"disk"},{kind:"new"},{kind:"from-url"},{kind:"add-machine"},...f]}const h=Yb(t);if(h)return u.length>0?u:[{kind:"clone",...h}];const m=g=>g.toLowerCase()===t.toLowerCase();return e.repos.some(g=>m(g.name))||e.pending.some(g=>m(g.name))?[...u,...f]:Eu(t)?[...u,...f]:[...u,{kind:"create",name:t,parent:null},...f]}if(e.answered.trim()!==t||!e.target)return n();const{target:r}=e;if(r.exists){const a=t.replace(/\/+$/,"")||"/";if(r.isRepo)return[...n(),{kind:"open",path:a}];if(!r.isDir)return n();const c=tc(a,e.home);return c==="/"||c===e.home||e.repos.some(f=>f.path.startsWith(`${c}/`))?n():[...n(),{kind:"init",path:a}]}if(t.endsWith("/"))return n();if(!r.parentExists)return[];const{parent:o,name:s}=jy(t);return Eu(s)?n():[...n(),{kind:"create",name:s,parent:o}]}function tc(e,t){return t&&(e==="~"||e.startsWith("~/"))?`${t}${e.slice(1)}`:e}function hT(e,t){const n=tc(e,t).replace(/\/+$/,"");return n.startsWith("/")?Ty(n.slice(0,n.lastIndexOf("/"))||"/",t):null}function Ak(e,t){const n=tc(e,t).replace(/\/+$/,"");return n.slice(n.lastIndexOf("/")+1)||"/"}function N8(e){const t=e.query.trim(),n=t.lastIndexOf("/"),r=n<0?"":t.slice(0,n)||"/",o=tc(r,e.home);if(!Ru(t)||!o.startsWith("/"))return[];const s=t.slice(n+1).toLowerCase(),a=e.answered.trim()===t?e.target:null,c=!a||(s?a.parentExists:a.exists&&a.isDir&&!a.isRepo),u=e.entries.filter(h=>{if(h.isRepo||h.isFile)return!1;const m=tc(h.path,e.home);return(m.slice(0,m.lastIndexOf("/"))||"/")===o&&h.name.toLowerCase().startsWith(s)}),f=hT(r,e.home);return[...c?[{kind:"here",path:r}]:[],...f?[{kind:"up",path:f}]:[],...u.map(h=>({kind:"dir",entry:h}))]}const j8=e=>e.t==="open-path"||e.t==="open-loose"||e.t==="open-clone"||e.t==="open-worktree",Ea=new Map,T8=16;function Rk({sock:e,dispatch:t},n,r){const o=pT({worktreeId:n,href:r.href});t({a:"link-refused",id:n,v:null}),e==null||e.send({t:"open-by-path",path:r.path,seq:o})}function $8(e,t){e==null||e.send({t:"open-by-path",path:t,seq:pT(null)})}function pT(e){const t=_o();Ea.set(t,e);for(const n of Ea.keys()){if(Ea.size<=T8)break;Ea.delete(n)}return t}function C8(e,t){if(!Ea.has(t.seq))return;const n=Ea.get(t.seq);Ea.delete(t.seq),n?e.dispatch({a:"link-refused",id:n.worktreeId,v:{href:n.href,message:t.message}}):e.dispatch({a:"server",msg:{t:"error",message:t.message}})}function I8(e,t,n){var s;const r=e.getState();if(n.t==="open-clone"){const{t:a,parent:c,...u}=n;e.dispatch({a:"new-project",v:ep({mode:"clone",parent:Ty(c,r.home),...u})});return}if(n.t==="open-worktree"){uo(r,n.worktreeId)&&r.activeId!==n.worktreeId&&e.dispatch({a:"activate",id:n.worktreeId});return}if(n.t==="open-path"){const a={dispatch:u=>e.dispatch(u)};if(uo(r,n.worktreeId)){r.activeId!==n.worktreeId&&e.dispatch({a:"activate",id:n.worktreeId}),Pn(a,{worktreeId:n.worktreeId,path:n.path});return}const c=Object.keys(r.trunks).find(u=>{var f;return((f=r.trunks[u])==null?void 0:f.id)===n.worktreeId});if(!c)return;if(((s=uo(r,r.activeId))==null?void 0:s.repoId)!==c){const u=r.rows.find(f=>f.repoId===c);if(!u)return;e.dispatch({a:"activate",id:u.id})}Pn(a,{worktreeId:n.worktreeId,path:n.path});return}const o=r.activeId;if(!o){e.dispatch({a:"server",msg:{t:"error",message:`open a project first; ${n.name} needs a window to open in`}});return}e.dispatch({a:"open-loose",v:{worktreeId:o,name:n.name,text:n.text,binary:n.binary,tooLarge:n.tooLarge,source:{kind:"grant",id:n.id,path:n.path,version:n.version},seq:_o()}})}function $y({open:e,remove:t},n){const r=n==null?void 0:n.sock,o=n&&r?()=>r.send({t:"reveal-attachment",worktreeId:n.worktreeId,file:n.file}):void 0,s=n&&r?r.urls.attachmentWhere(n.worktreeId,n.file):void 0;return[[...e?[{id:"open",label:"open full size",onClick:e}]:[],...Ho(o,po(r),"reveal the copy")],s?[{id:"copy-path",label:"copy path",onClick:()=>RN(s)}]:[],t?[{id:"remove",label:"remove",onClick:t}]:[]]}function Ra(e,t={},n){return Wn([[{id:"copy-image",label:"copy image",onClick:()=>G3(e)}],...$y(t,n)])}function mT({text:e,href:t}){return e!==void 0?[{id:"copy-text",label:"copy text",onClick:()=>tn(e)}]:t?[{id:"copy-text",label:"copy text",onClick:()=>RN(t)}]:[]}function A8(e,t={}){return Wn([mT(e),...$y(t)])}function R8(e,t={},n){return Wn([mT(e),...$y(t,n)])}function gT(e){return[IN(e),{id:"copy-link",label:"copy link",onClick:()=>tn(e)}]}function kp(e,t,n){if(e.kind==="worktree"){const{id:o,archived:s}=e;return()=>n.dispatch(s?{a:"open-archived",id:o}:{a:"activate",id:o})}if(e.kind==="outside"&&e.folder)return O8(e.path,n);if(!t)return null;if(e.kind==="outside")return()=>Rk(n,t,e);if(e.kind==="path")return()=>Rk(n,t,{href:e.path,path:e.path});if(e.kind!=="file")return null;const r=e.file;return r.folder?()=>t6(n,{worktreeId:t,path:r.path}):()=>Pn(n,{worktreeId:t,path:r.path,...r.line?{line:{n:r.line}}:{}})}function O8(e,{sock:t}){return!t||!lp(po(t))?null:()=>t.send({t:"reveal-path",path:e})}function M8(e,t,n){const r=e.kind==="outside"&&e.folder?null:kp(e,t,n),{sock:o}=n,s=e.kind==="file"?t?()=>o==null?void 0:o.send({t:"reveal",worktreeId:t,path:e.file.path}):void 0:()=>o==null?void 0:o.send({t:"reveal-path",path:e.path}),a=e.kind==="file"?e.file.path:e.path;return[[...r?[{id:"open",label:"open",onClick:r}]:[],...Ho(s,po(o))],[{id:"copy-path",label:"copy path",onClick:()=>tn(a)}]]}function L8(e,t){const n=kp(e,null,t);return[n?[{id:"open",label:e.archived?"open archived chat":"open chat",onClick:n}]:[],[{id:"copy-branch",label:"copy branch",onClick:()=>tn(e.branch)}]]}function Ok(e){return e?[{id:"copy-code",label:"copy code",onClick:()=>tn(e)}]:[]}function vi(e,t,n,r={},o="pointer"){if(o==="touch"&&!r.link&&!r.code)return null;const{dispatch:s,sock:a}=n,c=r.link,u=c?c.kind==="out"?[gT(c.href)]:c.kind==="worktree"?L8(c,n):M8(c,t,n):[],f=[{id:"copy",label:"copy message",onClick:()=>tn(e.text)}],h=[];return e.kind==="user"&&t&&h.push({id:"draft",label:"edit in composer",onClick:()=>{const m=e.seq;if(m===void 0||!a)return s({a:"set-draft",id:t,text:e.text});s({a:"set-draft",id:t,text:""}),a.send({t:"redraft",worktreeId:t,seq:m})}}),Wn([Ok(r.code),...u,f,h])}function kT(e,t,n){return[Ho(t,n),[{id:"copy-path",label:"copy path",onClick:()=>tn(e)}]]}function Cy(e,t,n){return Wn(kT(e,t,n))}function P8(e,t){const n=e.callFile??e.file,r=n?kT(n,void 0,t.host):[],o=t.remove?[{id:"remove",label:"remove",onClick:t.remove}]:[];return Wn([...r,o])}const o1=8,D8=.7,z8=100,F8=80,B8=220;function s1({dx:e,dy:t}){return Math.abs(e)<o1&&Math.abs(t)<o1?null:Math.abs(t)>Math.abs(e)?"away":"other"}function U8(e,t){const n=e.filter(s=>t-s.t<=z8),r=n[0],o=n[n.length-1];return!r||!o||o.t===r.t?0:(o.y-r.y)/(o.t-r.t)}const H8=e=>Math.abs(e)>=D8;function W8(e,t){return Math.min(B8,Math.max(F8,e/Math.abs(t)))}const Dl={s:1,x:0,y:0},K8=2.5,i1=.5,a1=4,Cl=e=>e.s===1&&e.x===0&&e.y===0;function q8(e,t){return Math.max(a1,t>0?e/t:a1)}function qf(e,t,n,r){const o=(n.x-e.x)/e.s,s=(n.y-e.y)/e.s;return{s:t,x:r.x-o*t,y:r.y-s*t}}function ka(e,t){return{s:e.s,x:l1(e.x,(t.w*e.s-t.W)/2),y:l1(e.y,(t.h*e.s-t.H)/2)}}const l1=(e,t)=>t<=0?0:Math.min(t,Math.max(-t,e));function c1(e,t){const n=Math.min(t.max,Math.max(1,e.s));return n===1?Dl:ka({...e,s:n},t)}function u1(e,t,n){return Cl(e)?ka(qf(e,Math.min(K8,n.max),t,t),n):Dl}const Z8=400,d1=300,G8=32,f1=260,V8=.01,h1=(e,t)=>Math.hypot(t.clientX-e.clientX,t.clientY-e.clientY),p1=(e,t)=>({x:(e.clientX+t.clientX)/2,y:(e.clientY+t.clientY)/2}),jl=(e,t)=>({x:e.x-t.x,y:e.y-t.y}),bg=(e,t,n)=>Math.min(n,Math.max(t,e));function Y8(e,t,n){const r=E.useRef(n);r.current=n,E.useEffect(()=>{const o=e.current;if(!o)return;let s=null,a=!1,c=[],u=0,f=Dl,h=null,m=null,g=null,y=0,w=0;const v=()=>{const B=o.querySelector(t);if(!B)return null;const J=o.getBoundingClientRect(),V=B.offsetWidth,ee=B.offsetHeight,F=B instanceof HTMLImageElement?B.naturalWidth:V;return{centre:{x:J.left+B.offsetLeft+V/2,y:J.top+B.offsetTop+ee/2},bounds:{w:V,h:ee,W:o.clientWidth,H:o.clientHeight,max:q8(F,V)}}},_=(B,J,V)=>{V!==void 0&&o.style.setProperty("--swipe-ms",`${V}ms`),o.dataset.swipe!==J&&(o.dataset.swipe=J,o.offsetWidth),o.style.setProperty("--swipe-y",`${B}px`),o.style.setProperty("--swipe-fade",`${Math.min(1,Math.abs(B)/(window.innerHeight/2))}`)},x=()=>{o.style.removeProperty("--swipe-y"),o.style.removeProperty("--swipe-fade"),o.style.removeProperty("--swipe-ms"),delete o.dataset.swipe},N=(B,J)=>{if(f=B,window.clearTimeout(w),J?(o.dataset.zoom!==J&&(o.dataset.zoom=J,o.offsetWidth),w=window.setTimeout(()=>delete o.dataset.zoom,f1)):delete o.dataset.zoom,Cl(B)){o.style.removeProperty("--zoom-s"),o.style.removeProperty("--zoom-x"),o.style.removeProperty("--zoom-y");return}o.style.setProperty("--zoom-s",`${B.s}`),o.style.setProperty("--zoom-x",`${B.x}px`),o.style.setProperty("--zoom-y",`${B.y}px`)},T=()=>{const B=a;s=null,a=!1,c=[],h=null,m=null,B&&(_(0,"settle"),u=window.setTimeout(x,f1))},j=B=>{var $;const J=B.target,V=J===o||!!(J!=null&&J.closest(t));if(((($=window.visualViewport)==null?void 0:$.scale)??1)>1.01)return T();if(o.dataset.swipe==="leave")return;const ee=B.touches[0],F=B.touches[1];if(ee&&F&&B.touches.length===2&&V){T(),window.clearTimeout(y),g=null,h={d:h1(ee,F),m:p1(ee,F),z:f};return}if(B.touches.length!==1||!ee||!V)return T();window.clearTimeout(u),s={x:ee.clientX,y:ee.clientY,at:B.timeStamp},c=[{y:ee.clientY,t:B.timeStamp}],m=Cl(f)?null:f},A=B=>{const J=B.touches[0],V=B.touches[1];if(h&&J&&V){B.preventDefault();const $=v();if(!$)return;const Q=bg(h.z.s*h1(J,V)/h.d,i1,$.bounds.max);N(ka(qf(h.z,Q,jl(h.m,$.centre),jl(p1(J,V),$.centre)),$.bounds));return}if(!s||!J)return;const ee=J.clientX-s.x,F=J.clientY-s.y;if(m){B.preventDefault();const $=v();$&&N(ka({s:m.s,x:m.x+ee,y:m.y+F},$.bounds));return}if(!a){const $=s1({dx:ee,dy:F});if($==="other"&&(s=null),$!=="away")return;a=!0}B.preventDefault(),c.push({y:J.clientY,t:B.timeStamp}),c.length>16&&c.shift(),_(F,"drag")},R=B=>{if(h){if(B.touches.length>=2)return;const oe=v();N(oe?c1(f,oe.bounds):Dl,"settle"),h=null;const de=B.touches[0];de&&!Cl(f)&&(s={x:de.clientX,y:de.clientY,at:B.timeStamp},m=f);return}const J=B.changedTouches[0];if(!s||!J)return;const V={x:J.clientX,y:J.clientY},ee=V.y-s.y,F=B.timeStamp-s.at;if(!a&&F<Z8&&B.target!==o&&s1({dx:V.x-s.x,dy:ee})===null){if(B.preventDefault(),s=null,m=null,g&&B.timeStamp-g.t<d1&&Math.hypot(V.x-g.p.x,V.y-g.p.y)<G8){window.clearTimeout(y),g=null;const oe=v();N(oe?u1(f,jl(V,oe.centre),oe.bounds):Dl,"settle");return}g={p:V,t:B.timeStamp},Cl(f)&&(y=window.setTimeout(()=>r.current(),d1));return}if(m){m=null,s=null,c=[];return}const Q=U8(c,B.timeStamp);if(!a||!H8(Q))return T();s=null,a=!1,c=[];const q=Math.sign(Q)*window.innerHeight,W=W8(Math.abs(q-ee),Q);_(q,"leave",W),u=window.setTimeout(()=>r.current(),W)},C=B=>{var V;if(!((V=B.target)!=null&&V.closest(t)))return;const J=v();J&&N(u1(f,jl({x:B.clientX,y:B.clientY},J.centre),J.bounds),"settle")},M=B=>{const J=v();if(J)if(B.ctrlKey){B.preventDefault();const V=jl({x:B.clientX,y:B.clientY},J.centre),ee=bg(f.s*Math.exp(-B.deltaY*V8),1,J.bounds.max);N(ka(qf(f,ee,V,V),J.bounds))}else Cl(f)||(B.preventDefault(),N(ka({s:f.s,x:f.x-B.deltaX,y:f.y-B.deltaY},J.bounds)))};let I=null;const D=B=>{if(h)return;B.preventDefault();const J=v(),V=B;J&&(I={z:f,p:jl({x:V.clientX,y:V.clientY},J.centre)})},H=B=>{if(h)return;B.preventDefault();const J=v();if(!I||!J)return;const V=bg(I.z.s*B.scale,i1,J.bounds.max);N(ka(qf(I.z,V,I.p,I.p),J.bounds))},Z=B=>{if(h)return;B.preventDefault(),I=null;const J=v();N(J?c1(f,J.bounds):Dl,"settle")};return o.addEventListener("touchstart",j,{passive:!0}),o.addEventListener("touchmove",A,{passive:!1}),o.addEventListener("touchend",R),o.addEventListener("touchcancel",T),o.addEventListener("dblclick",C),o.addEventListener("wheel",M,{passive:!1}),o.addEventListener("gesturestart",D),o.addEventListener("gesturechange",H),o.addEventListener("gestureend",Z),()=>{window.clearTimeout(u),window.clearTimeout(y),window.clearTimeout(w),o.removeEventListener("touchstart",j),o.removeEventListener("touchmove",A),o.removeEventListener("touchend",R),o.removeEventListener("touchcancel",T),o.removeEventListener("dblclick",C),o.removeEventListener("wheel",M),o.removeEventListener("gesturestart",D),o.removeEventListener("gesturechange",H),o.removeEventListener("gestureend",Z)}},[e,t])}function Qu({owner:e,onClose:t,menu:n,nav:r,children:o}){const s=vn(e),a=E.useRef(null);return Y8(a,"img",t),d.jsxs(Ws,{className:"attach-full scrim",boxRef:a,onDismiss:t,onKey:c=>{if(c.key==="Escape"){c.stopPropagation(),t();return}const u=r&&h8(c);u&&(c.preventDefault(),c.stopPropagation(),r.step(u))},onClick:c=>{c.target===c.currentTarget&&t()},...n&&s.contextMenu(n),children:[o,d.jsxs("div",{className:"attach-head",children:[r&&r.of>1&&d.jsxs("span",{className:"attach-count",children:[r.at+1," of ",r.of]}),d.jsx(At,{icon:"close",label:"Close",tone:"quiet",onClick:t})]})]})}function X8({item:e}){if(!e.outcome)return null;const t=A4[e.outcome];if(e.ask.kind==="permission"){const{title:n,choices:r}=e.ask,o=r.find(s=>s.id===e.choiceId);return d.jsxs("div",{className:"ask-closed",children:[!e.toolId&&d.jsx("div",{className:"ask-lead",children:n}),d.jsx("div",{className:"ask-answered",children:o?o.name:t??"closed"})]})}return d.jsxs("div",{className:"ask-closed",children:[d.jsx("div",{className:"ask-lead",children:e.ask.message}),d.jsx("div",{className:"ask-answered",children:t??"closed"})]})}function wT(e,t){if(!t||t.startsWith("#")||t.startsWith("/")||/^[a-z][a-z\d+.-]*:/i.test(t))return null;const n=t.split(/[?#]/)[0]??"";if(!n)return null;const r=e?e.split("/"):[];for(const o of n.split("/"))if(!(o===""||o==="."))if(o===".."){if(!r.length)return null;r.pop()}else r.push(decodeURIComponent(o));return r.length?r.join("/"):null}const Q8=e=>e.slice(0,Math.max(0,e.lastIndexOf("/")));function yT(e,t){let n;try{n=decodeURIComponent(t)}catch{return null}const r=n.match(/#L(\d+)(?:-L?\d+)?$/i);r?n=n.slice(0,r.index):n=n.split(/[?#]/)[0]??"";const o=n.match(/:(\d+)(?::\d+)?$/);o&&(n=n.slice(0,o.index));const s=e.replace(/\/+$/,"");if(!s||!n.startsWith(`${s}/`))return null;const a=n.endsWith("/"),c=n.slice(s.length+1).replace(/\/+$/,"");if(!c||c.split("/").some(h=>h===".."))return null;if(a)return{path:c,folder:!0};const u=(r==null?void 0:r[1])??(o==null?void 0:o[1]),f=u?Number.parseInt(u,10):void 0;return f&&f>0?{path:c,line:f}:{path:c}}function vT(e){var t;return((t=e.match(/^file:\/\/(?:localhost)?(\/.*)$/i))==null?void 0:t[1])??e}function bT(e){if(!e.startsWith("/")||e.startsWith("//"))return null;let t;try{t=decodeURIComponent(e)}catch{return null}if(t.length>1&&t.endsWith("/"))return{path:t.replace(/\/+$/,""),folder:!0};const n=t.match(/:(\d+)(?::\d+)?$/);if(!n)return{path:t};const r=Number.parseInt(n[1]??"",10),o=t.slice(0,n.index);return r>0?{path:o,line:r}:{path:o}}function J8(e){return e.length<2||!e.startsWith("/")||e.startsWith("//")||/\s/.test(e)?null:e}function wp(e,t){const n=e.closest("[data-worktree]"),r=n==null?void 0:n.getAttribute("data-worktree");if(n&&r)return{kind:"worktree",id:r,branch:n.getAttribute("data-branch")??"",archived:n.hasAttribute("data-archived")};const o=e.closest("a, code[data-path]");if(!o)return null;const s=o.getAttribute("data-path");if(s)return{kind:"path",path:s};const a=o.getAttribute("href");if(!a)return null;const c=t?yT(t,a):null;if(c)return{kind:"file",file:c};const u=bT(a);return u?{kind:"outside",href:a,...u}:{kind:"out",href:a}}function Iy(e,t,n,r){var s;const o=wp(e.target,t);!o||o.kind==="path"||o.kind==="out"||(e.preventDefault(),(s=kp(o,n,r))==null||s())}const e9=150,t9=e=>({side:e,align:"center",offset:12,flip:"side",margin:8});function xT({chip:e,className:t,children:n}){const[r,o]=E.useState(!1),s=qu("chat");E.useEffect(()=>{const c=e.current;if(!c)return;let u=0;const f=()=>{window.clearTimeout(u),o(!1)},h=()=>{window.clearTimeout(u),u=window.setTimeout(()=>o(!0),e9)};return c.addEventListener("mouseenter",h),c.addEventListener("mouseleave",f),c.addEventListener("mousedown",f),()=>{window.clearTimeout(u),c.removeEventListener("mouseenter",h),c.removeEventListener("mouseleave",f),c.removeEventListener("mousedown",f)}},[e]);const a=()=>{var h;const c=e.current;if(!c)return null;const u=c.getBoundingClientRect(),f=((h=c.closest(".chat-log"))==null?void 0:h.getBoundingClientRect())??u;return{left:f.left,right:f.right,top:u.top,bottom:u.bottom}};return r?d.jsx(Ws,{className:Ke("chip-peek",t),anchor:a,placement:t9(s),track:!0,children:n}):null}function Ay({className:e,label:t,tip:n,peek:r,full:o,menu:s,removeLabel:a,onRemove:c}){const u=E.useRef(null),f=vn("chat"),h=o!==void 0,m=g8(u,h);return d.jsxs("div",{ref:u,className:Ke("pick-chip row row-sm",e),"data-tip":h?"Open full size":n,"data-tip-placement":"follow",...f.contextMenu(()=>s({open:h?m.show:void 0,remove:c})),children:[h?d.jsx("button",{type:"button",className:"chip-link",onClick:m.show,children:t}):t,c&&d.jsx(At,{icon:"close",label:a,tone:"quiet",onClick:c}),h&&r!==void 0&&d.jsx(xT,{chip:u,children:r}),m.open&&h&&d.jsx(Qu,{owner:"chat",onClose:m.close,menu:()=>s(),nav:m.nav,children:o})]})}/*! @license DOMPurify 3.4.14 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.4.14/LICENSE */function m1(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function n9(e){if(Array.isArray(e))return e}function r9(e,t){var n=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var r,o,s,a,c=[],u=!0,f=!1;try{if(s=(n=n.call(e)).next,t!==0)for(;!(u=(r=s.call(n)).done)&&(c.push(r.value),c.length!==t);u=!0);}catch(h){f=!0,o=h}finally{try{if(!u&&n.return!=null&&(a=n.return(),Object(a)!==a))return}finally{if(f)throw o}}return c}}function o9(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
138
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function s9(e,t){return n9(e)||r9(e,t)||i9(e,t)||o9()}function i9(e,t){if(e){if(typeof e=="string")return m1(e,t);var n={}.toString.call(e).slice(8,-1);return n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set"?Array.from(e):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?m1(e,t):void 0}}const ET=Object.entries,g1=Object.setPrototypeOf,a9=Object.isFrozen,l9=Object.getPrototypeOf,c9=Object.getOwnPropertyDescriptor;let Er=Object.freeze,Ir=Object.seal,Il=Object.create,ST=typeof Reflect<"u"&&Reflect,Mk=ST.apply,Lk=ST.construct;Er||(Er=function(t){return t});Ir||(Ir=function(t){return t});Mk||(Mk=function(t,n){for(var r=arguments.length,o=new Array(r>2?r-2:0),s=2;s<r;s++)o[s-2]=arguments[s];return t.apply(n,o)});Lk||(Lk=function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];return new t(...r)});const pa=kr(Array.prototype.forEach),u9=kr(Array.prototype.lastIndexOf),k1=kr(Array.prototype.pop),Qc=kr(Array.prototype.push),d9=kr(Array.prototype.splice),ql=Array.isArray,iu=kr(String.prototype.toLowerCase),xg=kr(String.prototype.toString),w1=kr(String.prototype.match),Jc=kr(String.prototype.replace),y1=kr(String.prototype.indexOf),f9=kr(String.prototype.trim),h9=kr(Number.prototype.toString),p9=kr(Boolean.prototype.toString),v1=typeof BigInt>"u"?null:kr(BigInt.prototype.toString),b1=typeof Symbol>"u"?null:kr(Symbol.prototype.toString),lo=kr(Object.prototype.hasOwnProperty),eu=kr(Object.prototype.toString),Hr=kr(RegExp.prototype.test),fa=m9(TypeError);function kr(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];return Mk(e,t,r)}}function m9(e){return function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return Lk(e,n)}}function gn(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:iu;if(g1&&g1(e,null),!ql(t))return e;let r=t.length;for(;r--;){let o=t[r];if(typeof o=="string"){const s=n(o);s!==o&&(a9(t)||(t[r]=s),o=s)}e[o]=!0}return e}function g9(e){for(let t=0;t<e.length;t++)lo(e,t)||(e[t]=null);return e}function Eo(e){const t=Il(null);for(const r of ET(e)){var n=s9(r,2);const o=n[0],s=n[1];lo(e,o)&&(ql(s)?t[o]=g9(s):s&&typeof s=="object"&&s.constructor===Object?t[o]=Eo(s):t[o]=s)}return t}function k9(e){switch(typeof e){case"string":return e;case"number":return h9(e);case"boolean":return p9(e);case"bigint":return v1?v1(e):"0";case"symbol":return b1?b1(e):"Symbol()";case"undefined":return eu(e);case"function":case"object":{if(e===null)return eu(e);const t=e,n=Jo(t,"toString");if(typeof n=="function"){const r=n(t);return typeof r=="string"?r:eu(r)}return eu(e)}default:return eu(e)}}function Jo(e,t){for(;e!==null;){const r=c9(e,t);if(r){if(r.get)return kr(r.get);if(typeof r.value=="function")return kr(r.value)}e=l9(e)}function n(){return null}return n}function w9(e){try{return Hr(e,""),!0}catch{return!1}}const x1=Er(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),Eg=Er(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),Sg=Er(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),y9=Er(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),_g=Er(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),v9=Er(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),E1=Er(["#text"]),S1=Er(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","command","commandfor","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns"]),Ng=Er(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dominant-baseline","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","pointer-events","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-orientation","text-rendering","textlength","type","u1","u2","unicode","values","vector-effect","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),_1=Er(["accent","accentunder","align","bevelled","close","columnalign","columnlines","columnspacing","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lquote","lspace","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),$f=Er(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),b9=Ir(/{{[\w\W]*|^[\w\W]*}}/g),x9=Ir(/<%[\w\W]*|^[\w\W]*%>/g),E9=Ir(/\${[\w\W]*/g),S9=Ir(/^data-[\-\w.\u00B7-\uFFFF]+$/),_9=Ir(/^aria-[\-\w]+$/),N1=Ir(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),N9=Ir(/^(?:\w+script|data):/i),j9=Ir(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),T9=Ir(/^html$/i),$9=Ir(/^[a-z][.\w]*(-[.\w]+)+$/i),j1=Ir(/<[/\w!]/g),T1=Ir(/<[/\w]/g),C9=Ir(/<\/no(script|embed|frames)/i),I9=Ir(/\/>/i),xo={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},_T=["style","script","xmp","iframe","noembed","noframes","plaintext","noscript"],A9=Er(gn({},_T)),R9=(function(){const e={};return pa(_T,t=>{e[t]=Ir(new RegExp("</"+t+"(?=[\\t\\n\\f\\r />])","i"))}),Er(e)})(),O9=function(){return typeof window>"u"?null:window},M9=function(t,n){if(typeof t!="object"||typeof t.createPolicy!="function")return null;let r=null;const o="data-tt-policy-suffix";n&&n.hasAttribute(o)&&(r=n.getAttribute(o));const s="dompurify"+(r?"#"+r:"");try{return t.createPolicy(s,{createHTML(a){return a},createScriptURL(a){return a}})}catch{return console.warn("TrustedTypes policy "+s+" could not be created."),null}},$1=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},bi=function(t,n,r,o){return lo(t,n)&&ql(t[n])?gn(o.base?Eo(o.base):{},t[n],o.transform):r},jg=function(t,n,r){const o=lo(t,n)?t[n]:void 0;return o&&typeof o=="object"?Eo(o):r()};function NT(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:O9();const t=Ie=>NT(Ie);if(t.version="3.4.14",t.removed=[],!e||!e.document||e.document.nodeType!==xo.document||!e.Element)return t.isSupported=!1,t;let n=e.document;const r=n,o=r.currentScript;e.DocumentFragment;const s=e.HTMLTemplateElement,a=e.Node,c=e.Element,u=e.NodeFilter,f=e.NamedNodeMap;f===void 0&&(e.NamedNodeMap||e.MozNamedAttrMap),e.HTMLFormElement;const h=e.DOMParser,m=e.trustedTypes,g=c.prototype,y=Jo(g,"cloneNode"),w=Jo(g,"remove"),v=Jo(g,"nextSibling"),_=Jo(g,"childNodes"),x=Jo(g,"parentNode"),N=Jo(g,"shadowRoot"),T=Jo(g,"attributes"),j=a&&a.prototype?Jo(a.prototype,"nodeType"):null,A=a&&a.prototype?Jo(a.prototype,"nodeName"):null,R=a&&a.prototype?Jo(a.prototype,"ownerDocument"):null,C=function(U){return j?j(U):U.nodeType},M=function(U){return A?A(U):U.nodeName};if(typeof s=="function"){const Ie=n.createElement("template");Ie.content&&Ie.content.ownerDocument&&(n=Ie.content.ownerDocument)}let I,D="",H,Z=!1,B=0;const J=function(){if(B>0)throw fa('A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.')},V=function(U){J(),B++;try{return I.createHTML(U)}finally{B--}},ee=function(U){J(),B++;try{return I.createScriptURL(U)}finally{B--}},F=function(){return Z||(H=M9(m,o),Z=!0),H},$=n,Q=$.implementation,q=$.createNodeIterator,W=$.createDocumentFragment,oe=$.getElementsByTagName,de=r.importNode;let he=$1();t.isSupported=typeof ET=="function"&&typeof x=="function"&&Q&&Q.createHTMLDocument!==void 0;const Ne=b9,Me=x9,Be=E9,K=S9,te=_9,pe=N9,ue=j9,ie=$9;let ye=N1,Se=null;const Ee=gn({},[...x1,...Eg,...Sg,..._g,...E1]);let Le=null;const Ue=gn({},[...S1,...Ng,..._1,...$f]);let Je=Object.seal(Il(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),Ht=null,qt=null;const xt=Object.seal(Il(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let Ze=!0,_t=!0,mt=!1,De=!0,nt=!1,lt=!0,Yt=!1,$n=!1,gt=null,rt=null,Kn=!1,Qt=!1,Cn=!1,qn=!1,dn=!0,yn=!1;const ne="user-content-";let we=!0,qe=!1,ot={},Tt=null;const Dt=gn({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","selectedcontent","style","svg","template","thead","title","video","xmp"]);let P=null;const se=gn({},["audio","video","img","source","image","track"]);let je=null;const Fe=gn({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Rt="http://www.w3.org/1998/Math/MathML",Zt="http://www.w3.org/2000/svg",Ae="http://www.w3.org/1999/xhtml";let We=Ae,Ve=!1,Xt=null;const Wt=gn({},[Rt,Zt,Ae],xg),bn=Er(["mi","mo","mn","ms","mtext"]);let xn=gn({},bn);const Ct=Er(["annotation-xml"]);let Jt=gn({},Ct);const sr=gn({},["title","style","font","a","script"]);let Gt=null;const Rn=["application/xhtml+xml","text/html"],fn="text/html";let ae=null,_e=null;const ht=n.createElement("form"),ct=function(U){return U instanceof RegExp||U instanceof Function},zt=function(){let U=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(_e&&_e===U)return;(!U||typeof U!="object")&&(U={}),U=Eo(U),Gt=Rn.indexOf(U.PARSER_MEDIA_TYPE)===-1?fn:U.PARSER_MEDIA_TYPE,ae=Gt==="application/xhtml+xml"?xg:iu,Se=bi(U,"ALLOWED_TAGS",Ee,{transform:ae}),Le=bi(U,"ALLOWED_ATTR",Ue,{transform:ae}),Xt=bi(U,"ALLOWED_NAMESPACES",Wt,{transform:xg}),je=bi(U,"ADD_URI_SAFE_ATTR",Fe,{transform:ae,base:Fe}),P=bi(U,"ADD_DATA_URI_TAGS",se,{transform:ae,base:se}),Tt=bi(U,"FORBID_CONTENTS",Dt,{transform:ae}),Ht=bi(U,"FORBID_TAGS",Eo({}),{transform:ae}),qt=bi(U,"FORBID_ATTR",Eo({}),{transform:ae}),ot=lo(U,"USE_PROFILES")?U.USE_PROFILES&&typeof U.USE_PROFILES=="object"?Eo(U.USE_PROFILES):U.USE_PROFILES:!1,Ze=U.ALLOW_ARIA_ATTR!==!1,_t=U.ALLOW_DATA_ATTR!==!1,mt=U.ALLOW_UNKNOWN_PROTOCOLS||!1,De=U.ALLOW_SELF_CLOSE_IN_ATTR!==!1,nt=U.SAFE_FOR_TEMPLATES||!1,lt=U.SAFE_FOR_XML!==!1,Yt=U.WHOLE_DOCUMENT||!1,Qt=U.RETURN_DOM||!1,Cn=U.RETURN_DOM_FRAGMENT||!1,qn=U.RETURN_TRUSTED_TYPE||!1,Kn=U.FORCE_BODY||!1,dn=U.SANITIZE_DOM!==!1,yn=U.SANITIZE_NAMED_PROPS||!1,we=U.KEEP_CONTENT!==!1,qe=U.IN_PLACE||!1,ye=w9(U.ALLOWED_URI_REGEXP)?U.ALLOWED_URI_REGEXP:N1,We=typeof U.NAMESPACE=="string"?U.NAMESPACE:Ae,xn=jg(U,"MATHML_TEXT_INTEGRATION_POINTS",()=>gn({},bn)),Jt=jg(U,"HTML_INTEGRATION_POINTS",()=>gn({},Ct));const G=jg(U,"CUSTOM_ELEMENT_HANDLING",()=>Il(null));if(Je=Il(null),lo(G,"tagNameCheck")&&ct(G.tagNameCheck)&&(Je.tagNameCheck=G.tagNameCheck),lo(G,"attributeNameCheck")&&ct(G.attributeNameCheck)&&(Je.attributeNameCheck=G.attributeNameCheck),lo(G,"allowCustomizedBuiltInElements")&&typeof G.allowCustomizedBuiltInElements=="boolean"&&(Je.allowCustomizedBuiltInElements=G.allowCustomizedBuiltInElements),Ir(Je),nt&&(_t=!1),Cn&&(Qt=!0),ot&&(Se=gn({},E1),Le=Il(null),ot.html===!0&&(gn(Se,x1),gn(Le,S1)),ot.svg===!0&&(gn(Se,Eg),gn(Le,Ng),gn(Le,$f)),ot.svgFilters===!0&&(gn(Se,Sg),gn(Le,Ng),gn(Le,$f)),ot.mathMl===!0&&(gn(Se,_g),gn(Le,_1),gn(Le,$f))),xt.tagCheck=null,xt.attributeCheck=null,lo(U,"ADD_TAGS")&&(typeof U.ADD_TAGS=="function"?xt.tagCheck=U.ADD_TAGS:ql(U.ADD_TAGS)&&(Se===Ee&&(Se=Eo(Se)),gn(Se,U.ADD_TAGS,ae))),lo(U,"ADD_ATTR")&&(typeof U.ADD_ATTR=="function"?xt.attributeCheck=U.ADD_ATTR:ql(U.ADD_ATTR)&&(Le===Ue&&(Le=Eo(Le)),gn(Le,U.ADD_ATTR,ae))),lo(U,"ADD_FORBID_CONTENTS")&&ql(U.ADD_FORBID_CONTENTS)&&(Tt===Dt&&(Tt=Eo(Tt)),gn(Tt,U.ADD_FORBID_CONTENTS,ae)),we&&(Se["#text"]=!0),Yt&&gn(Se,["html","head","body"]),Se.table&&(gn(Se,["tbody"]),delete Ht.tbody),U.TRUSTED_TYPES_POLICY){if(typeof U.TRUSTED_TYPES_POLICY.createHTML!="function")throw fa('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof U.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw fa('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');const ce=I;I=U.TRUSTED_TYPES_POLICY;try{D=V("")}catch(ve){throw I=ce,ve}}else U.TRUSTED_TYPES_POLICY===null?(I=void 0,D=""):(I===void 0&&(I=F()),I&&typeof D=="string"&&(D=V("")));Er&&Er(U),_e=U},kn=gn({},[...Eg,...Sg,...y9]),Pr=gn({},[..._g,...v9]),cr=function(U,G,ce){return G.namespaceURI===Ae?U==="svg":G.namespaceURI===Rt?U==="svg"&&(ce==="annotation-xml"||xn[ce]):!!kn[U]},ln=function(U,G,ce){return G.namespaceURI===Ae?U==="math":G.namespaceURI===Zt?U==="math"&&Jt[ce]:!!Pr[U]},ur=function(U,G,ce){return G.namespaceURI===Zt&&!Jt[ce]||G.namespaceURI===Rt&&!xn[ce]?!1:!Pr[U]&&(sr[U]||!kn[U])},nn=function(U){let G=x(U);(!G||!G.tagName)&&(G={namespaceURI:We,tagName:"template"});const ce=iu(U.tagName),ve=iu(G.tagName);return Xt[U.namespaceURI]?U.namespaceURI===Zt?cr(ce,G,ve):U.namespaceURI===Rt?ln(ce,G,ve):U.namespaceURI===Ae?ur(ce,G,ve):!!(Gt==="application/xhtml+xml"&&Xt[U.namespaceURI]):!1},Bt=function(U){Qc(t.removed,{element:U});try{x(U).removeChild(U)}catch{if(w(U),!x(U))throw fa("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},Ft=function(U,G,ce){try{U.removeAttributeNode(G)}catch{try{U.removeAttribute(ce)}catch{}}},be=function(U){yt(U);const G=_(U);if(G){const ve=[];pa(G,Pe=>{Qc(ve,Pe)}),pa(ve,Pe=>{try{w(Pe)}catch{}})}const ce=T(U);if(ce)for(let ve=ce.length-1;ve>=0;--ve){const Pe=ce[ve],Te=Pe&&Pe.name;typeof Te=="string"&&Ft(U,Pe,Te)}},Ye=function(U,G,ce){if(!ce)try{ce=G.getAttributeNode(U)}catch{ce=null}Qc(t.removed,{attribute:ce||null,from:G});try{ce?G.removeAttributeNode(ce):G.removeAttribute(U)}catch{try{G.removeAttribute(U)}catch{}}if(U==="is")if(Qt||Cn)try{Bt(G)}catch{}else try{G.setAttribute(U,"")}catch{}},wt=function(U){const G=T(U);if(G)for(let ce=G.length-1;ce>=0;--ce){const ve=G[ce],Pe=ve&&ve.name;typeof Pe!="string"||Le[ae(Pe)]||Ft(U,ve,Pe)}},yt=function(U){const G=[U];for(;G.length>0;){const ce=G.pop();C(ce)===xo.element&&wt(ce);const Pe=_(ce);if(Pe)for(let Te=Pe.length-1;Te>=0;--Te)G.push(Pe[Te])}},cn=function(U,G){return lt?U==="patchsrc"?!0:U==="for"&&G!=="label"&&G!=="output":!1},hn=function(U){if(!lt)return;const G=[U];for(;G.length>0;){const ce=G.pop(),ve=C(ce);if(ve===xo.processingInstruction||ve===xo.comment&&Hr(T1,ce.data)){try{w(ce)}catch{}continue}if(ve===xo.element){const Te=ce,$t=ae(M(ce));try{Te.hasAttribute&&Te.hasAttribute("patchsrc")&&Te.removeAttribute("patchsrc"),Te.hasAttribute&&Te.hasAttribute("for")&&cn("for",$t)&&Te.removeAttribute("for")}catch{}}const Pe=_(ce);if(Pe)for(let Te=Pe.length-1;Te>=0;--Te)G.push(Pe[Te])}},wr=function(U){let G=null,ce=null;if(Kn)U="<remove></remove>"+U;else{const Te=w1(U,/^[\r\n\t ]+/);ce=Te&&Te[0]}Gt==="application/xhtml+xml"&&We===Ae&&(U='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+U+"</body></html>");const ve=I?V(U):U;if(We===Ae)try{G=new h().parseFromString(ve,Gt)}catch{}if(!G||!G.documentElement){G=Q.createDocument(We,"template",null);try{G.documentElement.innerHTML=Ve?D:ve}catch{}}const Pe=G.body||G.documentElement;return U&&ce&&Pe.insertBefore(n.createTextNode(ce),Pe.childNodes[0]||null),We===Ae?oe.call(G,Yt?"html":"body")[0]:Yt?G.documentElement:Pe},Zn=function(U){const G=R?R(U):U.ownerDocument;return q.call(G||U,U,u.SHOW_ELEMENT|u.SHOW_COMMENT|u.SHOW_TEXT|u.SHOW_PROCESSING_INSTRUCTION|u.SHOW_CDATA_SECTION,null)},Ut=function(U){return U=Jc(U,Ne," "),U=Jc(U,Me," "),U=Jc(U,Be," "),U},pn=function(U){var G;U.normalize();const ce=R?R(U):U.ownerDocument,ve=q.call(ce||U,U,u.SHOW_TEXT|u.SHOW_COMMENT|u.SHOW_CDATA_SECTION|u.SHOW_PROCESSING_INSTRUCTION,null);let Pe=ve.nextNode();for(;Pe;)Pe.data=Ut(Pe.data),Pe=ve.nextNode();const Te=(G=U.querySelectorAll)===null||G===void 0?void 0:G.call(U,"template");Te&&pa(Te,$t=>{X($t.content)&&pn($t.content)})},yr=function(U){const G=A?A(U):null;return typeof G!="string"||ae(G)!=="form"?!1:typeof U.nodeName!="string"||typeof U.textContent!="string"||typeof U.removeChild!="function"||U.attributes!==T(U)||typeof U.removeAttribute!="function"||typeof U.setAttribute!="function"||typeof U.namespaceURI!="string"||typeof U.insertBefore!="function"||typeof U.hasChildNodes!="function"||U.nodeType!==j(U)||U.childNodes!==_(U)},X=function(U){if(!j||typeof U!="object"||U===null)return!1;try{return j(U)===xo.documentFragment}catch{return!1}},ge=function(U){if(!j||typeof U!="object"||U===null)return!1;try{return typeof j(U)=="number"}catch{return!1}};function Ge(Ie,U,G){Ie.length!==0&&pa(Ie,ce=>{ce.call(t,U,G,_e)})}const Vt=function(U,G){return!!(lt&&U.hasChildNodes()&&!ge(U.firstElementChild)&&Hr(j1,U.textContent)&&Hr(j1,U.innerHTML)||lt&&U.namespaceURI===Ae&&A9[G]&&(ge(U.firstElementChild)||typeof U.textContent=="string"&&Hr(R9[G],U.textContent))||U.nodeType===xo.processingInstruction||lt&&U.nodeType===xo.comment&&Hr(T1,U.data))},Mt=function(U,G){if(U instanceof RegExp)return Hr(U,G);if(U instanceof Function){for(var ce=arguments.length,ve=new Array(ce>2?ce-2:0),Pe=2;Pe<ce;Pe++)ve[Pe-2]=arguments[Pe];return!!U(G,...ve)}return!1},On=function(U,G,ce){if(!Ht[G]&&vt(G)&&Mt(Je.tagNameCheck,G))return!1;if(we&&!Tt[G]){const ve=x(U),Pe=_(U);if(Pe&&ve){const Te=Pe.length;for(let $t=Te-1;$t>=0;--$t){const sn=U===ce?y(Pe[$t],!0):Pe[$t];ve.insertBefore(sn,v(U))}}}return Bt(U),!0},Sn=function(U,G,ce,ve){return U.length===0?G:G===ce||G===ve?Eo(G):G},zn=function(U,G){return U===G||x(U)!==null?!1:(qe&&yt(U),!0)},ir=function(U,G){if(Ge(he.beforeSanitizeElements,U,null),zn(U,G))return!0;if(yr(U))return Bt(U),!0;const ce=ae(M(U));if(Se=Sn(he.uponSanitizeElement,Se,Ee,gt),Ge(he.uponSanitizeElement,U,{tagName:ce,allowedTags:Se}),zn(U,G))return!0;if(Vt(U,ce))return Bt(U),!0;if(Ht[ce]||!(xt.tagCheck instanceof Function&&xt.tagCheck(ce))&&!Se[ce]){const Pe=On(U,ce,G);return Pe===!1&&Ge(he.afterSanitizeElements,U,null),Pe}if(C(U)===xo.element&&!nn(U)||(ce==="noscript"||ce==="noembed"||ce==="noframes")&&Hr(C9,U.innerHTML))return Bt(U),!0;if(nt&&U.nodeType===xo.text){const Pe=Ut(U.textContent);U.textContent!==Pe&&(Qc(t.removed,{element:U.cloneNode()}),U.textContent=Pe)}return Ge(he.afterSanitizeElements,U,null),!1},go=function(U,G,ce){if(qt[G]||cn(G,U)||dn&&(G==="id"||G==="name")&&(ce in n||ce in ht))return!1;const ve=Le[G]||xt.attributeCheck instanceof Function&&xt.attributeCheck(G,U);return _t&&Hr(K,G)||Ze&&Hr(te,G)?!0:ve?je[G]||Hr(ye,Jc(ce,ue,""))||(G==="src"||G==="xlink:href"||G==="href")&&U!=="script"&&y1(ce,"data:")===0&&P[U]||mt&&!Hr(pe,Jc(ce,ue,""))?!0:!ce:vt(U)&&Mt(Je.tagNameCheck,U)&&Mt(Je.attributeNameCheck,G,U)||G==="is"&&Je.allowCustomizedBuiltInElements&&Mt(Je.tagNameCheck,ce)},rn=gn({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),vt=function(U){return!rn[iu(U)]&&Hr(ie,U)},ko=function(U,G,ce,ve){if(I&&typeof m=="object"&&typeof m.getAttributeType=="function"&&!ce)switch(m.getAttributeType(U,G)){case"TrustedHTML":return V(ve);case"TrustedScriptURL":return ee(ve)}return ve},Fn=function(U,G,ce,ve){try{ce?U.setAttributeNS(ce,G,ve):U.setAttribute(G,ve),yr(U)?Bt(U):k1(t.removed)}catch{Ye(G,U)}},on=function(U){Ge(he.beforeSanitizeAttributes,U,null);const G=U.attributes;if(!G||yr(U))return;Le=Sn(he.uponSanitizeAttribute,Le,Ue,rt);const ce={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:Le,forceKeepAttr:void 0};let ve=G.length;const Pe=ae(U.nodeName);for(;ve--;){const Te=G[ve],$t=Te.name,sn=Te.namespaceURI,nr=Te.value,Mn=ae($t),qs=nr;let En=$t==="value"?qs:f9(qs);if(ce.attrName=Mn,ce.attrValue=En,ce.keepAttr=!0,ce.forceKeepAttr=void 0,Ge(he.uponSanitizeAttribute,U,ce),En=ce.attrValue,yn&&(Mn==="id"||Mn==="name")&&y1(En,ne)!==0&&(Ye($t,U,Te),En=ne+En),lt&&Hr(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,En)){Ye($t,U,Te);continue}if(Mn==="attributename"&&w1(En,"href")){Ye($t,U,Te);continue}if(!ce.forceKeepAttr){if(!ce.keepAttr){Ye($t,U,Te);continue}if(!De&&Hr(I9,En)){Ye($t,U,Te);continue}if(nt&&(En=Ut(En)),!go(Pe,Mn,En)){Ye($t,U,Te);continue}En=ko(Pe,Mn,sn,En),En!==qs&&Fn(U,$t,sn,En)}}Ge(he.afterSanitizeAttributes,U,null)},Ar=function(U){let G=null;const ce=Zn(U);for(Ge(he.beforeSanitizeShadowDOM,U,null);G=ce.nextNode();)if(Ge(he.uponSanitizeShadowNode,G,null),ir(G,U),on(G),X(G.content)&&Ar(G.content),C(G)===xo.element){const ve=N(G);X(ve)&&(dr(ve),Ar(ve))}Ge(he.afterSanitizeShadowDOM,U,null)},dr=function(U){const G=[{node:U,shadow:null}];for(;G.length>0;){const ce=G.pop();if(ce.shadow){Ar(ce.shadow);continue}const ve=ce.node,Te=C(ve)===xo.element,$t=_(ve);if($t)for(let sn=$t.length-1;sn>=0;--sn)G.push({node:$t[sn],shadow:null});if(Te){const sn=A?A(ve):null;if(typeof sn=="string"&&ae(sn)==="template"){const nr=ve.content;X(nr)&&G.push({node:nr,shadow:null})}}if(Te){const sn=N(ve);X(sn)&&G.push({node:null,shadow:sn},{node:sn,shadow:null})}}};return t.sanitize=function(Ie){let U=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},G=null,ce=null,ve=null,Pe=null;if(Ve=!Ie,Ve&&(Ie="<!-->"),typeof Ie!="string"&&!ge(Ie)&&(Ie=k9(Ie),typeof Ie!="string"))throw fa("dirty is not a string, aborting");if(!t.isSupported)return Ie;$n?(Se=gt,Le=rt):zt(U),(he.uponSanitizeElement.length>0||he.uponSanitizeAttribute.length>0)&&(Se=Eo(Se)),he.uponSanitizeAttribute.length>0&&(Le=Eo(Le)),t.removed=[];const Te=qe&&typeof Ie!="string"&&ge(Ie);if(Te){hn(Ie);const nr=M(Ie);if(typeof nr=="string"){const Mn=ae(nr);if(!Se[Mn]||Ht[Mn])throw be(Ie),fa("root node is forbidden and cannot be sanitized in-place")}if(yr(Ie))throw be(Ie),fa("root node is clobbered and cannot be sanitized in-place");try{dr(Ie)}catch(Mn){throw be(Ie),Mn}}else if(ge(Ie))G=wr("<!---->"),ce=G.ownerDocument.importNode(Ie,!0),ce.nodeType===xo.element&&ce.nodeName==="BODY"||ce.nodeName==="HTML"?G=ce:G.appendChild(ce),dr(ce);else{if(!Qt&&!nt&&!Yt&&Ie.indexOf("<")===-1)return I&&qn?V(Ie):Ie;if(G=wr(Ie),!G)return Qt?null:qn?D:""}G&&Kn&&Bt(G.firstChild);const $t=Te?Ie:G;try{const nr=Zn($t);for(;ve=nr.nextNode();)ir(ve,$t),on(ve),X(ve.content)&&Ar(ve.content)}catch(nr){throw Te&&(be(Ie),pa(t.removed,Mn=>{Mn.element&&yt(Mn.element)})),nr}if(Te)return pa(t.removed,nr=>{nr.element&&yt(nr.element)}),nt&&pn(Ie),Ie;if(Qt){if(nt&&pn(G),Cn)for(Pe=W.call(G.ownerDocument);G.firstChild;)Pe.appendChild(G.firstChild);else Pe=G;return(Le.shadowroot||Le.shadowrootmode)&&(Pe=de.call(r,Pe,!0)),Pe}let sn=Yt?G.outerHTML:G.innerHTML;return Yt&&Se["!doctype"]&&G.ownerDocument&&G.ownerDocument.doctype&&G.ownerDocument.doctype.name&&Hr(T9,G.ownerDocument.doctype.name)&&(sn="<!DOCTYPE "+G.ownerDocument.doctype.name+`>
139
- `+sn),nt&&(sn=Ut(sn)),I&&qn?V(sn):sn},t.setConfig=function(){let Ie=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};zt(Ie),$n=!0,gt=Se,rt=Le},t.clearConfig=function(){_e=null,$n=!1,gt=null,rt=null,I=H,D=""},t.isValidAttribute=function(Ie,U,G){_e||zt({});const ce=ae(Ie),ve=ae(U);return go(ce,ve,G)},t.addHook=function(Ie,U){typeof U=="function"&&lo(he,Ie)&&Qc(he[Ie],U)},t.removeHook=function(Ie,U){if(lo(he,Ie)){if(U!==void 0){const G=u9(he[Ie],U);return G===-1?void 0:d9(he[Ie],G,1)[0]}return k1(he[Ie])}},t.removeHooks=function(Ie){lo(he,Ie)&&(he[Ie]=[])},t.removeAllHooks=function(){he=$1()},t}var L9=NT();function Ry(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var Ba=Ry();function jT(e){Ba=e}var wa={exec:()=>null};function Tl(e){let t=[];return n=>{let r=Math.max(0,Math.min(3,n-1)),o=t[r];return o||(o=e(r),t[r]=o),o}}function an(e,t=""){let n=typeof e=="string"?e:e.source,r={replace:(o,s)=>{let a=typeof s=="string"?s:s.source;return a=a.replace(Kr.caret,"$1"),n=n.replace(o,a),r},getRegex:()=>new RegExp(n,t)};return r}var P9=((e="")=>{try{return!!new RegExp("(?<=1)(?<!1)"+e)}catch{return!1}})(),Kr={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,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ 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,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:e=>new RegExp(`^( {0,3}${e})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:Tl(e=>new RegExp(`^ {0,${e}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`)),hrRegex:Tl(e=>new RegExp(`^ {0,${e}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`)),fencesBeginRegex:Tl(e=>new RegExp(`^ {0,${e}}(?:\`\`\`|~~~)`)),headingBeginRegex:Tl(e=>new RegExp(`^ {0,${e}}#`)),htmlBeginRegex:Tl(e=>new RegExp(`^ {0,${e}}<(?:[a-z].*>|!--)`,"i")),blockquoteBeginRegex:Tl(e=>new RegExp(`^ {0,${e}}>`))},D9=/^(?:[ \t]*(?:\n|$))+/,z9=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,F9=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Ju=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,B9=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,Oy=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,TT=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,$T=an(TT).replace(/bull/g,Oy).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}(?:\s|$)/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),U9=an(TT).replace(/bull/g,Oy).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}(?:\s|$)/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),My=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table|[ \t]+\n)[^\n]+)*)/,H9=/^[^\n]+/,Ly=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,W9=an(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Ly).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),K9=an(/^(bull)([ \t][^\n]*?)?(?:\n|$)/).replace(/bull/g,Oy).getRegex(),yp="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",Py=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,q9=an("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n*|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>[^\\n]*\\n*|$)|<![A-Z][\\s\\S]*?(?:>[^\\n]*\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>[^\\n]*\\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",Py).replace("tag",yp).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),CT=e=>an(My).replace("hr",Ju).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace("list",e).replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",yp).getRegex(),Z9=CT(/ {0,3}(?:[*+-]|1[.)])[ \t]+[^ \t\n]/),G9=CT(/ {0,3}(?:[*+-]|\d{1,9}[.)])(?:[ \t]|\n|$)/),V9=an(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",G9).getRegex(),Dy={blockquote:V9,code:z9,def:W9,fences:F9,heading:B9,hr:Ju,html:q9,lheading:$T,list:K9,newline:D9,paragraph:Z9,table:wa,text:H9},C1=an("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",Ju).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",yp).getRegex(),Y9={...Dy,lheading:U9,table:C1,paragraph:an(My).replace("hr",Ju).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",C1).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]+[^ \\t\\n]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",yp).getRegex()},X9={...Dy,html:an(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Py).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:wa,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:an(My).replace("hr",Ju).replace("heading",` *#{1,6} *[^
140
- ]`).replace("lheading",$T).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},Q9=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,J9=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,IT=/^( {2,}|\\)\n(?!\s*$)/,eB=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,Ks=/[\p{P}\p{S}]/u,cc=/[\s\p{P}\p{S}]/u,ed=/[^\s\p{P}\p{S}]/u,tB=an(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,cc).getRegex(),nB=/[\p{Pi}\p{Ps}"']/u,AT=/(?!~)[\p{P}\p{S}]/u,rB=/(?!~)[\s\p{P}\p{S}]/u,oB=/(?:[^\s\p{P}\p{S}]|~)/u,sB=an(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",P9?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),RT=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,iB=an(RT,"u").replace(/punct/g,Ks).getRegex(),aB=an(RT,"u").replace(/punct/g,AT).getRegex(),lB=/^(?:\*+(?:((?!\*)(?!openQuote)punct)|([^\s*]))?)|^_+(?:((?!_)(?!openQuote)punct)|([^\s_]))?/,cB=an(lB,"u").replace(/openQuote/g,nB).replace(/punct/g,Ks).getRegex(),OT="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",uB=an(OT,"gu").replace(/notPunctSpace/g,ed).replace(/punctSpace/g,cc).replace(/punct/g,Ks).getRegex(),dB=an(OT,"gu").replace(/notPunctSpace/g,oB).replace(/punctSpace/g,rB).replace(/punct/g,AT).getRegex(),fB="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)[\\s](\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|(?:(?!\\*)punct|notPunctSpace)(\\*+)(?!\\*)(?=notPunctSpace)",hB=an(fB,"gu").replace(/notPunctSpace/g,ed).replace(/punctSpace/g,cc).replace(/punct/g,Ks).getRegex(),pB=an("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,ed).replace(/punctSpace/g,cc).replace(/punct/g,Ks).getRegex(),mB="^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)[\\s](_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)|(?:(?!_)punct|notPunctSpace)(_+)(?!_)(?=notPunctSpace)",gB=an(mB,"gu").replace(/notPunctSpace/g,ed).replace(/punctSpace/g,cc).replace(/punct/g,Ks).getRegex(),kB=an(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,Ks).getRegex(),wB="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",yB=an(wB,"gu").replace(/notPunctSpace/g,ed).replace(/punctSpace/g,cc).replace(/punct/g,Ks).getRegex(),vB=an(/\\(punct)/,"gu").replace(/punct/g,Ks).getRegex(),bB=an(/^<(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(),xB=an(Py).replace("(?:-->|$)","-->").getRegex(),EB=an("^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",xB).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),gh=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,SB=an(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",gh).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]+|(?=\))/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),MT=an(/^!?\[(label)\]\[(ref)\]/).replace("label",gh).replace("ref",Ly).getRegex(),LT=an(/^!?\[(ref)\](?:\[\])?/).replace("ref",Ly).getRegex(),_B=an("reflink|nolink(?!\\()","g").replace("reflink",MT).replace("nolink",LT).getRegex(),I1=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,zy={_backpedal:wa,anyPunctuation:vB,autolink:bB,blockSkip:sB,br:IT,code:J9,del:wa,delLDelim:wa,delRDelim:wa,emStrongLDelim:iB,emStrongRDelimAst:uB,emStrongRDelimUnd:pB,escape:Q9,link:SB,nolink:LT,punctuation:tB,reflink:MT,reflinkSearch:_B,tag:EB,text:eB,url:wa},NB={...zy,emStrongLDelim:cB,emStrongRDelimAst:hB,emStrongRDelimUnd:gB,link:an(/^!?\[(label)\]\((.*?)\)/).replace("label",gh).getRegex(),reflink:an(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",gh).getRegex()},Pk={...zy,emStrongRDelimAst:dB,emStrongLDelim:aB,delLDelim:kB,delRDelim:yB,url:an(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",I1).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\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:an(/^(`+|~+|[^`~])(?:(?=[`~])|(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",I1).getRegex()},jB={...Pk,br:an(IT).replace("{2,}","*").getRegex(),text:an(Pk.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},Cf={normal:Dy,gfm:Y9,pedantic:X9},tu={normal:zy,gfm:Pk,breaks:jB,pedantic:NB},TB={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},A1=e=>TB[e];function hs(e,t){if(t){if(Kr.escapeTest.test(e))return e.replace(Kr.escapeReplace,A1)}else if(Kr.escapeTestNoEncode.test(e))return e.replace(Kr.escapeReplaceNoEncode,A1);return e}function R1(e){try{e=encodeURI(e).replace(Kr.percentDecode,"%")}catch{return null}return e}function O1(e,t){var s;let n=e.replace(Kr.findPipe,(a,c,u)=>{let f=!1,h=c;for(;--h>=0&&u[h]==="\\";)f=!f;return f?"|":" |"}),r=n.split(Kr.splitPipe),o=0;if(r[0].trim()||r.shift(),r.length>0&&!((s=r.at(-1))!=null&&s.trim())&&r.pop(),t)if(r.length>t)r.splice(t);else for(;r.length<t;)r.push("");for(;o<r.length;o++)r[o]=r[o].trim().replace(Kr.slashPipe,"|");return r}function xi(e,t,n){let r=e.length;if(r===0)return"";let o=0;for(;o<r&&e.charAt(r-o-1)===t;)o++;return e.slice(0,r-o)}function M1(e){let t=e.split(`
141
- `),n=t.length-1;for(;n>=0&&Kr.blankLine.test(t[n]);)n--;return t.length-n<=2?e:t.slice(0,n+1).join(`
142
- `)}function $B(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 CB(e,t=0){let n=t,r="";for(let o of e)if(o===" "){let s=4-n%4;r+=" ".repeat(s),n+=s}else r+=o,n++;return r}function L1(e,t,n,r,o){let s=t.href,a=t.title||null,c=e[1].replace(o.other.outputLinkReplace,"$1"),u=e[0].charAt(0)==="!";r.state.inLink=!0;let f=r.state.linkEmitted,h=r.state.inRawBlock;r.state.linkEmitted=!1;let m=r.inlineTokens(c),g=r.state.linkEmitted;if(r.state.linkEmitted=f,r.state.inLink=!1,!u){if(g){r.state.inRawBlock=h;return}r.state.linkEmitted=!0}return{type:u?"image":"link",raw:n,href:s,title:a,text:c,tokens:m}}function IB(e,t,n){let r=e.match(n.other.indentCodeCompensation);if(r===null)return t;let o=r[1];return t.split(`
143
- `).map(s=>{let a=s.match(n.other.beginningSpace);if(a===null)return s;let[c]=a;return c.length>=o.length?s.slice(o.length):s}).join(`
144
- `)}var kh=class{constructor(e){jt(this,"options");jt(this,"rules");jt(this,"lexer");this.options=e||Ba}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 n=this.options.pedantic?t[0]:M1(t[0]),r=n.replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:n,codeBlockStyle:"indented",text:r}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let n=t[0],r=IB(n,t[3]||"",this.rules);return{type:"code",raw:n,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):t[2],text:r}}}heading(e){let t=this.rules.block.heading.exec(e);if(t){let n=t[2].trim();if(this.rules.other.endingHash.test(n)){let r=xi(n,"#");(this.options.pedantic||!r||this.rules.other.endingSpaceChar.test(r))&&(n=r.trim())}return{type:"heading",raw:xi(t[0],`
145
- `),depth:t[1].length,text:n,tokens:this.lexer.inline(n)}}}hr(e){let t=this.rules.block.hr.exec(e);if(t)return{type:"hr",raw:xi(t[0],`
146
- `)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let n=xi(t[0],`
147
- `).split(`
148
- `),r="",o="",s=[];for(;n.length>0;){let a=!1,c=[],u;for(u=0;u<n.length;u++)if(this.rules.other.blockquoteStart.test(n[u]))c.push(n[u]),a=!0;else if(!a)c.push(n[u]);else break;n=n.slice(u);let f=c.join(`
149
- `),h=f.replace(this.rules.other.blockquoteSetextReplace,`
150
- $1`).replace(this.rules.other.blockquoteSetextReplace2,"");r=r?`${r}
151
- ${f}`:f,o=o?`${o}
152
- ${h}`:h;let m=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(h,s,!0),this.lexer.state.top=m,n.length===0)break;let g=s.at(-1);if((g==null?void 0:g.type)==="code")break;if((g==null?void 0:g.type)==="blockquote"){let y=g,w=n.join(`
153
- `),v=y.raw+`
154
- `+w.replace(this.rules.other.blockquoteSetextReplace2,""),_=this.blockquote(v);s[s.length-1]=_,r=`${r}
155
- ${w}`,o=o.substring(0,o.length-y.text.length)+_.text;break}else if((g==null?void 0:g.type)==="list"){let y=g,w=y.raw+`
156
- `+n.join(`
157
- `),v=this.list(w);s[s.length-1]=v,r=r.substring(0,r.length-g.raw.length)+v.raw,o=o.substring(0,o.length-y.raw.length)+v.raw,n=w.substring(s.at(-1).raw.length).split(`
158
- `);continue}}return{type:"blockquote",raw:r,tokens:s,text:o}}}list(e){let t=this.rules.block.list.exec(e);if(t){let n=t[1].trim(),r=n.length>1,o={type:"list",raw:"",ordered:r,start:r?+n.slice(0,-1):"",loose:!1,items:[]};n=r?`\\d{1,9}\\${n.slice(-1)}`:`\\${n}`,this.options.pedantic&&(n=r?n:"[*+-]");let s=this.rules.other.listItemRegex(n),a=!1;for(;e;){let u=!1,f="",h="";if(!(t=s.exec(e))||this.rules.block.hr.test(e))break;f=t[0],e=e.substring(f.length);let m=CB(t[2].split(`
159
- `,1)[0],t[1].length),g=e.split(`
160
- `,1)[0],y=!m.trim(),w=0;if(this.options.pedantic?(w=2,h=m.trimStart()):y?w=t[1].length+1:(w=m.search(this.rules.other.nonSpaceChar),w=w>4?1:w,h=m.slice(w),w+=t[1].length),y&&this.rules.other.blankLine.test(g)&&(f+=g+`
161
- `,e=e.substring(g.length+1),u=!0),!u){let v=this.rules.other.nextBulletRegex(w),_=this.rules.other.hrRegex(w),x=this.rules.other.fencesBeginRegex(w),N=this.rules.other.headingBeginRegex(w),T=this.rules.other.htmlBeginRegex(w),j=this.rules.other.blockquoteBeginRegex(w);for(;e;){let A=e.split(`
162
- `,1)[0],R;if(g=A,this.options.pedantic?(g=g.replace(this.rules.other.listReplaceNesting," "),R=g):R=g.replace(this.rules.other.tabCharGlobal," "),x.test(g)||N.test(g)||T.test(g)||j.test(g)||v.test(g)||_.test(g))break;if(R.search(this.rules.other.nonSpaceChar)>=w||!g.trim())h+=`
163
- `+R.slice(w);else{if(y||m.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||x.test(m)||N.test(m)||_.test(m))break;h+=`
164
- `+g}y=!g.trim(),f+=A+`
165
- `,e=e.substring(A.length+1),m=R.slice(w)}}o.loose||(a?o.loose=!0:this.rules.other.doubleBlankLine.test(f)&&(a=!0)),o.items.push({type:"list_item",raw:f,task:!!this.options.gfm&&this.rules.other.listIsTask.test(h),loose:!1,text:h,tokens:[]}),o.raw+=f}let c=o.items.at(-1);if(c)c.raw=c.raw.trimEnd(),c.text=c.text.trimEnd();else return;o.raw=o.raw.trimEnd();for(let u of o.items)if(this.lexer.state.top=!1,u.tokens=this.lexer.blockTokens(u.text,[]),!o.loose){let f=u.tokens.filter(m=>m.type==="space"),h=f.length>0&&f.some(m=>this.rules.other.anyLine.test(m.raw));o.loose=h}for(let u of o.items){let f=u.tokens[0];if(u.task&&((f==null?void 0:f.type)==="text"||(f==null?void 0:f.type)==="paragraph")){u.text=u.text.replace(this.rules.other.listReplaceTask,""),f.raw=f.raw.replace(this.rules.other.listReplaceTask,""),f.text=f.text.replace(this.rules.other.listReplaceTask,"");for(let m=this.lexer.inlineQueue.length-1;m>=0;m--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[m].src)){this.lexer.inlineQueue[m].src=this.lexer.inlineQueue[m].src.replace(this.rules.other.listReplaceTask,"");break}let h=this.rules.other.listTaskCheckbox.exec(u.raw);if(h){let m={type:"checkbox",raw:h[0]+" ",checked:h[0]!=="[ ]"};u.checked=m.checked,o.loose?u.tokens[0]&&["paragraph","text"].includes(u.tokens[0].type)&&"tokens"in u.tokens[0]&&u.tokens[0].tokens?(u.tokens[0].raw=m.raw+u.tokens[0].raw,u.tokens[0].text=m.raw+u.tokens[0].text,u.tokens[0].tokens.unshift(m)):u.tokens.unshift({type:"paragraph",raw:m.raw,text:m.raw,tokens:[m]}):u.tokens.unshift(m)}}else u.task&&(u.task=!1)}if(o.loose)for(let u of o.items){u.loose=!0;for(let f of u.tokens)f.type==="text"&&(f.type="paragraph")}return o}}html(e){let t=this.rules.block.html.exec(e);if(t){let n=M1(t[0]);return{type:"html",block:!0,raw:n,pre:t[1]==="pre"||t[1]==="script"||t[1]==="style",text:n}}}def(e){let t=this.rules.block.def.exec(e);if(t){let n=t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),r=t[2]?t[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",o=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):t[3];return{type:"def",tag:n,raw:xi(t[0],`
166
- `),href:r,title:o}}}table(e){var a;let t=this.rules.block.table.exec(e);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let n=O1(t[1]),r=t[2].replace(this.rules.other.tableAlignChars,"").split("|"),o=(a=t[3])!=null&&a.trim()?t[3].replace(this.rules.other.tableRowBlankLine,"").split(`
167
- `):[],s={type:"table",raw:xi(t[0],`
168
- `),header:[],align:[],rows:[]};if(n.length===r.length){for(let c of r)this.rules.other.tableAlignRight.test(c)?s.align.push("right"):this.rules.other.tableAlignCenter.test(c)?s.align.push("center"):this.rules.other.tableAlignLeft.test(c)?s.align.push("left"):s.align.push(null);for(let c=0;c<n.length;c++)s.header.push({text:n[c],tokens:this.lexer.inline(n[c]),header:!0,align:s.align[c]});for(let c of o)s.rows.push(O1(c,s.header.length).map((u,f)=>({text:u,tokens:this.lexer.inline(u),header:!1,align:s.align[f]})));return s}}lheading(e){let t=this.rules.block.lheading.exec(e);if(t){let n=t[1].trim();return{type:"heading",raw:xi(t[0],`
169
- `),depth:t[2].charAt(0)==="="?1:2,text:n,tokens:this.lexer.inline(n)}}}paragraph(e){let t=this.rules.block.paragraph.exec(e);if(t){let n=t[1].charAt(t[1].length-1)===`
170
- `?t[1].slice(0,-1):t[1];return{type:"paragraph",raw:t[0],text:n,tokens:this.lexer.inline(n)}}}text(e){let t=this.rules.block.text.exec(e);if(t)return{type:"text",raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(e){let t=this.rules.inline.escape.exec(e);if(t)return{type:"escape",raw:t[0],text:t[1]}}tag(e){let t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&this.rules.other.startATag.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(e){let t=this.rules.inline.link.exec(e);if(t){let n=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(n)){if(!this.rules.other.endAngleBracket.test(n))return;let s=xi(n.slice(0,-1),"\\");if((n.length-s.length)%2===0)return}else{let s=$B(t[2],"()");if(s===-2)return;if(s>-1){let a=(t[0].indexOf("!")===0?5:4)+t[1].length+s;t[2]=t[2].substring(0,s),t[0]=t[0].substring(0,a).trim(),t[3]=""}}let r=t[2],o="";if(this.options.pedantic){let s=this.rules.other.pedanticHrefTitle.exec(r);s&&(r=s[1],o=s[3])}else o=t[3]?t[3].slice(1,-1):"";return r=r.trim(),this.rules.other.startAngleBracket.test(r)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(n)?r=r.slice(1):r=r.slice(1,-1)),L1(t,{href:r&&r.replace(this.rules.inline.anyPunctuation,"$1"),title:o&&o.replace(this.rules.inline.anyPunctuation,"$1")},t[0],this.lexer,this.rules)}}reflink(e,t){let n;if((n=this.rules.inline.reflink.exec(e))||(n=this.rules.inline.nolink.exec(e))){let r=(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal," "),o=t[r.toLowerCase()];if(!o){let s=n[0].charAt(0);return{type:"text",raw:s,text:s}}return L1(n,o,n[0],this.lexer,this.rules)}}emStrong(e,t,n=""){let r=this.rules.inline.emStrongLDelim.exec(e);if(!(!r||!r[1]&&!r[2]&&!r[3]&&!r[4]||r[4]&&n.match(this.rules.other.unicodeAlphaNumeric))&&(!(r[1]||r[3])||!n||this.rules.inline.punctuation.exec(n))){let o=[...r[0]].length-1,s,a,c=o,u=0,f=r[0][0],h=n===f,m=f==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(m.lastIndex=0,t=t.slice(-1*e.length+o);(r=m.exec(t))!==null;){if(s=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!s)continue;if(a=[...s].length,r[3]||r[4]){c+=a;continue}else if(r[5]||r[6]){if(o%3&&!((o+a)%3)){u+=a;continue}if(h)break}if(c-=a,c>0)continue;a=Math.min(a,a+c+u);let g=[...r[0]][0].length,y=e.slice(0,o+r.index+g+a);if(Math.min(o,a)%2){let v=y.slice(1,-1);return{type:"em",raw:y,text:v,tokens:this.lexer.inlineTokens(v)}}let w=y.slice(2,-2);return{type:"strong",raw:y,text:w,tokens:this.lexer.inlineTokens(w)}}}}codespan(e){let t=this.rules.inline.code.exec(e);if(t){let n=t[2].replace(this.rules.other.newLineCharGlobal," "),r=this.rules.other.nonSpaceChar.test(n),o=this.rules.other.startingSpaceChar.test(n)&&this.rules.other.endingSpaceChar.test(n);return r&&o&&(n=n.substring(1,n.length-1)),{type:"codespan",raw:t[0],text:n}}}br(e){let t=this.rules.inline.br.exec(e);if(t)return{type:"br",raw:t[0]}}del(e,t,n=""){let r=this.rules.inline.delLDelim.exec(e);if(r&&(!r[1]||!n||this.rules.inline.punctuation.exec(n))){let o=[...r[0]].length-1,s,a,c=o,u=this.rules.inline.delRDelim;for(u.lastIndex=0,t=t.slice(-1*e.length+o);(r=u.exec(t))!==null;){if(s=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!s||(a=[...s].length,a!==o))continue;if(r[3]||r[4]){c+=a;continue}if(c-=a,c>0)continue;a=Math.min(a,a+c);let f=[...r[0]][0].length,h=e.slice(0,o+r.index+f+a),m=h.slice(o,-o);return{type:"del",raw:h,text:m,tokens:this.lexer.inlineTokens(m)}}}}autolink(e){let t=this.rules.inline.autolink.exec(e);if(t){let n,r;return t[2]==="@"?(n=t[1],r="mailto:"+n):(n=t[1],r=n),{type:"link",raw:t[0],text:n,href:r,tokens:[{type:"text",raw:n,text:n}]}}}url(e){var n;let t;if(t=this.rules.inline.url.exec(e)){let r,o;if(t[2]==="@")r=t[0],o="mailto:"+r;else{let s;do s=t[0],t[0]=((n=this.rules.inline._backpedal.exec(t[0]))==null?void 0:n[0])??"";while(s!==t[0]);r=t[0],t[1]==="www."?o="http://"+t[0]:o=t[0]}return{type:"link",raw:t[0],text:r,href:o,tokens:[{type:"text",raw:r,text:r}]}}}inlineText(e){let t=this.rules.inline.text.exec(e);if(t){let n=this.lexer.state.inRawBlock;return{type:"text",raw:t[0],text:t[0],escaped:n}}}},ts=class Dk{constructor(t){jt(this,"tokens");jt(this,"options");jt(this,"state");jt(this,"inlineQueue");jt(this,"tokenizer");this.tokens=[],this.tokens.links=Object.create(null),this.options=t||Ba,this.options.tokenizer=this.options.tokenizer||new kh,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,linkEmitted:!1,top:!0};let n={other:Kr,block:Cf.normal,inline:tu.normal};this.options.pedantic?(n.block=Cf.pedantic,n.inline=tu.pedantic):this.options.gfm&&(n.block=Cf.gfm,this.options.breaks?n.inline=tu.breaks:n.inline=tu.gfm),this.tokenizer.rules=n}static get rules(){return{block:Cf,inline:tu}}static lex(t,n){return new Dk(n).lex(t)}static lexInline(t,n){return new Dk(n).inlineTokens(t)}lex(t){t=t.replace(Kr.carriageReturn,`
171
- `),this.blockTokens(t,this.tokens);for(let n=0;n<this.inlineQueue.length;n++){let r=this.inlineQueue[n];this.inlineTokens(r.src,r.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(t,n=[],r=!1){var s,a,c;this.tokenizer.lexer=this,this.options.pedantic&&(t=t.replace(Kr.tabCharGlobal," ").replace(Kr.spaceLine,""));let o=1/0;for(;t;){if(t.length<o)o=t.length;else{this.infiniteLoopError(t.charCodeAt(0));break}let u;if((a=(s=this.options.extensions)==null?void 0:s.block)!=null&&a.some(h=>(u=h.call({lexer:this},t,n))?(t=t.substring(u.raw.length),n.push(u),!0):!1))continue;if(u=this.tokenizer.space(t)){t=t.substring(u.raw.length);let h=n.at(-1);u.raw.length===1&&h!==void 0?h.raw+=`
172
- `:n.push(u);continue}if(u=this.tokenizer.code(t)){t=t.substring(u.raw.length);let h=n.at(-1);(h==null?void 0:h.type)==="paragraph"||(h==null?void 0:h.type)==="text"?(h.raw+=(h.raw.endsWith(`
173
- `)?"":`
174
- `)+u.raw,h.text+=`
175
- `+u.text,this.inlineQueue.at(-1).src=h.text):n.push(u);continue}if(u=this.tokenizer.fences(t)){t=t.substring(u.raw.length),n.push(u);continue}if(u=this.tokenizer.heading(t)){t=t.substring(u.raw.length),n.push(u);continue}if(u=this.tokenizer.hr(t)){t=t.substring(u.raw.length),n.push(u);continue}if(u=this.tokenizer.blockquote(t)){t=t.substring(u.raw.length),n.push(u);continue}if(u=this.tokenizer.list(t)){t=t.substring(u.raw.length),n.push(u);continue}if(u=this.tokenizer.html(t)){t=t.substring(u.raw.length),n.push(u);continue}if(u=this.tokenizer.def(t)){t=t.substring(u.raw.length);let h=n.at(-1);(h==null?void 0:h.type)==="paragraph"||(h==null?void 0:h.type)==="text"?(h.raw+=(h.raw.endsWith(`
176
- `)?"":`
177
- `)+u.raw,h.text+=`
178
- `+u.raw,this.inlineQueue.at(-1).src=h.text):this.tokens.links[u.tag]||(this.tokens.links[u.tag]={href:u.href,title:u.title},n.push(u));continue}if(u=this.tokenizer.table(t)){t=t.substring(u.raw.length),n.push(u);continue}if(u=this.tokenizer.lheading(t)){t=t.substring(u.raw.length),n.push(u);continue}let f=t;if((c=this.options.extensions)!=null&&c.startBlock){let h=1/0,m=t.slice(1),g;this.options.extensions.startBlock.forEach(y=>{g=y.call({lexer:this},m),typeof g=="number"&&g>=0&&(h=Math.min(h,g))}),h<1/0&&h>=0&&(f=t.substring(0,h+1))}if(this.state.top&&(u=this.tokenizer.paragraph(f))){let h=n.at(-1);r&&(h==null?void 0:h.type)==="paragraph"?(h.raw+=(h.raw.endsWith(`
179
- `)?"":`
180
- `)+u.raw,h.text+=`
181
- `+u.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=h.text):n.push(u),r=f.length!==t.length,t=t.substring(u.raw.length);continue}if(u=this.tokenizer.text(t)){t=t.substring(u.raw.length);let h=n.at(-1);(h==null?void 0:h.type)==="text"?(h.raw+=(h.raw.endsWith(`
182
- `)?"":`
183
- `)+u.raw,h.text+=`
184
- `+u.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=h.text):n.push(u);continue}if(t){this.infiniteLoopError(t.charCodeAt(0));break}}return this.state.top=!0,n}inline(t,n=[]){return this.inlineQueue.push({src:t,tokens:n}),n}linkInText(t){if(!t.includes("["))return!1;let n=this.tokenizer.rules.inline.link;for(let r of t.matchAll(this.tokenizer.rules.inline.blockSkip))if(n.test(r[0])&&t.charAt(r.index-1)!=="!")return!0;for(let r of t.matchAll(this.tokenizer.rules.inline.reflinkSearch)){let o=r[0],s=o.lastIndexOf("[");if(!(o.charAt(0)==="!"||!Object.hasOwn(this.tokens.links,o.slice(s+1,-1)))&&!(s>1&&this.linkInText(o.slice(1,s-1))))return!0}return!1}inlineTokens(t,n=[]){var c,u,f,h,m;this.tokenizer.lexer=this;let r=t;if(this.tokens.links&&t.includes("[")){let g=this.tokenizer.rules.inline.reflinkSearch,y=w=>{let v=w.lastIndexOf("[");if(!Object.hasOwn(this.tokens.links,w.slice(v+1,-1)))return w;if(v>1&&w.charAt(0)!=="!"){let _=w.slice(1,v-1);if(this.linkInText(_))return"["+_.replace(g,y)+"]["+"a".repeat(w.length-v-2)+"]"}return"["+"a".repeat(w.length-2)+"]"};r=r.replace(g,y)}r=r.replace(this.tokenizer.rules.inline.anyPunctuation,g=>"+".repeat(g.length)),r=r.replace(this.tokenizer.rules.inline.blockSkip,(g,y,w)=>{let v=w?w.length:0;return g.slice(0,v)+"["+"a".repeat(g.length-v-2)+"]"}),r=((u=(c=this.options.hooks)==null?void 0:c.emStrongMask)==null?void 0:u.call({lexer:this},r))??r;let o=!1,s="",a=1/0;for(;t;){if(t.length<a)a=t.length;else{this.infiniteLoopError(t.charCodeAt(0));break}o||(s=""),o=!1;let g;if((h=(f=this.options.extensions)==null?void 0:f.inline)!=null&&h.some(w=>(g=w.call({lexer:this},t,n))?(t=t.substring(g.raw.length),n.push(g),!0):!1))continue;if(g=this.tokenizer.escape(t)){t=t.substring(g.raw.length),n.push(g);continue}if(g=this.tokenizer.tag(t)){t=t.substring(g.raw.length),n.push(g);continue}if(g=this.tokenizer.link(t)){t=t.substring(g.raw.length),n.push(g);continue}if(g=this.tokenizer.reflink(t,this.tokens.links)){t=t.substring(g.raw.length);let w=n.at(-1);g.type==="text"&&(w==null?void 0:w.type)==="text"?(w.raw+=g.raw,w.text+=g.text):n.push(g);continue}if(g=this.tokenizer.emStrong(t,r,s)){t=t.substring(g.raw.length),n.push(g);continue}if(g=this.tokenizer.codespan(t)){t=t.substring(g.raw.length),n.push(g);continue}if(g=this.tokenizer.br(t)){t=t.substring(g.raw.length),n.push(g);continue}if(g=this.tokenizer.del(t,r,s)){t=t.substring(g.raw.length),n.push(g);continue}if(g=this.tokenizer.autolink(t)){t=t.substring(g.raw.length),n.push(g);continue}if(!this.state.inLink&&(g=this.tokenizer.url(t))){t=t.substring(g.raw.length),n.push(g);continue}let y=t;if((m=this.options.extensions)!=null&&m.startInline){let w=1/0,v=t.slice(1),_;this.options.extensions.startInline.forEach(x=>{_=x.call({lexer:this},v),typeof _=="number"&&_>=0&&(w=Math.min(w,_))}),w<1/0&&w>=0&&(y=t.substring(0,w+1))}if(g=this.tokenizer.inlineText(y)){t=t.substring(g.raw.length),g.raw.slice(-1)!=="_"&&(s=g.raw.slice(-1)),o=!0;let w=n.at(-1);(w==null?void 0:w.type)==="text"?(w.raw+=g.raw,w.text+=g.text):n.push(g);continue}if(t){this.infiniteLoopError(t.charCodeAt(0));break}}return n}infiniteLoopError(t){let n="Infinite loop on byte: "+t;if(this.options.silent)console.error(n);else throw new Error(n)}},Ou=class{constructor(e){jt(this,"options");jt(this,"parser");this.options=e||Ba}space(e){return""}code({text:e,lang:t,escaped:n}){var s;let r=(s=(t||"").match(Kr.notSpaceStart))==null?void 0:s[0],o=e.replace(Kr.endingNewline,"")+`
185
- `;return r?'<pre><code class="language-'+hs(r)+'">'+(n?o:hs(o,!0))+`</code></pre>
186
- `:"<pre><code>"+(n?o:hs(o,!0))+`</code></pre>
187
- `}blockquote({tokens:e}){return`<blockquote>
188
- ${this.parser.parse(e)}</blockquote>
189
- `}html({text:e}){return e}def(e){return""}heading({tokens:e,depth:t}){return`<h${t}>${this.parser.parseInline(e)}</h${t}>
190
- `}hr(e){return`<hr>
191
- `}list(e){let t=e.ordered,n=e.start,r="";for(let a=0;a<e.items.length;a++){let c=e.items[a];r+=this.listitem(c)}let o=t?"ol":"ul",s=t&&n!==1?' start="'+n+'"':"";return"<"+o+s+`>
192
- `+r+"</"+o+`>
193
- `}listitem(e){return`<li>${this.parser.parse(e.tokens)}</li>
194
- `}checkbox({checked:e}){return"<input "+(e?'checked="" ':"")+'disabled="" type="checkbox"> '}paragraph({tokens:e}){return`<p>${this.parser.parseInline(e)}</p>
195
- `}table(e){let t="",n="";for(let o=0;o<e.header.length;o++)n+=this.tablecell(e.header[o]);t+=this.tablerow({text:n});let r="";for(let o=0;o<e.rows.length;o++){let s=e.rows[o];n="";for(let a=0;a<s.length;a++)n+=this.tablecell(s[a]);r+=this.tablerow({text:n})}return r&&(r=`<tbody>${r}</tbody>`),`<table>
196
- <thead>
197
- `+t+`</thead>
198
- `+r+`</table>
199
- `}tablerow({text:e}){return`<tr>
200
- ${e}</tr>
201
- `}tablecell(e){let t=this.parser.parseInline(e.tokens),n=e.header?"th":"td";return(e.align?`<${n} align="${e.align}">`:`<${n}>`)+t+`</${n}>
202
- `}strong({tokens:e}){return`<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return`<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return`<code>${hs(e,!0)}</code>`}br(e){return"<br>"}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,tokens:n}){let r=this.parser.parseInline(n),o=R1(e);if(o===null)return r;e=o;let s='<a href="'+e+'"';return t&&(s+=' title="'+hs(t)+'"'),s+=">"+r+"</a>",s}image({href:e,title:t,text:n,tokens:r}){r&&(n=this.parser.parseInline(r,this.parser.textRenderer));let o=R1(e);if(o===null)return hs(n);e=o;let s=`<img src="${e}" alt="${hs(n)}"`;return t&&(s+=` title="${hs(t)}"`),s+=">",s}text(e){return"tokens"in e&&e.tokens?this.parser.parseInline(e.tokens):"escaped"in e&&e.escaped?e.text:hs(e.text)}},Fy=class{strong({text:e}){return e}em({text:e}){return e}codespan({text:e}){return e}del({text:e}){return e}html({text:e}){return e}text({text:e}){return e}link({text:e}){return""+e}image({text:e}){return""+e}br(){return""}checkbox({raw:e}){return e}},ns=class zk{constructor(t){jt(this,"options");jt(this,"renderer");jt(this,"textRenderer");this.options=t||Ba,this.options.renderer=this.options.renderer||new Ou,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Fy}static parse(t,n){return new zk(n).parse(t)}static parseInline(t,n){return new zk(n).parseInline(t)}parse(t){var r,o;this.renderer.parser=this;let n="";for(let s=0;s<t.length;s++){let a=t[s];if((o=(r=this.options.extensions)==null?void 0:r.renderers)!=null&&o[a.type]){let u=a,f=this.options.extensions.renderers[u.type].call({parser:this},u);if(f!==!1||!["space","hr","heading","code","table","blockquote","list","checkbox","html","def","paragraph","text"].includes(u.type)){n+=f||"";continue}}let c=a;switch(c.type){case"space":{n+=this.renderer.space(c);break}case"hr":{n+=this.renderer.hr(c);break}case"heading":{n+=this.renderer.heading(c);break}case"code":{n+=this.renderer.code(c);break}case"table":{n+=this.renderer.table(c);break}case"blockquote":{n+=this.renderer.blockquote(c);break}case"list":{n+=this.renderer.list(c);break}case"checkbox":{n+=this.renderer.checkbox(c);break}case"html":{n+=this.renderer.html(c);break}case"def":{n+=this.renderer.def(c);break}case"paragraph":{n+=this.renderer.paragraph(c);break}case"text":{n+=this.renderer.text(c);break}default:{let u='Token with "'+c.type+'" type was not found.';if(this.options.silent)return console.error(u),"";throw new Error(u)}}}return n}parseInline(t,n=this.renderer){var o,s;this.renderer.parser=this;let r="";for(let a=0;a<t.length;a++){let c=t[a];if((s=(o=this.options.extensions)==null?void 0:o.renderers)!=null&&s[c.type]){let f=this.options.extensions.renderers[c.type].call({parser:this},c);if(f!==!1||!["escape","html","link","image","checkbox","strong","em","codespan","br","del","text"].includes(c.type)){r+=f||"";continue}}let u=c;switch(u.type){case"escape":{r+=n.text(u);break}case"html":{r+=n.html(u);break}case"link":{r+=n.link(u);break}case"image":{r+=n.image(u);break}case"checkbox":{r+=n.checkbox(u);break}case"strong":{r+=n.strong(u);break}case"em":{r+=n.em(u);break}case"codespan":{r+=n.codespan(u);break}case"br":{r+=n.br(u);break}case"del":{r+=n.del(u);break}case"text":{r+=n.text(u);break}default:{let f='Token with "'+u.type+'" type was not found.';if(this.options.silent)return console.error(f),"";throw new Error(f)}}}return r}},Pf,au=(Pf=class{constructor(e){jt(this,"options");jt(this,"block");this.options=e||Ba}preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(e=this.block){return e?ts.lex:ts.lexInline}provideParser(e=this.block){return e?ns.parse:ns.parseInline}},jt(Pf,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens","emStrongMask"])),jt(Pf,"passThroughHooksRespectAsync",new Set(["preprocess","postprocess","processAllTokens"])),Pf),AB=class{constructor(...e){jt(this,"defaults",Ry());jt(this,"options",this.setOptions);jt(this,"parse",this.parseMarkdown(!0));jt(this,"parseInline",this.parseMarkdown(!1));jt(this,"Parser",ns);jt(this,"Renderer",Ou);jt(this,"TextRenderer",Fy);jt(this,"Lexer",ts);jt(this,"Tokenizer",kh);jt(this,"Hooks",au);this.use(...e)}walkTokens(e,t){var r,o;let n=[];for(let s of e)switch(n=n.concat(t.call(this,s)),s.type){case"table":{let a=s;for(let c of a.header)n=n.concat(this.walkTokens(c.tokens,t));for(let c of a.rows)for(let u of c)n=n.concat(this.walkTokens(u.tokens,t));break}case"list":{let a=s;n=n.concat(this.walkTokens(a.items,t));break}default:{let a=s;(o=(r=this.defaults.extensions)==null?void 0:r.childTokens)!=null&&o[a.type]?this.defaults.extensions.childTokens[a.type].forEach(c=>{let u=a[c].flat(1/0);n=n.concat(this.walkTokens(u,t))}):a.tokens&&(n=n.concat(this.walkTokens(a.tokens,t)))}}return n}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(n=>{let r={...n};if(r.async=this.defaults.async||r.async||!1,n.extensions&&(n.extensions.forEach(o=>{if(!o.name)throw new Error("extension name required");if("renderer"in o){let s=t.renderers[o.name];s?t.renderers[o.name]=function(...a){let c=o.renderer.apply(this,a);return c===!1&&(c=s.apply(this,a)),c}:t.renderers[o.name]=o.renderer}if("tokenizer"in o){if(!o.level||o.level!=="block"&&o.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let s=t[o.level];s?s.unshift(o.tokenizer):t[o.level]=[o.tokenizer],o.start&&(o.level==="block"?t.startBlock?t.startBlock.push(o.start):t.startBlock=[o.start]:o.level==="inline"&&(t.startInline?t.startInline.push(o.start):t.startInline=[o.start]))}"childTokens"in o&&o.childTokens&&(t.childTokens[o.name]=o.childTokens)}),r.extensions=t),n.renderer){let o=this.defaults.renderer||new Ou(this.defaults);for(let s in n.renderer){if(!(s in o))throw new Error(`renderer '${s}' does not exist`);if(["options","parser"].includes(s))continue;let a=s,c=n.renderer[a],u=o[a];o[a]=(...f)=>{let h=c.apply(o,f);return h===!1&&(h=u.apply(o,f)),h||""}}r.renderer=o}if(n.tokenizer){let o=this.defaults.tokenizer||new kh(this.defaults);for(let s in n.tokenizer){if(!(s in o))throw new Error(`tokenizer '${s}' does not exist`);if(["options","rules","lexer"].includes(s))continue;let a=s,c=n.tokenizer[a],u=o[a];o[a]=(...f)=>{let h=c.apply(o,f);return h===!1&&(h=u.apply(o,f)),h}}r.tokenizer=o}if(n.hooks){let o=this.defaults.hooks||new au;for(let s in n.hooks){if(!(s in o))throw new Error(`hook '${s}' does not exist`);if(["options","block"].includes(s))continue;let a=s,c=n.hooks[a],u=o[a];au.passThroughHooks.has(s)?o[a]=f=>{if(this.defaults.async&&au.passThroughHooksRespectAsync.has(s))return(async()=>{let m=await c.call(o,f);return u.call(o,m)})();let h=c.call(o,f);return u.call(o,h)}:o[a]=(...f)=>{if(this.defaults.async)return(async()=>{let m=await c.apply(o,f);return m===!1&&(m=await u.apply(o,f)),m})();let h=c.apply(o,f);return h===!1&&(h=u.apply(o,f)),h}}r.hooks=o}if(n.walkTokens){let o=this.defaults.walkTokens,s=n.walkTokens;r.walkTokens=function(a){let c=[];return c.push(s.call(this,a)),o&&(c=c.concat(o.call(this,a))),c}}this.defaults={...this.defaults,...r}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return ts.lex(e,t??this.defaults)}parser(e,t){return ns.parse(e,t??this.defaults)}parseMarkdown(e){return(t,n)=>{let r={...n},o={...this.defaults,...r},s=this.onError(!!o.silent,!!o.async);if(this.defaults.async===!0&&r.async===!1)return s(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof t>"u"||t===null)return s(new Error("marked(): input parameter is undefined or null"));if(typeof t!="string")return s(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(t)+", string expected"));if(o.hooks&&(o.hooks.options=o,o.hooks.block=e),o.async)return(async()=>{let a=o.hooks?await o.hooks.preprocess(t):t,c=await(o.hooks?await o.hooks.provideLexer(e):e?ts.lex:ts.lexInline)(a,o),u=o.hooks?await o.hooks.processAllTokens(c):c;o.walkTokens&&await Promise.all(this.walkTokens(u,o.walkTokens));let f=await(o.hooks?await o.hooks.provideParser(e):e?ns.parse:ns.parseInline)(u,o);return o.hooks?await o.hooks.postprocess(f):f})().catch(s);try{o.hooks&&(t=o.hooks.preprocess(t));let a=(o.hooks?o.hooks.provideLexer(e):e?ts.lex:ts.lexInline)(t,o);o.hooks&&(a=o.hooks.processAllTokens(a)),o.walkTokens&&this.walkTokens(a,o.walkTokens);let c=(o.hooks?o.hooks.provideParser(e):e?ns.parse:ns.parseInline)(a,o);return o.hooks&&(c=o.hooks.postprocess(c)),c}catch(a){return s(a)}}}onError(e,t){return n=>{if(n.message+=`
203
- Please report this to https://github.com/markedjs/marked.`,e){let r="<p>An error occurred:</p><pre>"+hs(n.message+"",!0)+"</pre>";return t?Promise.resolve(r):r}if(t)return Promise.reject(n);throw n}}},Oa=new AB;function _n(e,t){return Oa.parse(e,t)}_n.options=_n.setOptions=function(e){return Oa.setOptions(e),_n.defaults=Oa.defaults,jT(_n.defaults),_n};_n.getDefaults=Ry;_n.defaults=Ba;function RB(...e){return Oa.use(...e),_n.defaults=Oa.defaults,jT(_n.defaults),_n}_n.use=RB;_n.walkTokens=function(e,t){return Oa.walkTokens(e,t)};_n.parseInline=Oa.parseInline;_n.Parser=ns;_n.parser=ns.parse;_n.Renderer=Ou;_n.TextRenderer=Fy;_n.Lexer=ts;_n.lexer=ts.lex;_n.Tokenizer=kh;_n.Hooks=au;_n.parse=_n;_n.options;_n.setOptions;_n.walkTokens;_n.parseInline;ns.parse;ts.lex;const Ma=100,OB=e=>e.type==="text-delta"||e.type==="thinking-delta"||e.type==="tool-delta";function MB(e,t){if(e.worktreeId!==t.worktreeId||e.event.type!==t.event.type)return!1;switch(e.event.type){case"text-delta":return e.event.messageId===t.event.messageId;case"tool-delta":return e.event.toolId===t.event.toolId;default:return!0}}const LB={now:()=>performance.now(),after:(e,t)=>void setTimeout(t,e)};function PB(e,t=LB){let n=[],r=!1,o=Number.NEGATIVE_INFINITY;const s=()=>{if(r=!1,n.length===0)return;const a=n;n=[],o=t.now();for(const c of a)e(c)};return a=>{if(a.t==="agent"&&OB(a.event)){const c={...a,event:{...a.event}},u=t.now();if(n.length===0&&u-o>=Ma){o=u,e(c);return}const f=n[n.length-1];f&&MB(f,c)?f.event={...f.event,text:f.event.text+c.event.text}:n.push(c),r||(r=!0,t.after(Math.max(0,o+Ma-u),s));return}s(),e(a)}}const PT="#toyon-link-pending",DB=/!?\[([^[\]\n]*)(?:\]\(([^()\s]*))?$/;function zB(e){const t=e.lastIndexOf(`
204
- `)+1,n=e.slice(t),r=DB.exec(n);return!r||FB(e.slice(0,t))||BB(n.slice(0,r.index))?e:`${e.slice(0,t)}${n.slice(0,r.index)}[${r[1]}](${PT})`}function FB(e){let t=!1;for(const n of e.split(`
205
- `))/^\s*(```|~~~)/.test(n)&&(t=!t);return t}function BB(e){let t=0;for(const n of e)n==="`"&&t++;return t%2===1}const Tg="__[a-z][a-z0-9_]*[a-z0-9]__",UB=new RegExp(`^(?:${Tg}\\.)+${Tg}|^${Tg}(?=\\.\\w|\\(|["'])`),HB={name:"dunder",level:"inline",start:e=>e.indexOf("__"),tokenizer(e){const t=UB.exec(e);if(t)return{type:"dunder",raw:t[0],text:t[0]}},renderer:e=>e.text},Fo=e=>e.replace(/[&<>]/g,t=>t==="&"?"&amp;":t==="<"?"&lt;":"&gt;");function WB({text:e}){return Fo(e)}const KB="[A-Za-z0-9](?:[A-Za-z0-9-]{0,38})?",qB="[\\w.-]*[\\w-]",By=`(${KB}\\/${qB})#(\\d+)`,DT=new RegExp(`(^|[^\\w./@-])${By}(?![\\w-])`),ZB=new RegExp(`^${By}(?![\\w-])`),GB=new RegExp(`^${By}$`),VB=new RegExp(DT.source,"g"),YB=/^https?:\/\/\S+$/;function XB(e){const t=[];for(const n of e.matchAll(VB)){const r=n.index+(n[1]??"").length;t.push({start:r,end:n.index+n[0].length})}return t}function Uy(e){const t=GB.exec(e);return t?`https://github.com/${t[1]}/issues/${t[2]}`:null}function zT(e){return YB.test(e)?e:Uy(e)}function QB({text:e}){const t=`<code>${Fo(e)}</code>`,n=zT(e);return n?`<a href="${FT(n)}">${t}</a>`:t}const FT=e=>Fo(e).replace(/"/g,"&quot;"),JB={name:"githubRef",level:"inline",start:e=>{const t=DT.exec(e);return t?t.index+t[1].length:void 0},tokenizer(e){const t=ZB.exec(e);if(t)return{type:"githubRef",raw:t[0],text:t[0],href:Uy(t[0])}},renderer:e=>`<a href="${FT(e.href)}">${Fo(e.text)}</a>`};function eU(e){return`<div class="md-table">${tU.call(this,e)}</div>
206
- `}function tU(e){if(e.header.some(n=>n.text.trim()))return Ou.prototype.table.call(this,e);let t="";for(const n of e.rows){let r="";for(const o of n)r+=this.tablecell(o);t+=this.tablerow({text:r})}return`<table>
207
- <tbody>${t}</tbody></table>
208
- `}function nU(e){const t=e.regex,n={},r={begin:/\$\{/,end:/\}/,contains:["self",{begin:/:-/,contains:[n]}]};Object.assign(n,{className:"variable",variants:[{begin:t.concat(/\$[\w\d#@][\w\d_]*/,"(?![\\w\\d])(?![$])")},r]});const o={className:"subst",begin:/\$\(/,end:/\)/,contains:[e.BACKSLASH_ESCAPE]},s=e.inherit(e.COMMENT(),{match:[/(^|\s)/,/#.*$/],scope:{2:"comment"}}),a={begin:/<<-?\s*(?=\w+)/,starts:{contains:[e.END_SAME_AS_BEGIN({begin:/(\w+)/,end:/(\w+)/,className:"string"})]}},c={className:"string",begin:/"/,end:/"/,contains:[e.BACKSLASH_ESCAPE,n,o]};o.contains.push(c);const u={match:/\\"/},f={className:"string",begin:/'/,end:/'/},h={match:/\\'/},m={begin:/\$?\(\(/,end:/\)\)/,contains:[{begin:/\d+#[0-9a-f]+/,className:"number"},e.NUMBER_MODE,n]},g=["fish","bash","zsh","sh","csh","ksh","tcsh","dash","scsh"],y=e.SHEBANG({binary:`(${g.join("|")})`,relevance:10}),w={className:"function",begin:/\w[\w\d_]*\s*\(\s*\)\s*\{/,returnBegin:!0,contains:[e.inherit(e.TITLE_MODE,{begin:/\w[\w\d_]*/})],relevance:0},v=["if","then","else","elif","fi","time","for","while","until","in","do","done","case","esac","coproc","function","select"],_=["true","false"],x={match:/(\/[a-z._-]+)+/},N=["break","cd","continue","eval","exec","exit","export","getopts","hash","pwd","readonly","return","shift","test","times","trap","umask","unset"],T=["alias","bind","builtin","caller","command","declare","echo","enable","help","let","local","logout","mapfile","printf","read","readarray","source","sudo","type","typeset","ulimit","unalias"],j=["autoload","bg","bindkey","bye","cap","chdir","clone","comparguments","compcall","compctl","compdescribe","compfiles","compgroups","compquote","comptags","comptry","compvalues","dirs","disable","disown","echotc","echoti","emulate","fc","fg","float","functions","getcap","getln","history","integer","jobs","kill","limit","log","noglob","popd","print","pushd","pushln","rehash","sched","setcap","setopt","stat","suspend","ttyctl","unfunction","unhash","unlimit","unsetopt","vared","wait","whence","where","which","zcompile","zformat","zftp","zle","zmodload","zparseopts","zprof","zpty","zregexparse","zsocket","zstyle","ztcp"],A=["chcon","chgrp","chown","chmod","cp","dd","df","dir","dircolors","ln","ls","mkdir","mkfifo","mknod","mktemp","mv","realpath","rm","rmdir","shred","sync","touch","truncate","vdir","b2sum","base32","base64","cat","cksum","comm","csplit","cut","expand","fmt","fold","head","join","md5sum","nl","numfmt","od","paste","ptx","pr","sha1sum","sha224sum","sha256sum","sha384sum","sha512sum","shuf","sort","split","sum","tac","tail","tr","tsort","unexpand","uniq","wc","arch","basename","chroot","date","dirname","du","echo","env","expr","factor","groups","hostid","id","link","logname","nice","nohup","nproc","pathchk","pinky","printenv","printf","pwd","readlink","runcon","seq","sleep","stat","stdbuf","stty","tee","test","timeout","tty","uname","unlink","uptime","users","who","whoami","yes"];return{name:"Bash",aliases:["sh","zsh"],keywords:{$pattern:/\b[a-z][a-z0-9._-]+\b/,keyword:v,literal:_,built_in:[...N,...T,"set","shopt",...j,...A]},contains:[y,e.SHEBANG(),w,m,s,a,x,c,u,f,h,n]}}const rU=e=>({IMPORTANT:{scope:"meta",begin:"!important"},BLOCK_COMMENT:e.C_BLOCK_COMMENT_MODE,HEXCOLOR:{scope:"number",begin:/#(([0-9a-fA-F]{3,4})|(([0-9a-fA-F]{2}){3,4}))\b/},UNICODE_RANGE:{scope:"number",begin:/\b[Uu]\+[0-9A-Fa-f][0-9A-Fa-f?]{0,5}(-[0-9A-Fa-f][0-9A-Fa-f]{0,5})?/},FUNCTION_DISPATCH:{className:"built_in",begin:/[\w-]+(?=\()/},ATTRIBUTE_SELECTOR_MODE:{scope:"selector-attr",begin:/\[/,end:/\]/,illegal:"$",contains:[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE]},CSS_NUMBER_MODE:{scope:"number",begin:e.NUMBER_RE+"(%|em|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc|px|deg|grad|rad|turn|s|ms|Hz|kHz|dpi|dpcm|dppx)?",relevance:0},CSS_VARIABLE:{className:"attr",begin:/--[A-Za-z_][A-Za-z0-9_-]*/}}),oU=["a","abbr","address","article","aside","audio","b","blockquote","body","button","canvas","caption","cite","code","dd","del","details","dfn","div","dl","dt","em","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","html","i","iframe","img","input","ins","kbd","label","legend","li","main","mark","menu","nav","object","ol","optgroup","option","p","picture","q","quote","samp","section","select","source","span","strong","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","tr","ul","var","video"],sU=["defs","g","marker","mask","pattern","svg","switch","symbol","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feFlood","feGaussianBlur","feImage","feMerge","feMorphology","feOffset","feSpecularLighting","feTile","feTurbulence","linearGradient","radialGradient","stop","circle","ellipse","image","line","path","polygon","polyline","rect","text","use","textPath","tspan","foreignObject","clipPath"],iU=[...oU,...sU],aU=["any-hover","any-pointer","aspect-ratio","color","color-gamut","color-index","device-aspect-ratio","device-height","device-width","display-mode","forced-colors","grid","height","hover","inverted-colors","monochrome","orientation","overflow-block","overflow-inline","pointer","prefers-color-scheme","prefers-contrast","prefers-reduced-motion","prefers-reduced-transparency","resolution","scan","scripting","update","width","min-width","max-width","min-height","max-height"].sort().reverse(),lU=["active","any-link","blank","checked","current","default","defined","dir","disabled","drop","empty","enabled","first","first-child","first-of-type","fullscreen","future","focus","focus-visible","focus-within","has","host","host-context","hover","indeterminate","in-range","invalid","is","lang","last-child","last-of-type","left","link","local-link","not","nth-child","nth-col","nth-last-child","nth-last-col","nth-last-of-type","nth-of-type","only-child","only-of-type","optional","out-of-range","past","placeholder-shown","read-only","read-write","required","right","root","scope","target","target-within","user-invalid","valid","visited","where"].sort().reverse(),cU=["after","backdrop","before","cue","cue-region","first-letter","first-line","grammar-error","marker","part","placeholder","selection","slotted","spelling-error"].sort().reverse(),uU=["accent-color","align-content","align-items","align-self","alignment-baseline","all","anchor-name","animation","animation-composition","animation-delay","animation-direction","animation-duration","animation-fill-mode","animation-iteration-count","animation-name","animation-play-state","animation-range","animation-range-end","animation-range-start","animation-timeline","animation-timing-function","appearance","aspect-ratio","backdrop-filter","backface-visibility","background","background-attachment","background-blend-mode","background-clip","background-color","background-image","background-origin","background-position","background-position-x","background-position-y","background-repeat","background-size","baseline-shift","block-size","border","border-block","border-block-color","border-block-end","border-block-end-color","border-block-end-style","border-block-end-width","border-block-start","border-block-start-color","border-block-start-style","border-block-start-width","border-block-style","border-block-width","border-bottom","border-bottom-color","border-bottom-left-radius","border-bottom-right-radius","border-bottom-style","border-bottom-width","border-collapse","border-color","border-end-end-radius","border-end-start-radius","border-image","border-image-outset","border-image-repeat","border-image-slice","border-image-source","border-image-width","border-inline","border-inline-color","border-inline-end","border-inline-end-color","border-inline-end-style","border-inline-end-width","border-inline-start","border-inline-start-color","border-inline-start-style","border-inline-start-width","border-inline-style","border-inline-width","border-left","border-left-color","border-left-style","border-left-width","border-radius","border-right","border-right-color","border-right-style","border-right-width","border-spacing","border-start-end-radius","border-start-start-radius","border-style","border-top","border-top-color","border-top-left-radius","border-top-right-radius","border-top-style","border-top-width","border-width","bottom","box-align","box-decoration-break","box-direction","box-flex","box-flex-group","box-lines","box-ordinal-group","box-orient","box-pack","box-shadow","box-sizing","break-after","break-before","break-inside","caption-side","caret-color","clear","clip","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","color-scheme","column-count","column-fill","column-gap","column-rule","column-rule-color","column-rule-style","column-rule-width","column-span","column-width","columns","contain","contain-intrinsic-block-size","contain-intrinsic-height","contain-intrinsic-inline-size","contain-intrinsic-size","contain-intrinsic-width","container","container-name","container-type","content","content-visibility","corner-bottom-left-shape","corner-bottom-right-shape","corner-shape","corner-top-left-shape","corner-top-right-shape","counter-increment","counter-reset","counter-set","cue","cue-after","cue-before","cursor","cx","cy","direction","display","dominant-baseline","empty-cells","enable-background","field-sizing","fill","fill-opacity","fill-rule","filter","flex","flex-basis","flex-direction","flex-flow","flex-grow","flex-shrink","flex-wrap","float","flood-color","flood-opacity","flow","font","font-display","font-family","font-feature-settings","font-kerning","font-language-override","font-optical-sizing","font-palette","font-size","font-size-adjust","font-smooth","font-smoothing","font-stretch","font-style","font-synthesis","font-synthesis-position","font-synthesis-small-caps","font-synthesis-style","font-synthesis-weight","font-variant","font-variant-alternates","font-variant-caps","font-variant-east-asian","font-variant-emoji","font-variant-ligatures","font-variant-numeric","font-variant-position","font-variation-settings","font-weight","forced-color-adjust","gap","glyph-orientation-horizontal","glyph-orientation-vertical","grid","grid-area","grid-auto-columns","grid-auto-flow","grid-auto-rows","grid-column","grid-column-end","grid-column-start","grid-gap","grid-row","grid-row-end","grid-row-start","grid-template","grid-template-areas","grid-template-columns","grid-template-rows","hanging-punctuation","height","hyphenate-character","hyphenate-limit-chars","hyphens","icon","image-orientation","image-rendering","image-resolution","ime-mode","initial-letter","initial-letter-align","inline-size","inset","inset-area","inset-block","inset-block-end","inset-block-start","inset-inline","inset-inline-end","inset-inline-start","isolation","justify-content","justify-items","justify-self","kerning","left","letter-spacing","lighting-color","line-break","line-height","line-height-step","list-style","list-style-image","list-style-position","list-style-type","margin","margin-block","margin-block-end","margin-block-start","margin-bottom","margin-inline","margin-inline-end","margin-inline-start","margin-left","margin-right","margin-top","margin-trim","marker","marker-end","marker-mid","marker-start","marks","mask","mask-border","mask-border-mode","mask-border-outset","mask-border-repeat","mask-border-slice","mask-border-source","mask-border-width","mask-clip","mask-composite","mask-image","mask-mode","mask-origin","mask-position","mask-repeat","mask-size","mask-type","masonry-auto-flow","math-depth","math-shift","math-style","max-block-size","max-height","max-inline-size","max-width","min-block-size","min-height","min-inline-size","min-width","mix-blend-mode","nav-down","nav-index","nav-left","nav-right","nav-up","none","normal","object-fit","object-position","offset","offset-anchor","offset-distance","offset-path","offset-position","offset-rotate","opacity","order","orphans","outline","outline-color","outline-offset","outline-style","outline-width","overflow","overflow-anchor","overflow-block","overflow-clip-margin","overflow-inline","overflow-wrap","overflow-x","overflow-y","overlay","overscroll-behavior","overscroll-behavior-block","overscroll-behavior-inline","overscroll-behavior-x","overscroll-behavior-y","padding","padding-block","padding-block-end","padding-block-start","padding-bottom","padding-inline","padding-inline-end","padding-inline-start","padding-left","padding-right","padding-top","page","page-break-after","page-break-before","page-break-inside","paint-order","pause","pause-after","pause-before","perspective","perspective-origin","place-content","place-items","place-self","pointer-events","position","position-anchor","position-visibility","print-color-adjust","quotes","r","resize","rest","rest-after","rest-before","right","rotate","row-gap","ruby-align","ruby-position","scale","scroll-behavior","scroll-margin","scroll-margin-block","scroll-margin-block-end","scroll-margin-block-start","scroll-margin-bottom","scroll-margin-inline","scroll-margin-inline-end","scroll-margin-inline-start","scroll-margin-left","scroll-margin-right","scroll-margin-top","scroll-padding","scroll-padding-block","scroll-padding-block-end","scroll-padding-block-start","scroll-padding-bottom","scroll-padding-inline","scroll-padding-inline-end","scroll-padding-inline-start","scroll-padding-left","scroll-padding-right","scroll-padding-top","scroll-snap-align","scroll-snap-stop","scroll-snap-type","scroll-timeline","scroll-timeline-axis","scroll-timeline-name","scrollbar-color","scrollbar-gutter","scrollbar-width","shape-image-threshold","shape-margin","shape-outside","shape-rendering","speak","speak-as","src","stop-color","stop-opacity","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","tab-size","table-layout","text-align","text-align-all","text-align-last","text-anchor","text-combine-upright","text-decoration","text-decoration-color","text-decoration-line","text-decoration-skip","text-decoration-skip-ink","text-decoration-style","text-decoration-thickness","text-emphasis","text-emphasis-color","text-emphasis-position","text-emphasis-style","text-indent","text-justify","text-orientation","text-overflow","text-rendering","text-shadow","text-size-adjust","text-transform","text-underline-offset","text-underline-position","text-wrap","text-wrap-mode","text-wrap-style","timeline-scope","top","touch-action","transform","transform-box","transform-origin","transform-style","transition","transition-behavior","transition-delay","transition-duration","transition-property","transition-timing-function","translate","unicode-bidi","unicode-range","user-modify","user-select","vector-effect","vertical-align","view-timeline","view-timeline-axis","view-timeline-inset","view-timeline-name","view-transition-name","visibility","voice-balance","voice-duration","voice-family","voice-pitch","voice-range","voice-rate","voice-stress","voice-volume","white-space","white-space-collapse","widows","width","will-change","word-break","word-spacing","word-wrap","writing-mode","x","y","z-index","zoom"].sort().reverse();function dU(e){const t=e.regex,n=rU(e),r={begin:/-(webkit|moz|ms|o)-(?=[a-z])/},o="and or not only",s=/@-?\w[\w]*(-\w+)*/,a="[a-zA-Z-][a-zA-Z0-9_-]*",c=[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE];return{name:"CSS",case_insensitive:!0,illegal:/[=|'\$]/,keywords:{keyframePosition:"from to"},classNameAliases:{keyframePosition:"selector-tag"},contains:[n.BLOCK_COMMENT,r,n.CSS_NUMBER_MODE,{className:"selector-id",begin:/#[A-Za-z0-9_-]+/,relevance:0},{className:"selector-class",begin:"\\."+a,relevance:0},n.ATTRIBUTE_SELECTOR_MODE,{className:"selector-pseudo",variants:[{begin:":("+lU.join("|")+")"},{begin:":(:)?("+cU.join("|")+")"}]},n.CSS_VARIABLE,{className:"attribute",begin:"\\b("+uU.join("|")+")\\b"},{begin:/:/,end:/[;}{]/,contains:[n.BLOCK_COMMENT,n.HEXCOLOR,n.IMPORTANT,n.CSS_NUMBER_MODE,n.UNICODE_RANGE,...c,{begin:/(url|data-uri)\(/,end:/\)/,relevance:0,keywords:{built_in:"url data-uri"},contains:[...c,{className:"string",begin:/[^)]/,endsWithParent:!0,excludeEnd:!0}]},n.FUNCTION_DISPATCH]},{begin:t.lookahead(/@/),end:"[{;]",relevance:0,illegal:/:/,contains:[{className:"keyword",begin:s},{begin:/\s/,endsWithParent:!0,excludeEnd:!0,relevance:0,keywords:{$pattern:/[a-z-]+/,keyword:o,attribute:aU.join(" ")},contains:[{begin:/[a-z-]+(?=:)/,className:"attribute"},...c,n.CSS_NUMBER_MODE]}]},{className:"selector-tag",begin:"\\b("+iU.join("|")+")\\b"}]}}function fU(e){const s={keyword:["break","case","chan","const","continue","default","defer","else","fallthrough","for","func","go","goto","if","import","interface","map","package","range","return","select","struct","switch","type","var"],type:["bool","byte","complex64","complex128","error","float32","float64","int8","int16","int32","int64","string","uint8","uint16","uint32","uint64","int","uint","uintptr","rune"],literal:["true","false","iota","nil"],built_in:["append","cap","close","complex","copy","imag","len","make","new","panic","print","println","real","recover","delete"]};return{name:"Go",aliases:["golang"],keywords:s,illegal:"</",contains:[e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,{className:"string",variants:[e.QUOTE_STRING_MODE,e.APOS_STRING_MODE,{begin:"`",end:"`"}]},{className:"number",variants:[{match:/-?\b0[xX]\.[a-fA-F0-9](_?[a-fA-F0-9])*[pP][+-]?\d(_?\d)*i?/,relevance:0},{match:/-?\b0[xX](_?[a-fA-F0-9])+((\.([a-fA-F0-9](_?[a-fA-F0-9])*)?)?[pP][+-]?\d(_?\d)*)?i?/,relevance:0},{match:/-?\b0[oO](_?[0-7])*i?/,relevance:0},{match:/-?\b0[bB](_?[01])*i?/,relevance:0},{match:/-?\.\d(_?\d)*([eE][+-]?\d(_?\d)*)?i?/,relevance:0},{match:/-?\b\d(_?\d)*(\.(\d(_?\d)*)?)?([eE][+-]?\d(_?\d)*)?i?/,relevance:0}]},{begin:/:=/},{className:"function",beginKeywords:"func",end:"\\s*(\\{|$)",excludeEnd:!0,contains:[e.TITLE_MODE,{className:"params",begin:/\(/,end:/\)/,endsParent:!0,keywords:s,illegal:/["']/}]}]}}function hU(e){const t=e.regex,n={className:"number",relevance:0,variants:[{begin:/([+-]+)?[\d]+_[\d_]+/},{begin:e.NUMBER_RE}]},r=e.COMMENT();r.variants=[{begin:/;/,end:/$/},{begin:/#/,end:/$/}];const o={className:"variable",variants:[{begin:/\$[\w\d"][\w\d_]*/},{begin:/\$\{(.*?)\}/}]},s={className:"literal",begin:/\bon|off|true|false|yes|no\b/},a={className:"string",contains:[e.BACKSLASH_ESCAPE],variants:[{begin:"'''",end:"'''",relevance:10},{begin:'"""',end:'"""',relevance:10},{begin:'"',end:'"'},{begin:"'",end:"'"}]},c={begin:/\[/,end:/\]/,contains:[r,s,o,a,n,"self"],relevance:0},u=/[A-Za-z0-9_-]+/,f=/"(\\"|[^"])*"/,h=/'[^']*'/,m=t.either(u,f,h),g=t.concat(m,"(\\s*\\.\\s*",m,")*",t.lookahead(/\s*=\s*[^#\s]/));return{name:"TOML, also INI",aliases:["toml"],case_insensitive:!0,illegal:/\S/,contains:[r,{className:"section",begin:/\[+/,end:/\]+/},{begin:g,className:"attr",starts:{end:/$/,contains:[r,c,s,o,a,n]}}]}}const P1="[A-Za-z$_][0-9A-Za-z$_]*",pU=["as","in","of","if","for","while","finally","var","new","function","do","return","void","else","break","catch","instanceof","with","throw","case","default","try","switch","continue","typeof","delete","let","yield","const","class","debugger","async","await","static","import","from","export","extends","using"],mU=["true","false","null","undefined","NaN","Infinity"],BT=["Object","Function","Boolean","Symbol","Math","Date","Number","BigInt","String","RegExp","Array","Float32Array","Float64Array","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Int32Array","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array","Set","Map","WeakSet","WeakMap","ArrayBuffer","SharedArrayBuffer","Atomics","DataView","JSON","Promise","Generator","GeneratorFunction","AsyncFunction","Reflect","Proxy","Intl","WebAssembly"],UT=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],HT=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],gU=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","self","global"],kU=[].concat(HT,BT,UT);function wU(e){const t=e.regex,n=($,{after:Q})=>{const q="</"+$[0].slice(1);return $.input.indexOf(q,Q)!==-1},r=P1,o={begin:"<>",end:"</>"},s=/<[A-Za-z0-9\\._:-]+\s*\/>/,a={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:($,Q)=>{const q=$[0].length+$.index,W=$.input[q];if(W==="<"||W===","){Q.ignoreMatch();return}W===">"&&(n($,{after:q})||Q.ignoreMatch());let oe;const de=$.input.substring(q);if(oe=de.match(/^\s*=/)){Q.ignoreMatch();return}if((oe=de.match(/^\s+extends\s+/))&&oe.index===0){Q.ignoreMatch();return}}},c={$pattern:P1,keyword:pU,literal:mU,built_in:kU,"variable.language":gU},u="[0-9](_?[0-9])*",f=`\\.(${u})`,h="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",m={className:"number",variants:[{begin:`(\\b(${h})((${f})|\\.)?|(${f}))[eE][+-]?(${u})\\b`},{begin:`\\b(${h})\\b((${f})\\b|\\.)?|(${f})\\b`},{begin:"\\b(0|[1-9](_?[0-9])*)n\\b"},{begin:"\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*n?\\b"},{begin:"\\b0[bB][0-1](_?[0-1])*n?\\b"},{begin:"\\b0[oO][0-7](_?[0-7])*n?\\b"},{begin:"\\b0[0-7]+n?\\b"}],relevance:0},g={className:"subst",begin:"\\$\\{",end:"\\}",keywords:c,contains:[]},y={begin:".?html`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,g],subLanguage:"xml"}},w={begin:".?css`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,g],subLanguage:"css"}},v={begin:".?gql`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,g],subLanguage:"graphql"}},_={className:"string",begin:"`",end:"`",contains:[e.BACKSLASH_ESCAPE,g]},N={className:"comment",variants:[e.COMMENT(/\/\*\*(?!\/)/,"\\*/",{relevance:0,contains:[{begin:"(?=@[A-Za-z]+)",relevance:0,contains:[{className:"doctag",begin:"@[A-Za-z]+"},{className:"type",begin:"\\{",end:"\\}",excludeEnd:!0,excludeBegin:!0,relevance:0},{className:"variable",begin:r+"(?=\\s*(-)|$)",endsParent:!0,relevance:0},{begin:/(?=[^\n])\s/,relevance:0}]}]}),e.C_BLOCK_COMMENT_MODE,e.C_LINE_COMMENT_MODE]},T=[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,y,w,v,_,{match:/\$\d+/},m];g.contains=T.concat({begin:/\{/,end:/\}/,keywords:c,contains:["self"].concat(T)});const j=[].concat(N,g.contains),A=j.concat([{begin:/(\s*)\(/,end:/\)/,keywords:c,contains:["self"].concat(j)}]),R={className:"params",begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:c,contains:A},C={variants:[{match:[/class/,/\s+/,r,/\s+/,/extends/,/\s+/,t.concat(r,"(",t.concat(/\./,r),")*")],scope:{1:"keyword",3:"title.class",5:"keyword",7:"title.class.inherited"}},{match:[/class/,/\s+/,r],scope:{1:"keyword",3:"title.class"}}]},M={relevance:0,match:t.either(/\bJSON/,/\b[A-Z][a-z]+([A-Z][a-z]*|\d)*/,/\b[A-Z]{2,}([A-Z][a-z]+|\d)+([A-Z][a-z]*)*/,/\b[A-Z]{2,}[a-z]+([A-Z][a-z]+|\d)*([A-Z][a-z]*)*/),className:"title.class",keywords:{_:[...BT,...UT]}},I={label:"use_strict",className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},D={variants:[{match:[/function/,/\s+/,r,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:"keyword",3:"title.function"},label:"func.def",contains:[R],illegal:/%/},H={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"};function Z($){return t.concat("(?!",$.join("|"),")")}const B={match:t.concat(/\b/,Z([...HT,"super","import","await"].map($=>`${$}\\s*\\(`)),r,t.lookahead(/\s*\(/)),className:"title.function",relevance:0},J={begin:t.concat(/\./,t.lookahead(t.concat(r,/(?![0-9A-Za-z$_(])/))),end:r,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},V={match:[/get|set/,/\s+/,r,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},R]},ee="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+e.UNDERSCORE_IDENT_RE+")\\s*=>",F={match:[/const|var|let/,/\s+/,r,/\s*/,/=\s*/,/(async\s*)?/,t.lookahead(ee)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[R]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:c,exports:{PARAMS_CONTAINS:A,CLASS_REFERENCE:M},illegal:/#(?![$_A-Za-z])/,contains:[e.SHEBANG({label:"shebang",binary:"node",relevance:5}),I,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,y,w,v,_,N,{match:/\$\d+/},m,M,{scope:"attr",match:r+t.lookahead(":"),relevance:0},F,{begin:"("+e.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",relevance:0,contains:[N,e.REGEXP_MODE,{className:"function",begin:ee,returnBegin:!0,end:"\\s*=>",contains:[{className:"params",variants:[{begin:e.UNDERSCORE_IDENT_RE,relevance:0},{className:null,begin:/\(\s*\)/,skip:!0},{begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:c,contains:A}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:o.begin,end:o.end},{match:s},{begin:a.begin,"on:begin":a.isTrulyOpeningTag,end:a.end}],subLanguage:"xml",contains:[{begin:a.begin,end:a.end,skip:!0,contains:["self"]}]}]},D,{beginKeywords:"while if switch catch for"},{begin:"\\b(?!function)"+e.UNDERSCORE_IDENT_RE+"\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",returnBegin:!0,label:"func.def",contains:[R,e.inherit(e.TITLE_MODE,{begin:r,className:"title.function"})]},{match:/\.\.\./,relevance:0},J,{match:"\\$"+r,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[R]},B,H,C,V,{match:/\$[(.]/}]}}const yU="([-+]?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)|NaN|[-+]?Infinity",vU={scope:"number",match:yU,relevance:0};function bU(e){const t={className:"attr",begin:/(("(\\.|[^\\"\r\n])*")|('(\\.|[^\\'\r\n])*'))(?=\s*:)/,relevance:1.01},n={match:/[{}[\],:]/,className:"punctuation",relevance:0},r=["true","false","null"],o={scope:"literal",beginKeywords:r.join(" ")};return{name:"JSON",aliases:["jsonc","json5"],keywords:{literal:r},contains:[t,n,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,o,vU,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE],illegal:"\\S"}}function xU(e){const t=e.regex,n={begin:/<\/?[A-Za-z_]/,end:">",subLanguage:"xml",relevance:0},r={match:/^ {0,3}([-*_])[ \t]*(?:\1[ \t]*){2,}$/},o={className:"code",variants:[{begin:"(`{3,})[^`](.|\\n)*?\\1`*[ ]*"},{begin:"(~{3,})[^~](.|\\n)*?\\1~*[ ]*"},{begin:"```",end:"```+[ ]*$"},{begin:"~~~",end:"~~~+[ ]*$"},{begin:"`.+?`"},{begin:"(?=^( {4}|\\t))",contains:[{begin:"^( {4}|\\t)",end:"(\\n)$"}],relevance:0}]},s={className:"bullet",begin:"^[ ]*([*+-]|(\\d+\\.))(?=\\s+)",end:"\\s+",excludeEnd:!0},a={begin:/^\[[^\n]+\]:/,returnBegin:!0,contains:[{className:"symbol",begin:/\[/,end:/\]/,excludeBegin:!0,excludeEnd:!0},{className:"link",begin:/:\s*/,end:/$/,excludeBegin:!0}]},c=/[A-Za-z][A-Za-z0-9+.-]*/,u={variants:[{begin:/\[.+?\]\[.*?\]/,relevance:0},{begin:/\[.+?\]\(((data|javascript|mailto):|(?:http|ftp)s?:\/\/).*?\)/,relevance:2},{begin:t.concat(/\[.+?\]\(/,c,/:\/\/.*?\)/),relevance:2},{begin:/\[.+?\]\([./?&#].*?\)/,relevance:1},{begin:/\[.*?\]\(.*?\)/,relevance:0}],returnBegin:!0,contains:[{match:/\[(?=\])/},{className:"string",relevance:0,begin:"\\[",end:"\\]",excludeBegin:!0,returnEnd:!0},{className:"link",relevance:0,begin:"\\]\\(",end:"\\)",excludeBegin:!0,excludeEnd:!0},{className:"symbol",relevance:0,begin:"\\]\\[",end:"\\]",excludeBegin:!0,excludeEnd:!0}]},f={className:"strong",contains:[],variants:[{begin:/_{2}(?!\s)/,end:/_{2}/},{begin:/\*{2}(?!\s)/,end:/\*{2}/}]},h={className:"emphasis",contains:[],variants:[{begin:/\*(?![*\s])/,end:/\*/},{begin:/_(?![_\s])/,end:/_/,relevance:0}]},m=e.inherit(f,{contains:[]}),g=e.inherit(h,{contains:[]});f.contains.push(g),h.contains.push(m);let y=[n,u];return[f,h,m,g].forEach(x=>{x.contains=x.contains.concat(y)}),y=y.concat(f,h),{name:"Markdown",aliases:["md","mkdown","mkd"],contains:[{className:"section",variants:[{begin:"^#{1,6}",end:"$",contains:y},{begin:"(?=^.+?\\n[=-]{2,}$)",contains:[{begin:"^[=-]*$"},{begin:"^",end:"\\n",contains:y}]}]},n,s,r,f,h,{className:"quote",begin:"^>\\s+",contains:y,end:"$"},o,u,a,{scope:"literal",match:/&([a-zA-Z0-9]+|#[0-9]{1,7}|#[Xx][0-9a-fA-F]{1,6});/}]}}function EU(e){const t=e.regex,n=new RegExp("[\\p{XID_Start}_]\\p{XID_Continue}*","u"),r=["and","as","assert","async","await","break","case","class","continue","def","del","elif","else","except","finally","for","from","global","if","import","in","is","lambda","lazy","match","nonlocal|10","not","or","pass","raise","return","try","while","with","yield"],c={$pattern:/[A-Za-z]\w+|__\w+__/,keyword:r,built_in:["__import__","abs","aiter","all","anext","any","ascii","bin","bool","breakpoint","bytearray","bytes","callable","chr","classmethod","compile","complex","delattr","dict","dir","divmod","enumerate","eval","exec","filter","float","format","frozendict","frozenset","getattr","globals","hasattr","hash","help","hex","id","input","int","isinstance","issubclass","iter","len","list","locals","map","max","memoryview","min","next","object","oct","open","ord","pow","print","property","range","repr","reversed","round","sentinel","set","setattr","slice","sorted","staticmethod","str","sum","super","tuple","type","vars","zip"],literal:["__debug__","Ellipsis","False","None","NotImplemented","True"],type:["Any","Callable","Coroutine","Dict","List","Literal","Generic","Optional","Sequence","Set","Tuple","Type","Union"]},u={className:"meta",begin:/^(>>>|\.\.\.) /},f={className:"subst",begin:/\{/,end:/\}/,keywords:c,illegal:/#/},h={begin:/\{\{/,relevance:0},m={className:"string",contains:[e.BACKSLASH_ESCAPE],variants:[{begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?'''/,end:/'''/,contains:[e.BACKSLASH_ESCAPE,u],relevance:10},{begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?"""/,end:/"""/,contains:[e.BACKSLASH_ESCAPE,u],relevance:10},{begin:/([fFtT][rR]|[rR][fFtT]|[fFtT])'''/,end:/'''/,contains:[e.BACKSLASH_ESCAPE,u,h,f]},{begin:/([fFtT][rR]|[rR][fFtT]|[fFtT])"""/,end:/"""/,contains:[e.BACKSLASH_ESCAPE,u,h,f]},{begin:/([uU]|[rR])'/,end:/'/,relevance:10},{begin:/([uU]|[rR])"/,end:/"/,relevance:10},{begin:/([bB]|[bB][rR]|[rR][bB])'/,end:/'/},{begin:/([bB]|[bB][rR]|[rR][bB])"/,end:/"/},{begin:/([fFtT][rR]|[rR][fFtT]|[fFtT])'/,end:/'/,contains:[e.BACKSLASH_ESCAPE,h,f]},{begin:/([fFtT][rR]|[rR][fFtT]|[fFtT])"/,end:/"/,contains:[e.BACKSLASH_ESCAPE,h,f]},e.APOS_STRING_MODE,e.QUOTE_STRING_MODE]},g="[0-9](_?[0-9])*",y=`(\\b(${g}))?\\.(${g})|\\b(${g})\\.`,w=`\\b|${r.join("|")}`,v={className:"number",relevance:0,variants:[{begin:`(\\b(${g})|(${y}))[eE][+-]?(${g})[jJ]?(?=${w})`},{begin:`(${y})[jJ]?`},{begin:`\\b([1-9](_?[0-9])*|0+(_?0)*)[lLjJ]?(?=${w})`},{begin:`\\b0[bB](_?[01])+[lL]?(?=${w})`},{begin:`\\b0[oO](_?[0-7])+[lL]?(?=${w})`},{begin:`\\b0[xX](_?[0-9a-fA-F])+[lL]?(?=${w})`},{begin:`\\b(${g})[jJ](?=${w})`}]},_={className:"comment",begin:t.lookahead(/# type:/),end:/$/,keywords:c,contains:[{begin:/# type:/},{begin:/#/,end:/\b\B/,endsWithParent:!0}]},x={className:"params",variants:[{className:"",begin:/\(\s*\)/,skip:!0},{begin:/\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:c,contains:["self",u,v,m,e.HASH_COMMENT_MODE]}]};return f.contains=[m,v,u],{name:"Python",aliases:["py","gyp","ipython"],unicodeRegex:!0,keywords:c,illegal:/(<\/|\?)|=>/,contains:[u,v,{scope:"variable.language",match:/\bself\b/},{beginKeywords:"if",relevance:0},{match:/\bor\b/,scope:"keyword"},m,_,e.HASH_COMMENT_MODE,{match:[/\bdef/,/\s+/,n],scope:{1:"keyword",3:"title.function"},contains:[x]},{variants:[{match:[/\bclass/,/\s+/,n,/\s*/,/\(\s*/,n,/\s*\)/]},{match:[/\bclass/,/\s+/,n]}],scope:{1:"keyword",3:"title.class",6:"title.class.inherited"}},{className:"meta",begin:/^[\t ]*@/,end:/(?=#)|$/,contains:[v,x,m]}]}}function SU(e){const t=e.regex,n=/(r#)?/,r=t.concat(n,e.UNDERSCORE_IDENT_RE),o=t.concat(n,e.IDENT_RE),s={scope:"title.function.invoke",relevance:0,begin:t.concat(/\b/,/(?!(?:let|for|while|if|else|match)\b)/,o,t.lookahead(/\s*\(/))},a="([ui](8|16|32|64|128|size)|f(16|32|64|128))?",c=["abstract","as","async","await","become","box","break","const","continue","crate","do","dyn","else","enum","extern","false","final","fn","for","if","impl","in","let","loop","macro","match","mod","move","mut","override","priv","pub","raw","ref","return","self","Self","static","struct","super","trait","true","try","type","typeof","union","unsafe","unsized","use","virtual","where","while","yield"],u=["true","false","Some","None","Ok","Err"],f=["drop ","Copy","Send","Sized","Sync","Drop","Fn","FnMut","FnOnce","ToOwned","Clone","Debug","PartialEq","PartialOrd","Eq","Ord","AsRef","AsMut","Into","From","Default","Iterator","Extend","IntoIterator","DoubleEndedIterator","ExactSizeIterator","SliceConcatExt","ToString","assert!","assert_eq!","bitflags!","bytes!","cfg!","col!","concat!","concat_idents!","debug_assert!","debug_assert_eq!","env!","eprintln!","panic!","file!","format!","format_args!","include_bytes!","include_str!","line!","local_data_key!","module_path!","option_env!","print!","println!","select!","stringify!","try!","unimplemented!","unreachable!","vec!","write!","writeln!","macro_rules!","assert_ne!","debug_assert_ne!"],h=["i8","i16","i32","i64","i128","isize","u8","u16","u32","u64","u128","usize","f16","f32","f64","f128","str","char","bool","Box","Option","Result","String","Vec"];return{name:"Rust",aliases:["rs"],keywords:{$pattern:e.IDENT_RE+"!?",type:h,keyword:c,literal:u,built_in:f},illegal:"</",contains:[e.C_LINE_COMMENT_MODE,e.COMMENT("/\\*","\\*/",{contains:["self"]}),e.inherit(e.QUOTE_STRING_MODE,{begin:/b?"/,illegal:null}),{scope:"symbol",begin:/'[a-zA-Z_][a-zA-Z0-9_]*(?!')/},{scope:"string",variants:[{begin:/b?r(#*)"(.|\n)*?"\1(?!#)/},{begin:/b?'/,end:/'/,contains:[{scope:"char.escape",match:/\\('|"|\\|\w|x\w{2}|u\w{4}|U\w{8})/}]}]},{scope:"number",variants:[{begin:"\\b0b([01_]+)"+a},{begin:"\\b0o([0-7_]+)"+a},{begin:"\\b0x([A-Fa-f0-9_]+)"+a},{begin:"\\b(\\d[\\d_]*(\\.[0-9_]+)?([eE][+-]?[0-9_]+)?)"+a}],relevance:0},{begin:[/\bsafe/,/\s+/,/extern/],scope:{1:"keyword",3:"keyword"}},{begin:[/fn/,/\s+/,r],scope:{1:"keyword",3:"title.function"}},{scope:"meta",begin:"#!?\\[",end:"\\]",contains:[{scope:"string",begin:/"/,end:/"/,contains:[e.BACKSLASH_ESCAPE]}]},{begin:[/let/,/\s+/,/(?:mut\s+)?/,r],scope:{1:"keyword",3:"keyword",4:"variable"}},{begin:[/for/,/\s+/,r,/\s+/,/in/],scope:{1:"keyword",3:"variable",5:"keyword"}},{begin:[/type/,/\s+/,r],scope:{1:"keyword",3:"title.class"}},{begin:[/(?:trait|enum|struct|union|impl|for)/,/\s+/,r],scope:{1:"keyword",3:"title.class"}},{begin:e.IDENT_RE+"::",keywords:{keyword:"Self",built_in:f,type:h}},{scope:"punctuation",begin:"->"},s]}}const wh="[A-Za-z$_][0-9A-Za-z$_]*",WT=["as","in","of","if","for","while","finally","var","new","function","do","return","void","else","break","catch","instanceof","with","throw","case","default","try","switch","continue","typeof","delete","let","yield","const","class","debugger","async","await","static","import","from","export","extends","using"],KT=["true","false","null","undefined","NaN","Infinity"],qT=["Object","Function","Boolean","Symbol","Math","Date","Number","BigInt","String","RegExp","Array","Float32Array","Float64Array","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Int32Array","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array","Set","Map","WeakSet","WeakMap","ArrayBuffer","SharedArrayBuffer","Atomics","DataView","JSON","Promise","Generator","GeneratorFunction","AsyncFunction","Reflect","Proxy","Intl","WebAssembly"],ZT=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],GT=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],VT=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","self","global"],YT=[].concat(GT,qT,ZT);function _U(e){const t=e.regex,n=($,{after:Q})=>{const q="</"+$[0].slice(1);return $.input.indexOf(q,Q)!==-1},r=wh,o={begin:"<>",end:"</>"},s=/<[A-Za-z0-9\\._:-]+\s*\/>/,a={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:($,Q)=>{const q=$[0].length+$.index,W=$.input[q];if(W==="<"||W===","){Q.ignoreMatch();return}W===">"&&(n($,{after:q})||Q.ignoreMatch());let oe;const de=$.input.substring(q);if(oe=de.match(/^\s*=/)){Q.ignoreMatch();return}if((oe=de.match(/^\s+extends\s+/))&&oe.index===0){Q.ignoreMatch();return}}},c={$pattern:wh,keyword:WT,literal:KT,built_in:YT,"variable.language":VT},u="[0-9](_?[0-9])*",f=`\\.(${u})`,h="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",m={className:"number",variants:[{begin:`(\\b(${h})((${f})|\\.)?|(${f}))[eE][+-]?(${u})\\b`},{begin:`\\b(${h})\\b((${f})\\b|\\.)?|(${f})\\b`},{begin:"\\b(0|[1-9](_?[0-9])*)n\\b"},{begin:"\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*n?\\b"},{begin:"\\b0[bB][0-1](_?[0-1])*n?\\b"},{begin:"\\b0[oO][0-7](_?[0-7])*n?\\b"},{begin:"\\b0[0-7]+n?\\b"}],relevance:0},g={className:"subst",begin:"\\$\\{",end:"\\}",keywords:c,contains:[]},y={begin:".?html`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,g],subLanguage:"xml"}},w={begin:".?css`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,g],subLanguage:"css"}},v={begin:".?gql`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,g],subLanguage:"graphql"}},_={className:"string",begin:"`",end:"`",contains:[e.BACKSLASH_ESCAPE,g]},N={className:"comment",variants:[e.COMMENT(/\/\*\*(?!\/)/,"\\*/",{relevance:0,contains:[{begin:"(?=@[A-Za-z]+)",relevance:0,contains:[{className:"doctag",begin:"@[A-Za-z]+"},{className:"type",begin:"\\{",end:"\\}",excludeEnd:!0,excludeBegin:!0,relevance:0},{className:"variable",begin:r+"(?=\\s*(-)|$)",endsParent:!0,relevance:0},{begin:/(?=[^\n])\s/,relevance:0}]}]}),e.C_BLOCK_COMMENT_MODE,e.C_LINE_COMMENT_MODE]},T=[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,y,w,v,_,{match:/\$\d+/},m];g.contains=T.concat({begin:/\{/,end:/\}/,keywords:c,contains:["self"].concat(T)});const j=[].concat(N,g.contains),A=j.concat([{begin:/(\s*)\(/,end:/\)/,keywords:c,contains:["self"].concat(j)}]),R={className:"params",begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:c,contains:A},C={variants:[{match:[/class/,/\s+/,r,/\s+/,/extends/,/\s+/,t.concat(r,"(",t.concat(/\./,r),")*")],scope:{1:"keyword",3:"title.class",5:"keyword",7:"title.class.inherited"}},{match:[/class/,/\s+/,r],scope:{1:"keyword",3:"title.class"}}]},M={relevance:0,match:t.either(/\bJSON/,/\b[A-Z][a-z]+([A-Z][a-z]*|\d)*/,/\b[A-Z]{2,}([A-Z][a-z]+|\d)+([A-Z][a-z]*)*/,/\b[A-Z]{2,}[a-z]+([A-Z][a-z]+|\d)*([A-Z][a-z]*)*/),className:"title.class",keywords:{_:[...qT,...ZT]}},I={label:"use_strict",className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},D={variants:[{match:[/function/,/\s+/,r,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:"keyword",3:"title.function"},label:"func.def",contains:[R],illegal:/%/},H={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"};function Z($){return t.concat("(?!",$.join("|"),")")}const B={match:t.concat(/\b/,Z([...GT,"super","import","await"].map($=>`${$}\\s*\\(`)),r,t.lookahead(/\s*\(/)),className:"title.function",relevance:0},J={begin:t.concat(/\./,t.lookahead(t.concat(r,/(?![0-9A-Za-z$_(])/))),end:r,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},V={match:[/get|set/,/\s+/,r,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},R]},ee="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+e.UNDERSCORE_IDENT_RE+")\\s*=>",F={match:[/const|var|let/,/\s+/,r,/\s*/,/=\s*/,/(async\s*)?/,t.lookahead(ee)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[R]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:c,exports:{PARAMS_CONTAINS:A,CLASS_REFERENCE:M},illegal:/#(?![$_A-Za-z])/,contains:[e.SHEBANG({label:"shebang",binary:"node",relevance:5}),I,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,y,w,v,_,N,{match:/\$\d+/},m,M,{scope:"attr",match:r+t.lookahead(":"),relevance:0},F,{begin:"("+e.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",relevance:0,contains:[N,e.REGEXP_MODE,{className:"function",begin:ee,returnBegin:!0,end:"\\s*=>",contains:[{className:"params",variants:[{begin:e.UNDERSCORE_IDENT_RE,relevance:0},{className:null,begin:/\(\s*\)/,skip:!0},{begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:c,contains:A}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:o.begin,end:o.end},{match:s},{begin:a.begin,"on:begin":a.isTrulyOpeningTag,end:a.end}],subLanguage:"xml",contains:[{begin:a.begin,end:a.end,skip:!0,contains:["self"]}]}]},D,{beginKeywords:"while if switch catch for"},{begin:"\\b(?!function)"+e.UNDERSCORE_IDENT_RE+"\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",returnBegin:!0,label:"func.def",contains:[R,e.inherit(e.TITLE_MODE,{begin:r,className:"title.function"})]},{match:/\.\.\./,relevance:0},J,{match:"\\$"+r,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[R]},B,H,C,V,{match:/\$[(.]/}]}}function NU(e){const t=e.regex,n=_U(e),r=wh,o=["any","void","number","boolean","string","object","never","symbol","bigint","unknown"],s={begin:[/namespace/,/\s+/,e.IDENT_RE],beginScope:{1:"keyword",3:"title.class"}},a={beginKeywords:"interface",end:/\{/,excludeEnd:!0,keywords:{keyword:"interface extends",built_in:o},contains:[n.exports.CLASS_REFERENCE]},c={className:"meta",relevance:10,begin:/^\s*['"]use strict['"]/},u=["type","interface","public","private","protected","implements","declare","abstract","readonly","enum","override","satisfies"],f={$pattern:wh,keyword:WT.concat(u),literal:KT,built_in:YT.concat(o),"variable.language":VT},h={className:"meta",begin:"@"+r},m=(v,_,x)=>{const N=v.contains.findIndex(T=>T.label===_);if(N===-1)throw new Error("can not find mode to replace");v.contains.splice(N,1,x)};Object.assign(n.keywords,f),n.exports.PARAMS_CONTAINS.push(h);const g=n.contains.find(v=>v.scope==="attr"),y=Object.assign({},g,{match:t.concat(r,t.lookahead(/\s*\?:/))});n.exports.PARAMS_CONTAINS.push([n.exports.CLASS_REFERENCE,g,y]),n.contains=n.contains.concat([h,s,a,y]),m(n,"shebang",e.SHEBANG()),m(n,"use_strict",c);const w=n.contains.find(v=>v.label==="func.def");return w.relevance=0,Object.assign(n,{name:"TypeScript",aliases:["ts","tsx","mts","cts"]}),n}function jU(e){const t=e.regex,n=t.concat(/[\p{L}_]/u,t.optional(/[\p{L}0-9_.-]*:/u),/[\p{L}0-9_.-]*/u),r=/[\p{L}0-9._:-]+/u,o={className:"symbol",begin:/&[a-z]+;|&#[0-9]+;|&#x[a-f0-9]+;/},s={begin:/\s/,contains:[{className:"keyword",begin:/#?[a-z_][a-z1-9_-]+/,illegal:/\n/}]},a=e.inherit(s,{begin:/\(/,end:/\)/}),c=e.inherit(e.APOS_STRING_MODE,{className:"string"}),u=e.inherit(e.QUOTE_STRING_MODE,{className:"string"}),f={endsWithParent:!0,illegal:/</,relevance:0,contains:[{className:"attr",begin:r,relevance:0},{begin:/=\s*/,relevance:0,contains:[{className:"string",endsParent:!0,variants:[{begin:/"/,end:/"/,contains:[o]},{begin:/'/,end:/'/,contains:[o]},{begin:/[^\s"'=<>`]+/}]}]}]};return{name:"HTML, XML",aliases:["html","xhtml","rss","atom","xjb","xsd","xsl","plist","wsf","svg"],case_insensitive:!0,unicodeRegex:!0,contains:[{className:"meta",begin:/<![a-z]/,end:/>/,relevance:10,contains:[s,u,c,a,{begin:/\[/,end:/\]/,contains:[{className:"meta",begin:/<![a-z]/,end:/>/,contains:[s,a,u,c]}]}]},e.COMMENT(/<!--/,/-->/,{relevance:10}),{begin:/<!\[CDATA\[/,end:/\]\]>/,relevance:10},o,{className:"meta",end:/\?>/,variants:[{begin:/<\?xml/,relevance:10,contains:[u]},{begin:/<\?[a-z][a-z0-9]+/}]},{className:"tag",begin:/<style(?=\s|>)/,end:/>/,keywords:{name:"style"},contains:[f],starts:{end:/<\/style>/,returnEnd:!0,subLanguage:"css"}},{className:"tag",begin:/<script(?=\s|>)/,end:/>/,keywords:{name:"script"},contains:[f],starts:{end:/<\/script>/,returnEnd:!0,subLanguage:"javascript"}},{className:"tag",begin:/<>|<\/>/},{className:"tag",begin:t.concat(/</,t.lookahead(t.concat(n,t.either(/\/>/,/>/,/\s/)))),end:/\/?>/,contains:[{className:"name",begin:n,relevance:0,starts:f}]},{className:"tag",begin:t.concat(/<\//,t.lookahead(t.concat(n,/>/))),contains:[{className:"name",begin:n,relevance:0},{begin:/>/,relevance:0,endsParent:!0}]}]}}function TU(e){const t="true false yes no null",n="[\\w#;/?:@&=+$,.~*'()[\\]]+",r={className:"attr",variants:[{begin:/[\w*@][\w*@ :()\./-]*:(?=[ \t]|$)/},{begin:/"[\w*@][\w*@ :()\./-]*":(?=[ \t]|$)/},{begin:/'[\w*@][\w*@ :()\./-]*':(?=[ \t]|$)/}]},o={className:"template-variable",variants:[{begin:/\{\{/,end:/\}\}/},{begin:/%\{/,end:/\}/}]},s={className:"string",relevance:0,begin:/'/,end:/'/,contains:[{match:/''/,scope:"char.escape",relevance:0}]},a={className:"string",relevance:0,variants:[{begin:/"/,end:/"/},{begin:/\S+/}],contains:[e.BACKSLASH_ESCAPE,o]},c=e.inherit(a,{variants:[{begin:/'/,end:/'/,contains:[{begin:/''/,relevance:0}]},{begin:/"/,end:/"/},{begin:/[^\s,{}[\]]+/}]}),g={className:"number",begin:"\\b"+"[0-9]{4}(-[0-9][0-9]){0,2}"+"([Tt \\t][0-9][0-9]?(:[0-9][0-9]){2})?"+"(\\.[0-9]*)?"+"([ \\t])*(Z|[-+][0-9][0-9]?(:[0-9][0-9])?)?"+"\\b"},y={end:",",endsWithParent:!0,excludeEnd:!0,keywords:t,relevance:0},w={begin:/\{/,end:/\}/,contains:[y],illegal:"\\n",relevance:0},v={begin:"\\[",end:"\\]",contains:[y],illegal:"\\n",relevance:0},_=[r,{className:"meta",begin:"^---\\s*$",relevance:10},{className:"string",begin:"[\\|>]([1-9]?[+-])?[ ]*\\n( +)[^ ][^\\n]*\\n(\\2[^\\n]+\\n?)*"},{begin:"<%[%=-]?",end:"[%-]?%>",subLanguage:"ruby",excludeBegin:!0,excludeEnd:!0,relevance:0},{className:"type",begin:"!\\w+!"+n},{className:"type",begin:"!<"+n+">"},{className:"type",begin:"!"+n},{className:"type",begin:"!!"+n},{className:"meta",begin:"&"+e.UNDERSCORE_IDENT_RE+"$"},{className:"meta",begin:"\\*"+e.UNDERSCORE_IDENT_RE+"$"},{className:"bullet",begin:"-(?=[ ]|$)",relevance:0},e.HASH_COMMENT_MODE,{beginKeywords:t,keywords:{literal:t}},g,{className:"number",begin:e.C_NUMBER_RE+"\\b",relevance:0},w,v,s,a],x=[..._];return x.pop(),x.push(c),y.contains=x,{name:"YAML",case_insensitive:!0,aliases:["yml"],contains:_}}var $g,D1;function $U(){if(D1)return $g;D1=1;function e(P){return P instanceof Map?P.clear=P.delete=P.set=function(){throw new Error("map is read-only")}:P instanceof Set&&(P.add=P.clear=P.delete=function(){throw new Error("set is read-only")}),Object.freeze(P),Object.getOwnPropertyNames(P).forEach(se=>{const je=P[se],Fe=typeof je;(Fe==="object"||Fe==="function")&&!Object.isFrozen(je)&&e(je)}),P}class t{constructor(se){se.data===void 0&&(se.data={}),this.data=se.data,this.isMatchIgnored=!1}ignoreMatch(){this.isMatchIgnored=!0}}function n(P){return P.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#x27;")}function r(P,...se){const je=Object.create(null);for(const Fe in P)je[Fe]=P[Fe];return se.forEach(function(Fe){for(const Rt in Fe)je[Rt]=Fe[Rt]}),je}const o="</span>",s=P=>!!P.scope,a=(P,{prefix:se})=>{if(P.startsWith("language:"))return P.replace("language:","language-");if(P.includes(".")){const je=P.split(".");return[`${se}${je.shift()}`,...je.map((Fe,Rt)=>`${Fe}${"_".repeat(Rt+1)}`)].join(" ")}return`${se}${P}`};class c{constructor(se,je){this.buffer="",this.classPrefix=je.classPrefix,se.walk(this)}addText(se){this.buffer+=n(se)}openNode(se){if(!s(se))return;const je=a(se.scope,{prefix:this.classPrefix});this.span(je)}closeNode(se){s(se)&&(this.buffer+=o)}value(){return this.buffer}span(se){this.buffer+=`<span class="${se}">`}}const u=(P={})=>{const se={children:[]};return Object.assign(se,P),se};class f{constructor(){this.rootNode=u(),this.stack=[this.rootNode]}get top(){return this.stack[this.stack.length-1]}get root(){return this.rootNode}add(se){this.top.children.push(se)}openNode(se){const je=u({scope:se});this.add(je),this.stack.push(je)}closeNode(){if(this.stack.length>1)return this.stack.pop()}closeAllNodes(){for(;this.closeNode(););}toJSON(){return JSON.stringify(this.rootNode,null,4)}walk(se){return this.constructor._walk(se,this.rootNode)}static _walk(se,je){return typeof je=="string"?se.addText(je):je.children&&(se.openNode(je),je.children.forEach(Fe=>this._walk(se,Fe)),se.closeNode(je)),se}static _collapse(se){typeof se!="string"&&se.children&&(se.children.every(je=>typeof je=="string")?se.children=[se.children.join("")]:se.children.forEach(je=>{f._collapse(je)}))}}class h extends f{constructor(se){super(),this.options=se}addText(se){se!==""&&this.add(se)}startScope(se){this.openNode(se)}endScope(){this.closeNode()}__addSublanguage(se,je){const Fe=se.root;je&&(Fe.scope=`language:${je}`),this.add(Fe)}toHTML(){return new c(this,this.options).value()}finalize(){return this.closeAllNodes(),!0}}function m(P){return P?typeof P=="string"?P:P.source:null}function g(P){return v("(?=",P,")")}function y(P){return v("(?:",P,")*")}function w(P){return v("(?:",P,")?")}function v(...P){return P.map(je=>m(je)).join("")}function _(P){const se=P[P.length-1];return typeof se=="object"&&se.constructor===Object?(P.splice(P.length-1,1),se):{}}function x(...P){return"("+(_(P).capture?"":"?:")+P.map(Fe=>m(Fe)).join("|")+")"}function N(P){return new RegExp(P.toString()+"|").exec("").length-1}function T(P,se){const je=P&&P.exec(se);return je&&je.index===0}const j=/\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)|\\./;function A(P,{joinWith:se}){let je=0;return P.map(Fe=>{je+=1;const Rt=je;let Zt=m(Fe),Ae="";for(;Zt.length>0;){const We=j.exec(Zt);if(!We){Ae+=Zt;break}Ae+=Zt.substring(0,We.index),Zt=Zt.substring(We.index+We[0].length),We[0][0]==="\\"&&We[1]?Ae+="\\"+String(Number(We[1])+Rt):(Ae+=We[0],We[0]==="("&&je++)}return Ae}).map(Fe=>`(${Fe})`).join(se)}const R=/\b\B/,C="[a-zA-Z]\\w*",M="[a-zA-Z_]\\w*",I="\\b\\d+(\\.\\d+)?",D="(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)",H="\\b(0b[01]+)",Z="!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~",B=(P={})=>{const se=/^#![ ]*\//;return P.binary&&(P.begin=v(se,/.*\b/,P.binary,/\b.*/)),r({scope:"meta",begin:se,end:/$/,relevance:0,"on:begin":(je,Fe)=>{je.index!==0&&Fe.ignoreMatch()}},P)},J={begin:"\\\\[\\s\\S]",relevance:0},V={scope:"string",begin:"'",end:"'",illegal:"\\n",contains:[J]},ee={scope:"string",begin:'"',end:'"',illegal:"\\n",contains:[J]},F={begin:/\b(a|an|the|are|I'm|isn't|don't|doesn't|won't|but|just|should|pretty|simply|enough|gonna|going|wtf|so|such|will|you|your|they|like|more)\b/},$=function(P,se,je={}){const Fe=r({scope:"comment",begin:P,end:se,contains:[]},je);Fe.contains.push({scope:"doctag",begin:"[ ]*(?=(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):)",end:/(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):/,excludeBegin:!0,relevance:0});const Rt=x("I","a","is","so","us","to","at","if","in","it","on",/[A-Za-z]+['](d|ve|re|ll|t|s|n)/,/[A-Za-z]+[-][a-z]+/,/[A-Za-z][a-z]{2,}/);return Fe.contains.push({begin:v(/[ ]+/,"(",Rt,/[.]?[:]?([.][ ]|[ ])/,"){3}")}),Fe},Q=$("//","$"),q=$("/\\*","\\*/"),W=$("#","$"),oe={scope:"number",begin:I,relevance:0},de={scope:"number",begin:D,relevance:0},he={scope:"number",begin:H,relevance:0},Ne={scope:"regexp",begin:/\/(?=[^/\n]*\/)/,end:/\/[gimuy]*/,contains:[J,{begin:/\[/,end:/\]/,relevance:0,contains:[J]}]},Me={scope:"title",begin:C,relevance:0},Be={scope:"title",begin:M,relevance:0},K={begin:"\\.\\s*"+M,relevance:0};var pe=Object.freeze({__proto__:null,APOS_STRING_MODE:V,BACKSLASH_ESCAPE:J,BINARY_NUMBER_MODE:he,BINARY_NUMBER_RE:H,COMMENT:$,C_BLOCK_COMMENT_MODE:q,C_LINE_COMMENT_MODE:Q,C_NUMBER_MODE:de,C_NUMBER_RE:D,END_SAME_AS_BEGIN:function(P){return Object.assign(P,{"on:begin":(se,je)=>{je.data._beginMatch=se[1]},"on:end":(se,je)=>{je.data._beginMatch!==se[1]&&je.ignoreMatch()}})},HASH_COMMENT_MODE:W,IDENT_RE:C,MATCH_NOTHING_RE:R,METHOD_GUARD:K,NUMBER_MODE:oe,NUMBER_RE:I,PHRASAL_WORDS_MODE:F,QUOTE_STRING_MODE:ee,REGEXP_MODE:Ne,RE_STARTERS_RE:Z,SHEBANG:B,TITLE_MODE:Me,UNDERSCORE_IDENT_RE:M,UNDERSCORE_TITLE_MODE:Be});function ue(P,se){P.input[P.index-1]==="."&&se.ignoreMatch()}function ie(P,se){P.className!==void 0&&(P.scope=P.className,delete P.className)}function ye(P,se){se&&P.beginKeywords&&(P.begin="\\b("+P.beginKeywords.split(" ").join("|")+")(?!\\.)(?=\\b|\\s)",P.__beforeBegin=ue,P.keywords=P.keywords||P.beginKeywords,delete P.beginKeywords,P.relevance===void 0&&(P.relevance=0))}function Se(P,se){Array.isArray(P.illegal)&&(P.illegal=x(...P.illegal))}function Ee(P,se){if(P.match){if(P.begin||P.end)throw new Error("begin & end are not supported with match");P.begin=P.match,delete P.match}}function Le(P,se){P.relevance===void 0&&(P.relevance=1)}const Ue=(P,se)=>{if(!P.beforeMatch)return;if(P.starts)throw new Error("beforeMatch cannot be used with starts");const je=Object.assign({},P);Object.keys(P).forEach(Fe=>{delete P[Fe]}),P.keywords=je.keywords,P.begin=v(je.beforeMatch,g(je.begin)),P.starts={relevance:0,contains:[Object.assign(je,{endsParent:!0})]},P.relevance=0,delete je.beforeMatch},Je=["of","and","for","in","not","or","if","then","parent","list","value"],Ht="keyword";function qt(P,se,je=Ht){const Fe=Object.create(null);return typeof P=="string"?Rt(je,P.split(" ")):Array.isArray(P)?Rt(je,P):Object.keys(P).forEach(function(Zt){Object.assign(Fe,qt(P[Zt],se,Zt))}),Fe;function Rt(Zt,Ae){se&&(Ae=Ae.map(We=>We.toLowerCase())),Ae.forEach(function(We){const Ve=We.split("|");Fe[Ve[0]]=[Zt,xt(Ve[0],Ve[1])]})}}function xt(P,se){return se?Number(se):Ze(P)?0:1}function Ze(P){return Je.includes(P.toLowerCase())}const _t={},mt=P=>{console.error(P)},De=(P,...se)=>{console.log(`WARN: ${P}`,...se)},nt=(P,se)=>{_t[`${P}/${se}`]||(console.log(`Deprecated as of ${P}. ${se}`),_t[`${P}/${se}`]=!0)},lt=new Error;function Yt(P,se,{key:je}){let Fe=0;const Rt=P[je],Zt={},Ae={};for(let We=1;We<=se.length;We++)Ae[We+Fe]=Rt[We],Zt[We+Fe]=!0,Fe+=N(se[We-1]);P[je]=Ae,P[je]._emit=Zt,P[je]._multi=!0}function $n(P){if(Array.isArray(P.begin)){if(P.skip||P.excludeBegin||P.returnBegin)throw mt("skip, excludeBegin, returnBegin not compatible with beginScope: {}"),lt;if(typeof P.beginScope!="object"||P.beginScope===null)throw mt("beginScope must be object"),lt;Yt(P,P.begin,{key:"beginScope"}),P.begin=A(P.begin,{joinWith:""})}}function gt(P){if(Array.isArray(P.end)){if(P.skip||P.excludeEnd||P.returnEnd)throw mt("skip, excludeEnd, returnEnd not compatible with endScope: {}"),lt;if(typeof P.endScope!="object"||P.endScope===null)throw mt("endScope must be object"),lt;Yt(P,P.end,{key:"endScope"}),P.end=A(P.end,{joinWith:""})}}function rt(P){P.scope&&typeof P.scope=="object"&&P.scope!==null&&(P.beginScope=P.scope,delete P.scope)}function Kn(P){rt(P),typeof P.beginScope=="string"&&(P.beginScope={_wrap:P.beginScope}),typeof P.endScope=="string"&&(P.endScope={_wrap:P.endScope}),$n(P),gt(P)}function Qt(P){function se(Ae,We){return new RegExp(m(Ae),"m"+(P.case_insensitive?"i":"")+(P.unicodeRegex?"u":"")+(We?"g":""))}class je{constructor(){this.matchIndexes={},this.regexes=[],this.matchAt=1,this.position=0}addRule(We,Ve){Ve.position=this.position++,this.matchIndexes[this.matchAt]=Ve,this.regexes.push([Ve,We]),this.matchAt+=N(We)+1}compile(){this.regexes.length===0&&(this.exec=()=>null);const We=this.regexes.map(Ve=>Ve[1]);this.matcherRe=se(A(We,{joinWith:"|"}),!0),this.lastIndex=0}exec(We){this.matcherRe.lastIndex=this.lastIndex;const Ve=this.matcherRe.exec(We);if(!Ve)return null;const Xt=Ve.findIndex((bn,xn)=>xn>0&&bn!==void 0),Wt=this.matchIndexes[Xt];return Ve.splice(0,Xt),Object.assign(Ve,Wt)}}class Fe{constructor(){this.rules=[],this.multiRegexes=[],this.count=0,this.lastIndex=0,this.regexIndex=0}getMatcher(We){if(this.multiRegexes[We])return this.multiRegexes[We];const Ve=new je;return this.rules.slice(We).forEach(([Xt,Wt])=>Ve.addRule(Xt,Wt)),Ve.compile(),this.multiRegexes[We]=Ve,Ve}resumingScanAtSamePosition(){return this.regexIndex!==0}considerAll(){this.regexIndex=0}addRule(We,Ve){this.rules.push([We,Ve]),Ve.type==="begin"&&this.count++}exec(We){const Ve=this.getMatcher(this.regexIndex);Ve.lastIndex=this.lastIndex;let Xt=Ve.exec(We);if(this.resumingScanAtSamePosition()&&!(Xt&&Xt.index===this.lastIndex)){const Wt=this.getMatcher(0);Wt.lastIndex=this.lastIndex+1,Xt=Wt.exec(We)}return Xt&&(this.regexIndex+=Xt.position+1,this.regexIndex===this.count&&this.considerAll()),Xt}}function Rt(Ae){const We=new Fe;return Ae.contains.forEach(Ve=>We.addRule(Ve.begin,{rule:Ve,type:"begin"})),Ae.terminatorEnd&&We.addRule(Ae.terminatorEnd,{type:"end"}),Ae.illegal&&We.addRule(Ae.illegal,{type:"illegal"}),We}function Zt(Ae,We){const Ve=Ae;if(Ae.isCompiled)return Ve;[ie,Ee,Kn,Ue].forEach(Wt=>Wt(Ae,We)),P.compilerExtensions.forEach(Wt=>Wt(Ae,We)),Ae.__beforeBegin=null,[ye,Se,Le].forEach(Wt=>Wt(Ae,We)),Ae.isCompiled=!0;let Xt=null;return typeof Ae.keywords=="object"&&Ae.keywords.$pattern&&(Ae.keywords=Object.assign({},Ae.keywords),Xt=Ae.keywords.$pattern,delete Ae.keywords.$pattern),Xt=Xt||/\w+/,Ae.keywords&&(Ae.keywords=qt(Ae.keywords,P.case_insensitive)),Ve.keywordPatternRe=se(Xt,!0),We&&(Ae.begin||(Ae.begin=/\B|\b/),Ve.beginRe=se(Ve.begin),!Ae.end&&!Ae.endsWithParent&&(Ae.end=/\B|\b/),Ae.end&&(Ve.endRe=se(Ve.end)),Ve.terminatorEnd=m(Ve.end)||"",Ae.endsWithParent&&We.terminatorEnd&&(Ve.terminatorEnd+=(Ae.end?"|":"")+We.terminatorEnd)),Ae.illegal&&(Ve.illegalRe=se(Ae.illegal)),Ae.contains||(Ae.contains=[]),Ae.contains=[].concat(...Ae.contains.map(function(Wt){return qn(Wt==="self"?Ae:Wt)})),Ae.contains.forEach(function(Wt){Zt(Wt,Ve)}),Ae.starts&&Zt(Ae.starts,We),Ve.matcher=Rt(Ve),Ve}if(P.compilerExtensions||(P.compilerExtensions=[]),P.contains&&P.contains.includes("self"))throw new Error("ERR: contains `self` is not supported at the top-level of a language. See documentation.");return P.classNameAliases=r(P.classNameAliases||{}),Zt(P)}function Cn(P){return P?P.endsWithParent||Cn(P.starts):!1}function qn(P){return P.variants&&!P.cachedVariants&&(P.cachedVariants=P.variants.map(function(se){return r(P,{variants:null},se)})),P.cachedVariants?P.cachedVariants:Cn(P)?r(P,{starts:P.starts?r(P.starts):null}):Object.isFrozen(P)?r(P):P}var dn="11.11.2";class yn extends Error{constructor(se,je){super(se),this.name="HTMLInjectionError",this.html=je}}const ne=n,we=r,qe=Symbol("nomatch"),ot=7,Tt=function(P){const se=Object.create(null),je=Object.create(null),Fe=[];let Rt=!0;const Zt="Could not find the language '{}', did you forget to load/include a language module?",Ae={disableAutodetect:!0,name:"Plain text",contains:[]};let We={ignoreUnescapedHTML:!1,throwUnescapedHTML:!1,noHighlightRe:/^(no-?highlight)$/i,languageDetectRe:/\blang(?:uage)?-([\w-]+)\b/i,classPrefix:"hljs-",cssSelector:"pre code",languages:null,__emitter:h};function Ve(be){return We.noHighlightRe.test(be)}function Xt(be){let Ye=be.className+" ";Ye+=be.parentNode?be.parentNode.className:"";const wt=We.languageDetectRe.exec(Ye);if(wt){const yt=kn(wt[1]);return yt||(De(Zt.replace("{}",wt[1])),De("Falling back to no-highlight mode for this block.",be)),yt?wt[1]:"no-highlight"}return Ye.split(/\s+/).find(yt=>Ve(yt)||kn(yt))}function Wt(be,Ye,wt){let yt="",cn="";typeof Ye=="object"?(yt=be,wt=Ye.ignoreIllegals,cn=Ye.language):(nt("10.7.0","highlight(lang, code, ...args) has been deprecated."),nt("10.7.0",`Please use highlight(code, options) instead.
209
- https://github.com/highlightjs/highlight.js/issues/2277`),cn=be,yt=Ye),wt===void 0&&(wt=!0);const hn={code:yt,language:cn};Bt("before:highlight",hn);const wr=hn.result?hn.result:bn(hn.language,hn.code,wt);return wr.code=hn.code,Bt("after:highlight",wr),wr}function bn(be,Ye,wt,yt){const cn=Object.create(null);function hn(G,ce){return G.keywords[ce]}function wr(){if(!vt.keywords){Fn.addText(on);return}let G=0;vt.keywordPatternRe.lastIndex=0;let ce=vt.keywordPatternRe.exec(on),ve="";for(;ce;){ve+=on.substring(G,ce.index);const Pe=ir.case_insensitive?ce[0].toLowerCase():ce[0],Te=hn(vt,Pe);if(Te){const[$t,sn]=Te;if(Fn.addText(ve),ve="",cn[Pe]=(cn[Pe]||0)+1,cn[Pe]<=ot&&(Ar+=sn),$t.startsWith("_"))ve+=ce[0];else{const nr=ir.classNameAliases[$t]||$t;pn(ce[0],nr)}}else ve+=ce[0];G=vt.keywordPatternRe.lastIndex,ce=vt.keywordPatternRe.exec(on)}ve+=on.substring(G),Fn.addText(ve)}function Zn(){if(on==="")return;let G=null;if(typeof vt.subLanguage=="string"){if(!se[vt.subLanguage]){Fn.addText(on);return}G=bn(vt.subLanguage,on,!0,ko[vt.subLanguage]),ko[vt.subLanguage]=G._top}else G=Ct(on,vt.subLanguage.length?vt.subLanguage:null);vt.relevance>0&&(Ar+=G.relevance),Fn.__addSublanguage(G._emitter,G.language)}function Ut(){vt.subLanguage!=null?Zn():wr(),on=""}function pn(G,ce){G!==""&&(Fn.startScope(ce),Fn.addText(G),Fn.endScope())}function yr(G,ce){let ve=1;const Pe=ce.length-1;for(;ve<=Pe;){if(!G._emit[ve]){ve++;continue}const Te=ir.classNameAliases[G[ve]]||G[ve],$t=ce[ve];Te?pn($t,Te):(on=$t,wr(),on=""),ve++}}function X(G,ce){return G.scope&&typeof G.scope=="string"&&Fn.openNode(ir.classNameAliases[G.scope]||G.scope),G.beginScope&&(G.beginScope._wrap?(pn(on,ir.classNameAliases[G.beginScope._wrap]||G.beginScope._wrap),on=""):G.beginScope._multi&&(yr(G.beginScope,ce),on="")),vt=Object.create(G,{parent:{value:vt}}),vt}function ge(G,ce,ve){let Pe=T(G.endRe,ve);if(Pe){if(G["on:end"]){const Te=new t(G);G["on:end"](ce,Te),Te.isMatchIgnored&&(Pe=!1)}if(Pe){for(;G.endsParent&&G.parent;)G=G.parent;return G}}if(G.endsWithParent)return ge(G.parent,ce,ve)}function Ge(G){return vt.matcher.regexIndex===0?(on+=G[0],1):(U=!0,0)}function Vt(G){const ce=G[0],ve=G.rule,Pe=new t(ve),Te=[ve.__beforeBegin,ve["on:begin"]];for(const $t of Te)if($t&&($t(G,Pe),Pe.isMatchIgnored))return Ge(ce);return ve.skip?on+=ce:(ve.excludeBegin&&(on+=ce),Ut(),!ve.returnBegin&&!ve.excludeBegin&&(on=ce)),X(ve,G),ve.returnBegin?0:ce.length}function Mt(G){const ce=G[0],ve=Ye.substring(G.index),Pe=ge(vt,G,ve);if(!Pe)return qe;const Te=vt;vt.endScope&&vt.endScope._wrap?(Ut(),pn(ce,vt.endScope._wrap)):vt.endScope&&vt.endScope._multi?(Ut(),yr(vt.endScope,G)):Te.skip?on+=ce:(Te.returnEnd||Te.excludeEnd||(on+=ce),Ut(),Te.excludeEnd&&(on=ce));do vt.scope&&Fn.closeNode(),!vt.skip&&!vt.subLanguage&&(Ar+=vt.relevance),vt=vt.parent;while(vt!==Pe.parent);return Pe.starts&&X(Pe.starts,G),Te.returnEnd?0:ce.length}function On(){const G=[];for(let ce=vt;ce!==ir;ce=ce.parent)ce.scope&&G.unshift(ce.scope);G.forEach(ce=>Fn.openNode(ce))}let Sn={};function zn(G,ce){const ve=ce&&ce[0];if(on+=G,ve==null)return Ut(),0;if(Sn.type==="begin"&&ce.type==="end"&&Sn.index===ce.index&&ve===""){if(on+=Ye.slice(ce.index,ce.index+1),!Rt){const Pe=new Error(`0 width match regex (${be})`);throw Pe.languageName=be,Pe.badRule=Sn.rule,Pe}return 1}if(Sn=ce,ce.type==="begin")return Vt(ce);if(ce.type==="illegal"&&!wt){const Pe=new Error('Illegal lexeme "'+ve+'" for mode "'+(vt.scope||"<unnamed>")+'"');throw Pe.mode=vt,Pe}else if(ce.type==="end"){const Pe=Mt(ce);if(Pe!==qe)return Pe}if(ce.type==="illegal"&&ve==="")return ce.index===Ye.length||(on+=`
210
- `),1;if(Ie>1e5&&Ie>ce.index*3)throw new Error("potential infinite loop, way more iterations than matches");return on+=ve,ve.length}const ir=kn(be);if(!ir)throw mt(Zt.replace("{}",be)),new Error('Unknown language: "'+be+'"');const go=Qt(ir);let rn="",vt=yt||go;const ko={},Fn=new We.__emitter(We);On();let on="",Ar=0,dr=0,Ie=0,U=!1;try{if(ir.__emitTokens)ir.__emitTokens(Ye,Fn);else{for(vt.matcher.considerAll();;){Ie++,U?U=!1:vt.matcher.considerAll(),vt.matcher.lastIndex=dr;const G=vt.matcher.exec(Ye);if(!G)break;const ce=Ye.substring(dr,G.index),ve=zn(ce,G);dr=G.index+ve}zn(Ye.substring(dr))}return Fn.finalize(),rn=Fn.toHTML(),{language:be,value:rn,relevance:Ar,illegal:!1,_emitter:Fn,_top:vt}}catch(G){if(G.message&&G.message.includes("Illegal"))return{language:be,value:ne(Ye),illegal:!0,relevance:0,_illegalBy:{message:G.message,index:dr,context:Ye.slice(dr-100,dr+100),mode:G.mode,resultSoFar:rn},_emitter:Fn};if(Rt)return{language:be,value:ne(Ye),illegal:!1,relevance:0,errorRaised:G,_emitter:Fn,_top:vt};throw G}}function xn(be){const Ye={value:ne(be),illegal:!1,relevance:0,_top:Ae,_emitter:new We.__emitter(We)};return Ye._emitter.addText(be),Ye}function Ct(be,Ye){Ye=Ye||We.languages||Object.keys(se);const wt=xn(be),yt=Ye.filter(kn).filter(cr).map(Ut=>bn(Ut,be,!1));yt.unshift(wt);const cn=yt.sort((Ut,pn)=>{if(Ut.relevance!==pn.relevance)return pn.relevance-Ut.relevance;if(Ut.language&&pn.language){if(kn(Ut.language).supersetOf===pn.language)return 1;if(kn(pn.language).supersetOf===Ut.language)return-1}return 0}),[hn,wr]=cn,Zn=hn;return Zn.secondBest=wr,Zn}function Jt(be,Ye,wt){const yt=Ye&&je[Ye]||wt;be.classList.add("hljs"),be.classList.add(`language-${yt}`)}function sr(be){let Ye=null;const wt=Xt(be);if(Ve(wt))return;if(Bt("before:highlightElement",{el:be,language:wt}),be.dataset.highlighted){console.log("Element previously highlighted. To highlight again, first unset `dataset.highlighted`.",be);return}if(be.children.length>0&&(We.ignoreUnescapedHTML||(console.warn("One of your code blocks includes unescaped HTML. This is a potentially serious security risk."),console.warn("https://github.com/highlightjs/highlight.js/wiki/security"),console.warn("The element with unescaped HTML:"),console.warn(be)),We.throwUnescapedHTML))throw new yn("One of your code blocks includes unescaped HTML.",be.innerHTML);Ye=be;const yt=Ye.textContent,cn=wt?Wt(yt,{language:wt,ignoreIllegals:!0}):Ct(yt);be.innerHTML=cn.value,be.dataset.highlighted="yes",Jt(be,wt,cn.language),be.result={language:cn.language,re:cn.relevance,relevance:cn.relevance},cn.secondBest&&(be.secondBest={language:cn.secondBest.language,relevance:cn.secondBest.relevance}),Bt("after:highlightElement",{el:be,result:cn,text:yt})}function Gt(be){We=we(We,be)}const Rn=()=>{_e(),nt("10.6.0","initHighlighting() deprecated. Use highlightAll() now.")};function fn(){_e(),nt("10.6.0","initHighlightingOnLoad() deprecated. Use highlightAll() now.")}let ae=!1;function _e(){function be(){_e()}if(document.readyState==="loading"){ae||window.addEventListener("DOMContentLoaded",be,!1),ae=!0;return}document.querySelectorAll(We.cssSelector).forEach(sr)}function ht(be,Ye){let wt=null;try{wt=Ye(P)}catch(yt){if(mt("Language definition for '{}' could not be registered.".replace("{}",be)),Rt)mt(yt);else throw yt;wt=Ae}wt.name||(wt.name=be),se[be]=wt,wt.rawDefinition=Ye.bind(null,P),wt.aliases&&Pr(wt.aliases,{languageName:be})}function ct(be){delete se[be];for(const Ye of Object.keys(je))je[Ye]===be&&delete je[Ye]}function zt(){return Object.keys(se)}function kn(be){return be=(be||"").toLowerCase(),se[be]||se[je[be]]}function Pr(be,{languageName:Ye}){typeof be=="string"&&(be=[be]),be.forEach(wt=>{je[wt.toLowerCase()]=Ye})}function cr(be){const Ye=kn(be);return Ye&&!Ye.disableAutodetect}function ln(be){be["before:highlightBlock"]&&!be["before:highlightElement"]&&(be["before:highlightElement"]=Ye=>{be["before:highlightBlock"](Object.assign({block:Ye.el},Ye))}),be["after:highlightBlock"]&&!be["after:highlightElement"]&&(be["after:highlightElement"]=Ye=>{be["after:highlightBlock"](Object.assign({block:Ye.el},Ye))})}function ur(be){ln(be),Fe.push(be)}function nn(be){const Ye=Fe.indexOf(be);Ye!==-1&&Fe.splice(Ye,1)}function Bt(be,Ye){const wt=be;Fe.forEach(function(yt){yt[wt]&&yt[wt](Ye)})}function Ft(be){return nt("10.7.0","highlightBlock will be removed entirely in v12.0"),nt("10.7.0","Please use highlightElement now."),sr(be)}Object.assign(P,{highlight:Wt,highlightAuto:Ct,highlightAll:_e,highlightElement:sr,highlightBlock:Ft,configure:Gt,initHighlighting:Rn,initHighlightingOnLoad:fn,registerLanguage:ht,unregisterLanguage:ct,listLanguages:zt,getLanguage:kn,registerAliases:Pr,autoDetection:cr,inherit:we,addPlugin:ur,removePlugin:nn}),P.debugMode=function(){Rt=!1},P.safeMode=function(){Rt=!0},P.versionString=dn,P.regex={concat:v,lookahead:g,either:x,optional:w,anyNumberOfTimes:y};for(const be in pe)typeof pe[be]=="object"&&e(pe[be]);return Object.assign(P,pe),P},Dt=Tt({});return Dt.newInstance=()=>Tt({}),$g=Dt,Dt.HighlightJS=Dt,Dt.default=Dt,$g}var CU=$U();const IU=QE(CU),z1={},AU="hljs-";function RU(e){const t=IU.newInstance();return e&&s(e),{highlight:n,highlightAuto:r,listLanguages:o,register:s,registerAlias:a,registered:c};function n(u,f,h){const m=h||z1,g=typeof m.prefix=="string"?m.prefix:AU;if(!t.getLanguage(u))throw new Error("Unknown language: `"+u+"` is not registered");t.configure({__emitter:OU,classPrefix:g});const y=t.highlight(f,{ignoreIllegals:!0,language:u});if(y.errorRaised)throw new Error("Could not highlight with `Highlight.js`",{cause:y.errorRaised});const w=y._emitter.root,v=w.data;return v.language=y.language,v.relevance=y.relevance,w}function r(u,f){const m=(f||z1).subset||o();let g=-1,y=0,w;for(;++g<m.length;){const v=m[g];if(!t.getLanguage(v))continue;const _=n(v,u,f);_.data&&_.data.relevance!==void 0&&_.data.relevance>y&&(y=_.data.relevance,w=_)}return w||{type:"root",children:[],data:{language:void 0,relevance:y}}}function o(){return t.listLanguages()}function s(u,f){if(typeof u=="string")t.registerLanguage(u,f);else{let h;for(h in u)Object.hasOwn(u,h)&&t.registerLanguage(h,u[h])}}function a(u,f){if(typeof u=="string")t.registerAliases(typeof f=="string"?f:[...f],{languageName:u});else{let h;for(h in u)if(Object.hasOwn(u,h)){const m=u[h];t.registerAliases(typeof m=="string"?m:[...m],{languageName:h})}}}function c(u){return!!t.getLanguage(u)}}class OU{constructor(t){this.options=t,this.root={type:"root",children:[],data:{language:void 0,relevance:0}},this.stack=[this.root]}addText(t){if(t==="")return;const n=this.stack[this.stack.length-1],r=n.children[n.children.length-1];r&&r.type==="text"?r.value+=t:n.children.push({type:"text",value:t})}startScope(t){this.openNode(String(t))}endScope(){this.closeNode()}__addSublanguage(t,n){const r=this.stack[this.stack.length-1],o=t.root.children;n?r.children.push({type:"element",tagName:"span",properties:{className:[n]},children:o}):r.children.push(...o)}openNode(t){const n=this,r=t.split(".").map(function(a,c){return c?a+"_".repeat(c):n.options.classPrefix+a}),o=this.stack[this.stack.length-1],s={type:"element",tagName:"span",properties:{className:r},children:[]};o.children.push(s),this.stack.push(s)}closeNode(){this.stack.pop()}finalize(){}toHTML(){return""}}const XT=RU({bash:nU,css:dU,go:fU,ini:hU,javascript:wU,json:bU,markdown:xU,python:EU,rust:SU,typescript:NU,xml:jU,yaml:TU}),F1={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",html:"xml",htm:"xml",xml:"xml",svg:"xml",vue:"xml",md:"markdown",mdx:"markdown",markdown:"markdown",py:"python",pyi:"python",rs:"rust",go:"go",java:"javascript",kt:"javascript",c:"javascript",h:"javascript",cc:"javascript",cpp:"javascript",hpp:"javascript",cs:"javascript",swift:"javascript",yml:"yaml",yaml:"yaml",toml:"ini",ini:"ini",env:"ini",sh:"bash",bash:"bash",zsh:"bash",fish:"bash"};function vp(e,t){const n=e&&(F1[e]??(XT.registered(e)?e:null));if(n)return n;const r=t.lastIndexOf("."),o=r<0?"":t.slice(r+1).toLowerCase();return(o?F1[o]:null)??null}const MU=/^(?:diff --git a\/\S+ b\/(\S+)|\+\+\+ (?:b\/)?(\S+))$/gm;function LU(e){const t=new Set;for(const n of e.matchAll(MU)){const r=n[1]??n[2]??"";r&&r!=="/dev/null"&&t.add(r)}return t.size===1?[...t][0]:""}const PU={comment:"comment",quote:"comment",doctag:"comment",keyword:"keyword",literal:"keyword",meta:"keyword","meta-keyword":"keyword",operator:"keyword","selector-tag":"keyword",tag:"keyword",string:"string",regexp:"string","meta-string":"string","template-tag":"string",symbol:"string",number:"number",type:"type",built_in:"type",class:"type",class_:"type","selector-class":"type","selector-id":"type",title:"function",function_:"function",function:"function",variable:"variable",language_:"variable",constant_:"variable",attr:"variable",attribute:"variable",property:"variable",params:"variable",name:"variable"};function QT(e,t){const n=[[]],r=(s,a)=>{const c=s.split(`
211
- `);for(const[u,f]of c.entries()){if(u>0&&n.push([]),!f)continue;const h=n[n.length-1],m=h[h.length-1];m&&m.scope===a?m.text+=f:h.push({text:f,scope:a})}},o=(s,a)=>{for(const c of s)c.type==="text"?r(c.value,a):c.type==="element"&&o(c.children,DU(c)??a)};try{o(XT.highlight(t,e).children,"")}catch{return e.split(`
212
- `).map(s=>s?[{text:s,scope:""}]:[])}return n}function DU(e){var r;const t=((r=e.properties)==null?void 0:r.className)??[];let n=null;for(const o of t){const s=PU[o.startsWith("hljs-")?o.slice(5):o];s&&(n=s)}return n}const B1=/^\d+\t/;function bp(e,t){if(!t)return[];const n=e.split(`
213
- `),r=B1.test(n[0]??""),o=r?n.map(a=>{var c;return((c=B1.exec(a))==null?void 0:c[0])??""}):[],s=r?n.map((a,c)=>a.slice(o[c].length)).join(`
214
- `):e;return QT(s,t).map((a,c)=>{const u=a.map(h=>({text:h.text,changed:!1,scope:h.scope})),f=o[c];return f?[{text:f,changed:!1,scope:""},...u]:u})}function zU(e,t){var r;const n=new Array(e.length);if(t){let o=0;for(let s=0;s<=e.length;s++){const a=(r=e[s])==null?void 0:r.kind;s<e.length&&a!=="hunk"&&a!=="meta"||(FU(e,o,s,t,n),o=s+1)}}return e.map((o,s)=>HU(o.spans,n[s],o.text))}function FU(e,t,n,r,o){var s,a;for(const c of["del","add"]){const u=[];for(let m=t;m<n;m++){const g=(s=e[m])==null?void 0:s.kind;(g===""||g===c)&&u.push(m)}if(u.length===0)continue;const f=u.map(m=>{var g;return((g=e[m])==null?void 0:g.text)??""}).join(`
215
- `),h=QT(f,r);for(const[m,g]of u.entries())(c==="add"||((a=e[g])==null?void 0:a.kind)==="del")&&(o[g]=h[m])}}const xp="link",BU=/https?:\/\/[^\s<>"'`]+/g,JT=/https?:\/\//;function e$(e){const t=[];for(const n of e.matchAll(BU)){const r=n.index+UU(n[0]).length;r>n.index&&t.push({start:n.index,end:r})}return t}const U1={")":"(","]":"[","}":"{"};function UU(e){let t=e.length;for(;t>0;){const n=e[t-1];if(".,;:!?".includes(n))t--;else if(U1[n]&&H1(e.slice(0,t),U1[n])<H1(e.slice(0,t),n))t--;else break}return e.slice(0,t)}function H1(e,t){let n=0;for(const r of e)r===t&&n++;return n}function t$(e){const t=e.map(c=>c.text).join("");if(!JT.test(t))return e;const n=e$(t);if(!n.length)return e;const r=[];let o=0,s=0,a=null;for(const c of e){let u=0;for(;u<c.text.length;){const f=n[s],h=o+u;if(f&&h>=f.start){const m=Math.min(f.end,o+c.text.length)-h;a||(a={text:"",changed:!1,scope:xp},r.push(a)),a.text+=c.text.slice(u,u+m),a.changed||(a.changed=c.changed),u+=m,h+m>=f.end&&(a=null,s++)}else{const m=f?Math.min(f.start-o,c.text.length):c.text.length;r.push({text:c.text.slice(u,m),changed:c.changed,scope:c.scope}),u=m}}o+=c.text.length}return r}const yh=e=>e.map(t$);function Hy(e){return JT.test(e)?e.split(`
216
- `).map(t=>t$(t?[{text:t,changed:!1,scope:""}]:[])):[]}function n$(e){const t=e[e.length-1],n=t==null?void 0:t[t.length-1];return!n||n.scope!==xp?e:[...e.slice(0,-1),[...t.slice(0,-1),{...n,scope:""}]]}function HU(e,t,n){if(!(e!=null&&e.length)&&!(t!=null&&t.length))return n?[{text:n,changed:!1,scope:""}]:[];const r=[],o=e!=null&&e.length?e:[{text:n,changed:!1}],s=t!=null&&t.length?t:[{text:n,scope:""}];let a=0,c=0,u=0,f=0;for(;a<o.length&&c<s.length;){const h=o[a],m=s[c],g=Math.min(h.text.length-u,m.text.length-f);if(g>0){const y={text:h.text.slice(u,u+g),changed:h.changed,scope:m.scope},w=r[r.length-1];w&&w.changed===y.changed&&w.scope===y.scope?w.text+=y.text:r.push(y)}u+=g,f+=g,u>=h.text.length&&(a++,u=0),f>=m.text.length&&(c++,f=0)}return r}const WU=/^[^\s]*$/,KU=e=>e.split(/\s+/).slice(1).every(t=>!t||/[a-z0-9]/i.test(t));function Cg(e,t,n){if(e.startsWith("!"))return null;if(e.startsWith("/")){const a=e.indexOf(" "),c=a===-1?e.length:a;if(!(e.indexOf("/",1)!==-1&&e.indexOf("/",1)<c)&&t<=c)return{kind:"command",query:e.slice(1,t),from:0,to:c}}const r=e.lastIndexOf("@",Math.max(0,t-1));if(r===-1||r>=t||r>0&&!/\s/.test(e[r-1]??""))return null;const o=e.slice(r+1,t);if(!WU.test(o)&&!(KU(o)&&(n!=null&&n(o))))return null;let s=t;for(;s<e.length&&!/\s/.test(e[s]??"");)s++;return{kind:"file",query:o,from:r,to:s}}const Fk=new Map,W1={files:new Set,folders:new Set,worktrees:Fk,titled:[]},K1=new WeakMap;function r$(e,t=Fk){let n;if(e?(n=K1.get(e),n||(n={...W1,files:new Set(e),folders:new Set(R_(e))},K1.set(e,n))):n=W1,t===Fk)return n;const r=[...t].map(([o,s])=>({...s,branch:o})).sort((o,s)=>s.title.length-o.title.length);return{...n,worktrees:t,titled:r}}function o$(e,t){const n=new Map;for(const{branch:r,...o}of e)n.set(r,o);for(const r of t??[])n.has(r.branch)||n.set(r.branch,{id:r.id,title:r.title,archived:!0});return n}const qU=/^[ \t]*(?<ticks>`{3,})[ \t]*(?<lang>[^`\s]*)[^`\n]*$/;function ZU(e){var s;const t=[],n=a=>{if(!a)return;const c=t.at(-1);(c==null?void 0:c.kind)==="prose"?c.text+=a:t.push({kind:"prose",text:a})};let r=0,o=0;for(;r<e.length;){const a=e.indexOf("`",r);if(a===-1)break;const c=e.lastIndexOf(`
217
- `,a-1)+1,u=e.indexOf(`
218
- `,a),f=(s=qU.exec(e.slice(c,u===-1?e.length:u)))==null?void 0:s.groups;if(f!=null&&f.ticks){const w=f.ticks.length,v=new RegExp(`^[ \\t]*\`{${w},}[ \\t]*$`,"m"),_=u===-1?e.length:u+1,x=v.exec(e.slice(_));let N=e.length,T=e.slice(_);x&&(T=e.slice(_,_+x.index),N=_+x.index+x[0].length,e[N]===`
219
- `&&N++),n(e.slice(o,c)),t.push({kind:"block",text:e.slice(c,N),code:T.replace(/\n$/,""),lang:f.lang??""}),o=r=N;continue}let h=1;for(;e[a+h]==="`";)h++;const m=new RegExp(`(?<!\`)\`{${h}}(?!\`)`,"g");m.lastIndex=a+h;const g=m.exec(e);if(!g){r=a+h;continue}let y=e.slice(a+h,g.index);y.length>2&&y.startsWith(" ")&&y.endsWith(" ")&&y.trim()&&(y=y.slice(1,-1)),n(e.slice(o,a)),t.push({kind:"code",text:e.slice(a,g.index+h),code:y}),o=r=g.index+h}return n(e.slice(o)),t}const GU=/(^|\s)(@\S+)/g,VU=/[.,;:!?)\]}'"]$/,YU=/^[.,;:!?)\]}'"]*(\s|$)/;function q1(e,t){if(e==="changes")return{kind:"changes",text:"@changes"};if(t.files.has(e))return{kind:"file",text:`@${e}`,path:e};const n=e.replace(/\/+$/,"");if(n&&t.folders.has(n))return{kind:"folder",text:`@${e}`,path:n};const r=t.worktrees.get(e);return r?{kind:"worktree",text:`@${e}`,branch:e,...r}:null}function XU(e,t){const n=e.toLowerCase();for(const r of t.titled){const o=r.title.toLowerCase();if(o&&n.startsWith(o)&&YU.test(e.slice(o.length)))return{kind:"worktree",text:`@${e.slice(0,o.length)}`,...r}}return null}function Ep(e){const t=[];return e.archived?t.push("archived"):(e.state&&t.push(e.state),e.at!==void 0&&t.push(`last sent ${So(mr(e.at))}`)),e.branch&&t.push(e.branch),e.dir&&t.push(e.dir),{text:e.title,detail:t,dot:e.archived?"archived":e.dot}}function QU(e,t,n){let r=0;for(const o of Wy(e,n)){if(r===t)return o.kind!=="text";r+=o.text.length}return!1}function Wy(e,t){const n=[];for(const r of ZU(e))r.kind==="prose"?JU(r.text,n.length===0,t,n):n.push(r);return n}function JU(e,t,n,r){const o=[];for(const c of e.matchAll(GU)){if(c.index===0&&!c[1]&&!t)continue;const u=c.index+(c[1]??"").length,f=XU(e.slice(u+1),n);let h=(c[2]??"").slice(1),m=f&&/\s/.test(f.text)?f:q1(h,n);for(;!m&&VU.test(h);)h=h.slice(0,-1),m=h?q1(h,n):null;m??(m=f),m&&o.push({start:u,span:m})}for(const c of e$(e)){const u=e.slice(c.start,c.end);o.push({start:c.start,span:{kind:"url",text:u,href:u}})}for(const c of XB(e)){const u=e.slice(c.start,c.end);o.push({start:c.start,span:{kind:"url",text:u,href:Uy(u)??u}})}o.sort((c,u)=>c.start-u.start);let s=0;const a=c=>{if(!c)return;const u=r.at(-1);(u==null?void 0:u.kind)==="text"?u.text+=c:r.push({kind:"text",text:c})};for(const{start:c,span:u}of o)c<s||(a(e.slice(s,c)),r.push(u),s=c+u.text.length);a(e.slice(s))}function Z1(e,t){return Wy(e,t).map(n=>n.kind==="worktree"?`@${n.branch}`:n.text).join("")}function e7(e,t,n){return{text:e.slice(0,t.from)+n+e.slice(t.to),caret:t.from+n.length}}function t7(e,t){const n=t.trim().toLowerCase();if(!n)return e;const r=s=>e.map((a,c)=>({c:a,i:c,score:s(a)})).filter(a=>a.score>0).sort((a,c)=>c.score-a.score||a.i-c.i).map(a=>a.c),o=r(s=>Ik(s.name,n));return o.length>0?o:r(s=>Ik(s.description,n))}const G1=e=>e.slice(e.lastIndexOf("/")+1);function n7(e,t,n){const r=[],o=new Set;for(const s of e){const a=s.worktree;if(a.repoId!==n)continue;const c=G1(a.path);o.has(c)||(o.add(c),r.push({dir:c,id:a.id,title:a.title,branch:a.branch}))}for(const s of t??[]){const a=G1(s.path);s.repoId!==n||o.has(a)||(o.add(a),r.push({dir:a,id:s.id,title:s.title,branch:s.branch,archived:!0}))}return r}const V1=new WeakMap;function r7(e,t){let n=V1.get(e.visible);n||(n=new Map,V1.set(e.visible,n));const r=e.archived[t],o=n.get(t);if(o&&o.archived===r)return o.key;const s=JSON.stringify(n7(e.visible,r,t));return n.set(t,{archived:r,key:s}),s}function o7(e){const t=new Map;for(const n of JSON.parse(e))t.set(n.dir,n);return n=>t.get(n)??null}const s$="wt-[0-9a-f]{4}",s7=new RegExp(`(^|[^\\w\\-/\`])\`?${s$}(?![\\w\\-/\`])`),i7=new RegExp(`^(\`?)(${s$})\\1(?![\\w\\-/\`])`),ha=e=>Fo(e).replace(/"/g,"&quot;");function a7(e){return{name:"worktree",level:"inline",start:t=>{const n=s7.exec(t);return n?n.index+n[1].length:void 0},tokenizer(t){const n=i7.exec(t);if(n)return{type:"worktree",raw:n[0],text:n[2],code:n[1]!==""}},renderer(t){var c;const n=t.text,r=((c=e())==null?void 0:c(n))??null;if(!r)return t.code?`<code>${n}</code>`:n;const o=Ep({id:r.id,title:r.title,branch:r.branch,dir:n,...r.archived?{archived:!0}:{}}),s=r.archived?' data-archived=""':"",a=o.dot?` data-tip-dot="${ha(o.dot)}"`:"";return`<span class="chat-mention" data-worktree="${ha(r.id)}" data-branch="${ha(r.branch)}" data-dir="${ha(n)}"${s} data-tip="${ha(o.text)}" data-tip-detail="${ha(o.detail.join(`
220
- `))}"${a} data-tip-placement="follow">@${Fo(r.title)}<span class="chat-mention-dot"><span class="dot${o.dot?` ${ha(o.dot)}`:""}"></span></span></span>`}}}const l7=4*Ma;function c7(e,t,n){if(!e)return{from:t,to:t,at:n,span:Ma};const r=Math.min(i$(e,n),t),o=Math.min(Math.max(n-e.at,Ma),l7);return{from:r,to:t,at:n,span:o}}function i$(e,t){const n=t-e.at;return n>=e.span?e.to:e.from+Math.floor((e.to-e.from)*Math.max(0,n)/e.span)}function u7(e,t){if(t>=e.length)return e;const n=e.charCodeAt(t);return e.slice(0,n>=56320&&n<=57343?t+1:t)}_n.use({extensions:[HB,JB,a7(()=>In==null?void 0:In.worktrees)],renderer:{code({text:e,lang:t}){const n=vp((t??"").trim().toLowerCase().split(/\s+/)[0]??"","");let r=n?yh(bp(e,n)):Hy(e);return r.length?(In!=null&&In.streaming&&Zf.trimEnd().endsWith(e.trimEnd())&&(r=n$(r)),`<pre><code>${r.map(s=>s.map(a=>a.scope===xp?`<a href="${Fo(a.text)}">${Fo(a.text)}</a>`:a.scope?`<span class="sy-${a.scope}">${Fo(a.text)}</span>`:Fo(a.text)).join("")).join(`
221
- `)}</code></pre>
222
- `):!1},codespan:QB,html(e){return In!=null&&In.keepHtml?!1:WB(e)},image({href:e,text:t}){if(In!=null&&In.base||/^(https?:|data:)/i.test(e))return!1;const n=In==null?void 0:In.stills,r=n==null?void 0:n.pictures.find(u=>u.path===e),o=Fo(t);if(r&&n){const u=n.urls.attachment(n.worktreeId,r.file);return`<button type="button" class="md-still" data-file="${If(r.file)}" data-tip="Open full size" data-tip-placement="follow"><img src="${If(u)}" alt="${If(t)}"></button>`}const s=vT(e),a=In==null?void 0:In.fileRoot,c=s.startsWith("/")?s:a?`${a}/${s}`:null;return c?`<a href="${If(c)}">${o}</a>`:o},table:eU}});const If=e=>Fo(e).replace(/"/g,"&quot;"),Ky=L9(window);let In=null,Zf="";Ky.addHook("uponSanitizeAttribute",(e,t)=>{e.tagName==="A"&&t.attrName==="href"&&(t.attrValue=vT(t.attrValue))});Ky.addHook("afterSanitizeAttributes",e=>{const t=e.tagName==="A"?e.getAttribute("href")??"":"";if(t===PT){e.removeAttribute("href"),e.classList.add("link-pending","live-text");return}/^https?:/i.test(t)&&(e.setAttribute("target","_blank"),e.setAttribute("rel","noreferrer"));const n=In!=null&&In.fileRoot?yT(In.fileRoot,t):null,r=n?null:bT(t);if(n?(e.classList.add("file-link"),e.setAttribute("data-tip",n.folder?`${n.path}/`:`${n.path}${n.line?`:${n.line}`:""}`),e.setAttribute("data-tip-placement","follow")):r&&(e.classList.add("file-link"),e.setAttribute("data-tip",r.folder?`${r.path}/`:`${r.path}${r.line?`:${r.line}`:""}`),e.setAttribute("data-tip-placement","follow")),e.tagName==="CODE"&&!e.closest("pre, a")){const s=J8(e.textContent??"");s&&e.setAttribute("data-path",s)}const o=In==null?void 0:In.base;if(e.tagName==="IMG"&&o){const s=wT(o.dir,e.getAttribute("src")??"");s&&e.setAttribute("src",o.urls.worktreeFile(o.worktreeId,s,o.version))}});function Ta(e,t){In=t??null,Zf=t!=null&&t.streaming?zB(e):e;try{return Ky.sanitize(_n.parse(Zf,{async:!1,breaks:!(t!=null&&t.keepHtml)}))}finally{In=null,Zf=""}}function d7(e,t){const[n,r]=E.useState(e),o=E.useRef(null);return E.useEffect(()=>{if(!t){o.current=null;return}o.current=c7(o.current,e.length,performance.now());let s=0;const a=()=>{const c=o.current;if(!c)return;const u=i$(c,performance.now());r(u7(e,u)),u<c.to&&(s=requestAnimationFrame(a))};return a(),()=>cancelAnimationFrame(s)},[e,t]),t?n:e}function td(e,t){var v,_,x,N;const[n,r]=E.useState(()=>Ta(e,t)),o=E.useRef(0),s=(v=t==null?void 0:t.base)==null?void 0:v.worktreeId,a=(_=t==null?void 0:t.base)==null?void 0:_.dir,c=(x=t==null?void 0:t.base)==null?void 0:x.version,u=(N=t==null?void 0:t.base)==null?void 0:N.urls,f=t==null?void 0:t.fileRoot,h=t==null?void 0:t.worktrees,m=t==null?void 0:t.stills,g=!!(t!=null&&t.keepHtml),y=!!(t!=null&&t.streaming),w=d7(e,y);return E.useEffect(()=>{const T=s!==void 0&&a!==void 0&&u!==void 0?{worktreeId:s,dir:a,version:c??null,urls:u}:void 0,j=T||f||h||m||g||y?{base:T,fileRoot:f,worktrees:h,stills:m,keepHtml:g,streaming:y}:void 0,A=performance.now()-o.current;if(y||A>=Ma){o.current=performance.now(),r(Ta(w,j));return}const R=setTimeout(()=>{o.current=performance.now(),r(Ta(w,j))},Ma-A);return()=>clearTimeout(R)},[w,s,a,c,u,f,h,m,g,y]),n}const f7=/^ {0,3}(`{3,}|~{3,})/,h7=/^#{1,6} \S/,p7=/^\s*(?:[-*+]|\d+[.)]) \S/,m7=/^> ?\S/,g7=/^\s*\|?\s*:?-{3,}:?\s*(?:\|\s*:?-{3,}:?\s*)+\|?\s*$/,k7=/\[[^\]\n]+\]\((?:https?:|\.{0,2}\/|#)[^)\s]*\)/,w7=/\*\*[^\s*][^*\n]*\*\*/;function y7(e){var s,a;const t=e.split(`
223
- `),n=new Set;let r=null,o=0;for(let c=0;c<t.length;c++){const u=t[c],f=(s=f7.exec(u))==null?void 0:s[1];if(r){f!=null&&f.startsWith(r)&&(r=null,n.add("fence"));continue}if(f){r=f;continue}h7.test(u)&&!((a=t[c+1])!=null&&a.trim())&&n.add("heading"),p7.test(u)&&++o===2&&n.add("list"),m7.test(u)&&n.add("quote"),g7.test(u)&&n.add("table"),k7.test(u)&&n.add("link"),w7.test(u)&&n.add("bold")}return n.size}function v7(e,t){if(t)return Yh(t)==="markdown"?"rendered":"plain";const n=y7(e);return n>=2?"rendered":n===1?"source":"plain"}function Sp({n:e,name:t,source:n,lines:r,chars:o,preview:s,text:a,href:c,onRemove:u,className:f=""}){const h=(n==null?void 0:n.path)??t??"",m=h.includes("/")?h.slice(0,h.lastIndexOf("/")):"",g=n?[m,n.ref?`at ${n.ref.slice(0,7)}`:""].filter(Boolean).join(" "):[m,`${r} ${r===1?"line":"lines"}`,`${o.toLocaleString()} chars`,s].filter(Boolean).join(" · "),y=d.jsxs(d.Fragment,{children:[d.jsx(kt,{name:"text",className:"icon-inline"}),d.jsxs("span",{className:"pick-target",children:[d.jsx("b",{children:t?t.slice(t.lastIndexOf("/")+1):n?PP(n):uS("paste",e)}),g&&d.jsxs("span",{className:"pick-file row-dim",children:[" · ",g]})]})]}),w=a!==void 0||c!==void 0;return d.jsx(Ay,{className:Ke("paste-chip",f),label:y,tip:s||void 0,peek:w?d.jsx(c$,{text:a,href:c}):void 0,full:w?d.jsx(l$,{text:a,href:c,path:h||void 0}):void 0,menu:v=>A8({text:a,href:c},v),removeLabel:"Remove attachment",onRemove:u})}function a$(e,t){const[n,r]=E.useState(e??null),[o,s]=E.useState(!1);return E.useEffect(()=>{if(e!==void 0||!t)return;let a=!0;return fetch(t).then(c=>c.ok?c.text():Promise.reject(new Error(String(c.status)))).then(c=>{a&&r(c)}).catch(()=>{a&&s(!0)}),()=>{a=!1}},[e,t]),{text:e??n,failed:o}}function l$({text:e,href:t,path:n}){const{text:r,failed:o}=a$(e,t),s=E.useMemo(()=>r?v7(r,n):"plain",[r,n]),[a,c]=E.useState(null);if(o)return d.jsx("p",{className:"paste-full hint",children:"Toyon could not read that back."});if(!r||s==="plain")return d.jsx("pre",{className:"paste-full paste-text",children:r});const u=a??s==="rendered";return d.jsxs("div",{className:"paste-full paste-doc",children:[d.jsx("div",{className:"paste-doc-head",children:d.jsxs(Oe,{variant:"outline",tone:"quiet",mono:!0,className:"deep-link",onClick:()=>c(!u),"data-tip":u?"Text: read it as it was sent":"Preview: read it rendered",children:[d.jsx(kt,{name:u?"text":"book",className:"icon-inline"})," ",u?"text":"preview"]})}),u?d.jsx(b7,{text:r}):d.jsx("pre",{className:"paste-doc-body paste-text",children:r})]})}function b7({text:e}){const t=E.useMemo(()=>Ta(e),[e]);return d.jsx("div",{className:"paste-doc-body md md-preview",onClick:n=>{const r=n.target.closest("a");r&&r.target!=="_blank"&&n.preventDefault()},dangerouslySetInnerHTML:{__html:t}})}const x7=2e4;function c$({text:e,href:t}){const{text:n}=a$(e,t);return n?d.jsx("pre",{className:"paste-peek paste-text",children:n.slice(0,x7)}):null}function _p({name:e,bytes:t,href:n,kept:r,uploading:o,progress:s,onRemove:a,className:c=""}){const u=Qe();return d.jsx(Ay,{className:Ke("file-chip",c),label:d.jsxs(d.Fragment,{children:[d.jsx(kt,{name:"file",className:"icon-inline"}),d.jsxs("span",{className:"pick-target",children:[d.jsx("b",{children:e}),d.jsxs("span",{className:"pick-file row-dim",children:[" ","· ",mw(t),s!==void 0?d.jsxs(d.Fragment,{children:[" ","· ",d.jsxs("span",{className:"pick-progress",children:[s,"%"]})]}):o&&" · uploading"]})]})]}),tip:e,peek:n?d.jsx(c$,{href:n}):void 0,full:n?d.jsx(l$,{href:n,path:e}):void 0,menu:f=>R8({href:n},f,r&&{...r,sock:u}),removeLabel:"Remove attachment",onRemove:a})}function nc({rows:e,cursor:t,onCursor:n,onPick:r,onHint:o,hover:s=!1,plain:a=!1}){const c=Bi(),u=!c&&!a,f=E.useRef(null),[h,m]=E.useState(null),g=c&&!!o;gj(f,{rowOf:w=>{if(!g||w.closest("textarea"))return null;const v=w.closest(".slide"),_=v==null?void 0:v.dataset.row,x=_===void 0?void 0:e[Number(_)];return v&&_!==void 0&&(x!=null&&x.hint)&&!x.field?{el:v,key:_,rungs:1,rung:120}:null},onSlide:m,onPick:w=>o==null?void 0:o(Number(w))});const y=w=>{var v;w.target instanceof HTMLTextAreaElement||(w.preventDefault(),(v=w.currentTarget.querySelector("textarea"))==null||v.focus())};return d.jsx("div",{className:Ke("choices",s&&"choices-hover",c&&"choices-touch",a&&"choices-plain"),ref:f,children:e.map((w,v)=>{const _=!c&&t===v,x=gr({cursor:_,checked:w.checked}),N=w.tone==="deny"&&"choice-deny",T=()=>n==null?void 0:n(v),j=R=>{var I;if(!g)return R;const C=(h==null?void 0:h.key)===String(v)?h.step:null,M=C!==null&&C>0&&((I=w.hint)==null?void 0:I.on)!==!1;return d.jsxs("div",{className:"slide","data-row":v,children:[R,C!==null&&w.hint&&d.jsxs("span",{className:"slide-verb","data-rung":M?"hint":void 0,"aria-hidden":"true",children:[d.jsx("span",{className:"slide-word",children:w.hint.label}),d.jsx(kt,{name:w.hint.icon})]})]},v)},A=d.jsxs(d.Fragment,{children:[u&&d.jsx(os,{k:String(v+1),className:"choice-num row-dim"}),d.jsx("span",{className:"choice-label",children:w.label}),u&&w.hint&&d.jsxs("span",{className:Ke("choice-hint row-dim",_&&w.hint.on!==!1&&"on"),children:[d.jsx(os,{k:w.hint.k})," ",w.hint.label]}),w.description&&d.jsx("span",{className:"choice-desc",children:w.description}),w.sample&&d.jsx("pre",{className:"choice-sample",children:w.sample})]});return w.field?j(d.jsxs("div",{className:Ke("picker-item choice row-edge",N),"data-state":x,onMouseMove:T,onMouseDown:y,children:[A,d.jsx(Cu,{ref:w.field.ref,bare:!0,font:"ui",rows:1,className:"choice-field",enterKeyHint:w.field.enterKeyHint,placeholder:w.field.placeholder,value:w.field.value,onChange:R=>{var C;return(C=w.field)==null?void 0:C.onChange(R.target.value)}}),c&&w.field.onSend&&d.jsx(At,{className:"choice-send",icon:"send",tone:"primary",label:"Send",onClick:w.field.onSend})]},v)):j(d.jsx("button",{type:"button",className:Ke("picker-item choice row-edge",N),"data-state":x,disabled:w.disabled,onMouseMove:T,onClick:()=>r(v),children:A},v))})})}function u$({hints:e,note:t,className:n=""}){return d.jsxs("div",{className:`key-hints ${n}`.trim(),children:[e.map(([r,o])=>d.jsxs("span",{className:"key-hint",children:[d.jsx(os,{k:r}),o]},r)),t&&d.jsx("span",{className:"key-note",children:t})]})}function Mu({anchored:e=!1,...t}){return e?d.jsx(E7,{...t,anchored:e===!0?{}:e}):d.jsx(S7,{...t})}function E7({onClose:e,onEscape:t,boxClass:n="",bare:r=!1,anchored:o,coverBy:s,id:a,children:c}){const{onKey:u,back:f}=d$(t);return d.jsx(Ws,{className:Ke(r?"":"overlay-box","anchored",n),id:a,anchor:"parent",placement:{side:"bottom",align:"start",cover:!0,margin:0,...o},coverBy:s,onDismiss:e?()=>e():void 0,onKey:u,onBack:()=>f()||(e==null?void 0:e()),children:c})}function S7({onClose:e,onEscape:t,boxClass:n="",bare:r=!1,id:o,children:s}){const{onKey:a,back:c}=d$(t);return d.jsx(Ws,{className:"overlay scrim",id:o,onDismiss:e?()=>e():void 0,onKey:a,onBack:()=>c()||(e==null?void 0:e()),onClick:u=>{e&&u.target===u.currentTarget&&e()},children:d.jsx("div",{className:Ke(r?"":"overlay-box",n),children:s})})}function d$(e){const t=Dn(),n=()=>{if(e)return e(),!0;const o=t.getState();return!o.overlay||o.choosingFolder?!1:(t.dispatch({a:"close",back:X_(o.overlay)}),!0)};return{onKey:o=>{o.key==="Escape"&&n()&&o.stopPropagation()},back:n}}function _7(e){const t=e.value.length;e.setSelectionRange(t,t)}function N7({text:e,params:t}){if(t.length===0)return e;const n=[];let r=0;for(const[o,s]of t)o>r&&n.push(e.slice(r,o)),n.push(d.jsx("span",{className:"picker-ghost-param",children:e.slice(o,s)},o)),r=s;return r<e.length&&n.push(e.slice(r)),n}function qr({items:e,filter:t,keyOf:n,row:r,rowClass:o,rowTitle:s,onPick:a,onBack:c,onActive:u,onSide:f,onTab:h,onQuery:m,completionOf:g,narrowTo:y,placeholder:w,initialQuery:v="",initialIndex:_,selectOnMount:x=!1,idleWhen:N,onIdlePick:T,anchored:j=!1,onEscape:A,lead:R,trailing:C,empty:M="no matches",footer:I,keys:D,rowMenu:H,groupOf:Z,groupHead:B,headAlone:J=!1,field:V}){const ee=vn("picker"),[F,$]=E.useState(v),Q=E.useMemo(()=>t(e,F),[e,F,t]),q=E.useRef(null),W=Bi(),oe=t3(x,!W&&!V);E.useEffect(()=>{if(!m)return;const Se=setTimeout(()=>m(F),150);return()=>clearTimeout(Se)},[F,m]);const de=fj({results:Q,keyOf:n,q:F,onPick:a,listRef:q,onActive:u,onSide:f,completionOf:g,narrowTo:y,setQ:$,initialIndex:_,idle:(N==null?void 0:N(v))??!1,onIdlePick:T}),{index:he,ghost:Ne}=de,Me=V?V.open:!0;at([Me,v],()=>{!V||Me||($(v),de.setIndex(N!=null&&N(v)?-1:0))}),at([Me],()=>{if(!V||!Me||W)return;const Se=()=>{const Le=oe.current;!Le||document.activeElement===Le||(Le.focus(),x&&Le.select())};Se();const Ee=requestAnimationFrame(Se);return()=>cancelAnimationFrame(Ee)});const Be=E.useRef(!1),K=typeof D=="function"?D(de.active,F):D,te=[];K!=null&&K.nav&&te.push(["↑↓",K.nav]),K!=null&&K.side&&f&&te.push(["←→",K.side]),K!=null&&K.complete&&(Ne!=null&&Ne.accept)&&te.push(["tab",K.complete]),K!=null&&K.tab&&h&&te.push(["tab",K.tab]),K!=null&&K.pick&&te.push(["enter",K.pick]),K!=null&&K.back&&te.push(["esc",K.back]);const pe=Se=>d.jsxs("div",{...V==null?void 0:V.attrs,className:Ke("picker-input",V&&"picker-field",V==null?void 0:V.className),"data-open":(V==null?void 0:V.open)||void 0,onMouseDown:Ee=>{var Le;Ee.target.closest("input, .float")||(Ee.preventDefault(),(Le=oe.current)==null||Le.focus())},children:[R,d.jsxs("div",{className:"picker-caret",children:[d.jsx(Bo,{font:"mono",bare:!0,ref:oe,value:F,spellCheck:!1,"aria-controls":V==null?void 0:V.id,"aria-expanded":V?V.open:void 0,onFocus:()=>{V&&!V.open&&V.onOpen()},onBlur:Ee=>{const Le=Ee.relatedTarget;V!=null&&V.open&&Le instanceof Element&&!Le.closest(".float")&&c()},onMouseDown:Ee=>{const Le=document.activeElement!==Ee.currentTarget;if(Be.current=Le,V&&Le){const Ue=document.getSelection();Ue&&(!Ue.isCollapsed||Ue.toString()!=="")&&Ue.removeAllRanges()}},onClick:Ee=>{if(!V||!Be.current)return;Be.current=!1;const Le=Ee.currentTarget;setTimeout(()=>{document.activeElement===Le&&Le.selectionStart===Le.selectionEnd&&Le.select()},0)},onChange:Ee=>{$(Ee.target.value),de.setIndex(N!=null&&N(Ee.target.value)?-1:0),V&&!V.open&&V.onOpen()},onKeyDown:Ee=>{var Le;if(V&&!V.open){if(Ee.key==="ArrowDown"||Ee.key==="ArrowUp")V.onOpen();else if(Ee.key==="Escape"){_7(Ee.currentTarget),Ee.currentTarget.blur();return}}if(H&&de.active&&(Ee.key==="ContextMenu"||Ee.key==="F10"&&Ee.shiftKey)){const Ue=(Le=q.current)==null?void 0:Le.querySelector('[data-state~="cursor"]');if(Ue){Ee.preventDefault(),Ee.stopPropagation(),fo.open({items:H(de.active),owner:"picker",target:Ue,anchor:Ue.getBoundingClientRect()});return}}de.onKeyDown(Ee)||!h||Ee.key!=="Tab"||Ee.shiftKey||(Ee.preventDefault(),h())},placeholder:w}),Ne&&d.jsxs("div",{className:"picker-ghost","aria-hidden":"true",children:[d.jsx("span",{className:"picker-typed",children:F}),N7(Ne)]})]}),C,Se]}),ue=new Map;if(Z)for(const Se of Q)ue.set(Z(Se),(ue.get(Z(Se))??0)+1);const ie=d.jsxs("div",{className:"picker-list",ref:q,onMouseDown:Se=>{V&&Se.target!==Se.currentTarget&&Se.preventDefault()},children:[Q.map((Se,Ee)=>{const Le=Z==null?void 0:Z(Se),Ue=Le!==void 0&&(J||ue.size>1)&&(Ee===0||(Z==null?void 0:Z(Q[Ee-1]))!==Le)?d.jsx("div",{className:"picker-group",children:(B==null?void 0:B(Le,ue.get(Le)??0))??Le}):null;return d.jsxs(E.Fragment,{children:[Ue,d.jsx("button",{className:Ke("picker-item",o==null?void 0:o(Se)),"data-state":gr({cursor:Ee===he}),title:s==null?void 0:s(Se),onMouseMove:()=>Ee!==he&&de.setIndex(Ee),onClick:()=>{var Je;de.pick(Se),(Je=oe.current)==null||Je.focus()},...ee.contextMenu(()=>(H==null?void 0:H(Se))??[]),children:r(Se,Ee===he,F)})]},n(Se))}),Q.length===0&&d.jsx("div",{className:"empty",children:typeof M=="function"?M(F):M}),I==null?void 0:I(F,Q)]}),ye=te.length>0&&d.jsx(u$,{hints:te});return V?pe(V.open&&d.jsxs(Mu,{onClose:c,onEscape:A,boxClass:"picker",anchored:j,id:V.id,children:[ie,ye]})):d.jsxs(Mu,{onClose:c,onEscape:A,boxClass:"picker",anchored:j,coverBy:R?".picker-input > *:first-child":C?".picker-input > *:last-child":void 0,children:[pe(),ie,ye]})}function Os({value:e,reads:t,options:n,onChange:r,placeholder:o,hint:s,className:a,onClose:c}){const[u,f]=E.useState(!1),h=()=>{f(!1),c==null||c()},m=t??e,g=n.find(w=>w.id===m),y=(g==null?void 0:g.chip)??(g==null?void 0:g.label)??m;return d.jsxs("span",{className:"chip-picker",children:[d.jsx(Oe,{variant:"ghost",tone:"chrome",mono:!0,on:u,className:Ke("chip-picker-btn",a),...Lt(s),onClick:()=>u?h():f(!0),children:y}),u&&d.jsx(qr,{anchored:{flip:"both",margin:0},onEscape:h,items:n,filter:(w,v)=>{const _=v.trim().toLowerCase().split(/\s+/).filter(Boolean);return w.filter(x=>{const N=`${x.prefix??""} ${x.label??x.id} ${x.suffix??""} ${x.id}`.toLowerCase();return _.every(T=>N.includes(T))})},keyOf:w=>w.id,initialIndex:w=>Math.max(0,w.findIndex(v=>v.id===e)),lead:d.jsx(Oe,{tone:"chrome",mono:!0,on:!0,className:"chip-picker-lead",onClick:h,children:y}),placeholder:o,rowClass:()=>"picker-row",row:w=>d.jsxs(d.Fragment,{children:[w.id===e&&d.jsx("span",{className:"row-current","aria-hidden":"true"}),d.jsxs("span",{className:Ke("chip-option",w.disabled&&"chip-option-off"),"aria-disabled":w.disabled,children:[d.jsxs("span",{className:"chip-option-name",children:[w.prefix?`${w.prefix} `:null,w.label??w.id,w.suffix?d.jsx("span",{className:"chip-option-suffix",children:` ${w.suffix}`}):null]}),w.description&&d.jsx("span",{className:"chip-option-desc row-dim",children:w.description})]})]}),onPick:w=>{w.disabled||(r(w.id),h())},onBack:h})]})}const qy=e=>e.startsWith("remote:")?e.slice(7):null;function j7(e,t){var o,s;const n=(s=(o=t.worktree.sources)==null?void 0:o[e])==null?void 0:s.at,r=mS(n);return r!==void 0?`remote:${r}`:Lh(n)?"here":"main"}function f$(e,t,n,r){var _,x,N,T;const o=j7(e,t),s=((_=t.remoteBehind)==null?void 0:_.includes(e))??!1,a=(r==null?void 0:r.dirty)??0,c=(N=(x=t.borrowed)==null?void 0:x.find(j=>j.name===e))==null?void 0:N.status,u=c!==void 0&&!Ah(c),f=((T=t.procs)==null?void 0:T.some(j=>j.name===e&&j.status==="preparing"))??!1,h=["main runs it for every worktree",...a>0?[Yl(a,e)]:[],...u?[`main's ${e} is ${c}`]:[],...f?[`${e} is setting up here and takes over once it answers`]:[]].join("; "),m={id:"main",label:"main",chip:`${e} · main`,description:h},g={id:"here",label:"here",chip:`${e} · here`,description:f?"this worktree is setting up its own":"this worktree runs its own"},y=Object.entries(pS(n.config.run[e]??"")).map(([j,A])=>({id:`remote:${j}`,label:j,chip:`${e} · ${j}`,description:A})),w=s?[g,m,...y]:[m,g,...y];let v;if(s)v=`${e} edits here are not what the page is talking to; pick here to run them`;else if(o==="main"){const j=f?"; its own is setting up here":a>0?`; ${Yl(a,e)}`:"";v=`${e} runs on main for every worktree${j}. Click to change`}else o==="here"?v=`${e} runs here: this worktree's own. Click to change`:v=`${e} points at ${qy(o)} for this worktree. Click to change`;return{value:o,held:s,hint:v,options:w}}function T7(e,t,n,r){if(t===n)return null;const o=qy(n),a={t:"set-proc-source",worktreeId:r,name:e,source:o!==null?{remote:o}:n==="main"?"main":"here"};return n==="main"&&t==="here"?{msg:a,confirm:`Stop this worktree's own ${e} and use main's?
224
-
225
- What they hold that main's do not (a database of their own) is not carried over.`}:{msg:a}}function h$(e,t,n,r,o){const s=T7(t,n,r,o);s&&(s.confirm&&!window.confirm(s.confirm)||e==null||e.send(s.msg))}function $7({name:e,wt:t,repo:n,trunk:r,onClose:o}){const s=Qe(),{value:a,held:c,hint:u,options:f}=f$(e,t,n,r);return d.jsx(Os,{value:a,options:f,onChange:h=>h$(s,e,a,h,t.worktree.id),onClose:o,className:Ke("source-chip",c&&"source-held"),hint:u,placeholder:`where ${e} runs for this worktree`})}function C7(e,t,n,r,o){var g,y;const s=`this worktree changed ${t??"what it runs on"}`;if(!n||!r||!(e in(r.tier??{})))return{word:"ran here",text:`${e} ran here: ${s}`,value:null,rows:[]};const{value:a,options:c}=f$(e,n,r,o),u=c.map(w=>({...w,current:w.id===a})),f=(y=(g=n.procs)==null?void 0:g.find(w=>w.name===e))==null?void 0:y.status,h=a==="here"||f==="preparing";let m;if(h){const w=f??"starting",v=w==="running"?`${e} runs here`:`${e} is ${Pw(w).toLowerCase()} here`;m=w==="preparing"||w==="starting"?`${v}: ${s}; the page reaches main's until it answers`:`${v}: ${s}`}else a==="main"?m=`${e} runs on main for every worktree again; it ran here after ${s}`:m=`${e} points at ${qy(a)} for this worktree; it ran here after ${s}`;return{word:h?"runs here":"ran here",text:m,value:a,rows:u}}function I7({item:e,worktreeId:t}){return d.jsx(d.Fragment,{children:e.names.map(n=>d.jsx(A7,{name:n,file:e.file,ts:e.ts,worktreeId:t},n))})}function A7({name:e,file:t,ts:n,worktreeId:r}){const o=Qe(),s=L(h=>Kt(h,r)),a=L(h=>ws(h,s==null?void 0:s.repoId)),c=L(h=>Pi(h,s==null?void 0:s.repoId)),u=C7(e,t,s,a,c),f=s&&u.value!==null?{id:s.worktree.id,value:u.value}:null;return d.jsx(lr,{icon:"run",word:u.word,tone:"quiet",at:n,under:f&&d.jsx(nc,{hover:!0,plain:!0,rows:u.rows.map(h=>({label:h.label??h.id,description:h.description,checked:h.current})),onPick:h=>{const m=u.rows[h];m&&h$(o,e,f.value,m.id,f.id)}}),children:d.jsx("span",{className:"daemon-text",children:u.text})})}function p$(e){return e.replace(/^([\t ]*)\*\*(\S(?:[^\n]*\S)?)\*\*([\t ]*)$/gm,"$1$2$3")}const m$=120,R7=/^\*\*(\S(?:[^\n]*\S)?)\*\*$/;function g$(e){var n,r;const t=[];for(const o of e.split(/\n[\t ]*\n/)){const s=o.trim();if(!s)continue;const a=((r=(n=R7.exec(s))==null?void 0:n[1])==null?void 0:r.replace(/`/g,""))??"";if(!a||a.length>m$)return[];t.push(a)}return t}function k$(e){const t=g$(e);if(t.length)return t.at(-1);const n=p$(e).trim().replace(/`/g,"");return n&&!n.includes(`
226
- `)&&n.length<=m$?n:""}const O7={read:"read",edit:"edit",delete:"delete",move:"move",search:"search",execute:"run",think:"think",fetch:"fetch",switch_mode:"mode",other:"tool"},Y1={read:"book",edit:"edit",delete:"trash",move:"move",search:"search",execute:"run",think:"bulb",fetch:"globe",switch_mode:"swap",other:"dot"},w$="Skill",y$="ScheduleWakeup",Ig=new Map([[cw,"chat"],["Monitor","clock"],[y$,"clock"],["TaskOutput","terminal"],[w$,"slash"],[uw,"handoff"],[nS,"worktrees"],[rS,"run"],["EnterPlanMode","swap"]]),M7=new Map([["Read","read"],["Edit","edit"],["Write","edit"],["MultiEdit","edit"],["NotebookEdit","edit"],["Bash","execute"],["Grep","search"],["Glob","search"],["WebSearch","fetch"],["WebFetch","fetch"],["EnterPlanMode","switch_mode"],["ExitPlanMode","switch_mode"]]);function L7(e){const t=e.input&&typeof e.input=="object"?e.input.names:void 0,n=Array.isArray(t)?t.filter(r=>typeof r=="string"):[];return n.length>0?`run ${n.join(", ")} here`:"run it here"}function Bk(e){var o,s;if(e.name!==$a)return null;const t=/^select:(.*)$/.exec($r(e,"query").trim()),n=(s=(o=t==null?void 0:t[1])==null?void 0:o.split(",")[0])==null?void 0:s.trim();if(!n)return null;const r=M7.get(n);return r?{name:n,kind:r}:{name:n}}function P7(e){if(e.name!==w$)return"";const t=$r(e,"skill").trim();if(!t)return"";const n=$r(e,"args").trim();return n?`/${t} ${n}`:`/${t}`}const Uk={grep:"search",rg:"search",ag:"search",ack:"search",find:"search",fd:"search",cat:"book",head:"book",tail:"book",nl:"book",less:"book",bat:"book",ls:"folder",tree:"folder",mkdir:"folder",rm:"trash",rmdir:"trash",mv:"move",curl:"globe",wget:"globe",git:"branch"},D7=/(^|\s)(-[A-Za-z]*[iI]|--in-place)/,X1=String.raw`(?:"[^"]*"|'[^']*'|[^\s;&|]+)`,Q1=new RegExp(String.raw`^\s*(?:(?:cd|echo)\s+${X1}\s*(?:&&|;)|mkdir(?:\s+${X1})+\s*(?:&&|;)|(?:export\s+)?[A-Za-z_]\w*=(?:"[^"]*"|'[^']*'|[^\s;&|()\`]*)\s*(?:&&|;|(?=\s)))\s*`),z7=/^python[\d.]*$/,F7=new RegExp(`open\\([^)]*,\\s*["'][wax]|(?<!std(?:out|err))\\.write\\(|\\.write_text\\(`);function v$(e){let t=e;for(let n=t.replace(Q1,"");n!==t;n=t.replace(Q1,""))t=n;return t}const B7=new RegExp("(?<![0-9&])>{1,2}\\s*(?!\\/dev\\/null|&)[^\\s&>]"),b$=/&&|;|\n|\|/;function U7(e){return e.split(b$).some(t=>/^\s*(?:\S*\/)?sed\s/.test(t)&&D7.test(t))}function H7(e){return e.split(/&&|;|\n/).map(t=>v$(t).trim().split(/\s+/)[0]??"").filter(Boolean).every(t=>Uk[t.slice(t.lastIndexOf("/")+1)]==="trash")}function W7(e){const t=v$(e).trim(),n=t.split(/\s+/)[0]??"",r=n.slice(n.lastIndexOf("/")+1),o=r==="sed"?U7(e)?void 0:"book":Uk[r];if(o==="book"||o==="search"){const s=t.split(b$)[0]??"";if(B7.test(s))return r==="cat"&&s.includes("<<")?"edit":void 0}if(!(o==="trash"&&!H7(t)))return o||(z7.test(r)?t.includes("<<")&&F7.test(t)?"edit":void 0:Uk[r])}function $r(e,t){const n=e.input,r=n?n[t]:void 0;return typeof r=="string"?r:""}function K7(e){if(e.name!==uw)return"";const t=e.input;if(!Array.isArray(t==null?void 0:t.pieces))return"";const n=t.pieces.map(o=>o&&typeof o=="object"?o.title:void 0).filter(o=>typeof o=="string"&&o.trim()!=="").map(o=>o.trim());return n.length===0?"":`offered ${n.length===1?n[0]:`${n.slice(0,-1).join(", ")} and ${n.at(-1)}`}`}function q7(e){return e.name===nS&&!$r(e,"query").trim()?"the open ones and the newest archived":""}const Z7=/^(?:\/(?:usr\/)?bin\/)?(?:ba|z|da)?sh\s+(?:-[a-zA-Z]+\s+)*(?:'([^']*)'|"((?:[^"\\]|\\.)*)")\s*$/;function x$(e){const t=Z7.exec(e.trim());return t?t[1]!==void 0?t[1]:(t[2]??"").replace(/\\(["\\$`])/g,"$1"):e}const G7="Guardian Review";function E$(e){return e.toolKind==="think"&&e.title===G7}function V7(e){const t=o=>{var a,c;return((c=(a=[...e.matchAll(new RegExp(`^${o}:[ \\t]*(.+)$`,"gm"))].at(-1))==null?void 0:a[1])==null?void 0:c.trim().toLowerCase())??""},n=t("Status"),r=t("Risk");return!n||n==="in progress"?"reviewing":r?`${n}, ${r} risk`:n}function Lu(e,t=[]){const n=x$($r(e,"command")),r=e.name===$a?"":$r(e,"query"),o=e.name===y$?$r(e,"reason"):"",s=e.name===rS?L7(e):"",a=S$(e)||n||$r(e,"path")||$r(e,"pattern")||r||o||s,c=rA(e.name),u=a||P7(e)||K7(e)||q7(e)||(e.title&&e.title!==e.name?e.title:"")||(c?c.tool:""),f=Np($r(e,"description")||(c?$r(e,"rationale"):"")||u,t),h=e.toolKind&&e.toolKind in Y1?e.toolKind:"other",m=O7[h],g=e.name===cw,y=h!=="other"||Ig.has(e.name),w=e.name===e.title||e.name===Ai||e.name===tS,v=c?c.server:f&&(y||w||e.name===$a)?"":e.name,_=v&&v.toLowerCase()!==m?v:f?"":m,x=(h==="execute"||h==="other")&&n?W7(n):void 0;return{label:g?"ask":m,name:_,icon:Ig.get(e.name)??Ig.get(e.title??"")??x??(c&&h==="other"?"cube":Y1[h]),hint:f===_?"":f,command:n&&n!==f?n:""}}const Y7=/^Async agent launched/m;function X7(e){if(!e.subagent)return!1;const t=e.input;return!!e.detached||(t==null?void 0:t.run_in_background)===!0||!!e.output&&Y7.test(e.output)}const Q7={read:"choosing a file",edit:"writing the change",delete:"choosing a file",move:"choosing the files",search:"writing the search",execute:"writing the command",fetch:"writing the url"};function J7(e){const t=e.toolKind;return e.subagent?$r(e,"prompt")?"":"writing the brief":!Ch(e.input)||!sS({name:e.name,kind:t},e.input)?"":dw(t)?Q7[t]:"writing the question"}function Hk(e,t){const n=_$(t),r=n[0],o=$r(e,"description");return o&&r&&!r.code&&r.text===o?n.slice(1):n}function rc(e){return S$(e)||$r(e,"path")}function eH(e){return $r(e,"description")}function S$(e){return $r(e,"file_path")||$r(e,"filepath")||$r(e,"filePath")||tH(e)}function tH(e){const t=e.input,n=Array.isArray(t==null?void 0:t.locations)?t.locations[0]:void 0,r=n&&typeof n=="object"?n.path:void 0;return typeof r=="string"?r:""}function Np(e,t){if(!e.startsWith("/"))return e;for(const n of t)if(n&&e.startsWith(`${n}/`))return e.slice(n.length+1);return e}const nH=/^(`{3,})([\w+#.-]*)\s*$/;function _$(e){var c;const t=[];let n=[],r="",o=!1,s=0;const a=()=>{const u=n.join(`
227
- `).replace(/^\n+|\n+$/g,"");u.trim()&&t.push({code:o,diff:rH(u,r),lang:o?r:"",text:u}),n=[]};for(const u of e.split(`
228
- `)){const f=nH.exec(u),h=((c=f==null?void 0:f[1])==null?void 0:c.length)??0;if(!f||o&&(h<s||f[2])){n.push(u);continue}a(),o=!o,s=o?h:0,r=o?(f[2]??"").toLowerCase():""}return a(),t}function rH(e,t){return t==="diff"||t==="patch"||/^diff --git /m.test(e)||/^@@ .*@@/m.test(e)?!0:/^--- /m.test(e)&&/^[+-]/m.test(e)}const oH=/^(diff --git |index [0-9a-f]+\.\.|new file mode |deleted file mode |similarity index |rename (from|to) |Binary files )/;function sH(e){const t=[];for(const n of e.split(`
229
- `)){const r=aH(n);if(r==="meta"&&!n.startsWith("diff --git "))continue;const o=r==="add"||r==="del"||n.startsWith(" ");t.push({kind:r,text:o?n.slice(1):n})}return iH(t),t}function iH(e){var t,n,r,o;for(let s=0;s<e.length;){if(((t=e[s])==null?void 0:t.kind)!=="del"&&((n=e[s])==null?void 0:n.kind)!=="add"){s++;continue}let a=s;for(;((r=e[a])==null?void 0:r.kind)==="del";)a++;let c=a;for(;((o=e[c])==null?void 0:o.kind)==="add";)c++;const u=e.slice(s,a),f=e.slice(a,c),h=u.length>0&&f.length>0?QA(u.map(m=>m.text).join(`
230
- `),f.map(m=>m.text).join(`
231
- `)):null;h&&(J1(u,db(h.before)),J1(f,db(h.after)));for(const m of[...u,...f])m.spans??(m.spans=[]);s=c}}function J1(e,t){if(t.length===e.length)for(const[n,r]of e.entries())r.spans=t[n]}function aH(e){return e.startsWith("@@")?"hunk":e.startsWith("+++")||e.startsWith("---")||oH.test(e)?"meta":e.startsWith("+")?"add":e.startsWith("-")?"del":""}function lH(e){const t=e.tools.at(-1);return t.done||t.parentToolId?!1:t.name===Ai?!t.background:!!t.background}const N$=new Set(["read","edit","fetch"]);function Zy(e,t){if(e.isError||!e.toolKind||!N$.has(e.toolKind)||dw(e.toolKind)&&Ch(e.input))return"";const{hint:n}=Lu(e,t);return n?`${e.parentToolId??""}
232
- ${e.toolKind}
233
- ${n}`:""}function eE(e,t,n){if(!t||!("tools"in t)||e.done||e.isError||!e.toolKind||!N$.has(e.toolKind))return!1;const r=t.tools[0];return r.toolKind===e.toolKind&&r.parentToolId===e.parentToolId&&Zy(r,n)!==""}function cH(e,t){const n=e.length-1,r=e[n];if(!r||!("tools"in r)||r.next)return-1;const o=r.tools[0],s=r.tools.at(-1);return o.toolKind!=="edit"||o.parentToolId||!s.done||s.isError?-1:Zy(o,t)?n:-1}function j$(e){const t=new Set;for(const n of e)n.kind==="tool"&&(n.subagent&&t.add(n.id),n.parentToolId&&t.add(n.parentToolId));return t}function uH(e){return!e.done||e.isError?!1:!!e.cut||!e.output&&sS({name:e.name,kind:e.toolKind},e.input)}const tE=new WeakMap;function dH(e,t,n){if(e.name!==$a||e.isError)return e;if(!e.done)return null;if(!Bk(e))return t?e:null;if(!t||!n)return null;let r=tE.get(e);if(!r){const o=Bk(e),{output:s,title:a,toolKind:c,...u}=e;r={...u,name:o.name,input:{},done:!1,...o.kind?{toolKind:o.kind}:{}},tE.set(e,r)}return r}function fH(e,t){return t&&(e==null?void 0:e.kind)==="tool"&&e.name===$a&&e.done&&!e.isError&&Bk(e)!==null}function hH(e,t,n=!1){const r=j$(e),o=[],s=new Map;let a="";for(const[c,u]of e.entries()){if(u.kind!=="tool"){a="",o.push({at:c,item:u});continue}if(uH(u))continue;const f=dH(u,c===e.length-1,n);if(!f)continue;if(r.has(f.id)){a="";const y={at:c,spawn:f,run:[],end:c};s.set(f.id,{entry:y,key:""}),o.push(y);continue}const h=Zy(f,t),m=f.parentToolId?s.get(f.parentToolId):void 0;if(m){const y=m.entry.run,w=y.at(-1);h&&h===m.key&&w?w.tools.push(f):!h&&eE(f,w,t)?w.next=f:y.push({at:c,tools:[f]}),m.key=h,m.entry.end=c;continue}const g=o.at(-1);if(h&&h===a&&g&&"tools"in g){g.tools.push(f);continue}if(!h&&eE(f,g,t)){g.next=f;continue}a=h,o.push({at:c,tools:[f]})}return o}function pH(e){return e.reduce((t,n)=>t+n.tools.length,0)}function mH(e){const t=new Set,n=new Set;let r=!0;for(let s=e.length-1;s>=0;s--){const a=e[s];if(a.kind!=="tool"||!a.parentToolId){r=!1;continue}n.add(a.parentToolId),(r||!a.done)&&t.add(a.parentToolId)}let o=!0;for(let s=e.length-1;s>=0;s--){const a=e[s];Hu(a)&&(o=!1),!(a.kind!=="tool"||!a.subagent)&&(a.isError?t.delete(a.id):a.done?X7(a)?o&&!n.has(a.id)&&t.add(a.id):t.delete(a.id):t.add(a.id))}return t}function gH(e,t){const n=[],r=[];let o=-1;for(const s of e)"spawn"in s?t.has(s.spawn.id)?n.push(s):(o=Math.max(o,s.end),r.push({key:o,entry:s})):"tools"in s&&lH(s)?n.push(s):r.push({key:s.at,entry:s});return r.sort((s,a)=>s.key-a.key),{flow:r.map(s=>s.entry),floating:n}}function kH(e,t=!1){const n=j$(e);return fH(e.at(-1),t)?!0:e.some(r=>r.kind==="tool"&&!r.done&&!r.parentToolId&&!r.background&&r.name!==$a&&(!n.has(r.id)||Ch(r.input)))}function T$(e,t=!1){const n=new Set;let r=!1,o=!1;return e.forEach((s,a)=>{if(!("tools"in s)||!t&&s.tools[0].parentToolId)return;const c=s.tools.at(-1);if(c.done||c.background||c.name===Ai)return;const u=oS({name:c.name,kind:c.toolKind});(o||r&&u)&&n.add(a),r=!0,o||(o=u)}),n}function wH(e){return e.findIndex(t=>!t.tools.at(-1).done)}function Gy(e,t){return e.length===t.length&&e.every((n,r)=>n===t[r])}function $$(e,t){return!e||!t?e===t:e.length===t.length&&e.every((n,r)=>{var o,s;return n.at===((o=t[r])==null?void 0:o.at)&&n.next===((s=t[r])==null?void 0:s.next)&&Gy(n.tools,t[r].tools)})}function yH(e,t){if(e.length===0)return t;const n=new Map;for(const s of e)n.set(s.at,s);let r=e.length===t.length;const o=t.map((s,a)=>{const c=n.get(s.at),u=c!==void 0&&vH(c,s)?c:s;return u!==e[a]&&(r=!1),u});return r?e:o}function vH(e,t){return"spawn"in e?"spawn"in t&&e.spawn===t.spawn&&e.end===t.end&&$$(e.run,t.run):"tools"in e?"tools"in t&&e.next===t.next&&Gy(e.tools,t.tools):"item"in t&&e.item===t.item}function bH(e){for(let t=e.length-1;t>=0;t--){const n=e[t];if(!("spawn"in n)){if("tools"in n){const r=n.tools[0];if((r==null?void 0:r.toolKind)==="think"&&!E$(r))return t;continue}if(n.item.kind==="thinking"){if(!n.item.text.trim())continue;return k$(n.item.text)?-1:t}if(xH(n.item))return-1}}return-1}function xH(e){return e.kind==="assistant"?!!e.text.trim():e.kind==="ask"?e.ask.kind==="question"||!!e.outcome:!0}function EH(e,t){for(let n=e.length-1;n>=0;n--){const r=e[n];if("seq"in r&&r.seq!==void 0&&r.seq<=t)return n}return-1}function jp(e,t,n,r={}){var s;if(!t)return[];const o=[];for(const a of e){const c=a.worktree;if(c.repoId!==t||c.id===n||c.kind!=="worktree")continue;const u=(s=r[c.id])==null?void 0:s.op;o.push({id:c.id,title:c.title,branch:c.branch,dir:c.path.slice(c.path.lastIndexOf("/")+1),dot:T_(a,u),state:$_(a,u),at:Ca(c)})}return o}function C$(e,t){const n=e.trim();if(!n||/\s/.test(n))return null;const r=t.find(o=>o.branch===n||o.dir===n);return r?`@${r.title} `:null}function SH(e,t){return/[/-]/.test(e)?C$(e,t):null}const nE=e=>e.toLowerCase().replace(/[^a-z0-9]/g,"");function rE(e,t){const n=nE(e);if(!n)return!e.trim();const r=/\s$/.test(e);return[t.title,t.branch].some(o=>{const s=nE(o);return s.includes(n)&&(!r||!s.endsWith(n))})}function Qr({id:e,title:t,inert:n}){const r=Qe(),o=dt(),s=L(w=>w.visible),a=L(w=>w.shipping),c=L(w=>Kt(w,e)),u=L(w=>c?null:Object.values(w.archived).flat().find(v=>v.id===e)??null),f=E.useMemo(()=>c?jp(s,c.worktree.repoId,null,a).find(w=>w.id===e)??null:null,[s,a,c,e]),h=(f==null?void 0:f.branch)??(u==null?void 0:u.branch);if(!h)return d.jsx("span",{children:t??e});const m=Ep(f??{title:(u==null?void 0:u.title)??t??h,archived:!0,branch:h}),g=Lt(m.text,void 0,{placement:"follow",dot:m.dot,detail:m.detail}),y=kp({kind:"worktree",id:e,archived:!f},null,{sock:r,dispatch:o});return d.jsxs("span",{className:"chat-mention","data-worktree":e,"data-branch":h,"data-archived":f?void 0:"",...g,onClick:n?void 0:w=>{w.stopPropagation(),y==null||y()},children:["@",m.text,m.dot&&d.jsx("span",{className:"chat-mention-dot",children:d.jsx("span",{className:`dot ${m.dot}`})})]})}function _H(e){const t=e.body??"";return e.note?`${t.trimEnd()}
234
-
235
- ---
236
-
237
- You added: ${e.note}
238
- `:t}function NH({item:e,worktreeId:t,marked:n,children:r}){Qe();const o=dt(),s=e.via==="plan",a=()=>{if(s&&e.path&&t){Pn({dispatch:o},{worktreeId:t,path:e.path,view:"preview"});return}o({a:"open-loose",v:{worktreeId:t??e.origin.id,name:`${e.origin.title}.md`,text:_H(e),binary:!1,tooLarge:!1,source:{kind:"text"},seq:_o()}})};return d.jsx(lr,{icon:"handoff",word:s?"plan":"piece",tone:"accent",at:e.ts,"data-state":gr({cursor:n}),below:[e.note?`you added: ${e.note}`:void 0,r],children:d.jsxs("span",{className:"daemon-text",children:["from ",d.jsx(Qr,{id:e.origin.id,title:e.origin.title}),e.origin.project?` in ${e.origin.project}`:""," · ",d.jsx(Oe,{variant:"inline","data-tip":s?"Read the plan this worktree was given, beside the chat":"Read the message beside the chat",onClick:a,children:s?"the plan":"the message"})]})})}function oE({item:e,worktreeId:t}){var y;Qe();const n=dt();if(e.state==="held"||e.state==="proposed")return null;const r=e.plan,o=r&&t?d.jsx(Oe,{variant:"inline",onClick:()=>Pn({dispatch:n},{worktreeId:t,path:r,view:"preview"}),children:e.companion?"the plan":"the list"}):null;if(e.state==="going"){const w=g6(e);return d.jsx(lr,{icon:"handoff",word:"handed off",tone:"accent",at:e.ts,children:d.jsx("span",{className:"daemon-text",children:w.length===0?d.jsx("span",{className:"live-text",children:"starting"}):w.map((v,_)=>d.jsxs(E.Fragment,{children:[_>0&&(_===w.length-1?" and ":", "),v.worktreeId?d.jsx(Qr,{id:v.worktreeId,title:v.title}):d.jsxs("span",{className:"handoff-wait",children:[v.title,d.jsx("span",{className:"dot idle"})]}),v.repoName?` in ${v.repoName}`:""]},v.pieceId))})})}if(e.state==="declined")return d.jsx(lr,{icon:"close",word:"not handed off",tone:"quiet",at:e.ts,below:e.reason,children:d.jsxs("span",{className:"daemon-text",children:["nothing started",o&&d.jsxs(d.Fragment,{children:[" · ",o]})]})});const s=w=>e.pieces.find(v=>v.id===w),a=w=>{var v;return((v=s(w))==null?void 0:v.title)??w},c=e.outcomes.filter(w=>w.fate==="worktree"&&w.worktreeId),u=e.outcomes.filter(w=>w.fate==="worktree"&&w.after),f=e.outcomes.filter(w=>w.fate==="send"&&w.worktreeId),h=e.outcomes.filter(w=>w.fate==="here").length,m=e.outcomes.filter(w=>w.error),g=[];for(const w of c)g.push(d.jsxs("span",{children:[d.jsx(Qr,{id:w.worktreeId,title:w.title??a(w.pieceId)}),w.repoName?` in ${w.repoName}`:""]},w.pieceId));for(const w of u){const v=(y=s(w.pieceId))==null?void 0:y.after;g.push(d.jsxs("span",{children:[a(w.pieceId)," queued after"," ",v&&"id"in v?v.id===t?"this branch":d.jsx(Qr,{id:v.id,title:v.branch}):w.after]},w.pieceId))}for(const w of f)g.push(d.jsxs("span",{children:[a(w.pieceId)," sent to ",d.jsx(Qr,{id:w.worktreeId,title:w.title}),w.repoName?` in ${w.repoName}`:""]},w.pieceId));return h&&g.push(d.jsx("span",{children:`${h} here`},"here")),d.jsx(lr,{icon:"handoff",word:"handed off",tone:"accent",at:e.ts,below:m.length?m.map(w=>`${a(w.pieceId)}: ${w.error}`).join("; "):void 0,children:d.jsxs("span",{className:"daemon-text",children:[g.length===0?"nothing started":g.map((w,v)=>d.jsxs("span",{children:[v>0&&", ",w]},v)),o&&d.jsxs(d.Fragment,{children:[" · ",o]})]})})}function jH({item:e}){return e.worktreeId?d.jsx(lr,{icon:"handoff",word:"handed off",tone:"accent",at:e.ts,children:d.jsxs("span",{className:"daemon-text",children:[d.jsx(Qr,{id:e.worktreeId,title:e.title??"the worktree"})," started, its branch having landed"]})}):d.jsx(lr,{icon:"close",word:"dropped",tone:"quiet",at:e.ts,below:e.reason,children:d.jsx("span",{className:"daemon-text",children:e.title??"a queued worktree"})})}function TH({item:e}){return d.jsx(lr,{icon:"check",word:e.again?"landed again":"landed",tone:"aqua",at:e.ts,children:d.jsxs("span",{className:"daemon-text",children:[e.same?d.jsx(Qr,{id:e.worktreeId,title:e.title}):`${e.title} in ${e.repoName}`,e.awaited&&", which the work here waited for",e.url&&d.jsxs(d.Fragment,{children:[" ","·"," ",d.jsx(Oe,{variant:"inline",onClick:()=>window.open(e.url,"_blank"),children:"the PR"})]})]})})}function Tp({src:e,n:t,name:n,width:r,height:o,bytes:s,kept:a,uploading:c,progress:u,onRemove:f,className:h=""}){const m=Qe();return d.jsx(Ay,{className:Ke("image-chip",h),label:d.jsxs(d.Fragment,{children:[d.jsx("img",{className:"image-thumb",src:e,alt:n,width:40,height:40}),d.jsxs("span",{className:"pick-target",children:[d.jsx("b",{children:uS("image",t)}),d.jsxs("span",{className:"pick-file row-dim",children:[" ","· ",n," · ",r,"×",o," · ",mw(s),u!==void 0?d.jsxs(d.Fragment,{children:[" ","· ",d.jsxs("span",{className:"pick-progress",children:[u,"%"]})]}):c&&" · uploading"]})]})]}),peek:d.jsx("img",{src:e,alt:n,style:{aspectRatio:`${r} / ${o}`}}),full:d.jsx("img",{src:e,alt:n}),menu:g=>Ra(e,g,a&&{...a,sock:m}),removeLabel:"Remove image",onRemove:f})}function $H({img:e,worktreeId:t,src:n}){return d.jsx(Tp,{className:"in-chat",src:n,...e,kept:{worktreeId:t,file:e.file}})}function mu({pieces:e}){return d.jsx(d.Fragment,{children:e.map((t,n)=>{if(t.scope===xp)return d.jsx("a",{className:t.changed?"ch":void 0,href:t.text,target:"_blank",rel:"noreferrer",children:t.text},n);const r=`${t.changed?"ch ":""}${t.scope?`sy-${t.scope}`:""}`.trim();return r?d.jsx("span",{className:r,children:t.text},n):d.jsx(E.Fragment,{children:t.text},n)})})}function CH({code:e,lang:t}){const n=vp(t.toLowerCase(),""),r=n?yh(bp(e,n)):Hy(e);return d.jsx("pre",{children:d.jsx("code",{children:r.length?r.map((o,s)=>d.jsxs(E.Fragment,{children:[s>0&&`
239
- `,d.jsx(mu,{pieces:o})]},s)):e})})}const IH=/(^|\s)@\S/;function Pu({text:e,worktreeId:t,root:n,inField:r}){const o=Dn(),s=Qe(),a=L(v=>{var _;return t?(_=v.local[t])==null?void 0:_.files:void 0}),c=L(v=>v.visible),u=L(v=>v.shipping),f=L(v=>{var _;return(_=Kt(v,t))==null?void 0:_.worktree.repoId}),h=L(v=>f?v.archived[f]:void 0),m=E.useMemo(()=>o$(jp(c,f,t,u),h),[c,u,h,f,t]),g=E.useMemo(()=>r$(a,m),[a,m]),y=E.useMemo(()=>Wy(e,g),[e,g]),w=a===void 0&&t&&IH.test(e)?t:null;return E.useEffect(()=>{w&&cp(w,o.getState(),{sock:s,dispatch:o.dispatch})},[w,o,s]),d.jsx(d.Fragment,{children:y.map((v,_)=>{if(v.kind==="text")return v.text;if(v.kind==="code"){if(r)return v.text;const j=zT(v.code),A=d.jsx("code",{children:v.code},_);return j?d.jsx("a",{className:"chat-url",href:j,target:"_blank",rel:"noreferrer",children:A},_):A}if(v.kind==="block")return r?v.text:d.jsx(CH,{code:v.code,lang:v.lang},_);if(v.kind==="url")return d.jsx("a",{className:"chat-url",href:v.href,target:"_blank",rel:"noreferrer",tabIndex:r?-1:void 0,children:v.text},_);if(v.kind==="changes"){const j=Lt("this worktree's uncommitted files",void 0,{placement:"follow"});return d.jsx("span",{className:"chat-mention","data-changes":"",...j,children:v.text},_)}if(v.kind==="worktree"){const j=Ep(v),A=Lt(j.text,void 0,{placement:"follow",dot:j.dot,detail:j.detail});return d.jsx("span",{className:"chat-mention","data-worktree":v.id,"data-branch":v.branch,"data-archived":v.archived?"":void 0,...A,children:r?v.text:d.jsxs(d.Fragment,{children:["@",j.text,j.dot&&d.jsx("span",{className:"chat-mention-dot",children:d.jsx("span",{className:`dot ${j.dot}`})})]})},_)}if(!n||!t)return v.text;const x=v.kind==="folder",N=`${n}/${v.path}${x?"/":""}`,T=Lt(x?`${v.path}/`:v.path,void 0,{placement:"follow"});return d.jsx("a",{className:"chat-mention",href:N,tabIndex:r?-1:void 0,...T,children:v.text},_)})})}function Du(e,t,n,r){if(e.target.closest("[data-changes]")){n&&r.dispatch({a:"focus-changes",tab:"changes"});return}Iy(e,t,n,r)}function AH(e){return e.length<2||!e.every(t=>{var n;return t.length===1&&((n=t[0])==null?void 0:n.diff)})?null:OH(e.map(t=>t[0].text))}const RH=/^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@/;function OH(e,t=3){let n=[];for(const r of e){const o=MH(r);if(!o)return null;const s=LH(n,o);if(!s)return null;n=s}return n.some(r=>r.kind!=="same")?PH(n,t):null}function MH(e){const t=[];let n=null;for(const r of e.split(`
240
- `)){const o=RH.exec(r);if(o){n={oldStart:Number(o[1]),newStart:Number(o[2]),ops:[]},t.push(n);continue}if(!n)return null;const s=r[0];if(s===" "||s==="-"||s==="+")n.ops.push({mark:s,text:r.slice(1)});else if(r==="")n.ops.push({mark:" ",text:""});else return null}return t.length>0?t:null}function LH(e,t){const n=[];let r=0,o=0,s=0,a=0;const c=h=>{h.kind==="same"?o=h.a-h.c:h.kind==="add"?o-=1:o+=1},u=()=>{for(;r<e.length&&e[r].kind==="del";)n.push(e[r]),c(e[r]),r++},f=h=>{for(let m=h;m<e.length;m++){const g=e[m];if(g.kind!=="del")return g.c}return Number.POSITIVE_INFINITY};for(const h of t){if(h.oldStart<=a)return null;for(;r<e.length;){const y=e[r];if((y.kind==="del"?f(r):y.c)>=h.oldStart)break;n.push(y.kind==="del"?y:{...y,c:y.c+s}),c(y),r++}let m=h.oldStart,g=h.newStart;for(const y of h.ops){if(u(),y.mark==="+"){n.push({kind:"add",c:g,text:y.text}),g++;continue}const w=e[r],v=w&&w.kind!=="del"&&w.c===m?w:void 0;if(v){if(v.text!==y.text)return null;r++,c(v),y.mark===" "?n.push({...v,c:g}):v.kind==="same"&&n.push({kind:"del",a:v.a,text:v.text})}else y.mark===" "?n.push({kind:"same",a:m+o,c:g,text:y.text}):n.push({kind:"del",a:m+o,text:y.text});y.mark===" "&&g++,m++}s=g-m,a=m-1}for(;r<e.length;r++){const h=e[r];n.push(h.kind==="del"?h:{...h,c:h.c+s})}return n}function PH(e,t){const n=[];for(const r of zH(e))for(const[o,s]of FH(r.rows,t)){const a=DH(r.rows.slice(o,s)),c=a.filter(m=>m.kind!=="add").length,u=a.filter(m=>m.kind!=="del").length,f=a.find(m=>m.kind!=="add"),h=a.find(m=>m.kind!=="del");n.push(`@@ -${f?f.a:r.oldAt[o]},${c} +${h?h.c:r.newAt[o]},${u} @@`,...a.map(m=>`${m.kind==="add"?"+":m.kind==="del"?"-":" "}${m.text}`))}return n.join(`
241
- `)}function DH(e){const t=[];for(let n=0;n<e.length;){if(e[n].kind==="same"){t.push(e[n]),n++;continue}let r=n;for(;r<e.length&&e[r].kind!=="same";)r++;const o=e.slice(n,r);t.push(...o.filter(s=>s.kind==="del"),...o.filter(s=>s.kind==="add")),n=r}return t}function zH(e){const t=[];let n=null,r=1,o=1;for(const s of e){const a=s.kind==="add"?r:s.a,c=s.kind==="del"?o:s.c;(!n||a!==r||c!==o)&&(n={rows:[],oldAt:[],newAt:[]},t.push(n)),n.rows.push(s),n.oldAt.push(a),n.newAt.push(c),r=a+(s.kind==="add"?0:1),o=c+(s.kind==="del"?0:1)}return t}function FH(e,t){const n=[];let r=0;for(;r<e.length;){if(e[r].kind==="same"){r++;continue}let o=r,s=r;for(;s<e.length;){if(e[s].kind!=="same"){o=s,s++;continue}let a=0;for(;s+a<e.length&&e[s+a].kind==="same";)a++;if(a>t*2||s+a>=e.length)break;s+=a}n.push([Math.max(0,r-t),Math.min(e.length,o+t+1)]),r=o+t+1}return n}function $p({pick:e,worktreeId:t,tipText:n,onHover:r,onOpen:o,onRemove:s,className:a=""}){const c=e.callFile,u=e.file,f=c?{path:c,line:e.callLine}:u?{path:u,line:e.line}:null,h=c&&u?{path:u,line:e.line}:null,m=(N,T)=>`${N}${T?`:${T}`:""}`,g=N=>N.split("/").pop()??N,y=(N,T,j,A)=>o?d.jsx("button",{className:"pick-open","data-tip":A,onClick:()=>o(N,T??1),children:j}):j,w=vn("chat"),{host:v}=Lr(),_=E.useRef(null),x=s?()=>{r==null||r(!1),s()}:void 0;return d.jsxs("div",{ref:_,className:Ke("pick-chip row row-sm",a),"data-tip":n,onMouseEnter:()=>r==null?void 0:r(!0),onMouseLeave:()=>r==null?void 0:r(!1),...w.contextMenu(()=>P8(e,{remove:x,host:v})),children:[d.jsxs("span",{className:"pick-target",children:[d.jsx(kt,{name:"pick",className:"icon-inline"})," ",Uw(e),f&&d.jsxs("span",{className:"pick-file row-dim",children:[" ","· ",y(f.path,f.line,m(g(f.path),f.line),`Open ${m(f.path,f.line)}`)]}),h&&d.jsxs("span",{className:"pick-file row-dim",children:[" ","·"," ",y(h.path,h.line,m(h.path.split("/").pop()??h.path,h.line),`Open the component: ${m(h.path,h.line)}`)]})]}),x&&d.jsx(At,{icon:"close",label:"Remove attachment",tone:"quiet",onClick:x}),t&&(f==null?void 0:f.line)&&d.jsx(xT,{chip:_,children:d.jsx(HH,{worktreeId:t,path:f.path,line:f.line})})]})}const BH=6,UH=16;function HH({worktreeId:e,path:t,line:n}){const r=Jw(),o=Qe(),s=L(m=>{var g;return((g=Uo(m))==null?void 0:g.id)===e}),a=L(m=>{var g;return s?0:(g=Mr(m,e).changedRanges[t])==null?void 0:g.offset}),[c,u]=E.useState(null);E.useEffect(()=>{let m=!0;return s||o==null||o.send({t:"changed-ranges",worktreeId:e,path:t}),r==null||r.look(e,t).then(g=>{m&&u(g)}),()=>{m=!1}},[r,o,e,t,s]);const f=E.useMemo(()=>{if(c===null||a===void 0)return null;const m=c.split(`
242
- `),g=n-a,y=Math.max(1,g-BH),w=Math.min(m.length,g+UH);if(y>w)return null;const v=m.slice(y-1,w);return{from:y,at:g,slice:v,painted:bp(v.join(`
243
- `),vp("",t))}},[c,a,n,t]);if(!f)return null;const h=String(f.from+f.slice.length-1).length;return d.jsx("pre",{className:"pick-peek",children:f.slice.map((m,g)=>{const y=f.from+g,w=f.painted[g];return d.jsxs("span",{className:"pick-peek-line","data-state":y===f.at?"current":void 0,children:[d.jsx("span",{className:"pick-peek-n",children:String(y).padStart(h)}),w!=null&&w.length?d.jsx(mu,{pieces:w}):m||" "]},y)})})}function WH(e){return e.startsWith("!")?e.slice(1).trim():null}function Vy(e){if(e.kind!=="tool"||e.name!==Ai&&e.name!==tS)return null;const t=e.input;return typeof(t==null?void 0:t.command)=="string"?t.command:null}function I$(e){var t;return e.kind!=="tool"||e.name!==Ai||(t=e.input)!=null&&t.landing?null:Vy(e)}function KH(e){return e.length>0&&e.every(t=>t.kind==="tool"&&I$(t)!==null&&t.done&&!t.isError)}function qH(e){const t=[],n=new Set(e.flatMap(r=>r.kind==="asked"&&r.toolId?[r.toolId]:[]));for(let r=e.length-1;r>=0;r--){const o=e[r];if(Hu(o))break;if(o.kind!=="tool"||!o.done||n.has(o.id))continue;const s=Vy(o);if(s===null)continue;const a=_$(o.output??"").map(u=>u.text).join(`
244
- `),c=NP(a);t.unshift(`$ ${s}${c?`
245
- ${c}`:""}`)}if(t.length!==0)return`Shell commands the user ran since their last message, and what each printed:
246
- ${t.join(`
247
- `)}`}const sE={diff:"Open this file's diff in the editor pane",file:"Open this file in the editor pane",preview:"Read this file rendered in the editor pane"};function A$(e,t,n,r,o){const s=e[0];if(!s||!n)return[];const a=Np(o||rc(s),t);return a?a.startsWith("/")?[{label:"open",tip:sE.file,open:()=>Rk(r,n.id,{href:a,path:a})}]:[...Li(a)==="preview"?["preview"]:[],...s.toolKind==="edit"?["diff"]:[],"file"].map(u=>({label:`open ${u}`,tip:sE[u],open:()=>Pn(r,{worktreeId:n.id,path:a,view:u})})):[]}const ZH=(...e)=>A$(...e)[0]??null;function GH(e,t,n,r,o,s,a){const{sock:c}=r,u=e[0];if(!u)return[];const f=s?gT(s):[],h=[],m=Np(a||rc(u),t),g=A$(e,t,n,r,a).map(T=>({id:T.label.replace(" ","-"),label:T.label,onClick:T.open}));m&&!m.startsWith("/")&&n?h.push(...g,...Ho(()=>c==null?void 0:c.send({t:"reveal",worktreeId:n.id,path:m}),po(c))):m.startsWith("/")&&h.push(...g,...Ho(()=>c==null?void 0:c.send({t:"reveal-path",path:m}),po(c)));const y=[],w=a||rc(u);m&&w&&y.push({id:"copy-path",label:"copy path",onClick:()=>tn(w)});const v=Lu(u,t).command,_=eH(u);_&&_!==v&&y.push({id:"copy-description",label:"copy description",onClick:()=>tn(_)}),v&&y.push({id:"copy-command",label:"copy command",onClick:()=>tn(v)});const x=e.map(T=>T.output??"").filter(Boolean).join(`
248
- `);x&&y.push({id:"copy-output",label:"copy output",onClick:()=>tn(x)});const N=o.leaf?[]:[{id:"fold",label:o.open?"collapse":"expand",onClick:o.toggle}];return Wn([f,h,y,N])}const R$=e=>e.replace(/\n$/,""),VH=1500,iE=4;function O$(e){return e.closest(".md pre, .card-code pre")}function Wk(e){const t=O$(e);return t?R$(t.textContent??""):null}function YH(e,t){const n=e.getBoundingClientRect(),r=t.getBoundingClientRect();return{pre:t,top:r.top-n.top+e.scrollTop+iE,right:n.left+e.clientLeft+e.clientWidth-r.right+iE}}function Yy(e){const[t,n]=E.useState(null),[r,o]=E.useState(null);if(E.useEffect(()=>{const f=e.current;if(!f)return;const h=g=>{if(!(g.target instanceof Element)||g.target.closest(".code-copy"))return;const y=O$(g.target);n(y&&f.contains(y)?YH(f,y):null)},m=()=>n(null);return f.addEventListener("pointerover",h),f.addEventListener("pointerleave",m),()=>{f.removeEventListener("pointerover",h),f.removeEventListener("pointerleave",m)}},[e]),E.useEffect(()=>{if(!r)return;const f=setTimeout(()=>o(null),VH);return()=>clearTimeout(f)},[r]),!(t!=null&&t.pre.isConnected))return null;const{pre:s,top:a,right:c}=t,u=r===s;return d.jsx(At,{className:"code-copy",style:{top:a,right:c},icon:u?"check":"copy",label:u?"Copied":"Copy code",onClick:()=>{tn(R$(s.textContent??"")),o(s)}})}function XH(e){for(const t of e.split(`
249
- `)){const n=/^#{1,6}\s+(.+?)\s*#*\s*$/.exec(t);if(n)return n[1];if(t.trim()&&!t.startsWith("<!--"))return null}return null}function QH(e){return e.slice(e.lastIndexOf("/")+1).replace(/\.md$/,"")}const Af=new Map;function Xy(e,t){var c;const n=Jw(),r=(c=It(e,"git"))==null?void 0:c.version,o=e&&t?`${e}
250
- ${t}`:null,[,s]=E.useState(0);return at([n,e,t,r],()=>{if(!n||!o||!e||!t)return;let u=!0;return n.look(e,t).then(f=>{if(!u||f===null)return;const h=XH(f);Af.has(o)&&Af.get(o)===h||(Af.set(o,h),s(m=>m+1))}),()=>{u=!1}}),(o?Af.get(o)??null:null)??(t?QH(t):"")}function M$(e){const t=L(r=>{var o;return(o=Kt(r,e))==null?void 0:o.worktree.repoId}),n=L(r=>t?r7(r,t):"");return E.useMemo(()=>n?o7(n):void 0,[n])}function Ag({text:e,menu:t,marked:n,worktreeId:r,fileRoot:o,streaming:s,pictures:a}){const c=M$(r),u=Lr(),f=E.useMemo(()=>r&&(a!=null&&a.length)?{worktreeId:r,urls:u,pictures:a}:void 0,[r,u,a]),h=td(e,{fileRoot:o,streaming:s,worktrees:c,stills:f}),m=Qe(),g=dt(),y=vn("chat"),[w,v]=E.useState(null),_=A=>{const R=A.closest("button.md-still"),C=R==null?void 0:R.querySelector("img");return R&&C&&r?{src:C.src,alt:C.alt,file:R.dataset.file??"",kept:{worktreeId:r,file:R.dataset.file??"",sock:m}}:null},x=E.useRef(null);kN(x,h);const N=L(A=>{var R;return r?(R=A.local[r])==null?void 0:R.refusedLink:void 0});at([h,N],()=>{var R;const A=x.current;if(A)for(const C of A.querySelectorAll("a.file-link, code[data-path]")){const M=C.getAttribute("href")??C.dataset.path,I=N!==void 0&&M===N.href;C.classList.toggle("file-link-refused",I),I?((R=C.dataset).tipWas??(R.tipWas=C.dataset.tip??""),C.dataset.tip=N.message,C.dataset.tipPlacement="bottom",C.dispatchEvent(new MouseEvent("mouseover",{bubbles:!0}))):C.dataset.tipWas!==void 0&&(C.dataset.tipWas?(C.dataset.tip=C.dataset.tipWas,C.dataset.tipPlacement="follow"):(delete C.dataset.tip,delete C.dataset.tipPlacement),delete C.dataset.tipWas)}});const T=E.useRef(null),j=Yy(T);return d.jsxs("div",{ref:T,className:"msg-assistant md row-edge","data-state":gr({cursor:n}),...y.contextMenu((A,R)=>{const C=_(R);return C?Ra(C.src,{open:()=>v(C)},C.kept):t(wp(R,o),Wk(R),A)}),onClick:A=>{const R=_(A.target);R?v(R):Iy(A,o,r,{sock:m,dispatch:g})},children:[d.jsx("div",{ref:x}),j,w&&r&&d.jsx(Qu,{owner:"chat",onClose:()=>v(null),menu:()=>Ra(w.src,{},{worktreeId:r,file:w.file,sock:m}),children:d.jsx("img",{src:w.src,alt:w.alt})})]})}const Rg=40;function L$(e,t,n=!1){return e.map((r,o)=>{const s=vp(r.lang,t||(r.diff?LU(r.text):"")),a=r.diff?sH(r.text):[];let c=r.diff?yh(zU(a,s)):r.code&&s?yh(bp(r.text,s)):Hy(r.text);return n&&o===e.length-1&&(c=n$(c)),{...r,lines:a,painted:c}})}function P$({blocks:e,path:t,worktreeId:n}){Qe();const r=dt();return d.jsx("div",{className:"tool-out",children:e.map((o,s)=>o.diff?d.jsxs("pre",{className:"tool-block diff",children:[o.lines.slice(0,Rg).map((a,c)=>{var u;return a.kind==="hunk"?d.jsx("span",{className:"dl hunk",title:a.text},c):d.jsx("span",{className:`dl ${a.kind}`,children:(u=o.painted[c])!=null&&u.length?d.jsx(mu,{pieces:o.painted[c]}):a.text||" "},c)}),o.lines.length>Rg&&d.jsxs("button",{type:"button",className:"dl more",disabled:!t||!n,"data-tip":t&&n?"Open this file's diff":void 0,onClick:()=>n&&Pn({dispatch:r},{worktreeId:n,path:t,view:"diff"}),children:[o.lines.length-Rg," more lines"]})]},s):o.code?d.jsx("pre",{className:"tool-block",children:o.painted.length?o.painted.map((a,c)=>d.jsxs(E.Fragment,{children:[c>0?`
251
- `:null,d.jsx(mu,{pieces:a})]},c)):o.text},s):d.jsx("p",{className:"tool-note",children:o.painted.length?o.painted.map((a,c)=>d.jsxs(E.Fragment,{children:[c>0?`
252
- `:null,d.jsx(mu,{pieces:a})]},c)):o.text},s))})}function JH({image:e,worktreeId:t}){const n=Lr().attachment(t,e.file),r={worktreeId:t,file:e.file,sock:Qe()},[o,s]=E.useState(!1),a=vn("chat");return d.jsxs(d.Fragment,{children:[d.jsx("button",{type:"button",className:"tool-image","data-tip":"Open full size","data-tip-placement":"follow",onClick:()=>s(!0),...a.contextMenu(()=>Ra(n,{open:()=>s(!0)},r)),children:d.jsx("img",{src:n,alt:e.file})}),o&&d.jsx(Qu,{owner:"chat",onClose:()=>s(!1),menu:()=>Ra(n,{},r),children:d.jsx("img",{src:n,alt:e.file})})]})}const eW=E.memo(function({item:t,roots:n,worktreeId:r}){const o=E.useMemo(()=>L$(Hk(t,t.output??""),rc(t),!t.done),[t]),s=Lu(t,n).command,a=r?t.images??[]:[];return!s&&o.length===0&&a.length===0?null:d.jsxs("div",{className:"tool-part",children:[s&&d.jsx("pre",{className:"tool-block cmd",children:s}),o.length>0&&d.jsx(P$,{blocks:o,path:D$(t,n),worktreeId:r}),a.length>0&&r&&d.jsx("div",{className:"tool-out",children:a.map(c=>d.jsx(JH,{image:c,worktreeId:r},c.file))})]})});function D$(e,t){const n=Np(rc(e),t??[]);return n.startsWith("/")?"":n}const tW=E.memo(function({text:t,item:n,roots:r,worktreeId:o}){const s=rc(n),a=E.useMemo(()=>L$([{code:!0,diff:!0,lang:"diff",text:t}],s),[t,s]);return d.jsx("div",{className:"tool-part",children:d.jsx(P$,{blocks:a,path:D$(n,r),worktreeId:o})})});function Kk({className:e,state:t,auto:n,leaf:r,growing:o,label:s,summary:a,menu:c,children:u}){const[f,h]=E.useState(null),m=E.useRef(null),g=E.useRef(null),y=gN(g),w=o3(".chat-log"),v=!r&&(f??n),[_,x]=E.useState(v);E.useEffect(()=>{v&&x(!0)},[v]);const N=()=>{r||(v||w(m.current),h(!v))},T=vn("chat");return d.jsxs("details",{ref:m,className:Ke(e,r&&"leaf"),"data-state":t,open:v,onToggle:j=>{if(!j.currentTarget.open||o)return;const A=g.current;A&&(A.scrollTop=0,y.read())},...T.contextMenu((j,A)=>c({open:v,leaf:!!r,toggle:N},A)),tabIndex:-1,onPointerDown:()=>{var j;return(j=m.current)==null?void 0:j.focus({preventScroll:!0})},onKeyDown:j=>{if((j.key==="ArrowLeft"||j.key==="ArrowRight")&&!r){if(j.shiftKey||j.altKey||j.metaKey||j.ctrlKey)return;fp([{depth:0,open:v}],0,j.key)&&N();return}j.key!=="Escape"||!v||(j.stopPropagation(),h(!1))},children:[d.jsx("summary",{"aria-label":s,tabIndex:r?-1:void 0,onClick:j=>{j.preventDefault(),N()},children:a}),d.jsx("div",{className:"tool-body",ref:g,children:v||_?u:null})]})}function z$({text:e,live:t,className:n}){const r=E.useRef(null);return E.useEffect(()=>{const o=r.current;if(!t||!o)return;const s=new ResizeObserver(([a])=>{a&&o.style.setProperty("--line",`${a.contentRect.width}px`)});return s.observe(o),()=>{s.disconnect(),o.style.removeProperty("--line")}},[t]),d.jsx("span",{ref:r,className:Ke("tool-hint",n),children:t?d.jsx("span",{className:"live-text",children:e}):e})}function nW({markdown:e,streaming:t,worktreeId:n,fileRoot:r}){const o=M$(n),s=td(e,r||t||o?{fileRoot:r,streaming:t,worktrees:o}:void 0),a=Qe(),c=dt(),u=E.useRef(null);kN(u,s);const f=E.useRef(null),h=Yy(f);return d.jsx("div",{className:"tool-part",children:d.jsxs("div",{ref:f,className:"tool-out thought-out md",onClick:m=>Iy(m,r,n,{sock:a,dispatch:c}),children:[d.jsx("div",{ref:u}),h]})})}const rW=E.memo(function({item:t,open:n,streaming:r,worktreeId:o,fileRoot:s}){const a=g$(t.text),c=a.slice(0,-1),u=r?"Thinking":"Thought",f=d.jsx(nW,{markdown:a.length?c.join(`
253
-
254
- `):p$(t.text),streaming:r,worktreeId:o,fileRoot:s}),h=a.at(-1)??(r?"":k$(t.text));if(h){const m=c.length===0;return d.jsx(Kk,{className:"tool-row",auto:!1,leaf:m,growing:r,label:h,menu:(g,y)=>Wn([Ok(Wk(y)),[{id:"copy",label:"copy thought",onClick:()=>tn(t.text)}],...m?[]:[[{id:"fold",label:g.open?"collapse":"expand",onClick:g.toggle}]]]),summary:d.jsxs(d.Fragment,{children:[d.jsx(kt,{name:"bulb",className:"tool-icon"}),d.jsx(z$,{className:"thought-line",text:h,live:!!r})]}),children:m?null:f})}return d.jsx(Kk,{className:"tool-row",auto:!!n,growing:r,label:u,menu:(m,g)=>Wn([Ok(Wk(g)),[{id:"copy",label:"copy thought",onClick:()=>tn(t.text)}],[{id:"fold",label:m.open?"collapse":"expand",onClick:m.toggle}]]),summary:d.jsxs(d.Fragment,{children:[d.jsx(kt,{name:"bulb",className:"tool-icon"}),d.jsx("span",{className:Ke("tool-name",r&&"live-text"),children:u})]}),children:f})}),ma=6,oW={land:"the land",commit:"the commit","sync-main":"the sync","pull-main":"the pull"},Rf=E.memo(function e({tools:t,run:n,next:r,live:o,working:s,held:a,since:c,queued:u,roots:f,worktreeId:h,marked:m}){const g=t[0],y=E.useMemo(()=>AH(t.map(K=>Hk(K,K.output??""))),[t]),w=t.at(-1)??g,v=!w.done,_=v&&!!w.background,N=(v||!!r||!!a)&&!u||!!s,T=v&&!!u,j=Ci((v||s)&&!w.until?c:void 0),A=n?wH(n):-1,R=E.useMemo(()=>n?T$(n,!0):void 0,[n]),C=!!o,M=Lu(g,f),I=v?J7(g):"",{label:D,icon:H}=M,Z=E$(g),B=I?"":Z?"Guardian":M.name,J=I&&g.subagent?M.hint:"",V=J||I||(Z?V7(g.output??""):M.hint),ee=!(n&&n.length>0)&&!y&&t.every(K=>{var te;return!Lu(K,f).command&&Hk(K,K.output??"").length===0&&!((te=K.images)!=null&&te.length)}),F=n?pH(n):0,$=KH(t),Q=_?w.until?`wakes ${Qh(w.until)}`:"in the background":"",q=[D,V].filter(Boolean).join(" ")+(Q?`, ${Q}`:"")+(T?", queued":"")+($?", done":""),W=I?"":n?`${F} ${F===1?"call":"calls"}`:t.length>1?`×${t.length}`:"",oe=Dn(),de=Qe(),he=L(K=>{var te;return h?(te=K.shipping[h])==null?void 0:te.op:void 0}),Ne=v&&g.name===Ai&&h?{worktreeId:h,toolId:w.id}:null,Me=L(K=>g.name===uw?w6(Mr(K,h).chat,g.id):void 0),Be=v?null:(()=>{const K=Kt(oe.getState(),h),te={sock:de,dispatch:oe.dispatch};return ZH(t,f??[],K?{id:K.worktree.id}:null,te,Me)})();return d.jsxs(Kk,{className:Ke("tool-row",t.some(K=>K.isError)&&"error",g.parentToolId&&"nested",n&&"spawn",T&&"queued"),state:gr({cursor:m}),auto:C,leaf:ee,growing:N,label:n&&W?`${q}, ${W}`:t.length>1?`${q}, ${t.length} calls`:q,menu:(K,te)=>{const pe=Kt(oe.getState(),h),ue=pe?{id:pe.worktree.id}:null,ie=wp(te,null),ye=(ie==null?void 0:ie.kind)==="out"?ie.href:null;return GH(t,f??[],ue,{sock:de,dispatch:oe.dispatch},K,ye,Me)},summary:d.jsxs(d.Fragment,{children:[d.jsx(kt,{name:n?"spawn":H,className:"tool-icon"}),B&&d.jsx("span",{className:Ke("tool-name",N&&!V&&"live-text"),children:B}),I&&!J?d.jsx("span",{className:"tool-writing","data-tip":V,children:d.jsx(uh,{})}):V&&d.jsx(z$,{text:V,live:N}),Q&&d.jsx("span",{className:"tool-status",children:Q}),T&&d.jsx("span",{className:"tool-status",children:"queued"}),$&&d.jsx(kt,{name:"check",className:"tool-done"}),j>=ma&&d.jsx("span",{className:Ke("tool-age",A>=0&&"tool-age-folded"),children:ba(j)}),W&&d.jsx("span",{className:"tool-count",children:W}),J&&d.jsx("span",{className:"tool-writing","data-tip":I,children:d.jsx(uh,{})}),Ne&&d.jsx(At,{icon:"stop",className:"tool-stop",label:he?`Stop ${oW[he]}: this step is killed, and what it printed so far stays`:_?"Kill what the command left running; what it printed so far stays":"Kill the command and everything it started; what it printed so far stays",onClick:K=>{K.preventDefault(),K.stopPropagation(),de==null||de.send({t:"exec-stop",...Ne})}}),Be&&d.jsx(At,{icon:"eye",className:"tool-open",label:Be.tip,onClick:K=>{K.preventDefault(),K.stopPropagation(),Be.open()}})]}),children:[n&&n.length>0&&d.jsx("div",{className:"spawn-run",children:n.map((K,te)=>d.jsx(e,{tools:K.tools,next:K.next,since:te===A?c:void 0,queued:R==null?void 0:R.has(te),roots:f,worktreeId:h},K.at))}),y?d.jsx(tW,{text:y,item:g,roots:f,worktreeId:h}):t.map(K=>d.jsx(eW,{item:K,roots:f,worktreeId:h},K.id))]})},(e,t)=>e.live===t.live&&e.working===t.working&&e.held===t.held&&e.since===t.since&&e.queued===t.queued&&e.next===t.next&&e.roots===t.roots&&e.worktreeId===t.worktreeId&&e.marked===t.marked&&Gy(e.tools,t.tools)&&$$(e.run,t.run));function sW({item:e}){const t=Qe(),n=dt(),r=L(v=>v.activeId),o=L(v=>v.layout.term),s=L(v=>{var _;return((_=v.rows.find(x=>x.id===v.activeId))==null?void 0:_.login)??!1}),a=L(v=>v.managed.problem),[c,u]=E.useState(""),[f,h]=E.useState(null),m=E.useRef(!1);if(at([s],()=>{s&&m.current&&r&&n({a:"term-stream",id:r,stream:Ds,tall:!0})}),at([e.done],()=>{e.done&&m.current&&o&&n({a:"toggle-terminal"}),m.current=!1}),!r)return null;const g=e.provider==="aws",y=(v,_)=>{t==null||t.send({t:"agent-auth",worktreeId:r,methodId:v,..._?{apiKey:_}:{}})},w=e.methods.find(v=>v.id===f);return d.jsxs("div",{className:`auth-card ${e.done?"done":""}`,children:[d.jsx("div",{className:"auth-title","data-tip":e.done?void 0:e.detail,children:e.done?`${e.agentName} is logged in`:e.provider==="aws"?`${e.agentName}'s AWS session expired`:e.rejected?`${e.agentName}'s credentials were refused`:`${e.agentName} is not logged in`}),!e.done&&d.jsxs("div",{className:"auth-methods",children:[e.methods.map((v,_)=>v.needsKey?d.jsx(Oe,{variant:"outline",on:f===v.id,"data-tip":v.description,onClick:()=>h(f===v.id?null:v.id),children:v.name},v.id):d.jsx(Oe,{variant:"outline",tone:g&&_===0?"primary":void 0,"data-tip":v.kind==="terminal"&&!v.description?"opens in the terminal pane":v.description,onClick:()=>{y(v.id),v.kind==="terminal"&&(m.current=!0)},children:v.name},v.id)),d.jsx(Oe,{variant:g?"ghost":"outline",tone:g?"quiet":void 0,"data-tip":"after logging in elsewhere (the terminal, another window)",onClick:()=>t==null?void 0:t.send({t:"agent-retry",worktreeId:r}),children:"send again"})]}),!e.done&&s&&d.jsx("div",{className:"hint auth-hint",children:e.provider==="aws"?"the login tab below opens the browser to sign in. Your message sends once you are in.":"paste the code into the login tab below and press Enter; it stays hidden as you paste. Your message sends once you are in."}),!e.done&&e.refresh&&d.jsxs("div",{className:"hint auth-hint",children:["your Claude settings refresh it with ",d.jsx("code",{children:e.refresh}),", which got no session this time"]}),!e.done&&e.withheld&&d.jsx("div",{className:"hint auth-hint",children:a?"the policy file on this machine is invalid, so signing in with a Claude plan is off until it is fixed; toyon doctor says why":"signing in with a Claude plan is managed by your organization"}),!e.done&&w&&d.jsxs("form",{className:"auth-key",onSubmit:v=>{v.preventDefault(),c.trim()&&(y(w.id,c.trim()),u(""),h(null))},children:[d.jsx(Bo,{type:"password",autoFocus:!0,placeholder:`${w.name} for ${e.agentName}`,value:c,onChange:v=>u(v.target.value)}),d.jsx(Oe,{type:"submit",children:"use key"})]})]})}const iW=E.memo(function({item:t,worktreeId:n,onPickHover:r,marked:o,streaming:s}){const a=Dn(),c=Qe(),u=Lr(),f=vn("chat"),h={sock:c,dispatch:a.dispatch},m=()=>{var y;return(y=Kt(a.getState(),n))==null?void 0:y.worktree.path},g=y=>y&&n&&d.jsx(mp,{children:d.jsx("div",{className:"msg-attachments",children:y.map(w=>w.kind==="image"?d.jsx($H,{img:w,worktreeId:n,src:u.attachment(n,w.file)},`${w.kind}-${w.n}`):w.kind==="file"?d.jsx(_p,{className:"in-chat",name:w.name,bytes:w.bytes,href:w.text?u.attachment(n,w.file):void 0,kept:{worktreeId:n,file:w.file}},`${w.kind}-${w.n}`):w.kind==="paste"?d.jsx(Sp,{className:"in-chat",n:w.n,name:w.name,source:w.source,lines:w.lines,chars:w.chars,preview:w.preview,href:u.attachment(n,w.file)},`${w.kind}-${w.n}`):d.jsx($p,{pick:w,className:"in-chat",tipText:"Hover to highlight on the page",onHover:v=>r==null?void 0:r(w,v),worktreeId:n,onOpen:(v,_)=>ja(a,c,n,v,_)},`${w.kind}-${w.n}`))})});switch(t.kind){case"user":{const y=g(t.attachments),w=m();return d.jsxs("div",{className:"msg-user row-edge","data-state":gr({cursor:o}),...f.contextMenu((v,_)=>vi(t,n??null,h,{link:wp(_,w)},v)),onClick:v=>Du(v,w,n,h),children:[y,d.jsx(Pu,{text:t.text,worktreeId:n,root:w})]})}case"assistant":return d.jsx(Ag,{text:t.text,menu:(y,w,v)=>vi(t,n??null,h,{link:y,code:w},v),marked:o,worktreeId:n,fileRoot:m(),streaming:s,pictures:t.pictures});case"error":return d.jsx("div",{className:"msg-assistant msg-error",...f.contextMenu(y=>vi(t,n??null,h,{},y)),children:t.text});case"auth":return d.jsx(sW,{item:t});case"ask":{const y=S4(t);if(y){const T={kind:"assistant",text:Ow(y.questions,y.answers).join(`
255
- `)};return d.jsxs(d.Fragment,{children:[d.jsx(Ag,{text:y.message,menu:(j,A,R)=>vi({kind:"assistant",text:y.message},n??null,h,{link:j,code:A},R),worktreeId:n,fileRoot:m()}),d.jsx("div",{className:"msg-user row-edge","data-state":gr({cursor:o}),...f.contextMenu(j=>vi(T,n??null,h,{},j)),children:x4(y.questions,y.answers).map((j,A)=>{var R;return d.jsxs("div",{children:[j.pick,j.descriptions.map((C,M)=>d.jsx("div",{className:"msg-pick-desc",children:C},M)),j.note&&d.jsx("div",{children:j.note})]},((R=y.questions[A])==null?void 0:R.id)??A)})})]})}const w=N4(t);if(!w)return d.jsx(X8,{item:t});const v=w.file,_={kind:"assistant",text:w.choice};return d.jsxs(d.Fragment,{children:[v?d.jsx(aW,{file:v,worktreeId:n}):w.text&&d.jsx(Ag,{text:w.text,menu:(x,N,T)=>vi({kind:"assistant",text:w.text},n??null,h,{link:x,code:N},T),worktreeId:n,fileRoot:m()}),d.jsx("div",{className:"msg-user",...f.contextMenu(x=>vi(_,n??null,h,{},x)),children:w.choice})]})}case"blocked":return d.jsxs(lr,{icon:"lock",word:"blocked",tone:"red",below:t.reason,...f.contextMenu(()=>Cy(t.path,void 0,po(h.sock))),children:[d.jsx("span",{className:"tool-name",children:t.tool}),t.path&&d.jsx("span",{className:"tool-hint",children:t.path})]});case"grafted":return d.jsx(lr,{icon:"pull",word:"grafted",tone:"accent",below:t.branch,"data-tip":`what follows was said in ${t.title} before it was merged in here`,"data-tip-placement":"follow",children:d.jsx("span",{className:"daemon-text",children:t.title})});case"switched":return d.jsx(lr,{icon:"swap",word:"model",tone:"quiet",below:t.asked?`${t.asked} is not on the agent's list`:"the agent switched to it",children:d.jsx("span",{className:"daemon-text",children:t.name})});case"asked":return d.jsx(lr,{icon:"send",word:"asked",tone:"quiet",children:d.jsx("span",{className:"daemon-text",children:t.why})});case"stopped":return d.jsx(lr,{icon:"stop",word:"stopped",tone:"quiet"});case"landed":return d.jsx(cW,{item:t});case"handed":return d.jsx(NH,{item:t,worktreeId:n,marked:o,children:g(t.attachments)});case"piece-landed":return d.jsx(TH,{item:t});case"handoff":{const y=E6(t);if(!y)return d.jsx(oE,{item:t,worktreeId:n});const w={kind:"assistant",text:y};return d.jsxs(d.Fragment,{children:[d.jsx("div",{className:"msg-user",...f.contextMenu(v=>vi(w,n??null,h,{},v)),children:y}),d.jsx(oE,{item:t,worktreeId:n})]})}case"piece-later":return d.jsx(jH,{item:t});case"restored":return d.jsx(lW,{item:t});case"adopted":return d.jsx(lr,{icon:"branch",word:"taken over",tone:"quiet",at:t.ts,children:d.jsxs("span",{className:"daemon-text",children:["on ",t.branch,", its own branch"]})});case"owned":{if(t.by==="edit")return d.jsx(I7,{item:t,worktreeId:n});const y=t.by==="agent"?"the agent asked for it before changing the backend":"asked for";return d.jsx(lr,{icon:"run",word:"runs here",tone:"quiet",at:t.ts,children:d.jsxs("span",{className:"daemon-text",children:[t.names.join(", "),": ",y]})})}case"own-failed":return d.jsx(lr,{icon:"run",word:"setup failed",tone:"quiet",at:t.ts,children:d.jsxs("span",{className:"daemon-text",children:[t.name," (exit ",t.exit,"): ",t.cmd,"; the page still reaches main's ",t.name]})})}});function aW({file:e,worktreeId:t}){const n=Qe(),r=dt(),o=vn("chat"),s=Xy(t??void 0,e);return d.jsx(lr,{icon:"file",word:"plan",tone:"quiet",...o.contextMenu(()=>Cy(e,t?()=>n==null?void 0:n.send({t:"reveal",worktreeId:t,path:e}):void 0,po(n))),children:d.jsx("span",{className:"daemon-text",children:d.jsx(Oe,{variant:"inline",tone:"strong","data-tip":e,onClick:()=>t&&Pn({dispatch:r},{worktreeId:t,path:e,view:"preview"}),children:s})})})}function lW({item:e}){return d.jsx(lr,{icon:"reload",word:"restored",tone:"quiet",at:e.ts,children:d.jsxs("span",{className:"daemon-text",children:["after ",Hw(e.ts-e.archivedAt)," in the archive, back on ",e.branch,e.uncommitted?" with its uncommitted changes":""]})})}function cW({item:e}){const t=Vj(e.ts),n=e.mark&&ky(e.mark),r=`${e.text}, ${t}`,o=e.url&&d.jsx(Oe,{variant:"inline",onClick:()=>window.open(e.url,"_blank"),children:"the PR"}),s=e.held&&`Not marked landed: ${Jr(e.held)}`;return d.jsx(lr,{icon:"check",word:"landed",tone:"aqua",at:e.ts,below:[n?r:void 0,s],children:d.jsxs("span",{className:"daemon-text",children:[n??r,o&&d.jsxs(d.Fragment,{children:[" · ",o]})]})})}const Cp=".jump-seat, .draft-intro, .chat-input";function uW(e){const t=e instanceof Element?e:e.parentElement;return!!(t!=null&&t.closest(Cp))}function aE(e,t){const n=new Map(t.map(r=>[r.id,r]));for(const r of e.querySelectorAll(`.chat-mention[data-dir]:not([data-archived], :is(${Cp}) *)`)){const o=n.get(r.dataset.worktree??"");if(!o)continue;const s=Ep({...o,dir:r.dataset.dir}),a=r.querySelector(".dot"),c=`dot ${o.dot}`;a&&a.className!==c&&(a.className=c);const u=s.detail.join(`
256
- `);r.dataset.tipDetail!==u&&(r.dataset.tipDetail=u),r.dataset.tipDot!==o.dot&&(r.dataset.tipDot=o.dot)}}function dW(e,t){const n=L(s=>s.visible),r=L(s=>s.shipping),o=L(s=>{var a;return(a=Kt(s,t))==null?void 0:a.worktree.repoId});E.useEffect(()=>{const s=e.current;if(!s||!o)return;const a=jp(n,o,null,r);aE(s,a);let c=0;const u=new MutationObserver(f=>{f.every(h=>uW(h.target))||(cancelAnimationFrame(c),c=requestAnimationFrame(()=>aE(s,a)))});return u.observe(s,{childList:!0,subtree:!0}),()=>{u.disconnect(),cancelAnimationFrame(c)}},[e,n,r,o])}const F$=e=>e===""||e==="!";function lE(e,t){const n=new Set,r=[];for(let o=e.length-1;o>=0;o--){const s=e[o],a=I$(s),c=a!==null?`!${a}`:t?null:s.kind==="user"?s.text:s.kind==="ask"?_4(s):null;c===null||!c.trim()||n.has(c)||(n.add(c),r.push({text:c,at:o}))}return r}function fW(e,t,n,r){if(!t){if(r!=="up"&&r!=="first"||!F$(n))return null;const c=lE(e,n==="!"),u=r==="up"?c[0]:c.at(-1);return u?{walk:{at:u.at,from:n},text:u.text}:null}if(r==="box")return{walk:null,text:t.from};const o=lE(e,t.from==="!"),s=r==="first"?o.length-1:o.findIndex(c=>c.at===t.at)+(r==="up"?1:-1);if(s<0)return{walk:null,text:t.from};const a=o[s];return a?{walk:{at:a.at,from:t.from},text:a.text}:{walk:t,text:n}}function hW(e,t,n,r){const o=new Map;return{rows:t.map((a,c)=>{const u=n(a,c),f=e.get(a.at),h=f&&f.row.kind===u.kind&&pW(f.row.props,u.props)?f.el:r(a,u);return o.set(a.at,{row:u,el:h}),h}),cache:o}}function pW(e,t){const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(const o of n){if(!(o in t))return!1;const s=e[o],a=t[o];if(!Object.is(s,a)&&(!Array.isArray(s)||!Array.isArray(a)||s.length!==a.length||!s.every((c,u)=>Object.is(c,a[u]))))return!1}return!0}const mW=4;function gW(e,t,n){const r=Math.max(t,0);return n?e>=r+1:e>=r+mW}function kW(e,t,n){E.useEffect(()=>{const r=e.current,o=r==null?void 0:r.parentElement,s=r==null?void 0:r.querySelector(":scope > .chat-input");if(!r||!o||!s){n(!1);return}let a=0,c=!1,u=0,f=0;const h=()=>o.style.setProperty("--cover",`${c?f:u}px`),m=()=>{if(u=s.offsetHeight,f=u,t&&s.classList.contains("foldable")){const _=r.scrollTop;s.classList.add("fold-measure"),f=s.offsetHeight,s.classList.remove("fold-measure"),r.scrollTop=_}a=u-f,o.style.setProperty("--fold",`${a}px`),o.style.setProperty("--keep",`${f}px`),h()},g=()=>{if(!t)return;const _=gW(r.scrollHeight-r.scrollTop-r.clientHeight,a,c);_!==c&&(c=_,h(),n(c))};m(),g(),r.addEventListener("scroll",g,{passive:!0});const y=new ResizeObserver(()=>{m(),g()});y.observe(s);let w=s.className;const v=new MutationObserver(()=>{s.className!==w&&(w=s.className,m(),g())});return v.observe(s,{attributes:!0,attributeFilter:["class"]}),()=>{r.removeEventListener("scroll",g),y.disconnect(),v.disconnect();for(const _ of["--fold","--keep","--cover"])o.style.removeProperty(_);n(!1)}},[e,t,n])}const wW={get current(){return pu.el}},yW={upTo:e=>e.querySelector(":scope > .jump-seat"),except:Cp};function qk({items:e,next:t,worktreeId:n,onOpen:r}){const o=Lr();return d.jsx(mp,{children:d.jsx("div",{className:"msg-attachments",children:pw(e,t).map(([s,a])=>s.kind==="image"?d.jsx(Tp,{className:"in-chat",src:"local"in s&&s.local||o.upload(s.upload),n:a,name:s.name,width:s.width,height:s.height,bytes:s.bytes,progress:"progress"in s?s.progress:void 0},`image-${a}`):s.kind==="file"?d.jsx(_p,{className:"in-chat",name:s.name,bytes:s.bytes,href:s.text&&s.upload?o.upload(s.upload):void 0,progress:"progress"in s?s.progress:void 0},`file-${a}`):s.kind==="paste"?d.jsx(Sp,{className:"in-chat",n:a,name:s.name,source:s.source,...jw(s.text),text:s.text},`paste-${a}`):d.jsx($p,{className:"in-chat",pick:s,worktreeId:n,onOpen:r},`pick-${a}`))})})}function vW({entry:e,next:t,worktreeId:n,root:r,onOpen:o}){const s=dt(),a=Qe(),c=It(e.id,"draft"),u=It(e.id,"attachments");return d.jsxs("div",{className:"msg-user queued-msg",onClick:f=>Du(f,r,n,{sock:a,dispatch:s}),children:[d.jsxs("span",{className:"queued-tag",children:[d.jsx(kt,{name:"clock",className:"icon-inline"}),d.jsx("span",{className:"live-text",children:"uploading"})]}),d.jsxs("span",{className:"queued-actions",children:[d.jsx(At,{icon:"edit",label:"Edit: puts it back in the input",onClick:()=>s({a:"unsend",id:e.id})}),d.jsx(At,{icon:"close",label:"Remove: it is not sent",onClick:()=>s({a:"drop-out",id:e.id})})]}),d.jsxs("div",{className:"queued-text",children:[u.length>0&&d.jsx(qk,{items:u,next:t,worktreeId:n,onOpen:o}),d.jsx(Pu,{text:c,worktreeId:n,root:r})]})]})}const bW=new Set;function Og({active:e,archived:t,found:n,lead:r,tail:o,foot:s}){var Dt;const a=Qe(),c=Dn(),u=dt(),f=L(P=>P.frame==="phone"),h=(e==null?void 0:e.worktree.id)??(t==null?void 0:t.id)??(n==null?void 0:n.id)??null,m=It(h,"chat"),g=It(h,"queue"),y=It(h,"sending"),w=E.useMemo(()=>Kg(P_(m)),[m]),v=E.useMemo(()=>{let P=w;return g.map(se=>{const je=P;return P=du(P,se.attachments??[]),je})},[g,w]),_=L(P=>P.outbox),x=E.useMemo(()=>{let P=g.reduce((se,je)=>du(se,je.attachments??[]),w);return _.filter(se=>se.log===h).map(se=>{const je=P;return P=du(P,se.kinds.map(Fe=>({kind:Fe}))),{entry:se,next:je}})},[_,h,g,w]),N=y!=null&&y.message?g.findIndex(P=>{var se;return P.text===((se=y.message)==null?void 0:se.text)}):-1,T=E.useRef(null);dW(T,h),f8(T,yW);const[j,A]=E.useState(null),R=E.useCallback(()=>{const P=(T.current&&Tk(T.current))??"";A(se=>({seed:P||(se==null?void 0:se.seed)||"",seq:((se==null?void 0:se.seq)??0)+1}))},[]),C=E.useCallback(P=>!(P!=null&&P.closest("[data-pane]"))&&!c.getState().overlay,[c]);tT(wW,Ey,R,C);const M=P=>{if(A(null),P){const se=window.getSelection();se==null||se.removeAllRanges(),se==null||se.addRange(P)}},I=gN(T,m);at([h],()=>I.jump());const D=I.offStart&&I.moving==="up",H=I.offEnd&&(I.moving==="down"||I.away),Z=P=>P.preventDefault(),B=(D||H)&&d.jsxs("div",{className:Ke("jump",I.away&&"jump-news"),children:[D&&d.jsx("button",{className:"jump-up",onMouseDown:Z,onClick:I.start,"data-tip":"Jump to start",children:d.jsx(kt,{name:"caret-up",className:"icon-inline"})}),H&&d.jsxs("button",{className:"jump-down",onMouseDown:Z,onClick:I.jump,"data-tip":"Jump to latest",children:[d.jsx(kt,{name:"caret",className:"icon-inline"}),I.away&&" new messages"]})]}),J=E.useCallback(P=>u({a:"reading",on:P}),[u]);kW(T,f,J);const V=It(h,"mark"),ee=(V==null?void 0:V.by)==="walk"?V.at:void 0,F=E.useRef(null),$=()=>{const P=T.current,se=P==null?void 0:P.querySelector(':scope > [data-state~="cursor"]');if(!P||!se)return;const je=parseFloat(getComputedStyle(P).paddingTop)||0;P.scrollTop+=se.getBoundingClientRect().top-P.getBoundingClientRect().top-je,I.read()};at([ee],()=>{const P=T.current;if(P){if(ee===void 0){const se=F.current;if(F.current=null,!se||!F$(Mr(c.getState(),h).draft))return;se.bottom?I.jump():(P.scrollTop=se.top,I.read());return}F.current??(F.current={bottom:I.pinned(),top:P.scrollTop}),$()}});const Q=It(h,"sent");at([Q],()=>{Q&&I.jump()});const q=x.length,W=E.useRef(q);at([q],()=>{q>W.current&&I.jump(),W.current=q});const oe=(V==null?void 0:V.by)==="reveal"?V:void 0,de=E.useMemo(()=>oe?EH(m,oe.seq):-1,[m,oe]),he=ee??(de>=0?de:void 0);at([oe==null?void 0:oe.n,de],()=>{de>=0&&$()});const Ne=E.useCallback((P,se)=>{h&&(se?un.post(h,{type:"highlight-selector",selector:P.selector,label:Uw(P)}):un.post(h,{type:"highlight-clear"}))},[h]),Me=ss(e==null?void 0:e.agent),Be=It(h,"cardParked"),K=E.useMemo(()=>{const P=fy(m);return!!P&&Be!==P.id},[m,Be]),te=e==null?void 0:e.worktree,pe=(te==null?void 0:te.path)??(t==null?void 0:t.path)??(n==null?void 0:n.path),ue=E.useMemo(()=>pe?[pe]:[],[pe]),ie=E.useMemo(()=>hH(m,ue,Me),[m,ue,Me]),ye=E.useMemo(()=>Me?mH(m):bW,[Me,m]),Se=E.useMemo(()=>gH(ie,ye),[ie,ye]),Ee=Se.floating,Le=E.useRef([]),Ue=E.useMemo(()=>(Le.current=yH(Le.current,Se.flow),Le.current),[Se]),Je=(e==null?void 0:e.agent)==="working",Ht=Je||(e==null?void 0:e.agent)==="waiting",qt=E.useMemo(()=>Ht?bH(Ue):-1,[Ht,Ue]),xt=Ue.at(-1),Ze=Je&&xt&&"item"in xt&&(xt.item.kind==="thinking"||xt.item.kind==="assistant")?Ue.length-1:-1,_t=(Dt=ie.findLast(P=>{var se;return"tools"in P&&((se=P.tools[0])==null?void 0:se.name)===Ai}))==null?void 0:Dt.at,mt=It(h,"chatAt"),De=Ci(Me?mt:void 0),nt=It(h,"usage"),lt=(nt==null?void 0:nt.heard)!==void 0&&mt!==void 0&&nt.heard>mt?nt.heard:void 0,Yt=Ci(Me?lt:void 0),$n=Ci(y&&!Me?y.at:void 0),gt=kH(m,Me),rt=Ee.length>0,Kn=Ze>=0||gt||rt,Qt=Je&&!Kn&&De<ma?cH(Ue,ue):-1,Cn=E.useMemo(()=>T$(Ue),[Ue]),qn=It(h,"running"),dn=P=>qn&&P.tools.some(se=>se.id===qn.id)?qn.at:void 0,yn=e==null?void 0:e.worktree.path,ne=P=>`${h??""}:${P}`,we=(P,se)=>"spawn"in P?{kind:"tool",props:{tools:[P.spawn],run:P.run,roots:ue,worktreeId:h}}:"tools"in P?{kind:"tool",props:{tools:P.tools,next:P.next,live:se===qt||P.at===_t,held:se===Qt,since:dn(P),queued:Cn.has(se),roots:ue,worktreeId:h,marked:P.at===he}}:P.item.kind==="thinking"?{kind:"thought",props:{item:P.item,open:se===qt,streaming:se===Ze,worktreeId:h,fileRoot:yn}}:{kind:"item",props:{item:P.item,worktreeId:h,onPickHover:Ne,marked:P.at===he,streaming:Je&&se===Ue.length-1}},qe=E.useRef(new Map),ot=hW(qe.current,Ue,we,(P,se)=>se.kind==="tool"?d.jsx(Rf,{...se.props},ne(P.at)):se.kind==="thought"?d.jsx(rW,{...se.props},ne(P.at)):d.jsx(iW,{...se.props},ne(P.at)));qe.current=ot.cache;const Tt=d.jsxs("div",{className:"chat-wrap",children:[d.jsxs("div",{className:"chat-log",ref:T,children:[r,ot.rows,Ee.map(P=>{var se;return"spawn"in P?d.jsx(Rf,{tools:[P.spawn],run:P.run,working:!0,since:mt,roots:ue,worktreeId:h},ne(P.at)):((se=P.tools[0])==null?void 0:se.name)===Ai?d.jsx(Rf,{tools:P.tools,live:P.at===_t,since:dn(P),roots:ue,worktreeId:h,marked:P.at===he},ne(P.at)):d.jsx(Rf,{tools:P.tools,since:mt,roots:ue,worktreeId:h},ne(P.at))}),h&&(y==null?void 0:y.message)&&d.jsxs("div",{className:"msg-user",onClick:P=>Du(P,pe,h,{sock:a,dispatch:u}),children:[y.message.attachments&&d.jsx(qk,{items:y.message.attachments,next:w,worktreeId:h,onOpen:(P,se)=>ja(c,a,h,P,se)}),d.jsx(Pu,{text:y.message.text,worktreeId:h,root:pe})]}),e&&(y||Me&&!(e.agent==="waiting"&&K)&&!gt&&!rt&&Qt<0&&!(Kn&&De<ma))&&d.jsx("div",{className:"working-row",children:e.agent==="waiting"?"waiting for your answer…":Kn?De>=ma&&d.jsxs("span",{children:["quiet for",d.jsx("span",{className:"working-num",children:ba(De)})]}):d.jsxs("span",{className:"working-mark",children:[d.jsx(uh,{}),!Me&&y?$n>=ma&&d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"working-word",children:"waiting for the agent"}),d.jsx("span",{className:"working-num",children:ba($n)})]}):lt!==void 0?Yt>=ma&&d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"working-word",children:"thinking"}),d.jsx("span",{className:"working-num",children:ba(Yt)})]}):De>=ma&&d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"working-word",children:"waiting for the model"}),d.jsx("span",{className:"working-num",children:ba(De)})]})]})}),h&&g.map((P,se)=>se===N?null:d.jsxs("div",{className:"msg-user queued-msg",onClick:je=>Du(je,pe,h,{sock:a,dispatch:u}),children:[d.jsxs("span",{className:"queued-tag",children:[d.jsx(kt,{name:"clock",className:"icon-inline"}),"queued"]}),d.jsxs("span",{className:"queued-actions",children:[d.jsx(At,{icon:"edit",label:"Edit: removes from queue, puts it back in the input",onClick:()=>zN(c,a,h,se)}),d.jsx(At,{icon:"close",label:"Remove from queue",onClick:()=>a==null?void 0:a.send({t:"unqueue",worktreeId:h,index:se})})]}),d.jsxs("div",{className:"queued-text",children:[P.attachments&&d.jsx(qk,{items:P.attachments,next:v[se]??w,worktreeId:h,onOpen:(je,Fe)=>ja(c,a,h,je,Fe)}),d.jsx(Pu,{text:P.text,worktreeId:h,root:pe})]})]},`q-${se}`)),h&&x.map(({entry:P,next:se})=>d.jsx(vW,{entry:P,next:se,worktreeId:h,root:pe,onOpen:(je,Fe)=>ja(c,a,h,je,Fe)},P.id)),o,d.jsx("div",{className:"jump-seat",children:B}),f&&s]}),j&&d.jsx(Jj,{root:T,body:T,skip:Cp,seed:j.seed,seq:j.seq,onClose:M,onReveal:I.read})]});return f?Tt:d.jsxs(d.Fragment,{children:[Tt,s]})}function xW(e){return e.offer?e.offer.state!=="offered"?!0:e.agent==="idle"&&e.chat.some(t=>t.kind==="assistant"):!1}const EW=/EACCES|EPERM|permission denied/i,SW="https://docs.npmjs.com/resolving-eacces-permissions-errors-when-installing-packages-globally";function _W(e){return{why:e.line.replace(/\.$/,""),permissions:EW.test(e.line),command:e.command}}function NW(){try{return localStorage.getItem(tt.installOffered)==="1"}catch{return!1}}let vh={prompt:null,offered:typeof localStorage<"u"&&NW()};const Zk=new Set;function Gk(e){vh={...vh,...e};for(const t of Zk)t()}typeof window<"u"&&(window.addEventListener("beforeinstallprompt",e=>{e.preventDefault(),Gk({prompt:e})}),window.addEventListener("appinstalled",()=>Gk({prompt:null})));function B$(e){return Zk.add(e),()=>{Zk.delete(e)}}function U$(){return E.useSyncExternalStore(B$,()=>vh.prompt)}function jW(){return E.useSyncExternalStore(B$,()=>vh.offered)}function cE(){try{localStorage.setItem(tt.installOffered,"1")}catch{}Gk({offered:!0})}function TW(e){return!e.prompt||e.offered||e.agent!=="idle"?!1:e.chat.some(t=>t.kind==="assistant")}function Qy(e,{sock:t}){var o;const n=[];e.canLogout&&((o=e.auth)==null?void 0:o.kind)!=="none"&&n.push({id:"logout",label:"log out",danger:!0,onClick:()=>t==null?void 0:t.send({t:"agent-logout",agent:e.id})});const r=Jy(e);return r&&n.push({id:"install",label:r,onClick:()=>t==null?void 0:t.send(H$(e))}),n}function Jy(e){return e.install?e.install==="missing"?"install":e.install.held?"install anyway":"install again":null}function H$(e){const t=Jy(e)==="install anyway";return{t:"install-agent",agent:e.id,...t?{anyway:!0}:{}}}const Ip=e=>e.reason??"not installed",$W={side:"top",align:"start",offset:4,alignOffset:-10,matchWidth:-20,flip:"side",margin:8};function CW({results:e,keyOf:t,row:n,rowClass:r,nav:o,listRef:s,empty:a,note:c,groupOf:u,groupHead:f}){const h=new Set(u?e.map(u):[]);return d.jsxs(Ws,{className:"inline-picker",anchor:"parent",placement:$W,children:[d.jsxs("div",{className:"picker-list",ref:s,children:[e.map((m,g)=>{const y=u==null?void 0:u(m),w=y!==void 0&&h.size>1&&(g===0||(u==null?void 0:u(e[g-1]))!==y)?d.jsx("div",{className:"picker-group",children:(f==null?void 0:f(y))??y}):null;return d.jsxs(E.Fragment,{children:[w,d.jsx("button",{className:Ke("picker-item",r==null?void 0:r(m)),"data-state":gr({cursor:g===o.index}),onMouseMove:()=>g!==o.index&&o.setIndex(g),onMouseDown:v=>v.preventDefault(),onClick:()=>o.pick(m),children:n(m,g===o.index)})]},t(m))}),e.length===0&&d.jsx("div",{className:"empty",children:a})]}),d.jsx(u$,{hints:[["↑↓","moves"],["tab","inserts"],["esc","dismisses"]],note:c})]})}const uE=e=>Math.max(0,Math.min(1,Number.isFinite(e)?e:0));function IW({fraction:e,level:t,className:n}){const o=2*Math.PI*5.5,s=uE(e),a=E.useId(),c=3.5,u=2*c*uE(t);return d.jsxs("svg",{className:Ke("ring",n),viewBox:"0 0 14 14",width:"14",height:"14","aria-hidden":"true",children:[t!==void 0&&d.jsxs(d.Fragment,{children:[d.jsx("clipPath",{id:a,children:d.jsx("circle",{cx:"7",cy:"7",r:c})}),d.jsx("rect",{className:"ring-level",clipPath:`url(#${a})`,x:"0",y:7+c-u,width:"14",height:u})]}),d.jsx("circle",{className:"ring-track",cx:"7",cy:"7",r:5.5}),d.jsx("circle",{className:"ring-fill",cx:"7",cy:"7",r:5.5,strokeDasharray:`${o*s} ${o}`})]})}function AW(e,t=yu.folder.shared){return`New project: ${e}. The repository is empty apart from a root commit. Pick the mainstream stack for what the message describes, and say which in your first sentence; if the message names a stack, that wins. Scaffold it in this directory, write its .gitignore before installing anything, make it start on $PORT, and write ${t}.`}const Ps="";function W$(e,t){return!e||t.length===0?e:uA(e,t)??Ps}function RW(e){var f;const t=MW(e.name);if(t){const h=[t.qualifier,e.description||e.name].filter(Boolean).join(" · ");return{label:t.label,version:t.version,description:h}}const n=e.name.match(/^([A-Za-z]+)-(\d+(?:\.\d+)*)(?:-([A-Z][a-z]+))?$/);if(n!=null&&n[1]&&n[2])return{label:n[3]??n[1],version:n[2],...e.description?{description:e.description}:{}};const[r="",...o]=(e.description??"").split(" · "),s=e.name.replace(/\s*\([^)]*\)$/,""),a=r.match(/^(.+?) (\d+(?:\.\d+)*)(?: with (.+))?$/);if(!(a!=null&&a[2])||a[1]!==s)return{label:e.name,...e.description?{description:e.description}:{}};const u=[a[3]??((f=e.name.match(/\(([^)]*)\)$/))==null?void 0:f[1]),...o].filter(Boolean).join(" · ");return{label:s,version:a[2],...u?{description:u}:{}}}const OW=/(?:^|[./])claude-(?:(\d{1,2}(?:-\d{1,2}(?!\d))?)-)?([a-z]+)(?:-(\d{1,2}(?:-\d{1,2}(?!\d))?))?(?:-\d{8})?(?:-v\d+(?::\d+)?)?(?:@\d{8})?(?:\[(\d+m)\])?$/;function MW(e){const t=e.match(OW),n=t==null?void 0:t[2],r=(t==null?void 0:t[3])??(t==null?void 0:t[1]);if(!(!n||!r))return{label:n.charAt(0).toUpperCase()+n.slice(1),version:r.replace("-","."),...t[4]?{qualifier:`${t[4].toUpperCase()} context`}:{}}}function K$(e,t,n,r,o){const s=iS(e),a=cA(e,o),c=_=>a&&_===(s==null?void 0:s.id)?a.id:_,u=W$(t,e),f=c(u||n||(s==null?void 0:s.id)||Ps),h=c(u||(s==null?void 0:s.id)||Ps),m=a?e.filter(_=>_!==s):e,g=m.some(_=>_.id===f),y=m.map(_=>({c:_,words:RW(_)})),w=_=>[_.label,_.version].filter(Boolean).join(" "),v=[...s?[]:[{id:Ps,label:r.label,description:r.description}],...y.map(({c:_,words:x})=>{const N=y.filter(j=>w(j.words)===w(x)).length===1?x:void 0,T=N?N.description:_.description;return{id:_.id,label:N?N.label:_.name,...N!=null&&N.version?{suffix:N.version}:{},...N!=null&&N.version&&y.some(j=>j.c!==_&&j.words.label===N.label)?{chip:w(N)}:{},description:_===a?["default",T].filter(Boolean).join(" · "):T}}),...f&&!g?[{id:f,label:f}]:[]];if(f!==h){const _=v.find(T=>T.id===f),x=v.findIndex(T=>T.id===h),N=v[x];if(N){const T=(_==null?void 0:_.chip)??(_==null?void 0:_.label)??f;v[x]={...N,description:[`${T} now`,N.description].filter(Boolean).join(" · ")}}}return{rows:v,shown:f,picked:h}}const nu=(e,t)=>`${e} ${t}`;function LW(e){const t=e.indexOf(" ");return t<0?{agent:e,model:Ps}:{agent:e.slice(0,t),model:e.slice(t+1)}}function PW(e,t,n){const r=e.length>1;let o=nu(t,n);return{rows:e.flatMap(a=>{var h;const c=a.short??a.name,u=a.id===t;if(!a.available||!((h=a.models)!=null&&h.length))return u&&(o=nu(a.id,Ps)),[{id:nu(a.id,Ps),label:c,description:a.available?a.checkFailed??"its own default model; the rest are listed once it has run":Ip(a),disabled:!a.available}];const f=K$(a.models,u?n:Ps,void 0,{label:`${c} default`,description:`whatever ${a.name} runs when nothing is asked for`},a.defaultModel);return u&&(o=nu(a.id,f.shown)),f.rows.map(m=>({...m,id:nu(a.id,m.id),...r&&m.id!==Ps?{prefix:c}:{}}))}),shown:o}}function q$({choices:e,value:t,current:n,runs:r,what:o,defaultLabel:s,defaultDescription:a,placeholder:c,className:u,onChange:f,onClose:h}){const{rows:m,shown:g,picked:y}=E.useMemo(()=>K$(e,t,n,{label:s,description:a},r),[e,t,n,r,s,a]);if(e.length===0)return null;const w=m.find(_=>_.id===g),v=(w==null?void 0:w.chip)??(w==null?void 0:w.label)??g;return d.jsx(Os,{value:y,reads:g,options:m,onChange:f,onClose:h,className:u,hint:W$(t,e)?`asked for ${v}; click to change`:`${v}, the agent's choice; click to pick ${o}`,placeholder:c})}function dE({efforts:e,value:t,current:n,runs:r,onChange:o,onClose:s}){return d.jsx(q$,{choices:e,value:t,current:n,runs:r,what:"an effort level",defaultLabel:"default effort",defaultDescription:"the level the agent runs at when nothing is asked for",placeholder:"how hard the agent thinks here",className:"effort-chip",onChange:o,onClose:s})}const DW=e=>{var t;return((t=Ih.find(n=>n.id===e))==null?void 0:t.description)??""};function fE({value:e,onChange:t,onClose:n}){return d.jsx(Os,{value:e,options:Ih.map(r=>({id:r.id,label:r.name,description:r.description})),onChange:t,onClose:n,className:Ke("mode-chip",e!=="auto"&&"mode-held"),hint:`${e}: ${DW(e)}. Click to change`,placeholder:"what the agent may do without asking"})}function hE({models:e,value:t,current:n,runs:r,onChange:o,onClose:s}){return d.jsx(q$,{choices:e,value:t,current:n,runs:r,what:"a model",defaultLabel:"default model",defaultDescription:"whatever the agent runs when nothing is asked for",placeholder:"which model answers here",className:"model-chip",onChange:o,onClose:s})}function zW({agents:e,agent:t,model:n,onChange:r,onClose:o}){const{rows:s,shown:a}=E.useMemo(()=>PW(e,t,n),[e,t,n]);if(s.length===0)return null;const c=s.find(f=>f.id===a),u=c?[c.prefix,c.label,c.suffix].filter(Boolean).join(" "):n;return d.jsx(Os,{value:a,options:s,onChange:f=>{const h=LW(f);r(h.agent,h.model)},onClose:o,className:"model-chip",hint:`${u} works on the new worktree; click to change`,placeholder:"which agent and model work on it"})}function FW(e){const t=[],n=new Map,r=new Map;for(const s of[...e].sort((a,c)=>a.at-c.at)){if(s.review){t.push({root:s,replies:[]});continue}const a=s.replyTo?n.get(s.replyTo):void 0;if(a){a.replies.push(s);continue}const c={root:s,replies:[]};n.set(s.id,c);const u=s.path??"";r.set(u,[...r.get(u)??[],c])}const o=[...r.entries()].sort(([s],[a])=>s.localeCompare(a)).map(([s,a])=>({path:s,threads:a.sort((c,u)=>(c.root.line??0)-(u.root.line??0))}));return{reviews:t,files:o}}const ev=e=>e.line===void 0?null:e.startLine!==void 0?`${e.startLine}-${e.line}`:String(e.line);function Z$(e){return e==="changes_requested"?"requested changes":e==="approved"?"approved":"reviewed"}const pE=e=>e.split(`
257
- `).map(t=>t?`> ${t}`:">").join(`
258
- `);function BW({root:e,replies:t}){const n=ev(e),r=e.path?`${e.path}${n?` ${e.startLine===void 0?"line":"lines"} ${n}`:""}`:null,s=[`${e.review?`${e.author} ${e.review==="changes_requested"?"requested changes on":Z$(e.review)} the pull request`:r?`${e.author} commented on ${r} in the pull request`:`${e.author} commented on the pull request`}, ${e.url}`];e.body&&s.push(pE(e.body));for(const a of t)s.push(`${a.author} replied:
259
- ${pE(a.body)}`);return s.join(`
260
-
261
- `)}function UW({root:e}){if(!e.path)return`review from ${e.author}`;const t=e.path.slice(e.path.lastIndexOf("/")+1),n=ev(e);return`${t}${n?` (${n})`:""} from ${e.author}`}function G$(e,t){const n=t.length===0?"":t.length<=2?` from ${t.join(" and ")}`:` from ${t[0]} and ${t.length-1} others`;return{count:`${e} ${e===1?"comment":"comments"}`,rest:n}}function oc(e,t,n){if(!t)return e;const r=new Set(t.map(a=>a-n)),o=[];let s="";for(let a=0;a<e.length;a++)r.has(a)?(s&&o.push(s),s="",o.push(d.jsx("b",{className:"hit",children:e[a]},a))):s+=e[a];return s&&o.push(s),o}function HW({c:e,query:t}){const n=t.trim();return d.jsxs(d.Fragment,{children:[d.jsxs("span",{className:"picker-name",children:["/",oc(e.name,n?Ny(e.name,n):null,0)]}),d.jsx("span",{className:"picker-desc row-dim",children:e.description})]})}function An({label:e,hint:t,current:n=!1}){return d.jsxs(d.Fragment,{children:[n&&d.jsx("span",{className:"row-current","aria-hidden":"true"}),d.jsx("span",{className:"picker-label",children:e}),t?d.jsx("span",{className:"picker-hint row-dim",children:t}):null]})}function WW(e,t,{sock:n}){return[{id:`forget-visit:${t}`,label:"remove from this list",onClick:()=>n==null?void 0:n.send({t:"forget-visit",repoId:e,path:t})}]}const KW=/ \| | - | \u2013 | \u2014 | \u00b7 |: /,qW=/^(\d+|[0-9a-f]{8}-[0-9a-f-]{27}|[0-9a-f]{12,})$/i,ZW=/^[[:$*{]|\[/;function GW(e){const t=new Map,n=e.filter(s=>!!s.title);if(new Set(n.map(s=>s.path)).size<2)return t;const r=n.map(s=>({path:s.path,parts:s.title.split(KW).map(a=>a.trim()).filter(Boolean)})),o=new Map;for(const{path:s,parts:a}of r)for(const c of a)o.set(c,(o.get(c)??new Set).add(s));for(const{path:s,parts:a}of r){const c=a.filter(u=>{var f;return(((f=o.get(u))==null?void 0:f.size)??0)<2});c.length>0&&t.set(s,c.join(" "))}return t}function tv(e){const t=e.replace(/\?[^#]*/,"").split(/[/#]/).filter(Boolean);for(let n=t.length-1;n>=0;n--){let r=t[n];try{r=decodeURIComponent(r)}catch{}if(qW.test(r)||ZW.test(r))continue;const o=r.replace(/[-_.]+/g," ").trim();if(o)return o[0].toUpperCase()+o.slice(1)}return"Home"}const Mg=8,VW=3,YW=50,XW=3;function QW(e,t,n=[]){const r=new Map,o=[],s=new Map;for(const a of(t==null?void 0:t.routes)??[]){if(a.endpoint)continue;const c=a.dynamic?sD(a.path):null;c?(o.push(c),s.set(a.path,a)):r.set(a.path,a)}return{history:e,statics:r,templates:o,templateRoutes:s,unseen:(t==null?void 0:t.unseen)??{},titles:GW(e),links:new Map(n.map(a=>[a.path,a.text]))}}function JW(e){if(!e)return"/";try{const t=new URL(e);return t.pathname+t.search+t.hash}catch{return"/"}}function eK(e){const t=e.trim();return/^[/?#]/.test(t)?t:`/${t}`}function tK(e,t){const n=/^[/?#]/.test(t)?e:e.replace(/^\//,"");return t&&n.toLowerCase().startsWith(t.toLowerCase())?n:null}const V$=e=>/^\[\[?\.\.\.|^\*$|^\$$/.test(e),lu=e=>V$(e)||/[[:$*{]/.test(e)&&!/^[^[{:$*]+\?$/.test(e),nK=e=>Gh(`/${e}`).text.slice(1),nv=e=>e.split("/").filter(Boolean);function rv(e,t){const n=t.startsWith("/"),r=t.replace(/^\//,"").split("/"),o=nv(e);let s="";const a=[],c=m=>{const g=nK(m);a.push([s.length,s.length+g.length]),s+=g};for(let m=0;m<r.length;m++){const g=r[m],y=o[m];if(y===void 0)return null;if(m<r.length-1){if(V$(y))return{show:t,accept:t};if(lu(y)){if(!g)return null}else if(g.toLowerCase()!==y.toLowerCase())return null;s+=`${lu(y)?g:y}/`;continue}if(lu(y))g?s+=g:c(y);else{if(!y.toLowerCase().startsWith(g.toLowerCase()))return null;s+=y}}for(const m of o.slice(r.length))s+="/",lu(m)?c(m):s+=m;const u=n?1:0,f=(n?"/":"")+s,h=a[0];return{show:f,accept:h?f.slice(0,h[0]+u):f,params:a.map(([m,g])=>[m+u,g+u])}}function rK(e,t){const n=rv(e,t);return n?n.accept.length>t.length?n.accept:t:Gh(e).literal}function Y$(e,t){if(e.kind==="go")return null;if(e.template){const n=rv(e.path,t);return n&&n.show.length>t.length?n:null}return tK(e.path,t)}const oK=e=>e.trim().replace(/^\//,"").toLowerCase();function X$(e,t){for(let n=0;n<e.length;n++)if("/-_.#".includes(e[n])&&e.startsWith(t,n+1))return!0;return!1}function sK(e,t,n){const r=e.replace(/^\//,"").toLowerCase(),o=t.toLowerCase();return r===n?100:r.startsWith(n)?80:X$(r,n)?60:o.startsWith(n)?50:o.split(/\s+/).some(s=>s.startsWith(n))?45:r.includes(n)||o.includes(n)?20:0}function iK(e,t){const{text:n,literal:r}=Gh(e);return r.replace(/^\//,"").toLowerCase().startsWith(t)?80:rv(e,t)?70:X$(n.replace(/^\//,"").toLowerCase(),t)?60:0}function aK(e,t){const n=nv(e).findIndex(lu);return n>=0&&t.split("/").length>n}function gu(e,t,n){var c;const r=e.statics.get(t),o=r?null:iD(e.templates,t),s=(r==null?void 0:r.file)??(o?(c=e.templateRoutes.get(o.path))==null?void 0:c.file:void 0),a=s?e.unseen[s]:void 0;return{kind:"page",path:t,title:e.titles.get(t)||e.links.get(t)||tv(t),template:!1,visited:n<Number.POSITIVE_INFINITY,...s?{file:s}:{},...a?{badge:a}:{},rank:n,group:(o==null?void 0:o.path)??t,score:0}}function Q$(e,t){const n=e.unseen[t.file];return{kind:"page",path:t.path,title:tv(t.path),template:!0,visited:!1,file:t.file,...n?{badge:n}:{},rank:Number.POSITIVE_INFINITY,group:t.path,score:0}}function Gf({rank:e,group:t,score:n,...r}){return r}const bh=e=>nv(e).length,xh=e=>e.badge==="new"?0:e.badge==="changed"?1:2;function lK(e,t){const n=new Set,r=[];e.history.forEach((h,m)=>{if(h.path===t)return;const g=gu(e,h.path,m);n.has(g.group)||(n.add(g.group),r.push(g))});const o=new Set(r.map(h=>h.path)),s=r.filter(h=>h.badge);for(const[h,m]of e.statics)e.unseen[m.file]&&h!==t&&!o.has(h)&&s.push(gu(e,h,Number.POSITIVE_INFINITY));for(const h of e.templateRoutes.values())e.unseen[h.file]&&!n.has(h.path)&&s.push(Q$(e,h));s.sort((h,m)=>xh(h)-xh(m)||h.rank-m.rank);const a=r.filter(h=>!h.badge),c=s.slice(0,Mg-Math.min(VW,a.length));for(const h of a)c.length<Mg&&c.push(h);const u=new Set(c.map(h=>h.path)),f=[...e.statics.keys(),...[...e.links.keys()].filter(h=>!e.statics.has(h))].filter(h=>h!==t&&!u.has(h)&&!o.has(h)).sort((h,m)=>bh(h)-bh(m)||(h<m?-1:h>m?1:0));for(const h of f){if(c.length>=Mg)break;c.push(gu(e,h,Number.POSITIVE_INFINITY))}return c.map(Gf)}function cK(e,t,n){const r=oK(t),o=eK(t),s=new Map;e.history.forEach((y,w)=>{y.path!==n&&s.set(y.path,gu(e,y.path,w))});for(const y of[...e.statics.keys(),...e.links.keys()])y!==n&&!s.has(y)&&s.set(y,gu(e,y,Number.POSITIVE_INFINITY));const a=[];for(const y of s.values()){const w=sK(y.path,y.title,r);w>0&&a.push({...y,score:w})}let c=null;for(const y of e.templates){const w=e.templateRoutes.get(y.path);if(!c&&!e.statics.has(o)&&y.re.test(o)){c=w;continue}const v=iK(y.path,r);v>=60&&a.push({...Q$(e,w),score:v})}a.sort((y,w)=>w.score-y.score||y.rank-w.rank||xh(y)-xh(w)||bh(y.path)-bh(w.path)||(y.path<w.path?-1:y.path>w.path?1:0));const u=new Map,f=[];for(const y of a){if(!y.template&&y.group!==y.path){const w=u.get(y.group)??0;if(w>=XW&&!aK(y.group,r))continue;u.set(y.group,w+1)}if(f.push(y),f.length>=YW)break}if(f.some(y=>y.score===100))return f.map(Gf);const h={kind:"go",path:o,...c?{title:tv(c.path)}:{}},m=f[0];return!c&&m!==void 0&&m.score>=80&&uK(m.path,r)?[...f.map(Gf),h]:[h,...f.map(Gf)]}function uK(e,t){const n=e.replace(/^\//,"").toLowerCase().slice(t.length);return!t.endsWith("/")&&n.length>0&&!/^[/?#]/.test(n)}function J$(e,{query:t,current:n,here:r}){return t===n||t.trim()===""?lK(e,r):cK(e,t,r)}const dK=[],fK=[];function eC(e,t){const n=L(s=>(t?s.visits[t]:void 0)??dK),r=It(e,"pages"),o=It(e,"links");return at([e],()=>{O_(r)&&un.post(e,{type:"links"})}),E.useMemo(()=>QW(n,r,o),[n,r,o])}function hK({row:e}){if(e.kind!=="page"||!e.template)return d.jsx("span",{className:"bar-route-path row-dim",children:e.path});const{text:t,params:n}=Gh(e.path),r=[];let o=0;for(const[s,a]of n)s>o&&r.push(t.slice(o,s)),r.push(d.jsx("span",{className:"bar-route-param",children:t.slice(s,a)},s)),o=a;return o<t.length&&r.push(t.slice(o)),d.jsx("span",{className:"bar-route-path row-dim",children:r})}function tC({row:e}){return e.kind==="go"?d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"picker-label",children:e.path}),e.title?d.jsx("span",{className:"bar-route-path row-dim",children:e.title}):null,d.jsx("span",{className:"picker-hint row-dim",children:"as typed"})]}):d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"picker-label",children:e.title}),d.jsx(hK,{row:e}),e.badge?d.jsx("span",{className:e.badge==="new"?"badge-new":"badge-changed",children:e.badge}):null]})}const nC=e=>e.kind==="page"&&e.file?e.file:e.path,rC=(e,t)=>e.kind==="page"&&e.template?rK(e.path,t):null,oC=e=>e.kind==="page"&&e.template?"fills in the parameter":"goes there";function sC(e,t,n){return e.kind!=="page"?[]:ap([...e.file&&t.dir?Ls({id:t.worktreeId,dir:t.dir},e.file,{},n):[],$N,...e.visited?WW(t.repoId,e.path,n):[]])}function pK({worktreeId:e,repoId:t,url:n,open:r}){const o=dt(),s=Qe(),a=L(w=>{const v=Kt(w,e);return v?v.worktree.path:null}),c=eC(e,t),u=JW(n),f=n?Zh(n):null,h=E.useCallback((w,v)=>J$(c,{query:v,current:u,here:f}),[c,u,f]),m=E.useCallback(w=>w===u||w.trim()==="",[u]),g=()=>o({a:"close"}),y=E.useMemo(()=>({open:r,onOpen:()=>o({a:"open",overlay:{kind:"routes"}}),id:"routes",className:"bar-path",attrs:Lt("Go to a page",Pt("routes"))}),[r,o]);return d.jsx(qr,{anchored:{matchWidth:0,cover:!1,offset:-1},field:y,items:fK,filter:h,initialQuery:u,selectOnMount:!0,idleWhen:m,onIdlePick:w=>{w.trim()===""?un.post(e,{type:"navigate",path:"/"}):un.post(e,{type:"reload"}),g()},keyOf:w=>`${w.kind}:${w.path}`,rowClass:()=>"picker-row",rowTitle:nC,completionOf:(w,v)=>m(v)?null:Y$(w,v),narrowTo:rC,onPick:w=>{un.post(e,{type:"navigate",path:w.path}),g()},onBack:g,rowMenu:w=>sC(w,{worktreeId:e,repoId:t,dir:a},{sock:s,dispatch:o}),placeholder:"type a path",keys:(w,v)=>({complete:"completes the path",pick:w?oC(w):v.trim()===""?"goes to the root":"reloads",back:"closes"}),empty:"no pages yet; type a path",row:w=>d.jsx(tC,{row:w})})}function iC(e,t){const n=t.trim();return d.jsx(An,{label:oc(e.label,n?Ny(e.label,n):null,0),hint:e.hint&&d.jsx(os,{k:e.hint})})}function aC({anchored:e,trailing:t}){const n=dt(),r=cT(),o=L(s=>{var a;return((a=s.paletteReturn)==null?void 0:a.mode)==="commands"?s.paletteReturn.q:""});return d.jsx(qr,{anchored:e,trailing:t,items:r,filter:uT,rowClass:()=>"picker-row",keyOf:s=>s.id,onPick:(s,a)=>{s.sub?n({a:"palette-return",v:{mode:"commands",q:a}}):n({a:"close"}),s.run()},onBack:()=>n({a:"close"}),placeholder:"run a command…",initialQuery:o,empty:"no matching command",row:(s,a,c)=>iC(s,c)})}function lC(e,t){const n=new Map(t.map(a=>[a.path,a])),r=t.filter(a=>a.xy==="??"&&a.path.endsWith("/")).map(a=>a.path),o=e.map(a=>{const c=n.get(a)??(r.some(u=>a.startsWith(u))?{path:a,xy:"??"}:void 0);return c?{path:a,status:c}:{path:a}}),s=new Set(e);for(const a of t)!s.has(a.path)&&!a.path.endsWith("/")&&o.push({path:a.path,status:a});return o}function mE(e,t){const n=e.split("/"),r=t.split("/");for(let o=0;;o++){const s=n[o],a=r[o];if(s===void 0||a===void 0)return n.length-r.length;const c=o===n.length-1,u=o===r.length-1;if(c!==u)return c?-1:1;if(s!==a)return s<a?-1:1}}function cC(e,t,n,r=50){const o=lC(e,t),s=n.trim().toLowerCase();if(!s){const c=new Map(t.map((m,g)=>[m.path,g])),u=m=>{var g;return c.get(((g=m.status)==null?void 0:g.path)??"")??c.get(m.path)??Number.MAX_SAFE_INTEGER},f=o.filter(m=>m.status).sort((m,g)=>u(m)-u(g)||mE(m.path,g.path)),h=o.filter(m=>!m.status).sort((m,g)=>mE(m.path,g.path));return{rows:[...f,...h].slice(0,r),changed:Math.min(f.length,r)}}const a=dC(o,s);return a.sort((c,u)=>u.score-c.score||c.row.path.localeCompare(u.row.path)),{rows:a.slice(0,r).map(c=>c.row),changed:0}}function uC(e,t){const n=e.toLowerCase(),r=gE(n,t);return r<=0?0:gE(n.slice(n.lastIndexOf("/")+1),t)>0?r+10:r}function dC(e,t){const n=[];for(const r of e){const o=uC(r.path,t);o>0&&n.push({row:r,score:r.status?o+4:o})}return n}function mK(e,t,n,r,o){const s=r.trim().toLowerCase();if(!s)return cC(e,n,r,o).rows.map(u=>({kind:"file",path:u.path,status:u.status}));const a=dC(lC(e,n),s).map(({row:u,score:f})=>({row:{kind:"file",path:u.path,status:u.status},score:f}));for(const u of t){const f=uC(u,s);f>0&&a.push({row:{kind:"folder",path:u},score:f})}const c=u=>u.kind==="folder"?1:0;return a.sort((u,f)=>f.score-u.score||c(u.row)-c(f.row)||u.row.path.localeCompare(f.row.path)),a.slice(0,o).map(u=>u.row)}function gK(e,t){const n=e.toLowerCase(),r=[];let o=0;for(const s of t.toLowerCase()){const a=n.indexOf(s,o);if(a===-1)return null;r.push(a),o=a+1}return r}function gE(e,t){let n=0,r=0,o=0;for(const s of t){const a=e.indexOf(s,r);if(a===-1)return 0;o=a===r?o+1:1,n+=o+(a===0||e[a-1]==="/"||e[a-1]==="."?3:0),r=a+1}return n+Math.max(0,40-e.length/4)}function kK(e){const t=e.lastIndexOf("/");return t===-1?[e,""]:[e.slice(t+1),e.slice(0,t+1)]}const kE=[],wK=[],yK=[];function vK({worktreeId:e}){var _;const t=dt(),n=Qe(),r=Dn(),o=L(x=>x.connected);at([e,o,n],()=>cp(e,r.getState(),{sock:n,dispatch:t}));const s=SN(e),a=s.files??wK,c=((_=s.git)==null?void 0:_.files)??yK,u=cT(),f=L(x=>{var N;return((N=x.paletteReturn)==null?void 0:N.mode)==="quick-open"?x.paletteReturn.q:""}),h=L(x=>{var T;const N=(T=Kt(x,e))==null?void 0:T.worktree;return N?N.path:null}),m=L(x=>{var N;return((N=Kt(x,e))==null?void 0:N.repoId)??null}),g=L(x=>{var N;return((N=Su(x))==null?void 0:N.worktreeId)===e}),y=eC(e,m),w=s.page.url?Zh(s.page.url):null,v=E.useCallback((x,N)=>N.startsWith(">")?uT(u,N.slice(1)).map(T=>({kind:"cmd",c:T})):N.startsWith("/")?g?J$(y,{query:N,current:"/",here:w}).map(T=>({kind:"page",page:T})):kE:cC(a,c,N).rows.map(T=>({kind:"file",path:T.path,status:T.status})),[u,a,c,g,y,w]);return d.jsx(qr,{items:kE,filter:v,keyOf:x=>x.kind==="cmd"?`c:${x.c.id}`:x.kind==="page"?`p:${x.page.kind}:${x.page.path}`:`f:${x.path}`,rowClass:x=>x.kind==="file"?"qo-file":"picker-row",rowTitle:x=>x.kind==="page"?nC(x.page):void 0,completionOf:(x,N)=>x.kind==="page"?Y$(x.page,N):null,narrowTo:(x,N)=>x.kind==="page"?rC(x.page,N):null,onPick:(x,N)=>{x.kind==="cmd"?(x.c.sub?t({a:"palette-return",v:{mode:"quick-open",q:N}}):t({a:"close"}),x.c.run()):x.kind==="page"?(un.post(e,{type:"navigate",path:x.page.path}),t({a:"close"})):(Pn({dispatch:t},{worktreeId:e,path:x.path,view:Li(x.path)}),t({a:"close"}))},onBack:()=>t({a:"close"}),rowMenu:x=>x.kind==="file"&&h?Ls({id:e,dir:h},x.path,{},{sock:n,dispatch:t}):x.kind==="page"&&m?sC(x.page,{worktreeId:e,repoId:m,dir:h},{sock:n,dispatch:t}):[],placeholder:"jump to file · type > for commands, / for pages",keys:(x,N)=>N.startsWith("/")?{complete:"completes the path",pick:(x==null?void 0:x.kind)==="page"?oC(x.page):void 0,back:"closes"}:{pick:"opens",back:"closes"},initialQuery:f,empty:x=>x.startsWith(">")?"no matching command":x.startsWith("/")?g?"no pages yet; type a path":"no preview running":"no matches",row:(x,N,T)=>x.kind==="cmd"?iC(x.c,T.slice(1)):x.kind==="page"?d.jsx(tC,{row:x.page}):Vk(x.path,x.status,T,{gutter:c.length>0})})}function Vk(e,t,n,{folder:r=!1,gutter:o=!0}={}){const[s,a]=kK(e),c=n.trim()?gK(e,n.trim()):null;return d.jsxs(d.Fragment,{children:[o&&d.jsx("span",{className:`xy ${t?zw(t.xy):""}`,children:t?Fw(t.xy):""}),d.jsxs("span",{className:"name",children:[oc(s,c,a.length),r&&"/"]}),d.jsx("span",{className:"dir row-dim",children:a&&d.jsxs(d.Fragment,{children:["‎",oc(a,c,0),"‎"]})}),t&&d.jsx(Hj,{f:t})]})}function bK(e,t,n){var a;if(!e)return null;if(e.available)return e.checkFailed?{kind:"unready",text:e.checkFailed,retry:null}:((a=e.auth)==null?void 0:a.kind)==="none"?{kind:"unready",text:e.loginHint??`${e.name} is not logged in`,retry:null}:null;const r=n?t.find(c=>c.available&&c.id!==e.id):void 0,o=r?{other:r}:{};return e.installing?{kind:"installing",text:`${e.name} is installing`,retry:null,...o}:{kind:"failed",text:typeof e.install=="object"?`${e.name} did not install: ${e.install.failed}`:`${e.name} is not ready: ${Ip(e)}`,retry:Jy(e),...o}}function Ms({icon:e,verb:t,tip:n,onPress:r,busy:o,onDismiss:s,className:a,children:c}){return d.jsxs("div",{className:Ke("composer-offer",a),children:[d.jsx(kt,{name:e,className:"icon-inline"}),d.jsxs("span",{className:Ke("composer-offer-line",o&&"live-text"),children:[t&&d.jsxs(d.Fragment,{children:[d.jsx(Oe,{variant:"inline",tone:"strong","data-tip":n,onClick:r,children:t})," "]}),c]}),s&&d.jsx(At,{icon:"close",tone:"quiet",className:"composer-offer-close",label:"Not this one",onClick:s})]})}function fC({item:e,n:t,onRemove:n}){const r=Lr();return e.kind==="image"?d.jsx(Tp,{src:e.local??r.upload(e.upload),n:t,name:e.name,width:e.width,height:e.height,bytes:e.bytes,uploading:e.uploading,progress:e.progress,onRemove:n}):e.kind==="file"?d.jsx(_p,{name:e.name,bytes:e.bytes,href:e.text&&e.upload?r.upload(e.upload):void 0,uploading:e.uploading,progress:e.progress,onRemove:n}):d.jsx(Sp,{n:t,name:e.name,source:e.source,lines:e.lines,chars:e.chars,preview:e.preview,text:e.text,onRemove:n})}function hC({children:e}){return d.jsx("code",{className:"composer-offer-whole",children:e})}function xK({children:e}){var n;if(!e.includes("://"))return d.jsx(hC,{children:e});const t=[];for(const r of e.split(" ")){const o=t.length-1;r.includes("://")||o<0||(n=t[o])!=null&&n.includes("://")?t.push(r):t[o]=`${t[o]} ${r}`}return d.jsx("code",{children:t.map((r,o)=>d.jsxs(E.Fragment,{children:[o>0&&" ",r.includes("://")?r.split(new RegExp("(?=\\/)(?<![:/])")).map((s,a)=>d.jsxs(E.Fragment,{children:[a>0&&d.jsx("wbr",{}),d.jsx("span",{className:"composer-offer-whole",children:s})]},a)):d.jsx("span",{className:"composer-offer-whole",children:r})]},o))})}function EK({offer:e,onInstall:t,onDismiss:n}){if(e.state==="installing")return d.jsx(Ms,{icon:"download",busy:!0,children:"Installing Toyon with npm"});if(e.state==="installed")return d.jsxs(Ms,{icon:"check",className:"composer-offer-long",onDismiss:n,children:["Toyon is installed. In a new terminal, ",d.jsx(hC,{children:"toyon restart"})," moves onto it."]});if(e.state==="failed"){const r=_W(e);return d.jsxs(Ms,{icon:"download",verb:"try again",tip:"Run the install again",className:"composer-offer-long",onPress:t,onDismiss:n,children:[r.why,"."," ",r.permissions&&d.jsxs(d.Fragment,{children:[d.jsx("a",{href:SW,target:"_blank",rel:"noreferrer",children:"npm's guide"})," ","covers this error."," "]}),"By hand: ",d.jsx(xK,{children:r.command})]})}return d.jsx(Ms,{icon:"download",verb:"install",tip:"Toyon started with npx does not update itself and leaves no toyon command. This runs npm install -g toyon.",onPress:t,onDismiss:n,children:"Toyon for good, so it updates itself"})}function pC(e){return cu(e.key)&&(e.metaKey||e.ctrlKey)&&!e.altKey?!1:e.metaKey||e.ctrlKey||e.altKey}const mC=e=>e.length===1&&e>="1"&&e<="9",cu=e=>e==="Enter"||e==="NumpadEnter";function SK(e,t,n){const r=cu(e.key)&&(e.metaKey||e.ctrlKey);return t?e.key==="Escape"||e.key==="Tab"&&!e.shiftKey?{kind:"field-leave"}:r?{kind:"submit"}:cu(e.key)&&!e.shiftKey?{kind:"field-enter"}:{kind:"typing"}:pC(e)?{kind:"chord"}:e.key==="Escape"?{kind:"escape"}:r?{kind:"submit"}:cu(e.key)||e.key===" "&&n.spacePicks?n.cursor===void 0?{kind:"submit"}:{kind:"pick",at:n.cursor,by:cu(e.key)?"enter":"space"}:e.key==="ArrowUp"||e.key==="ArrowDown"?n.cursor===void 0?null:{kind:"cursor",to:Gu(n.cursor,e.key==="ArrowUp"?-1:1,n.count)}:mC(e.key)&&Number(e.key)<=n.count?{kind:"pick",at:Number(e.key)-1,by:"digit"}:null}function ov(e,t){var o,s,a,c;const n=e.target instanceof HTMLTextAreaElement,r=SK(e,n,t);if(!r)return!1;switch(r.kind){case"chord":case"typing":return!0;case"escape":case"field-leave":return e.preventDefault(),e.stopPropagation(),(o=r.kind==="escape"?t.onEscape:t.onFieldLeave)==null||o(),!0;case"submit":return e.preventDefault(),t.onSubmit?t.onSubmit():n?(s=t.onFieldEnter)==null||s.call(t):t.cursor!==void 0&&t.onPick(t.cursor,"enter"),!0;case"pick":return e.preventDefault(),t.onPick(r.at,r.by),!0;case"cursor":return e.preventDefault(),(a=t.onCursor)==null||a.call(t,r.to),!0;case"field-enter":return e.preventDefault(),(c=t.onFieldEnter)==null||c.call(t),!0}}function gC(e){return!e||e===document.body?!1:e.closest(".monaco-editor, .xterm")?!0:(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement)&&!e.closest(".chat-input")}function _K(e,t){at([t],()=>{const o=requestAnimationFrame(()=>{var s;gC(document.activeElement)||(s=e.current)==null||s.focus()});return()=>cancelAnimationFrame(o)});const n=E.useRef(!1),r=E.useCallback(()=>{requestAnimationFrame(()=>{var o;document.activeElement===document.body&&((o=e.current)==null||o.focus())})},[e]);return E.useEffect(()=>{const o=()=>{n.current=!0},s=()=>{n.current=!1,r()};return window.addEventListener("pointerdown",o,!0),window.addEventListener("pointerup",s,!0),window.addEventListener("pointercancel",s,!0),()=>{window.removeEventListener("pointerdown",o,!0),window.removeEventListener("pointerup",s,!0),window.removeEventListener("pointercancel",s,!0)}},[r]),o=>{!o.relatedTarget&&!n.current&&r()}}function Eh(e){var n,r;const t=document.activeElement;gC(t)||t&&((n=e.current)!=null&&n.contains(t))||(r=e.current)==null||r.focus({preventScroll:!0})}function Sh({root:e,id:t,onKeyDown:n,onKeyUp:r,onPaste:o,children:s}){const a=_K(e,t);return d.jsx("div",{ref:e,className:"card",tabIndex:-1,onKeyDown:n,onKeyUp:r,onPaste:o,onBlur:a,children:s})}function zu({children:e,sub:t}){return d.jsxs("div",{className:"card-head",children:[d.jsx("div",{className:"card-text",children:e}),t&&d.jsx("div",{className:"card-sub",children:t})]})}function Yk(e){const t=E.useRef(null),n=Yy(t);return"html"in e?d.jsxs("div",{ref:t,className:"card-band md",children:[d.jsx("div",{dangerouslySetInnerHTML:{__html:e.html}}),n]}):d.jsxs("div",{ref:t,className:"card-band card-code",children:[d.jsx("pre",{children:e.code}),n]})}function NK({children:e}){return d.jsx("div",{className:"card-foot",children:e})}const jK=[{selected:[]}];function TK({item:e,worktreeId:t,rootRef:n}){var V,ee;const r=Qe(),o=dt(),s=It(t,"card"),a=L(F=>{var $;return($=Kt(F,t))==null?void 0:$.worktree.mode})??e.mode,c=a==="plan"?"auto":a,u=(s==null?void 0:s.id)===e.id?s.draft:jK,f=(V=u[0])==null?void 0:V.note,h=f!==void 0,m=h?Number(((ee=u[0])==null?void 0:ee.selected[0])??0):-1,g=(F,$=0)=>o({a:"card-draft",id:t,card:{id:e.id,draft:[{...F[0]??{selected:[]},selected:[String($)]}],current:0}}),y=E.useRef(null),[w,v]=E.useState(0),[_,x]=E.useState(null),N=_!==null,T=e.pieces.length===1?e.pieces[0]:void 0,j=e.plan,A=()=>{j&&Pn({dispatch:o},{worktreeId:t,path:j,view:"preview"})},R=E.useMemo(()=>T?Ta(T.plan):"",[T]),C=E.useMemo(()=>T?qN(e,T):[{fate:"worktree",label:"go"},{fate:null,label:"not now"}],[e,T]),M=F=>{if(N||!r)return;const $=C[F];$&&($.fate===null?r.send(Cx(e,t,!1,void 0)):(T&&$.fate!==Hs(e,T)&&r.send(ZN(e,t,T.id,$.fate)),r.send(Cx(e,t,!0,f)),x(F)),o({a:"answered",id:t}))},I=()=>{const F=C[w],$=F&&F.fate!==null?w:C.findIndex(Q=>Q.fate!==null);$!==-1&&((!h||m!==$)&&g(ih(u,0,f??""),$),v($),requestAnimationFrame(()=>{var Q;return(Q=y.current)==null?void 0:Q.focus()}))},D=()=>o({a:"card-park",id:t,cardId:e.id}),H=()=>{var $;const F=ou(u,0);F!==u&&g(F,m),($=n.current)==null||$.focus()},Z=F=>{ov(F,{count:C.length,cursor:w,onCursor:v,onPick:M,onEscape:D,onFieldEnter:()=>M(m),onFieldLeave:H})||(F.key==="n"?(F.preventDefault(),I()):F.key==="r"&&j&&!T&&(F.preventDefault(),A()))},B=C.map((F,$)=>({label:F.label,..._===$?{description:"starting"}:F.description?{description:F.description}:{},...F.fate!==null?{hint:{k:"n",label:"add context",icon:"edit",on:!h}}:{},tone:F.fate===null?"deny":void 0,checked:h&&$===m,field:h&&$===m?{ref:y,value:f??"",placeholder:T?F.fate==="here"?"a note for this worktree's agent, sent with it":"a note for the agent there, sent with it":"a note for every agent this hands to, sent with go",enterKeyHint:"send",onChange:Q=>g(ih(u,0,Q),m),onSend:()=>M(m)}:void 0,disabled:N}));if(T)return d.jsxs(Sh,{root:n,id:e.id,onKeyDown:Z,children:[d.jsx(zu,{sub:d.jsxs(d.Fragment,{children:[T.project?`Starts a worktree in ${T.project.name}, in ${c} mode${c==="auto"?", which runs without asking":""}, with this as its plan. `:"","Nothing has started yet."]}),children:kk(e)}),d.jsx(Yk,{html:R}),d.jsx(nc,{rows:B,cursor:w,onCursor:F=>{v(F),Eh(n)},onPick:M})]});const J=j?d.jsx(Oe,{variant:"inline","data-tip":"Open it beside the box; any row can still be moved (r)",onClick:()=>A(),children:"The list is on its page"}):"The list is the agent's";return d.jsxs(Sh,{root:n,id:e.id,onKeyDown:Z,children:[d.jsx(zu,{sub:d.jsxs(d.Fragment,{children:[J,". Nothing has started yet."]}),children:kk(e)}),d.jsx(nc,{rows:B,cursor:w,onCursor:F=>{v(F),Eh(n)},onPick:M})]})}function $K(e,t){if(t.queued>0||t.sending||t.card)return null;const n=e.at(-1);if(!n)return null;if(n.kind==="stopped"||n.kind==="error"){if(n.seq===void 0)return null;const o=`${n.kind}:${n.seq}`;return t.dismissed.has(o)?null:n.kind==="stopped"?{verb:"continue",key:o,after:"stop"}:{verb:"continue",key:o,after:"error",...CK(e)?{again:!0}:{}}}if(n.kind!=="tool"||!n.done||!n.fixable||t.dismissed.has(n.id)||e.some(o=>o.kind==="asked"&&o.toolId===n.id))return null;const r=Vy(n);return r===null?null:{verb:"fix",key:n.id,toolId:n.id,command:r}}function CK(e){const[t,n,r]=e.slice(-3);return(r==null?void 0:r.kind)==="error"&&(n==null?void 0:n.kind)==="asked"&&n.about==="failed"&&(t==null?void 0:t.kind)==="error"&&t.text===r.text}let Xk=new Set;const Qk=new Set;function IK(e){return Qk.add(e),()=>{Qk.delete(e)}}function wE(e){Xk=new Set(Xk).add(e);for(const t of Qk)t()}function AK(){return E.useSyncExternalStore(IK,()=>Xk)}const RK=e=>Ih.some(t=>t.id===e);function OK(e){return[...Ih.map(t=>({name:t.id,description:t.description,hint:"[<description>]"})),{name:"check",description:"run the repo's check here and write the recap and the commit message",hint:"[<note for the commit message>]"},{name:"land",description:e},{name:"archive",description:"archive this worktree once its work has landed"},{name:"handoff",description:"a new worktree for part of this work, here or in another project, born with a plan for it",hint:"[<project>] [<message>]"}]}function MK(e,t,n){const r=e.trim();if(!r)return{pick:!0};const o=t.find(h=>h.id===n),s=r.search(/\s/),a=s===-1?r:r.slice(0,s),c=s===-1?void 0:r.slice(s).trim()||void 0,u=a.toLowerCase(),f=u==="here"?o:t.find(h=>h.name.toLowerCase()===u);return f?{repo:f,...c?{text:c}:{}}:o?{repo:o,text:r}:{pick:!0}}function kC(e,t){const n=new Set(e.map(o=>o.name)),r=t.filter(o=>!n.has(o.name));return{yours:r.filter(o=>o.origin),own:e,rest:r.filter(o=>!o.origin)}}function yE(e,t){const n=kC(e,t);return[...n.yours,...n.own,...n.rest]}function vE(e,t){const n=kC(e,t);return{rows:[...n.yours,...n.own],more:n.rest.length}}function LK(e,t){var r;const n=/^\/(\S+) $/.exec(e);return n?((r=t.find(o=>o.name===n[1]))==null?void 0:r.hint)??null:null}function PK(e,t){const n=/^\/(\S*)([\s\S]*)$/.exec(e);if(!n)return null;const r=n[1]??"";return t.some(o=>o.name===r)?{name:r,args:(n[2]??"").trim()}:null}function DK(e,t){var r;const n=[];for(const o of e){const s=Lh((r=t==null?void 0:t[o])==null?void 0:r.at);!s||s.by==="hand"||(s.by==="agent"?n.push(`Running its own ${o} here now: the agent asked for it before changing the backend.`):n.push(`Running its own ${o} here now: this branch changed ${s.file??"it"}.`))}return n.length>0?n.join(" "):null}function zK(e){const t=e.findIndex(n=>n.kind.startsWith("reject"));return t<0?null:t}function FK(e){const{key:t}=e;return t.length!==1||t===" "||t==="n"||mC(t)||pC(e)?null:t}const bE=[{selected:[]}];function BK({item:e,ask:t,worktreeId:n,rootRef:r}){var Z;const o=Qe(),s=dt(),a=L(B=>B.activeId),c=It(n,"card"),u=(c==null?void 0:c.id)===e.id?c.draft:bE,f=(Z=u[0])==null?void 0:Z.note,h=f!==void 0,m=h?t.choices.findIndex(B=>{var J;return B.id===((J=u[0])==null?void 0:J.selected[0])}):-1,g=E.useRef(null),[y,w]=E.useState(0),v=t.plan,_=E.useMemo(()=>t.detail&&!v?Ta(t.detail):"",[t.detail,v]),x=L(B=>B.frame==="phone"),N=()=>{v&&a===n&&!x&&Pn({dispatch:s},{worktreeId:n,path:v,view:"preview",focus:!1})};at([e.id,v],N);const T=t.handoff,j=L(B=>{var V;const J=T?(V=Mr(B,n).chat)==null?void 0:V.find(ee=>ee.kind==="handoff"&&ee.id===T):null;return(J==null?void 0:J.kind)==="handoff"?J:null}),A=B=>s({a:"card-draft",id:n,card:{id:e.id,draft:B,current:0}}),R=(B,J)=>{const V=t.choices[B];V&&(A([{selected:[V.id],note:J}]),w(B),requestAnimationFrame(()=>{const ee=g.current;ee&&(ee.focus(),ee.setSelectionRange(ee.value.length,ee.value.length))}))},C=B=>{const J=t.choices[B];if(!J)return;const V=f==null?void 0:f.trim();o==null||o.send({t:"agent-decide",worktreeId:n,askId:e.id,choiceId:J.id,...V?{note:V}:{}}),s({a:"answered",id:n})},M=()=>s({a:"card-park",id:n,cardId:e.id}),I=()=>{var B;f!=null&&f.trim()||A(bE),(B=r.current)==null||B.focus()},D=B=>{if(ov(B,{count:t.choices.length,cursor:y,onCursor:w,onPick:C,onEscape:M,onFieldEnter:()=>C(m),onFieldLeave:I}))return;if(B.key==="n"){B.preventDefault(),R(y,f??"");return}const J=FK(B);J!==null&&(B.preventDefault(),R(h?m:zK(t.choices)??y,(f??"")+J))},H=t.choices.map((B,J)=>{const V=B.kind.startsWith("reject"),ee=h&&J===m;return{label:B.name,tone:V?"deny":void 0,hint:{k:"n",label:"add context",icon:"edit",on:!h},checked:ee,field:ee?{ref:g,value:f,placeholder:V?"what to change, sent with your no":"a note for the work, sent with your yes",enterKeyHint:"send",onChange:F=>A([{selected:[B.id],note:F}]),onSend:()=>C(m)}:void 0}});return d.jsxs(Sh,{root:r,id:e.id,onKeyDown:D,children:[d.jsx(zu,{sub:j?d.jsxs(d.Fragment,{children:[v6(j,n)," ",d.jsx(Oe,{variant:"inline","data-tip":"Read the list at the head of the plan; any row can still be moved",onClick:()=>v&&Pn({dispatch:s},{worktreeId:n,path:v,view:"preview"}),children:"The list is on the plan"}),"."]}):void 0,children:t.title}),t.command&&d.jsx(Yk,{code:x$(t.command)}),_&&d.jsx(Yk,{html:_}),d.jsx(nc,{rows:H,cursor:y,onCursor:B=>{w(B),Eh(r)},onPick:C,onHint:B=>R(B,f??"")})]})}function UK({item:e,ask:t,worktreeId:n,rootRef:r,numbers:o,onAnswer:s}){const a=Qe(),c=dt(),u=Dn(),f=L(te=>te.clientId),{message:h,questions:m}=t,g=Fl(e.id),y=It(g,"attachments"),w=nj(g,n),v=It(n,"card"),_=E.useMemo(()=>(v==null?void 0:v.id)===e.id?v:{id:e.id,draft:y4(m),current:0},[v,e.id,m]),{draft:x,current:N}=_,T=N===Ml(m),j=m[N],A=x[N],R=!!(j!=null&&j.multi),[C,M]=E.useState(()=>Ol(j,A)),I=E.useRef(null);E.useEffect(()=>{const te=window.visualViewport;if(!te)return;const pe=()=>{I.current&&I.current===document.activeElement&&I.current.scrollIntoView({block:"nearest"})};return te.addEventListener("resize",pe),()=>te.removeEventListener("resize",pe)},[]);const D=(te,pe)=>c({a:"card-draft",id:n,card:{id:e.id,draft:te,current:pe}}),H=xN(),Z=te=>{if(H)return;if(s){te&&s(te);return}const pe=te?y:[],ue={t:"agent-answer",worktreeId:n,askId:e.id,...te?{answers:te}:{}};pe.some(Mi)?c({a:"hold-send",id:g,log:n,text:Ow(m,te).join(`
262
- `),frame:ue}):(a==null||a.send({...ue,...pe.length?{attachments:pe.map(Ul),boxId:g,clientId:f}:{}}),pe.length&&c({a:"clear-attachments",id:g})),c({a:"answered",id:n})},B=()=>c(s?{a:"ask-revive",id:n}:{a:"card-park",id:n,cardId:e.id}),J=()=>{fg(m,x)&&Z(x)},V=te=>{M(Ol(m[te],x[te])),D(x,te)},ee=te=>{j!=null&&j.note&&(D(sx(x,N,te,R),N),requestAnimationFrame(()=>{var pe;return(pe=I.current)==null?void 0:pe.focus()}))},F=te=>{if(!(j!=null&&j.note))return;const pe=j.options[te];if(M(te),!pe||R)return ee(!pe);D(sx(ox(x,N,pe.value,!1),N,!1,!1),N),requestAnimationFrame(()=>{var ue;return(ue=I.current)==null?void 0:ue.focus()})},$=()=>F(C),Q=te=>{const pe=C4(m,te,N);M(pe.cursor),D(te,pe.current),pe.send&&fg(m,te)&&Z(te)},q=te=>{if(ix(j,te))return M(te),ee(!0);const pe=j==null?void 0:j.options[te];if(!j||!pe)return;const ue=ox(ou(x,N),N,pe.value,R);if(R){M(te),D(ue,N);return}Q(ue)},W=te=>{if(!R||ix(j,te)||!b4(j,x[N]))return q(te);Q(ou(x,N))},oe=()=>{var pe;const te=ou(x,N);te!==x&&(D(te,N),M(Ol(j,te[N]))),(pe=r.current)==null||pe.focus()},de=()=>{var pe;const te=ou(x,N);if((pe=r.current)==null||pe.focus(),!Na(te[N])){te!==x&&(D(te,N),M(Ol(j,te[N])));return}Q(te)},he=te=>{if(w.onPasteKey(te),!ov(te,{count:T?m.length:v4(j),cursor:T?void 0:C,spacePicks:R,onCursor:M,onPick:(pe,ue)=>T?V(pe):ue==="enter"?W(pe):q(pe),onSubmit:J,onEscape:B,onFieldEnter:de,onFieldLeave:oe})){if(te.key==="ArrowLeft"||te.key==="ArrowRight"||te.key==="Tab"){te.preventDefault();const pe=te.key==="ArrowLeft"||te.key==="Tab"&&te.shiftKey;return V(j4(N,pe?-1:1,$4(m)))}if(te.key==="n"&&(j!=null&&j.note))return te.preventDefault(),$();if(te.key==="s"&&!s)return te.preventDefault(),Z()}},Ne=te=>m.length===1&&!te.multi,Me=(te,pe)=>d.jsxs(NK,{children:[(!te||!Ne(te))&&d.jsx(Oe,{variant:"outline",size:"md",disabled:H||!fg(m,x),onClick:J,children:"send"}),(te==null?void 0:te.note)&&pe&&pe.selected.length>0&&pe.note===void 0&&d.jsxs(Oe,{tone:"quiet",size:"md",onClick:()=>ee(!1),children:[d.jsx(os,{k:"n",chip:!0}),"add a note"]}),!s&&d.jsxs(Oe,{tone:"quiet",size:"md",onClick:()=>Z(),children:[d.jsx(os,{k:"s",chip:!0}),"skip"]}),d.jsx(At,{className:"card-attach",icon:"attach",tone:"chrome",label:"Attach a picture or a file",onClick:()=>QN(u,g)})]}),Be=y.length>0&&d.jsx(mp,{children:d.jsx("div",{className:"card-chips",children:pw(y,o).map(([te,pe])=>{const ue=()=>c({a:"detach",id:g,key:te.key});return te.kind==="pick"?null:d.jsx(fC,{item:te,n:pe,onRemove:ue},te.key)})})}),K=(te,pe)=>{const ue=pe===N,ie=x[pe],ye=b_(ie,!!te.multi),Se=Le=>({ref:ue?I:void 0,value:(ie==null?void 0:ie.note)??"",placeholder:Le,enterKeyHint:Ml(m)===-1?"send":"next",onChange:Ue=>D(ih(x,pe,Ue),pe),...Ml(m)===-1?{onSend:de}:{}}),Ee=te.options.map(Le=>{const Ue=!!(ie!=null&&ie.selected.includes(Le.value));return{label:d.jsxs(d.Fragment,{children:[Mw(Le.label),I4(Le.label)&&d.jsx("span",{className:"badge-recommended",children:"recommended"})]}),description:Le.description,sample:Le.preview,hint:te.note&&!te.multi?{k:"n",label:"add a note",icon:"edit",on:(ie==null?void 0:ie.note)===void 0}:void 0,checked:Ue,field:Ue&&!ye&&(ie==null?void 0:ie.note)!==void 0?Se("a note for the agent, sent with your pick"):void 0}});return te.note&&Ee.push({label:te.note.label,description:ye?void 0:"your own answer",checked:ye,field:ye?Se("your own answer"):void 0}),d.jsxs("div",{className:Ke("card-page",!ue&&"card-page-off"),children:[d.jsx(zu,{children:te.text||h}),ue&&Be,d.jsx(nc,{rows:Ee,cursor:ue?C:void 0,onCursor:Le=>{M(Le),Eh(r)},onPick:Le=>{var Ue;q(Le),(Ue=r.current)==null||Ue.focus()},onHint:F}),Me(te,ie)]},te.id)};return d.jsxs(Sh,{root:r,id:e.id,onKeyDown:he,onKeyUp:w.onPasteKeyUp,onPaste:w.onPaste,children:[m.length>1&&d.jsx("div",{className:"card-tabs",children:d.jsx(Vu,{label:"questions",owner:"ask",items:[...m.map((te,pe)=>({id:String(pe),label:te.header||`question ${pe+1}`,lead:d.jsx("span",{className:Ke("dot card-step",Na(x[pe])&&"answered")})})),{id:String(m.length),label:"send",far:!0}],current:String(N),onPick:te=>{var pe;V(Number(te)),(pe=r.current)==null||pe.focus()}})}),d.jsxs("div",{className:"card-pages",children:[m.map(K),Ml(m)!==-1&&d.jsxs("div",{className:Ke("card-page",!T&&"card-page-off"),children:[d.jsx(zu,{children:"Send these answers?"}),T&&Be,d.jsx(nc,{hover:!0,rows:m.map((te,pe)=>{const ue=Na(x[pe])?E_(te,x[pe]):void 0;return{label:d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"row-dim",children:te.header||`question ${pe+1}`})," ",d.jsx("span",{className:Ke(!ue&&"row-dim"),children:ue?ue.pick:"no answer yet"})]}),description:ue==null?void 0:ue.note}}),onPick:te=>{var pe;V(te),(pe=r.current)==null||pe.focus()}}),Me()]})]})]})}const HK=lj("top"),WK=5*6e4;function wC({usage:e,limits:t,auth:n,now:r}){const o=t?VF(t,r):[],s=o.length?BF(n):void 0,a=t&&r-t.at>WK?Hw(r-t.at):null,c=(e==null?void 0:e.cost)!==void 0?` · ${Xu(e.cost)}`:"";return d.jsxs("div",{className:"usage-figures",children:[e&&d.jsx(xE,{name:"context",used:e.used/e.size,sub:`${Qx(e.used)} of ${Qx(e.size)}${c}`}),s&&d.jsx("div",{className:"usage-who section-title",children:s}),o.map(u=>d.jsx(xE,{name:u.name,used:u.used,sub:u.sub},u.key)),a&&d.jsxs("div",{className:"usage-stale hint",children:["read ",a," ago"]})]})}function KK({onClose:e,...t}){return d.jsx(Ws,{className:"usage-panel",anchor:"parent",placement:HK,onDismiss:e,onKey:n=>{n.key==="Escape"&&(n.stopPropagation(),e())},children:d.jsx(wC,{...t})})}function xE({name:e,used:t,sub:n}){const r=Math.max(0,Math.min(1,t));return d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"usage-row",children:[d.jsx("span",{className:"usage-name",children:e}),d.jsx("span",{className:"meter",children:d.jsx("span",{className:"meter-fill",style:{"--meter":r}})}),d.jsxs("span",{className:"usage-fig",children:[Math.round(100*t),"%"]})]}),d.jsx("div",{className:"usage-sub hint",children:n})]})}function yC(e,t,n){const r=E.useRef(n);r.current=n,at([e,t,n==null?void 0:n.id],()=>{if(!e||!t)return;const o=()=>{const s=r.current;s!=null&&s.available&&e.send({t:"agent-check",agent:s.id})};return o(),window.addEventListener("focus",o),()=>window.removeEventListener("focus",o)})}const EE="not answering; send once Toyon is back",SE=[],qK=[],ZK=new Set(["ArrowLeft","ArrowRight","Home","End","PageUp","PageDown"]),GK=150,VK=3,_E=e=>({kind:"cmd",c:e});function YK(e,t,n){var r;return((r=n.find(o=>o.proposalId===e.proposalId&&o.pieceId===t))==null?void 0:r.title)??"another piece"}function XK(e,t,n,r){return e==="command"?r?n===0?d.jsx("span",{className:"live-text",children:"starting the agent to see what it offers"}):"no matching command":"no session has run this agent yet, so it has offered no commands":t?"no matches":d.jsx("span",{className:"live-text",children:"listing files"})}function QK(e){return e.kind==="cmd"?`/${e.c.name} `:e.kind==="folder"?`@${e.path}/ `:e.kind==="worktree"?`@${e.title} `:e.kind==="changes"?"@changes ":`@${e.path} `}function ku({active:e,draft:t,archived:n,found:r,project:o,greenfield:s,placement:a="dock"}){var xc,Ec,Sc,sl,bd,xd,Es,il,oi,al,_c;const c=a==="screen",u=dt(),f=Qe(),h=Dn(),m=!!t,g=(e==null?void 0:e.worktree.id)??null,y=e==null?void 0:e.worktree.repoId,w=o?Xl:n?n.id:r?r.id:Pa(e),v=!!n||!!r,_=n?n.restorable:!!r&&!r.locked,x=It(w,"draft"),N=It(w,"attachments"),T=It(w,"notice"),j=Object.entries((e==null?void 0:e.worktree.sources)??{}).filter(([,z])=>Lh(z.at)).map(([z])=>z).join(","),A=E.useRef({id:g,owns:j});at([g,j],()=>{const z=A.current;if(A.current={id:g,owns:j},z.id!==g||z.owns===j||!j||!w||n)return;const $e=new Set(z.owns.split(",").filter(Boolean)),ft=DK(j.split(",").filter(Nt=>!$e.has(Nt)),e==null?void 0:e.worktree.sources);ft&&u({a:"notice",id:w,text:ft})});const R=It(w,"mark"),C=(R==null?void 0:R.by)==="walk"?R:void 0,M=It(g,"chat"),I=It(g,"queue"),D=E.useMemo(()=>g&&!m?fy(M):null,[g,m,M]),H=It(g,"cardParked"),Z=It(g,"sending"),B=E.useMemo(()=>g&&!m&&!Z?v_(M):null,[g,m,Z,M]),J=It(g,"askRevived"),V=!D&&B&&J===B.id?B:null,ee=D&&H!==D.id?D:V,F=V?Fl(V.id):null,$=It(F,"attachments"),Q=D?H===D.id?D:null:B&&!V?B:null,q=E.useRef(null),W=Bi(),oe=sy(),de=It(oe,"page"),he=Ku(),Ne=P3(),Me=U$(),Be=jW(),K=L(z=>z.globalInstall),te=!!Me&&!!g&&!m&&!ee&&TW({prompt:Me,offered:Be,agent:e==null?void 0:e.agent,chat:M}),pe=AK(),ue=E.useMemo(()=>g&&!m?$K(M,{queued:I.length,sending:!!Z,card:!!(ee||Q),dismissed:pe}):null,[g,m,M,I.length,Z,ee,Q,pe]),ie=z=>w&&u({a:"set-draft",id:w,text:z}),ye=L(z=>z.clientId),Se=L(z=>z.repos),Ee=L(z=>z.repos.find($e=>$e.id===(e==null?void 0:e.worktree.repoId))??null),Le=L(z=>z.defaultAgent),Ue=L(z=>z.agentChosen),Je=m||!!s||!!o,Ht=!Je&&!!e&&!e.worktree.agent,qt=Je||Ht,xt=(t==null?void 0:t.agent)??Le,Ze=L(z=>z.agents.find($e=>$e.id===(qt?xt:e==null?void 0:e.worktree.agent)));yC(f,g??(Je?"new":null),Ze);const _t=!!(Ze!=null&&Ze.quick),mt=(Ze==null?void 0:Ze.models)??SE,De=(Ze==null?void 0:Ze.efforts)??SE,nt=Ze==null?void 0:Ze.defaultModel,lt=Ze==null?void 0:Ze.defaultEffort,Yt=((xc=Ze==null?void 0:Ze.picks)==null?void 0:xc.model)??"",$n=((Ec=Ze==null?void 0:Ze.picks)==null?void 0:Ec.effort)??"",gt=(z,$e,ft)=>f==null?void 0:f.send({t:"set-agent-pick",agent:z,field:$e,value:ft}),rt=z=>gt(xt,"model",z),Kn=z=>gt(xt,"effort",z),Qt=L(z=>z.agents),Cn=(z,$e)=>{gt(z,"model",$e),z!==xt&&qn(z)},qn=z=>{m?u({a:"draft-agent",id:z}):f==null||f.send({t:"set-default-agent",agent:z})},dn=bK(Ze,Qt,qt),yn=dn==null?void 0:dn.other,ne=It(g,"model"),we=It(g,"effort"),qe=It(g,"usage")??(e==null?void 0:e.usage),ot=((Sc=Ee==null?void 0:Ee.picks)==null?void 0:Sc.mode)??Wg,Tt=z=>{Ee&&(f==null||f.send({t:"set-repo-pick",repoId:Ee.id,field:"mode",value:z}))},Dt=(e==null?void 0:e.worktree.mode)??Wg,P=L(z=>z.picking),se=L(z=>z.layout.term),je=C_((e==null?void 0:e.procs)??[]),Fe=vn("composer"),Rt=It(g,"files"),Zt=E.useMemo(()=>R_(Rt??qK),[Rt]),Ae=L(z=>z.visible),We=L(z=>z.shipping),Ve=E.useMemo(()=>jp(Ae,y,g,We),[Ae,y,g,We]),Xt=L(z=>y?z.archived[y]:void 0),Wt=E.useMemo(()=>o$(Ve,Xt),[Ve,Xt]),bn=E.useMemo(()=>r$(Rt,Wt),[Rt,Wt]),xn=E.useMemo(()=>[...Ve,...(Xt??[]).map(z=>({title:z.title,branch:z.branch,dir:z.path.slice(z.path.lastIndexOf("/")+1)}))],[Ve,Xt]),Ct=It(g,"git"),Jt=(Ct==null?void 0:Ct.files.length)??(e==null?void 0:e.dirty)??0,sr=(Ct==null?void 0:Ct.unpushed)??(e==null?void 0:e.unpushed)??0,Gt=L(z=>{var $e;return g?($e=z.shipping[g])==null?void 0:$e.op:void 0}),Rn=L(z=>{var $e;return g?($e=z.shipping[g])==null?void 0:$e.step:void 0}),fn=L(z=>Pi(z,y)),ae=L(z=>{var $e;return fn?($e=z.shipping[fn.id])==null?void 0:$e.op:void 0}),_e=fn&&Ee&&Je?__(Ee.defaultBranch,fn):null,ht=L(z=>m?H4(z.rows,y,xt,Le):g),ct=It(ht,"commands"),zt=ct.some(z=>z.name==="compact"),kn=ss(e==null?void 0:e.agent),Pr=L(z=>B_(z,g)),cr=kn&&!!g&&!m,ln=e==null?void 0:e.worktree.lastTurn,ur=!x.trim()&&N.length===0,nn=!m&&!s&&ur&&!kn?ln:void 0,Bt=!m&&!s&&e&&ya(e.worktree)?e.worktree.landing:void 0,Ft=!!(Bt!=null&&Bt.ready)&&!Bt.stale&&!Sf(Bt,Jt,_t,Ze==null?void 0:Ze.name),be=ur&&(!kn||Ft)?Bt:void 0,Ye=Jt>0&&!!(be!=null&&be.subject),wt=Jt||(((sl=Ct==null?void 0:Ct.extras)==null?void 0:sl.committed.length)??0),yt=!m&&!s&&ur&&!kn&&!!e,cn=!!(e!=null&&e.worktree.landed)&&Jt===0,hn=yt&&cn,wr=e?gw(e.worktree,Jt):void 0,Zn=wr?zh(wr):void 0,Ut=yt&&!hn?Zn:void 0,pn=!cn&&(Zn==null?void 0:Zn.state)==="open"?Zn:void 0,yr=!!pn&&(Jt>0||sr>0),X=(Zn==null?void 0:Zn.state)==="closed",ge=Ti((Ee==null?void 0:Ee.config)??{}),Ge=E.useMemo(()=>OK(Xf(Ti((Ee==null?void 0:Ee.config)??{}),Ee==null?void 0:Ee.defaultBranch)),[Ee]),Vt=()=>g&&(f==null?void 0:f.send({t:"chat",worktreeId:g,text:"/compact"})),Mt=Je?"nothing to compact until the first reply":zt?kn?"wait for the turn to end":void 0:"this agent offers no compact command",On=zt&&qe?HF(qe.used/qe.size):void 0,Sn=Ze==null?void 0:Ze.limits,zn=Je?void 0:qe,ir=(!!g||Je)&&!!(zn||Sn),go=Date.now(),[rn,vt]=E.useState(!1),ko=E.useRef(0),Fn=W?()=>d.jsx(wC,{usage:zn,limits:Sn,auth:Ze==null?void 0:Ze.auth,now:Date.now()}):void 0,on=()=>{window.clearTimeout(ko.current),vt(!1)};at([g],on);const Ar=iy(),dr=(Ar==null?void 0:Ar.owner)==="composer"&&Ar.key==="usage";at([dr],()=>{dr&&on()});const Ie=()=>[{id:"compact",label:"compact the context",detail:Mt||!qe?void 0:UF(qe.used/qe.size),disabled:Mt,onClick:Vt}],[U,G]=E.useState(0),[ce,ve]=E.useState(null),Pe=E.useRef(null),Te=w&&!v&&!o?Cg(x,U,z=>Ve.some($e=>rE(z,$e))):null,$t=Te==null?void 0:Te.kind,sn=Te==null?void 0:Te.query,nr=E.useMemo(()=>{if(sn===void 0)return[];if($t==="command")return sn.trim()?t7(yE(Ge,ct),sn).slice(0,8).map(_E):vE(Ge,ct).rows.map(_E);const z=[],$e=(Ct==null?void 0:Ct.files.length)??0;$e>0&&"changes".startsWith(sn.toLowerCase())&&z.push({kind:"changes",n:$e});const ft=sn.trim(),Nt=ft?Ve.filter(Gn=>rE(ft,Gn)):Ve.slice(0,VK);return z.push(...Nt.map(Gn=>({kind:"worktree",...Gn}))),z.push(...mK(Rt??[],Zt,(Ct==null?void 0:Ct.files)??[],sn,8)),z},[$t,sn,Rt,Zt,Ct,ct,Ge,Ve]),Mn=Te!==null&&Te.from!==ce&&!C&&!(Te.kind==="file"&&QU(x,Te.from,bn)),qs=$t==="command"&&sn!==void 0&&!sn.trim()?vE(Ge,ct).more:0,En=E.useRef(null),Ui=E.useRef(null),Ua=E.useRef(null),rd=(z,$e,ft,Nt)=>{var si;const{text:Gn,caret:rr}=BN(x.slice(0,$e)+x.slice(ft),$e,Nt);ie(Gn),ve(((si=Cg(Gn,rr))==null?void 0:si.from)??null),requestAnimationFrame(()=>{z.focus(),z.setSelectionRange(rr,rr),G(rr)})},Zs=z=>{const $e=En.current;return!z||!$e?!1:(rd($e,$e.selectionStart,$e.selectionEnd,z),!0)},{onPaste:Hi,onPasteKey:Gs,onPasteKeyUp:Ha}=nj(w,g,z=>Zs(C$(z,xn)));J6(Ui,En,z=>Zs(SH(z,xn)));const Wa=()=>{var z;return(z=q.current??En.current)==null?void 0:z.focus()},as=Wa;at([s?e==null?void 0:e.worktree.id:null],()=>{if(!s)return;const z=requestAnimationFrame(()=>{var ft;const $e=document.activeElement;(!$e||$e===document.body)&&((ft=En.current)==null||ft.focus())});return()=>cancelAnimationFrame(z)});const Vs=L(z=>z.focusChat),Wi=E.useRef(Vs),Ys=!!_N();at([Vs],()=>{if(Vs===Wi.current||(Wi.current=Vs,Ys!==!!s))return;const z=requestAnimationFrame(Wa);return()=>cancelAnimationFrame(z)});const Ki=ee==null?void 0:ee.id,Ko=E.useRef({id:g,cardUpId:Ki});at([g,Ki],()=>{const z=Ko.current;if(Ko.current={id:g,cardUpId:Ki},Ki||!z.cardUpId||z.id!==g||Ys!==!!s||W&&!Q)return;const $e=requestAnimationFrame(()=>{var Nt;const ft=document.activeElement;(!ft||ft===document.body)&&((Nt=En.current)==null||Nt.focus())});return()=>cancelAnimationFrame($e)});const Xs=L(z=>z.walked),qi=E.useRef(Xs);at([Xs],()=>{if(Xs===qi.current||(qi.current=Xs,Ys!==!!s))return;const z=requestAnimationFrame(()=>{const $e=document.activeElement;(!$e||$e===document.body||$e.closest(".rail"))&&Wa()});return()=>cancelAnimationFrame(z)});const Ka=fj({results:nr,keyOf:z=>z.kind==="cmd"?`c:${z.c.name}`:z.kind==="changes"?"changes":z.kind==="worktree"?`w:${z.id}`:`f:${z.path}`,q:(Te==null?void 0:Te.query)??"",listRef:Pe,tabPicks:!0,onPick:z=>{if(!Te)return;const{text:$e,caret:ft}=e7(x,Te,QK(z));ie($e),ve(Te.from),requestAnimationFrame(()=>{const Nt=En.current;Nt&&(Nt.focus(),Nt.setSelectionRange(ft,ft),G(ft))})}}),vr=g||v?WH(x):null,qa=E.useMemo(()=>yE(Ge,ct),[Ge,ct]),od=LK(x,qa),Zr=vr===""&&e?m?" a command to run in the new worktree's terminal":` a command to run in ${e.worktree.title}; the agent sees its output with your next message`:null,ls=od??Zr,Zi=(e==null?void 0:e.worktree.title)??"untitled",$o=(bd=ln==null?void 0:ln.recap)==null?void 0:bd.text,dc=()=>{g&&Ii(f,u,{t:"land",worktreeId:g})},Za=z=>{g&&(f==null||f.send({t:"judge",worktreeId:g,...z?{note:z}:{}}))},fc=!!((xd=Ee==null?void 0:Ee.config.check)!=null&&xd.trim()),bs=vy(Bt,Jt,_t),Ga=yt&&!Gt&&!Je&&ya(e.worktree)&&!cn&&!X&&wt>0&&(!Bt||!!Bt.stale||bs==="unanswered"),hc="Archive this worktree when you are done here; the rail's archived section brings it back with its chat.",Rp=yr?"update":kw(ge,wr??{}),sd=Ee?Dh(Ee):"main",Op=yr&&pn?`Commit, take ${sd} in and push the branch; PR #${pn.number} takes the new commits.`:`${Xf(ge,Ee==null?void 0:Ee.defaultBranch)}.`,Va=Ut&&!$o?{links:uF(Ut)}:{},Dr=g?hn?{word:"archive",kind:"archive",line:(Zn==null?void 0:Zn.state)==="merged"?As(Zn):`landed on ${(Ee==null?void 0:Ee.defaultBranch)??"main"}.`,tip:hc,run:()=>Kl(f,u,[g])}:(Ut==null?void 0:Ut.state)==="open"&&!yr?Lj(Ut)?{word:"land",kind:"merge",line:_f($o??As(Ut)),tip:`${As(Ut)} ${Mj(Ut)}.`,...Va,run:dc,ships:!0}:{word:"view",kind:"view",line:_f($o??As(Ut)),tip:`${As(Ut)} Open the PR on GitHub.`,...Va,run:()=>window.open(Ut.url,"_blank")}:(Ut==null?void 0:Ut.state)==="closed"?{word:"archive",kind:"archive",line:As(Ut),tip:`${As(Ut)} ${hc}`,run:()=>Kl(f,u,[g])}:Ga?{word:"check",kind:"check",line:(Bt==null?void 0:Bt.subject)??_f($o??mF(wt)),tip:Pj(Bt,fc,bs),run:Za}:be!=null&&be.ready&&!Sf(be,Jt,_t,Ze==null?void 0:Ze.name)?{word:Rp,kind:"ship",line:be.subject??_f($o??(Ux(be,wt)||"ready")),tip:[Ux(be,wt),pF(sd,e==null?void 0:e.behind),Op,be.subject&&Jt>0?"Tab from the word edits the message first.":""].filter(Boolean).join(" "),run:dc,ships:!0}:null:null,id=(Es=e==null?void 0:e.worktree.lands)==null?void 0:Es.at(-1),ad=id&&ky(id),Ya=E.useMemo(()=>{const z=M?p6(M):null;return(z?T6(z):[]).filter($e=>{const ft=Ae.find(Nt=>Nt.worktree.id===$e.id);return!!ft&&!ft.worktree.landed})},[M,Ae]),Mp=Ya.length>0?d.jsxs(d.Fragment,{children:["After"," ",Ya.map((z,$e)=>d.jsxs(E.Fragment,{children:[$e>0&&($e===Ya.length-1?" and ":", "),d.jsx(Qr,{id:z.id,title:z.title})]},z.id))," ",Ya.length===1?"lands":"land","."]}):null,Xa=((Dr==null?void 0:Dr.kind)==="ship"||(Dr==null?void 0:Dr.kind)==="check")&&be?Mp??gF(be,bs):(Dr==null?void 0:Dr.word)==="archive"&&ad?Jr(ad):null,pc=E.useRef(null);Gt!=="land"&&(pc.current=g&&(Dr!=null&&Dr.ships)?{id:g,verb:Dr,under:Xa}:null);const Qa=Gt==="land"&&ur&&((il=pc.current)==null?void 0:il.id)===g?pc.current:null,Bn=Qa?Qa.verb:Dr,ld=(oi=Bn==null?void 0:Bn.links)!=null&&oi.length?dF(Bn.line,Bn.links):null,Qs=!!(Bn!=null&&Bn.ships)&&Gt==="land",mc=ey(Rn,ty),Ja=Iu(e,"commit"),el=Iu(e,"check"),xs=zj(Qs?Ja:el),cd=Ci(xy(xs)?xs==null?void 0:xs.since:void 0),gc=be?be.check==="pending"&&el&&xs===el?fh("Checking the work",el,cd):Sf(be,Jt,_t,Ze==null?void 0:Ze.name):null,kc=Bn&&Qs?mc?`${Bn.word}: ${mc}`:`${Bn.word} ${Bn.line}`:null,ud=kc&&Ja&&xs===Ja?fh(kc,Ja,cd):kc,dd=n?n.restorable?`message agent on ${n.title}; sending restores it first`:"its commits were not kept, so it cannot come back":r?r.locked?`held by ${r.lockReason??"another tool"}; Toyon takes it over once the lock goes`:`message agent on ${r.name}; sending takes it over first`:o?`describe ${o.name||"the app"}; return makes it`:e?Bn?"":gc||(Ut?As(Ut):nn?by(nn):s?`describe ${Zi}…`:Je?"describe a change":c?`message agent on ${Zi}`:`message agent on ${Zi}; / for a command, ! for a shell command`):"no worktree selected",tl=x!==""||ls||!e?null:Qs?mc?null:Qa?Qa.under:Xa:Bn?Xa:Ut||gc?$o??(be==null?void 0:be.subject)??null:null,nl=E.useRef(!1);E.useEffect(()=>{const z=Mn&&!nl.current;nl.current=Mn,z&&((Te==null?void 0:Te.kind)==="file"&&g?cp(g,h.getState(),{sock:f,dispatch:u}):(Te==null?void 0:Te.kind)==="command"&&ht&&ct.length===0&&(f==null||f.send({t:"list-commands",worktreeId:ht})))},[Mn,Te==null?void 0:Te.kind,ct.length,g,ht,f,h,u]);const Js=()=>{if(!e)return;const z=[],$e=de;if($e.url)try{const Gn=new URL($e.url);z.push(`current route: ${Gn.pathname}${Gn.search}`)}catch{}$e.title&&z.push(`page title: ${$e.title}`);const ft=[];s&&ft.push(AW(e.worktree.title,Ee==null?void 0:Ee.configFile)),z.length>0&&ft.push(`What the user is looking at right now:
263
- ${z.join(`
264
- `)}`);const Nt=qH(M);return Nt&&ft.push(Nt),ft.length>0?ft:void 0},fd=z=>{Je?Tt(z):g&&z!==Dt&&(f==null||f.send({t:"set-worktree-mode",worktreeId:g,mode:z}))},fr=z=>w&&u({a:"notice",id:w,text:z}),Gi=xN(),hd=(z,$e="")=>{if(!e||!g)return;if(z==="handoff"){if(Je)return fr("a new worktree has nothing to continue yet");const Nt=MK($e,Se,e.worktree.repoId);"pick"in Nt?u({a:"open",overlay:{kind:"handoff",worktreeId:g}}):f==null||f.send({t:"handoff-ask",worktreeId:g,repoId:Nt.repo.id,...Nt.text?{text:Nt.text}:{}});return}if(z==="archive"){cn||X?Kl(f,u,[g]):fr("archive is for a landed worktree; this one has not landed");return}if(z==="check"){Je||!ya(e.worktree)?fr("nothing to check from here"):kn?fr("wait for the turn to end"):wt===0?fr("nothing to check: no changes here"):Za($e||void 0);return}const ft=Bt?Sf(Bt,Jt,_t,Ze==null?void 0:Ze.name):null;Je||!ya(e.worktree)?fr("nothing to land from here"):cn?fr(`already landed on ${(Ee==null?void 0:Ee.defaultBranch)??"main"}`):ft?fr(ft):kn&&(!Bt||Bt.stale)?fr("wait for the turn to end"):Bt!=null&&Bt.stale?fr("the work changed since this was checked; check again first"):dc()},Vi=N.some(Mi),wc=()=>{var z;W&&((z=En.current)==null||z.blur())},Co=()=>{w&&(f==null||f.send({t:"set-draft",boxId:w,text:x,clientId:ye})),wc()},Yi=(z,$e,ft,Nt)=>{u({a:"hold-send",id:z,log:$e,text:ft,frame:Nt}),wc()},yc=()=>{if(!w)return;const z=PK(x,Ge),$e=z&&RK(z.name)?z.name:void 0;if(o){if(o.busy)return;if(Gi)return fr(EE);if(o.why)return fr(o.why);(xt!==Le||!Ue)&&(f==null||f.send({t:"set-default-agent",agent:xt})),Co(),o.create();return}if(ur)return;if(Gi&&!($e&&!(z!=null&&z.args)))return fr(EE);const ft=vr===null&&(!z||!!$e&&!!z.args);if(dn&&dn.kind!=="unready"&&Ze&&ft){fr(dn.kind==="installing"?`${Ze.name} is still installing`:dn.retry?`nothing runs here until ${Ze.name} is installed`:dn.text);return}const Nt=Z1(x.trim(),bn),Gn=()=>({text:Nt,attachments:N.length?N.map(Ul):void 0});if(n){if(!n.restorable)return;if(vr!==null){fr("nothing runs here until it is restored");return}const wo={t:"restore-worktree",archiveId:n.id,clientId:ye};if(Vi)return Yi(w,w,Nt,wo);Co(),f==null||f.send(su(wo,w,Nt,N)),u({a:"sending",id:w,message:Gn()}),u({a:"sent-box",id:w});return}if(r){if(r.locked)return;if(vr!==null){fr("nothing runs here until Toyon takes it over; its menu on the rail opens a shell");return}const wo={t:"adopt-worktree",worktreeId:r.id,clientId:ye};if(Vi)return Yi(w,w,Nt,wo);Co(),f==null||f.send(su(wo,w,Nt,N)),u({a:"sending",id:w,message:Gn()}),u({a:"sent-box",id:w});return}if(!e||!g)return;if(vr!==null){if(vr&&Gt&&!m){fr(`${oR(Gt)} is running here; run the command once it is done`);return}vr&&m?u({a:"term-run",id:g,command:vr}):vr&&(f==null||f.send({t:"exec",worktreeId:g,command:vr})),ie("");return}if(z&&!$e){hd(z.name,z.args),ie("");return}if($e&&!(z!=null&&z.args)){fd($e),ie("");return}const rr=z?Z1(z.args,bn):Nt,si=Js(),Nc=N.length?N.map(Ul):void 0;if($e&&fd($e),Je){const wo=Rh(e.worktree)?{worktreeId:g}:{},Ed={clientId:ye,repoId:e.worktree.repoId,context:si,agent:xt,...$e?{mode:$e}:{},...t!=null&&t.carry?{carry:!0}:{}};(xt!==Le||!Ue)&&(f==null||f.send({t:"set-default-agent",agent:xt}));const jc={t:"create-worktree",...Ed,...wo};Vi?Yi(w,w,rr,jc):(Co(),f==null||f.send(su(jc,w,rr,N)),u({a:"sending",id:w,message:{text:rr,attachments:Nc}}),u({a:"sent-box",id:w}))}else{const wo={t:"chat",worktreeId:g,clientId:ye,context:si};Vi?Yi(w,g,rr,wo):(Co(),f==null||f.send(su(wo,w,rr,N)),Pr||u({a:"sending",id:g,message:{text:rr,attachments:Nc}}),u({a:"sent-box",id:w}))}s&&u({a:"show-chat"})},Lp=z=>{if(!g||(V==null?void 0:V.ask.kind)!=="question")return;if(!z.some(Na))return u({a:"ask-revive",id:g});const $e=Ow(V.ask.questions,z).join(`
265
- `),ft={t:"chat",worktreeId:g,clientId:ye,context:Js()};if(F&&$.some(Mi))Yi(F,g,$e,ft);else{const Nt=$.length?$.map(Ul):void 0,Gn=Nt&&F?{attachments:Nt,boxId:F}:{};f==null||f.send({...ft,text:$e,...Gn}),Nt&&F&&u({a:"clear-attachments",id:F}),u({a:"sending",id:g,message:{text:$e,attachments:Nt}})}u({a:"answered",id:g}),u({a:"ask-revive",id:g})},rl=L(z=>z.autoSend);at([rl,g],()=>{!rl||rl!==g||ur||Ys!==!!s||(u({a:"auto-sent"}),yc())});const pd=()=>{const z=N[N.length-1];return!w||!z?!1:(u({a:"detach",id:w,key:z.key}),!0)},ei=z=>{w&&(u({a:"walk",id:w,walk:z.walk,text:z.text}),requestAnimationFrame(()=>{var $e;($e=En.current)==null||$e.setSelectionRange(z.text.length,z.text.length),G(z.text.length)}))},ti=()=>{w&&C&&u({a:"walk",id:w,walk:null,text:x})},md=Je?[]:P_(M),Xi=Je?[]:I.flatMap(z=>z.attachments??[]),Io=e==null?void 0:e.worktree.plan,gd=Xy(e==null?void 0:e.worktree.id,Io),qo=((al=e==null?void 0:e.worktree.from)==null?void 0:al.kind)==="worktree"?e.worktree.from:null,ni=qo?M.find(z=>z.kind==="handed"&&z.via==="plan"):void 0,kd=(ni==null?void 0:ni.kind)==="handed"?ni.origin.title:qo==null?void 0:qo.ref,Qi=pn&&((_c=e==null?void 0:e.worktree.prComments)==null?void 0:_c.pr)===pn.number?e.worktree.prComments:void 0,ol=Qi&&Qi.count>0?G$(Qi.count,Qi.authors):null,vc=(e==null?void 0:e.worktree.queued)??[],wd=cr&&!ee,Pp=L(z=>z.reading),[bc,yd]=E.useState(!1),eo=c&&!Q&&(ee?!bc:ur&&!Ne),ri=eo&&Pp;E.useEffect(()=>{if(c)return u({a:"typing",on:bc}),()=>u({a:"typing",on:!1})},[c,bc,u]);const vd=z=>{if(!ri||z.target instanceof Element&&z.target.closest("button, a, [role=button]"))return;const $e=z.currentTarget.closest(".chat-log");$e&&($e.scrollTop=$e.scrollHeight)};return d.jsxs("div",{ref:Ui,className:Ke("composer chat-input",wd&&"stopping",eo&&"foldable",ri&&"lean"),onClick:vd,onFocus:z=>yd(z.target instanceof HTMLTextAreaElement),onBlur:()=>yd(!1),children:[(Io||qo)&&e&&d.jsxs("div",{className:"composer-plan",...Io?Fe.contextMenu(()=>Cy(Io,()=>f==null?void 0:f.send({t:"reveal",worktreeId:e.worktree.id,path:Io}),po(f))):{},children:[d.jsx(kt,{name:Io?"text":"handoff",className:"icon-inline"}),Io&&d.jsx(Oe,{variant:"inline",className:"composer-plan-path","data-tip":Io,onClick:()=>Pn({dispatch:u},{worktreeId:e.worktree.id,path:Io,view:"preview"}),children:gd}),qo&&d.jsxs("span",{className:"composer-plan-from",children:[Io?" from ":"from ",d.jsx(Qr,{id:qo.origin.id,title:kd})]})]}),pn&&ol&&e&&d.jsxs("div",{className:"composer-plan",children:[d.jsx(kt,{name:"pr",className:"icon-inline"}),d.jsx(Oe,{variant:"inline",tone:"strong","data-tip":"Read them beside the chat",onClick:()=>J3({dispatch:u},e.worktree.id,pn.number),children:ol.count}),d.jsxs("span",{className:"row-dim",children:["on PR #",pn.number,ol.rest,pn.review==="changes_requested"?", changes requested":pn.review==="approved"?", approved":""]})]}),Q&&g&&d.jsx(Ms,{icon:"chat",verb:"answer",tip:"Bring the question back into the box",onPress:()=>{u(Q.kind==="ask"&&Q.outcome?{a:"ask-revive",id:g,askId:Q.id}:{a:"card-unpark",id:g}),u({a:"focus-chat"})},children:C6(Q)}),(ue==null?void 0:ue.verb)==="fix"&&"toolId"in ue&&g&&d.jsxs(Ms,{icon:"run",verb:ue.verb,tip:"Send the agent what it printed and ask for a fix",onPress:()=>f==null?void 0:f.send({t:"fix",worktreeId:g,toolId:ue.toolId}),onDismiss:()=>wE(ue.key),children:["what failed in ",d.jsx("code",{children:ue.command})]}),(ue==null?void 0:ue.verb)==="continue"&&g&&d.jsx(Ms,{icon:"send",verb:ue.verb,tip:ue.after==="stop"?"Send the agent on from where its turn stopped":ue.again?"The last press ended in this same error. Send the agent on once more, or wait it out.":"Send the agent on from where its turn failed",onPress:()=>f==null?void 0:f.send({t:"continue",worktreeId:g}),onDismiss:()=>wE(ue.key),children:ue.after==="stop"?"where it stopped":ue.again?"after the same error again":"after the error"}),Ne&&w&&!ee&&(e||_||o)&&d.jsx(Ms,{icon:"copy",verb:"attach",tip:"Attach it, as a paste would",onPress:()=>{K6(h,w,Ne),Wa()},onDismiss:NN,children:Ne.kind==="image"?"the image you copied":`the text you copied, ${Ne.text.split(`
266
- `).length} lines`}),te&&d.jsx(Ms,{icon:"download",verb:"install",tip:"Install Toyon as an app: a window of its own, with a Dock icon and no browser bar",onPress:()=>{cE(),Me==null||Me.prompt()},onDismiss:cE,children:"Toyon as a window of its own, with a Dock icon and no browser bar"}),K&&g&&!m&&!ee&&!te&&lp(po(f))&&xW({offer:K,agent:e==null?void 0:e.agent,chat:M})&&d.jsx(EK,{offer:K,onInstall:()=>f==null?void 0:f.send({t:"install-global"}),onDismiss:()=>f==null?void 0:f.send({t:"dismiss-global-install"})}),w&&!ee&&vr===null&&d.jsx(mp,{children:pw(N,du(Kg(md),Xi)).map(([z,$e])=>{const ft=()=>u({a:"detach",id:w,key:z.key});return z.kind!=="pick"?d.jsx(fC,{item:z,n:$e,onRemove:ft},z.key):d.jsx($p,{pick:z,tipText:z.html,onHover:Nt=>oe&&un.post(oe,Nt?{type:"highlight-selector",selector:z.selector,label:Uw(z)}:{type:"highlight-clear"}),worktreeId:g,onOpen:(Nt,Gn)=>g&&ja(h,f,g,Nt,Gn),onRemove:ft},z.key)})}),Mn&&Te&&d.jsx(CW,{results:nr,keyOf:z=>z.kind==="cmd"?`c:${z.c.name}`:z.kind==="changes"?"changes":z.kind==="worktree"?`w:${z.id}`:z.kind==="folder"?`d:${z.path}`:`f:${z.path}`,rowClass:z=>z.kind==="file"||z.kind==="folder"?"qo-file":z.kind==="changes"||z.kind==="worktree"?"picker-row":"picker-row picker-cmd",nav:Ka,listRef:Pe,empty:XK(Te.kind,Rt,ct.length,ht!==null),note:qs>0?`type to find ${qs} more`:void 0,groupOf:z=>z.kind==="worktree"?"worktrees":z.kind==="cmd"?"commands":"files",row:z=>{const $e=((Ct==null?void 0:Ct.files.length)??0)>0;return z.kind==="file"?Vk(z.path,z.status,Te.query,{gutter:$e}):z.kind==="folder"?Vk(z.path,void 0,Te.query,{folder:!0,gutter:$e}):z.kind==="changes"?d.jsx(An,{label:"@changes",hint:`${z.n} uncommitted ${z.n===1?"file":"files"}`}):z.kind==="worktree"?d.jsxs(d.Fragment,{children:[d.jsx("span",{className:`dot ${z.dot}`}),d.jsx(An,{label:z.title,hint:mr(z.at)})]}):d.jsx(HW,{c:z.c,query:Te.query})}}),ee&&g?ee.kind==="handoff"?d.jsx(TK,{item:ee,worktreeId:g,rootRef:q},ee.id):ee.ask.kind==="question"?d.jsx(UK,{item:ee,ask:ee.ask,worktreeId:g,rootRef:q,numbers:du(Kg(md),Xi),onAnswer:V?Lp:void 0},ee.id):d.jsx(BK,{item:ee,ask:ee.ask,worktreeId:g,rootRef:q},ee.id):d.jsxs("div",{className:Ke("composer-field",vr!==null&&"shell",C&&"recalled"),children:[d.jsx(Cu,{size:"lg",bare:!0,font:vr!==null?"mono":"ui",ref:En,value:x,onChange:z=>{var rr;const $e=z.target.value,ft=z.target.selectionStart??$e.length;ie($e),G(ft),Ka.setIndex(0);const{inputType:Nt}=z.nativeEvent;ve(Nt==="insertFromPaste"||Nt==="insertFromDrop"?((rr=Cg($e,ft))==null?void 0:rr.from)??null:null)},onKeyUp:z=>{Ha(),G(z.currentTarget.selectionStart??0)},onClick:z=>{G(z.currentTarget.selectionStart??0),ti()},onPaste:Hi,onDrop:z=>{const $e=_j(h,z);if(!$e)return;z.stopPropagation();const ft=z.currentTarget,Nt=oF(ft,z.clientX,z.clientY)??x.length;rd(ft,Nt,Nt,$e.words)},onScroll:z=>{Ua.current&&(Ua.current.scrollTop=z.currentTarget.scrollTop)},onKeyDown:z=>{var $e;if(Gs(z),!z.nativeEvent.isComposing){if(Mn){if(z.key==="Escape"){z.preventDefault(),z.stopPropagation(),ve((Te==null?void 0:Te.from)??null);return}if(Ka.onKeyDown(z))return}if((z.key==="ArrowUp"||z.key==="ArrowDown")&&!z.altKey&&!z.ctrlKey){const ft=z.key==="ArrowUp",Nt=I.at(-1);if(ft&&!z.metaKey&&!C&&x===""&&g&&!m&&Nt!==void 0){z.preventDefault(),zN(h,f,g,I.length-1);return}const Gn=z.metaKey?ft?"first":"box":ft?"up":"down",rr=g?fW(M,C??null,x,Gn):null;if(rr){z.preventDefault(),(rr.walk!==C||rr.text!==x)&&ei(rr);return}}if(C&&z.key==="Escape"){z.preventDefault(),z.stopPropagation(),ei({walk:null,text:C.from});return}if(z.key==="Escape"&&kn&&g&&!m){z.preventDefault(),z.stopPropagation(),f==null||f.send({t:"stop-agent",worktreeId:g});return}if(C&&ZK.has(z.key)&&ti(),z.key==="Tab"&&!z.shiftKey&&x===""){const ft=($e=z.currentTarget.closest(".composer"))==null?void 0:$e.querySelector(".composer-verb");if(ft&&!ft.disabled){z.preventDefault(),ft.focus();return}if(Ye){z.preventDefault(),u({a:"edit-commit"});return}}z.key==="Enter"&&(W?z.metaKey||z.ctrlKey:!z.shiftKey)?(z.preventDefault(),yc()):z.key==="Backspace"&&x===""&&pd()&&z.preventDefault()}},placeholder:tl||Bn?"":dd,disabled:o?o.busy:!e&&!_}),ls&&d.jsxs("div",{className:"composer-ghost","aria-hidden":"true",children:[d.jsx("span",{className:"picker-typed",children:x}),ls]}),g&&vr===null&&x.includes("@")&&d.jsx("div",{ref:Ua,className:"composer-ghost composer-marks","aria-hidden":"true",onClick:z=>Du(z,e==null?void 0:e.worktree.path,g,{sock:f,dispatch:u}),children:d.jsx(Pu,{text:x,worktreeId:g,root:e==null?void 0:e.worktree.path,inField:!0})}),(tl||Bn)&&d.jsxs("div",{className:"composer-ghost composer-standing","aria-hidden":Bn?void 0:"true",children:[d.jsx("span",{className:Ke("composer-placeholder",Qs&&"live-text"),children:ud||(Bn?d.jsxs(d.Fragment,{children:[d.jsx(Oe,{variant:"inline",tone:"strong",className:"composer-verb",disabled:!!Bn.ships&&!!Gt||Gi,...Lt(Bn.tip,void 0,{placement:"top"}),onClick:()=>{var z;Bn.run(),W||(z=En.current)==null||z.focus()},onKeyDown:z=>{z.key==="Tab"&&!z.shiftKey&&Ye&&(z.preventDefault(),u({a:"edit-commit"}))},children:Bn.word})," ",d.jsx("span",{className:"composer-verb-line",children:ld?ld.map(z=>typeof z=="string"?z:d.jsxs(Oe,{variant:"inline",className:"composer-verb-tail",...Lt(z.tip,void 0,{placement:"top"}),onClick:()=>{var $e;window.open(z.url,"_blank"),W||($e=En.current)==null||$e.focus()},...Fe.contextMenu(()=>[{id:"open-link",label:z.open,onClick:()=>window.open(z.url,"_blank")},{id:"copy-link",label:"copy link",onClick:()=>tn(z.url)}]),children:[z.text," ",d.jsx(kt,{name:"external",className:"icon-inline"})]},z.text)):Bn.line})]}):dd)}),tl&&d.jsxs(d.Fragment,{children:[`
267
- `,d.jsx("span",{className:"composer-subline",children:tl})]})]}),wd&&d.jsx(At,{icon:"stop",tone:"danger",className:Ke("composer-stop",(e==null?void 0:e.stopping)&&"pending"),label:e!=null&&e.stopping?"Stopping: the agent is winding down; press again to send the stop once more":`Stop the agent (context up to here is kept${I.length?"; queued messages go next":""})`,hint:"esc",onClick:()=>g&&(f==null?void 0:f.send({t:"stop-agent",worktreeId:g}))})]}),T&&d.jsx("div",{className:"hint composer-notice",role:"status",children:T}),!ee&&d.jsxs("div",{className:"hint composer-knobs",children:[d.jsxs("span",{className:"spawn-left",children:[qt?Qt.length>1?d.jsx(zW,{agents:Qt,agent:xt,model:Yt,onChange:Cn,onClose:as}):d.jsx(hE,{models:mt,value:Yt,runs:nt,onChange:rt,onClose:as}):e&&d.jsx(hE,{models:mt,value:e.worktree.model??"",current:ne,runs:nt,onChange:z=>f==null?void 0:f.send({t:"set-worktree-model",worktreeId:e.worktree.id,model:z}),onClose:as}),qt?d.jsx(dE,{efforts:De,value:$n,runs:lt,onChange:Kn,onClose:as}):e&&d.jsx(dE,{efforts:De,value:e.worktree.effort??"",current:we,runs:lt,onChange:z=>f==null?void 0:f.send({t:"set-worktree-effort",worktreeId:e.worktree.id,effort:z}),onClose:as}),Je?!o&&d.jsx(fE,{value:ot,onChange:Tt,onClose:as}):e&&d.jsx(fE,{value:Dt,onChange:z=>f==null?void 0:f.send({t:"set-worktree-mode",worktreeId:e.worktree.id,mode:z}),onClose:as}),e&&!Je&&!v&&Ee&&!Ri(e.worktree)&&Object.keys(Ee.tier??{}).map(z=>d.jsx($7,{name:z,wt:e,repo:Ee,trunk:fn,onClose:as},z)),ir&&d.jsxs("span",{className:"usage-knob",onMouseEnter:()=>{dr||(window.clearTimeout(ko.current),ko.current=window.setTimeout(()=>vt(!0),GK))},onMouseLeave:()=>{window.clearTimeout(ko.current),vt(!1)},onFocus:z=>{dr||!z.target.matches(":focus-visible")||(window.clearTimeout(ko.current),vt(!0))},onBlur:on,children:[d.jsx(At,{icon:d.jsx(IW,{fraction:zn?zn.used/zn.size:0,level:Sn?qF(Sn,go):void 0}),tone:"chrome",on:dr,silent:!0,label:zn?`${Math.round(100*zn.used/zn.size)}% of context`:Sn?Jx(Sn,go):"",detail:[...zn&&Sn?[Jx(Sn,go)]:[],...On?[On]:[]],...Fe.dropdown(Ie,"left","usage",Fn),...Fe.contextMenu(Ie,"usage")}),rn&&d.jsx(KK,{usage:zn,limits:Sn,auth:Ze==null?void 0:Ze.auth,now:go,onClose:on})]})]}),d.jsxs("span",{className:"spawn-tools",children:[w&&(e||_||o)&&d.jsx(At,{icon:"attach",tone:"chrome",label:c?"Attach a picture or a file":"Attach a picture or a file, or drop one here",onClick:()=>QN(h,w)}),!s&&!v&&!c&&!o&&d.jsx(At,{icon:"terminal",tone:"chrome",on:se,className:"composer-term",disabled:!e,label:je?je.tip:"Terminal",hint:Pt("terminal"),badge:je&&d.jsx("span",{className:"composer-term-dot"}),onClick:()=>{u(je&&!se&&g?{a:"term-stream",id:g,stream:je.stream}:{a:"toggle-terminal"})},...Fe.contextMenu(()=>e&&g?y8(e.procs,g,se,{sock:f,dispatch:h.dispatch}):[])}),!s&&!he&&!v&&!c&&!o&&d.jsx(At,{icon:"pick",label:"Pick an element on the page to attach",hint:Pt("pick"),on:P==="chat",disabled:!oe,onClick:()=>oe&&Tu(oe,P,u,"chat")}),W&&w&&(e||_||o)&&d.jsx(At,{icon:"send",tone:"primary",label:o?"Create the project":"Send",disabled:Gi||(o?o.busy:ur),onMouseDown:z=>z.preventDefault(),onClick:yc})]})]}),(dn||_e&&fn||vc.length>0)&&d.jsxs("div",{className:"composer-notes",children:[vc.map(z=>d.jsx("div",{className:"hint composer-note",children:d.jsxs("span",{children:[z.title," starts when"," ","id"in z.after?z.after.id===(e==null?void 0:e.worktree.id)?"this branch":d.jsx(Qr,{id:z.after.id}):YK(z,z.after.piece,vc)," ","lands"]})},`${z.proposalId}/${z.pieceId}`)),dn&&Ze&&d.jsxs("div",{className:"hint composer-note",role:"status",children:[d.jsx("span",{children:dn.text}),(dn.retry||yn)&&d.jsxs("span",{className:"composer-note-actions",children:[dn.retry&&d.jsx(Oe,{variant:"outline",onClick:()=>f==null?void 0:f.send(H$(Ze)),children:dn.retry}),yn&&d.jsxs(Oe,{variant:"outline","data-tip":`${yn.name} is installed and takes this message instead`,onClick:()=>qn(yn.id),children:["use ",yn.name]})]})]}),_e&&fn&&d.jsxs("div",{className:"hint composer-note",children:[d.jsx("span",{children:_e}),O4(fn)&&d.jsx(Oe,{variant:"outline",busy:ae==="pull-main",disabled:!!ae,"data-tip":"Fast-forward main to origin",onClick:()=>Ii(f,u,{t:"pull-main",worktreeId:fn.id}),children:"pull"})]})]})]})}function JK({children:e,className:t,tip:n,...r}){return d.jsxs("label",{className:Ke("check",t),"data-tip":n,children:[d.jsx("input",{type:"checkbox",className:"check-box",...r}),d.jsx("span",{children:e})]})}function eq({draft:e,lead:t}){const n=dt(),r=L(a=>ws(a,t==null?void 0:t.repoId)),o=L(a=>{var c;return((c=Pi(a,t==null?void 0:t.repoId))==null?void 0:c.dirty)??0});return!!t&&!!r&&o>0?d.jsx("div",{className:"draft-intro",children:d.jsx("div",{className:"draft-notes",children:d.jsxs(JK,{className:"hint draft-note",checked:!!e.carry,tip:`Move the ${o} uncommitted ${o===1?"file":"files"} into the new worktree, leaving ${r.defaultBranch} clean`,onChange:a=>n({a:"draft-carry",v:a.currentTarget.checked}),children:[d.jsxs("span",{className:"badge-dirty",children:["~",o]})," on ",r.defaultBranch," come along"]})})}):null}function tq({row:e}){const t=Qe(),n=L(a=>a.clientId),r=L(a=>a.home),o=r&&e.path.startsWith(`${r}/`)?`~${e.path.slice(r.length)}`:e.path,s=e.locked?"Toyon would be working in a directory something else is using, so taking it over waits for the lock to go.":"A message sent below takes over this branch.";return d.jsxs(lr,{icon:e.locked?"lock":"branch",word:e.locked?"held":"discovered",tone:"quiet",below:s,children:[d.jsxs("span",{className:"daemon-text",children:[e.locked&&`by ${e.lockReason??"another tool"}, at `,d.jsx("span",{className:"tool-hint",children:o})]}),!e.locked&&d.jsx(Oe,{variant:"inline",tone:"strong",onClick:()=>t==null?void 0:t.send({t:"adopt-worktree",worktreeId:e.id,clientId:n}),children:"take over"})]})}function wu({placement:e,className:t,width:n,archived:r,found:o}){const s=dt(),a=Us(),c=N3(),u=It(a==null?void 0:a.worktree.id,"sending"),f=lc(),h=e==="centre"&&!r&&(f!=null&&f.assumed)?f:null,m=L(v=>{var _;return((_=v.dragFiles)==null?void 0:_.at)==="chat"}),g=Dn(),y=E.useMemo(()=>({onDragOver:v=>rF(g,v),onDrop:v=>{const _=_j(g,v);_&&UN(g,_.boxId,_.words)}}),[g]),w=d.jsxs(d.Fragment,{children:[!r&&!o&&c&&!u&&d.jsx(eq,{draft:c,lead:a}),r?d.jsx(ku,{active:null,archived:r,placement:e}):o?d.jsx(ku,{active:null,found:o,placement:e}):d.jsx(ku,{active:a,draft:c,placement:e})]});return d.jsx("div",{className:Ke(e==="dock"?"chat-dock":e==="centre"?"chat-centre":"chat-screen",t,m&&"drop-over"),style:n===void 0?void 0:{width:n},...y,ref:v=>{var _;v?pu.el=v:(_=pu.el)!=null&&_.isConnected||(pu.el=null)},children:r?d.jsx(Og,{active:null,archived:r,tail:d.jsx(QF,{item:r}),foot:w}):o?d.jsx(Og,{active:null,found:o,tail:d.jsx(tq,{row:o}),foot:w}):d.jsx(Og,{active:a,lead:h&&d.jsxs("p",{className:"hint chat-centre-note",children:[h.name," has ",d.jsx("code",{children:h.assumed})," and no dev server, so it is chat only for now."," ",d.jsx(Oe,{variant:"inline",onClick:()=>s({a:"open",overlay:{kind:"setup",repoId:h.id}}),children:"add a dev server"})]}),foot:w})})}const nq="modulepreload",rq=function(e){return"/"+e},NE={},Jk=function(t,n,r){let o=Promise.resolve();if(n&&n.length>0){let a=function(f){return Promise.all(f.map(h=>Promise.resolve(h).then(m=>({status:"fulfilled",value:m}),m=>({status:"rejected",reason:m}))))};document.getElementsByTagName("link");const c=document.querySelector("meta[property=csp-nonce]"),u=(c==null?void 0:c.nonce)||(c==null?void 0:c.getAttribute("nonce"));o=a(n.map(f=>{if(f=rq(f),f in NE)return;NE[f]=!0;const h=f.endsWith(".css"),m=h?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${f}"]${m}`))return;const g=document.createElement("link");if(g.rel=h?"stylesheet":nq,h||(g.as="script"),g.crossOrigin="",g.href=f,u&&g.setAttribute("nonce",u),document.head.appendChild(g),h)return new Promise((y,w)=>{g.addEventListener("load",y),g.addEventListener("error",()=>w(Error(`Unable to preload CSS for ${f}`)))})}))}function s(a){const c=new Event("vite:preloadError",{cancelable:!0});if(c.payload=a,window.dispatchEvent(c),!c.defaultPrevented)throw a}return o.then(a=>{for(const c of a||[])c.status==="rejected"&&s(c.reason);return t().catch(s)})},sv=800;function oq(e,t,n,r){if(r.version===e.version)return"same";const o=t===e.text&&n===null;return r.version===null?o?"gone":"conflict":r.after===t||r.after===n?"adopt":o?"apply":"conflict"}const Qo=e=>`${e.worktreeId}
268
- ${e.ref??""}
269
- ${e.since??""}
270
- ${e.path}`;class sq{constructor(t){jt(this,"files",new Map);jt(this,"looks",new Map);this.d=t}start(){var s,a;let t=this.d.store.getState();const n=this.d.store.subscribe(()=>{const c=this.d.store.getState(),u=t;t=c,this.follow(u,c)}),r=()=>{const c=this.d.store.getState().editor;c&&!c.loose&&this.refresh(Qo(c))};(s=this.d.win)==null||s.addEventListener("focus",r);const o=()=>{for(const[c,u]of this.files)u.timer!==void 0&&this.saveNow(c)};return(a=this.d.win)==null||a.addEventListener("pagehide",o),()=>{var c,u;n(),(c=this.d.win)==null||c.removeEventListener("focus",r),(u=this.d.win)==null||u.removeEventListener("pagehide",o)}}receive(t){const n=t.t==="file-read"?this.looks.get(t.seq):void 0;if(n&&t.t==="file-read"){this.looks.delete(t.seq),n(t.error||t.binary||t.tooLarge||t.version===null?null:t.after);return}const r=this.files.get(Qo(t));if(!r)return;if(t.t==="file-blame"){this.blamed(r,t);return}const o=r.out;!o||o.seq!==t.seq||(r.out=null,t.t==="file-read"?this.read(r,t):o.write!==void 0&&this.written(r,o.write,t),this.next(r))}look(t,n){if(!this.d.store.getState().connected)return Promise.resolve(null);const r=_o();return new Promise(o=>{this.looks.set(r,o),this.d.send({t:"read-file",worktreeId:t,path:n,seq:r})})}bind(t){const n=Qo(t);return{attach:r=>this.attach(n,r),edited:()=>this.edited(n),saveNow:()=>this.saveNow(n)}}reload(t){var o;const n=this.files.get(Qo(t)),r=n==null?void 0:n.conflict;!n||!r||(this.cancelTimer(n),n.pending=null,n.base={text:r.after,version:r.version},this.setConflict(n,null),r.version===null?this.d.store.dispatch({a:"close-editor"}):(o=n.buffer)==null||o.replace(r.after),this.next(n))}keepMine(t){const n=this.files.get(Qo(t)),r=n==null?void 0:n.conflict;!(n!=null&&n.buffer)||!r||(n.base={text:r.after,version:r.version},this.setConflict(n,null),n.pending=n.buffer.text(),this.next(n))}follow(t,n){var s,a,c,u;t.connected&&!n.connected&&this.dropped();const r=(s=n.editor)!=null&&s.loose?null:n.editor,o=(a=t.editor)!=null&&a.loose?null:t.editor;if(o&&(!r||Qo(o)!==Qo(r))&&this.closed(Qo(o)),r&&(!o||o.seq!==r.seq)&&this.opened(r),!t.connected&&n.connected)for(const f of this.files.values())f.reread=!0,this.next(f);else r&&o&&o.seq===r.seq&&((c=Mr(t,r.worktreeId).git)==null?void 0:c.version)!==((u=Mr(n,r.worktreeId).git)==null?void 0:u.version)&&this.refresh(Qo(r))}opened(t){const n=Qo(t);let r=this.files.get(n);r||(r={file:{worktreeId:t.worktreeId,path:t.path,...t.ref?{ref:t.ref}:{},...t.since?{since:t.since}:{}},open:!0,base:null,out:null,pending:null,reread:!1,writable:!1,conflict:null,buffer:null,timer:void 0,blame:null},this.files.set(n,r)),r.open=!0,r.reread=!0,r.conflict&&this.d.store.dispatch({a:"editor-conflict",file:r.file,theirs:r.conflict}),this.next(r)}closed(t){const n=this.files.get(t);n&&(n.open=!1,this.next(n))}refresh(t){const n=this.files.get(t);!n||n.file.ref||(n.reread=!0,this.next(n))}dropped(){for(const t of this.looks.values())t(null);this.looks.clear();for(const t of this.files.values())t.out&&(t.out.write!==void 0&&(t.pending??(t.pending=t.out.write)),t.out=null,t.reread=!0)}next(t){var a;if(t.out||!this.d.store.getState().connected)return;const{worktreeId:n,path:r,ref:o,since:s}=t.file;if(t.reread){t.reread=!1;const c=_o();t.out={seq:c},this.d.send({t:"read-file",worktreeId:n,path:r,ref:o,since:s,seq:c});return}if(t.pending!==null&&t.base&&t.pending===t.base.text&&(t.pending=null),t.pending!==null&&t.writable&&!t.conflict&&!o){const c=t.pending,u=_o();t.pending=null,t.out={seq:u,write:c},this.d.send({t:"write-file",worktreeId:n,path:r,content:c,base:((a=t.base)==null?void 0:a.version)??null,seq:u});return}!t.open&&!t.buffer&&t.pending===null&&!t.conflict&&this.files.delete(Qo(t.file))}read(t,n){var g,y;const{file:r}=t;if(n.error){t.open&&this.d.store.dispatch({a:"editor-read",file:r,disk:null,error:n.error});return}const{before:o,after:s,version:a,writable:c,binary:u,tooLarge:f}=n;t.writable=c,t.open&&(this.d.store.dispatch({a:"editor-read",file:r,disk:{before:o,after:s,version:a,writable:c,binary:u,tooLarge:f}}),!u&&!f&&(a!==null||r.ref)&&this.askBlame(t,a));const h={after:t.buffer?t.buffer.normalize(s):s,version:a};if(!t.base){t.base={text:h.after,version:a};return}const m=((g=t.buffer)==null?void 0:g.text())??t.pending??t.base.text;switch(oq(t.base,m,t.pending,h)){case"same":break;case"adopt":t.base={text:h.after,version:a};break;case"apply":(y=t.buffer)==null||y.replace(h.after),t.base={text:h.after,version:a};break;case"gone":t.base={text:"",version:null},t.open&&this.d.store.dispatch({a:"close-editor"});break;case"conflict":this.setConflict(t,h);return}this.setConflict(t,null)}askBlame(t,n){const r=_o();t.blame={seq:r,version:n};const{worktreeId:o,path:s,ref:a}=t.file;this.d.send({t:"blame-file",worktreeId:o,path:s,ref:a,seq:r})}blamed(t,n){const r=t.blame;if(!r||r.seq!==n.seq||(t.blame=null,!t.open))return;const{commits:o,lines:s}=n;this.d.store.dispatch({a:"editor-blame",file:t.file,blame:{commits:o,lines:s,version:r.version}})}written(t,n,r){if(r.ok){t.base={text:n,version:r.version};return}if(r.reason==="changed"){t.pending??(t.pending=n),t.reread=!0;return}t.writable=!1,t.pending=null,this.d.store.dispatch({a:"editor-refused",file:t.file,message:r.message??`not saved: ${t.file.path}`})}setConflict(t,n){t.conflict===n||t.conflict&&n&&t.conflict.version===n.version||(t.conflict=n,t.open&&this.d.store.dispatch({a:"editor-conflict",file:t.file,theirs:n}))}attach(t,n){const r=this.files.get(t);if(r){if(n){r.buffer=n,r.base&&(r.base={...r.base,text:n.normalize(r.base.text)}),r.conflict&&r.pending!==null&&n.replace(r.pending);return}r.buffer&&((r.timer!==void 0||r.conflict)&&(r.pending=r.buffer.text()),this.cancelTimer(r),r.buffer=null,this.next(r))}}edited(t){const n=this.files.get(t);!(n!=null&&n.buffer)||!n.writable||n.file.ref||(this.cancelTimer(n),n.timer=this.d.timers.set(()=>{n.timer=void 0,this.saveNow(t)},sv))}saveNow(t){const n=this.files.get(t);if(!(n!=null&&n.buffer))return;this.cancelTimer(n);const r=n.buffer.text();r.length>rh||(n.pending=r,this.next(n))}cancelTimer(t){t.timer!==void 0&&(this.d.timers.clear(t.timer),t.timer=void 0)}}const vC={attach:()=>{},edited:()=>{},saveNow:()=>{}},iq=e=>({timers:{set:(t,n)=>setTimeout(t,n),clear:t=>clearTimeout(t)},win:typeof window>"u"?null:window,send:e}),ew=new Map;function aq(e){const t=ew.get(e.seq);return t?(ew.delete(e.seq),t(e),!0):!1}function lq(e,t,n,r){if(e.kind==="bytes"||e.kind==="text"||e.kind==="pr-comments")return vC;if(e.kind==="grant")return cq(e,t,n,r);const o=e.handle;let s=null,a,c=null,u=Promise.resolve(),f=!1;const h=()=>(c??(c=(async()=>await o.queryPermission({mode:"readwrite"})==="granted"?!0:await o.requestPermission({mode:"readwrite"})==="granted")().catch(()=>!1)),c),m=()=>{a!==void 0&&r.timers.clear(a),a=void 0},g=()=>{f||(f=!0,m(),n(`read-only: the browser would not save ${t}`))},y=async _=>{if(!await h())return g();const x=await o.createWritable();await x.write(_),await x.close()},w=()=>{if(!s||f)return;m();const _=s.text();u=u.then(()=>y(_)).catch(g)},v=()=>{a!==void 0&&w()};return{attach(_){var x,N;if(_){s=_,(x=r.win)==null||x.addEventListener("pagehide",v);return}a!==void 0&&w(),s=null,(N=r.win)==null||N.removeEventListener("pagehide",v)},edited(){!s||f||(h().then(_=>{_||g()}),m(),a=r.timers.set(w,sv))},saveNow:w}}function cq(e,t,n,r){let o=null,s,a=e.version,c=!1,u=null,f=!1;const h=()=>{s!==void 0&&r.timers.clear(s),s=void 0},m=v=>{f||(f=!0,h(),u=null,n(v))},g=v=>{if(!r.send)return;const _=_o();c=!0,ew.set(_,x=>{if(c=!1,x.ok?a=x.version:x.reason==="changed"?m(`read-only: ${t} changed on disk; open it again to edit`):m(x.message??`not saved: ${t}`),u!==null&&!f){const N=u;u=null,g(N)}}),r.send({t:"write-loose",id:e.id,content:v,base:a,seq:_})},y=()=>{if(!o||f)return;h();const v=o.text();v.length>rh||(c?u=v:g(v))},w=()=>{s!==void 0&&y()};return{attach(v){var _,x;if(v){o=v,(_=r.win)==null||_.addEventListener("pagehide",w);return}s!==void 0&&y(),o=null,(x=r.win)==null||x.removeEventListener("pagehide",w)},edited(){!o||f||(h(),s=r.timers.set(y,sv))},saveNow:y}}function iv({kind:e,className:t,height:n,resizable:r=!0,onDragStart:o,title:s,tabs:a,actions:c,menu:u,full:f,onToggleFull:h,onClose:m,closeHint:g="esc",children:y}){const w=vn("pane"),v=h&&d.jsxs(Oe,{variant:"outline",tone:"quiet",mono:!0,className:"deep-link",onClick:h,"data-tip":f?"Split view: show the preview above":"Full height: hide the preview",children:[d.jsx(kt,{name:f?"split":"full",className:"icon-inline"})," ",f?"split":"full"]}),_=d.jsxs("span",{className:"pane-shape",children:[v,d.jsx(At,{icon:"close",label:"Close",hint:g,onClick:m})]});return d.jsxs("div",{className:`pane ${t}`,"data-pane":e,tabIndex:-1,style:n===void 0?void 0:{height:n},children:[r&&d.jsx("div",{className:"pane-resize",onPointerDown:o}),d.jsx("div",{className:Ke("pane-head",a&&"pane-head-tabs"),...w.contextMenu(()=>(u==null?void 0:u())??[]),children:a?d.jsx(Vu,{...a,end:d.jsxs(d.Fragment,{children:[c,_]})}):d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"pane-title",children:s}),c,_]})}),y]})}function uq({src:e,path:t,full:n,onFull:r}){const o=vn("editor");return d.jsxs(d.Fragment,{children:[d.jsx("button",{type:"button",className:"editor-image",onClick:()=>r(!0),...o.contextMenu(()=>Ra(e,{open:()=>r(!0)})),children:d.jsx("img",{src:e,alt:t})}),n&&d.jsx(Qu,{owner:"editor",onClose:()=>r(!1),menu:()=>Ra(e),children:d.jsx("img",{src:e,alt:t})})]})}function dq({src:e,path:t}){return d.jsx("div",{className:"editor-video",children:d.jsx("video",{src:e,controls:!0,preload:"metadata",title:t})})}const fq={image:uq,video:dq};function hq({kind:e,src:t,path:n,openSeq:r,focus:o,full:s,onFull:a}){const c=E.useRef(null);at([r],()=>{var f;o&&((f=c.current)==null||f.focus())});const u=fq[e];return d.jsx("div",{ref:c,className:"editor-viewer",tabIndex:-1,children:d.jsx(u,{src:t,path:n,full:s,onFull:a})})}function pq(e){const t=[];return e.map(n=>{for(;t.length&&t[t.length-1]>=n;)t.pop();if(n===1)return 0;const r=t.length;return t.push(n),r})}function mq(e){const t=new Map,n=Array.from(e.querySelectorAll("h1, h2, h3, h4, h5, h6")),r=pq(n.map(o=>Number(o.tagName[1])));return n.map((o,s)=>{var u;const a=((u=o.textContent)==null?void 0:u.trim())??"",c=t.get(a)??0;return t.set(a,c+1),{id:`${c}
271
- ${a}`,level:Number(o.tagName[1]),depth:r[s],text:a,el:o}})}const gq=48,kq=16;function av({html:e,openSeq:t=0,focus:n=!0,onLink:r,onChat:o,lead:s}){const a=E.useRef(null),c=E.useRef(null),[u,f]=E.useState([]),[h,m]=E.useState(-1),[g,y]=E.useState(null),w=N=>{var T;if(y(null),N){const j=window.getSelection();j==null||j.removeAllRanges(),j==null||j.addRange(N)}(T=a.current)==null||T.focus()};at([t],()=>{var N;n&&((N=a.current)==null||N.focus())}),at([e],()=>{f(c.current?mq(c.current):[])}),E.useLayoutEffect(()=>{const N=a.current;if(!N)return;let T=0;const j=()=>{if(T=0,N.scrollTop+N.clientHeight>=N.scrollHeight-1){m(u.length-1);return}const R=N.scrollTop+gq;let C=-1;for(let M=0;M<u.length;M++)u[M].el.offsetTop<=R&&(C=M);m(C)},A=()=>{T||(T=requestAnimationFrame(j))};return j(),N.addEventListener("scroll",A),()=>{N.removeEventListener("scroll",A),T&&cancelAnimationFrame(T)}},[u]);const v=N=>{var j,A;const T=(j=u[N])==null?void 0:j.el;(A=a.current)==null||A.scrollTo({top:Math.max(0,T?T.offsetTop-kq:0),behavior:"smooth"})},_=N=>{const T=N.target.closest("a"),j=T==null?void 0:T.getAttribute("href");!j||(T==null?void 0:T.target)==="_blank"||(N.preventDefault(),r==null||r(j))},x=N=>{var T;if(Ey(N)){N.preventDefault(),N.stopPropagation();const j=(c.current&&Tk(c.current))??"";y(A=>({seed:j||(A==null?void 0:A.seed)||"",seq:((A==null?void 0:A.seq)??0)+1}));return}if(N.key==="Escape"&&g){N.stopPropagation(),w(null);return}if(eT(N)&&c.current){N.preventDefault(),nT(c.current);return}if(o&&((T=dS(N))==null?void 0:T.id)==="composer"&&c.current){const j=Tk(c.current);if(!j)return;N.preventDefault(),N.stopPropagation(),o(j)}};return d.jsxs(d.Fragment,{children:[d.jsxs("div",{ref:a,className:"document",tabIndex:-1,onClick:_,onKeyDown:x,children:[s,d.jsx("div",{ref:c,className:"md md-preview",dangerouslySetInnerHTML:{__html:e}})]}),g&&d.jsx(Jj,{root:a,body:c,seed:g.seed,seq:g.seq,onClose:w}),d.jsx(wq,{heads:u,at:h,onJump:v})]})}function wq({heads:e,at:t,onJump:n}){const[r,o]=E.useState(!1),s=E.useRef(null);return e.length<2?null:d.jsxs(d.Fragment,{children:[d.jsx("div",{ref:s,className:"document-outline","aria-hidden":!0,onPointerEnter:a=>{a.pointerType==="mouse"&&o(!0)},onClick:()=>o(a=>!a),children:e.map((a,c)=>d.jsx("span",{className:"document-outline-tick","data-level":a.level,"data-state":gr({current:c===t})},a.id))}),r&&d.jsx(Ws,{className:"document-outline-list",anchor:()=>{var a;return((a=s.current)==null?void 0:a.getBoundingClientRect())??null},placement:{side:"right",align:"center",cover:!0},trigger:s.current,onDismiss:()=>o(!1),onPointerLeave:a=>{a.pointerType==="mouse"&&o(!1)},children:e.map((a,c)=>d.jsx("button",{type:"button",className:"row document-outline-row","data-level":a.level,"data-state":gr({current:c===t}),onClick:()=>n(c),children:d.jsx("span",{className:"document-outline-label",style:{"--outline-depth":a.depth},children:a.text})},a.id))})]})}function bC({text:e,path:t,worktreeId:n,version:r,openSeq:o,focus:s,onChat:a,lead:c}){Qe();const u=Lr(),f=dt(),h=Q8(t),m=td(e,{keepHtml:!0,base:r===void 0?void 0:{worktreeId:n,dir:h,version:r,urls:u}}),g=y=>{const w=wT(h,y);w&&Pn({dispatch:f},{worktreeId:n,path:w,view:Li(w)})};return d.jsx(av,{html:m,openSeq:o,focus:s,onLink:g,onChat:a,lead:c})}function yq({refs:e,worktreeId:t}){const n=Lr();return e.length===0?null:d.jsx("div",{className:"editor-piece-chips",children:e.map(r=>r.kind==="image"?d.jsx(Tp,{className:"in-chat",src:n.attachment(t,r.file),n:r.n,name:r.name,width:r.width,height:r.height,bytes:r.bytes},`image-${r.n}`):r.kind==="file"?d.jsx(_p,{className:"in-chat",name:r.name,bytes:r.bytes,href:r.text?n.attachment(t,r.file):void 0},`file-${r.n}`):r.kind==="paste"?d.jsx(Sp,{className:"in-chat",n:r.n,name:r.name,source:r.source,lines:r.lines,chars:r.chars,preview:r.preview,href:n.attachment(t,r.file)},`paste-${r.n}`):d.jsx($p,{className:"in-chat",pick:r,worktreeId:t},`pick-${r.n}`))})}function vq(e){const t="repoName"in e&&e.repoName?` in ${e.repoName}`:"";switch(e.kind){case"starting":return"Starting.";case"failed":return`Could not start: ${e.error}`;case"here":return"This worktree's agent does it.";case"skipped":return"Skipped: nothing happened to it.";case"dropped":return e.reason;case"sent":return`Sent to ${e.title??"the worktree"}${t}.`;case"worktree":return`A worktree of its own${t}: ${e.title??"open it from the line above its text"}.`;case"queued":return`Queued until ${e.after?e.after.kind==="branch"?e.after.branch:e.after.title:e.said??"its turn"} lands.`}}function bq(e,t,n,r){const o=L(s=>s.visible);return E.useMemo(()=>{if(!e)return;const s=[];t!==null&&s.push({id:"plan",label:t});for(const a of GN(e)){const c=_6(e,a),u="worktreeId"in c?o.find(f=>f.worktree.id===c.worktreeId):void 0;s.push({id:a.id,lead:u?d.jsx("span",{className:`dot ${Fs(u)}`}):null,label:a.title})}if(!(s.length<2))return{items:s,current:n,onPick:r,owner:"handoff",label:"the plan and what it hands off",segmented:!0}},[e,t,n,r,o])}function xq({tabs:e}){const t=E.useRef(null),[n,r]=E.useState({start:!1,end:!1});return at([e.items],()=>{var c;const o=(c=t.current)==null?void 0:c.querySelector(".tabs-list");if(!o)return;const s=()=>{const u=o.scrollLeft,f=u>1,h=u+o.clientWidth<o.scrollWidth-1;r(m=>m.start===f&&m.end===h?m:{start:f,end:h})};s(),o.addEventListener("scroll",s,{passive:!0});const a=new ResizeObserver(s);return a.observe(o),()=>{o.removeEventListener("scroll",s),a.disconnect()}}),at([e.current],()=>{var o,s;(s=(o=t.current)==null?void 0:o.querySelector('.tabs-list [data-state~="current"]'))==null||s.scrollIntoView({block:"nearest",inline:"nearest"})}),d.jsxs("div",{ref:t,className:"editor-handoff-track","data-more-start":n.start?"":void 0,"data-more-end":n.end?"":void 0,children:[d.jsx("span",{className:"editor-handoff-mark",...Lt("Handed off from this plan"),children:d.jsx(kt,{name:"handoff"})}),d.jsx(Vu,{...e})]})}function Eq({item:e,piece:t}){var o,s;const n=ju(e,t),r="repoName"in n&&n.repoName?` in ${n.repoName}`:"";switch(n.kind){case"starting":return d.jsx("span",{className:"live-text",children:"starting"});case"failed":case"skipped":case"dropped":return d.jsx(d.Fragment,{children:vq(n)});case"sent":return d.jsxs(d.Fragment,{children:["Sent to ",n.worktreeId?d.jsx(Qr,{id:n.worktreeId,title:n.title}):n.title??"the worktree",r,"."]});case"worktree":return d.jsxs(d.Fragment,{children:["A worktree of its own",r,": ",d.jsx(Qr,{id:n.worktreeId,title:n.title}),"."]});case"queued":return d.jsxs(d.Fragment,{children:["Queued until"," ",((o=n.after)==null?void 0:o.kind)==="branch"?d.jsx(Qr,{id:n.after.id,title:n.after.branch}):((s=n.after)==null?void 0:s.title)??n.said??"its turn"," ","lands."]});case"here":{const a=t.after,c=a&&"piece"in a?e.pieces.find(h=>h.id===a.piece):void 0,u=c?ju(e,c):null,f=a&&"id"in a?d.jsx(Qr,{id:a.id,title:a.title}):u&&(u.kind==="worktree"||u.kind==="sent")&&u.worktreeId?d.jsx(Qr,{id:u.worktreeId,title:u.title??(c==null?void 0:c.title)}):c?c.title:null;return f?d.jsxs(d.Fragment,{children:["This worktree's agent does it, once ",f," lands."]}):d.jsx(d.Fragment,{children:"This worktree's agent does it."})}}}function Sq({item:e,piece:t,alone:n,worktreeId:r,path:o,version:s,openSeq:a,focus:c,onChat:u}){const f=Qe(),h=T=>f==null?void 0:f.send(ZN(e,r,t.id,T)),m=Hs(e,t),g=Zu(e,t),y=Nu(e)?S6(t,e.pieces).filter(T=>T!==m):[],{title:w,rest:v}=E.useMemo(()=>o_(FP(t)),[t]),_=td(`# ${w}`),x=N6(e,t,n)&&d.jsx("p",{className:"editor-piece-line hint",children:Nu(e)?d.jsxs(d.Fragment,{children:[e.stale&&"The plan changed since these were read. ",x6(t,m,g),y.length>0&&d.jsxs(d.Fragment,{children:[" ","Instead:"," ",y.map((T,j)=>d.jsxs("span",{children:[j>0&&" · ",d.jsx(Oe,{variant:"inline",onClick:()=>h(T),children:T==="send"&&t.to?`send to ${t.to.title}`:b6(t,T)})]},T))]})]}):d.jsx(Eq,{item:e,piece:t})}),N=d.jsxs("div",{className:"md md-preview editor-piece-head",children:[d.jsx("div",{dangerouslySetInnerHTML:{__html:_}}),x,d.jsx(yq,{refs:t.attachments,worktreeId:r})]});return d.jsx(bC,{text:v,path:o,worktreeId:r,version:s,openSeq:a,focus:c,onChat:u,lead:N})}function _q(e){return`/${e.replace(/(^|\/)index\.html?$/i,"$1").split("/").map(encodeURIComponent).join("/")}`}const jE=6e4,Nq=3e3,jq=e=>e.kind==="worktree"?`w:${e.worktreeId}:${e.path}`:e.kind==="loose"?`g:${e.grantId}`:`t:${e.text}`;function Tq({source:e,path:t,version:n,openSeq:r,focus:o}){const s=E.useRef(null);at([r],()=>{var y;o&&((y=s.current)==null||y.focus())});const a=Lr(),[c,u]=E.useState(null),[f,h]=E.useState(null),m=E.useRef(e);m.current=e;const g=jq(e);return E.useEffect(()=>{let y=!1,w;const v=()=>{u4(a,m.current).then(_=>{if(!y){if(_===null){w=setTimeout(v,Nq);return}if(typeof _=="string"){h(_),u(null);return}h(null),u(_.url),w=setTimeout(v,Math.max(_.ms-jE,jE))}})};return v(),()=>{y=!0,clearTimeout(w)}},[a,g,n]),d.jsx("div",{ref:s,className:"editor-viewer",tabIndex:-1,children:f!==null?d.jsx("p",{className:"hint",children:f}):c!==null&&d.jsx("iframe",{className:"editor-frame",title:t,sandbox:"allow-scripts",referrerPolicy:"no-referrer",src:c})})}function $q({worktreeId:e,openSeq:t,focus:n}){const r=Qe(),o=L(m=>{var g;return(g=Kt(m,e))==null?void 0:g.worktree.pr}),s=L(m=>{var g;return(g=Kt(m,e))==null?void 0:g.worktree.prComments}),a=L(m=>Mr(m,e).prComments),c=s==null?void 0:s.version;at([r,e,c],()=>{r==null||r.send({t:"pr-comments",worktreeId:e})});const u=E.useMemo(()=>FW(a??[]),[a]),f=G$((a==null?void 0:a.length)??0,(s==null?void 0:s.authors)??[]),h=d.jsxs("div",{className:"md md-preview pr-page",children:[d.jsx("h1",{children:o?`PR #${o.number}`:"Pull request"}),d.jsxs("p",{className:"pr-page-byline",children:[a===void 0?"reading what reviewers wrote":a.length===0?"no comments yet":d.jsxs(d.Fragment,{children:[f.count,f.rest]}),o&&d.jsxs(d.Fragment,{children:[" · ",d.jsx(Oe,{variant:"inline",tone:"quiet",onClick:()=>window.open(o.url,"_blank"),children:"on GitHub"})]})]}),u.reviews.map(m=>d.jsx(TE,{thread:m,worktreeId:e},m.root.id)),u.files.map(m=>d.jsxs("section",{children:[m.path&&d.jsx("h2",{className:"pr-page-path",children:m.path}),m.threads.map(g=>d.jsx(TE,{thread:g,worktreeId:e},g.root.id))]},m.path))]});return d.jsx(av,{html:"",openSeq:t,focus:n,lead:h})}function TE({thread:e,worktreeId:t}){const n=Dn();Qe();const{root:r,replies:o}=e,s=L(u=>u.activeId===t&&Pa(Kt(u,t))!==null),a=ev(r),c=r.review?d.jsx("span",{className:"pr-page-verb","data-review":r.review,children:Z$(r.review)}):r.path&&a?d.jsxs(Oe,{variant:"inline","data-tip":"Open the diff at this line",onClick:()=>r.path&&Pn({dispatch:n.dispatch},{worktreeId:t,path:r.path,view:"diff",...r.line?{line:{n:r.line}}:{}}),children:[r.startLine===void 0?"line":"lines"," ",a]}):null;return d.jsxs("div",{className:"pr-page-thread",children:[d.jsxs("div",{className:"pr-page-head",children:[d.jsx("span",{className:"pr-page-author",children:r.author}),c,d.jsx("span",{className:"pr-page-gap"}),d.jsx($E,{url:r.url}),s&&d.jsx(Oe,{variant:"outline",tone:"quiet","data-tip":"Put this in the message box for the agent",onClick:()=>Hf(n,{worktreeId:t,text:BW(e),name:UW(e)}),children:"add to chat"})]}),r.body&&d.jsx(CE,{text:r.body}),o.map(u=>d.jsxs("div",{className:"pr-page-reply",children:[d.jsxs("div",{className:"pr-page-head",children:[d.jsx("span",{className:"pr-page-author",children:u.author}),d.jsx("span",{className:"pr-page-gap"}),d.jsx($E,{url:u.url})]}),d.jsx(CE,{text:u.body})]},u.id))]})}function $E({url:e}){return d.jsx(Oe,{variant:"inline",tone:"quiet",onClick:()=>window.open(e,"_blank"),children:"GitHub"})}function CE({text:e}){const t=E.useMemo(()=>Ta(e),[e]);return d.jsx("div",{className:"pr-page-body",dangerouslySetInnerHTML:{__html:t}})}const Cq=900;function Iq(){return ps(tt.editorSplit,!1,e=>e===null?void 0:e==="1")}function Aq({split:e,onSplit:t}){return d.jsxs(Oe,{variant:"outline",tone:"quiet",mono:!0,className:"deep-link",onClick:()=>t(!e),"data-tip":e?"Inline: old and new in one column, and the chat back if the split took its room":"Split: old beside new, taking the chat's room when the pane is too narrow for both",children:[d.jsx(kt,{name:e?"split":"columns",className:"icon-inline"})," ",e?"inline":"split"]})}function Rq({text:e,path:t,openSeq:n,focus:r,full:o,onFull:s}){const a=E.useRef(null);at([n],()=>{var u;r&&((u=a.current)==null||u.focus())});const c=E.useMemo(()=>`data:image/svg+xml;charset=utf-8,${encodeURIComponent(e)}`,[e]);return d.jsxs("div",{ref:a,className:"editor-viewer editor-svg",tabIndex:-1,children:[d.jsx("button",{type:"button",className:"editor-image",onClick:()=>s(!0),children:d.jsx("img",{src:c,alt:t})}),o&&d.jsx(Qu,{owner:"editor",onClose:()=>s(!1),children:d.jsx("img",{className:"editor-svg-full",src:c,alt:t})})]})}function Oq(){return ps(tt.editorWrap,!1,e=>e===null?void 0:e==="1")}function Mq({wrap:e,onWrap:t}){return d.jsxs(Oe,{variant:"outline",tone:"quiet",mono:!0,className:"deep-link",onClick:()=>t(!e),"data-tip":e?"Unwrap lines: one line per row, scroll sideways for the rest":"Wrap lines: fold a long line at the pane's edge",children:[d.jsx(kt,{name:"wrap",className:"icon-inline"})," ",e?"unwrap":"wrap"]})}const Lq=E.lazy(async()=>{const[e]=await Promise.all([Jk(()=>import("./Editor-C2e_GpDQ.js").then(t=>t.E),__vite__mapDeps([0,1,2])),Jk(()=>import("./grammar-Cty-NAQC.js"),[]).then(t=>t.grammarsReady)]);return e});function IE({what:e}){return mN(!0,3e3)?d.jsx("div",{className:"empty",children:d.jsxs("span",{className:"live-text",children:["loading ",e]})}):null}const Pq=()=>{},Dq=[],zq={diff:"diff",file:"text",preview:"book"};function Fq({path:e,note:t,title:n,worktreeId:r}){const o=Dn(),s=hp(),a=I_(e),c=n??a.name,u=n?"":a.dir;return d.jsxs("span",{className:"editor-title","data-tip":u||n?e:void 0,draggable:s&&!!r,onDragStart:r?f=>$u(f,{kind:"paths",worktreeId:r,items:[{path:e,folder:!1}]}):void 0,onDragEnd:r?()=>Yu(o):void 0,children:[d.jsxs("span",{className:"editor-name",children:[c,t]}),u&&d.jsx("span",{className:"editor-dir row-dim",children:u})]})}function Bq(e,t){return e==="diff"?"Diff view: show what changed":e==="preview"?"Preview: read it rendered":t==="diff"?"File view: hide the diff":"File view: edit the text"}function xC({editor:e,height:t,full:n=!1,onToggleFull:r,onDragStart:o,placement:s="stack"}){const a=s==="screen",c=dt(),u=Dn(),f=Qe(),h=Lr(),m=Jw(),g=op(),{worktreeId:y,path:w,ref:v,since:_}=e,x=e.loose,N=(x==null?void 0:x.source.kind)==="pr-comments",T=L(De=>{var nt;return((nt=Uo(De))==null?void 0:nt.id)===y}),j=L(De=>{var lt,Yt;const nt=(lt=Kt(De,y))==null?void 0:lt.worktree;return nt?nt.path:(Yt=Uo(De))==null?void 0:Yt.path}),A=v!==void 0,R=L(De=>{var nt;return(nt=Kt(De,y))==null?void 0:nt.worktree.plan}),C=!x&&!A&&R===w,M=Xy(C?y:void 0,C?w:void 0),I=L(De=>m6(Mr(De,y).chat??Dq,w,R)),D=A||x||e.view!=="preview"?null:I,[H,Z]=E.useState(null);at([D==null?void 0:D.id,w],()=>Z(null)),at([e.seq],()=>{e.piece&&Z(e.piece)});const B=!!D&&!k6(D),J=D?H!==null&&(H==="plan"?B:D.pieces.some(De=>De.id===H))?H:j6(D,B):"plan",V=D&&J!=="plan"?D.pieces.find(De=>De.id===J)??null:null,ee=bq(D,B?"Plan":null,J,Z),F=E.useMemo(()=>x?lq(x.source,w,De=>c({a:"editor-refused",file:{worktreeId:y,path:w},message:De}),iq(f?De=>f.send(De):null)):(m==null?void 0:m.bind({worktreeId:y,path:w,...v?{ref:v}:{},..._?{since:_}:{}}))??vC,[m,y,w,v,_,x,c,f]),$=L(De=>Mr(De,y).changedRanges[w]);E.useEffect(()=>{!$&&!A&&!T&&!x&&(f==null||f.send({t:"changed-ranges",worktreeId:y,path:w}))},[y,w,$,A,T,x,f]);const Q=($==null?void 0:$.offset)??0,q=e.disk,W=e.view??"diff",oe=!!q&&(q.before===""||q.before===q.after),de=N?[]:ON(w,oe).filter(De=>De!==W&&!(x&&De==="diff")),he=(x==null?void 0:x.source.kind)==="grant"?x.source:null,Ne=A||T||x&&!he?null:WD(w),Me=Yh(w),[Be,K]=E.useState(!1),te=Ne==="image"||W==="preview"&&Me==="svg"&&!!q&&!q.binary&&!q.tooLarge,[pe,ue]=Oq(),ie=!!q&&!N&&!Ne&&!q.binary&&!q.tooLarge&&W!=="preview",ye=ie&&W==="diff"&&!oe&&!a,[Se,Ee]=Iq(),Le=E.useRef(null),Ue=E.useRef(!1),Je=L(De=>De.layout.chat);at([Je],()=>{Je&&(Ue.current=!1)});const Ht=E.useCallback(()=>{if(!Ue.current)return;Ue.current=!1;const De=u.getState();!De.layout.chat&&!No(De)&&c({a:"toggle-chat"})},[u,c]),qt=De=>{var Yt;if(Ee(De),!De){Ht();return}const nt=u.getState(),lt=((Yt=Le.current)==null?void 0:Yt.clientWidth)??Number.POSITIVE_INFINITY;nt.layout.chat&&!No(nt)&&lt<Cq&&(Ue.current=!0,c({a:"toggle-chat"}))};E.useEffect(()=>Ht,[Ht]);const xt=e.line&&!e.line.fiber?e.line.n:void 0,_t=L(De=>{var nt;return((nt=Su(De))==null?void 0:nt.worktreeId)===y})&&!a&&!A&&!T&&!x&&Me==="html",mt=()=>{un.post(y,{type:"navigate",path:_q(w)}),n&&(r==null||r())};return d.jsxs(iv,{kind:"editor",className:Ke("editor-pane",n&&"full"),height:n||a?void 0:t,resizable:!n&&!a,onDragStart:o??Pq,title:d.jsx(Fq,{path:w,note:A?` at ${v==null?void 0:v.slice(0,7)}`:_?", last turn":void 0,title:C&&M?M:void 0,worktreeId:x?void 0:y}),menu:()=>j&&!x?Ls({id:y,dir:j},w,{discard:!A&&!T,kept:T,ref:v,showing:e.view??void 0,noDiff:oe},{sock:f,dispatch:c}):[],onClose:()=>c({a:"close-editor"}),full:n,onToggleFull:a?void 0:r,actions:d.jsxs(d.Fragment,{children:[!Ne&&de.length>0&&d.jsx("span",{className:"editor-views",children:de.map(De=>d.jsxs(Oe,{variant:"outline",tone:"quiet",mono:!0,className:"deep-link",onClick:()=>c({a:"editor-view",v:De}),"data-tip":Bq(De,W),children:[d.jsx(kt,{name:zq[De],className:"icon-inline"})," ",De]},De))}),te&&d.jsxs(Oe,{variant:"outline",tone:"quiet",mono:!0,className:"deep-link",onClick:()=>K(!0),"data-tip":"Full size: see the picture over the window",children:[d.jsx(kt,{name:"zen",className:"icon-inline"})," full size"]}),ye&&d.jsx(Aq,{split:Se,onSplit:qt}),ie&&d.jsx(Mq,{wrap:pe,onWrap:ue}),_t&&d.jsxs(Oe,{variant:"outline",tone:"quiet",mono:!0,className:"deep-link",onClick:mt,"data-tip":"Run: open the page in the preview, with its scripts on",children:[d.jsx(kt,{name:"run",className:"icon-inline"})," run"]})]}),children:[q&&d.jsx(Uq,{editor:e,disk:q,files:m}),ee&&d.jsx(xq,{tabs:ee}),d.jsx("div",{className:"editor-body",ref:Le,children:N?d.jsx($q,{worktreeId:y,openSeq:e.seq,focus:e.focus}):q?Ne?d.jsx(hq,{kind:Ne,src:he?h.loose(he.id,he.version):h.worktreeFile(y,w,q.version),path:w,openSeq:e.seq,focus:e.focus,full:Be,onFull:K}):q.binary?d.jsx("div",{className:"empty",children:"not a text file: open it in another editor"}):q.tooLarge?d.jsx("div",{className:"empty",children:"too large to open here: open it in another editor"}):W==="preview"&&D&&V?d.jsx(Sq,{item:D,piece:V,alone:!ee,worktreeId:y,path:w,version:A||T||x?void 0:q.version,openSeq:e.seq,focus:e.focus,onChat:De=>Hf(u,{worktreeId:y,text:De,name:w})}):W==="preview"&&Me==="svg"?d.jsx(Rq,{text:q.after,path:w,openSeq:e.seq,focus:e.focus,full:Be,onFull:K}):W==="preview"&&Me==="html"?d.jsx(Tq,{source:he?{kind:"loose",grantId:he.id}:A||T||x?{kind:"text",text:q.after}:{kind:"worktree",worktreeId:y,path:w},path:w,version:q.version,openSeq:e.seq,focus:e.focus}):W==="preview"?d.jsx(bC,{text:q.after,path:w,worktreeId:y,version:A||T||x?void 0:q.version,openSeq:e.seq,focus:e.focus,onChat:De=>Hf(u,{worktreeId:y,text:De,name:w})}):d.jsx(gy,{pane:!0,children:d.jsx(E.Suspense,{fallback:d.jsx(IE,{what:W}),children:d.jsx(Lq,{file:{worktreeId:y,path:w,...v?{ref:v}:{},..._?{since:_}:{}},disk:q,blame:e.blame,view:W,openSeq:e.seq,line:xt,focus:e.focus,readOnly:A||!q.writable||a,numbers:!a,wrap:pe,split:Se,theme:g,sync:F,onCopy:x?void 0:(De,nt,lt)=>D3(lt,{worktreeId:y,path:De,...nt,...v?{ref:v}:{}}),onChat:(De,nt)=>Hf(u,nt&&(x?{worktreeId:y,text:nt.text,name:De}:{worktreeId:y,text:nt.text,source:{path:De,startLine:nt.startLine,endLine:nt.endLine,...v?{ref:v}:{}}})),onNew:()=>u.dispatch({a:"open-draft"}),onLineHover:A||x?void 0:De=>{De==null?un.post(y,{type:"highlight-clear"}):un.post(y,{type:"highlight-file",path:w,ranges:[[De+Q,De+Q]]})}},`${y}
272
- ${x?"loose":v??_??""}
273
- ${w}`)})}):d.jsx(IE,{what:w},w)})]})}function Uq({editor:e,disk:t,files:n}){var f,h;const{worktreeId:r,path:o,ref:s,since:a,conflict:c}=e,u={worktreeId:r,path:o,...s?{ref:s}:{},...a?{since:a}:{}};if(c){const m=c.version===null;return d.jsxs("div",{className:"editor-note",children:[d.jsx("span",{className:"editor-note-text",children:m?"deleted on disk; your edits are not saved":"changed on disk; your edits are not saved"}),d.jsx(Oe,{variant:"outline",onClick:()=>n==null?void 0:n.reload(u),"data-tip":m?"Close the file; your edits go with it":"Take the file as it is on disk; undo brings your edits back",children:m?"close":"reload"}),d.jsx(Oe,{variant:"outline",tone:"danger",onClick:()=>n==null?void 0:n.keepMine(u),"data-tip":m?"Save your edits as the file again":"Save your edits over the file on disk",children:"keep mine"})]})}return e.refused?d.jsx("div",{className:"editor-note",children:d.jsx("span",{className:"hint",children:e.refused})}):((f=e.loose)==null?void 0:f.source.kind)==="pr-comments"?null:((h=e.loose)==null?void 0:h.source.kind)==="text"&&!t.writable?d.jsx("div",{className:"editor-note",children:d.jsx("span",{className:"hint",children:"read-only: the message as it was sent, kept in the chat and not in a file"})}):e.loose&&!t.writable&&!t.tooLarge&&!t.binary?d.jsx("div",{className:"editor-note",children:d.jsxs("span",{className:"hint",children:["read-only: ",o," is not in a project; drop it on a folder in files to add it"]})}):s===void 0&&!t.writable&&!t.binary&&!t.tooLarge?d.jsx("div",{className:"editor-note",children:d.jsx("span",{className:"hint",children:"read-only: Toyon does not run this worktree"})}):null}function EC(e,t,n=!1){var o;const r=((o=t.find(s=>s.id===(e==null?void 0:e.repoId)))==null?void 0:o.defaultBranch)??"the default branch";return e!=null&&e.building?{text:`Rebuilding Toyon from ${r}`,busy:!0}:e!=null&&e.buildFailed?{text:"Rebuilding Toyon stopped",detail:e.buildFailed,build:"try again",busy:!1}:e!=null&&e.rebuild?{text:`Toyon's shell is behind ${r}`,build:"rebuild",busy:!1}:e!=null&&e.restart?{text:n?`Toyon itself is behind ${r}; this page reloads once it has restarted`:`Toyon itself is behind ${r}`,restart:!0,busy:!1}:n?{text:"Toyon's shell was rebuilt while this page was open",reload:!0,busy:!1}:null}const Hq=(e,t)=>{const n=nk(t);switch(e){case"npm":case"bun":return`installed with ${e}. A newer version from ${n} installs itself when nothing is busy; press to check now and install one if it is out`;case"npx":return`run with npx, which fetches the newest version from ${n} itself. Press to check for one now`;case"none":return"run from a checkout, which does not update itself. Press to check for a newer release"}},Wq="https://toyon.dev",_h="https://github.com/toyon-dev/toyon",Kq=e=>`${_h}/releases/tag/v${e}`,qq=`${_h}/releases/latest`,Zq=4e3;function Gq(e,t,n,r){if(r==="asking")return{value:`${e} checking`,text:`Asking ${nk(n)} for the newest version`,act:"check",busy:!0};const o=nk(r.registry),s={act:"check",busy:!1};if(r.latest===null)return{...s,value:`${e} no answer`,text:`Could not reach ${o}. Press to ask again`,settles:!0};if(f_(r.latest,e)){const a=t==="none"?"This copy runs from a checkout, so pull to get it":t==="npx"?`This copy runs with npx, so run npx toyon@${r.latest} to use it`:"It installs once no chat is replying";return{...s,value:`${r.latest} out`,text:`Toyon ${r.latest} is out. ${a}`}}return{...s,value:`${e} up to date`,text:`Toyon ${e} is the newest version ${o} lists. Press to ask again`,settles:!0}}function Vq(e,t,n,r,o,s=!1,a=null,c=null){if(n){if(n.restarting){const f=n.installed??n.running,h=n.restarting.length>0?wj(n.restarting):"Toyon is restarting; this page reloads when it is back";return{value:`${f} restarting`,text:h,act:"restart",busy:!0}}if(n.installing){const f=n.latest??n.installed??n.running;return{value:`${f} installing`,text:`Installing Toyon ${f}`,act:"update",busy:!0}}if(n.failed){const f=n.failed.line.replace(/\.$/,"");return{value:`${n.running} update failed`,text:`Installing Toyon ${n.failed.version} stopped: ${f}. Press to try again, or run ${n.failed.command}`,act:"update",busy:!1}}if(n.installed)return{value:`${n.installed} ready`,text:`Toyon ${n.installed} is installed and ${n.running} is still running. It restarts onto the new one when nothing is busy; press to restart now`,act:"restart",busy:!1};if(n.latest)return{value:`${n.latest} out`,text:n.method==="npx"?`Toyon ${n.latest} is out. This copy runs with npx, so run npx toyon@${n.latest} to use it`:`Toyon ${n.latest} is out and installs when nothing is busy; press to install now`,act:"update",busy:!1}}const u=EC(r,o,s);return u?u.busy?{value:`${e} rebuilding`,text:u.text,act:"rebuild",busy:!0}:u.reload?{value:`${e} rebuilt`,text:u.text,act:"reload",busy:!1}:u.build==="try again"?{value:`${e} rebuild stopped`,text:u.text,detail:u.detail,act:"rebuild",busy:!1}:{value:`${e} behind`,text:u.text,act:u.build?"rebuild":"restart",busy:!1}:c?Gq(e,t,a,c):{value:e,text:`Toyon ${e}, ${Hq(t,a)}`,act:"check",busy:!1}}function Yq(e,t,n){const r=o=>()=>window.open(o,"_blank");return Wn([t?[{id:"check-update",label:"check for updates",...t.off?{disabled:t.off}:{},onClick:t.run}]:[],[n?{id:"release-notes",label:"release notes",onClick:n}:{id:"release-notes",label:`release notes for ${e}`,onClick:r(Kq(e))},{id:"latest-release",label:"latest release",onClick:r(qq)},{id:"site",label:"toyon.dev",onClick:r(Wq)},{id:"repo",label:"Toyon on GitHub",onClick:r(_h)},{id:"report",label:"report a problem",onClick:r(`${_h}/issues/new`)}],[{id:"copy-version",label:"copy version",onClick:()=>tn(e)}]])}const Xq=TA.map(e=>({title:e,rows:IA(e).map(t=>[Pt(t),fu[t].label])}));function Qq(){const e=dt(),t=Qe(),n=vn("keys"),r=L(g=>g.themePrefs),o=L(g=>g.themes),s=L(g=>g.chatSide),a=L(g=>g.keepAwake),c=Qw(),u=L(g=>g.agents),f=lc(),h=L(g=>g.rows),m=g=>{e({a:"palette-return",v:{mode:"keys",q:""}}),e(g)};return d.jsxs(Mu,{bare:!0,boxClass:"keys-stack",id:"keys-help",onClose:()=>e({a:"close"}),children:[d.jsxs("div",{className:"keys-card",children:[d.jsxs("div",{children:[f&&d.jsxs(d.Fragment,{children:[d.jsx("div",{className:"section-title keys-h",children:f.name}),d.jsxs("div",{className:"keys-setting",children:[d.jsx("span",{className:"keys-d",children:"processes"}),d.jsx(Oe,{variant:"field",mono:!0,className:"keys-chip","data-tip":`edit the install + start commands in ${f.configFile}`,onClick:()=>e({a:"open",overlay:{kind:"setup",repoId:f.id}}),...n.contextMenu(()=>gp(f,f.id,{sock:t,dispatch:e},h)),children:d.jsx("span",{className:"keys-v",children:Object.keys(f.config.run).join(" + ")||"not set up"})})]})]}),d.jsx("div",{className:"section-title keys-h",children:"Agents"}),u.map(g=>d.jsx(tZ,{agent:g},g.id))]}),d.jsxs("div",{children:[d.jsx("div",{className:"section-title keys-h",children:"Appearance"}),d.jsxs("div",{className:"keys-setting",children:[d.jsx("span",{className:"keys-d",children:"mode"}),d.jsx(Oe,{variant:"field",mono:!0,onClick:()=>m({a:"open",overlay:{kind:"appearance"}}),children:ph[r.mode]})]}),d.jsxs("div",{className:"keys-setting",children:[d.jsx("span",{className:"keys-d",children:"theme"}),d.jsx(Oe,{variant:"field",mono:!0,onClick:()=>m({a:"open",overlay:{kind:"theme",slot:"theme"}}),children:Vh(r,o,c).name})]}),d.jsxs("div",{className:"keys-setting",children:[d.jsx("span",{className:"keys-d",children:"chat side"}),d.jsx(Oe,{variant:"field",mono:!0,onClick:()=>e({a:"toggle-chat-side"}),children:s})]}),d.jsx("div",{className:"section-title keys-h",children:"Toyon"}),a!==null&&d.jsxs("div",{className:"keys-setting",children:[d.jsx("span",{className:"keys-d",children:"keep awake"}),d.jsx(Oe,{variant:"field",mono:!0,onClick:()=>m({a:"open",overlay:{kind:"keep-awake"}}),children:mh[a]})]}),d.jsx(Jq,{}),d.jsx(eZ,{})]})]}),d.jsx("div",{className:"keys-card",children:Xq.map(g=>d.jsxs("div",{children:[d.jsx("div",{className:"section-title keys-h",children:g.title}),g.rows.map(([y,w])=>d.jsxs("div",{className:"keys-row",children:[d.jsx(os,{k:y}),d.jsx("span",{className:"keys-d",children:w})]},y))]},g.title))})]})}function Jq(){const e=Qe(),t=dt(),n=vn("keys"),r=L(T=>T.version),o=L(T=>T.install),s=L(T=>T.registry),a=L(T=>T.update),c=L(T=>T.self),u=L(T=>T.rebuilt),f=L(T=>T.repos),h=L(T=>T.managed.updates),m=L(T=>T.updateCheck),g=L(T=>T.frame),y=L(T=>T.newProject!==null),w=Vq(r,o,a,c,f,u,s,m),v=!h&&(w.act==="update"||w.act==="check"),_=w.settles&&m&&m!=="asking"?m:null;E.useEffect(()=>{if(!_)return;const T=()=>t({a:"update-check-settle",check:_}),j=setTimeout(T,Zq);return()=>{clearTimeout(j),T()}},[_,t]);const x=()=>{w.act==="restart"?e==null||e.send({t:"restart-daemon"}):w.act==="reload"?window.location.reload():w.act==="rebuild"&&c?e==null||e.send({t:"run-after-land",repoId:c.repoId}):w.act==="update"?e==null||e.send({t:"update-now"}):w.act==="check"&&e&&(t({a:"update-check"}),e.send({t:"check-update"}))},N=()=>Yq(r,w.act==="check"&&!w.busy?{run:x,...v?{off:"managed by your organization"}:{}}:null,g==="phone"||y?void 0:()=>t({a:"open-release-notes"}));return d.jsxs("div",{className:"keys-setting",...n.contextMenu(N),children:[d.jsx("span",{className:"keys-d",children:"version"}),d.jsx(Oe,{variant:"field",mono:!0,busy:w.busy,disabled:v,onClick:x,...Lt(v?"updates are managed by your organization":w.text,void 0,{detail:w.detail}),children:w.value})]})}function eZ(){const e=L(n=>n.managed);if(e.source===null)return null;const t=e.problem?"the policy file on this machine is invalid, so everything it governs is off; toyon doctor says why":`managed by your organization: ${_P(e).join(", ")||"nothing turned off"}`;return d.jsx("div",{className:"hint",children:t})}function SC(e){return e.available?e.auth?e.auth.kind==="none"?"not logged in":e.auth.label:e.checkFailed?"not ready":"ready":e.installing?"installing":"not installed"}function _C(e){var n,r;return e.available?e.checkFailed?e.checkFailed:e.auth?[e.auth.detail,(n=e.auth.account)==null?void 0:n.email,(r=e.auth.account)==null?void 0:r.organization].filter(Boolean).join(" · ")||e.auth.label:"installed; it names the account it runs on the first time it runs":Ip(e)}function tZ({agent:e}){const t=dt(),n=Qe(),r=vn("keys");return d.jsxs("div",{className:"keys-setting",children:[d.jsx("span",{className:"keys-d",children:e.name}),d.jsx(Oe,{variant:"field",mono:!0,"data-tip":_C(e),...r.contextMenu(()=>Qy(e,{sock:n})),onClick:()=>{t({a:"palette-return",v:{mode:"keys",q:""}}),t({a:"open",overlay:{kind:"agent-page",agent:e.id}})},children:SC(e)})]})}function nZ({agentId:e}){const t=dt(),n=Qe(),r=lc(),o=L(g=>g.home),s=L(g=>g.agents.find(y=>y.id===e)??null),a=L(g=>g.agentConfigs[e]??null),c=vn("keys");if(E.useEffect(()=>{n==null||n.send({t:"agent-config",agent:e,...r?{repoId:r.id}:{}})},[n,e,r]),yC(n,e,s??void 0),!s)return null;const u=Qy(s,{sock:n}),f=()=>t({a:"close",back:!0}),h=g=>o&&g.startsWith(`${o}/`)?`~${g.slice(o.length)}`:g,m=g=>n==null?void 0:n.send({t:"reveal-agent-file",agent:e,file:g.id,...r?{repoId:r.id}:{}});return d.jsx(Mu,{bare:!0,boxClass:"keys-stack",onClose:f,children:d.jsxs("div",{className:"keys-card keys-settings",children:[d.jsx("div",{className:"agent-page-back",children:d.jsx(At,{icon:"back",label:"back to settings",hint:"esc",onClick:f})}),d.jsx("div",{className:"section-title keys-h",children:s.name}),d.jsxs("div",{className:"keys-setting",children:[d.jsx("span",{className:"keys-d",children:"signed in"}),d.jsx(Oe,{variant:"field",mono:!0,"data-tip":_C(s),disabled:u.length===0,...c.dropdown(()=>u,"right"),children:SC(s)})]}),d.jsxs("div",{className:"keys-setting",children:[d.jsx("span",{className:"keys-d",children:"commit messages"}),d.jsx("span",{className:"keys-d",children:s.quick?"its quick model writes one after each turn":"none: it offers no small model, so you write them in the changes panel"})]}),d.jsx("div",{className:"section-title keys-h",children:"MCP servers it will load"}),a===null?d.jsx("div",{className:"keys-setting",children:d.jsx("span",{className:"keys-d live-text",children:"reading"})}):a.servers.length===0?d.jsxs("div",{className:"keys-setting",children:[d.jsx("span",{className:"keys-d",children:"none configured"}),d.jsx("span",{className:"keys-d",children:"add one with the agent's own CLI, or a .mcp.json in the repo"})]}):a.servers.map(g=>d.jsx(rZ,{s:g},`${g.scope}:${g.name}`)),a&&a.files.length>0&&d.jsxs(d.Fragment,{children:[d.jsx("div",{className:"section-title keys-h",children:"the files it reads"}),a.files.map(g=>d.jsxs("div",{className:"keys-setting",children:[d.jsx("span",{className:"keys-d",children:g.label}),g.exists?d.jsx(Oe,{variant:"field",mono:!0,"data-tip":`reveal ${h(g.path)} in Finder`,onClick:()=>m(g),children:h(g.path)}):d.jsxs("span",{className:"keys-d",children:["not present: ",h(g.path)]})]},g.id))]})]})})}function rZ({s:e}){return d.jsxs("div",{className:"keys-setting",children:[d.jsx("span",{children:e.name}),d.jsx("span",{className:"keys-d",children:e.detail?`${e.scope} · ${e.detail}`:e.scope})]})}function oZ(){const e=dt(),t=Qe(),n=L(o=>o.agents),r=L(o=>o.defaultAgent);return d.jsx(qr,{items:n,filter:(o,s)=>o.filter(a=>rs(s,a.name,a.id)),rowClass:o=>o.available?"picker-row":"picker-row dim",keyOf:o=>o.id,initialIndex:o=>Math.max(0,o.findIndex(s=>s.id===r)),onPick:o=>{o.available&&(t==null||t.send({t:"set-default-agent",agent:o.id}),e({a:"close"}))},onBack:()=>e({a:"close",back:!0}),rowMenu:o=>Qy(o,{sock:t}),placeholder:"default agent for new worktrees",row:o=>d.jsx(An,{label:o.name,current:o.id===r,hint:o.available?o.checkFailed??(o.sandboxed?void 0:"unsandboxed"):Ip(o)})})}const sZ=["dark","light","system","daylight"],iZ=new Intl.DateTimeFormat(void 0,{hour:"numeric",minute:"2-digit"});function aZ(){const e=dt(),t=Qe(),n=L(u=>u.themePrefs),r=L(u=>u.themes),o=Qw(),s=L(u=>u.daylight),a=u=>{var f;return((f=r.find(h=>h.id===n[Cw({...n,mode:u},o)]))==null?void 0:f.name)??""},c=u=>{if(u==="system")return`${o.system?"dark":"light"} now · ${a(u)}`;if(u!=="daylight")return a(u);const f=s&&s.until>Date.now()?` · ${o.daylight?"light":"dark"} at ${iZ.format(s.until)}`:"";return`${o.daylight?"dark":"light"} now${f} · ${a(u)}`};return d.jsx(qr,{items:sZ,filter:(u,f)=>u.filter(h=>rs(f,ph[h])),rowClass:()=>"picker-row",keyOf:u=>u,initialIndex:u=>u.indexOf(n.mode),onActive:u=>e({a:"preview-theme",theme:u?Vh({...n,mode:u},r,o):null}),onPick:u=>{t==null||t.send({t:"set-theme",prefs:{...n,mode:u}}),e({a:"close"})},onBack:()=>e({a:"close",back:!0}),placeholder:"light/dark mode",keys:{nav:"preview",pick:"keeps",back:"reverts"},row:u=>d.jsx(An,{label:ph[u],current:u===n.mode,hint:c(u)})})}const lZ=2,tw=e=>l_(e).join(" ").length<lZ,cZ=e=>({kind:"chat",id:e.id,name:e.name,hint:e.branch??"",fields:[e.name,e.branch??""]}),uZ=e=>({kind:"chat",id:e.id,name:e.title,hint:Zj(e),fields:[e.title,e.branch],prompt:e.prompt,archived:e});function dZ(e,t,n){const r=l_(t),o=n==="all"&&!tw(t);return e.filter(s=>{if(s.kind==="hit")return o;const a=n==="names"&&s.prompt?[...s.fields,s.prompt]:s.fields;return r.every(c=>a.some(u=>u.toLowerCase().includes(c)))})}const fZ=e=>e.flatMap(([t,n])=>Array.from({length:n},(r,o)=>t+o));function hZ({repoId:e,scope:t}){const n=dt(),r=Qe(),o=L(j=>j.clientId),s=L(j=>j.frame),a=L(j=>j.chats[e]),c=ry(),u=L(j=>j.archived[e]),[f,h]=E.useState(t),m=E.useCallback(()=>h(j=>j==="all"?"names":"all"),[]);E.useEffect(()=>{r==null||r.send({t:"list-archived",repoId:e})},[r,e]);const g=E.useMemo(()=>[...c.filter(j=>!Cr(j.worktree)).map(cZ),...(u??[]).map(uZ)],[c,u]),y=E.useMemo(()=>new Map(g.map(j=>[j.id,j])),[g]),w=E.useMemo(()=>[...g,...((a==null?void 0:a.hits)??[]).map(j=>({kind:"hit",hit:j}))],[g,a]),v=E.useMemo(()=>{const j=new Map;for(const A of(a==null?void 0:a.hits)??[])j.set(A.worktreeId,Math.max(j.get(A.worktreeId)??0,A.ts));return j},[a]),_=E.useCallback((j,A)=>dZ(j,A,f),[f]),x=E.useCallback(j=>{f==="all"&&!tw(j)&&(r==null||r.send({t:"search-chats",repoId:e,query:j.trim()}))},[r,e,f]),N=j=>!a||a.query!==j.trim(),T=j=>f==="all"&&!tw(j);return d.jsx(qr,{items:w,filter:_,onQuery:x,onTab:m,trailing:d.jsx(Oe,{tone:"chrome",on:f==="names","aria-pressed":f==="names",onClick:m,children:"names only"}),keyOf:j=>j.kind==="hit"?`h:${j.hit.worktreeId}:${j.hit.seq}`:`w:${j.id}`,rowClass:j=>j.kind==="hit"?"chats-hit":Ke("picker-row",j.archived&&!j.archived.restorable&&"dim"),rowTitle:j=>{var A;return j.kind==="hit"?j.hit.text:((A=j.archived)==null?void 0:A.prompt)??j.name},groupOf:j=>j.kind==="hit"?`h:${j.hit.worktreeId}`:j.archived?"archived":"open",groupHead:(j,A)=>{if(!j.startsWith("h:"))return`${j} · ${A}`;const R=j.slice(2),C=y.get(R),M=a==null?void 0:a.asks[R],I=v.get(R)??0;return d.jsxs(d.Fragment,{children:[d.jsxs("span",{className:"chats-name",children:[(C==null?void 0:C.name)??"a worktree",(C==null?void 0:C.archived)&&d.jsxs(d.Fragment,{children:[" ",d.jsx("span",{className:"row-dim",children:"archived"})]})]}),I>0&&d.jsx("span",{className:"picker-group-tail",children:mr(I)}),M&&d.jsx("span",{className:"picker-group-line",children:pp(M,Aj*2)})]})},headAlone:!0,onPick:j=>{const A=j.kind==="hit"?j.hit.worktreeId:j.id,R=j.kind==="hit"?j.hit.archived:!!j.archived;n(R?{a:"open-archived",id:A}:{a:"activate",id:A}),j.kind==="hit"&&n({a:"reveal",id:A,seq:j.hit.seq}),n({a:"close"})},onBack:()=>n({a:"close"}),rowMenu:j=>j.kind==="chat"&&j.archived?Kf(j.archived,{clientId:o,frame:s},{sock:r,dispatch:n}):[],placeholder:f==="names"?"find a chat by name…":"search in chats…",keys:j=>({nav:"moves",tab:f==="names"?"searches messages too":"searches names only",pick:j?j.kind==="hit"?"opens the chat there":"opens its chat":void 0,back:"closes"}),empty:j=>j.trim()?T(j)?N(j)?d.jsx("span",{className:"live-text",children:"searching"}):"no chat says that":"no chat is named that":u?"no chats yet":d.jsx("span",{className:"live-text",children:"looking"}),footer:(j,A)=>{const R=A.filter(C=>C.kind==="hit").length;return a!=null&&a.truncated&&!N(j)&&R>0?d.jsxs("div",{className:"empty",children:["showing the first ",R,"; narrow the search"]}):null},row:j=>j.kind==="chat"?d.jsx(An,{label:j.name,hint:j.hint}):d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"chats-text",children:oc(j.hit.text,fZ(j.hit.match),0)}),d.jsxs("span",{className:"chats-said row-dim",children:[j.hit.role==="user"?"you":"the agent",j.hit.ts>0&&mr(j.hit.ts)!==mr(v.get(j.hit.worktreeId)??0)?` · ${mr(j.hit.ts)}`:""]})]})})}const uc=function(e,t){let o=e;const s=uu[t];let a=null,c=0,u=null;const f=[],h={},m=function(C,M){c=o*4+17,a=(function(I){const D=new Array(I);for(let H=0;H<I;H+=1){D[H]=new Array(I);for(let Z=0;Z<I;Z+=1)D[H][Z]=null}return D})(c),g(0,0),g(c-7,0),g(0,c-7),v(),w(),x(C,M),o>=7&&_(C),u==null&&(u=j(o,s,f)),N(u,M)},g=function(C,M){for(let I=-1;I<=7;I+=1)if(!(C+I<=-1||c<=C+I))for(let D=-1;D<=7;D+=1)M+D<=-1||c<=M+D||(0<=I&&I<=6&&(D==0||D==6)||0<=D&&D<=6&&(I==0||I==6)||2<=I&&I<=4&&2<=D&&D<=4?a[C+I][M+D]=!0:a[C+I][M+D]=!1)},y=function(){let C=0,M=0;for(let I=0;I<8;I+=1){m(!0,I);const D=Si.getLostPoint(h);(I==0||C>D)&&(C=D,M=I)}return M},w=function(){for(let C=8;C<c-8;C+=1)a[C][6]==null&&(a[C][6]=C%2==0);for(let C=8;C<c-8;C+=1)a[6][C]==null&&(a[6][C]=C%2==0)},v=function(){const C=Si.getPatternPosition(o);for(let M=0;M<C.length;M+=1)for(let I=0;I<C.length;I+=1){const D=C[M],H=C[I];if(a[D][H]==null)for(let Z=-2;Z<=2;Z+=1)for(let B=-2;B<=2;B+=1)Z==-2||Z==2||B==-2||B==2||Z==0&&B==0?a[D+Z][H+B]=!0:a[D+Z][H+B]=!1}},_=function(C){const M=Si.getBCHTypeNumber(o);for(let I=0;I<18;I+=1){const D=!C&&(M>>I&1)==1;a[Math.floor(I/3)][I%3+c-8-3]=D}for(let I=0;I<18;I+=1){const D=!C&&(M>>I&1)==1;a[I%3+c-8-3][Math.floor(I/3)]=D}},x=function(C,M){const I=s<<3|M,D=Si.getBCHTypeInfo(I);for(let H=0;H<15;H+=1){const Z=!C&&(D>>H&1)==1;H<6?a[H][8]=Z:H<8?a[H+1][8]=Z:a[c-15+H][8]=Z}for(let H=0;H<15;H+=1){const Z=!C&&(D>>H&1)==1;H<8?a[8][c-H-1]=Z:H<9?a[8][15-H-1+1]=Z:a[8][15-H-1]=Z}a[c-8][8]=!C},N=function(C,M){let I=-1,D=c-1,H=7,Z=0;const B=Si.getMaskFunction(M);for(let J=c-1;J>0;J-=2)for(J==6&&(J-=1);;){for(let V=0;V<2;V+=1)if(a[D][J-V]==null){let ee=!1;Z<C.length&&(ee=(C[Z]>>>H&1)==1),B(D,J-V)&&(ee=!ee),a[D][J-V]=ee,H-=1,H==-1&&(Z+=1,H=7)}if(D+=I,D<0||c<=D){D-=I,I=-I;break}}},T=function(C,M){let I=0,D=0,H=0;const Z=new Array(M.length),B=new Array(M.length);for(let F=0;F<M.length;F+=1){const $=M[F].dataCount,Q=M[F].totalCount-$;D=Math.max(D,$),H=Math.max(H,Q),Z[F]=new Array($);for(let de=0;de<Z[F].length;de+=1)Z[F][de]=255&C.getBuffer()[de+I];I+=$;const q=Si.getErrorCorrectPolynomial(Q),oe=Fu(Z[F],q.getLength()-1).mod(q);B[F]=new Array(q.getLength()-1);for(let de=0;de<B[F].length;de+=1){const he=de+oe.getLength()-B[F].length;B[F][de]=he>=0?oe.getAt(he):0}}let J=0;for(let F=0;F<M.length;F+=1)J+=M[F].totalCount;const V=new Array(J);let ee=0;for(let F=0;F<D;F+=1)for(let $=0;$<M.length;$+=1)F<Z[$].length&&(V[ee]=Z[$][F],ee+=1);for(let F=0;F<H;F+=1)for(let $=0;$<M.length;$+=1)F<B[$].length&&(V[ee]=B[$][F],ee+=1);return V},j=function(C,M,I){const D=AE.getRSBlocks(C,M),H=RE();for(let B=0;B<I.length;B+=1){const J=I[B];H.put(J.getMode(),4),H.put(J.getLength(),Si.getLengthInBits(J.getMode(),C)),J.write(H)}let Z=0;for(let B=0;B<D.length;B+=1)Z+=D[B].dataCount;if(H.getLengthInBits()>Z*8)throw"code length overflow. ("+H.getLengthInBits()+">"+Z*8+")";for(H.getLengthInBits()+4<=Z*8&&H.put(0,4);H.getLengthInBits()%8!=0;)H.putBit(!1);for(;!(H.getLengthInBits()>=Z*8||(H.put(236,8),H.getLengthInBits()>=Z*8));)H.put(17,8);return T(H,D)};h.addData=function(C,M){M=M||"Byte";let I=null;switch(M){case"Numeric":I=pZ(C);break;case"Alphanumeric":I=mZ(C);break;case"Byte":I=gZ(C);break;case"Kanji":I=kZ(C);break;default:throw"mode:"+M}f.push(I),u=null},h.isDark=function(C,M){if(C<0||c<=C||M<0||c<=M)throw C+","+M;return a[C][M]},h.getModuleCount=function(){return c},h.make=function(){if(o<1){let C=1;for(;C<40;C++){const M=AE.getRSBlocks(C,s),I=RE();for(let H=0;H<f.length;H++){const Z=f[H];I.put(Z.getMode(),4),I.put(Z.getLength(),Si.getLengthInBits(Z.getMode(),C)),Z.write(I)}let D=0;for(let H=0;H<M.length;H++)D+=M[H].dataCount;if(I.getLengthInBits()<=D*8)break}o=C}m(!1,y())},h.createTableTag=function(C,M){C=C||2,M=typeof M>"u"?C*4:M;let I="";I+='<table style="',I+=" border-width: 0px; border-style: none;",I+=" border-collapse: collapse;",I+=" padding: 0px; margin: "+M+"px;",I+='">',I+="<tbody>";for(let D=0;D<h.getModuleCount();D+=1){I+="<tr>";for(let H=0;H<h.getModuleCount();H+=1)I+='<td style="',I+=" border-width: 0px; border-style: none;",I+=" border-collapse: collapse;",I+=" padding: 0px; margin: 0px;",I+=" width: "+C+"px;",I+=" height: "+C+"px;",I+=" background-color: ",I+=h.isDark(D,H)?"#000000":"#ffffff",I+=";",I+='"/>';I+="</tr>"}return I+="</tbody>",I+="</table>",I},h.createSvgTag=function(C,M,I,D){let H={};typeof arguments[0]=="object"&&(H=arguments[0],C=H.cellSize,M=H.margin,I=H.alt,D=H.title),C=C||2,M=typeof M>"u"?C*4:M,I=typeof I=="string"?{text:I}:I||{},I.text=I.text||null,I.id=I.text?I.id||"qrcode-description":null,D=typeof D=="string"?{text:D}:D||{},D.text=D.text||null,D.id=D.text?D.id||"qrcode-title":null;const Z=h.getModuleCount()*C+M*2;let B,J,V,ee,F="",$;for($="l"+C+",0 0,"+C+" -"+C+",0 0,-"+C+"z ",F+='<svg version="1.1" xmlns="http://www.w3.org/2000/svg"',F+=H.scalable?"":' width="'+Z+'px" height="'+Z+'px"',F+=' viewBox="0 0 '+Z+" "+Z+'" ',F+=' preserveAspectRatio="xMinYMin meet"',F+=D.text||I.text?' role="img" aria-labelledby="'+A([D.id,I.id].join(" ").trim())+'"':"",F+=">",F+=D.text?'<title id="'+A(D.id)+'">'+A(D.text)+"</title>":"",F+=I.text?'<description id="'+A(I.id)+'">'+A(I.text)+"</description>":"",F+='<rect width="100%" height="100%" fill="white" cx="0" cy="0"/>',F+='<path d="',V=0;V<h.getModuleCount();V+=1)for(ee=V*C+M,B=0;B<h.getModuleCount();B+=1)h.isDark(V,B)&&(J=B*C+M,F+="M"+J+","+ee+$);return F+='" stroke="transparent" fill="black"/>',F+="</svg>",F},h.createDataURL=function(C,M){C=C||2,M=typeof M>"u"?C*4:M;const I=h.getModuleCount()*C+M*2,D=M,H=I-M;return bZ(I,I,function(Z,B){if(D<=Z&&Z<H&&D<=B&&B<H){const J=Math.floor((Z-D)/C),V=Math.floor((B-D)/C);return h.isDark(V,J)?0:1}else return 1})},h.createImgTag=function(C,M,I){C=C||2,M=typeof M>"u"?C*4:M;const D=h.getModuleCount()*C+M*2;let H="";return H+="<img",H+=' src="',H+=h.createDataURL(C,M),H+='"',H+=' width="',H+=D,H+='"',H+=' height="',H+=D,H+='"',I&&(H+=' alt="',H+=A(I),H+='"'),H+="/>",H};const A=function(C){let M="";for(let I=0;I<C.length;I+=1){const D=C.charAt(I);switch(D){case"<":M+="&lt;";break;case">":M+="&gt;";break;case"&":M+="&amp;";break;case'"':M+="&quot;";break;default:M+=D;break}}return M},R=function(C){C=typeof C>"u"?2:C;const I=h.getModuleCount()*1+C*2,D=C,H=I-C;let Z,B,J,V,ee;const F={"██":"█","█ ":"▀"," █":"▄"," ":" "},$={"██":"▀","█ ":"▀"," █":" "," ":" "};let Q="";for(Z=0;Z<I;Z+=2){for(J=Math.floor((Z-D)/1),V=Math.floor((Z+1-D)/1),B=0;B<I;B+=1)ee="█",D<=B&&B<H&&D<=Z&&Z<H&&h.isDark(J,Math.floor((B-D)/1))&&(ee=" "),D<=B&&B<H&&D<=Z+1&&Z+1<H&&h.isDark(V,Math.floor((B-D)/1))?ee+=" ":ee+="█",Q+=C<1&&Z+1>=H?$[ee]:F[ee];Q+=`
274
- `}return I%2&&C>0?Q.substring(0,Q.length-I-1)+Array(I+1).join("▀"):Q.substring(0,Q.length-1)};return h.createASCII=function(C,M){if(C=C||1,C<2)return R(M);C-=1,M=typeof M>"u"?C*2:M;const I=h.getModuleCount()*C+M*2,D=M,H=I-M;let Z,B,J,V;const ee=Array(C+1).join("██"),F=Array(C+1).join(" ");let $="",Q="";for(Z=0;Z<I;Z+=1){for(J=Math.floor((Z-D)/C),Q="",B=0;B<I;B+=1)V=1,D<=B&&B<H&&D<=Z&&Z<H&&h.isDark(J,Math.floor((B-D)/C))&&(V=0),Q+=V?ee:F;for(J=0;J<C;J+=1)$+=Q+`
275
- `}return $.substring(0,$.length-1)},h.renderTo2dContext=function(C,M){M=M||2;const I=h.getModuleCount();for(let D=0;D<I;D++)for(let H=0;H<I;H++)C.fillStyle=h.isDark(D,H)?"black":"white",C.fillRect(H*M,D*M,M,M)},h};uc.stringToBytes=function(e){const t=[];for(let n=0;n<e.length;n+=1){const r=e.charCodeAt(n);t.push(r&255)}return t};uc.createStringToBytes=function(e,t){const n=(function(){const o=yZ(e),s=function(){const u=o.read();if(u==-1)throw"eof";return u};let a=0;const c={};for(;;){const u=o.read();if(u==-1)break;const f=s(),h=s(),m=s(),g=String.fromCharCode(u<<8|f),y=h<<8|m;c[g]=y,a+=1}if(a!=t)throw a+" != "+t;return c})(),r=63;return function(o){const s=[];for(let a=0;a<o.length;a+=1){const c=o.charCodeAt(a);if(c<128)s.push(c);else{const u=n[o.charAt(a)];typeof u=="number"?(u&255)==u?s.push(u):(s.push(u>>>8),s.push(u&255)):s.push(r)}}return s}};const Wr={MODE_NUMBER:1,MODE_ALPHA_NUM:2,MODE_8BIT_BYTE:4,MODE_KANJI:8},uu={L:1,M:0,Q:3,H:2},Ei={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7},Si=(function(){const e=[[],[6,18],[6,22],[6,26],[6,30],[6,34],[6,22,38],[6,24,42],[6,26,46],[6,28,50],[6,30,54],[6,32,58],[6,34,62],[6,26,46,66],[6,26,48,70],[6,26,50,74],[6,30,54,78],[6,30,56,82],[6,30,58,86],[6,34,62,90],[6,28,50,72,94],[6,26,50,74,98],[6,30,54,78,102],[6,28,54,80,106],[6,32,58,84,110],[6,30,58,86,114],[6,34,62,90,118],[6,26,50,74,98,122],[6,30,54,78,102,126],[6,26,52,78,104,130],[6,30,56,82,108,134],[6,34,60,86,112,138],[6,30,58,86,114,142],[6,34,62,90,118,146],[6,30,54,78,102,126,150],[6,24,50,76,102,128,154],[6,28,54,80,106,132,158],[6,32,58,84,110,136,162],[6,26,54,82,110,138,166],[6,30,58,86,114,142,170]],t=1335,n=7973,r=21522,o={},s=function(a){let c=0;for(;a!=0;)c+=1,a>>>=1;return c};return o.getBCHTypeInfo=function(a){let c=a<<10;for(;s(c)-s(t)>=0;)c^=t<<s(c)-s(t);return(a<<10|c)^r},o.getBCHTypeNumber=function(a){let c=a<<12;for(;s(c)-s(n)>=0;)c^=n<<s(c)-s(n);return a<<12|c},o.getPatternPosition=function(a){return e[a-1]},o.getMaskFunction=function(a){switch(a){case Ei.PATTERN000:return function(c,u){return(c+u)%2==0};case Ei.PATTERN001:return function(c,u){return c%2==0};case Ei.PATTERN010:return function(c,u){return u%3==0};case Ei.PATTERN011:return function(c,u){return(c+u)%3==0};case Ei.PATTERN100:return function(c,u){return(Math.floor(c/2)+Math.floor(u/3))%2==0};case Ei.PATTERN101:return function(c,u){return c*u%2+c*u%3==0};case Ei.PATTERN110:return function(c,u){return(c*u%2+c*u%3)%2==0};case Ei.PATTERN111:return function(c,u){return(c*u%3+(c+u)%2)%2==0};default:throw"bad maskPattern:"+a}},o.getErrorCorrectPolynomial=function(a){let c=Fu([1],0);for(let u=0;u<a;u+=1)c=c.multiply(Fu([1,ji.gexp(u)],0));return c},o.getLengthInBits=function(a,c){if(1<=c&&c<10)switch(a){case Wr.MODE_NUMBER:return 10;case Wr.MODE_ALPHA_NUM:return 9;case Wr.MODE_8BIT_BYTE:return 8;case Wr.MODE_KANJI:return 8;default:throw"mode:"+a}else if(c<27)switch(a){case Wr.MODE_NUMBER:return 12;case Wr.MODE_ALPHA_NUM:return 11;case Wr.MODE_8BIT_BYTE:return 16;case Wr.MODE_KANJI:return 10;default:throw"mode:"+a}else if(c<41)switch(a){case Wr.MODE_NUMBER:return 14;case Wr.MODE_ALPHA_NUM:return 13;case Wr.MODE_8BIT_BYTE:return 16;case Wr.MODE_KANJI:return 12;default:throw"mode:"+a}else throw"type:"+c},o.getLostPoint=function(a){const c=a.getModuleCount();let u=0;for(let m=0;m<c;m+=1)for(let g=0;g<c;g+=1){let y=0;const w=a.isDark(m,g);for(let v=-1;v<=1;v+=1)if(!(m+v<0||c<=m+v))for(let _=-1;_<=1;_+=1)g+_<0||c<=g+_||v==0&&_==0||w==a.isDark(m+v,g+_)&&(y+=1);y>5&&(u+=3+y-5)}for(let m=0;m<c-1;m+=1)for(let g=0;g<c-1;g+=1){let y=0;a.isDark(m,g)&&(y+=1),a.isDark(m+1,g)&&(y+=1),a.isDark(m,g+1)&&(y+=1),a.isDark(m+1,g+1)&&(y+=1),(y==0||y==4)&&(u+=3)}for(let m=0;m<c;m+=1)for(let g=0;g<c-6;g+=1)a.isDark(m,g)&&!a.isDark(m,g+1)&&a.isDark(m,g+2)&&a.isDark(m,g+3)&&a.isDark(m,g+4)&&!a.isDark(m,g+5)&&a.isDark(m,g+6)&&(u+=40);for(let m=0;m<c;m+=1)for(let g=0;g<c-6;g+=1)a.isDark(g,m)&&!a.isDark(g+1,m)&&a.isDark(g+2,m)&&a.isDark(g+3,m)&&a.isDark(g+4,m)&&!a.isDark(g+5,m)&&a.isDark(g+6,m)&&(u+=40);let f=0;for(let m=0;m<c;m+=1)for(let g=0;g<c;g+=1)a.isDark(g,m)&&(f+=1);const h=Math.abs(100*f/c/c-50)/5;return u+=h*10,u},o})(),ji=(function(){const e=new Array(256),t=new Array(256);for(let r=0;r<8;r+=1)e[r]=1<<r;for(let r=8;r<256;r+=1)e[r]=e[r-4]^e[r-5]^e[r-6]^e[r-8];for(let r=0;r<255;r+=1)t[e[r]]=r;const n={};return n.glog=function(r){if(r<1)throw"glog("+r+")";return t[r]},n.gexp=function(r){for(;r<0;)r+=255;for(;r>=256;)r-=255;return e[r]},n})(),Fu=function(e,t){if(typeof e.length>"u")throw e.length+"/"+t;const n=(function(){let o=0;for(;o<e.length&&e[o]==0;)o+=1;const s=new Array(e.length-o+t);for(let a=0;a<e.length-o;a+=1)s[a]=e[a+o];return s})(),r={};return r.getAt=function(o){return n[o]},r.getLength=function(){return n.length},r.multiply=function(o){const s=new Array(r.getLength()+o.getLength()-1);for(let a=0;a<r.getLength();a+=1)for(let c=0;c<o.getLength();c+=1)s[a+c]^=ji.gexp(ji.glog(r.getAt(a))+ji.glog(o.getAt(c)));return Fu(s,0)},r.mod=function(o){if(r.getLength()-o.getLength()<0)return r;const s=ji.glog(r.getAt(0))-ji.glog(o.getAt(0)),a=new Array(r.getLength());for(let c=0;c<r.getLength();c+=1)a[c]=r.getAt(c);for(let c=0;c<o.getLength();c+=1)a[c]^=ji.gexp(ji.glog(o.getAt(c))+s);return Fu(a,0).mod(o)},r},AE=(function(){const e=[[1,26,19],[1,26,16],[1,26,13],[1,26,9],[1,44,34],[1,44,28],[1,44,22],[1,44,16],[1,70,55],[1,70,44],[2,35,17],[2,35,13],[1,100,80],[2,50,32],[2,50,24],[4,25,9],[1,134,108],[2,67,43],[2,33,15,2,34,16],[2,33,11,2,34,12],[2,86,68],[4,43,27],[4,43,19],[4,43,15],[2,98,78],[4,49,31],[2,32,14,4,33,15],[4,39,13,1,40,14],[2,121,97],[2,60,38,2,61,39],[4,40,18,2,41,19],[4,40,14,2,41,15],[2,146,116],[3,58,36,2,59,37],[4,36,16,4,37,17],[4,36,12,4,37,13],[2,86,68,2,87,69],[4,69,43,1,70,44],[6,43,19,2,44,20],[6,43,15,2,44,16],[4,101,81],[1,80,50,4,81,51],[4,50,22,4,51,23],[3,36,12,8,37,13],[2,116,92,2,117,93],[6,58,36,2,59,37],[4,46,20,6,47,21],[7,42,14,4,43,15],[4,133,107],[8,59,37,1,60,38],[8,44,20,4,45,21],[12,33,11,4,34,12],[3,145,115,1,146,116],[4,64,40,5,65,41],[11,36,16,5,37,17],[11,36,12,5,37,13],[5,109,87,1,110,88],[5,65,41,5,66,42],[5,54,24,7,55,25],[11,36,12,7,37,13],[5,122,98,1,123,99],[7,73,45,3,74,46],[15,43,19,2,44,20],[3,45,15,13,46,16],[1,135,107,5,136,108],[10,74,46,1,75,47],[1,50,22,15,51,23],[2,42,14,17,43,15],[5,150,120,1,151,121],[9,69,43,4,70,44],[17,50,22,1,51,23],[2,42,14,19,43,15],[3,141,113,4,142,114],[3,70,44,11,71,45],[17,47,21,4,48,22],[9,39,13,16,40,14],[3,135,107,5,136,108],[3,67,41,13,68,42],[15,54,24,5,55,25],[15,43,15,10,44,16],[4,144,116,4,145,117],[17,68,42],[17,50,22,6,51,23],[19,46,16,6,47,17],[2,139,111,7,140,112],[17,74,46],[7,54,24,16,55,25],[34,37,13],[4,151,121,5,152,122],[4,75,47,14,76,48],[11,54,24,14,55,25],[16,45,15,14,46,16],[6,147,117,4,148,118],[6,73,45,14,74,46],[11,54,24,16,55,25],[30,46,16,2,47,17],[8,132,106,4,133,107],[8,75,47,13,76,48],[7,54,24,22,55,25],[22,45,15,13,46,16],[10,142,114,2,143,115],[19,74,46,4,75,47],[28,50,22,6,51,23],[33,46,16,4,47,17],[8,152,122,4,153,123],[22,73,45,3,74,46],[8,53,23,26,54,24],[12,45,15,28,46,16],[3,147,117,10,148,118],[3,73,45,23,74,46],[4,54,24,31,55,25],[11,45,15,31,46,16],[7,146,116,7,147,117],[21,73,45,7,74,46],[1,53,23,37,54,24],[19,45,15,26,46,16],[5,145,115,10,146,116],[19,75,47,10,76,48],[15,54,24,25,55,25],[23,45,15,25,46,16],[13,145,115,3,146,116],[2,74,46,29,75,47],[42,54,24,1,55,25],[23,45,15,28,46,16],[17,145,115],[10,74,46,23,75,47],[10,54,24,35,55,25],[19,45,15,35,46,16],[17,145,115,1,146,116],[14,74,46,21,75,47],[29,54,24,19,55,25],[11,45,15,46,46,16],[13,145,115,6,146,116],[14,74,46,23,75,47],[44,54,24,7,55,25],[59,46,16,1,47,17],[12,151,121,7,152,122],[12,75,47,26,76,48],[39,54,24,14,55,25],[22,45,15,41,46,16],[6,151,121,14,152,122],[6,75,47,34,76,48],[46,54,24,10,55,25],[2,45,15,64,46,16],[17,152,122,4,153,123],[29,74,46,14,75,47],[49,54,24,10,55,25],[24,45,15,46,46,16],[4,152,122,18,153,123],[13,74,46,32,75,47],[48,54,24,14,55,25],[42,45,15,32,46,16],[20,147,117,4,148,118],[40,75,47,7,76,48],[43,54,24,22,55,25],[10,45,15,67,46,16],[19,148,118,6,149,119],[18,75,47,31,76,48],[34,54,24,34,55,25],[20,45,15,61,46,16]],t=function(o,s){const a={};return a.totalCount=o,a.dataCount=s,a},n={},r=function(o,s){switch(s){case uu.L:return e[(o-1)*4+0];case uu.M:return e[(o-1)*4+1];case uu.Q:return e[(o-1)*4+2];case uu.H:return e[(o-1)*4+3];default:return}};return n.getRSBlocks=function(o,s){const a=r(o,s);if(typeof a>"u")throw"bad rs block @ typeNumber:"+o+"/errorCorrectionLevel:"+s;const c=a.length/3,u=[];for(let f=0;f<c;f+=1){const h=a[f*3+0],m=a[f*3+1],g=a[f*3+2];for(let y=0;y<h;y+=1)u.push(t(m,g))}return u},n})(),RE=function(){const e=[];let t=0;const n={};return n.getBuffer=function(){return e},n.getAt=function(r){const o=Math.floor(r/8);return(e[o]>>>7-r%8&1)==1},n.put=function(r,o){for(let s=0;s<o;s+=1)n.putBit((r>>>o-s-1&1)==1)},n.getLengthInBits=function(){return t},n.putBit=function(r){const o=Math.floor(t/8);e.length<=o&&e.push(0),r&&(e[o]|=128>>>t%8),t+=1},n},pZ=function(e){const t=Wr.MODE_NUMBER,n=e,r={};r.getMode=function(){return t},r.getLength=function(a){return n.length},r.write=function(a){const c=n;let u=0;for(;u+2<c.length;)a.put(o(c.substring(u,u+3)),10),u+=3;u<c.length&&(c.length-u==1?a.put(o(c.substring(u,u+1)),4):c.length-u==2&&a.put(o(c.substring(u,u+2)),7))};const o=function(a){let c=0;for(let u=0;u<a.length;u+=1)c=c*10+s(a.charAt(u));return c},s=function(a){if("0"<=a&&a<="9")return a.charCodeAt(0)-48;throw"illegal char :"+a};return r},mZ=function(e){const t=Wr.MODE_ALPHA_NUM,n=e,r={};r.getMode=function(){return t},r.getLength=function(s){return n.length},r.write=function(s){const a=n;let c=0;for(;c+1<a.length;)s.put(o(a.charAt(c))*45+o(a.charAt(c+1)),11),c+=2;c<a.length&&s.put(o(a.charAt(c)),6)};const o=function(s){if("0"<=s&&s<="9")return s.charCodeAt(0)-48;if("A"<=s&&s<="Z")return s.charCodeAt(0)-65+10;switch(s){case" ":return 36;case"$":return 37;case"%":return 38;case"*":return 39;case"+":return 40;case"-":return 41;case".":return 42;case"/":return 43;case":":return 44;default:throw"illegal char :"+s}};return r},gZ=function(e){const t=Wr.MODE_8BIT_BYTE,n=uc.stringToBytes(e),r={};return r.getMode=function(){return t},r.getLength=function(o){return n.length},r.write=function(o){for(let s=0;s<n.length;s+=1)o.put(n[s],8)},r},kZ=function(e){const t=Wr.MODE_KANJI,n=uc.stringToBytes;(function(s,a){const c=n(s);if(c.length!=2||(c[0]<<8|c[1])!=a)throw"sjis not supported."})("友",38726);const r=n(e),o={};return o.getMode=function(){return t},o.getLength=function(s){return~~(r.length/2)},o.write=function(s){const a=r;let c=0;for(;c+1<a.length;){let u=(255&a[c])<<8|255&a[c+1];if(33088<=u&&u<=40956)u-=33088;else if(57408<=u&&u<=60351)u-=49472;else throw"illegal char at "+(c+1)+"/"+u;u=(u>>>8&255)*192+(u&255),s.put(u,13),c+=2}if(c<a.length)throw"illegal char at "+(c+1)},o},NC=function(){const e=[],t={};return t.writeByte=function(n){e.push(n&255)},t.writeShort=function(n){t.writeByte(n),t.writeByte(n>>>8)},t.writeBytes=function(n,r,o){r=r||0,o=o||n.length;for(let s=0;s<o;s+=1)t.writeByte(n[s+r])},t.writeString=function(n){for(let r=0;r<n.length;r+=1)t.writeByte(n.charCodeAt(r))},t.toByteArray=function(){return e},t.toString=function(){let n="";n+="[";for(let r=0;r<e.length;r+=1)r>0&&(n+=","),n+=e[r];return n+="]",n},t},wZ=function(){let e=0,t=0,n=0,r="";const o={},s=function(c){r+=String.fromCharCode(a(c&63))},a=function(c){if(c<0)throw"n:"+c;if(c<26)return 65+c;if(c<52)return 97+(c-26);if(c<62)return 48+(c-52);if(c==62)return 43;if(c==63)return 47;throw"n:"+c};return o.writeByte=function(c){for(e=e<<8|c&255,t+=8,n+=1;t>=6;)s(e>>>t-6),t-=6},o.flush=function(){if(t>0&&(s(e<<6-t),e=0,t=0),n%3!=0){const c=3-n%3;for(let u=0;u<c;u+=1)r+="="}},o.toString=function(){return r},o},yZ=function(e){const t=e;let n=0,r=0,o=0;const s={};s.read=function(){for(;o<8;){if(n>=t.length){if(o==0)return-1;throw"unexpected end of file./"+o}const u=t.charAt(n);if(n+=1,u=="=")return o=0,-1;if(u.match(/^\s$/))continue;r=r<<6|a(u.charCodeAt(0)),o+=6}const c=r>>>o-8&255;return o-=8,c};const a=function(c){if(65<=c&&c<=90)return c-65;if(97<=c&&c<=122)return c-97+26;if(48<=c&&c<=57)return c-48+52;if(c==43)return 62;if(c==47)return 63;throw"c:"+c};return s},vZ=function(e,t){const n=e,r=t,o=new Array(e*t),s={};s.setPixel=function(f,h,m){o[h*n+f]=m},s.write=function(f){f.writeString("GIF87a"),f.writeShort(n),f.writeShort(r),f.writeByte(128),f.writeByte(0),f.writeByte(0),f.writeByte(0),f.writeByte(0),f.writeByte(0),f.writeByte(255),f.writeByte(255),f.writeByte(255),f.writeString(","),f.writeShort(0),f.writeShort(0),f.writeShort(n),f.writeShort(r),f.writeByte(0);const h=2,m=c(h);f.writeByte(h);let g=0;for(;m.length-g>255;)f.writeByte(255),f.writeBytes(m,g,255),g+=255;f.writeByte(m.length-g),f.writeBytes(m,g,m.length-g),f.writeByte(0),f.writeString(";")};const a=function(f){const h=f;let m=0,g=0;const y={};return y.write=function(w,v){if(w>>>v)throw"length over";for(;m+v>=8;)h.writeByte(255&(w<<m|g)),v-=8-m,w>>>=8-m,g=0,m=0;g=w<<m|g,m=m+v},y.flush=function(){m>0&&h.writeByte(g)},y},c=function(f){const h=1<<f,m=(1<<f)+1;let g=f+1;const y=u();for(let N=0;N<h;N+=1)y.add(String.fromCharCode(N));y.add(String.fromCharCode(h)),y.add(String.fromCharCode(m));const w=NC(),v=a(w);v.write(h,g);let _=0,x=String.fromCharCode(o[_]);for(_+=1;_<o.length;){const N=String.fromCharCode(o[_]);_+=1,y.contains(x+N)?x=x+N:(v.write(y.indexOf(x),g),y.size()<4095&&(y.size()==1<<g&&(g+=1),y.add(x+N)),x=N)}return v.write(y.indexOf(x),g),v.write(m,g),v.flush(),w.toByteArray()},u=function(){const f={};let h=0;const m={};return m.add=function(g){if(m.contains(g))throw"dup key:"+g;f[g]=h,h+=1},m.size=function(){return h},m.indexOf=function(g){return f[g]},m.contains=function(g){return typeof f[g]<"u"},m};return s},bZ=function(e,t,n){const r=vZ(e,t);for(let c=0;c<t;c+=1)for(let u=0;u<e;u+=1)r.setPixel(u,c,n(u,c));const o=NC();r.write(o);const s=wZ(),a=o.toByteArray();for(let c=0;c<a.length;c+=1)s.writeByte(a[c]);return s.flush(),"data:image/gif;base64,"+s};uc.stringToBytes;function xZ(e){const t=uc(0,"M");t.addData(e,"Byte"),t.make();const n=t.getModuleCount();return Array.from({length:n},(r,o)=>Array.from({length:n},(s,a)=>t.isDark(o,a)))}const pr={title:"Your devices",scan:"Scan with your phone's camera to open this machine there, then let the phone in here.",turnOn:"Turn on, and your phone opens this machine at its tailnet name. Anyone on your tailnet you let in gets a shell here.",hereOff:"Tailscale on this machine is not connected, so nothing on your tailnet can reach it.",noneOnTailnet:"No other device is on your tailnet yet.",noPhone:"No phone has joined your tailnet. Install Tailscale on it and sign in to the same account.",knocking:"Let in the one whose words match the other screen.",missing:"A machine with no Toyon needs the phone button pressed on it, or `toyon remote --tailscale`.",listed:"listed",request:"request access",notAnswering:"not answering right now",offline:"offline",noToyon:"no Toyon",placeholder:"https://",notAnAddress:"That is not a Toyon address. It is https:// and the machine's name, as its screen shows it.",asking:e=>`Asking ${Nh(e)}.`,waiting:(e,t)=>`Toyon on ${Nh(e)} is asking whether to let ${t} in.`,added:e=>`Added ${e}.`,notKept:e=>`Let in, but not listed: ${e}`,add:"add"};function EZ(e,t){return e.reached?e.toyon&&!e.toyon.answering?pr.notAnswering:t?pr.listed:e.toyon?null:pr.noToyon:pr.offline}function OE(e){var t;return(t=e.toyon)!=null&&t.answering?0:e.toyon?1:e.reached?2:3}function Nh(e){try{return new URL(e).host}catch{return e}}function jC(e,t,n){const r=Nh(t);switch(e){case"refused":return`${r} did not let ${n} in.`;case"gone":return`${r} stopped waiting. Ask again, and answer there within five minutes.`;case"full":return`${r} has too many devices waiting already. Answer or turn those away there first.`;case"not-toyon":return`${r} is not a Toyon machine, or has no remote name set up.`;case"unreachable":return`${r} did not answer. Is Tailscale on here, and is Toyon running there?`}}function SZ(e,t,n){const r=(o,s)=>({word:o,note:s,offer:null});switch(t==null?void 0:t.state){case"not-installed":return r("no Tailscale","Tailscale is not installed on this machine, so nothing on your tailnet can reach it.");case"not-running":return r("Tailscale not running","Tailscale is not running on this machine, so nothing on your tailnet can reach it.");case"disconnected":return{word:null,note:"Tailscale on this machine is switched off, so nothing on your tailnet can reach it.",offer:"connect"};case"signed-out":return{word:null,note:"Tailscale on this machine is signed out, so nothing on your tailnet can reach it.",offer:"sign-in"};case"needs-approval":return r("not approved",t.line)}if(e===null)return r("not asked","Toyon could not ask Tailscale here just now.");if(e!==void 0&&!e.here)return r("not connected",pr.hereOff);if(n===null&&t!==null&&t.state!=="ready")switch(t.state){case"magicdns-off":return r("MagicDNS off",t.line);case"https-off":return r("HTTPS off",t.line);default:return r(null,t.line)}return r(null,null)}const _Z=e=>e==="phone"?"phone":"laptop";function ME({rows:e}){return d.jsx("div",{className:"tailnet-list",children:e.map(t=>d.jsxs("div",{className:"tailnet-row",children:[d.jsxs("div",{className:"tailnet-peer",children:[d.jsx("span",{className:Ke("dot tailnet-dot",t.reached===null?"tailnet-asking":t.reached?"tailnet-reached":"tailnet-unreached"),role:"img","aria-label":t.reached===null?"asking":t.reached?"connected":"not connected"}),d.jsx(kt,{name:t.icon,className:"tailnet-kind"}),d.jsx("span",{className:"tailnet-name",children:t.name}),t.host&&d.jsx("span",{className:"hint tailnet-host",children:t.host})]}),t.right!==void 0&&t.right!==null&&d.jsx("span",{className:Ke("tailnet-right",typeof t.right=="string"&&"hint"),children:t.right})]},t.key))})}const LE=(e,t)=>{var n;return{key:e.host||e.name,name:((n=e.toyon)==null?void 0:n.machine)??e.name,host:e.kind==="machine"&&e.host?e.host:void 0,reached:e.reached,icon:_Z(e.kind),right:t}},Lg=4;function NZ({text:e}){const{size:t,d:n}=E.useMemo(()=>{const r=xZ(e);let o="";return r.forEach((s,a)=>{s.forEach((c,u)=>{c&&(o+=`M${u+Lg} ${a+Lg}h1v1h-1z`)})}),{size:r.length+Lg*2,d:o}},[e]);return d.jsx("svg",{className:"devices-qr",viewBox:`0 0 ${t} ${t}`,shapeRendering:"crispEdges",role:"img","aria-label":"This machine's address",children:d.jsx("path",{d:n})})}const jZ=5e3;function TZ(e){return e.from===null?"A device that opened this address":`A Toyon page at ${Nh(e.from)}`}function $Z({knock:e,letIn:t,onAnswer:n}){return d.jsxs("div",{className:Ke("devices-knock",t!==null&&"devices-knock-done"),children:[d.jsxs("div",{className:"devices-knock-line",children:[d.jsx("span",{className:"knock-word",children:e.word}),d.jsx("span",{className:"devices-from",children:t===null?`${TZ(e)} wants in.`:t?"is in.":"was turned away."})]}),t===null&&d.jsxs("div",{className:"devices-actions",children:[d.jsx(Oe,{tone:"primary",onClick:()=>n(!0),children:"let in"}),d.jsx(Oe,{variant:"outline",onClick:()=>n(!1),children:"not now"})]})]})}function CZ({host:e,noPhone:t}){return d.jsxs("div",{className:"devices-address",children:[d.jsx("div",{className:"devices-frame",children:d.jsx(NZ,{text:FA(e)})}),d.jsxs("div",{className:"devices-about",children:[d.jsx("p",{className:"devices-line",children:pr.scan}),t&&d.jsx("p",{className:"devices-note",children:pr.noPhone})]})]})}function IZ(e){const t=e.devices.filter(r=>r.kind==="phone"),n=e.devices.map((r,o)=>({d:r,i:o})).filter(({d:r})=>r.kind==="machine").sort((r,o)=>OE(r.d)-OE(o.d)||r.i-o.i).map(({d:r})=>r);return[...t,...n]}function AZ(){const e=dt(),t=ys(),n=Lr(),r=L(ue=>ue.frame==="desk"),o=L(ue=>{var ie;return((ie=ue.remote)==null?void 0:ie.host)??null}),s=L(ue=>ue.machine),a=L(ue=>ue.tailscale),c=L(ue=>ue.knocks),[u,f]=E.useState(""),[h,m]=E.useState({kind:"idle"}),[g,y]=E.useState([]),w=()=>e({a:"close"}),v=h.kind==="asking"||h.kind==="waiting",_=m3(()=>r4(n),jZ,!v),x=E.useRef(new AbortController);E.useEffect(()=>()=>x.current.abort(),[]);const N=async ue=>{if(v)return;const ie=x.current.signal;m({kind:"asking",origin:ue});const ye=await y_(ue,ie,Le=>m({kind:"waiting",origin:ue,word:Le}));if(ie.aborted)return;if(typeof ye=="string"){m({kind:"failed",line:jC(ye,ue,"this page")});return}const Se=t.serving(),Ee=await l4(Aw(Se.origin,Se.token),ue,ye.token);m(Ee?{kind:"failed",line:pr.notKept(Ee)}:{kind:"added",name:t.displayName(ue)})},T=()=>{const ue=BA(u);ue?N(ue):m({kind:"failed",line:pr.notAnAddress})},j=()=>{x.current.abort(),x.current=new AbortController,m({kind:"idle"})},A=(ue,ie)=>{y(ye=>ye.some(Se=>Se.knock.id===ue.id)?ye:[...ye,{knock:ue,letIn:ie}]),c4(n,ue.id,ie)},R=c.filter(ue=>!g.some(ie=>ie.knock.id===ue.id)),C=[...g,...R.map(ue=>({knock:ue,letIn:null}))],[M,I]=E.useState(!1),[D,H]=E.useState(null),Z=async ue=>{I(!0),H(null);const ie=await(ue?o4(n):s4(n));I(!1),ie&&H(ie)},B=(_==null?void 0:_.here)===!0,J=SZ(_,a,o),V=o!==null,ee=r&&(B||_===void 0)?d.jsx(Oe,{variant:"outline",size:"sm",on:V,"aria-pressed":V,busy:M,disabled:!V&&(a==null?void 0:a.state)!=="ready",onClick:()=>void Z(!V),...Lt(V?"Take this machine's name off your tailnet":"Give this machine a name on your tailnet"),children:V?"on":"off"}):null,[F,$]=E.useState(!1),[Q,q]=E.useState(null),W=ue=>{window.open(ue,"_blank","noopener")===null?q(ue):q(null)},oe=async ue=>{if($(!0),H(null),ue==="connect"){const ie=await i4(n);ie&&H(ie)}else{const ie=await a4(n);"url"in ie?W(ie.url):H(ie.why)}$(!1)},de=r&&J.offer!==null?Q!==null?d.jsx(Oe,{variant:"outline",size:"sm",onClick:()=>W(Q),children:"open the sign-in page"}):d.jsx(Oe,{variant:"outline",size:"sm",busy:F,onClick:()=>void oe(J.offer??"connect"),...J.note?Lt(J.note):{},children:J.offer==="connect"?"connect":"sign in"}):null,he=J.word===null&&ee===null&&de===null?"this machine":d.jsxs(d.Fragment,{children:[J.word&&d.jsx("span",{className:"hint",children:J.word}),ee??de]}),Ne=[{key:"self",name:s??"This machine",host:o??void 0,reached:_===void 0?null:B,icon:"laptop",right:he}],Me=_?IZ(_).map(ue=>{if(ue.kind==="phone"||ue.host==="")return LE(ue,ue.reached?void 0:"not answering");const ie=`https://${ue.host}`,ye=EZ(ue,t.get(ie)!==null);return LE(ue,ye??d.jsx(Oe,{variant:"outline",size:"sm",disabled:v,onClick:()=>void N(ie),children:pr.request}))}):[],Be=r&&o!==null&&_!==null&&(_===void 0||_.here),K=_==null?void 0:_.devices.some(ue=>ue.kind==="machine"&&ue.host!==""&&ue.reached&&ue.toyon===null),te=Be&&_!==void 0&&!_.devices.some(ue=>ue.kind==="phone"),pe=(()=>{switch(h.kind){case"asking":return pr.asking(h.origin);case"waiting":return pr.waiting(h.origin,h.word);case"added":return pr.added(h.name);case"failed":return h.line;case"idle":return null}})();return d.jsxs(Mu,{boxClass:"devices-card",onClose:w,children:[d.jsx("div",{className:"devices-title",children:pr.title}),d.jsx(ME,{rows:Ne}),J.note&&J.offer===null&&d.jsx("p",{className:"devices-note",children:J.note}),D&&d.jsx("p",{className:"devices-note",children:D}),r&&!V&&(a==null?void 0:a.state)==="ready"&&d.jsx("p",{className:"devices-note",children:pr.turnOn}),Be&&o!==null&&d.jsx(CZ,{host:o,noPhone:te}),h.kind==="waiting"&&d.jsx("div",{className:"knock-word devices-word",children:h.word}),pe&&d.jsx("p",{className:Ke("devices-line",h.kind==="failed"&&"devices-failed"),children:pe}),_!==void 0&&d.jsxs(d.Fragment,{children:[Me.length>0&&d.jsx("div",{className:"devices-others",children:d.jsx(ME,{rows:Me})}),(_==null?void 0:_.devices.length)===0&&d.jsx("p",{className:"devices-note",children:pr.noneOnTailnet}),K&&d.jsx("p",{className:"devices-note",children:pr.missing})]}),!v&&d.jsxs("form",{className:"devices-form",onSubmit:ue=>{ue.preventDefault(),T()},children:[d.jsx(Bo,{size:"md",font:"ui",value:u,placeholder:pr.placeholder,"aria-label":"Address of the other machine",onChange:ue=>f(ue.target.value),className:"devices-field"}),d.jsx(Oe,{type:"submit",variant:"outline",disabled:!u.trim(),children:pr.add})]}),v&&d.jsx("div",{className:"devices-actions",children:d.jsx(Oe,{tone:"quiet",onClick:j,children:"cancel"})}),R.length>0&&d.jsx("p",{className:"devices-line devices-centred",children:pr.knocking}),C.map(ue=>d.jsx($Z,{knock:ue.knock,letIn:ue.letIn,onAnswer:ie=>A(ue.knock,ie)},ue.knock.id))]})}function RZ({worktreeId:e,hits:t}){const n=dt(),r=Qe(),o=L(c=>c.layout.changes),s=L(c=>{var f;const u=(f=Kt(c,e))==null?void 0:f.worktree;return u?u.path:null}),a=E.useCallback((c,u)=>{const f=u.trim().toLowerCase();return f?c.filter(h=>`${h.path}:${h.line} ${h.text}`.toLowerCase().includes(f)):c},[]);return d.jsx(qr,{items:t,filter:a,keyOf:c=>`${c.path}:${c.line}`,rowClass:()=>"search-hit",rowTitle:c=>`${c.path}:${c.line}`,onPick:c=>{Pn({dispatch:n},{worktreeId:e,path:c.path,view:"file",line:{n:c.line}}),o||n({a:"toggle-changes"}),n({a:"close"})},onBack:()=>n({a:"close"}),rowMenu:c=>s?Ls({id:e,dir:s},c.path,{},{sock:r,dispatch:n}):[],placeholder:"lines that could write this element",row:c=>d.jsxs(d.Fragment,{children:[d.jsxs("span",{className:"search-loc",children:[c.path,":",c.line]}),d.jsx("span",{className:"search-text",children:c.text})]})})}function OZ({project:e}){const t=dt(),n=Qe(),r=L(f=>f.paths),o=L(f=>f.home),s=E.useCallback(f=>{Ru(f)&&(n==null||n.send({t:"browse-path",path:f}))},[n]),a=E.useCallback((f,h)=>N8({query:h,entries:r.entries,target:r.target,answered:r.query,home:o}),[r,o]),c=Eu(e.name)?null:e.name.trim(),u=f=>`${f.replace(/\/+$/,"")}/`;return d.jsx(qr,{initialQuery:u(e.parent),lead:d.jsx("span",{className:"picker-chip",children:c??"new project"}),items:[],filter:a,keyOf:f=>f.kind==="dir"?`d:${f.entry.path}`:`${f.kind}:${f.path}`,rowClass:()=>"picker-row folder-row",onQuery:s,completionOf:f=>f.kind==="dir"?u(f.entry.path):null,narrowTo:f=>f.kind==="dir"?u(f.entry.path):f.kind==="up"?u(f.path):null,onPick:f=>{f.kind==="here"&&(t({a:"new-project-set",v:{mode:e.mode==="init"?"create":e.mode,parent:f.path}}),t({a:"close"}))},onBack:()=>t({a:"close"}),placeholder:"type a folder path",keys:f=>({complete:"completes the path",pick:(f==null?void 0:f.kind)==="here"?"chooses it":(f==null?void 0:f.kind)==="up"?"goes up":"opens it",back:"goes back"}),empty:"no such folder",row:f=>f.kind==="here"?d.jsx(An,{label:`put ${c??"it"} in ${Ak(f.path,o)}`,hint:d.jsx("bdi",{children:c?fT(f.path,c):f.path})}):f.kind==="up"?d.jsx(An,{label:`up to ${Ak(f.path,o)}`,hint:d.jsx("bdi",{children:f.path})}):d.jsx(An,{label:f.entry.name})})}function MZ({worktreeId:e}){const t=dt(),n=Qe(),r=L(g=>g.clientId),o=L(g=>Kt(g,e)),s=L(g=>g.repos),c=It(e,"draft").trim(),u=o==null?void 0:o.worktree.repoId,f=E.useMemo(()=>[...s.filter(g=>g.id===u),...s.filter(g=>g.id!==u)],[s,u]),h=()=>t({a:"close"}),m=g=>{if(!o)return h();n==null||n.send({t:"handoff-ask",worktreeId:e,repoId:g.id,...c?{text:c}:{}}),c&&(n==null||n.send({t:"set-draft",boxId:e,text:"",clientId:r}),t({a:"set-draft",id:e,text:""})),h()};return d.jsx(qr,{lead:d.jsx("span",{className:"picker-chip",children:(o==null?void 0:o.worktree.title)??"worktree"}),items:f,filter:(g,y)=>g.filter(w=>w.id===u&&rs(y,"here")||rs(y,w.name,w.path)),keyOf:g=>g.id,row:g=>d.jsx(An,{label:g.id===u?"a new worktree here":g.name,hint:g.path}),onPick:m,onBack:()=>t({a:"close",back:!0}),placeholder:"continue where?",empty:"no project is open",footer:c?()=>d.jsxs("div",{className:"empty",children:["with your message: ",c.split(`
276
- `)[0]]}):void 0})}const LZ={use:"an agent working, a question waiting, a phone connected",always:"whenever Toyon runs, on battery too",off:"the Mac sleeps when it would anyway"};function PZ(){const e=dt(),t=Qe(),n=L(r=>r.keepAwake);return d.jsx(qr,{items:[...lA],filter:(r,o)=>r.filter(s=>rs(o,mh[s])),rowClass:()=>"picker-row",keyOf:r=>r,initialIndex:r=>Math.max(0,n?r.indexOf(n):0),onPick:r=>{t==null||t.send({t:"set-keep-awake",mode:r}),e({a:"close"})},onBack:()=>e({a:"close",back:!0}),placeholder:"keep awake",row:r=>d.jsx(An,{label:mh[r],current:r===n,hint:LZ[r]})})}function DZ(e,t){if(t.incompatible)return`update Toyon on ${e}`;if(t.suspended)return"sleeping";if(!t.connected)return t.connectFailure?"not answering":"connecting";const n=$k(t.rows,null);return n?`${n.n} ${n.tier==="waiting"?"waiting":"unread"}`:"all quiet"}function nw(e){try{return UA(new URL(e).hostname)}catch{return!1}}function zZ(e){const t=new Set,n=e.build({...e.serving,serving:!0}),r=[];let o=n,s=[n];const a=()=>{s=[n,...r];for(const w of t)w()},c=new Map,u=w=>{var _;if(w.serving)return;(((_=w.store.getState().remote)==null?void 0:_.front)==="edge"||nw(w.origin))&&w!==o?w.sock.suspend():w.sock.resume()},f=w=>{var _;let v=(_=w.store.getState().remote)==null?void 0:_.front;c.set(w.origin,w.store.subscribe(()=>{var N;const x=(N=w.store.getState().remote)==null?void 0:N.front;x!==v&&(v=x,u(w))}))},h=()=>s,m={list:h,active:()=>o,serving:()=>n,get:w=>h().find(v=>v.origin===w)??null,displayName(w){const v=h().find(x=>x.origin===w);return v?h().filter(x=>x.name===v.name).length>1?`${v.name} (${new URL(v.origin).host})`:v.name:w},activate(w){const v=h().find(x=>x.origin===w);if(!v||v===o)return;const _=o;o=v,u(_),u(v),a()},add(w){var x;const v=r.find(N=>N.origin===w.origin);if(w.origin===n.origin)return n;if(v){if(v.token===w.token)return v;(x=c.get(v.origin))==null||x(),v.dispose(),r.splice(r.indexOf(v),1),o===v&&(o=n)}const _=e.build({...w,serving:!1});return r.push(_),f(_),nw(_.origin)&&_.sock.suspend(),a(),_},remove(w){var _;const v=r.find(x=>x.origin===w);v&&((_=c.get(w))==null||_(),c.delete(w),v.dispose(),v.storage.clear(),v.forget(),r.splice(r.indexOf(v),1),o===v&&(o=n),a())},broadcast(w){for(const v of h())v.store.dispatch(w)},subscribe(w){return t.add(w),()=>t.delete(w)}},g=w=>{for(const v of w)m.add(v);for(const v of[...r])w.some(_=>_.origin===v.origin)||m.remove(v.origin)};let y=n.store.getState().handed;return n.store.subscribe(()=>{const w=n.store.getState().handed;w!==y&&(y=w,g(y))}),g(y),m}function lv({form:e,anchored:t}){var F;const n=dt(),r=Qe(),o=ys(),s=Bs(),a=o.displayName(s.origin),c=L($=>$.repos),u=L($=>$.newProject?null:$.activeRepoId),f=L($=>$.rows),h=L($=>$.paths),m=L($=>$.home),g=L($=>$.pending),y=L($=>$.folderDialog),w=e==="url",v=E.useRef(""),_=E.useMemo(()=>ib(c,f),[c,f]),x=hN(),N=pN(),T=E.useMemo(()=>x.map($=>{var Q;return{...$,repos:ib($.repos,((Q=N.find(q=>q.origin===$.origin))==null?void 0:Q.rows)??[])}}),[x,N]),j=E.useCallback($=>{v.current=$,Ru($)&&(r==null||r.send({t:"browse-path",path:$}))},[r]),A=E.useCallback(($,Q)=>_8({query:Q,repos:_,pending:g,entries:[...h.entries].sort((q,W)=>Number(W.isRepo)-Number(q.isRepo)),target:h.target,answered:h.query,home:m,others:T,current:u,urlOnly:w}),[_,h,g,m,T,u,w]),R=()=>n({a:"close"}),C=()=>n({a:"close",back:!0}),M={sock:r,dispatch:n},I=$=>Au(M,{t:"register-repo",path:$}),D=($,Q)=>Au(M,{t:"create-repo",mode:"create",parent:$,name:Q}),H=($,Q,q)=>n({a:"new-project",v:ep({mode:$,name:Q,parent:S8(c,u,m),...q})}),Z=()=>n({a:"open",overlay:{kind:"projects",form:"disk"}}),B=()=>n({a:"open",overlay:{kind:"projects",form:"url"}}),J=()=>{const $=v.current.trim(),Q=$.lastIndexOf("/"),q=Ru($)&&Q>=0?$.slice(0,Q)||"/":"~";r==null||r.send({t:"choose-file",start:q}),R()},V=()=>n({a:"open",overlay:{kind:"devices"}}),ee=($,Q)=>{const q=o.get($);q&&(q.store.dispatch({a:"activate-repo",id:Q}),o.activate($))};return d.jsx(qr,{anchored:e==="pill"&&(t??!0),initialQuery:e==="disk"?"~/":"",lead:e==="disk"||w?void 0:d.jsx("span",{className:"picker-chip",children:((F=c.find($=>$.id===u))==null?void 0:F.name)??"no project"}),trailing:w?void 0:e==="disk"?y?d.jsx(At,{icon:"file",label:"Open a file from Finder",onClick:J}):void 0:d.jsx(At,{icon:"folder",label:"Find a project or file on disk",onClick:Z}),items:[],filter:A,initialIndex:$=>$.findIndex(Q=>Q.kind==="repo"&&!Q.machine&&Q.repo.id===u),groupOf:$=>$.kind==="machine"||$.kind==="repo"&&$.machine?$.machine.origin:s.origin,groupHead:$=>$===s.origin?a:d.jsx(FZ,{origin:$}),keyOf:$=>$.kind==="repo"?$.machine?`${$.machine.origin}:${$.repo.id}`:$.repo.id:$.kind==="dir"?`d:${$.entry.path}`:$.kind==="file"?`f:${$.entry.path}`:$.kind==="open"?`open:${$.path}`:$.kind==="init"?`init:${$.path}`:$.kind==="pending"?`p:${$.pending.id}`:$.kind==="clone"?`clone:${$.url}`:$.kind==="new"?"new-project":$.kind==="disk"?"open-folder":$.kind==="from-url"?"from-url":$.kind==="add-machine"?"add-machine":$.kind==="machine"?`machine:${$.machine.origin}`:`new:${$.parent??""}/${$.name}`,rowClass:$=>Ke("picker-row",($.kind==="new"||$.kind==="disk"||$.kind==="from-url"||$.kind==="add-machine")&&"new-project-row"),onQuery:j,completionOf:$=>$.kind==="dir"?$.entry.isRepo?$.entry.path:`${$.entry.path}/`:$.kind==="file"?$.entry.path:null,narrowTo:$=>$.kind==="dir"&&!$.entry.isRepo?`${$.entry.path}/`:null,onPick:$=>{if($.kind==="clone")return H("clone",$.name,{url:$.url,...$.branch?{branch:$.branch}:{}});if($.kind==="create"&&!$.parent)return H("create",$.name);if($.kind==="new")return H("create","");if($.kind==="disk")return Z();if($.kind==="from-url")return B();if($.kind==="add-machine")return V();$.kind==="machine"?o.activate($.machine.origin):$.kind==="pending"?n({a:"watch-import",id:$.pending.id}):$.kind==="repo"&&$.machine?ee($.machine.origin,$.repo.id):$.kind==="repo"?n({a:"activate-repo",id:$.repo.id}):$.kind==="open"?I($.path):$.kind==="file"?$8(r,$.entry.path):$.kind==="init"?aT(M,$.path):$.kind==="dir"?I($.entry.path):$.parent&&D($.parent,$.name),R()},onBack:C,rowMenu:$=>$.kind==="machine"||$.kind==="repo"&&$.machine?Ck(o,$.machine.origin):$.kind==="repo"?gp($.repo,u,M,f):$.kind==="pending"?v8($.pending,M):[],placeholder:w?"paste a git URL, like https://github.com/you/app":c.length>1?"switch project, or type a name or path":"type a name or a path to start",keys:$=>({complete:"completes the path",pick:($==null?void 0:$.kind)==="dir"&&!$.entry.isRepo?"descends":($==null?void 0:$.kind)==="pending"?"watches it":($==null?void 0:$.kind)==="create"?$.parent?"creates it":"names it":($==null?void 0:$.kind)==="clone"?"clones it":($==null?void 0:$.kind)==="new"?"starts one":($==null?void 0:$.kind)==="disk"?"browses":($==null?void 0:$.kind)==="from-url"?"asks for one":($==null?void 0:$.kind)==="add-machine"?"adds one":($==null?void 0:$.kind)==="machine"||($==null?void 0:$.kind)==="repo"&&$.machine?"switches machine":"opens",back:"closes"}),empty:w?$=>$.trim()?"not a git URL yet; paste the address of a repository, or of a page on GitHub, GitLab or Codeberg":"the address of a repository, or of a branch, file or pull request on GitHub, GitLab or Codeberg":"nothing here; keep typing a path (~/… or /…)",row:$=>$.kind==="repo"?d.jsx(An,{label:$.repo.name,current:!$.machine&&$.repo.id===u}):$.kind==="pending"?d.jsx(An,{label:$.pending.name,hint:$.pending.error?"import failed":d.jsx("span",{className:"live-text",children:"importing"})}):$.kind==="dir"?d.jsx(An,{label:$.entry.name,hint:$.entry.isRepo?"git repo":void 0}):$.kind==="file"?d.jsx(An,{label:$.entry.name,hint:"file"}):$.kind==="open"?d.jsx(An,{label:`open ${$.path}`,hint:"register with this daemon"}):$.kind==="init"?d.jsx(An,{label:`open ${$.path}`,hint:"no git yet; starts it here with the files in it"}):$.kind==="clone"?d.jsx(An,{label:`clone ${$.name}`,hint:$.branch?`${PE($.url)} · ${$.branch}`:PE($.url)}):$.kind==="new"?d.jsx(An,{label:d.jsxs(d.Fragment,{children:[d.jsx(kt,{name:"plus",className:"icon-inline"}),"new project"]})}):$.kind==="disk"?d.jsx(An,{label:d.jsxs(d.Fragment,{children:[d.jsx(kt,{name:"folder",className:"icon-inline"}),"open folder or file"]})}):$.kind==="from-url"?d.jsx(An,{label:d.jsxs(d.Fragment,{children:[d.jsx(kt,{name:"globe",className:"icon-inline"}),"clone from a URL"]})}):$.kind==="add-machine"?d.jsx(An,{label:d.jsxs(d.Fragment,{children:[d.jsx(kt,{name:"devices",className:"icon-inline"}),"add a machine"]})}):$.kind==="machine"?d.jsx(An,{label:`switch to ${o.displayName($.machine.origin)}`}):d.jsx(An,{label:`create ${$.name}`,hint:$.parent?`in ${$.parent}`:"new project"})})}function FZ({origin:e}){const t=ys(),n=t.get(e)??t.active(),r=Xc(n,m=>m.rows),o=Xc(n,m=>m.connected),s=Xc(n,m=>m.connectFailure),a=Xc(n,m=>m.incompatible),c=Xc(n,m=>{var g;return(g=m.remote)==null?void 0:g.front}),u=t.displayName(e),f=DZ(u,{rows:r.filter(Nn),connected:o,connectFailure:s,incompatible:a,suspended:(c==="edge"||nw(e))&&!o}),h=/^\d+ /.test(f);return d.jsxs(d.Fragment,{children:[u,d.jsx("span",{className:Ke("picker-group-tail",h&&"picker-group-owed"),children:f})]})}function PE(e){const t=e.match(/^[a-z+]+:\/\/(?:[^@/]*@)?([^/:]+)/i)??e.match(/^[^@]+@([^:]+):/);return(t==null?void 0:t[1])??"git remote"}function BZ(e){const t=[];if(e.pr){const r=e.pr.url;t.push({id:"open-pr",label:"open on GitHub",onClick:()=>window.open(r,"_blank")}),t.push({id:"copy-link",label:"copy link",onClick:()=>tn(r)})}const n=[{id:"copy-ref",label:e.kind==="pr"?"copy PR number":"copy branch name",onClick:()=>tn(e.ref)}];return Wn([t,n])}const UZ=[],HZ={branch:"branch",remote:"globe",pr:"pr"},DE={pr:0,branch:1,remote:2},WZ={pr:"pull requests",branch:"branches",remote:"remote branches"};function KZ({repoId:e}){const t=dt(),n=Qe(),r=L(m=>m.clientId),o=L(m=>m.refs[e]),s=L(m=>m.rows),a=m=>{var g;return((g=s.find(y=>y.id===m))==null?void 0:g.name)??"a worktree"},c=E.useCallback(m=>[...m].sort((g,y)=>DE[g.kind]-DE[y.kind]),[]),u=E.useCallback(m=>n==null?void 0:n.send({t:"search-refs",repoId:e,query:m.trim()}),[n,e]),f=m=>!o||o.query!==m.trim(),h=m=>m.openIn?`open in ${a(m.openIn)}`:m.merged?"merged":m.pr?`${m.pr.author}${m.pr.draft?" · draft":""}${m.pr.fork?" · fork":""}`:m.subject??"";return d.jsx(qr,{items:(o==null?void 0:o.refs)??UZ,filter:c,onQuery:u,keyOf:m=>`${m.kind}:${m.ref}`,rowClass:()=>"picker-row ref-row",onPick:m=>{m.openIn?t({a:"activate",id:m.openIn}):n==null||n.send({t:"open-ref",repoId:e,kind:m.kind,ref:m.ref,clientId:r,...m.pr?{pr:{title:m.pr.title,url:m.pr.url}}:{}}),t({a:"close"})},onBack:()=>t({a:"close"}),rowMenu:BZ,groupOf:m=>m.kind,groupHead:(m,g)=>`${WZ[m]} · ${g}`,placeholder:"open a branch or PR…",keys:m=>({nav:"moves",pick:m!=null&&m.openIn?"switches to it":"opens it as a worktree",back:"closes"}),empty:m=>f(m)?d.jsx("span",{className:"live-text",children:"looking"}):m.trim()?"no branch or PR matches":"no unmerged branches or open PRs",row:m=>d.jsx(An,{label:d.jsxs(d.Fragment,{children:[d.jsx(kt,{name:HZ[m.kind],className:"icon-inline"}),d.jsx("span",{className:"ref-name",children:m.name})]}),hint:h(m)})})}const zE=[],Pg=2;function qZ(e,t){const n=t.trim().toLowerCase(),r=e.toLowerCase();if(!n||r.length!==e.length)return null;const o=[];for(let s=r.indexOf(n);s!==-1;s=r.indexOf(n,s+n.length))for(let a=0;a<n.length;a++)o.push(s+a);return o.length?o:null}function ZZ({worktreeId:e}){const t=dt(),n=Qe(),r=SN(e).search,o=L(f=>f.layout.changes),s=L(f=>{var m;const h=(m=Kt(f,e))==null?void 0:m.worktree;return h?h.path:null}),a=E.useCallback((f,h)=>h.trim().length>=Pg?f:zE,[]),c=E.useCallback(f=>{const h=f.trim();h.length>=Pg&&(n==null||n.send({t:"search",worktreeId:e,query:h}))},[n,e]),u=f=>!r||r.query.trim()!==f.trim();return E.useEffect(()=>()=>n==null?void 0:n.send({t:"search-stop"}),[n]),d.jsx(qr,{items:(r==null?void 0:r.hits)??zE,filter:a,onQuery:c,keyOf:f=>`${f.path}:${f.line}`,rowClass:()=>"search-hit",rowTitle:f=>`${f.path}:${f.line}`,onPick:f=>{Pn({dispatch:t},{worktreeId:e,path:f.path,view:"file",line:{n:f.line}}),o||t({a:"toggle-changes"}),t({a:"close"})},onBack:()=>t({a:"close"}),rowMenu:f=>s?Ls({id:e,dir:s},f.path,{},{sock:n,dispatch:t}):[],placeholder:"search in files…",empty:f=>f.trim().length<Pg?"type at least two characters":u(f)?d.jsx("span",{className:"live-text",children:"searching"}):"no matches",footer:(f,h)=>r!=null&&r.truncated&&!u(f)&&h.length>0?d.jsx("div",{className:"empty",children:"not every match is shown; narrow the search"}):null,row:(f,h,m)=>d.jsxs(d.Fragment,{children:[d.jsxs("span",{className:"search-loc",children:[f.path,":",f.line]}),d.jsx("span",{className:"search-text",children:oc(f.text,qZ(f.text,m),0)})]})})}const FE=e=>e.source==="file"?"~/.toyon/themes":e.source==="vscode"?"VS Code":"";function GZ({slot:e}){const t=dt(),n=Qe(),r=L(N=>N.themePrefs),o=L(N=>N.themes),s=Qw(),a=Cw(r,s),c=r[e==="theme"?a:e],u=()=>t({a:"close"}),f=()=>t({a:"close",back:!0}),h=N=>t({a:"preview-theme",theme:N}),[m,g]=E.useState(null),[y,w]=E.useState(null),v=(N,T)=>N[T??a]??N.dark??N.light??null,_=E.useMemo(()=>PD(o),[o]),x=E.useMemo(()=>o.filter(N=>N.kind===e),[o,e]);return at([m,y],()=>{e==="theme"&&h(m?v(m,y):null)}),e!=="theme"?d.jsx(qr,{items:x,filter:(N,T)=>N.filter(j=>rs(T,j.name,j.id)),rowClass:()=>"picker-row",keyOf:N=>N.id,initialIndex:N=>N.findIndex(T=>T.id===c),onActive:h,onPick:N=>{n==null||n.send({t:"set-theme",prefs:{...r,[e]:N.id}}),u()},onBack:f,placeholder:`${e} slot override`,keys:{nav:"preview",pick:"keeps",back:"reverts"},empty:"no matching theme",row:N=>d.jsx(An,{label:N.name,current:N.id===c,hint:FE(N)})}):d.jsx(qr,{items:_,filter:(N,T)=>N.filter(j=>{var A,R;return rs(T,j.name,(A=j.dark)==null?void 0:A.name,(R=j.light)==null?void 0:R.name)}),rowClass:()=>"picker-row",keyOf:N=>{var T,j;return N.name+(((T=N.dark)==null?void 0:T.id)??((j=N.light)==null?void 0:j.id))},initialIndex:N=>N.findIndex(T=>{var j,A;return((j=T.dark)==null?void 0:j.id)===c||((A=T.light)==null?void 0:A.id)===c}),onActive:g,onSide:N=>{var T;N.dark&&N.light&&w((((T=v(N,y))==null?void 0:T.kind)??a)==="dark"?"light":"dark")},onPick:N=>{n==null||n.send({t:"set-theme",prefs:DD(r,N)}),u()},onBack:f,placeholder:"theme",keys:{nav:"preview",side:"dark/light",pick:"keeps",back:"reverts"},empty:"no matching theme",row:(N,T)=>{var C,M;const j=v(N,T?y:null),A=FE(N.dark??N.light),R=((C=N.dark)==null?void 0:C.id)===c||((M=N.light)==null?void 0:M.id)===c;return d.jsx(An,{label:N.name,current:R,hint:d.jsxs("span",{className:"theme-kinds",children:[A&&d.jsx("span",{children:A}),d.jsx("span",{className:"kind","data-state":gr({current:T&&(j==null?void 0:j.kind)==="dark"}),children:N.dark?"dark":""}),d.jsx("span",{className:"kind","data-state":gr({current:T&&(j==null?void 0:j.kind)==="light"}),children:N.light?"light":""})]})})}})}function TC(){const e=S3(),t=L(s=>s.frame==="phone"),n=ac(),r=L(s=>s.activeRepoId),o=L(s=>s.newProject);return d.jsxs(d.Fragment,{children:[(e==null?void 0:e.kind)==="quick-open"&&n&&d.jsx(vK,{worktreeId:n}),(e==null?void 0:e.kind)==="search"&&n&&d.jsx(ZZ,{worktreeId:n}),(e==null?void 0:e.kind)==="element-sources"&&d.jsx(RZ,{worktreeId:e.worktreeId,hits:e.hits}),(e==null?void 0:e.kind)==="refs"&&r&&d.jsx(KZ,{repoId:r}),(e==null?void 0:e.kind)==="chats"&&r&&d.jsx(hZ,{repoId:r,scope:e.names?"names":"all"}),(e==null?void 0:e.kind)==="keys"&&d.jsx(Qq,{}),(e==null?void 0:e.kind)==="devices"&&d.jsx(AZ,{}),(e==null?void 0:e.kind)==="theme"&&d.jsx(GZ,{slot:e.slot}),(e==null?void 0:e.kind)==="appearance"&&d.jsx(aZ,{}),(e==null?void 0:e.kind)==="keep-awake"&&d.jsx(PZ,{}),(e==null?void 0:e.kind)==="agent"&&d.jsx(oZ,{}),(e==null?void 0:e.kind)==="agent-page"&&d.jsx(nZ,{agentId:e.agent}),(e==null?void 0:e.kind)==="handoff"&&d.jsx(MZ,{worktreeId:e.worktreeId}),(e==null?void 0:e.kind)==="commands"&&!t&&d.jsx(aC,{}),(e==null?void 0:e.kind)==="projects"&&e.form!=="pill"&&d.jsx(lv,{form:e.form},e.form),(e==null?void 0:e.kind)==="choose-folder"&&o&&d.jsx(OZ,{project:o})]})}const Vf="Lost the daemon; retrying",BE="Not answering";function VZ(e,t){return e!=="down"&&e!=="blocked"?Vf:t===null?BE:`${BE}; as of ${So(mr(t))}`}const YZ="Not run by Toyon",$C="new worktree",CC=e=>`started from ${e}`,XZ=(e,t)=>`in ${e}, ${CC(t)}`,QZ=e=>`in ${e}, here while it needs you`,JZ=new Set(["waiting","stopping","working","background","starting","preparing","failed","crashed"]);function rw(e,t){if(!Nn(e))return e.locked?`Held by ${e.lockReason??"another tool"}`:t.path;if(t.op)return Dw(t.op);if(Cr(e.worktree))return $C;const n=Lw(e,t.needsSetup),r=e.worktree.lastTurn;return!JZ.has(Fs(e))&&r?by(r):t.at&&t.at!=="now"?`${n} · ${t.at}`:n}function eG(e,t){if(!Nn(e)||t)return!1;const n=Fs(e);return(n==="idle"||n==="asleep")&&!e.unseen}function tG(e){const t=e.worktree.lastTurn,n=e.worktree.landed?wy(e.worktree.lands):[],r=t?(ss(e.agent)?wF:by)(t):void 0,o=zh(e.worktree),s=o&&!e.worktree.landed?As(o):void 0;return[...n,r,s].filter(a=>!!a)}function nG(e,t,n,r){let o;const s=(h,m)=>{const g=m==null?void 0:m[m.length-1];g&&(!o||g.at>o.mark.at)&&(o={title:h,mark:g})};for(const h of e)h.worktree&&s(h.worktree.title,h.worktree.lands);for(const h of t)s(h.title,h.lands);const a=o&&Rj(o.mark),c=o?`Landed ${o.title} ${So(mr(o.mark.at))}${a?`: ${Jr(a)}`:"."}`:void 0,u=n?__(r,n):null,f=u?Jr(`${u.charAt(0).toUpperCase()}${u.slice(1)}`):n!=null&&n.fetchedAt?`Level with origin, fetched ${So(mr(n.fetchedAt))}.`:void 0;return[c,f].filter(h=>!!h)}function rG(e){const t=e.prompt?pp(e.prompt):"";return[...t?[t]:[],...wy(e.lands)]}function oG(e){const n=[e.auto&&sG(e.auto,!!e.landed),e.cost!==void 0?Xu(e.cost):void 0].filter(r=>!!r);return n.length?n:void 0}function sG(e,t){const{what:n,idle:r}=pA(e);return r?`${t?"":`${n}, `}${r} idle`:n}const UE=25;function iG(e,t){if(e.length<=UE+1)return{shown:e,rest:0};const n=e.slice(0,UE),r=t?e.find(o=>o.id===t):void 0;return r&&!n.includes(r)&&n.push(r),{shown:n,rest:e.length-n.length}}function aG(e,t,n){const r=e.indexOf(t);return r<0?null:e[r+(n?1:-1)]??null}const lG=.5;function cG(e){const t=e.usage,n=t&&t.size>0?t.used/t.size:0,r=[n>=lG?`${Math.round(100*n)}% of context`:void 0,e.queued?`${e.queued} queued`:void 0,(t==null?void 0:t.cost)!==void 0?Xu(t.cost):void 0].filter(o=>!!o);return r.length?r:void 0}function uG(e){const t=e.filter(gs).find(n=>n.id==="archive")??null;return[...t?[{id:"archive",label:t.label,icon:"archive",item:t}]:[],{id:"more",label:"more",icon:"more",item:null}]}function IC(e){return e.altKey?"Alt":e.ctrlKey?"Control":e.metaKey?"Meta":null}function ow(e,t){return t==="Alt"?e.altKey:t==="Control"?e.ctrlKey:e.metaKey}const dG=200,AC={set:(e,t)=>setTimeout(e,t),clear:e=>clearTimeout(e)};function fG(){let e=null;return{press(t){e=IC(t)},holds(t){return e!==null&&ow(t,e)},keyup(t){e&&t===e&&(e=null)},mods(t){e&&!ow(t,e)&&(e=null)}}}function hG(e,t=AC){let n=null,r=!1,o=null;const s=()=>{r||(r=!0,e(!0))},a=()=>{o!==null&&(t.clear(o),o=null)},c=()=>{a(),n=null,r&&(r=!1,e(!1))};return{press(u){const f=n!==null;n=IC(u),a(),n&&(f?s():o=t.set(()=>{o=null,s()},dG))},keyup(u){n&&u===n&&c()},mods(u){n&&!ow(u,n)&&c()},end:c}}const pG=350,mG=80,gG=2e3;function kG(e,t=AC){let n=!1,r=null,o=null,s=null,a=null;const c=()=>{r&&(t.clear(r.pending),r=null)},u=()=>{s!==null&&t.clear(s),a!==null&&t.clear(a),s=null,a=null},f=()=>{c(),u(),o=null,n&&(n=!1,e(!1))};return{over(h){u(),a=t.set(f,gG),n||(n=!0,e(!0)),(r==null?void 0:r.id)!==(h==null?void 0:h.id)&&(c(),!(!h||h.id===o)&&(o=null,r={id:h.id,pending:t.set(()=>{r=null,o=h.id,h.land()},pG)}))},leave(){n&&(s!==null&&t.clear(s),s=t.set(f,mG))},end:f}}const Of=e=>e>999?"1k+":String(e);function RC({width:e,placement:t="strip"}){const n=t==="screen",r=Bi(),o=hp(),s=qu("chat"),a=dt(),c=Qe(),{host:u}=Lr(),f=ry(),h=f[0]&&Cr(f[0].worktree)?f[0]:null,m=h?f.slice(1):f,g=L(ne=>Pi(ne,ne.activeRepoId)),y=ne=>h&&ne.id===h.id&&g?{behind:g.behind,dirty:g.dirty}:ne,[,w]=E.useState(0);E.useEffect(()=>{const ne=setInterval(()=>w(we=>we+1),6e4);return()=>clearInterval(ne)},[]);const v=k3(),_=w3(),x=y3(),N=v3(),T=(ne,we,qe)=>{ne.key!=="ArrowLeft"&&ne.key!=="ArrowRight"||ne.shiftKey||ne.altKey||ne.metaKey||ne.ctrlKey||(ne.preventDefault(),fp([{depth:0,open:we}],0,ne.key)&&a({a:qe}))},j=za(),A=L(ne=>ne.notesPage),R=L(ne=>ne.clientId),C=L(ne=>ne.frame),M=L(ne=>ne.activeRepoId),I=L(ne=>ne.connected);E.useEffect(()=>{c&&I&&M&&c.send({t:"list-archived",repoId:M})},[c,I,M]);const D=ac(),H=bN(),Z=L(ne=>ne.layout),B=L(ne=>ne.railOpen),J=L(ne=>ne.railPeek),V=E.useRef(null),[ee,F]=E.useState(!1);at([J],()=>{var ne;J&&!n&&!r&&!((ne=V.current)!=null&&ne.matches(":hover"))&&F(!0)}),E.useEffect(()=>{if(!ee)return;let ne=null;const we=qe=>{if(!ne){ne={x:qe.clientX,y:qe.clientY};return}Math.abs(qe.clientX-ne.x)+Math.abs(qe.clientY-ne.y)<3||F(!1)};return window.addEventListener("pointermove",we),()=>window.removeEventListener("pointermove",we)},[ee]);const[$,Q]=E.useState(!1),q=E.useMemo(()=>kG(Q),[]);E.useEffect(()=>()=>q.end(),[q]);const W=L(ne=>{var we;return((we=ne.dragFiles)==null?void 0:we.at)==="rail"?ne.dragFiles.worktreeId:null}),oe=L(ne=>ne.focusRail),de=E.useRef(oe),he=E.useRef(null);at([oe],()=>{if(oe===de.current)return;de.current=oe;const ne=requestAnimationFrame(()=>{var we,qe;return(qe=(we=he.current)==null?void 0:we.querySelector('[data-state~="current"]'))==null?void 0:qe.focus()});return()=>cancelAnimationFrame(ne)});const Ne=(ne,we,qe,ot,Tt)=>{var P,se;if(ne.key!=="ArrowUp"&&ne.key!=="ArrowDown"||ne.altKey||ne.ctrlKey||ne.metaKey)return;ne.preventDefault();const Dt=aG(we,qe,ne.key==="ArrowDown");Dt!==null&&(Tt(Dt),(se=(P=he.current)==null?void 0:P.querySelector(`[${ot}="${Dt}"]`))==null||se.focus())},Me=L(ne=>ne.repos),Be=L(ne=>ne.shipping),K=L(ne=>ne.rows),te=ne=>Me.find(we=>we.id===ne.repoId)??null,pe=ne=>M?Gw(ne,M,K):null,ue=ne=>M&&ne.repoId!==M?te(ne):null,ie=vn("rail"),ye=Dn(),Se=iy(),Ee=L(ne=>ne.home),Le=ne=>{const we=ne.worktree?ne.worktree.path:ne.path;return Ee&&we.startsWith(`${Ee}/`)?`~${we.slice(Ee.length)}`:we},[Ue,Je]=E.useState(!1),[Ht,qt]=E.useState([]),xt=ne=>{!Df(ne.worktree)||ue(ne)||(Je(!0),qt(we=>we.includes(ne.worktree.id)?we.filter(qe=>qe!==ne.worktree.id):[...we,ne.worktree.id]))},Ze=()=>{Je(!1),qt([])};at([Ue],()=>{const ne=we=>we.key==="Escape"&&Ze();return Ue&&window.addEventListener("keydown",ne),()=>window.removeEventListener("keydown",ne)});const _t={sock:c,dispatch:a},mt=ne=>qw(ye.getState(),ne),De=ne=>{Je(!0),qt(we=>ne===D||we.includes(ne)?we:[...we,ne])},nt=ne=>Nn(ne)?Cj(ne,te(ne),{layout:Z,shipping:Be,frame:C,drafted:mt},_t,{...ue(ne)?{}:{graft:De},hostname:u}):iF(ne,{clientId:R,frame:C},_t,u),[lt,Yt]=E.useState(null),$n=ne=>Nn(ne)?uG(nt(ne)):[],gt=L(ne=>ne.left);gj(he,{rowOf:ne=>{if(!n||Ue||Y_({left:gt},Date.now()))return null;const we=ne.closest(".slide"),qe=we==null?void 0:we.dataset.row,ot=qe?f.find(Tt=>Tt.id===qe):void 0;return we&&qe&&ot?{el:we,key:qe,rungs:$n(ot).length}:null},onSlide:Yt,onPick:(ne,we)=>{var Tt;const qe=f.find(Dt=>Dt.id===ne),ot=qe?$n(qe)[we-1]:void 0;if(!(!qe||!ot)){if(ot.id==="more"){const Dt=(Tt=he.current)==null?void 0:Tt.querySelector(`.slide[data-row="${ne}"]`);Dt&&ie.openUnder(Dt,()=>nt(qe),ne)}else if(ot.item&&!ot.item.disabled){const Dt=ot.item.onClick;window.setTimeout(Dt,pj)}}}});const rt=iG(x,(j==null?void 0:j.id)??null),Kn=rt.shown.some(ne=>(ne.dirty??0)>0),Qt=ne=>d.jsxs("button",{type:"button",className:Ke("row row-edge row-quiet rail-disc-item rail-arch-item",(Se==null?void 0:Se.owner)==="rail"&&Se.key===ne.id&&"menu-open"),"data-state":gr({current:!n&&(j==null?void 0:j.id)===ne.id}),"data-arch":ne.id,...Lt(YF(ne),void 0,{placement:s,card:!0,detail:rG(ne),aside:oG(ne)}),onClick:()=>a({a:"open-archived",id:ne.id}),onKeyDown:we=>Ne(we,rt.shown.map(qe=>qe.id),ne.id,"data-arch",qe=>a({a:"open-archived",id:qe})),...ie.contextMenu(()=>Kf(ne,{clientId:R,frame:C},_t),ne.id),children:[d.jsxs("span",{className:"rail-gut",onClick:r?we=>{we.stopPropagation(),ie.openUnder(we.currentTarget,()=>Kf(ne,{clientId:R,frame:C},_t),ne.id)}:void 0,children:[d.jsx("span",{className:"rail-at row-dim",children:mr(ne.archivedAt)}),d.jsx("span",{className:"rail-more",...Lt("Actions"),onClick:we=>{we.stopPropagation(),ie.openUnder(we.currentTarget,()=>Kf(ne,{clientId:R,frame:C},_t),ne.id)},children:d.jsx(kt,{name:"more"})})]}),d.jsx("span",{className:"branch",children:ne.title}),Kn&&d.jsx("span",{className:"rail-counts",children:d.jsx("span",{className:"rail-count row-dim","data-tip":ne.dirty?`${ne.dirty} uncommitted, kept`:void 0,children:ne.dirty?`~${Of(ne.dirty)}`:""})}),ne.auto?d.jsx("span",{className:"rail-glyph rail-auto row-dim",children:d.jsx(kt,{name:"clock",className:"icon-inline"})}):d.jsx("span",{className:"dot"}),n&&d.jsx("span",{className:"rail-at rail-at-end row-dim",children:mr(ne.archivedAt)})]},ne.id),Cn=[...f,...v].map(y),qn=["ahead","dirty","behind"].filter(ne=>Cn.some(we=>(we[ne]??0)>0)),dn=ne=>{const we=qn.findIndex(qe=>(ne[qe]??0)>0);return new Set(we<0?[]:qn.slice(we))},yn=ne=>{var sr;const we=Nn(ne)?ne:null,qe=!!we&&Cr(we.worktree),ot=y(ne),Tt=Me.find(Gt=>Gt.id===ne.repoId)??null,Dt=Tt?Dh(Tt):"main",P=Tt&&nR(Tt)&&(g!=null&&g.fetchedAt)?` as of ${Qh(g.fetchedAt)}`:"",se=dn(ot),je=!!ot.ahead&&!ot.dirty,Fe=ne.id,Rt=(Se==null?void 0:Se.owner)==="rail"&&Se.key===Fe,Zt=we?pe(we):null,Ae=we?ue(we):null,We=we&&!Ae?gz(we,K,x):null,Ve=we&&!Ae&&Ue&&Df(we.worktree)&&Fe!==D,Xt=we&&we.worktree.kind==="worktree"&&!Ae?{title:we.worktree.title,branch:we.worktree.branch}:null,Wt=Jh(ne,(sr=Be[Fe])==null?void 0:sr.op),bn=d.jsxs("button",{type:"button",className:Ke("row row-edge",we?"rail-item":"row-quiet rail-disc-item",n&&eG(ne,Wt)&&"row-quiet",Rt&&"menu-open",W===Fe&&"drop-over"),"data-state":gr({current:!n&&Fe===D&&!j&&!A,checked:Ht.includes(Fe)}),...we?Lt(H?Vf:$_(ne,Wt,lh(te(we))),void 0,{placement:s,card:!0,aside:cG(ne),detail:Cr(we.worktree)?nG(f,x,g,Dt):[...Ae?[Zt?XZ(Ae.name,Zt.worktree.title):QZ(Ae.name)]:We?[CC(We)]:[],...tG(we)],dot:H?void 0:T_(ne,Wt)}):Lt(H?Vf:ne.locked?`Held by ${ne.lockReason??"another tool"}`:YZ,void 0,{placement:s,card:!0,detail:Le(ne),dot:H||ne.locked?void 0:"discovered"}),"data-wt":Fe,draggable:o&&Xt!==null,onDragStart:Xt!==null?Gt=>$u(Gt,{kind:"worktree",worktreeId:Fe,...Xt}):void 0,onDragEnd:()=>Yu(ye),onKeyDown:Gt=>{if(Ue)return;const Rn=(we?f:v).map(fn=>fn.id);Ne(Gt,Rn,Fe,"data-wt",fn=>a({a:"activate",id:fn}))},onClick:Gt=>{we&&!Ae&&(Ue||Gt.shiftKey)?Fe===D?Je(!0):xt(we):qe&&!n?a({a:"open-draft"}):(a({a:"activate",id:Fe}),we&&!r&&a({a:"walked"}))},...ie.contextMenu(()=>nt(ne),Fe),children:[d.jsx("span",{className:"rail-gut",onClick:r&&!Ue?Gt=>{Gt.stopPropagation(),ie.openUnder(Gt.currentTarget,()=>nt(ne),Fe)}:void 0,children:Ve?d.jsx("input",{type:"checkbox",className:"rail-graft-check",checked:Ht.includes(Fe),readOnly:!0,tabIndex:-1}):!Ue&&d.jsxs(d.Fragment,{children:[we&&!qe&&d.jsx("span",{className:"rail-at row-dim",children:mr(Ca(we.worktree))}),d.jsx("span",{className:"rail-more",...Lt("Actions"),onClick:Gt=>{Gt.stopPropagation(),ie.openUnder(Gt.currentTarget,()=>nt(ne),Fe)},children:d.jsx(kt,{name:"more"})})]})}),qe?d.jsxs("span",{className:"branch rail-main-label",children:[d.jsx(kt,{name:"plus",className:"icon-inline"}),"new worktree"]}):d.jsx("span",{className:Ke("branch",(we==null?void 0:we.worktree.unnamed)&&"row-dim"),children:ik(ne,we?te(we):null)}),(we==null?void 0:we.worktree.mode)&&we.worktree.mode!=="auto"&&d.jsx("span",{className:"rail-badge badge-mode","data-tip":`${we.worktree.mode} mode: the agent waits for you`,children:we.worktree.mode}),Ae&&d.jsx("span",{className:"rail-guest row-dim",children:Ae.name}),d.jsxs("span",{className:"rail-counts",children:[se.has("ahead")&&d.jsx("span",{className:"rail-count badge-ahead","data-tip":ot.ahead?`${ot.ahead} ahead of ${Dt}`:void 0,children:ot.ahead?`+${Of(ot.ahead)}`:""}),se.has("dirty")&&!je&&d.jsx("span",{className:"rail-count badge-dirty","data-tip":ot.dirty?`${ot.dirty} uncommitted${qe?" on main":""}`:void 0,children:ot.dirty?`~${Of(ot.dirty)}`:""}),se.has("behind")&&d.jsx("span",{className:"rail-count rail-behind row-dim","data-tip":ot.behind?`${ot.behind} behind ${qe?"origin":Dt}${qe?"":P}`:void 0,children:ot.behind?Of(ot.behind):""}),n&&we&&d.jsx("span",{className:"rail-at row-dim",children:qe?"":mr(Ca(we.worktree))})]}),(()=>{if(Wt)return d.jsx("span",{className:"dot background"});if(ne.locked)return d.jsx("span",{className:"rail-glyph rail-lock row-dim",children:d.jsx(kt,{name:"lock",className:"icon-inline"})});if(!we)return d.jsx("span",{className:"dot discovered"});const Gt=Ue||H?null:C_(ne.procs),Rn=ne.unseen?" unseen":"",fn=Fs(ne);return qe&&!Gt&&fn!=="crashed"&&!H?d.jsxs(d.Fragment,{children:[d.jsx("span",{className:`dot ${fn} rail-main-dot`}),d.jsx("span",{className:"rail-glyph rail-main-strip",children:d.jsx(kt,{name:"plus"})})]}):!Gt||fn!=="crashed"?d.jsx("span",{className:`dot ${fn}${Rn}`}):d.jsx("span",{className:`dot crashed clickable${Rn}`,...Lt(Gt.tip),onClick:ae=>{ae.stopPropagation(),a({a:"activate",id:Fe}),a({a:"term-stream",id:Fe,stream:Gt.stream})}})})(),n&&d.jsx("span",{className:"rail-say row-dim",children:rw(ne,{needsSetup:lh(we?te(we):null),path:Le(ne),op:Wt})})]},Fe);if(!n||!we)return bn;const xn=(lt==null?void 0:lt.key)===Fe?lt.step:null,Ct=xn===null?null:$n(ne)[Math.max(0,xn-1)],Jt=!!Ct&&xn!==null&&xn>0&&(Ct.id==="more"||!!Ct.item&&!Ct.item.disabled);return d.jsxs("div",{className:"slide","data-row":Fe,children:[bn,Ct&&d.jsxs("span",{className:"slide-verb","data-rung":Jt?Ct.id:void 0,"aria-hidden":"true",children:[d.jsx("span",{className:"slide-word",children:Ct.label}),d.jsx(kt,{name:Ct.icon})]})]},Fe)};return d.jsx("div",{ref:V,className:Ke("rail",n&&"rail-screen",!n&&(Ue||(Se==null?void 0:Se.owner)==="rail"||J||$)&&"hold",ee&&"quiet",(n||B)&&"pinned",H&&"offline"),style:e!==void 0&&!n?{"--rail-width":`${e}px`}:void 0,onClick:r&&!n&&!B?ne=>{ne.target instanceof Element&&ne.target.closest("button, .rail-gut")||a({a:"toggle-rail"})}:void 0,onDragOver:ne=>{var Tt;if(!vk(ne.dataTransfer))return;const we=ne.target instanceof Element?(Tt=ne.target.closest("[data-wt]"))==null?void 0:Tt.dataset.wt:void 0,qe=we?[...f,...v].find(Dt=>Dt.id===we):void 0;if(!qe||Ue||qe.id===D)return q.over(null);const ot=!n&&Nn(qe)&&Cr(qe.worktree);q.over({id:qe.id,land:()=>a(ot?{a:"open-draft"}:{a:"activate",id:qe.id})})},onDragLeave:q.leave,onDrop:q.end,children:d.jsx("div",{className:"rail-panel","data-tip":H?Vf:void 0,"data-tip-placement":"follow",children:d.jsxs("div",{className:"rail-list",ref:he,children:[h&&!n&&yn(h),m.map(yn),Ue&&d.jsxs("div",{className:"rail-graft",children:[(()=>{const ne=f.find(ot=>ot.worktree.id===D&&Df(ot.worktree)&&!ue(ot)),we=Ht.filter(ot=>ot!==(ne==null?void 0:ne.worktree.id)),qe=we.map(ot=>{var Tt;return((Tt=f.find(Dt=>Dt.worktree.id===ot))==null?void 0:Tt.worktree.title)??ot}).join(", ");return d.jsxs(Oe,{size:"md",tone:"primary",disabled:!ne||we.length===0,"data-tip":ne?`Merge the checked worktrees into ${ne.worktree.title} and remove them`:"Select a worktree to graft onto",onClick:()=>{ne&&window.confirm(`Graft ${qe} onto ${ne.worktree.title}?
277
-
278
- Their branches are merged in, then their directories and branches are removed.`)&&(c==null||c.send({t:"graft",targetId:ne.worktree.id,sourceIds:we}),Ze())},children:["graft ",we.length]})})(),d.jsxs(Oe,{size:"md",disabled:!Ht.some(ne=>{var we;return(((we=f.find(qe=>qe.worktree.id===ne))==null?void 0:we.behind)??0)>0}),"data-tip":"Pull main into every selected worktree that's behind",onClick:()=>{for(const ne of Ht){const we=f.find(qe=>qe.worktree.id===ne);((we==null?void 0:we.behind)??0)>0&&Ii(c,a,{t:"sync-main",worktreeId:ne})}Ze()},children:[d.jsx(kt,{name:"pull",className:"icon-inline"})," sync"]}),d.jsx(Oe,{size:"md",tone:"danger",disabled:Ht.length===0,"data-tip":"Archive all selected worktrees; their chats and work are kept",onClick:()=>{window.confirm(`Archive ${Ht.length} worktree(s)?
279
-
280
- Their directories and branches go. The chats, commits and any uncommitted changes are kept, and each can be restored.`)&&(Kl(c,a,Ht),Ze())},children:"archive…"}),d.jsx(At,{icon:"close",label:"Cancel",hint:"esc",onClick:Ze})]}),!Ue&&v.length>0&&d.jsxs(d.Fragment,{children:[d.jsxs("button",{className:"section-title section-row section-fold rail-disc-head","aria-expanded":_,...Lt(`${v.length} worktree${v.length===1?"":"s"} here that Toyon did not make`,void 0,{placement:s}),onClick:()=>a({a:"toggle-discovered"}),onKeyDown:ne=>T(ne,_,"toggle-discovered"),children:[d.jsx("span",{className:"rail-gut",children:d.jsx(kt,{name:"caret",className:Ke("icon-inline disc-caret",!_&&"shut")})}),d.jsx("span",{className:"rail-label",children:"discovered"})]}),_&&v.map(yn)]}),!Ue&&x.length>0&&d.jsxs(d.Fragment,{children:[d.jsxs("button",{type:"button",className:"section-title section-row section-fold rail-disc-head","aria-expanded":N,...Lt(`${x.length} archived worktree${x.length===1?"":"s"}, kept with ${x.length===1?"its chat":"their chats"}`,void 0,{placement:s}),onClick:()=>a({a:"toggle-archived"}),onKeyDown:ne=>T(ne,N,"toggle-archived"),children:[d.jsx("span",{className:"rail-gut",children:d.jsx(kt,{name:"caret",className:Ke("icon-inline disc-caret",!N&&"shut")})}),d.jsx("span",{className:"rail-label",children:"archived"})]}),N&&rt.shown.map(Qt),N&&rt.rest>0&&M&&d.jsxs("button",{type:"button",className:"row row-quiet rail-disc-item rail-arch-item",...Lt("Find an older one by its name, branch or first message",void 0,{placement:s}),onClick:()=>a({a:"open",overlay:{kind:"chats",names:!0}}),children:[d.jsx("span",{className:"rail-gut"}),d.jsxs("span",{className:"branch row-dim",children:[rt.rest," more"]}),d.jsx("span",{className:"dot"})]})]})]})})})}const jh=["home","chat","preview","changes"],wG=(e,t)=>jh.indexOf(t)<jh.indexOf(e)?"left":"right";function yG(e,t,n,r=null){if(e==="home")return t!=="left"||!r||r==="home"?null:r==="preview"&&!n?"chat":r;const o=jh.filter(a=>a!=="preview"||n),s=o.indexOf(e);return s<0?null:o[s+(t==="right"?-1:1)]??null}function vG({screen:e,tabs:t,fold:n,beside:r=!1,away:o=!1}){const s=dt(),a=ys(),c=Bs(),u=L(he=>he.reading),f=L(he=>he.typing),h=E3(),m=lc(),g=L(he=>he.repos),y=Us(),w=ac(),v=za(),_=oy(),x=ry(),N=bN(),T=L(he=>he.connectFailure),j=L(he=>he.recalledAt??he.heardAt);Ci(N&&j!==null?j:void 0);const A=VZ(T,j),R=pN(),C=k8(x,w,R),M=x.find(he=>Cr(he.worktree)),I=e==="home",D=!I&&!v&&!!y&&Cr(y.worktree),H=L(he=>{var Ne;return D&&y?Jh(y,(Ne=he.shipping[y.id])==null?void 0:Ne.op):null}),Z=Xw().length,B=a.displayName(c.origin),J=I?(h==null?void 0:h.name)??B:D?$C:(v==null?void 0:v.title)??(y==null?void 0:y.worktree.title)??(_==null?void 0:_.name)??null,V=x.filter(he=>!Cr(he.worktree)).length,ee=V===0?"no worktrees yet":`${V} ${V===1?"worktree":"worktrees"}`,F=L(he=>he.sharing),$=I?N?A:F||(h&&Z>1?`${B} · ${ee}`:ee):v?Zj(v):N?A:D?H?Dw(H):(h==null?void 0:h.name)??null:y?rw(y,{needsSetup:lh(m),path:y.worktree.path,at:mr(Ca(y.worktree))}):_?rw(_,{needsSetup:!1,path:_.path}):null,Q=!I&&!v&&!!y&&Fs(y)==="waiting",q=L(he=>{var Ne;return((Ne=he.overlay)==null?void 0:Ne.kind)==="projects"&&he.overlay.form==="pill"})&&!r,W=L(he=>{var Ne;return((Ne=he.overlay)==null?void 0:Ne.kind)==="commands"})&&!r,oe=d.jsxs("div",{className:"phone-title",children:[I&&(g.length>1||Z>1)?d.jsxs("span",{className:"phone-drop phone-switch",children:[d.jsxs(Oe,{tone:"chrome",on:q,onClick:()=>s({a:"toggle",overlay:{kind:"projects",form:"pill"}}),children:[d.jsx("span",{className:"phone-name",children:J}),d.jsx(kt,{name:"caret",className:"icon-inline"})]}),q&&d.jsx(lv,{form:"pill",anchored:{margin:6}})]}):d.jsx("span",{className:"phone-name",children:J}),$&&d.jsx("span",{className:Ke("phone-sub",Q&&"phone-sub-asks"),children:$})]}),de=C&&d.jsxs(Oe,{size:"md",tone:"primary",onClick:()=>{const he=w8(x,w,R);if(!he)return;if(he.origin===null)return s({a:"activate",id:he.activate});const Ne=a.get(he.origin);Ne&&(Ne.store.dispatch({a:"activate",id:he.activate}),a.activate(he.origin))},children:[C.n," ",C.tier]});return d.jsxs("div",{className:"phone-bar",children:[d.jsxs("div",{className:"phone-bar-row",children:[!I&&d.jsx(At,{icon:"back",label:"Worktrees",tone:"chrome",onClick:()=>s({a:"screen",to:"home"})}),t?d.jsx("div",{className:"phone-tabs",children:t}):oe,!t&&de,I&&M&&d.jsx(At,{icon:"plus",label:"New worktree",tone:"chrome",onClick:()=>s({a:"activate",id:M.id})}),d.jsxs("span",{className:"phone-drop",children:[d.jsx(At,{icon:"more",label:"Menu",tone:"chrome",on:W,onClick:()=>s({a:"toggle",overlay:{kind:"commands"}})}),W&&d.jsx(aC,{anchored:{flip:"align",margin:6},trailing:d.jsx(At,{icon:"close",label:"Close",tone:"chrome",onClick:()=>s({a:"close"})})})]})]}),t&&!n&&d.jsx("div",{className:"phone-title-seat","data-away":u||f||o||void 0,children:d.jsxs("div",{className:"phone-title-strip",children:[oe,de]})})]})}const Yf="toyonDepth",OC="toyonOver",Dg=-1;function zg(e){return e.frame!=="phone"||!e.heard&&e.recalledAt===null?null:e.screen!=="home"&&(uo(e,e.activeId)!==null||Uo(e)!==null)?1+(e.editor?1:0):0}const MC=(()=>{const e=new Set;return{watch(t){return e.add(t),()=>e.delete(t)},tell(t){for(const n of e)n(t)}}})(),Fg=e=>{const t=e&&typeof e=="object"?e[Yf]:void 0;return typeof t=="number"?t:null},bG=e=>!!e&&typeof e=="object"&&e[OC]===!0;function xG(e,t=window,n=ec,r=MC){const o=t.history;let s=Fg(o.state)??Dg,a=Fg(o.state)!==null,c=null;const u=()=>{const T=n.open();c&&!T.includes(c)&&(c=null);for(let j=T.length-1;j>=0;j--){const A=T[j];if(A!=null&&A.dismiss&&A!==c)return A}return null};let f=!1;const h=()=>{const T=zg(e.getState());if(T===null||f)return;a||(o.replaceState({[Yf]:Dg},""),a=!0);const j=T+(u()?1:0);if(j!==s)if(j>s){for(let A=s+1;A<=j;A++)o.pushState({[Yf]:A,[OC]:A>T},"");s=j}else o.go(-1),f=!0};let m=!1;const g=()=>{m||(m=!0,queueMicrotask(()=>{m=!1,h()}))},y=(T,j)=>{const A=u();if(A){c=A,n.shut(A);return}const R=j===0?"home":T.screen;e.dispatch({a:"screen",to:R})},w=T=>{const j=f;f=!1,s=Fg(T.state)??Dg;const A=e.getState(),R=zg(A);if(R===null)return;if(s<0){o.pushState({[Yf]:0},""),s=0,h();return}if(j){h();return}const C=R+(u()?1:0);C!==s&&(C>s?y(A,s):C===0&&A.activeId&&!bG(T.state)&&e.dispatch({a:"screen",to:"chat"}),h())},v=T=>{if(f){f=!1,h();return}const j=e.getState(),A=zg(j);A===null||A===0||j.screen==="preview"&&!j.editor&&A===1||T.dir==="forward"||y(j,A+(u()?1:0)-1)};t.addEventListener("popstate",w);const _=e.subscribe(h),x=n.watch(g),N=r.watch(v);return h(),()=>{t.removeEventListener("popstate",w),_(),x(),N()}}function EG({gated:e,active:t,url:n,onTouch:r}){const o=np(t),s=s5(Bs(),o?n:null,e),a=E.useRef(null),c=E.useRef(r);return c.current=r,E.useEffect(()=>{if(!s)return;const u=new URL(s,location.href).origin,f=h=>{var y,w;const m=(y=a.current)==null?void 0:y.contentWindow;if(!m||h.source!==m||h.origin!==u||!((w=h.data)!=null&&w.__toyon))return;const g=a_(h.data);(g==null?void 0:g.type)==="traversed"?MC.tell({dir:g.dir??null}):(g==null?void 0:g.type)==="touch"?c.current(g):(g==null?void 0:g.type)==="loaded"&&m.postMessage({__toyon:!0,type:"touches",on:!0},u)};return window.addEventListener("message",f),()=>window.removeEventListener("message",f)},[s]),d.jsx("div",{className:"phone-preview",children:o&&s?d.jsx("iframe",{ref:a,className:"phone-preview-frame",src:s,title:t.worktree.title}):d.jsx(vs,{wide:!0,children:d.jsx("p",{className:"status-line",children:Lw(t)})})})}function SG(e){return e.incompatible?{kind:"updated",foreign:e.serving?null:e.machine}:e.said?{kind:"say"}:e.onWorktree?e.editor?{kind:"editor"}:{kind:"tab",tab:e.tab}:{kind:"home"}}const _G=sh(),NG=!sj(),jG={current:null};function TG(){const e=E.useRef(null),t=E.useRef(null),n=E.useRef(null);f3(e),h3(e);const r=dt(),o=L(de=>de.screen),s=Us(),a=za(),c=oy(),u=L(de=>de.editor),f=L(de=>de.left),h=L(de=>de.remote),m=Ku(),g=L(de=>de.connected),y=L(de=>de.heard),w=L(de=>de.recalledAt!==null||de.heard),v=L(de=>de.connectFailure),_=Bi(),x=Bs(),N=ys(),[T,j]=E.useState(null),[A,R]=E.useState(null),C=L(de=>de.incompatible),M=vj({connected:g,heard:y,standing:w,connectFailure:v,hasToken:x.serving?_G:!0,projectChord:Pt("project"),title:(s==null?void 0:s.worktree.title)??null,machine:x.serving?null:N.displayName(x.origin)}),I=o!=="home"&&(s!==null||a!==null||c!==null),D=!I&&T!==null&&T!=="home",H=!m&&!a?s:null,Z=I||D?H:null,{host:B}=Lr(),J=Z?N_(Z.worktree.id,Z.worktree.proxyPort,h,B):null,V=o==="preview"&&!Z?"chat":o,ee=SG({incompatible:C,serving:x.serving,machine:N.displayName(x.origin),said:M!==null,onWorktree:I,editor:u!==null,tab:V}),F=ee.kind==="home"?"home":ee.kind==="tab"?ee.tab:null,$=Z!==null&&J!==null,Q=U5(NG?e:jG,{take:(de,he)=>{if(T!==null)return null;const Ne=ee.kind==="tab"?ee.tab:ee.kind==="home"?"home":null;if(!Ne)return null;const Me=Ne==="home"?Y_({left:f},Date.now()):null;if(he==="left"&&!Me&&de.closest(".slide"))return null;const Be=yG(Ne,he,H!==null,Me);return Be?(j(Be),(Be==="home"||Ne==="home"?t:n).current):null},onSettle:de=>{de&&T&&R(T)},onEnd:de=>{de&&T&&r({a:"screen",to:T}),j(null),R(null)}}),q=(de,he)=>d.jsx(vG,{screen:de==="home"?"home":"chat",beside:he,fold:de!=="chat"||u!==null,away:!he&&T!==null&&T!=="home",tabs:de!=="home"&&M===null&&d.jsx(Vu,{fill:!0,segmented:!0,owner:"phone-tabs",label:"worktree",items:oe,current:A&&A!=="home"?A:de,onPick:Ne=>r({a:"screen",to:Ne})})}),W=ee.kind==="updated"?d.jsx(yj,{foreign:ee.foreign??void 0}):ee.kind==="say"&&M?d.jsx(vs,{wide:!0,children:d.jsx("p",{className:Ke("status-line",M.live&&"live-text"),children:M.text})}):ee.kind==="editor"&&u?d.jsx(xC,{editor:u,placement:"screen"}):null,oe=[{id:"chat",label:"chat"},...Z&&J?[{id:"preview",label:"preview",trail:d.jsx(At,{icon:"external",label:"Open in browser",tone:"chrome",onClick:()=>i5(x,J,bk(x,h))})}]:[],{id:"changes",label:"code"}];return d.jsxs("div",{ref:e,className:"app phone","data-chat-side":"left","data-touch":_||void 0,"data-hover":!_||void 0,children:[d.jsx(cj,{}),d.jsx(hj,{}),d.jsx("div",{className:"phone-screen",children:d.jsxs("div",{className:"center-root",children:[d.jsxs("div",{className:"phone-track",ref:t,children:[(!I||T==="home")&&d.jsxs("div",{className:"phone-face","data-side":I?"left":void 0,children:[q("home",I),!I&&F===null?W:d.jsx(RC,{placement:"screen"})]},"home"),(I||D)&&d.jsxs("div",{className:"phone-face","data-side":D?"right":void 0,children:[q(D&&T?T:V,D),d.jsxs("div",{className:"phone-track",ref:n,children:[F===null&&d.jsx("div",{className:"phone-face",children:W},"cover"),jh.map(de=>{if(de==="home")return null;const he=D?de===T:de===F,Ne=de===T&&!he;return!he&&!Ne&&!(de==="preview"&&$)?null:d.jsx("div",{className:"phone-face",hidden:!he&&!Ne,"data-side":Ne&&F?wG(F,de):void 0,children:de==="chat"?d.jsx(wu,{placement:"screen",archived:a,found:c}):de==="changes"?d.jsx(Wj,{placement:"screen"}):Z&&J?d.jsx(EG,{gated:bk(x,h),active:Z,url:J,onTouch:Q},Z.worktree.id):null},de)})]})]},"worktree")]}),d.jsx(TC,{})]})})]})}function $G(){try{const e=localStorage.getItem(tt.theme);if(e){const t=JSON.parse(e);if(t!=null&&t.colors&&typeof t.colors.surface0=="string")return t}}catch{}return Uu}function CG(){if(my()!=="phone")return"surface0";try{const e=sessionStorage.getItem(tt.ground);if(e==="surface0"||e==="surface1")return e}catch{}return"surface1"}function LC(e,t={}){var s,a;const n=document.documentElement;for(const[c,u]of Object.entries(AD(e)))n.style.setProperty(c,u);n.style.colorScheme=e.kind,n.dataset.theme=e.kind;const r=t.ground??CG();n.dataset.ground=r;const o=my()==="phone"?e.colors[r]:e.colors.surface1;if((s=document.querySelector('meta[name="theme-color"]'))==null||s.setAttribute("content",o),(a=document.querySelector('link[rel="manifest"]'))==null||a.setAttribute("href",t.black?"/manifest.json?black=1":"/manifest.json"),t.remember!==!1)try{localStorage.setItem(tt.theme,JSON.stringify(e))}catch{}}function PC(e){const t=$w(e);return{type:"theme",accent:t,accentFg:UD(t)}}function IG(){var e;return((e=window.matchMedia)==null?void 0:e.call(window,"(prefers-color-scheme: dark)").matches)??!0}const AG=12*36e5;function RG(){try{const e=localStorage.getItem(tt.daylight);if(!e)return null;const t=JSON.parse(e);if(typeof(t==null?void 0:t.dark)!="boolean"||typeof t.until!="number")return null;const n=Date.now()-t.until;return n<0?t:n<AG?{dark:!t.dark,until:0}:null}catch{return null}}function OG(e){try{localStorage.setItem(tt.daylight,JSON.stringify(e))}catch{}}function MG(e){var r;const t=(r=window.matchMedia)==null?void 0:r.call(window,"(prefers-color-scheme: dark)");if(!t)return()=>{};const n=o=>e(o.matches);return t.addEventListener("change",n),()=>t.removeEventListener("change",n)}function LG(e,t){return{word:`what's new in ${t}`,text:`Toyon updated from ${e} to ${t} since you last opened it here. Press to read what changed`}}function HE(e,t){return t==="reading"?"Reading the release notes":`No release notes could be read from Toyon ${e}.`}function PG(){const e=Lr(),t=L(s=>s.version),[n,r]=E.useState(void 0);E.useEffect(()=>{let s=!0;return t4(e).then(a=>{s&&r(a)}),()=>{s=!1}},[e]);const o=td(n??"",{keepHtml:!0});return n?d.jsx("div",{className:"notes-page",children:d.jsx(av,{html:o})}):d.jsx(vs,{wide:!0,children:d.jsx("p",{className:"status-line",children:n===void 0?d.jsx("span",{className:"live-text",children:HE(t,"reading")}):HE(t,"missing")})})}function sw(e,t){return[{id:"copy-name",label:"copy name",detail:e,onClick:()=>tn(e)},{id:"copy-value",label:"copy value",detail:t,onClick:()=>tn(t)}]}function iw(e){return[{id:"copy-value",label:"copy value",detail:e,onClick:()=>tn(e)}]}function DG(e,t,{sock:n},r){return t?Wn([[{id:"source",label:"open source",onClick:r}],Ho(()=>n==null?void 0:n.send({t:"reveal",worktreeId:e.id,path:t}),po(n)),[{id:"copy-path",label:"copy path",onClick:()=>tn(t)}]]):[]}function Bu(e){const t=/^#([0-9a-f]{3,8})$/i.exec(e.trim());if(!t)return null;const n=t[1],r=n.length===3||n.length===4?[...n].map(s=>s+s).join(""):n;if(r.length!==6&&r.length!==8)return null;const o=Number.parseInt(r.slice(0,6),16);return[o>>16&255,o>>8&255,o&255]}function zG(e){const t=/^#([0-9a-f]{3,8})$/i.exec(e.trim());return t?t[1].length===4||t[1].length===8:!1}function WE([e,t,n]){const r=o=>{const s=o/255;return s<=.03928?s/12.92:((s+.055)/1.055)**2.4};return .2126*r(e)+.7152*r(t)+.0722*r(n)}function DC(e,t){if(zG(e))return null;const n=Bu(e);if(!n)return null;const r=Bu(t);if(!r)return null;const[o,s]=[WE(n),WE(r)];return`${((Math.max(o,s)+.05)/(Math.min(o,s)+.05)).toFixed(2)}:1`}function FG({worktreeId:e,height:t,full:n,onToggleFull:r,onDragStart:o}){const s=dt(),a=Qe(),c=L(f=>Mr(f,e).design);E.useEffect(()=>{c||a==null||a.send({t:"design-scan",worktreeId:e})},[c,e,a]),E.useEffect(()=>()=>un.post(e,{type:"highlight-clear"}),[e]);const u={outline:f=>un.post(e,f),clear:()=>un.post(e,{type:"highlight-clear"}),open:f=>Pn({dispatch:s},{worktreeId:e,path:f})};return d.jsx(iv,{kind:"design",className:Ke("design-pane",n&&"full"),height:n?void 0:t,resizable:!n,onDragStart:o,title:c?d.jsx("span",{children:WG(c)}):void 0,onClose:()=>s({a:"toggle-design"}),closeHint:Pt("design"),full:n,onToggleFull:r,actions:d.jsxs(Oe,{variant:"outline",onClick:()=>a==null?void 0:a.send({t:"design-scan",worktreeId:e}),"data-tip":"Scan this worktree again",children:[d.jsx(kt,{name:"reload",className:"icon-inline"})," rescan"]}),children:c?d.jsxs("div",{className:"design-body",style:HG,onMouseLeave:u.clear,children:[c.tokens.length===0&&c.literals.length>0?d.jsx(YG,{literals:c.literals,outline:u.outline,clear:u.clear}):d.jsx(GG,{tokens:c.tokens,coverage:c.coverage,outline:u.outline,clear:u.clear}),d.jsx(sV,{index:c,outline:u.outline,clear:u.clear,onOpen:u.open}),d.jsx(iV,{index:c,outline:u.outline,clear:u.clear,onOpen:u.open})]}):d.jsx("div",{className:"empty",children:d.jsx("span",{className:"live-text",children:"reading the design system"})})})}const BG=720,UG=132,HG={"--design-column":`${BG}px`,"--design-cell":`${UG}px`};function WG(e){const t=Object.values(e.coverage.files).reduce((r,o)=>r+o,0),n=e.coverage.stylesheets;return`${t} file${t===1?"":"s"} read, ${n} stylesheet${n===1?"":"s"}`}const zl=e=>`${e} use${e===1?"":"s"}`;function Ap({title:e,note:t,children:n}){return d.jsxs("section",{className:"design-section",children:[d.jsxs("h2",{className:"design-h",children:[e,t&&d.jsx("span",{className:"design-note",children:t})]}),n]})}function Th({children:e}){return d.jsx("p",{className:"design-gap",children:e})}const KG=[{kind:"font",label:"type"},{kind:"color",label:"color"},{kind:"length",label:"size & radius"},{kind:"shadow",label:"shadow"},{kind:"other",label:"computed"}];function qG(e){return e.find(t=>t.kind==="color"&&Bu(t.resolved??t.value)!==null)}function ZG(e){if(e.stylesheets===0)return"No stylesheet was read, so there is no palette or type scale to show.";const t=e.files,n=(t.scss??0)+(t.sass??0)+(t.less??0)+(t.styl??0),r="No custom properties, and no colors or sizes written out in the stylesheets.";return n>0?`${r} Sass, Less and Stylus variables are not read yet.`:r}function GG({tokens:e,coverage:t,outline:n,clear:r}){const o=qG(e),s=o&&(o.resolved??o.value),a=new Map;for(const u of e){const f=(u.resolved??u.value).trim().toLowerCase();a.set(f,[...a.get(f)??[],u.name])}const c=u=>(a.get((u.resolved??u.value).trim().toLowerCase())??[]).filter(f=>f!==u.name);return d.jsx(Ap,{title:"Tokens",children:e.length===0?d.jsx(Th,{children:ZG(t)}):KG.map(({kind:u,label:f})=>{const h=e.filter(g=>g.kind===u);if(h.length===0)return null;const m=FC(h.map(g=>g.value));return d.jsxs("div",{className:"design-group",children:[u!=="font"&&d.jsx("span",{className:"design-group-name",children:f}),u==="font"?d.jsx(BC,{groups:tV(h),outline:n,clear:r}):d.jsx("div",{className:"design-breakout",style:zC(h.length),children:d.jsx("div",{className:"design-grid",children:h.map(g=>{const y=g.resolved??g.value,w=g.kind==="color"&&s?DC(y,s):null;return d.jsx(UC,{kind:g.kind,name:g.name,lines:g.resolved?[g.value,g.resolved]:[g.value],actual:y,ratio:w,largest:m,tipText:rV(g,w,o,c(g)),menu:()=>sw(g.name,y),outline:n,clear:r},g.name)})})})]},u)})})}const VG=[{role:"color",kind:"color",label:"color"},{role:"radius",kind:"length",label:"radius"},{role:"shadow",kind:"shadow",label:"shadow"}];function YG({literals:e,outline:t,clear:n}){const r=e.find(s=>s.ground&&Bu(s.value)!==null),o=nV(e);return d.jsxs(Ap,{title:"Values",note:"written out in the rules; no custom properties",children:[o.length>0&&d.jsx("div",{className:"design-group",children:d.jsx(BC,{groups:o,outline:t,clear:n})}),VG.map(({role:s,kind:a,label:c})=>{const u=e.filter(h=>h.role===s);if(u.length===0)return null;const f=FC(u.map(h=>h.value));return d.jsxs("div",{className:"design-group",children:[d.jsx("span",{className:"design-group-name",children:c}),d.jsx("div",{className:"design-breakout",style:zC(u.length),children:d.jsx("div",{className:"design-grid",children:u.map(h=>{const m=a==="color"&&r?DC(h.value,r.value):null;return d.jsx(UC,{kind:a,name:h.value,lines:[zl(h.uses)],actual:h.value,ratio:m,largest:f,tipText:oV(h,m,r),menu:()=>iw(h.value),outline:t,clear:n},h.value)})})})]},s)})]})}function zC(e){const t="var(--design-cell)",n=`min(round(down, 100%, ${t}), calc(${e} * ${t}))`,r=`round(down, var(--design-column), ${t})`,o=`round(down, max(0px, calc((${n} - ${r}) / 2)), ${t})`;return{width:n,marginLeft:`max(0px, calc((100% - var(--design-column)) / 2 - ${o}))`}}function FC(e){return e.reduce((t,n)=>Math.max(t,Math.abs(Number.parseFloat(n))||0),0)}const XG=["color","background-color","border-top-color","border-right-color","border-bottom-color","border-left-color","outline-color"];function QG(e,t){if(!e)return[];const n=getComputedStyle(e);return t.map(r=>[r,n.getPropertyValue(r)])}const aw=e=>(e.split(",")[0]??e).replace(/["']/g,"").trim();function JG(e){const t=/^[1-9]00\s+([\d.]+)px(?:\s*\/\s*([\d.]+)(px)?)?\s+(.+)$/.exec(e.trim());if(!t)return{family:aw(e),size:null,lead:null};const n=Number(t[1]),r=t[2]?Number(t[2]):null,o=r===null?null:Math.round((t[3]?r:n*r)*100)/100;return{family:aw(t[4]??""),size:n,lead:o}}function Bg(e){const t=Number.parseFloat(e);return e.endsWith("em")?t*16:e.endsWith("pt")?t*4/3:e.endsWith("%")?t/100*16:t}function eV(e,t){if(!e)return null;const n=Number.parseFloat(e),r=/^[\d.]+$/.test(e)?t*n:e.endsWith("px")?n:null;return r===null?null:Math.round(r*100)/100}function tV(e){const t=e.map(n=>({token:n,actual:n.resolved??n.value,...JG(n.resolved??n.value)}));return[...new Set(t.map(n=>n.family))].map(n=>{const r=t.filter(s=>s.family===n),o=r.find(s=>s.size===null);return{family:n,stack:o?o.actual:n,name:o==null?void 0:o.token.name,label:o?o.token.name:n,tipText:o?`${o.token.name}
281
- ${o.actual}`:void 0,menu:()=>o?sw(o.token.name,o.actual):[],rows:r.filter(s=>s.size!==null).sort((s,a)=>(a.size??0)-(s.size??0)).map(s=>({key:s.token.name,sample:`${s.family} ${s.size}${s.lead===null?"":`/${s.lead}`}`,style:{font:s.actual},name:s.token.name,label:s.token.name,tipText:`${s.token.name}
282
- ${s.actual}`,menu:()=>sw(s.token.name,s.actual)}))}})}function nV(e){const t=e.filter(o=>o.role==="family"),n=e.filter(o=>o.role==="size");return[...new Set([...t.map(o=>o.value),...n.map(o=>o.family??"initial")])].map(o=>{const s=t.find(c=>c.value===o),a=o==="initial"?"default face":aw(o);return{family:a,stack:o,name:s?zl(s.uses):void 0,label:a,tipText:s?`${s.value}
283
- ${zl(s.uses)}: ${s.selectors.join(", ")}`:void 0,menu:()=>s?iw(s.value):[],rows:n.filter(c=>(c.family??"initial")===o).sort((c,u)=>Bg(u.value)-Bg(c.value)).map(c=>{const u=Bg(c.value),f=eV(c.lead,u),h=c.value.endsWith("px")?`${u}`:c.value;return{key:`${c.value}/${c.lead??""}`,sample:`${a} ${h}${f===null?"":`/${f}`}`,style:{fontFamily:o,fontSize:c.value,lineHeight:c.lead},name:zl(c.uses),label:c.value,tipText:`${c.value}${c.lead?` / ${c.lead}`:""}
284
- ${zl(c.uses)}: ${c.selectors.join(", ")}`,menu:()=>iw(c.value)}})}})}function BC({groups:e,outline:t,clear:n}){const r=(s,a,c)=>t({type:"highlight-computed",props:QG(s.currentTarget.querySelector(".design-face-sample"),a?["font-family","font-size","line-height"]:["font-family"]),match:"all",label:c}),o=vn("design");return d.jsx("div",{className:"design-faces",children:e.map(s=>d.jsxs("div",{className:"design-face-group",children:[d.jsxs("div",{className:"design-face-head row-edge",onMouseEnter:a=>r(a,!1,s.label),onMouseLeave:n,...o.contextMenu(s.menu),...s.tipText?Lt(s.tipText,void 0,{placement:"follow"}):{},children:[d.jsx("span",{className:"design-face-sample design-face-family",style:{fontFamily:s.stack},children:s.family}),s.name&&d.jsx("span",{className:"design-face-name row-dim",children:s.name})]}),s.rows.map(a=>d.jsxs("div",{className:"design-face row-edge",onMouseEnter:c=>r(c,!0,a.label),onMouseLeave:n,...o.contextMenu(a.menu),...Lt(a.tipText,void 0,{placement:"follow"}),children:[d.jsx("span",{className:"design-face-sample",style:a.style,children:a.sample}),d.jsx("span",{className:"design-face-name row-dim",children:a.name})]},a.key))]},s.stack))})}function UC({kind:e,name:t,lines:n,actual:r,ratio:o,largest:s,tipText:a,menu:c,outline:u,clear:f}){const h=e==="color"&&Bu(r)!==null,m=e==="length"?Number.parseFloat(r):Number.NaN,g=vn("design");return d.jsxs("div",{className:"design-cell","data-kind":e,...g.contextMenu(c),onMouseEnter:h?y=>{const w=y.currentTarget.querySelector(".design-fill"),v=w?getComputedStyle(w).backgroundColor:"";u({type:"highlight-computed",props:XG.map(_=>[_,v]),match:"any",label:t})}:void 0,onMouseLeave:h?f:void 0,...Lt(a),children:[e==="color"&&d.jsx("div",{className:"design-sample",children:h&&d.jsx("span",{className:"design-fill",style:{background:r}})}),d.jsxs("div",{className:"design-plate",children:[d.jsx("span",{className:"design-cell-name",children:t}),n.map((y,w)=>d.jsxs("span",{className:"design-cell-line",children:[d.jsx("span",{className:"design-cell-value",children:y}),w===0&&o&&d.jsx("span",{className:"design-cell-note",children:o})]},y)),Number.isFinite(m)&&s>0&&d.jsx("span",{className:"design-scale",style:{width:`${Math.max(2,Math.abs(m)/s*100)}%`}})]})]})}function rV(e,t,n,r=[]){const o=[e.name,e.resolved?`${e.value} resolves to ${e.resolved}`:e.value];if(r.length>0&&o.push(`same value as ${r.join(", ")}`),t&&n){const s=e.name===n.name;o.push(s?"the ground these ratios are measured against":`${t} against ${n.name}`)}return o.join(`
285
- `)}function oV(e,t,n){const r=[e.value,`${zl(e.uses)}: ${e.selectors.join(", ")}`];return t&&n&&r.push(e===n?"the page background these ratios are measured against":`${t} against the page background`),r.join(`
286
- `)}function HC({shared:e,rest:t}){return e.length===0?d.jsx("ul",{className:"design-rows",children:t}):d.jsxs(d.Fragment,{children:[d.jsx("ul",{className:"design-rows",children:e}),t.length>0&&d.jsxs("details",{className:"design-tail",children:[d.jsxs("summary",{className:"row-edge",children:[d.jsx("span",{className:"design-count row-dim",children:t.length}),"used once or never"]}),d.jsx("ul",{className:"design-rows",children:t})]})]})}function sV({index:e,outline:t,clear:n,onOpen:r}){const{components:o,typed:s}=e;if(o.length===0)return null;const a=o.filter(f=>f.imports>=2),c=o.filter(f=>f.imports<2),u=f=>d.jsx(WC,{count:f.imports,name:f.name,path:f.path,onEnter:()=>t({type:"highlight-file",path:f.path,ranges:null}),onLeave:n,onOpen:()=>r(f.path),children:f.variants.length>0&&d.jsx("span",{className:"design-variants",children:f.variants.map(h=>d.jsxs("span",{className:"design-variant",children:[h.prop,": ",h.values.join(" · ")]},h.prop))})},`${f.path}:${f.name}`);return d.jsxs(Ap,{title:"Components",note:`${a.length} reused of ${o.length}`,children:[!s&&d.jsx(Th,{children:"No TypeScript in this project, so the values each prop allows are not listed."}),d.jsx(HC,{shared:a.map(u),rest:c.map(u)})]})}function iV({index:e,outline:t,clear:n,onOpen:r}){const{classes:o,coverage:s}=e,a=o.filter(g=>g.uses>0),c=o.filter(g=>g.uses>=2),u=o.filter(g=>g.uses<2),f=c.filter(g=>g.unwrapped).length,h=o.length?`${c.length} reused of ${o.length}`+(f?`, ${f} with no component of their name`:""):void 0,m=g=>d.jsx(aV,{cls:g,outline:t,clear:n,onOpen:r},g.name);return d.jsx(Ap,{title:"Classes",note:h,children:o.length===0?d.jsx(Th,{children:"No stylesheet in this project defines a class. Utility-first CSS generates its own."}):a.length===0?d.jsx(Th,{children:s.classAttrs>0?`${s.classAttrs} class attributes were read, and none names a class this scan can follow. That is what a CSS Modules project looks like from here.`:"No class attribute anywhere in the source that was read. The markup may live in a file type this scan does not open."}):d.jsx(HC,{shared:c.map(m),rest:u.map(m)})})}function aV({cls:e,outline:t,clear:n,onOpen:r}){return d.jsx(WC,{count:e.uses,name:`.${e.name}`,path:e.path,onEnter:()=>t({type:"highlight-selector",selector:`.${e.name}`,label:`.${e.name}`}),onLeave:n,onOpen:()=>e.path&&r(e.path),children:e.unwrapped&&d.jsx("span",{className:"design-tag",children:"no component"})})}function WC({count:e,name:t,path:n,onEnter:r,onLeave:o,onOpen:s,children:a}){const c=Us(),u=Qe();dt();const f=vn("design");return d.jsx("li",{children:d.jsxs("button",{type:"button",className:"design-row row-edge",onMouseEnter:r,onFocus:r,onMouseLeave:o,onBlur:o,onClick:s,disabled:!n,...f.contextMenu(()=>c?DG({id:c.worktree.id},n,{sock:u},s):[]),children:[d.jsx("span",{className:"design-count row-dim",children:e}),d.jsx("span",{className:"design-name",children:t}),d.jsx("span",{className:"design-path row-dim",children:n}),a]})})}function lV(e,t){const n=[`${e.name} runs on main for every worktree; this one reaches it at its usual address.`];return t>0&&n.push(`${Yl(t,e.name)[0].toUpperCase()}${Yl(t,e.name).slice(1)}.`),Ah(e.status)||n.push(`Main's ${e.name} is ${Pw(e.status).toLowerCase()}.`),n.join(" ")}function cV({procs:e,borrowed:t,pointed:n,dirty:r}){return[...e.map(o=>({kind:"proc",proc:o})),...t.map(o=>({kind:"borrowed",name:o.name,dot:Ah(o.status)?"borrowed":o.status,tip:lV(o,r)})),...Object.entries(n).map(([o,s])=>({kind:"pointed",name:o,remote:s,tip:`${o} points at ${s} for this worktree`}))]}function uV({worktreeId:e,procs:t,borrowed:n,pointed:r,dirty:o,login:s,current:a,onRestart:c}){const u=Qe();dt();const f={sock:u},h=(g,y)=>d.jsx(At,{icon:"reload",label:y,onClick:()=>c(g)}),m={id:Ds,label:"login",tip:Lt("The agent's login; it closes once you are in",void 0,{placement:"top"}),trail:h(Ds,"Run the login again")};return s&&a===Ds?[m]:[{id:zo,label:"shell",tip:Lt("A shell in this worktree",void 0,{placement:"top"}),menu:()=>iT(e,f),trail:h(zo,"Restart the shell")},...s?[m]:[],...cV({procs:t,borrowed:n,pointed:r,dirty:o}).map(g=>{if(g.kind==="proc"){const y=g.proc;return{id:y.name,label:y.name,lead:d.jsx("span",{className:`dot ${y.status}`}),tip:Lt(Pw(y.status),void 0,{placement:"top",dot:y.status,name:y.name,detail:y.command,aside:[`:${y.port}`]}),menu:()=>_y(y,e,f),trail:h(y.name,`Restart ${y.name}`)}}return{id:g.name,label:g.name,lead:d.jsx("span",{className:`dot ${g.kind==="borrowed"?g.dot:"borrowed"}`}),tip:Lt(g.tip,void 0,{placement:"top"})}})]}const dV=E.lazy(()=>Jk(()=>import("./XTerm-B84G0H5I.js"),__vite__mapDeps([3,4]))),fV=[],hV={};function pV({worktreeId:e,opened:t,height:n,onDragStart:r}){const o=dt(),s=Qe(),a=op(),c=L(ee=>ee.connected),u=L(ee=>ee.focusTerm),f=Us(),h=(f==null?void 0:f.procs)??[],m=(f==null?void 0:f.borrowed)??fV,g=E.useMemo(()=>{const ee={};for(const[F,$]of Object.entries((f==null?void 0:f.worktree.sources)??{})){const Q=mS($.at);Q!==void 0&&(ee[F]=Q)}return Object.keys(ee).length>0?ee:hV},[f==null?void 0:f.worktree.sources]),y=(f==null?void 0:f.login)??!1,w=L(ee=>{var F;return((F=Pi(ee,f==null?void 0:f.repoId))==null?void 0:F.dirty)??0}),v=L(ee=>ws(ee,f==null?void 0:f.repoId)),_=It(e,"termStream"),x=L(ee=>{var F;return((F=ee.termRun)==null?void 0:F.id)===e&&_===zo?ee.termRun.command:null}),[N,T]=E.useState(null),j=m.find(ee=>ee.name===_),A=j!==void 0,R=g[_];E.useEffect(()=>{_===zo||(_===Ds?y:h.some(F=>F.name===_)||m.some(F=>F.name===_)||_ in g)||o({a:"term-stream",id:e,stream:zo})},[h,m,g,y,_,e,o]);const C=ee=>{ee!==_&&(T(null),o({a:"term-stream",id:e,stream:ee}))},M=E.useRef(!1),[I,D]=E.useState(0),H=ee=>{ee===zo&&ee===_&&(M.current=!0),s==null||s.send({t:"term-restart",worktreeId:e,stream:ee}),ee===Ds&&ee===_&&(T(null),D(F=>F+1))},Z=(ee,F)=>{if(ee)return T(null);if(M.current){M.current=!1,D($=>$+1);return}T({code:F})},B=uV({worktreeId:e,procs:h,borrowed:m,pointed:g,dirty:w,login:y,current:_,onRestart:H}),J=E.useRef(!t),V=!J.current;return E.useEffect(()=>{J.current=!1},[]),d.jsxs(iv,{kind:"terminal",className:"term-pane",height:n,onDragStart:r,tabs:{items:B,current:_,onPick:C,font:"mono",owner:"terminal",label:"terminal streams"},onClose:()=>o({a:"toggle-terminal"}),closeHint:Pt("terminal"),children:[d.jsxs("div",{className:"term-body",children:[j&&d.jsx(Wl,{pane:!0,title:`${_} runs on main`,body:["Every worktree reaches main's copy until its own changes touch it, or until asked.",...w>0?[`${Yl(w,_)[0].toUpperCase()}${Yl(w,_).slice(1)}.`]:[],...Ah(j.status)?[]:[`Main's ${_} is ${j.status}; every worktree reaching it is down until it is back.`]].join(" "),action:d.jsx(Oe,{variant:"outline",onClick:()=>s==null?void 0:s.send({t:"set-proc-source",worktreeId:e,name:_,source:"here"}),children:"run it here"})}),R!==void 0&&!A&&d.jsx(Wl,{pane:!0,title:`${_} points at ${R}`,body:`The page here talks to ${pS((v==null?void 0:v.config.run[_])??"")[R]??R}; nothing runs here.`,action:d.jsx(Oe,{variant:"outline",onClick:()=>s==null?void 0:s.send({t:"set-proc-source",worktreeId:e,name:_,source:"here"}),children:"run it here"})}),d.jsx(gy,{pane:!0,children:d.jsx(E.Suspense,{fallback:d.jsx("div",{className:"empty",children:d.jsx("span",{className:"live-text",children:"loading terminal"})}),children:d.jsx(dV,{worktreeId:e,stream:_,theme:a,sock:s,connected:c,focusOnMount:V,focusReq:u,onAlive:Z,run:x,onRan:()=>o({a:"term-ran"}),onEscape:()=>o({a:"toggle-terminal"})},`${_}:${I}`)})})]}),N!==null&&!A&&R===void 0&&d.jsx(Wl,{pane:!0,title:_===zo?"the shell exited":_===Ds?"the login did not finish":`${_} exited`,body:N.code===void 0?void 0:`exit code ${N.code}`,action:d.jsx(Oe,{variant:"outline",onClick:()=>H(_),children:"restart"})})]})}function mV(e){return e==="reserved"?"checking out a fresh worktree":e==="warming"?"copying dependencies and running setup":"starting dev servers"}const gV="preview off; it starts when the agent writes a file";function kV({worktree:e,log:t}){const n=Qe(),r=dt(),o=e.procs,s=v=>n==null?void 0:n.send({t:"term-restart",worktreeId:e.id,stream:v.name}),a=o.some(v=>v.status==="crashed"||v.status==="unreachable"),c=L(v=>v.clientId),u=Iu(e,"setup"),f=u&&u.status!=="terminated"?u:null,h=Ci(xy(f??void 0)?f==null?void 0:f.since:void 0),m=!!e.worktree.parked&&o.length===0,g=()=>n==null?void 0:n.send({t:"preview-start",worktreeId:e.id}),y=f&&(f.status==="running"||f.status==="detached"),w=()=>n==null?void 0:n.send({t:"fix-preview",worktreeId:e.id,clientId:c});return d.jsxs(vs,{wide:!0,children:[o.length===0?d.jsx("div",{className:"status-line",children:f?d.jsx("span",{className:"live-text","data-tip":_k[f.status],children:fh("setup",f,h)}):m?gV:d.jsx("span",{className:"live-text",children:mV(e.worktree.phase)})}):d.jsx("ul",{className:"boot-procs",children:o.map(v=>d.jsxs("li",{className:Ke("boot-proc",(v.status==="crashed"||v.status==="unreachable")&&"boot-bad"),children:[d.jsx("span",{className:"boot-name",children:v.name}),d.jsx("span",{className:"boot-status",children:wV(v)}),(v.status==="crashed"||v.status==="unreachable")&&d.jsx(Oe,{variant:"outline",onClick:()=>s(v),children:"restart"}),v.detail&&v.status!=="asleep"&&d.jsx("div",{className:"boot-detail",children:v.detail})]},v.name))}),m&&d.jsx("div",{className:"status-actions",children:d.jsx(Oe,{variant:"outline",size:"lg",onClick:g,children:"start preview"})}),y&&d.jsx("div",{className:"status-actions",children:d.jsx(Oe,{variant:"outline","data-tip":Bj("setup"),onClick:()=>n==null?void 0:n.send({t:"run-stop",worktreeId:e.id,kind:"setup"}),children:"stop setup"})}),a&&d.jsxs("div",{className:"status-actions",children:[e.agent==="idle"&&d.jsx(Oe,{variant:"outline",size:"lg",onClick:w,children:"ask the agent to fix it"}),d.jsx(Oe,{onClick:()=>r({a:"open",overlay:{kind:"setup",repoId:e.repoId}}),children:"edit setup"})]}),t.length>0&&d.jsx("pre",{className:"status-tail",children:t.slice(-30).map(v=>`[${v.proc}] ${v.line}`).join(`
287
- `)})]})}function wV(e){switch(e.status){case"preparing":return`setting up for :${e.port}`;case"starting":return`starting on :${e.port}`;case"running":return`running on :${e.boundPort??e.port}`;case"unreachable":return"never answered";case"crashed":return e.exitCode!=null?`crashed (exit ${e.exitCode})`:"crashed";case"stopped":return"stopped";case"asleep":return`asleep${e.detail?`: ${e.detail}`:""}; opens when you look`}}function yV(e){const{leaving:t,arriving:n}=e;return!t||!n||t===n||n!==e.carryTo?null:e.repoOf(t)===e.repoOf(n)?t:null}function KE(e){if(!e)return"/";try{const t=new URL(e);return`${t.pathname}${t.search}${t.hash}`}catch{return"/"}}function vV(e){return e.previewId===null?null:e.painted?e.previewId:e.ready?e.carry&&e.mounted.includes(e.carry)?e.carry:e.previewId:null}function bV({active:e}){const t=dt(),n=Qe(),r=lc(),o=L(c=>c.home),s=e.worktree.title,a=()=>{r!=null&&r.made&&(t({a:"new-project",v:{...ep({mode:r.made==="git"?"init":"create",name:r.name,parent:hT(r.path,o)??r.path}),phase:"unmaking",repoId:r.id}}),t({a:"move-box",from:e.worktree.id,to:Xl}),n==null||n.send({t:"unmake-repo",repoId:r.id}))};return d.jsx(vs,{anchor:"line",foot:d.jsx("div",{className:"composer view-foot",children:d.jsx(ku,{active:e,greenfield:!0})}),children:d.jsx("p",{className:"form-title",children:r!=null&&r.made?d.jsx(Oe,{variant:"inline",onClick:a,...Lt("Rename or move this project"),children:s}):s})})}function xV({pending:e}){const t=dt(),n=Qe(),r=!!e.error,o=()=>{n==null||n.send({t:"cancel-import",id:e.id}),t({a:"watch-import",id:null})},s=E.useRef(null);return E.useEffect(()=>{var a;return(a=s.current)==null?void 0:a.scrollTo({top:s.current.scrollHeight})},[e.lines.length]),d.jsxs(vs,{wide:!0,children:[d.jsxs("p",{className:"status-line",children:[r?"could not import":"importing"," ",e.name]}),d.jsxs("p",{children:["from ",d.jsx("code",{children:e.url}),e.branch&&d.jsxs(d.Fragment,{children:[" ","on ",d.jsx("code",{children:e.branch})]})," ","into ",d.jsx("code",{children:e.parent})]}),r?d.jsx("p",{className:"import-error",children:e.error}):d.jsx("p",{className:"hint",children:"the whole history is cloned, so worktrees, land and graft all work on it straight away."}),d.jsx("div",{className:"status-tail",ref:s,children:e.lines.length===0&&!r?d.jsx("span",{className:"live-text",children:"starting git"}):e.lines.map((a,c)=>d.jsx("div",{children:a},c))}),d.jsx("div",{className:"status-actions",children:d.jsx(Oe,{variant:"outline",size:"lg",onClick:o,children:r?"dismiss":"stop"})})]})}const EV=150,SV=/^[^\s@]+@[^\s@]+$/,_V=14;function NV({project:e}){var Q;const t=dt(),n=Qe(),r=L(q=>q.repos),o=L(q=>q.home),s=L(q=>q.folderDialog),a=L(q=>q.gitIdentity),c=L(q=>q.choosingFolder),u=L(q=>q.chosenFolder),f=L(q=>q.paths),[h,m]=E.useState({name:"",email:""}),[g,y]=E.useState(null),w=E.useRef(null),{mode:v,name:_,parent:x}=e,N=v==="clone",T=v==="init",j=e.phase==="editing",A=_.trim(),R=T||!A?null:Eu(_),C=!T&&A&&!R?fT(x,A):null,M=Ak(x,o),I=C!==null&&f.query===C&&((Q=f.target)==null?void 0:Q.exists)===!0,D=!a&&!N,H=!D||h.name.trim()!==""&&SV.test(h.email.trim()),Z=j?g?"the folder you chose is already a project: open it, or choose another":!T&&!A?"name the project first":R??(I?`${M} already has a folder called ${A}`:H?null:"git needs your name and email first"):null;E.useEffect(()=>{if(!C)return;const q=setTimeout(()=>n==null?void 0:n.send({t:"browse-path",path:C}),EV);return()=>clearTimeout(q)},[C,n]),at([e.phase],()=>{var q;e.phase==="editing"&&((q=w.current)==null||q.focus())}),at([e.error],()=>{e.error&&t({a:"notice",id:Xl,text:e.error})});const B={sock:n,dispatch:t},J=()=>{Z||!j||(t({a:"new-project-set",v:{phase:"creating"}}),Au(B,{t:"create-repo",mode:v,parent:x.trim(),name:A,...N&&e.url?{url:e.url,...e.branch?{branch:e.branch}:{}}:{},...D?{identity:{name:h.name.trim(),email:h.email.trim()}}:{}}))},V=q=>{const W=r.find(oe=>oe.path===tc(q,o));W?t({a:"activate-repo",id:W.id}):Au(B,{t:"register-repo",path:q})},ee=q=>{const W=jy(q);t({a:"new-project-set",v:{mode:"init",parent:W.parent,name:W.name}})},F=q=>{s?(t({a:"choosing-folder",v:q}),n==null||n.send({t:"choose-folder",start:x,purpose:q})):t(q==="location"?{a:"open",overlay:{kind:"choose-folder"}}:{a:"open",overlay:{kind:"projects",form:"disk"}})};at([u==null?void 0:u.seq],()=>{var W,oe;if(!c||!u)return;t({a:"choosing-folder",v:!1});const q=u.folder;if(!q){(W=w.current)==null||W.focus();return}if(c==="open"){q.kind==="project"?V(q.path):D?ee(q.path):aT(B,q.path);return}if(y(q.kind==="project"?q.path:null),q.kind!=="project"){if(q.kind==="empty"&&!N){ee(q.path);return}t({a:"new-project-set",v:{mode:N?"clone":"create",parent:q.path}}),(oe=w.current)==null||oe.focus()}});const $=T?"the folder you chose becomes the project":g?null:I?`${M} already has a folder called ${A}`:R;return d.jsxs(vs,{anchor:"line",foot:d.jsx("div",{className:"composer view-foot",children:d.jsx(ku,{active:null,project:{name:A,why:Z,busy:!j,create:J}})}),children:[N&&d.jsxs("p",{className:"new-project-url",children:[e.url,e.branch&&d.jsxs("span",{className:"hint",children:[" on ",e.branch]})]}),d.jsxs("div",{className:"form-head",children:[T?d.jsx("p",{className:"form-title",children:_}):d.jsx(Bo,{ref:w,bare:!0,font:"lead",className:"new-project-field",autoFocus:!0,spellCheck:!1,autoComplete:"off",value:_,placeholder:"Project name",disabled:!j,style:{width:`${Math.max(_.length+1,_V)}ch`},onChange:q=>t({a:"new-project-set",v:{name:q.target.value}}),onKeyDown:q=>{q.key==="Enter"&&(q.preventDefault(),t({a:"focus-chat"}))}}),d.jsxs("span",{className:"new-project-where",children:[d.jsx("span",{className:"hint",children:"in"}),d.jsx("span",{className:"new-project-parent",...Lt(x),children:M}),d.jsx(At,{icon:"folder",label:s?"Choose in Finder":"Choose a folder",className:"new-project-folder",on:c==="location",disabled:!j,onClick:()=>F("location")})]})]}),$&&d.jsx("p",{className:"hint",children:$}),g&&d.jsxs("p",{className:"hint",children:["the folder you chose is already a project:"," ",d.jsx(Oe,{variant:"inline",autoFocus:!0,onClick:()=>V(g),children:"open it"}),", or choose another"]}),D&&d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"new-project-identity",children:[d.jsx(Bo,{size:"md",font:"ui",rule:!0,value:h.name,placeholder:"Your name",autoComplete:"name",disabled:!j,onChange:q=>m({...h,name:q.target.value})}),d.jsx(Bo,{size:"md",font:"ui",rule:!0,type:"email",value:h.email,placeholder:"Email",autoComplete:"email",disabled:!j,onChange:q=>m({...h,email:q.target.value})})]}),d.jsx("p",{className:"hint",children:"git labels the work you save with these, and asks only once"})]}),!N&&j&&d.jsx(Oe,{tone:"quiet",className:"new-project-open",onClick:()=>F("open"),children:"or open a folder you already have"})]})}function $l({label:e,hint:t,children:n}){return d.jsxs("label",{className:"form-row",children:[d.jsx("span",{className:"form-label",children:e}),d.jsxs("div",{className:"form-control",children:[n,t&&d.jsx("span",{className:"hint",children:t})]})]})}function jV(e,t,n,r){const o=[n.envUrl?`\`${n.envUrl.name}\` in \`${n.envUrl.file}\``:null,n.compose?`the compose stack in \`${n.compose}\``:null].filter(Boolean).join(" and "),s=r[0]??"api",a=r.length>0?`the shared command${r.length>1?"s":""} \`${r.join("`, `")}\``:"the command that serves the database";return[`Toyon runs several worktrees of this repo (${e.name}) at once, each with its own copy of the code, and right now they would all share ${o}: a migration run in one worktree changes the database every other worktree is using.`,"",`Give each worktree its own. Every command Toyon runs gets \`TOYON_WORKTREE\` (the worktree's id, empty in the main checkout) and \`TOYON_ROOT\` (the main checkout). A command's own \`setup\` and \`teardown\` run where that command runs: never on main, in a worktree once it runs its own, and nowhere while the worktree points the command at a remote. Edit \`${t}\` so that ${a} carries the recipe, in this shape:`,"```json",`{ "run": { "${s}": { "cmd": "<its command>", "setup": ["uv sync", "createdb -T app_template \\"app_$TOYON_WORKTREE\\""], "teardown": ["dropdb --if-exists \\"app_$TOYON_WORKTREE\\""] } } }`,"```",'- `setup` makes the worktree\'s own database with the same schema and seed data. Postgres refuses to copy a database with connections open, so copy from a template nothing serves: `createdb -T <db>_template "<db>_$TOYON_WORKTREE"`, making `<db>_template` once from the seed if it does not exist. Keep it seed-sized, since every worktree copies it. A hosted database that branches (the repo already uses one, or its README says so) gets a branch named for the worktree instead. A compose stack: bring it up under `-p "<name>_$TOYON_WORKTREE"` and seed it the way the README does.',"- `teardown` drops it again (`dropdb --if-exists ...`, the branch deleted, or `docker compose -p ... down -v`).","- the command points at it, with the base database on main: put the URL in front of `cmd`, named `<db>${TOYON_WORKTREE:+_$TOYON_WORKTREE}`. `setup` does not see what `cmd` sets, so a migration step in `setup` needs the URL in front of it too.",'- a database container every worktree shares (each with its own database inside it) is `{ "cmd": "docker compose up db", "paths": [] }` in `run`: main runs it once for everyone and no worktree ever runs its own.',"- the top-level `setup` is for the page: leave the install there and put what the backend needs under the backend's own `setup`.","","Read the README and the existing env files for the database's name and credentials. Do not run any migration yourself, and do not start any server; Toyon picks the file up as soon as it is written."].join(`
288
- `)}function TV(e,t){return[`This repo (${e.name}) has no Toyon settings yet, so Toyon does not know how to install its dependencies or start its dev server.`,"",`Work it out from the repo itself (package manager, scripts, framework, a README) and write \`${t}\` in this shape:`,"```json",'{ "setup": ["<install command>"], "run": { "web": "<start command>" } }',"```",'`setup` runs once in each new worktree. A worktree starts with the branch\'s files only: `node_modules` and the `.env` files are copied in for it, but any other gitignored file the project needs (a local database, a test cache such as `.testmondata`) is not, so add a `cp` from `$TOYON_ROOT`, the main checkout, when you find one in `.gitignore`. Never copy a virtualenv or another dependency tree that holds absolute paths; reinstall it instead. Every command in `run` must run in the foreground and listen on the port in the PORT environment variable, which Toyon sets per worktree; a tool that takes its port from a flag needs the flag (Vite: `--port $PORT --strictPort`, and with npm the `--` before it). Name one entry per server if there are several. If the project has nothing to run (a library, a CLI), write `"run": {}` and say so. Do not start any server yourself; toyon picks the file up as soon as it is written.'].join(`
289
- `)}const $V=[{id:"auto",label:"auto",chip:"shared: auto",description:"main runs it for every worktree when the command names a folder Toyon can watch; a worktree that changes it runs its own"},{id:"trunk",label:"always",chip:"shared: always",description:"main runs it for every worktree; a worktree that changes a folder the command names runs its own, and nothing flips a command that names none"},{id:"copy",label:"never",chip:"shared: never",description:"every worktree runs its own"}];function CV(e,t,n,r){var a;const o=r.config.run[e.trim()];if(o===void 0||hS(o)!==t.trim()||n==="copy")return null;const s=(a=r.tier)==null?void 0:a[e.trim()];return s&&s.paths.length>0?`main runs it; a worktree that changes ${s.paths.join(", ")} runs its own`:s||n==="trunk"?"main runs it for every worktree; no change here flips it":"every worktree runs its own: the command names nothing Toyon can watch"}let IV=1;const $h=(e,t,n="auto",r={})=>({id:IV++,name:e,cmd:t,from:n,rest:r});function AV(e,t){if(typeof t=="string")return $h(e,t);const{cmd:n,from:r,...o}=t;return $h(e,n,r??"auto",o)}const RV=[{id:"shared",label:"committed",description:"in the repo; everyone who opens it gets these settings"},{id:"local",label:"kept local",description:"in a file git never sees; for when only you use Toyon here"}];function OV({repo:e,onClose:t}){const n=Qe(),r=Dn(),o=L(K=>K.clientId),s=L(K=>K.rows.find(te=>{var pe;return Nn(te)&&te.id===((pe=Pi(K,e.id))==null?void 0:pe.id)})??null),a=L(K=>{var te;return((te=Pi(K,e.id))==null?void 0:te.id)??null});E.useEffect(()=>{if(!t)return;const K=te=>te.key==="Escape"&&t();return window.addEventListener("keydown",K),()=>window.removeEventListener("keydown",K)},[t]);const[c]=E.useState(()=>Object.keys(e.config.run).length>0),[u,f]=E.useState(()=>{const K=Object.entries(e.config.run).map(([te,pe])=>AV(te,pe));return K.length>0?K:[$h("web","")]}),[h,m]=E.useState(()=>(e.config.setup??[]).join(`
290
- `)),[g,y]=E.useState(()=>(e.config.teardown??[]).join(`
291
- `)),[w,v]=E.useState(()=>e.config.check??""),[_,x]=E.useState(()=>Ti(e.config).land),[N,T]=E.useState(()=>Ti(e.config).automerge),[j,A]=E.useState(()=>Ti(e.config).merge??"default"),[R,C]=E.useState(()=>DA(e.configFile)),M=zA(e.configFile,R),I=!!e.remote&&_==="pr",D=u.length>1,H=u.some(K=>K.name.trim()&&K.cmd.trim()),B=!!s&&!t&&!c&&!H,J=(K,te)=>f(u.map((pe,ue)=>ue===K?{...pe,...te}:pe)),V=K=>K.split(`
292
- `).map(te=>te.trim()).filter(Boolean),ee=()=>V(h),F=()=>V(g),$=()=>{const{check:K,land:te,teardown:pe,...ue}=e.config,ie=e.remote?_:qg,ye=j==="default"||ie!=="pr"&&j===Zg?void 0:j,Se={...ie!==qg?{route:ie}:{},...ie==="pr"&&N?{automerge:!0}:{},...ye?{method:ye}:{}};return{...ue,setup:ee(),...F().length>0?{teardown:F()}:{},...w.trim()?{check:w.trim()}:{},...Object.keys(Se).length>0?{land:Se}:{}}},Q=()=>{n==null||n.send({t:"confirm-config",repoId:e.id,config:{...$(),run:Object.fromEntries(u.filter(K=>K.name.trim()&&K.cmd.trim()).map((K,te)=>{const pe={...K.rest,cmd:K.cmd.trim(),...te>0&&K.from!=="auto"?{from:K.from}:{}};return[K.name.trim(),Object.keys(pe).length===1?pe.cmd:pe]}))},kind:R}),t==null||t()},q=()=>{n==null||n.send({t:"confirm-config",repoId:e.id,config:{...$(),run:{}},kind:R}),t==null||t()},W=()=>n==null?void 0:n.send({t:"create-worktree",clientId:o,repoId:e.id,prompt:TV(e,M)}),oe=e.services,de=[h,g,...u.flatMap(K=>[K.cmd,...K.rest.setup??[],...K.rest.teardown??[]])].some(K=>K.includes("TOYON_WORKTREE"))||LA(e.config),he=oe?[oe.envUrl?`the database at ${oe.envUrl.name} in ${oe.envUrl.file}`:null,oe.compose?`the stack in ${oe.compose}`:null].filter(Boolean).join(" and "):"",Ne=u.filter((K,te)=>te>0&&K.from!=="copy"&&K.name.trim()).map(K=>K.name.trim()),Me=()=>oe&&(n==null?void 0:n.send({t:"create-worktree",clientId:o,repoId:e.id,prompt:jV(e,M,oe,Ne)})),Be=(K,te)=>d.jsxs("div",{className:"setup-proc",children:[D&&d.jsx(Bo,{size:"md",rule:!0,className:"setup-name",value:K.name,placeholder:"name",...Lt("Process name, shown in the status bar"),onChange:pe=>J(te,{name:pe.target.value})}),d.jsx(Bo,{size:"md",rule:!0,className:"setup-cmd",value:K.cmd,placeholder:"npm run dev",onChange:pe=>J(te,{cmd:pe.target.value})}),D&&d.jsx(At,{icon:"close",label:"Remove",onClick:()=>f(u.filter((pe,ue)=>ue!==te))}),D&&te>0&&d.jsxs("div",{className:"setup-source",children:[d.jsx(Os,{value:K.from,options:$V,onChange:pe=>J(te,{from:pe}),hint:"whether main runs it once for every worktree",placeholder:"who runs it"}),(()=>{const pe=CV(K.name,K.cmd,K.from,e);return pe?d.jsx("span",{className:"hint setup-source-hint",children:pe}):null})()]})]},K.id);return d.jsxs(vs,{children:[d.jsxs("p",{className:"form-title",children:["how does ",e.name," start?"]}),oe&&!de&&d.jsxs("p",{className:"hint setup-shared-note",children:["Worktrees will share ",he,", migrations included."," ",d.jsx(Oe,{tone:"quiet",disabled:!s,onClick:Me,children:"ask the agent to keep them apart"})]}),d.jsx($l,{label:"install",hint:"once per new worktree; one command per line",children:d.jsx(Cu,{size:"md",rule:!0,rows:Math.max(1,h.split(`
293
- `).length),value:h,placeholder:"bun install",onChange:K=>m(K.target.value)})}),d.jsx($l,{label:"remove",hint:"once when a worktree goes, before its directory does; one command per line",children:d.jsx(Cu,{size:"md",rule:!0,rows:Math.max(1,g.split(`
294
- `).length),value:g,placeholder:'dropdb --if-exists "app_$TOYON_WORKTREE"',onChange:K=>y(K.target.value)})}),d.jsx($l,{label:"check",hint:"runs after each of the agent's turns; the work lands only when it passes",children:d.jsx(Bo,{size:"md",rule:!0,value:w,placeholder:"bun run check",onChange:K=>v(K.target.value)})}),e.remote&&d.jsx($l,{label:"land",hint:"where a worktree's finished work goes; one way per repo",children:d.jsxs("div",{className:"setup-land",children:[d.jsx(Os,{value:_,options:JA.map(K=>({id:K.id,label:K.name,description:K.description})),onChange:x,hint:"where the work goes",placeholder:"where work lands"}),I&&d.jsx(Os,{value:N?"github":"you",options:tR.map(K=>({id:K.id,label:K.name,description:K.description})),onChange:K=>T(K==="github"),hint:"who merges the pull request",placeholder:"who merges it"})]})}),d.jsx($l,{label:"merge",hint:I?"how GitHub merges the pull request; only what the repo allows":"how the commits arrive on main",children:d.jsx(Os,{value:j==="default"&&!I?Zg:j,options:[...I?[{id:"default",label:"what the repo allows",description:"the repo's allowed methods on GitHub: squash, else a merge commit, else rebase"}]:[],...eR.map(K=>({id:K.id,label:K.name,description:K.description}))],onChange:A,hint:"how the commits arrive on main",placeholder:"how the commits arrive"})}),d.jsx($l,{label:"start",hint:d.jsxs(d.Fragment,{children:["must listen on ",d.jsx("code",{...Lt("Toyon sets a different port for each worktree"),children:"$PORT"}),e.guess&&a&&d.jsxs(d.Fragment,{children:[" · from ",d.jsx(Oe,{mono:!0,tone:"quiet",...Lt(`open ${e.guess} in the editor pane`),onClick:()=>ja(r,n,a,e.guess??"",1),children:e.guess})]})]}),children:u[0]&&Be(u[0],0)}),u.slice(1).map((K,te)=>d.jsxs("div",{className:"form-row",children:[d.jsx("span",{className:"form-label"}),d.jsx("div",{className:"form-control",children:Be(K,te+1)})]},K.id)),!D&&d.jsxs("div",{className:"form-row",children:[d.jsx("span",{className:"form-label"}),d.jsx("span",{className:"hint setup-tier-hint",children:"one command: every worktree runs its own"})]}),d.jsxs("div",{className:"form-row",children:[d.jsx("span",{className:"form-label"}),d.jsxs(Oe,{tone:"quiet",onClick:()=>f([...u,$h("","")]),children:[d.jsx(kt,{name:"plus",className:"icon-inline"})," another process"]})]}),d.jsxs("div",{className:"form-knobs",children:[d.jsx(Os,{value:R,options:RV,onChange:C,hint:"whether the settings file is committed with the repo or kept out of git",placeholder:"committed or kept local"}),d.jsx("span",{className:"form-sign",children:M}),t&&d.jsx(Oe,{onClick:t,children:"cancel"}),(!c||t)&&d.jsx(Oe,{...Lt("This project has no dev server: chat, changes and the terminal work, the preview stays empty"),onClick:q,children:"no dev server"}),B&&s?d.jsx(Oe,{variant:"outline",size:"lg",disabled:s.agent!=="idle",...Lt("The agent reads the repo and writes the settings file; the daemon picks it up as soon as it lands"),onClick:W,children:"let the agent work it out"}):d.jsxs(Oe,{variant:"outline",size:"lg",disabled:!H,...t?Lt("Restarts every worktree of this repo. Other keys in the file are kept."):{},onClick:Q,children:[t?"save + restart":"start"," ",d.jsx(kt,{name:"forward",className:"icon-inline"})]})]})]})}function MV(e){return`${Math.round(e.w)} × ${Math.round(e.h)}`}function LV(e){return e.w>0&&e.h>0}function PV(e,t,n){E.useEffect(()=>{if(!e||!t){n(null);return}const r=new ResizeObserver(o=>{var c;const s=(c=o[o.length-1])==null?void 0:c.contentRect;if(!s)return;const a={w:s.width,h:s.height};n(LV(a)?MV(a):null)});return r.observe(e),()=>{r.disconnect(),n(null)}},[e,t,n])}const DV=1500,zV={set:(e,t)=>setTimeout(e,t),clear:e=>clearTimeout(e)};class FV{constructor(t,n,r=zV){jt(this,"frames",new Map);this.send=t,this.sendTitle=n,this.timers=r}note(t,n,r){const o=this.frame(t);o.timer!==null&&(this.timers.clear(o.timer),o.timer=null),o.pending=null,r!==void 0&&(o.title=Xb(r));const s=Zh(n);if(!s){o.sent=null;return}if(s===o.sent){this.renamed(t,o);return}o.pending=s,o.timer=this.timers.set(()=>{o.timer=null,o.pending=null,o.sent=s,o.sentTitle=o.title,this.send(t,s,o.title)},DV)}title(t,n){const r=this.frame(t);r.title=Xb(n),r.pending===null&&this.renamed(t,r)}dispose(){for(const t of this.frames.values())t.timer!==null&&this.timers.clear(t.timer);this.frames.clear()}frame(t){let n=this.frames.get(t);return n||(n={sent:null,pending:null,timer:null},this.frames.set(t,n)),n}renamed(t,n){!n.sent||!n.title||n.title===n.sentTitle||(n.sentTitle=n.title,this.sendTitle(t,n.sent,n.title))}}const BV=sh(),UV=2*6e4;function qE(e){e==null||e.setAttribute("src",e.src)}const HV=8e3;function WV(e,t){try{const n=new URL(e,t);return n.origin===new URL(t).origin?n.href:null}catch{return null}}function KV({onRoot:e}){const t=E.useRef(null),n=E.useCallback(ae=>{t.current=ae,e(ae)},[e]),r=dt(),o=Dn(),s=Qe(),a=E.useRef(s);a.current=s;const[c]=E.useState(()=>new FV((ae,_e,ht)=>{var ct,zt;(ct=a.current)==null||ct.send({t:"visit",worktreeId:ae,path:_e,title:ht}),O_((zt=o.getState().local[ae])==null?void 0:zt.pages)&&un.post(ae,{type:"links"})},(ae,_e,ht)=>{var ct;return(ct=a.current)==null?void 0:ct.send({t:"page-title",worktreeId:ae,path:_e,title:ht})}));E.useEffect(()=>()=>c.dispose(),[c]);const u=EN(),f=ac(),h=Us(),m=L(ae=>ae.connected),g=L(ae=>ae.heard),y=L(ae=>ae.recalledAt!==null),w=L(ae=>ae.connectFailure),v=L(ae=>ae.remote),{host:_}=Lr(),x=Bs(),N=ys(),T=L(ae=>ae.editor),j=_N(),A=_3(),R=L(ae=>ae.notesPage),C=Wu(),M=L(ae=>ae.layout.term)&&!C,I=L(ae=>ae.focusTerm),D=E.useRef(!1),H=E.useRef(I),Z=!D.current||I!==H.current;E.useEffect(()=>{D.current=M&&!!f,H.current=I});const B=Ku(),J=L(ae=>ae.layout.design)&&!C&&!B,V=L(ae=>ae.reloadReq),ee=op(),F=E.useRef(ee);F.current=ee;const $=L(ae=>ae.zen),Q=L(ae=>{var _e;return((_e=ae.dragFiles)==null?void 0:_e.at)==="centre"}),q=E.useRef($);q.current=$;const W=It(f,"log"),oe=L(ae=>ae.incompatible),de=j3(),he=L(ae=>{var _e;return((_e=ae.overlay)==null?void 0:_e.kind)==="setup"?ae.repos.find(ht=>ht.id===ae.overlay.repoId)??null:null}),Ne=(h==null?void 0:h.worktree.empty)===!0,Me=ss(h==null?void 0:h.agent),Be=de&&!Ne&&!Me?de:null,K=Be??he,te=L(ae=>ae.pending.find(_e=>_e.id===ae.activeImportId)??null),[pe,ue]=E.useState([]),ie=E.useMemo(()=>pe.map(ae=>ae.id),[pe]),ye=E.useRef(new Map),Se=E.useRef(new Map),[Ee,Le]=E.useState([]),Ue=E.useRef(new Set),Je=E.useRef(new Set),Ht=E.useRef(ae=>qE(ye.current.get(ae)));E.useEffect(()=>{un.post=(ae,_e)=>{var ht,ct;if(_e.type==="reload"&&Ue.current.has(ae))return Ht.current(ae);(ct=(ht=ye.current.get(ae))==null?void 0:ht.contentWindow)==null||ct.postMessage({__toyon:!0,..._e},Se.current.get(ae)??"*")},un.broadcast=ae=>{var _e;for(const[ht,ct]of ye.current)(_e=ct.contentWindow)==null||_e.postMessage({__toyon:!0,...ae},Se.current.get(ht)??"*")}},[]),E.useEffect(()=>{let ae=null;const _e=zt=>{zt.target instanceof HTMLElement&&zt.target.tagName!=="IFRAME"&&(ae=zt.target)},ht=zt=>{zt.relatedTarget===null&&setTimeout(()=>{document.activeElement===document.body&&(ae=null)},0)},ct=zt=>{var kn,Pr,cr,ln,ur;if((kn=zt.data)!=null&&kn.__toyon)for(const[nn,Bt]of ye.current){if(Bt.contentWindow!==zt.source)continue;if(zt.origin!==Se.current.get(nn))return;const Ft=a_(zt.data);if(!Ft)return;switch(Ft.type){case"key":window.dispatchEvent(new KeyboardEvent(Ft.up?"keyup":"keydown",{key:Ft.key,code:Ft.code,metaKey:Ft.meta,ctrlKey:!!Ft.ctrl,shiftKey:!!Ft.shift,altKey:!!Ft.alt}));break;case"hmr":r({a:"hmr",id:nn}),(Pr=a.current)==null||Pr.send({t:"page-loaded",worktreeId:nn});break;case"loaded":Ue.current.delete(nn),Je.current.add(nn),Le(be=>be.includes(nn)?be:[...be,nn]),un.post(nn,PC(F.current)),un.post(nn,{type:"zen",on:q.current}),r({a:"hmr",id:nn}),r({a:"page",id:nn,url:Ft.url,title:Ft.title}),(cr=a.current)==null||cr.send({t:"page-loaded",worktreeId:nn}),c.note(nn,Ft.url,Ft.title);break;case"navigated":r({a:"page",id:nn,url:Ft.url,...Ft.title!==void 0?{title:Ft.title}:{}}),c.note(nn,Ft.url,Ft.title);break;case"title":r({a:"page",id:nn,title:Ft.title}),c.title(nn,Ft.title);break;case"links":r({a:"links",id:nn,links:Ft.links});break;case"page-error":{const be=M4(Ft);be&&((ln=a.current)==null||ln.send({t:"page-error",worktreeId:nn,message:be}));break}case"picked":{const{type:be,verb:Ye,site:wt,...yt}=Ft,cn=wt==="call"?{file:yt.callFile,line:yt.callLine}:{file:yt.file,line:yt.line};if(Ye==="code"){r({a:"set-picking",v:!1});const hn=(ur=Kt(o.getState(),nn))==null?void 0:ur.worktree;cn.file?ja(o,s,nn,j_(cn.file,hn==null?void 0:hn.path),cn.line??1):s==null||s.send({t:"find-element",worktreeId:nn,seq:_o(),element:yt.element})}else c6(o,nn,yt);break}case"pick-cancel":r({a:"set-picking",v:!1});break;case"drag-files":Ft.over?hy(o,o.getState().activeId?{at:"centre"}:null):XN(o);break;case"drop-files":tj(o,s,o.getState().activeId?{at:"centre"}:null,Z6(Ft.files));break;case"focus":Ft.gesture?ae=null:document.activeElement===Bt&&(ae!=null&&ae.isConnected)&&ae!==document.body&&ae.focus();break;case"highlight-miss":console.warn(`[toyon] highlight miss on ${Ft.path}: ${Ft.fileMatched} elements from this file, ${Ft.withSource} elements with source info on page, ranges=${JSON.stringify(Ft.ranges)}`);break}return}};return window.addEventListener("message",ct),document.addEventListener("focusin",_e),document.addEventListener("focusout",ht),()=>{window.removeEventListener("message",ct),document.removeEventListener("focusin",_e),document.removeEventListener("focusout",ht)}},[r,o,s,c]),E.useEffect(()=>{un.broadcast({type:"zen",on:$})},[$]);const qt=E.useRef(new Map);at([V==null?void 0:V.id,V==null?void 0:V.n],()=>{if(!V)return;const{id:ae}=V;clearTimeout(qt.current.get(ae)),qt.current.set(ae,setTimeout(()=>{qt.current.delete(ae),un.post(ae,{type:"reload"})},1200))});const xt=ny(),Ze=xt&&!Nn(xt)?xt:null,_t=za(),mt=!!h&&h.procs.some(ae=>ae.status==="running"),De=sy(),nt=De!==null&&De===f&&mt;E.useEffect(()=>{var ae;if(De&&nt&&!ie.includes(De)){const _e=KE((ae=o.getState().local[De])==null?void 0:ae.page.url);ue(ht=>[...ht,{id:De,path:_e}])}},[De,nt,ie,o]);const lt=u.filter(ae=>Nn(ae)&&ae.procs.some(_e=>_e.status==="asleep")).map(ae=>ae.id).join(" ");E.useEffect(()=>{const ae=new Set(lt.split(" ").filter(Boolean));ie.some(_e=>ae.has(_e))&&ue(_e=>_e.filter(ht=>!ae.has(ht.id)))},[lt,ie]);const Yt=ie.join(" ");E.useEffect(()=>{const ae=Yt.split(" ").filter(_e=>_e&&_e!==De).map(_e=>setTimeout(()=>ue(ht=>ht.filter(ct=>ct.id!==_e)),UV));return()=>{for(const _e of ae)clearTimeout(_e)}},[Yt,De]),E.useEffect(()=>{Le(ae=>ae.every(_e=>ie.includes(_e))?ae:ae.filter(_e=>ie.includes(_e)))},[ie]);const $n=E.useMemo(()=>u.filter(Nn).flatMap(ae=>{const _e=pe.find(ct=>ct.id===ae.id);if(!_e)return[];const ht=N_(ae.worktree.id,ae.worktree.proxyPort,v,_);return[{id:ae.worktree.id,port:ae.worktree.proxyPort,title:ae.worktree.title,url:WV(_e.path,ht)??ht}]}),[u,pe,v,_]),gt=bk(x,v),rt=aj(x,$n,gt);Ht.current=ae=>{var ht;const _e=KE((ht=o.getState().local[ae])==null?void 0:ht.page.url);if(pe.some(ct=>ct.id===ae&&ct.path!==_e)){ue(ct=>ct.map(zt=>zt.id===ae?{...zt,path:_e}:zt));return}gt?rt.renew(ae):qE(ye.current.get(ae))};const Kn=$n.filter(ae=>{var _e;return(_e=u.find(ht=>ht.id===ae.id))==null?void 0:_e.procs.some(ht=>ht.status==="running")}).map(ae=>ae.id).join(" ");at([Kn],()=>{for(const ae of Kn.split(" "))Ue.current.has(ae)&&Ht.current(ae)});const Qt=L(ae=>ae.carryTo),[Cn,qn]=E.useState(null),[dn,yn]=E.useState(De),ne=E.useRef(null);dn!==De&&(yn(De),qn(yV({leaving:ne.current,arriving:De,carryTo:Qt,repoOf:ae=>{var _e;return((_e=u.find(ht=>ht.id===ae))==null?void 0:_e.repoId)??null}}))),E.useEffect(()=>{if(!Cn)return;const ae=setTimeout(()=>qn(null),HV);return()=>clearTimeout(ae)},[Cn]);const we=De!==null&&Ee.includes(De),qe=vV({previewId:De,painted:we,ready:nt,carry:Cn,mounted:ie}),ot=qe!==null&&qe!==De;E.useEffect(()=>{ne.current=qe});const Tt=qe!==null&&!K&&!te&&!R&&!C&&!B,[Dt,P]=E.useState(null),se=E.useCallback(ae=>r({a:"preview-size",text:ae}),[r]);PV(Dt,Tt,se);const[je,Fe]=ps(tt.editorHeight,0,ae=>{const _e=Number(ae);return Number.isFinite(_e)&&_e>=120?_e:0}),[Rt,Zt]=ps(tt.designHeight,0,ae=>{const _e=Number(ae);return Number.isFinite(_e)&&_e>0?_e:0}),[Ae,We]=ps(tt.designFull,!1,ae=>ae===null?void 0:ae==="1"),[Ve,Xt]=ps(tt.editorFull,!1,ae=>ae===null?void 0:ae==="1"),[Wt,bn]=ps(tt.termHeight,240,ae=>{const _e=Number(ae);return Number.isFinite(_e)&&_e>=140?_e:void 0}),xn=L(ae=>ae.termTall);at([xn],()=>{const ae=t.current;xn&&ae&&bn(Math.max(Wt,Math.round(ae.clientHeight/2)))});const Ct=ae=>(_e,ht)=>{const ct=ht.parentElement,zt=t.current;if(!ct||!zt)return null;let kn=0;for(const cr of Array.from(zt.querySelectorAll(":scope > .pane")))cr!==ct&&!cr.classList.contains("full")&&(kn+=cr.offsetHeight);const Pr=Math.max(zt.clientHeight-kn-80,ae);return Math.min(Math.max(ct.getBoundingClientRect().bottom-_e.clientY,ae),Pr)},Jt=Hl(Ct(120),ae=>Fe(Math.round(ae))),sr=Hl(Ct(160),ae=>Zt(Math.round(ae))),Gt=Hl(Ct(140),ae=>bn(Math.round(ae))),Rn=L(ae=>{var _e,ht;return h&&Cr(h.worktree)?((ht=(_e=ae.rows.find(ct=>{var zt;return ct.repoId===h.worktree.repoId&&((zt=ct.worktree)==null?void 0:zt.kind)==="worktree"}))==null?void 0:_e.worktree)==null?void 0:ht.title)??null:null}),fn=eF({connected:m,heard:g,standing:y,connectFailure:w,hasToken:x.serving?BV:!0,projectChord:Pt("project"),title:(h==null?void 0:h.worktree.title)??null,machine:x.serving?null:N.displayName(x.origin),needsSetup:!!de,busy:Me,treeEmpty:Ne,landsFrom:Rn});return d.jsxs("div",{className:"center-root",ref:n,children:[d.jsx("div",{className:Ke("center-area",Q&&"drop-over"),style:{display:!($&&!B)&&!_t&&!R&&(T&&Ve||J&&Ae)?"none":void 0},children:d.jsxs("div",{className:"frames-wrap",ref:P,children:[$n.map(ae=>d.jsx("iframe",{ref:_e=>{_e?(ye.current.set(ae.id,_e),Se.current.set(ae.id,new URL(ae.url).origin)):(ye.current.delete(ae.id),Se.current.delete(ae.id),Ue.current.delete(ae.id),Je.current.delete(ae.id))},onLoad:()=>{Je.current.delete(ae.id)?Ue.current.delete(ae.id):Ue.current.add(ae.id)},src:rt.urlOf(ae.id)??void 0,title:ae.title,style:{display:Tt&&ae.id===qe?"block":"none"}},ae.id)),A?d.jsx(NV,{project:A}):R?d.jsx(PG,{}):d.jsxs(d.Fragment,{children:[te&&d.jsx(xV,{pending:te},te.id),j&&h&&!te&&d.jsx(bV,{active:h},h.worktree.id),K&&!te&&!j&&d.jsx(OV,{repo:K,onClose:Be?void 0:()=>r({a:"close"})},`${K.id}:${JSON.stringify(K.config)}`),Ze&&!K&&!te&&!_t&&d.jsx(wu,{placement:"centre",found:Ze},Ze.id),_t&&!K&&!te&&d.jsx(wu,{placement:"centre",archived:_t},_t.id),!mt&&!Ze&&!_t&&!K&&!te&&!j&&oe&&d.jsx(yj,{foreign:x.serving?void 0:N.displayName(x.origin)}),!mt&&!Ze&&!_t&&!K&&!te&&!j&&!oe&&(fn!==null?d.jsx(vs,{wide:!0,children:d.jsx("p",{className:Ke("status-line",fn.live&&"live-text"),children:fn.text})}):B?d.jsx(wu,{placement:"centre"}):ot?null:h&&d.jsx(kV,{worktree:h,log:W}))]})]})}),T&&d.jsx(xC,{editor:T,height:Ve?"100%":je>0?je:"45%",full:Ve,onToggleFull:()=>Xt(!Ve),onDragStart:Jt}),J&&f&&!_t&&!R&&d.jsx(FG,{worktreeId:f,height:Ae?"100%":Rt>0?Rt:"55%",full:Ae,onToggleFull:()=>We(!Ae),onDragStart:sr},`design:${f}`),M&&f&&!_t&&!R&&d.jsx(pV,{worktreeId:f,opened:Z,height:Wt,onDragStart:Gt},`term:${f}`),d.jsx(TC,{})]})}function qV({width:e}){const t=L(r=>r.layout.chat),n=Wu();return d.jsx(wu,{placement:"dock",className:!t||n?"collapsed":void 0,width:e})}function ZV(e,t){const n=[];return e&&(n.push(IN(e)),n.push({id:"copy-url",label:"copy URL",onClick:()=>tn(e)})),Wn([n,[{id:"reload",label:"reload preview",key:Pt("reload"),onClick:t.reload}]])}const GV=520,Ug=8;function VV({winW:e,centre:t,leadRight:n,toolsLeft:r}){const o=t.right-t.left,s=Math.max(0,Math.min(GV,Math.floor(e*.4),o-2*Ug)),a=t.left+(o-s)/2,c=n+Ug,u=r-Ug-s,f=Math.max(Math.min(a,u),c);return{left:Math.round(f),width:s}}function YV({center:e}){const t=r3(),n=wN(e),r=E.useRef(null);p3(r);const o=m5(),[s,a]=yx(),[c,u]=yx(),f=VV({winW:t,centre:n,leadRight:a.right,toolsLeft:u.left}),h=dt(),m=Qe(),g=Dn(),y=vn("bar"),w=Us(),v=Ku(),_=L(F=>F.zen)&&!v,x=L(F=>F.layout.changes),N=L(F=>F.layout.chat),T=Wu(),j=L(F=>F.layout.design),A=L(F=>{var $;return(($=F.overlay)==null?void 0:$.kind)==="keys"}),R=U$(),C=(w==null?void 0:w.worktree.id)??null,M=L(F=>F.archivedPage!==null||F.notesPage),I=!!w&&np(w)&&!M,D=L(F=>F.chatSide)==="left",H={tipAlign:"start"},Z={tipAlign:"end"},B=!T&&d.jsx(At,{icon:"branch",label:"Changes panel",hint:Pt("changes"),tone:"chrome",on:x,...D?Z:H,onClick:()=>h({a:"toggle-changes"})}),J=!T&&!v&&d.jsx(At,{icon:"chat",label:"Chat panel",hint:Pt("composer"),tone:"chrome",on:N,...D?H:Z,onClick:()=>h({a:"toggle-chat"})}),V=L(F=>F.railOpen),ee=!T&&d.jsx(At,{icon:"worktrees",label:"Worktree panel",hint:Pt("rail"),tone:"chrome",on:V,...D?H:Z,onClick:()=>h({a:"toggle-rail"})});return d.jsxs("div",{className:"top-bar",ref:r,"data-float-up":o||void 0,children:[_&&d.jsx("span",{className:"bar-zen-title",children:(w==null?void 0:w.worktree.title)??"Toyon"}),d.jsxs("span",{className:"bar-lead",ref:s,children:[D?ee:B,D&&J,d.jsx(XV,{}),R&&d.jsx(nd,{icon:"download","data-tip":"Install Toyon as an app (own window, dock icon)",onClick:()=>void R.prompt(),children:"install app"}),d.jsx(JV,{}),d.jsx(eY,{}),d.jsx(tY,{})]}),!v&&d.jsx(QV,{worktreeId:C,repoId:(w==null?void 0:w.repoId)??null,ready:I,left:f.left,width:f.width}),d.jsx("span",{className:"bar-grow"}),d.jsxs("span",{className:"bar-tools",ref:c,children:[d.jsx(nY,{}),d.jsx(At,{icon:"settings",label:"Settings & shortcuts",hint:Pt("keys"),tone:"chrome",on:A,...Z,"aria-controls":"keys-help","aria-expanded":A,onClick:()=>h({a:"toggle",overlay:{kind:"keys"}}),...y.contextMenu(()=>lT(g.getState(),{sock:m,dispatch:h}))}),!T&&!v&&d.jsx(At,{icon:"palette",label:"Design system",hint:Pt("design"),tone:"chrome",on:j,...Z,onClick:()=>h({a:"toggle-design"})}),D?B:J,!D&&ee,!v&&d.jsx(At,{icon:"zen",className:"bar-zen",label:"Full-bleed preview",hint:Pt("zen"),tone:"chrome",on:_,...Z,onClick:()=>h({a:"toggle-zen"})})]})]})}function XV(){const e=dt(),t=Qe(),n=lc(),r=L(m=>m.activeRepoId),o=L(m=>m.rows),s=L(m=>m.repos),a=vn("bar"),c=()=>Wn([[{id:"project",label:s.length>1?"switch project…":"open project…",key:Pt("project"),onClick:()=>e({a:"open",overlay:{kind:"projects",form:"pill"}})},{id:"project-disk",label:"find a project on disk…",onClick:()=>e({a:"open",overlay:{kind:"projects",form:"disk"}})}],n?gp(n,r,{sock:t,dispatch:e},o):[]]),u=L(m=>{var g;return((g=m.overlay)==null?void 0:g.kind)==="projects"&&m.overlay.form==="pill"}),f=L(m=>m.heard),h=L(m=>m.newProject!==null);return d.jsxs("span",{className:"bar-project",children:[d.jsx(Oe,{tone:"chrome",className:"bar-pill",on:u,...Lt(s.length>1?"Switch project":"Open a project",Pt("project")),onClick:()=>e({a:"toggle",overlay:{kind:"projects",form:"pill"}}),...a.contextMenu(c),children:d.jsx("span",{className:"bar-project-name",children:h?"new project":(n==null?void 0:n.name)??(f?"open project":"")})}),u&&d.jsx(lv,{form:"pill"})]})}function QV({worktreeId:e,repoId:t,ready:n,left:r,width:o}){const s=It(e,"page").url,a=dt(),c=L(y=>{var w;return((w=y.overlay)==null?void 0:w.kind)==="routes"}),u=L(y=>y.previewSize);at([e,n],()=>{c&&a({a:"close"})});const h=vn("bar").contextMenu(()=>n?ZV(s,{reload:()=>e&&un.post(e,{type:"reload"})}):[]),m=L(y=>y.picking),g=sy();return d.jsxs("div",{className:"bar-center",style:{left:r,width:o},children:[d.jsx(At,{icon:"back",label:"Back",hint:Pt("back"),disabled:!n,onClick:()=>e&&un.post(e,{type:"back"}),...h}),d.jsx(At,{icon:"forward",label:"Forward",hint:Pt("forward"),disabled:!n,onClick:()=>e&&un.post(e,{type:"forward"}),...h}),d.jsx(At,{icon:"reload",label:"Reload preview",hint:Pt("reload"),disabled:!n,onClick:()=>e&&un.post(e,{type:"reload"}),...h}),d.jsxs("span",{className:"bar-route",children:[n&&e&&t?d.jsx(pK,{worktreeId:e,repoId:t,url:s,open:c},e):d.jsx(Bo,{className:"bar-path",value:"",readOnly:!0,disabled:!0}),u&&d.jsx("span",{className:"bar-size",children:u})]}),d.jsx(At,{icon:"inspect",label:"Pick an element to open its code",hint:Pt("inspect"),also:{text:"Add an element to chat",key:Pt("pick")},on:m==="code",disabled:!n||!g,onClick:()=>g&&Tu(g,m,a,"code")})]})}function nd({icon:e,busy:t,children:n,...r}){return d.jsxs(Oe,{disabled:t,...r,children:[!t&&d.jsx(kt,{name:e,className:"icon-inline"}),d.jsx("span",{className:Ke(t&&"live-text"),children:n})]})}function JV(){const e=L(u=>u.self),t=L(u=>u.rebuilt),n=L(u=>u.repos),r=Qe(),o=L(u=>{var f;return((f=u.update)==null?void 0:f.restarting)!=null}),s=EC(e,n,t);if(!s||o)return null;const a=s.busy?"rebuilding":s.reload?"reload Toyon":s.build==="rebuild"?"rebuild Toyon":s.build??"restart Toyon",c=()=>{s.reload?window.location.reload():e&&(r==null||r.send(s.build?{t:"run-after-land",repoId:e.repoId}:{t:"restart-daemon"}))};return d.jsx(nd,{icon:"reload",busy:s.busy,onClick:c,...Lt(s.text,void 0,{detail:s.detail}),children:a})}function eY(){const e=L(o=>o.update),t=L(o=>o.managed.updates),n=Qe(),r=q5(e);return!r||!t?null:d.jsx(nd,{icon:"reload",busy:r.busy,onClick:()=>{r.retry&&(n==null||n.send({t:"update-now"}))},...Lt(r.text),children:r.word})}function tY(){const e=dt(),t=L(bz),n=L(a=>a.ranBefore),r=L(a=>a.newProject!==null);if(!t||!n||r)return null;const{word:o,text:s}=LG(n,t);return d.jsx(nd,{icon:"book",onClick:()=>e({a:"open-release-notes"}),...Lt(s),children:o})}function nY(){const e=dt(),t=L(Lz),n=L(s=>s.letIn),r=L(s=>{var a;return((a=s.overlay)==null?void 0:a.kind)==="devices"});if(!t)return null;const o=()=>e({a:"toggle",overlay:{kind:"devices"}});return n?d.jsx(At,{icon:"devices",label:"Your devices",tone:"chrome",on:r,tipAlign:"end","aria-expanded":r,onClick:o}):d.jsx(nd,{icon:"devices","aria-expanded":r,onClick:o,...Lt("Open this machine on your phone, and let it in"),children:"open on phone"})}function rY(e,t,n){return t==="left"?n-e.left:e.right-n}const oY="input, textarea, [contenteditable], .monaco-editor, .xterm, iframe";function sY(){const e=Dn(),t=dt(),n=Qe(),r=Wu(),o=Bi(),s=Ku(),a=L(Q=>Q.zen)&&!s,c=za(),u=L(Q=>Q.notesPage),f=!!oy()||!!c||u,h=L(Q=>Q.layout.changes)&&!r,m=L(Q=>Q.layout.chat)&&!r&&!s&&!f,g=L(Q=>Q.chatSide),y=L(Q=>Q.railOpen),[w,v]=ps(tt.changesWidth,220,Q=>Q?bf(Number(Q),220):void 0),[_,x]=ps(tt.chatWidth,380,Q=>Q?bf(Number(Q),380):void 0),[N,T]=ps(tt.railWidth,280,Q=>Q?bf(Number(Q),280):void 0),j=(Q,q,W)=>{const oe=q.classList.contains("left")?"left":"right",de=oe==="left"?q.previousElementSibling:q.nextElementSibling;return de?bf(rY(de.getBoundingClientRect(),oe,Q.clientX),W):null},A=Hl((Q,q)=>j(Q,q,220),v),R=Hl((Q,q)=>j(Q,q,380),x),C=Hl((Q,q)=>j(Q,q,280),T),[M,I]=E.useState(null),H=vn("app").contextMenu(()=>sT(e.getState(),{sock:n,dispatch:t})),Z=d.jsx(Wj,{width:w}),B=!s&&!f&&d.jsx(qV,{width:_}),J=!r&&d.jsx(RC,{width:N}),V=Q=>!r&&y&&d.jsx("div",{className:`dock-resize ${Q}`,onPointerDown:C}),ee=g==="left",F=ee?{dock:B,open:m,drag:R}:{dock:Z,open:h,drag:A},$=ee?{dock:Z,open:h,drag:A}:{dock:B,open:m,drag:R};return d.jsxs("div",{className:Ke("app",a&&"zen"),"data-chat-side":g,"data-touch":o||void 0,"data-hover":!o||void 0,onContextMenu:Q=>{Q.defaultPrevented||Q.target instanceof Element&&Q.target.closest(oY)||H.onContextMenu(Q)},children:[d.jsx(cj,{}),d.jsx(hj,{}),d.jsx(YV,{center:M}),d.jsxs("div",{className:"docks",children:[ee&&J,ee&&V("left"),F.dock,F.open&&d.jsx("div",{className:"dock-resize left",onPointerDown:F.drag}),d.jsx(KV,{onRoot:I}),$.open&&d.jsx("div",{className:"dock-resize right",onPointerDown:$.drag}),$.dock,!ee&&V("right"),!ee&&J]})]})}function iY(e,t,n,r){if(!n)return null;const o=e.findIndex(u=>u.id===n);if(o>=0){const u=e[(o+r+e.length)%e.length];return u&&u.id!==n?{activate:u.id}:null}const s=t.findIndex(u=>u.id===n);if(s<0)return null;const a=t[s+r];if(a)return{activate:a.id};const c=e[e.length-1];return r<0&&c?{activate:c.id}:null}const aY=new Set(["design","chats"]),lY=new Set(["back","forward"]),cY=new Set(["wt-back","wt-forward"]),uY=new Set(["project","commands","keys","zen"]);function dY(){const e=Dn(),t=Qe();E.useEffect(()=>{const n=hG(m=>e.dispatch({a:"rail-peek",on:m})),r=n.end,o=m=>{e.getState().railOpen||n.press(m)},s=fG(),a=m=>{n.keyup(m.key),s.keyup(m.key)},c=m=>{n.mods(m),s.mods(m)},u=()=>{var w,v;const m=e.getState(),y=((v=(w=document.activeElement)==null?void 0:w.closest("[data-pane]"))==null?void 0:v.dataset.pane)??(m.layout.term?"terminal":m.editor?"editor":m.layout.design?"design":null);y==="terminal"?e.dispatch({a:"toggle-terminal"}):y==="editor"?e.dispatch({a:"close-editor"}):y==="design"&&e.dispatch({a:"toggle-design"})},f=m=>{m.key!=="Escape"||!e.getState().choosingFolder||(m.stopImmediatePropagation(),t==null||t.send({t:"cancel-folder"}),e.dispatch({a:"choosing-folder",v:!1}))},h=m=>{var j,A,R,C;c(m),xA(m)&&!m.defaultPrevented&&m.preventDefault();const g=e.getState(),{dispatch:y}=e,w=(M,I={a:"activate",id:M})=>{const D=document.activeElement,H=!D||D===document.body||!!D.closest(".rail, .chat-input");y(I),H&&y({a:"walked"})},v=dS(m,{guest:!!((j=document.activeElement)!=null&&j.closest(".xterm"))}),_=g.zen&&!No(g),x=_?bA(v):v;if(_&&!g.overlay&&!g.picking&&!(x&&yA.has(x.id))||(x==null?void 0:x.id)==="close"&&!Bw()||!!((A=document.activeElement)!=null&&A.closest(".monaco-editor"))&&x&&aY.has(x.id))return;const T=x&&cY.has(x.id)&&s.holds(m);if(!(x&&!T&&jA(x.id,document.activeElement))&&!(x&&lY.has(x.id)&&!(Ll(g)&&Su(g)))&&!((x==null?void 0:x.id)==="reload"&&!ck(g))){if(x){const M=m.defaultPrevented;if(m.preventDefault(),g.newProject&&!uY.has(x.id))return;switch(x.id){case"worktree":{const I=SA(x.digit,g.visible.length),D=I===null?void 0:g.visible[I];D&&w(D.id);break}case"wt-prev":case"wt-next":{const I=iY(g.visible,g.visibleDiscovered,g.activeId,x.id==="wt-next"?1:-1);I&&w(I.activate),o(m);break}case"wt-unseen-prev":case"wt-unseen-next":{const I=Sy(g.visible,g.activeId,x.id==="wt-unseen-next"?1:-1);I&&w(I.activate),o(m);break}case"wt-back":case"wt-forward":{const I=new Set(g.rows.map(H=>H.id)),D=az(g.viewed,I,g.activeId,x.id==="wt-forward"?1:-1);D&&(w(D.activate,{a:"viewed-land",at:D.at}),s.press(m)),o(m);break}case"mark-unread":g.activeId&&!g.draft&&g.visible.some(I=>I.id===g.activeId)&&Tj(t,y,g.activeId);break;case"wt-archive":{if(m.repeat||M)break;const I=g.draft||g.archivedPage?void 0:g.visible.find(D=>D.id===g.activeId);I&&$j(t,y,D=>qw(g,D)).archive(I);break}case"new":y({a:"open-draft"});break;case"project":y({a:"toggle",overlay:{kind:"projects",form:"center"}});break;case"quick-open":((R=g.overlay)==null?void 0:R.kind)==="quick-open"?y({a:"close"}):g.activeId&&y({a:"open",overlay:{kind:"quick-open"}});break;case"routes":((C=g.overlay)==null?void 0:C.kind)==="routes"?y({a:"close"}):Su(g)&&y({a:"open",overlay:{kind:"routes"}});break;case"reload":{const I=ck(g);if(!I)break;I.act==="frame"?un.post(I.id,{type:"reload"}):t==null||t.send({t:"preview-start",worktreeId:I.id});break}case"back":case"forward":{const I=Ll(g);I&&un.post(I,{type:x.id});break}case"pick":case"inspect":{const I=Ll(g);I&&Tu(I,g.picking,y,x.id==="pick"?"chat":"code");break}case"search":g.activeId&&y({a:"toggle",overlay:{kind:"search"}});break;case"refs":g.activeRepoId&&y({a:"toggle",overlay:{kind:"refs"}});break;case"chats":g.activeRepoId&&y({a:"toggle",overlay:{kind:"chats"}});break;case"commands":y({a:"toggle",overlay:{kind:"commands"}});break;case"zen":y({a:"toggle-zen"});break;case"close":!(g.zen&&!No(g))&&!g.overlay&&u();break;case"changes":y(g.layout.changes&&(Jl(g)==="changes"||Uo(g)!==null)?{a:"toggle-changes"}:{a:"focus-changes",tab:"changes"});break;case"files":y(g.layout.changes&&Jl(g)==="files"?{a:"toggle-changes"}:{a:"focus-changes",tab:"files"});break;case"panel-tab-prev":case"panel-tab-next":if(tp(g))break;y(g.layout.changes?{a:"focus-changes",tab:vz(g,x.id==="panel-tab-next"?1:-1)}:{a:"focus-changes"});break;case"composer":y(H_(g));break;case"rail":y(g.railOpen?{a:"toggle-rail"}:{a:"focus-rail"});break;case"keys":y({a:"toggle",overlay:{kind:"keys"}});break;case"terminal":y(g.layout.term?{a:"toggle-terminal"}:{a:"focus-terminal"});break;case"design":y({a:"toggle-design"});break;case"term-tab":{const I=g.rows.find(B=>B.id===g.activeId);if(!I)break;const D=Mr(g,g.activeId).termStream;if(I.login&&D===Ds)break;const H=[zo,...I.login?[Ds]:[],...I.procs.map(B=>B.name)],Z=H.indexOf(D);y({a:"term-stream",id:I.id,stream:H[(Z+1)%H.length]??zo});break}}}else if(m.key==="Escape")if(g.newProject)g.newProject.phase==="editing"&&y({a:"close-new-project"});else if(g.picking){const M=Ll(g);M&&un.post(M,{type:"pick-cancel"}),y({a:"set-picking",v:!1})}else g.notesPage?y({a:"close-release-notes"}):g.archivedPage?y({a:"close-archived"}):g.activeImportId?y({a:"watch-import",id:null}):u()}};return window.addEventListener("keydown",f,!0),window.addEventListener("keydown",h),window.addEventListener("keyup",a),window.addEventListener("pointermove",c),window.addEventListener("pointerdown",c),window.addEventListener("blur",r),()=>{window.removeEventListener("keydown",f,!0),window.removeEventListener("keydown",h),window.removeEventListener("keyup",a),window.removeEventListener("pointermove",c),window.removeEventListener("pointerdown",c),window.removeEventListener("blur",r),r()}},[e,t]),E.useEffect(()=>{const n=r=>{if(r.key!=="Alt"&&r.key!=="Shift")return;const o=e.getState();o.picking&&o.activeId&&un.post(o.activeId,{type:"pick-mods",alt:r.altKey,shift:r.shiftKey})};return window.addEventListener("keydown",n),window.addEventListener("keyup",n),()=>{window.removeEventListener("keydown",n),window.removeEventListener("keyup",n)}},[e])}const fY=3,hY=2e3,pY=200,mY=5e3;function gY(){const e=dt(),t=Qe(),n=Bs(),{storage:r}=n,o=ac(),s=L(K=>K.activeRepoId),a=Us(),c=ny(),u=L(K=>K.connected),f=L(K=>K.daylight),h=L(K=>{var te;return((te=K.daylight)==null?void 0:te.until)??0}),m=za(),g=L(K=>K.notesPage),y=L(K=>K.version),w=L(K=>K.railOpen),v=L(K=>K.chatSide),_=L(K=>K.layouts),x=L(K=>K.lastActive),N=L(K=>K.discoveredOpen),T=L(K=>K.archivedOpen),j=L(K=>K.committedShut),A=L(K=>K.turnOpen),R=L(K=>K.treeOpen),C=op(),M=L(K=>K.previewTheme!==null),I=L(K=>K.openUrl),D=EN();E.useEffect(()=>ec.install(window),[]);const H=E.useRef([]),Z=E.useCallback(K=>t==null?void 0:t.send({t:"subscribe",worktreeId:K,since:n.since(K)}),[t,n]);E.useEffect(()=>{if(!t||!u||!o)return;const K=[o,...H.current.filter(te=>te!==o)];for(const te of K.splice(fY))t.send({t:"unsubscribe",worktreeId:te});H.current.includes(o)||Z(o),H.current=K},[o,u,t,Z]),E.useEffect(()=>{if(!(!t||!u))for(const K of H.current)Z(K)},[u,t,Z]);const B=E.useRef(void 0);E.useEffect(()=>{if(!t||!u)return;let K;const te=()=>{const ie=document.visibilityState==="visible"?o:null;t.send({t:"view",worktreeId:ie}),B.current=ie},pe=()=>{clearTimeout(K),K=setTimeout(te,pY)};B.current===void 0||B.current===o||document.visibilityState!=="visible"?te():pe();const ue=()=>document.visibilityState==="visible"?pe():te();return document.addEventListener("visibilitychange",ue),()=>{clearTimeout(K),document.removeEventListener("visibilitychange",ue)}},[o,u,t]);const J=(m==null?void 0:m.id)??null;E.useEffect(()=>{if(!(!t||!u||!J))return Z(J),()=>t.send({t:"unsubscribe",worktreeId:J})},[J,u,t,Z]),E.useEffect(()=>{const K=new Set(D.map(pe=>pe.id)),te=H.current.filter(pe=>!K.has(pe));if(te.length!==0&&(H.current=H.current.filter(pe=>K.has(pe)),!(!t||!u)))for(const pe of te)t.send({t:"unsubscribe",worktreeId:pe})},[D,u,t]);const V=g?"Release notes":(m==null?void 0:m.title)??(c==null?void 0:c.name)??null;E.useEffect(()=>{document.title=V?`${V} · Toyon`:"Toyon"},[V]);const ee=!!(a!=null&&a.unseen),F=L(K=>K.unreadHold!==null&&K.unreadHold===K.activeId);E.useEffect(()=>{if(!t||!o||!ee||F)return;let K;const te=()=>document.visibilityState==="visible"&&document.hasFocus(),pe=()=>{clearTimeout(K),te()&&(K=setTimeout(()=>{te()&&t.send({t:"seen",worktreeId:o})},hY))},ue=()=>clearTimeout(K);return pe(),window.addEventListener("focus",pe),window.addEventListener("blur",ue),()=>{ue(),window.removeEventListener("focus",pe),window.removeEventListener("blur",ue)}},[t,o,ee,F]);const $=E.useRef(0),Q=L(K=>Zw(K));E.useEffect(()=>{if(!t||!u||!s)return;const K=()=>{Date.now()-$.current<mY||($.current=Date.now(),t.send({t:"refresh-git",repoId:s}),Q&&Q!==s&&t.send({t:"refresh-git",repoId:Q}))};return window.addEventListener("focus",K),()=>window.removeEventListener("focus",K)},[t,u,s,Q]);const q=L(K=>K.frame==="phone"&&K.screen==="home"?"surface1":"surface0");E.useEffect(()=>{try{sessionStorage.setItem(tt.ground,q)}catch{}},[q]);const W=L(K=>K.frame==="phone"),oe=L(K=>K.blackGround),de=E.useMemo(()=>W&&oe?CD(C):C,[W,oe,C]);E.useEffect(()=>{try{localStorage.setItem(tt.blackGround,oe?"1":"0")}catch{}},[oe]),E.useEffect(()=>{LC(de,{remember:!M,ground:q,black:de!==C}),un.broadcast(PC(de))},[de,C,M,q]);const he=E.useCallback(()=>{t==null||t.send({t:"zone",tz:Intl.DateTimeFormat().resolvedOptions().timeZone})},[t]);E.useEffect(()=>{if(!u)return;he();const K=()=>{document.visibilityState==="visible"&&he()};return document.addEventListener("visibilitychange",K),()=>document.removeEventListener("visibilitychange",K)},[u,he]),E.useEffect(()=>{if(!u||h<=Date.now())return;const K=setTimeout(he,h-Date.now()+1e3);return()=>clearTimeout(K)},[u,h,he]),E.useEffect(()=>{f&&f.until>0&&OG(f)},[f]),E.useEffect(()=>{o&&r.set(tt.active,o)},[o,r]),E.useEffect(()=>{y&&r.set(tt.version,y)},[y,r]);const Ne=L(K=>K.frame==="phone"?K.screen!=="home":null);E.useEffect(()=>{Ne!==null&&r.session.set(tt.phoneRow,Ne?"1":"0")},[Ne,r]),E.useEffect(()=>{s&&r.set(tt.repo,s)},[s,r]),E.useEffect(()=>{try{localStorage.setItem(tt.rail,w?"1":"0")}catch{}},[w]),E.useEffect(()=>{try{localStorage.setItem(tt.chatSide,v)}catch{}},[v]),E.useEffect(()=>{try{localStorage.setItem(tt.layouts,JSON.stringify(_))}catch{}},[_]),E.useEffect(()=>{r.set(tt.lastActive,JSON.stringify(x))},[x,r]),E.useEffect(()=>{r.set(tt.discoveredOpen,JSON.stringify(N))},[N,r]),E.useEffect(()=>{r.set(tt.archivedOpen,JSON.stringify(T))},[T,r]),E.useEffect(()=>{r.set(tt.committedShut,JSON.stringify(j))},[j,r]),E.useEffect(()=>{r.set(tt.turnOpen,JSON.stringify(A))},[A,r]),E.useEffect(()=>{r.set(tt.treeOpen,JSON.stringify(R))},[R,r]),dY(),Q6();const Me=E.useRef(null);return E.useEffect(()=>{!I||Me.current===I||(Me.current=I,window.open(I,"_blank"),e({a:"opened-url"}))},[I,e]),L(K=>K.frame)==="phone"?d.jsx(TG,{}):d.jsx(sY,{})}function kY({origin:e,machine:t,onToken:n}){const[r,o]=E.useState({kind:"asking"}),[s,a]=E.useState(0),c=URL.canParse(e)&&Ph(new URL(e).hostname);return at([s],()=>{const u=new AbortController;return o({kind:"asking"}),y_(e,u.signal,f=>o({kind:"waiting",word:f})).then(f=>{if(!u.signal.aborted){if(typeof f=="string"){o({kind:"failed",failure:f});return}o({kind:"in"}),n(f.token)}}),()=>u.abort()}),d.jsxs(vs,{children:[r.kind==="waiting"&&d.jsx("div",{className:"knock-word",children:r.word}),d.jsx("p",{className:"status-line",children:r.kind==="asking"?`Asking Toyon on ${t} to let this device in.`:r.kind==="waiting"?`Toyon on ${t} is asking whether to let these two words in. Say yes there.`:r.kind==="in"?"Let in. Opening.":jC(r.failure,e,"this device")}),c&&r.kind!=="in"&&d.jsxs("p",{className:"status-line",children:["This is the machine Toyon runs on, so a terminal here can do it too: ",d.jsx("code",{children:"toyon"})," opens the shell already let in."]}),r.kind==="failed"&&d.jsx("div",{className:"status-actions",children:d.jsx(Oe,{variant:"outline",onClick:()=>a(u=>u+1),children:"ask again"})})]})}const Hg="toyon-shared",wY="x-toyon-name";async function yY(e=globalThis.caches){var t;try{if(!e||!await e.has(Hg))return[];const n=await e.open(Hg),r=[];for(const o of await n.keys()){const s=await n.match(o);if(!s)continue;const a=decodeURIComponent(s.headers.get(wY)??"")||"shared",c=((t=(s.headers.get("content-type")??"").split(";")[0])==null?void 0:t.trim())??"";r.push(new File([await s.blob()],a,{type:c}))}return await e.delete(Hg),r}catch{return[]}}function ZE(e,t=()=>!0){const n=()=>t()?Fa(e):null;return new Promise(r=>{const o=n();if(o)return r(o);const s=e.subscribe(()=>{const a=n();a&&(s(),r(a))})})}function vY(e){const[t]=e;if(e.length===1&&t)return`pick a chat for ${t.name}`;const n=e.every(r=>r.type.startsWith("image/"))?"images":"files";return`pick a chat for ${e.length} ${n}`}async function bY(e,t){const n=await yY(t);if(n.length===0)return;if(e.getState().frame!=="phone"){ch(e,await ZE(e),n);return}e.dispatch({a:"screen",to:"home"}),e.dispatch({a:"sharing",v:vY(n)});const r=await ZE(e,()=>e.getState().screen!=="home");e.dispatch({a:"sharing",v:null}),ch(e,r,n)}function xY(){const e=new Map;return{on(t,n){let r=e.get(t);return r||(r=new Set,e.set(t,r)),r.add(n),()=>{r.delete(n),r.size===0&&e.delete(t)}},deliver(t){for(const n of e.get(iA(t.worktreeId,t.stream))??[])n(t)}}}const EY=2e3,SY=1500;function _Y(e,t,n,r={}){const o=r.timers??{set:(R,C)=>setTimeout(R,C),clear:R=>clearTimeout(R)},s=r.now??(()=>Date.now()),a=r.win??(typeof window>"u"?null:window),c=new Map,u=R=>{let C=c.get(R);return C||(C=new sz,c.set(R,C)),C},f=new Map,h=new Map,m=R=>{var D;o.clear(h.get(R)),h.delete(R);const C=e.getState();if(R===""){if(!C.heard)return;const H=Q4(C,s());if(!H)return;const Z=oz(Object.fromEntries([...f].map(([B,J])=>[B,{at:J}])),C.rows);for(const B of Z)f.delete(B),c.delete(B);t.putHello(n,H).then(()=>Z.length?t.dropChats(n,Z):void 0);return}const M=c.get(R);if(!M||!C.rows.some(H=>H.id===R))return;const I=s();f.set(R,I),t.putChat(n,R,M.snapshot((D=C.local[R])==null?void 0:D.draft,I))},g=R=>{h.has(R)||h.set(R,o.set(()=>m(R),EY))},y=()=>{for(const R of[...h.keys()])m(R)};let w=e.getState();const v=new Map,_=e.subscribe(()=>{var C;const R=e.getState();if(R.heard&&(!w.heard||R.rows!==w.rows||R.repos!==w.repos||R.trunks!==w.trunks||R.handed!==w.handed||R.visits!==w.visits)&&g(""),R.local!==w.local)for(const M of c.keys()){const I=((C=R.local[M])==null?void 0:C.draft)??"";(v.get(M)??"")!==I&&(v.set(M,I),g(M))}w=R}),x=()=>{var R;((R=a==null?void 0:a.document)==null?void 0:R.visibilityState)==="hidden"&&y()};a==null||a.addEventListener("visibilitychange",x),a==null||a.addEventListener("pagehide",y);const N=Promise.all([t.hello(n),t.chats(n)]);let T;const j=new Promise(R=>{T=o.set(()=>R(null),SY)});return{recalled:Promise.race([N,j]).then(R=>{if(o.clear(T),!R)return;const[C,M]=R;for(const[D,H]of Object.entries(M))f.set(D,H.at);if(!C||!lx(C)||e.getState().heard)return;const I={};for(const[D,H]of Object.entries(M))lx(H)&&(I[D]=H);try{e.dispatch({a:"recall",hello:C,chats:I})}catch(D){console.error("the last-known machine could not be recalled; dropping it",D),f.clear(),t.clear(n);return}for(const[D,H]of Object.entries(I))u(D).reset(H.events,H.seq,!1),v.set(D,H.draft??"")}).catch(R=>{console.error("the last-known machine could not be read",R)}),hear(R){var C;if(R.t==="backfill"){const M=u(R.worktreeId);g(R.worktreeId);const I=(((C=e.getState().local[R.worktreeId])==null?void 0:C.chat.length)??0)>0;if(R.after!==void 0&&R.after===M.since()&&I)return M.extend(R.events,R.last),R;if(M.reset(R.events,R.last,R.after===void 0),R.after===void 0)return R;const{after:D,...H}=R;return H}return R.t==="agent"&&(u(R.worktreeId).add(R.seq,R.event),g(R.worktreeId)),R},since:R=>{var C;return(C=c.get(R))==null?void 0:C.since()},forget(){for(const R of[...h.keys()])o.clear(h.get(R)),h.delete(R);c.clear(),f.clear(),t.clear(n)},dispose(){_(),a==null||a.removeEventListener("visibilitychange",x),a==null||a.removeEventListener("pagehide",y),y()}}}function NY(){const e=new Map,t=n=>{const r=co.chats(n),o={};for(const[s,a]of e)s.startsWith(r)&&(o[s.slice(r.length)]=a);return o};return{hello:async n=>e.get(co.hello(n))??null,putHello:async(n,r)=>void e.set(co.hello(n),r),chats:async n=>t(n),putChat:async(n,r,o)=>void e.set(co.chat(n,r),o),dropChats:async(n,r)=>{for(const o of r)e.delete(co.chat(n,o))},clear:async n=>{e.delete(co.hello(n));for(const r of[...e.keys()])r.startsWith(co.chats(n))&&e.delete(r)}}}function KC(){if(typeof indexedDB>"u")return NY();let e=null;const t=()=>(e??(e=new Promise((s,a)=>{const c=indexedDB.open(ZD,1);c.onupgradeneeded=()=>c.result.createObjectStore(Vc),c.onsuccess=()=>s(c.result),c.onerror=()=>a(c.error),c.onblocked=()=>a(new Error("blocked"))}).catch(s=>{throw e=null,s})),e),n=async(s,a)=>{const c=(await t()).transaction(Vc,s).objectStore(Vc);return new Promise((u,f)=>{const h=a(c);h.onsuccess=()=>u(h.result),h.onerror=()=>f(h.error)})},r=s=>{const a=co.chats(s);return IDBKeyRange.bound(a,`${a}￿`)},o=async(s,a)=>{try{return await s}catch{return a}};return{hello:s=>o(n("readonly",a=>a.get(co.hello(s))),void 0).then(a=>a??null),putHello:(s,a)=>o(n("readwrite",c=>c.put(a,co.hello(s))),void 0).then(()=>{}),chats:async s=>{const a=co.chats(s),[c,u]=await o((async()=>{const h=(await t()).transaction(Vc,"readonly").objectStore(Vc),m=g=>new Promise((y,w)=>{g.onsuccess=()=>y(g.result),g.onerror=()=>w(g.error)});return Promise.all([m(h.getAllKeys(r(s))),m(h.getAll(r(s)))])})(),[[],[]]),f={};return c.forEach((h,m)=>{const g=u[m];typeof h=="string"&&g&&(f[h.slice(a.length)]=g)}),f},putChat:(s,a,c)=>o(n("readwrite",u=>u.put(c,co.chat(s,a))),void 0).then(()=>{}),dropChats:async(s,a)=>{for(const c of a)await o(n("readwrite",u=>u.delete(co.chat(s,c))),void 0)},clear:async s=>{await o(n("readwrite",a=>a.delete(co.hello(s))),void 0),await o(n("readwrite",a=>a.delete(r(s))),void 0)}}}function jY(e){try{const t=new URL(e),n=t.hostname.split(".")[0]??t.hostname;return t.port&&(n==="127"||n==="localhost")?`${t.hostname}:${t.port}`:n}catch{return e}}function TY(e){const t={};try{const n=JSON.parse(e??"{}");if(!n||typeof n!="object")return t;for(const[r,o]of Object.entries(n))uz(o)&&(t[r]=o)}catch{}return t}function $Y(e){const t={};try{const n=JSON.parse(e??"{}");if(!n||typeof n!="object")return t;for(const[r,o]of Object.entries(n))typeof o=="string"&&o&&(t[r]=o)}catch{}return t}function Mf(e){const t={};try{const n=JSON.parse(e??"{}");if(!n||typeof n!="object")return t;for(const[r,o]of Object.entries(n))typeof o=="boolean"&&(t[r]=o)}catch{}return t}function CY(e){const t={};try{const n=JSON.parse(e??"{}");if(!n||typeof n!="object")return t;for(const[r,o]of Object.entries(n))Array.isArray(o)&&o.every(s=>typeof s=="string")&&o.length>0&&(t[r]=o)}catch{}return t}const IY=400,AY=2e3;function qC(){const e=new Map;return{another(t,n=0){return(e.get(t)??0)===n?!1:(e.set(t,n),!0)}}}function ZC(e,t,n){const r=e.getState(),o=[];for(const[s,a]of t){if(a===n||r.local[s])continue;const c=ms(s);c&&c.clientId!==r.clientId||o.push(s)}return o}function RY(e,t){const n=new Map,r=new Map,o=qC(),s=u=>{var h,m;clearTimeout((h=r.get(u))==null?void 0:h.timer),r.delete(u);const f=e.getState().local[u];!f||((m=f.mark)==null?void 0:m.by)==="walk"||(n.get(u)??"")!==f.draft&&(n.set(u,f.draft),t.send({t:"set-draft",boxId:u,text:f.draft,clientId:e.getState().clientId}))},a=()=>{for(const u of[...r.keys()])s(u)},c=e.subscribe(()=>{var u,f,h;for(const[m,g]of Object.entries(e.getState().local)){if(o.another(m,g.sent)&&(clearTimeout((u=r.get(m))==null?void 0:u.timer),r.delete(m),n.set(m,"")),((f=g.mark)==null?void 0:f.by)==="walk"||(n.get(m)??"")===g.draft)continue;if(!g.draft){s(m);continue}const y=r.get(m);if((y==null?void 0:y.text)===g.draft)continue;clearTimeout(y==null?void 0:y.timer);const w=(y==null?void 0:y.since)??Date.now(),v=Math.max(0,Math.min(IY,w+AY-Date.now()));r.set(m,{text:g.draft,timer:setTimeout(s,v,m),since:w})}for(const m of ZC(e,n,""))clearTimeout((h=r.get(m))==null?void 0:h.timer),r.delete(m),n.set(m,""),t.send({t:"set-draft",boxId:m,text:"",clientId:e.getState().clientId})});return window.addEventListener("focusout",a),window.addEventListener("pagehide",a),{hello(u){n.clear();for(const[f,h]of Object.entries(u))n.set(f,h)},heard(u,f){return r.has(u)?!1:(n.set(u,f),!0)},dispose(){c();for(const u of r.values())clearTimeout(u.timer);r.clear(),window.removeEventListener("focusout",a),window.removeEventListener("pagehide",a)}}}function OY(e,t){const n=new Map,r=new Map,o=qC(),s=e.subscribe(()=>{const a=[];for(const[c,u]of Object.entries(e.getState().local)){if(o.another(c,u.sent)&&r.set(c,"[]"),n.get(c)===u.attachments)continue;n.set(c,u.attachments);const f=Ww(u.attachments),h=JSON.stringify(f),m=r.get(c)??"[]";m!==h&&(r.set(c,h),a.push({id:c,items:f,before:M_(JSON.parse(m))}))}for(const c of ZC(e,r,"[]"))r.set(c,"[]"),a.push({id:c,items:[],before:[]});for(const c of V4(a))t.send({t:"set-attachments",boxId:c.id,items:c.items,clientId:e.getState().clientId})});return{hello(a){r.clear(),n.clear();for(const[c,u]of Object.entries(a))r.set(c,JSON.stringify(u))},heard(a,c){r.set(a,JSON.stringify(c))},dispose:s}}function MY(e,t){return e.subscribe(()=>{for(const n of G4(e.getState().outbox,e.getState().local)){const r=e.getState(),o=r.local[n];o!=null&&o.outgoing&&(t.send({t:"set-draft",boxId:n,text:o.draft,clientId:r.clientId}),t.send(su(o.outgoing.frame,n,o.draft,o.attachments)),e.dispatch({a:"sent-out",id:n}))}})}const GE="not sent: the page reloaded while an upload was on its way; attach it again and send";function VE(e,t,n){var a;const r=e.getState(),o=new Set([...Object.keys(n.drafts),...Object.keys(n.attachments)]),s=[];for(const c of o){const u=ms(c);if((u==null?void 0:u.clientId)!==r.clientId||(a=r.local[c])!=null&&a.outgoing)continue;const f=n.drafts[c]??"",h=n.attachments[c]??[],m=n.drafts[u.source]??"",g=[...h,...n.attachments[u.source]??[]],y=m||f,w=r.clientId;g.length&&t.send({t:"set-attachments",boxId:u.source,items:g,clientId:w}),y!==m&&t.send({t:"set-draft",boxId:u.source,text:y,clientId:w}),t.send({t:"set-attachments",boxId:c,items:[],clientId:w}),t.send({t:"set-draft",boxId:c,text:"",clientId:w}),delete n.drafts[c],delete n.attachments[c],y&&(n.drafts[u.source]=y),g.length&&(n.attachments[u.source]=g),s.push(u.source)}return s}function LY(e,t){const n=(t.storage??GD)(e.origin),r=Qz(fz({cached:t.cached,systemDark:t.systemDark,daylight:t.daylight,storedActive:n.get(tt.active),storedPhoneRow:n.session.get(tt.phoneRow)==="1",storedRepo:n.get(tt.repo),storedVersion:n.get(tt.version),storedRailOpen:Lf(tt.rail)==="1",storedChatSide:Lf(tt.chatSide)==="right"?"right":"left",storedBlackGround:Lf(tt.blackGround)==="1",storedLayouts:TY(Lf(tt.layouts)),storedLastActive:$Y(n.get(tt.lastActive)),storedDiscoveredOpen:Mf(n.get(tt.discoveredOpen)),storedArchivedOpen:Mf(n.get(tt.archivedOpen)),storedCommittedShut:Mf(n.get(tt.committedShut)),storedTurnOpen:Mf(n.get(tt.turnOpen)),storedTreeOpen:CY(n.get(tt.treeOpen)),clientId:t.clientId,frame:t.frame,touch:t.touch})),o=xY(),s={version:null,protocol:null},a=PB(v=>r.dispatch({a:"server",msg:v}));let c,u,f;const h=_Y(r,t.snapshots??KC(),e.origin);let m=[];const g=new k4(e,v=>{if(v.t==="hello"){if(s.protocol=v.protocol,e.serving){const{rebuilt:x,update:N}=r.getState(),T=x&&(N==null?void 0:N.restarting)!=null;if(s.version!==null&&(T||v.version!==s.version||v.protocol!==va)){g.dispose(),t.reload();return}if(v.protocol!==va){r.dispatch({a:"incompatible"}),g.dispose();return}}else if(v.protocol!==va){r.dispatch({a:"incompatible"}),g.suspend();return}else r.getState().incompatible&&r.dispatch({a:"incompatible",v:!1});s.version=v.version;const _=new Set(g.sentWhileDown());if(_.size){const x=N=>Object.fromEntries(Object.entries(N).filter(([T])=>!_.has(T)));v.drafts=x(v.drafts),v.attachments=x(v.attachments)}m=VE(r,g,v),c.hello(v.drafts),u.hello(v.attachments)}if(v.t==="attachments"&&v.clientId!==r.getState().clientId&&u.heard(v.boxId,v.items),!(v.t==="draft"&&v.clientId!==r.getState().clientId&&!c.heard(v.boxId,v.text))){if(RP(v)){o.deliver(v);return}if(OP(v)){if(v.t==="file-written"&&e6(v))return;f.receive(v);return}if(v.t==="loose-written"){aq(v);return}if(j8(v)){I8(r,g,v);return}if(v.t==="open-refused"){C8(r,v);return}a(h.hear(v));for(const _ of m.splice(0))r.dispatch({a:"notice",id:_,text:GE})}},(v,_)=>r.dispatch({a:"connected",v,failure:_}),{},{known:()=>qz(r.getState()),held:e.serving});o6(r,g.urls),f=new sq({store:r,send:v=>g.send(v),timers:{set:(v,_)=>setTimeout(v,_),clear:v=>clearTimeout(v)},win:window});const y=f.start();c=RY(r,g),u=OY(r,g);const w=MY(r,g);return{origin:e.origin,serving:e.serving,token:e.token,get name(){return r.getState().machine??jY(e.origin)},store:r,sock:g,files:f,terminals:o,storage:n,heard:s,recalled:h.recalled,forget:()=>h.forget(),boot(v){try{if((v==null?void 0:v.t)==="hello"&&v.protocol===va){s.version??(s.version=v.version);const _=VE(r,g,v);u.hello(v.attachments),r.dispatch({a:"server",msg:v});for(const x of _)r.dispatch({a:"notice",id:x,text:GE})}}finally{g.resume()}},since:v=>{var _;return(_=r.getState().local[v])!=null&&_.chat.length?h.since(v):void 0},dispose(){g.dispose(),y(),c.dispose(),u.dispose(),w(),h.dispose()}}}function Lf(e){try{return localStorage.getItem(e)}catch{return null}}window.__toyonShell=!0;const GC=sj();GC&&(document.documentElement.dataset.framed="");YD(location.origin);const VC=$G();LC(VC);function PY(e,t){try{return e.getItem(t)}catch{return null}}function DY(){const e=PY(sessionStorage,tt.client);if(e)return e;const t=Math.random().toString(36).slice(2,10);try{sessionStorage.setItem(tt.client,t)}catch{}return t}const zY={cached:VC,systemDark:IG(),daylight:RG(),clientId:DY(),frame:my(),touch:n5(),reload:()=>window.location.reload(),snapshots:KC()},ks=zZ({serving:{origin:location.origin,token:h_()},build:e=>LY(e,zY)});r5({dispatch:e=>ks.broadcast(e)});MG(e=>ks.broadcast({a:"system-dark",v:e}));const YC=e=>GC?()=>{}:xG(e);let YE=YC(ks.active().store),XE=ks.active();ks.subscribe(()=>{const e=ks.active();e!==XE&&(XE=e,YE(),e.store.getState().frame==="phone"&&e.store.dispatch({a:"screen",to:"home"}),YE=YC(e.store))});window.addEventListener("vite:preloadError",Z5);const FY=Promise.all([(window.toyonBoot??Promise.resolve(null)).then(e=>{const t=e;ks.active().boot(t&&typeof t=="object"&&t.t==="hello"?t:null)}),ks.active().recalled]).catch(e=>{console.error("boot",e)});function BY(e){p_(e),window.location.reload()}const UY=QI.createRoot(document.getElementById("root"));FY.then(()=>{var e;eS.flushSync(()=>UY.render(d.jsx(ZI.StrictMode,{children:d.jsx(gy,{children:sh()?d.jsx(e3,{machines:ks,children:d.jsx(gY,{})}):d.jsx(kY,{origin:location.origin,machine:location.host,onToken:BY})})}))),document.documentElement.style.removeProperty("background"),document.documentElement.style.removeProperty("--boot-ink"),(e=document.getElementById("boot"))==null||e.remove(),sh()&&bY(ks.active().store)});"serviceWorker"in navigator&&navigator.serviceWorker.register("/sw.js").catch(()=>{});export{Ws as F,Cq as S,Jk as _,mr as a,$w as b,GY as c,at as d,YY as e,qY as f,KY as g,zD as h,fS as i,d as j,iA as k,r8 as l,dS as m,Ey as n,WY as o,ZY as p,E as r,ID as s,Uu as t,VY as u,ex as w};