toyon 0.22.0 → 0.23.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 +3 -3
  2. package/dist/CHANGELOG.md +28 -0
  3. package/dist/bridge.js +1 -1
  4. package/dist/cli.js +92 -3
  5. package/dist/daemon.js +9913 -9002
  6. package/dist/shell/assets/{Editor-1fCgxkUp.js → Editor-C2e_GpDQ.js} +165 -165
  7. package/dist/shell/assets/Editor-C2e_GpDQ.js.br +0 -0
  8. package/dist/shell/assets/Editor-C2e_GpDQ.js.gz +0 -0
  9. package/dist/shell/assets/XTerm-B84G0H5I.js +58 -0
  10. package/dist/shell/assets/XTerm-B84G0H5I.js.br +0 -0
  11. package/dist/shell/assets/XTerm-B84G0H5I.js.gz +0 -0
  12. package/dist/shell/assets/{cssMode-1LqDnQzX.js → cssMode-DhDLwjyN.js} +1 -1
  13. package/dist/shell/assets/cssMode-DhDLwjyN.js.br +0 -0
  14. package/dist/shell/assets/cssMode-DhDLwjyN.js.gz +0 -0
  15. package/dist/shell/assets/{freemarker2-BJFDEJKJ.js → freemarker2-rc8sP22g.js} +1 -1
  16. package/dist/shell/assets/freemarker2-rc8sP22g.js.br +0 -0
  17. package/dist/shell/assets/freemarker2-rc8sP22g.js.gz +0 -0
  18. package/dist/shell/assets/{grammar-DVeERVO3.js → grammar-Cty-NAQC.js} +1 -1
  19. package/dist/shell/assets/grammar-Cty-NAQC.js.br +0 -0
  20. package/dist/shell/assets/grammar-Cty-NAQC.js.gz +0 -0
  21. package/dist/shell/assets/{handlebars-BGFLy2DH.js → handlebars-BOQxV3p5.js} +1 -1
  22. package/dist/shell/assets/handlebars-BOQxV3p5.js.br +0 -0
  23. package/dist/shell/assets/handlebars-BOQxV3p5.js.gz +0 -0
  24. package/dist/shell/assets/{html-CPJflvc5.js → html-CxndUpse.js} +1 -1
  25. package/dist/shell/assets/html-CxndUpse.js.br +0 -0
  26. package/dist/shell/assets/html-CxndUpse.js.gz +0 -0
  27. package/dist/shell/assets/{htmlMode-CjqzceBV.js → htmlMode-CG7eVDLo.js} +1 -1
  28. package/dist/shell/assets/htmlMode-CG7eVDLo.js.br +0 -0
  29. package/dist/shell/assets/htmlMode-CG7eVDLo.js.gz +0 -0
  30. package/dist/shell/assets/index-DpSfPmkM.css +1 -0
  31. package/dist/shell/assets/index-DpSfPmkM.css.br +0 -0
  32. package/dist/shell/assets/index-DpSfPmkM.css.gz +0 -0
  33. package/dist/shell/assets/index-DzfHDra7.js +294 -0
  34. package/dist/shell/assets/index-DzfHDra7.js.br +0 -0
  35. package/dist/shell/assets/index-DzfHDra7.js.gz +0 -0
  36. package/dist/shell/assets/{javascript-B4CelO-C.js → javascript-CafoevnZ.js} +1 -1
  37. package/dist/shell/assets/{jsonMode-C2JxYuT6.js → jsonMode-Cg_4sMB_.js} +1 -1
  38. package/dist/shell/assets/jsonMode-Cg_4sMB_.js.br +0 -0
  39. package/dist/shell/assets/jsonMode-Cg_4sMB_.js.gz +0 -0
  40. package/dist/shell/assets/{liquid-BfXRgBm_.js → liquid-DxW_HNid.js} +1 -1
  41. package/dist/shell/assets/liquid-DxW_HNid.js.br +0 -0
  42. package/dist/shell/assets/liquid-DxW_HNid.js.gz +0 -0
  43. package/dist/shell/assets/{lspLanguageFeatures-CAi6hRgs.js → lspLanguageFeatures-Dhat9l4L.js} +1 -1
  44. package/dist/shell/assets/lspLanguageFeatures-Dhat9l4L.js.br +0 -0
  45. package/dist/shell/assets/lspLanguageFeatures-Dhat9l4L.js.gz +0 -0
  46. package/dist/shell/assets/{mdx-DeBYGdge.js → mdx-ZdMhgPNL.js} +1 -1
  47. package/dist/shell/assets/mdx-ZdMhgPNL.js.br +0 -0
  48. package/dist/shell/assets/mdx-ZdMhgPNL.js.gz +0 -0
  49. package/dist/shell/assets/{python-CFhHKm43.js → python-Bae_7wMM.js} +1 -1
  50. package/dist/shell/assets/python-Bae_7wMM.js.br +0 -0
  51. package/dist/shell/assets/python-Bae_7wMM.js.gz +0 -0
  52. package/dist/shell/assets/{razor-C-gkU4Y9.js → razor-CtwiCIJH.js} +1 -1
  53. package/dist/shell/assets/razor-CtwiCIJH.js.br +0 -0
  54. package/dist/shell/assets/razor-CtwiCIJH.js.gz +0 -0
  55. package/dist/shell/assets/toyon-mono-bold-9c1iJO0D.woff2 +0 -0
  56. package/dist/shell/assets/toyon-mono-regular-BXyxgSUK.woff2 +0 -0
  57. package/dist/shell/assets/{tsMode-8E7grKbo.js → tsMode-DH9rMbRS.js} +1 -1
  58. package/dist/shell/assets/tsMode-DH9rMbRS.js.br +0 -0
  59. package/dist/shell/assets/tsMode-DH9rMbRS.js.gz +0 -0
  60. package/dist/shell/assets/{xml-CBoTF2r1.js → xml-rA-vNTCn.js} +1 -1
  61. package/dist/shell/assets/xml-rA-vNTCn.js.br +0 -0
  62. package/dist/shell/assets/xml-rA-vNTCn.js.gz +0 -0
  63. package/dist/shell/assets/{yaml-CyKxhzxl.js → yaml-pOtRRozm.js} +1 -1
  64. package/dist/shell/assets/yaml-pOtRRozm.js.br +0 -0
  65. package/dist/shell/assets/yaml-pOtRRozm.js.gz +0 -0
  66. package/dist/shell/index.html +2 -2
  67. package/package.json +1 -1
  68. package/dist/shell/assets/Editor-1fCgxkUp.js.br +0 -0
  69. package/dist/shell/assets/Editor-1fCgxkUp.js.gz +0 -0
  70. package/dist/shell/assets/XTerm-B_hkTWne.js +0 -58
  71. package/dist/shell/assets/XTerm-B_hkTWne.js.br +0 -0
  72. package/dist/shell/assets/XTerm-B_hkTWne.js.gz +0 -0
  73. package/dist/shell/assets/cssMode-1LqDnQzX.js.br +0 -0
  74. package/dist/shell/assets/cssMode-1LqDnQzX.js.gz +0 -0
  75. package/dist/shell/assets/freemarker2-BJFDEJKJ.js.br +0 -0
  76. package/dist/shell/assets/freemarker2-BJFDEJKJ.js.gz +0 -0
  77. package/dist/shell/assets/grammar-DVeERVO3.js.br +0 -0
  78. package/dist/shell/assets/grammar-DVeERVO3.js.gz +0 -0
  79. package/dist/shell/assets/handlebars-BGFLy2DH.js.br +0 -0
  80. package/dist/shell/assets/handlebars-BGFLy2DH.js.gz +0 -0
  81. package/dist/shell/assets/html-CPJflvc5.js.br +0 -0
  82. package/dist/shell/assets/html-CPJflvc5.js.gz +0 -0
  83. package/dist/shell/assets/htmlMode-CjqzceBV.js.br +0 -0
  84. package/dist/shell/assets/htmlMode-CjqzceBV.js.gz +0 -0
  85. package/dist/shell/assets/index-DdrVWdNt.js +0 -292
  86. package/dist/shell/assets/index-DdrVWdNt.js.br +0 -0
  87. package/dist/shell/assets/index-DdrVWdNt.js.gz +0 -0
  88. package/dist/shell/assets/index-Dx-i3szQ.css +0 -1
  89. package/dist/shell/assets/index-Dx-i3szQ.css.br +0 -0
  90. package/dist/shell/assets/index-Dx-i3szQ.css.gz +0 -0
  91. package/dist/shell/assets/jsonMode-C2JxYuT6.js.br +0 -0
  92. package/dist/shell/assets/jsonMode-C2JxYuT6.js.gz +0 -0
  93. package/dist/shell/assets/liquid-BfXRgBm_.js.br +0 -0
  94. package/dist/shell/assets/liquid-BfXRgBm_.js.gz +0 -0
  95. package/dist/shell/assets/lspLanguageFeatures-CAi6hRgs.js.br +0 -0
  96. package/dist/shell/assets/lspLanguageFeatures-CAi6hRgs.js.gz +0 -0
  97. package/dist/shell/assets/mdx-DeBYGdge.js.br +0 -0
  98. package/dist/shell/assets/mdx-DeBYGdge.js.gz +0 -0
  99. package/dist/shell/assets/python-CFhHKm43.js.br +0 -0
  100. package/dist/shell/assets/python-CFhHKm43.js.gz +0 -0
  101. package/dist/shell/assets/razor-C-gkU4Y9.js.br +0 -0
  102. package/dist/shell/assets/razor-C-gkU4Y9.js.gz +0 -0
  103. package/dist/shell/assets/tsMode-8E7grKbo.js.br +0 -0
  104. package/dist/shell/assets/tsMode-8E7grKbo.js.gz +0 -0
  105. package/dist/shell/assets/xml-CBoTF2r1.js.br +0 -0
  106. package/dist/shell/assets/xml-CBoTF2r1.js.gz +0 -0
  107. package/dist/shell/assets/yaml-CyKxhzxl.js.br +0 -0
  108. package/dist/shell/assets/yaml-CyKxhzxl.js.gz +0 -0
@@ -1,292 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/Editor-1fCgxkUp.js","assets/grammar-DVeERVO3.js","assets/Editor-CB2SckMT.css","assets/XTerm-B_hkTWne.js","assets/XTerm-6GBZ9nXN.css"])))=>i.map(i=>d[i]);
2
- var jA=Object.defineProperty;var $A=(e,t,n)=>t in e?jA(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Tt=(e,t,n)=>$A(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 KE(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Gm={exports:{}},Wc={},Vm={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 U0;function CA(){if(U0)return en;U0=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"),h=Symbol.for("react.memo"),f=Symbol.for("react.lazy"),m=Symbol.iterator;function g(K){return K===null||typeof K!="object"?null:(K=m&&K[m]||K["@@iterator"],typeof K=="function"?K:null)}var y={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},w=Object.assign,v={};function N(K,ne,de){this.props=K,this.context=ne,this.refs=v,this.updater=de||y}N.prototype.isReactComponent={},N.prototype.setState=function(K,ne){if(typeof K!="object"&&typeof K!="function"&&K!=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,K,ne,"setState")},N.prototype.forceUpdate=function(K){this.updater.enqueueForceUpdate(this,K,"forceUpdate")};function x(){}x.prototype=N.prototype;function _(K,ne,de){this.props=K,this.context=ne,this.refs=v,this.updater=de||y}var j=_.prototype=new x;j.constructor=_,w(j,N.prototype),j.isPureReactComponent=!0;var T=Array.isArray,I=Object.prototype.hasOwnProperty,R={current:null},C={key:!0,ref:!0,__self:!0,__source:!0};function O(K,ne,de){var pe,je={},_e=null,fe=null;if(ne!=null)for(pe in ne.ref!==void 0&&(fe=ne.ref),ne.key!==void 0&&(_e=""+ne.key),ne)I.call(ne,pe)&&!C.hasOwnProperty(pe)&&(je[pe]=ne[pe]);var te=arguments.length-2;if(te===1)je.children=de;else if(1<te){for(var re=Array(te),we=0;we<te;we++)re[we]=arguments[we+2];je.children=re}if(K&&K.defaultProps)for(pe in te=K.defaultProps,te)je[pe]===void 0&&(je[pe]=te[pe]);return{$$typeof:e,type:K,key:_e,ref:fe,props:je,_owner:R.current}}function A(K,ne){return{$$typeof:e,type:K.type,key:ne,ref:K.ref,props:K.props,_owner:K._owner}}function D(K){return typeof K=="object"&&K!==null&&K.$$typeof===e}function B(K){var ne={"=":"=0",":":"=2"};return"$"+K.replace(/[=:]/g,function(de){return ne[de]})}var W=/\/+/g;function U(K,ne){return typeof K=="object"&&K!==null&&K.key!=null?B(""+K.key):ne.toString(36)}function Q(K,ne,de,pe,je){var _e=typeof K;(_e==="undefined"||_e==="boolean")&&(K=null);var fe=!1;if(K===null)fe=!0;else switch(_e){case"string":case"number":fe=!0;break;case"object":switch(K.$$typeof){case e:case t:fe=!0}}if(fe)return fe=K,je=je(fe),K=pe===""?"."+U(fe,0):pe,T(je)?(de="",K!=null&&(de=K.replace(W,"$&/")+"/"),Q(je,ne,de,"",function(we){return we})):je!=null&&(D(je)&&(je=A(je,de+(!je.key||fe&&fe.key===je.key?"":(""+je.key).replace(W,"$&/")+"/")+K)),ne.push(je)),1;if(fe=0,pe=pe===""?".":pe+":",T(K))for(var te=0;te<K.length;te++){_e=K[te];var re=pe+U(_e,te);fe+=Q(_e,ne,de,re,je)}else if(re=g(K),typeof re=="function")for(K=re.call(K),te=0;!(_e=K.next()).done;)_e=_e.value,re=pe+U(_e,te++),fe+=Q(_e,ne,de,re,je);else if(_e==="object")throw ne=String(K),Error("Objects are not valid as a React child (found: "+(ne==="[object Object]"?"object with keys {"+Object.keys(K).join(", ")+"}":ne)+"). If you meant to render a collection of children, use an array instead.");return fe}function Y(K,ne,de){if(K==null)return K;var pe=[],je=0;return Q(K,pe,"","",function(_e){return ne.call(de,_e,je++)}),pe}function se(K){if(K._status===-1){var ne=K._result;ne=ne(),ne.then(function(de){(K._status===0||K._status===-1)&&(K._status=1,K._result=de)},function(de){(K._status===0||K._status===-1)&&(K._status=2,K._result=de)}),K._status===-1&&(K._status=0,K._result=ne)}if(K._status===1)return K._result.default;throw K._result}var H={current:null},$={transition:null},Z={ReactCurrentDispatcher:H,ReactCurrentBatchConfig:$,ReactCurrentOwner:R};function q(){throw Error("act(...) is not supported in production builds of React.")}return en.Children={map:Y,forEach:function(K,ne,de){Y(K,function(){ne.apply(this,arguments)},de)},count:function(K){var ne=0;return Y(K,function(){ne++}),ne},toArray:function(K){return Y(K,function(ne){return ne})||[]},only:function(K){if(!D(K))throw Error("React.Children.only expected to receive a single React element child.");return K}},en.Component=N,en.Fragment=n,en.Profiler=o,en.PureComponent=_,en.StrictMode=r,en.Suspense=u,en.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=Z,en.act=q,en.cloneElement=function(K,ne,de){if(K==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+K+".");var pe=w({},K.props),je=K.key,_e=K.ref,fe=K._owner;if(ne!=null){if(ne.ref!==void 0&&(_e=ne.ref,fe=R.current),ne.key!==void 0&&(je=""+ne.key),K.type&&K.type.defaultProps)var te=K.type.defaultProps;for(re in ne)I.call(ne,re)&&!C.hasOwnProperty(re)&&(pe[re]=ne[re]===void 0&&te!==void 0?te[re]:ne[re])}var re=arguments.length-2;if(re===1)pe.children=de;else if(1<re){te=Array(re);for(var we=0;we<re;we++)te[we]=arguments[we+2];pe.children=te}return{$$typeof:e,type:K.type,key:je,ref:_e,props:pe,_owner:fe}},en.createContext=function(K){return K={$$typeof:a,_currentValue:K,_currentValue2:K,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},K.Provider={$$typeof:s,_context:K},K.Consumer=K},en.createElement=O,en.createFactory=function(K){var ne=O.bind(null,K);return ne.type=K,ne},en.createRef=function(){return{current:null}},en.forwardRef=function(K){return{$$typeof:c,render:K}},en.isValidElement=D,en.lazy=function(K){return{$$typeof:f,_payload:{_status:-1,_result:K},_init:se}},en.memo=function(K,ne){return{$$typeof:h,type:K,compare:ne===void 0?null:ne}},en.startTransition=function(K){var ne=$.transition;$.transition={};try{K()}finally{$.transition=ne}},en.unstable_act=q,en.useCallback=function(K,ne){return H.current.useCallback(K,ne)},en.useContext=function(K){return H.current.useContext(K)},en.useDebugValue=function(){},en.useDeferredValue=function(K){return H.current.useDeferredValue(K)},en.useEffect=function(K,ne){return H.current.useEffect(K,ne)},en.useId=function(){return H.current.useId()},en.useImperativeHandle=function(K,ne,de){return H.current.useImperativeHandle(K,ne,de)},en.useInsertionEffect=function(K,ne){return H.current.useInsertionEffect(K,ne)},en.useLayoutEffect=function(K,ne){return H.current.useLayoutEffect(K,ne)},en.useMemo=function(K,ne){return H.current.useMemo(K,ne)},en.useReducer=function(K,ne,de){return H.current.useReducer(K,ne,de)},en.useRef=function(K){return H.current.useRef(K)},en.useState=function(K){return H.current.useState(K)},en.useSyncExternalStore=function(K,ne,de){return H.current.useSyncExternalStore(K,ne,de)},en.useTransition=function(){return H.current.useTransition()},en.version="18.3.1",en}var H0;function sw(){return H0||(H0=1,Vm.exports=CA()),Vm.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 W0;function AA(){if(W0)return Wc;W0=1;var e=sw(),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,h){var f,m={},g=null,y=null;h!==void 0&&(g=""+h),u.key!==void 0&&(g=""+u.key),u.ref!==void 0&&(y=u.ref);for(f in u)r.call(u,f)&&!s.hasOwnProperty(f)&&(m[f]=u[f]);if(c&&c.defaultProps)for(f in u=c.defaultProps,u)m[f]===void 0&&(m[f]=u[f]);return{$$typeof:t,type:c,key:g,ref:y,props:m,_owner:o.current}}return Wc.Fragment=n,Wc.jsx=a,Wc.jsxs=a,Wc}var K0;function IA(){return K0||(K0=1,Gm.exports=AA()),Gm.exports}var d=IA(),S=sw();const RA=KE(S);var Ym={exports:{}},ao={},Xm={exports:{}},Qm={};/**
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 q0;function OA(){return q0||(q0=1,(function(e){function t($,Z){var q=$.length;$.push(Z);e:for(;0<q;){var K=q-1>>>1,ne=$[K];if(0<o(ne,Z))$[K]=Z,$[q]=ne,q=K;else break e}}function n($){return $.length===0?null:$[0]}function r($){if($.length===0)return null;var Z=$[0],q=$.pop();if(q!==Z){$[0]=q;e:for(var K=0,ne=$.length,de=ne>>>1;K<de;){var pe=2*(K+1)-1,je=$[pe],_e=pe+1,fe=$[_e];if(0>o(je,q))_e<ne&&0>o(fe,je)?($[K]=fe,$[_e]=q,K=_e):($[K]=je,$[pe]=q,K=pe);else if(_e<ne&&0>o(fe,q))$[K]=fe,$[_e]=q,K=_e;else break e}}return Z}function o($,Z){var q=$.sortIndex-Z.sortIndex;return q!==0?q:$.id-Z.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=[],h=[],f=1,m=null,g=3,y=!1,w=!1,v=!1,N=typeof setTimeout=="function"?setTimeout:null,x=typeof clearTimeout=="function"?clearTimeout:null,_=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function j($){for(var Z=n(h);Z!==null;){if(Z.callback===null)r(h);else if(Z.startTime<=$)r(h),Z.sortIndex=Z.expirationTime,t(u,Z);else break;Z=n(h)}}function T($){if(v=!1,j($),!w)if(n(u)!==null)w=!0,se(I);else{var Z=n(h);Z!==null&&H(T,Z.startTime-$)}}function I($,Z){w=!1,v&&(v=!1,x(O),O=-1),y=!0;var q=g;try{for(j(Z),m=n(u);m!==null&&(!(m.expirationTime>Z)||$&&!B());){var K=m.callback;if(typeof K=="function"){m.callback=null,g=m.priorityLevel;var ne=K(m.expirationTime<=Z);Z=e.unstable_now(),typeof ne=="function"?m.callback=ne:m===n(u)&&r(u),j(Z)}else r(u);m=n(u)}if(m!==null)var de=!0;else{var pe=n(h);pe!==null&&H(T,pe.startTime-Z),de=!1}return de}finally{m=null,g=q,y=!1}}var R=!1,C=null,O=-1,A=5,D=-1;function B(){return!(e.unstable_now()-D<A)}function W(){if(C!==null){var $=e.unstable_now();D=$;var Z=!0;try{Z=C(!0,$)}finally{Z?U():(R=!1,C=null)}}else R=!1}var U;if(typeof _=="function")U=function(){_(W)};else if(typeof MessageChannel<"u"){var Q=new MessageChannel,Y=Q.port2;Q.port1.onmessage=W,U=function(){Y.postMessage(null)}}else U=function(){N(W,0)};function se($){C=$,R||(R=!0,U())}function H($,Z){O=N(function(){$(e.unstable_now())},Z)}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,se(I))},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"):A=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 Z=3;break;default:Z=g}var q=g;g=Z;try{return $()}finally{g=q}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function($,Z){switch($){case 1:case 2:case 3:case 4:case 5:break;default:$=3}var q=g;g=$;try{return Z()}finally{g=q}},e.unstable_scheduleCallback=function($,Z,q){var K=e.unstable_now();switch(typeof q=="object"&&q!==null?(q=q.delay,q=typeof q=="number"&&0<q?K+q:K):q=K,$){case 1:var ne=-1;break;case 2:ne=250;break;case 5:ne=1073741823;break;case 4:ne=1e4;break;default:ne=5e3}return ne=q+ne,$={id:f++,callback:Z,priorityLevel:$,startTime:q,expirationTime:ne,sortIndex:-1},q>K?($.sortIndex=q,t(h,$),n(u)===null&&$===n(h)&&(v?(x(O),O=-1):v=!0,H(T,q-K))):($.sortIndex=ne,t(u,$),w||y||(w=!0,se(I))),$},e.unstable_shouldYield=B,e.unstable_wrapCallback=function($){var Z=g;return function(){var q=g;g=Z;try{return $.apply(this,arguments)}finally{g=q}}}})(Qm)),Qm}var Z0;function MA(){return Z0||(Z0=1,Xm.exports=OA()),Xm.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 G0;function LA(){if(G0)return ao;G0=1;var e=sw(),t=MA();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,h=/^[: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]*$/,f={},m={};function g(i){return u.call(m,i)?!0:u.call(f,i)?!1:h.test(i)?m[i]=!0:(f[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,E,M){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=E,this.removeEmptyString=M}var N={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(i){N[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];N[l]=new v(l,1,!1,i[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(i){N[i]=new v(i,2,!1,i.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(i){N[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){N[i]=new v(i,3,!1,i.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(i){N[i]=new v(i,3,!0,i,null,!1,!1)}),["capture","download"].forEach(function(i){N[i]=new v(i,4,!1,i,null,!1,!1)}),["cols","rows","size","span"].forEach(function(i){N[i]=new v(i,6,!1,i,null,!1,!1)}),["rowSpan","start"].forEach(function(i){N[i]=new v(i,5,!1,i.toLowerCase(),null,!1,!1)});var x=/[\-:]([a-z])/g;function _(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){N[i]=new v(i,1,!1,i.toLowerCase(),null,!1,!1)}),N.xlinkHref=new v("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(i){N[i]=new v(i,1,!1,i.toLowerCase(),null,!0,!0)});function j(i,l,p,k){var b=N.hasOwnProperty(l)?N[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 T=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,I=Symbol.for("react.element"),R=Symbol.for("react.portal"),C=Symbol.for("react.fragment"),O=Symbol.for("react.strict_mode"),A=Symbol.for("react.profiler"),D=Symbol.for("react.provider"),B=Symbol.for("react.context"),W=Symbol.for("react.forward_ref"),U=Symbol.for("react.suspense"),Q=Symbol.for("react.suspense_list"),Y=Symbol.for("react.memo"),se=Symbol.for("react.lazy"),H=Symbol.for("react.offscreen"),$=Symbol.iterator;function Z(i){return i===null||typeof i!="object"?null:(i=$&&i[$]||i["@@iterator"],typeof i=="function"?i:null)}var q=Object.assign,K;function ne(i){if(K===void 0)try{throw Error()}catch(p){var l=p.stack.trim().match(/\n( *(at )?)/);K=l&&l[1]||""}return`
35
- `+K+i}var de=!1;function pe(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
- `),E=k.stack.split(`
37
- `),M=b.length-1,V=E.length-1;1<=M&&0<=V&&b[M]!==E[V];)V--;for(;1<=M&&0<=V;M--,V--)if(b[M]!==E[V]){if(M!==1||V!==1)do if(M--,V--,0>V||b[M]!==E[V]){var ee=`
38
- `+b[M].replace(" at new "," at ");return i.displayName&&ee.includes("<anonymous>")&&(ee=ee.replace("<anonymous>",i.displayName)),ee}while(1<=M&&0<=V);break}}}finally{de=!1,Error.prepareStackTrace=p}return(i=i?i.displayName||i.name:"")?ne(i):""}function je(i){switch(i.tag){case 5:return ne(i.type);case 16:return ne("Lazy");case 13:return ne("Suspense");case 19:return ne("SuspenseList");case 0:case 2:case 15:return i=pe(i.type,!1),i;case 11:return i=pe(i.type.render,!1),i;case 1:return i=pe(i.type,!0),i;default:return""}}function _e(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 A:return"Profiler";case O:return"StrictMode";case U:return"Suspense";case Q:return"SuspenseList"}if(typeof i=="object")switch(i.$$typeof){case B:return(i.displayName||"Context")+".Consumer";case D:return(i._context.displayName||"Context")+".Provider";case W:var l=i.render;return i=i.displayName,i||(i=l.displayName||l.name||"",i=i!==""?"ForwardRef("+i+")":"ForwardRef"),i;case Y:return l=i.displayName||null,l!==null?l:_e(i.type)||"Memo";case se:l=i._payload,i=i._init;try{return _e(i(l))}catch{}}return null}function fe(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 _e(l);case 8:return l===O?"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 te(i){switch(typeof i){case"boolean":case"number":case"string":case"undefined":return i;case"object":return i;default:return""}}function re(i){var l=i.type;return(i=i.nodeName)&&i.toLowerCase()==="input"&&(l==="checkbox"||l==="radio")}function we(i){var l=re(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,E=p.set;return Object.defineProperty(i,l,{configurable:!0,get:function(){return b.call(this)},set:function(M){k=""+M,E.call(this,M)}}),Object.defineProperty(i,l,{enumerable:p.enumerable}),{getValue:function(){return k},setValue:function(M){k=""+M},stopTracking:function(){i._valueTracker=null,delete i[l]}}}}function ue(i){i._valueTracker||(i._valueTracker=we(i))}function le(i){if(!i)return!1;var l=i._valueTracker;if(!l)return!0;var p=l.getValue(),k="";return i&&(k=re(i)?i.checked?"true":"false":i.value),i=k,i!==p?(l.setValue(i),!0):!1}function be(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 Ce(i,l){var p=l.checked;return q({},l,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:p??i._wrapperState.initialChecked})}function Ne(i,l){var p=l.defaultValue==null?"":l.defaultValue,k=l.checked!=null?l.checked:l.defaultChecked;p=te(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 Ie(i,l){l=l.checked,l!=null&&j(i,"checked",l,!1)}function Be(i,l){Ie(i,l);var p=te(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")?zt(i,l.type,p):l.hasOwnProperty("defaultValue")&&zt(i,l.type,te(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 zt(i,l,p){(l!=="number"||be(i.ownerDocument)!==i)&&(p==null?i.defaultValue=""+i._wrapperState.initialValue:i.defaultValue!==""+p&&(i.defaultValue=""+p))}var Yt=Array.isArray;function _t(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=""+te(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 qe(i,l){if(l.dangerouslySetInnerHTML!=null)throw Error(n(91));return q({},l,{value:void 0,defaultValue:void 0,children:""+i._wrapperState.initialValue})}function xt(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(Yt(p)){if(1<p.length)throw Error(n(93));p=p[0]}l=p}l==null&&(l=""),p=l}i._wrapperState={initialValue:te(p)}}function ht(i,l){var p=te(l.value),k=te(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 at(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 Xt,Nt=(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(Xt=Xt||document.createElement("div"),Xt.innerHTML="<svg>"+l.valueOf().toString()+"</svg>",l=Xt.firstChild;i.firstChild;)i.removeChild(i.firstChild);for(;l.firstChild;)i.appendChild(l.firstChild)}});function Zt(i,l){if(l){var p=i.firstChild;if(p&&p===i.lastChild&&p.nodeType===3){p.nodeValue=l;return}}i.textContent=l}var gt={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},nr=["Webkit","ms","Moz","O"];Object.keys(gt).forEach(function(i){nr.forEach(function(l){l=l+i.charAt(0).toUpperCase()+i.substring(1),gt[l]=gt[i]})});function Jt(i,l,p){return l==null||typeof l=="boolean"||l===""?"":p||typeof l!="number"||l===0||gt.hasOwnProperty(i)&&gt[i]?(""+l).trim():l+"px"}function Rn(i,l){i=i.style;for(var p in l)if(l.hasOwnProperty(p)){var k=p.indexOf("--")===0,b=Jt(p,l[p],k);p==="float"&&(p="cssFloat"),k?i.setProperty(p,b):i[p]=b}}var Kn=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 un(i,l){if(l){if(Kn[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 vn(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 J=null;function ye(i){return i=i.target||i.srcElement||window,i.correspondingUseElement&&(i=i.correspondingUseElement),i.nodeType===3?i.parentNode:i}var We=null,rt=null,jt=null;function Ft(i){if(i=$c(i)){if(typeof We!="function")throw Error(n(280));var l=i.stateNode;l&&(l=jd(l),We(i.stateNode,i.type,l))}}function P(i){rt?jt?jt.push(i):jt=[i]:rt=i}function oe(){if(rt){var i=rt,l=jt;if(jt=rt=null,Ft(i),l)for(i=0;i<l.length;i++)Ft(l[i])}}function $e(i,l){return i(l)}function Fe(){}var Rt=!1;function Gt(i,l,p){if(Rt)return i(l,p);Rt=!0;try{return $e(i,l,p)}finally{Rt=!1,(rt!==null||jt!==null)&&(Fe(),oe())}}function Re(i,l){var p=i.stateNode;if(p===null)return null;var k=jd(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 He=!1;if(c)try{var Ze={};Object.defineProperty(Ze,"passive",{get:function(){He=!0}}),window.addEventListener("test",Ze,Ze),window.removeEventListener("test",Ze,Ze)}catch{He=!1}function Qt(i,l,p,k,b,E,M,V,ee){var ke=Array.prototype.slice.call(arguments,3);try{l.apply(p,ke)}catch(Le){this.onError(Le)}}var Wt=!1,En=null,Sn=!1,Ct=null,nn={onError:function(i){Wt=!0,En=i}};function sr(i,l,p,k,b,E,M,V,ee){Wt=!1,En=null,Qt.apply(nn,arguments)}function Pt(i,l,p,k,b,E,M,V,ee){if(sr.apply(this,arguments),Wt){if(Wt){var ke=En;Wt=!1,En=null}else throw Error(n(198));Sn||(Sn=!0,Ct=ke)}}function bn(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 ie(i){if(bn(i)!==i)throw Error(n(188))}function Te(i){var l=i.alternate;if(!l){if(l=bn(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 E=b.alternate;if(E===null){if(k=b.return,k!==null){p=k;continue}break}if(b.child===E.child){for(E=b.child;E;){if(E===p)return ie(b),i;if(E===k)return ie(b),l;E=E.sibling}throw Error(n(188))}if(p.return!==k.return)p=b,k=E;else{for(var M=!1,V=b.child;V;){if(V===p){M=!0,p=b,k=E;break}if(V===k){M=!0,k=b,p=E;break}V=V.sibling}if(!M){for(V=E.child;V;){if(V===p){M=!0,p=E,k=b;break}if(V===k){M=!0,k=E,p=b;break}V=V.sibling}if(!M)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 dt(i){return i=Te(i),i!==null?lt(i):null}function lt(i){if(i.tag===5||i.tag===6)return i;for(i=i.child;i!==null;){var l=lt(i);if(l!==null)return l;i=i.sibling}return null}var Bt=t.unstable_scheduleCallback,kn=t.unstable_cancelCallback,Dr=t.unstable_shouldYield,lr=t.unstable_requestPaint,ln=t.unstable_now,cr=t.unstable_getCurrentPriorityLevel,rn=t.unstable_ImmediatePriority,Ht=t.unstable_UserBlockingPriority,Ut=t.unstable_NormalPriority,xe=t.unstable_LowPriority,Ge=t.unstable_IdlePriority,kt=null,wt=null;function on(i){if(wt&&typeof wt.onCommitFiberRoot=="function")try{wt.onCommitFiberRoot(kt,i,void 0,(i.current.flags&128)===128)}catch{}}var dn=Math.clz32?Math.clz32:hn,Cn=Math.log,wn=Math.LN2;function hn(i){return i>>>=0,i===0?32:31-(Cn(i)/wn|0)|0}var Ln=64,vr=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,E=i.pingedLanes,M=p&268435455;if(M!==0){var V=M&~b;V!==0?k=X(V):(E&=M,E!==0&&(k=X(E)))}else M=p&~b,M!==0?k=X(M):E!==0&&(k=X(E));if(k===0)return 0;if(l!==0&&l!==k&&(l&b)===0&&(b=k&-k,E=l&-l,b>=E||b===16&&(E&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-dn(l),b=1<<p,k|=i[p],l&=~b;return k}function Ve(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 Kt(i,l){for(var p=i.suspendedLanes,k=i.pingedLanes,b=i.expirationTimes,E=i.pendingLanes;0<E;){var M=31-dn(E),V=1<<M,ee=b[M];ee===-1?((V&p)===0||(V&k)!==0)&&(b[M]=Ve(V,l)):ee<=l&&(i.expiredLanes|=V),E&=~V}}function Mt(i){return i=i.pendingLanes&-1073741825,i!==0?i:i&1073741824?1073741824:0}function pn(){var i=Ln;return Ln<<=1,(Ln&4194240)===0&&(Ln=64),i}function _n(i){for(var l=[],p=0;31>p;p++)l.push(i);return l}function zr(i,l,p){i.pendingLanes|=l,l!==536870912&&(i.suspendedLanes=0,i.pingedLanes=0),i=i.eventTimes,l=31-dn(l),i[l]=p}function qn(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-dn(p),E=1<<b;l[b]=0,k[b]=-1,i[b]=-1,p&=~E}}function os(i,l){var p=i.entangledLanes|=l;for(i=i.entanglements;p;){var k=31-dn(p),b=1<<k;b&l|i[k]&l&&(i[k]|=l),p&=~b}}var Vt=0;function yt(i){return i&=-i,1<i?4<i?(i&268435455)!==0?16:536870912:4:1}var ys,An,sn,br,Cr,Oe=!1,F=[],G=null,ce=null,Ee=null,ve=new Map,Ye=new Map,vt=[],Nn="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 Fn(i,l){switch(i){case"focusin":case"focusout":G=null;break;case"dragenter":case"dragleave":ce=null;break;case"mouseover":case"mouseout":Ee=null;break;case"pointerover":case"pointerout":ve.delete(l.pointerId);break;case"gotpointercapture":case"lostpointercapture":Ye.delete(l.pointerId)}}function Xn(i,l,p,k,b,E){return i===null||i.nativeEvent!==E?(i={blockedOn:l,domEventName:p,eventSystemFlags:k,nativeEvent:E,targetContainers:[b]},l!==null&&(l=$c(l),l!==null&&An(l)),i):(i.eventSystemFlags|=k,l=i.targetContainers,b!==null&&l.indexOf(b)===-1&&l.push(b),i)}function Ar(i,l,p,k,b){switch(l){case"focusin":return G=Xn(G,i,l,p,k,b),!0;case"dragenter":return ce=Xn(ce,i,l,p,k,b),!0;case"mouseover":return Ee=Xn(Ee,i,l,p,k,b),!0;case"pointerover":var E=b.pointerId;return ve.set(E,Xn(ve.get(E)||null,i,l,p,k,b)),!0;case"gotpointercapture":return E=b.pointerId,Ye.set(E,Xn(Ye.get(E)||null,i,l,p,k,b)),!0}return!1}function ir(i){var l=Yi(i.target);if(l!==null){var p=bn(l);if(p!==null){if(l=p.tag,l===13){if(l=fn(p),l!==null){i.blockedOn=l,Cr(i.priority,function(){sn(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 Ks(i){if(i.blockedOn!==null)return!1;for(var l=i.targetContainers;0<l.length;){var p=Zs(i.domEventName,i.eventSystemFlags,l[0],i.nativeEvent);if(p===null){p=i.nativeEvent;var k=new p.constructor(p.type,p);J=k,p.target.dispatchEvent(k),J=null}else return l=$c(p),l!==null&&An(l),i.blockedOn=p,!1;l.shift()}return!0}function sc(i,l,p){Ks(i)&&p.delete(l)}function rd(){Oe=!1,G!==null&&Ks(G)&&(G=null),ce!==null&&Ks(ce)&&(ce=null),Ee!==null&&Ks(Ee)&&(Ee=null),ve.forEach(sc),Ye.forEach(sc)}function Fi(i,l){i.blockedOn===l&&(i.blockedOn=null,Oe||(Oe=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,rd)))}function Bi(i){function l(b){return Fi(b,i)}if(0<F.length){Fi(F[0],i);for(var p=1;p<F.length;p++){var k=F[p];k.blockedOn===i&&(k.blockedOn=null)}}for(G!==null&&Fi(G,i),ce!==null&&Fi(ce,i),Ee!==null&&Fi(Ee,i),ve.forEach(l),Ye.forEach(l),p=0;p<vt.length;p++)k=vt[p],k.blockedOn===i&&(k.blockedOn=null);for(;0<vt.length&&(p=vt[0],p.blockedOn===null);)ir(p),p.blockedOn===null&&vt.shift()}var qs=T.ReactCurrentBatchConfig,vs=!0;function bs(i,l,p,k){var b=Vt,E=qs.transition;qs.transition=null;try{Vt=1,Fa(i,l,p,k)}finally{Vt=b,qs.transition=E}}function za(i,l,p,k){var b=Vt,E=qs.transition;qs.transition=null;try{Vt=4,Fa(i,l,p,k)}finally{Vt=b,qs.transition=E}}function Fa(i,l,p,k){if(vs){var b=Zs(i,l,p,k);if(b===null)Dp(i,l,k,xs,p),Fn(i,k);else if(Ar(b,i,l,p,k))k.stopPropagation();else if(Fn(i,k),l&4&&-1<Nn.indexOf(i)){for(;b!==null;){var E=$c(b);if(E!==null&&ys(E),E=Zs(i,l,p,k),E===null&&Dp(i,l,k,xs,p),E===b)break;b=E}b!==null&&k.stopPropagation()}else Dp(i,l,k,null,p)}}var xs=null;function Zs(i,l,p,k){if(xs=null,i=ye(k),i=Yi(i),i!==null)if(l=bn(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 xs=i,null}function ic(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(cr()){case rn:return 1;case Ht:return 4;case Ut:case xe:return 16;case Ge:return 536870912;default:return 16}default:return 16}}var ko=null,Ba=null,Gs=null;function Ir(){if(Gs)return Gs;var i,l=Ba,p=l.length,k,b="value"in ko?ko.value:ko.textContent,E=b.length;for(i=0;i<p&&l[i]===b[i];i++);var M=p-i;for(k=1;k<=M&&l[p-k]===b[E-k];k++);return Gs=b.slice(i,1<k?1-k:void 0)}function Ua(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 Ha(){return!0}function od(){return!1}function Rr(i){function l(p,k,b,E,M){this._reactName=p,this._targetInst=b,this.type=k,this.nativeEvent=E,this.target=M,this.currentTarget=null;for(var V in i)i.hasOwnProperty(V)&&(p=i[V],this[V]=p?p(E):E[V]);return this.isDefaultPrevented=(E.defaultPrevented!=null?E.defaultPrevented:E.returnValue===!1)?Ha: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=Ha)},stopPropagation:function(){var p=this.nativeEvent;p&&(p.stopPropagation?p.stopPropagation():typeof p.cancelBubble!="unknown"&&(p.cancelBubble=!0),this.isPropagationStopped=Ha)},persist:function(){},isPersistent:Ha}),l}var ss={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(i){return i.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},is=Rr(ss),Es=q({},ss,{view:0,detail:0}),sd=Rr(Es),ac,Ui,Hi,Wi=q({},Es,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Ki,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!==Hi&&(Hi&&i.type==="mousemove"?(ac=i.screenX-Hi.screenX,Ui=i.screenY-Hi.screenY):Ui=ac=0,Hi=i),ac)},movementY:function(i){return"movementY"in i?i.movementY:Ui}}),id=Rr(Wi),ad=q({},Wi,{dataTransfer:0}),Cp=Rr(ad),ld=q({},Es,{relatedTarget:0}),xr=Rr(ld),cd=q({},ss,{animationName:0,elapsedTime:0,pseudoElement:0}),ud=Rr(cd),Wa=q({},ss,{clipboardData:function(i){return"clipboardData"in i?i.clipboardData:window.clipboardData}}),Ap=Rr(Wa),lc=q({},ss,{data:0}),Ka=Rr(lc),qa={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Bn={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"},dd={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function Za(i){var l=this.nativeEvent;return l.getModifierState?l.getModifierState(i):(i=dd[i])?!!l[i]:!1}function Ki(){return Za}var Ga=q({},Es,{key:function(i){if(i.key){var l=qa[i.key]||i.key;if(l!=="Unidentified")return l}return i.type==="keypress"?(i=Ua(i),i===13?"Enter":String.fromCharCode(i)):i.type==="keydown"||i.type==="keyup"?Bn[i.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Ki,charCode:function(i){return i.type==="keypress"?Ua(i):0},keyCode:function(i){return i.type==="keydown"||i.type==="keyup"?i.keyCode:0},which:function(i){return i.type==="keypress"?Ua(i):i.type==="keydown"||i.type==="keyup"?i.keyCode:0}}),Va=Rr(Ga),Vs=q({},Wi,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),cc=Rr(Vs),uc=q({},Es,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Ki}),dc=Rr(uc),fd=q({},ss,{propertyName:0,elapsedTime:0,pseudoElement:0}),nv=Rr(fd),hd=q({},Wi,{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}),Ya=Rr(hd),pd=[9,13,27,32],Xa=c&&"CompositionEvent"in window,Ys=null;c&&"documentMode"in document&&(Ys=document.documentMode);var mr=c&&"TextEvent"in window&&!Ys,qi=c&&(!Xa||Ys&&8<Ys&&11>=Ys),md=" ",Zi=!1;function fc(i,l){switch(i){case"keyup":return pd.indexOf(l.keyCode)!==-1;case"keydown":return l.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Xs(i){return i=i.detail,typeof i=="object"&&"data"in i?i.data:null}var Co=!1;function hc(i,l){switch(i){case"compositionend":return Xs(l);case"keypress":return l.which!==32?null:(Zi=!0,md);case"textInput":return i=l.data,i===md&&Zi?null:i;default:return null}}function Ip(i,l){if(Co)return i==="compositionend"||!Xa&&fc(i,l)?(i=Ir(),Gs=Ba=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 qi&&l.locale!=="ko"?null:l.data;default:return null}}var pc={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 gd(i){var l=i&&i.nodeName&&i.nodeName.toLowerCase();return l==="input"?!!pc[i.type]:l==="textarea"}function mc(i,l,p,k){P(k),l=_d(l,"onChange"),0<l.length&&(p=new is("onChange","change",null,p,k),i.push({event:p,listeners:l}))}var Qs=null,Js=null;function kd(i){ov(i,0)}function Vr(i){var l=sl(i);if(le(l))return i}function Rp(i,l){if(i==="change")return l}var as=!1;if(c){var ei;if(c){var gc="oninput"in document;if(!gc){var Gi=document.createElement("div");Gi.setAttribute("oninput","return;"),gc=typeof Gi.oninput=="function"}ei=gc}else ei=!1;as=ei&&(!document.documentMode||9<document.documentMode)}function Qa(){Qs&&(Qs.detachEvent("onpropertychange",Ja),Js=Qs=null)}function Ja(i){if(i.propertyName==="value"&&Vr(Js)){var l=[];mc(l,Js,i,ye(i)),Gt(kd,l)}}function wd(i,l,p){i==="focusin"?(Qa(),Qs=l,Js=p,Qs.attachEvent("onpropertychange",Ja)):i==="focusout"&&Qa()}function Op(i){if(i==="selectionchange"||i==="keyup"||i==="keydown")return Vr(Js)}function kc(i,l){if(i==="click")return Vr(l)}function yd(i,l){if(i==="input"||i==="change")return Vr(l)}function vd(i,l){return i===l&&(i!==0||1/i===1/l)||i!==i&&l!==l}var to=typeof Object.is=="function"?Object.is:vd;function Vi(i,l){if(to(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)||!to(i[b],l[b]))return!1}return!0}function wc(i){for(;i&&i.firstChild;)i=i.firstChild;return i}function yc(i,l){var p=wc(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=wc(p)}}function vc(i,l){return i&&l?i===l?!0:i&&i.nodeType===3?!1:l&&l.nodeType===3?vc(i,l.parentNode):"contains"in i?i.contains(l):i.compareDocumentPosition?!!(i.compareDocumentPosition(l)&16):!1:!1}function bc(){for(var i=window,l=be();l instanceof i.HTMLIFrameElement;){try{var p=typeof l.contentWindow.location.href=="string"}catch{p=!1}if(p)i=l.contentWindow;else break;l=be(i.document)}return l}function el(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=bc(),p=i.focusedElem,k=i.selectionRange;if(l!==p&&p&&p.ownerDocument&&vc(p.ownerDocument.documentElement,p)){if(k!==null&&el(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,E=Math.min(k.start,b);k=k.end===void 0?E:Math.min(k.end,b),!i.extend&&E>k&&(b=k,k=E,E=b),b=yc(p,E);var M=yc(p,k);b&&M&&(i.rangeCount!==1||i.anchorNode!==b.node||i.anchorOffset!==b.offset||i.focusNode!==M.node||i.focusOffset!==M.offset)&&(l=l.createRange(),l.setStart(b.node,b.offset),i.removeAllRanges(),E>k?(i.addRange(l),i.extend(M.node,M.offset)):(l.setEnd(M.node,M.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,Ss=null,tl=null,ti=null,nl=!1;function xc(i,l,p){var k=p.window===p?p.document:p.nodeType===9?p:p.ownerDocument;nl||Ss==null||Ss!==be(k)||(k=Ss,"selectionStart"in k&&el(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}),ti&&Vi(ti,k)||(ti=k,k=_d(tl,"onSelect"),0<k.length&&(l=new is("onSelect","select",null,l,p),i.push({event:l,listeners:k}),l.target=Ss)))}function z(i,l){var p={};return p[i.toLowerCase()]=l.toLowerCase(),p["Webkit"+i]="webkit"+l,p["Moz"+i]="moz"+l,p}var Me={animationend:z("Animation","AnimationEnd"),animationiteration:z("Animation","AnimationIteration"),animationstart:z("Animation","AnimationStart"),transitionend:z("Transition","TransitionEnd")},pt={},$t={};c&&($t=document.createElement("div").style,"AnimationEvent"in window||(delete Me.animationend.animation,delete Me.animationiteration.animation,delete Me.animationstart.animation),"TransitionEvent"in window||delete Me.transitionend.transition);function Zn(i){if(pt[i])return pt[i];if(!Me[i])return i;var l=Me[i],p;for(p in l)if(l.hasOwnProperty(p)&&p in $t)return pt[i]=l[p];return i}var rr=Zn("animationend"),ni=Zn("animationiteration"),Ec=Zn("animationstart"),wo=Zn("transitionend"),Ed=new Map,Sc="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 ri(i,l){Ed.set(i,l),s(l,[i])}for(var Mp=0;Mp<Sc.length;Mp++){var Lp=Sc[Mp],PC=Lp.toLowerCase(),DC=Lp[0].toUpperCase()+Lp.slice(1);ri(PC,"on"+DC)}ri(rr,"onAnimationEnd"),ri(ni,"onAnimationIteration"),ri(Ec,"onAnimationStart"),ri("dblclick","onDoubleClick"),ri("focusin","onFocus"),ri("focusout","onBlur"),ri(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 _c="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(" "),zC=new Set("cancel close invalid load scroll toggle".split(" ").concat(_c));function rv(i,l,p){var k=i.type||"unknown-event";i.currentTarget=p,Pt(k,l,void 0,i),i.currentTarget=null}function ov(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 E=void 0;if(l)for(var M=k.length-1;0<=M;M--){var V=k[M],ee=V.instance,ke=V.currentTarget;if(V=V.listener,ee!==E&&b.isPropagationStopped())break e;rv(b,V,ke),E=ee}else for(M=0;M<k.length;M++){if(V=k[M],ee=V.instance,ke=V.currentTarget,V=V.listener,ee!==E&&b.isPropagationStopped())break e;rv(b,V,ke),E=ee}}}if(Sn)throw i=Ct,Sn=!1,Ct=null,i}function Un(i,l){var p=l[Wp];p===void 0&&(p=l[Wp]=new Set);var k=i+"__bubble";p.has(k)||(sv(l,i,2,!1),p.add(k))}function Pp(i,l,p){var k=0;l&&(k|=4),sv(p,i,k,l)}var Sd="_reactListening"+Math.random().toString(36).slice(2);function Nc(i){if(!i[Sd]){i[Sd]=!0,r.forEach(function(p){p!=="selectionchange"&&(zC.has(p)||Pp(p,!1,i),Pp(p,!0,i))});var l=i.nodeType===9?i:i.ownerDocument;l===null||l[Sd]||(l[Sd]=!0,Pp("selectionchange",!1,l))}}function sv(i,l,p,k){switch(ic(l)){case 1:var b=bs;break;case 4:b=za;break;default:b=Fa}p=b.bind(null,l,p,i),b=void 0,!He||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 Dp(i,l,p,k,b){var E=k;if((l&1)===0&&(l&2)===0&&k!==null)e:for(;;){if(k===null)return;var M=k.tag;if(M===3||M===4){var V=k.stateNode.containerInfo;if(V===b||V.nodeType===8&&V.parentNode===b)break;if(M===4)for(M=k.return;M!==null;){var ee=M.tag;if((ee===3||ee===4)&&(ee=M.stateNode.containerInfo,ee===b||ee.nodeType===8&&ee.parentNode===b))return;M=M.return}for(;V!==null;){if(M=Yi(V),M===null)return;if(ee=M.tag,ee===5||ee===6){k=E=M;continue e}V=V.parentNode}}k=k.return}Gt(function(){var ke=E,Le=ye(p),ze=[];e:{var Ae=Ed.get(i);if(Ae!==void 0){var Xe=is,ot=i;switch(i){case"keypress":if(Ua(p)===0)break e;case"keydown":case"keyup":Xe=Va;break;case"focusin":ot="focus",Xe=xr;break;case"focusout":ot="blur",Xe=xr;break;case"beforeblur":case"afterblur":Xe=xr;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=id;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":Xe=Cp;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":Xe=dc;break;case rr:case ni:case Ec:Xe=ud;break;case wo:Xe=nv;break;case"scroll":Xe=sd;break;case"wheel":Xe=Ya;break;case"copy":case"cut":case"paste":Xe=Ap;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":Xe=cc}var st=(l&4)!==0,ar=!st&&i==="scroll",he=st?Ae!==null?Ae+"Capture":null:Ae;st=[];for(var ae=ke,me;ae!==null;){me=ae;var Ue=me.stateNode;if(me.tag===5&&Ue!==null&&(me=Ue,he!==null&&(Ue=Re(ae,he),Ue!=null&&st.push(Tc(ae,Ue,me)))),ar)break;ae=ae.return}0<st.length&&(Ae=new Xe(Ae,ot,null,p,Le),ze.push({event:Ae,listeners:st}))}}if((l&7)===0){e:{if(Ae=i==="mouseover"||i==="pointerover",Xe=i==="mouseout"||i==="pointerout",Ae&&p!==J&&(ot=p.relatedTarget||p.fromElement)&&(Yi(ot)||ot[_s]))break e;if((Xe||Ae)&&(Ae=Le.window===Le?Le:(Ae=Le.ownerDocument)?Ae.defaultView||Ae.parentWindow:window,Xe?(ot=p.relatedTarget||p.toElement,Xe=ke,ot=ot?Yi(ot):null,ot!==null&&(ar=bn(ot),ot!==ar||ot.tag!==5&&ot.tag!==6)&&(ot=null)):(Xe=null,ot=ke),Xe!==ot)){if(st=id,Ue="onMouseLeave",he="onMouseEnter",ae="mouse",(i==="pointerout"||i==="pointerover")&&(st=cc,Ue="onPointerLeave",he="onPointerEnter",ae="pointer"),ar=Xe==null?Ae:sl(Xe),me=ot==null?Ae:sl(ot),Ae=new st(Ue,ae+"leave",Xe,p,Le),Ae.target=ar,Ae.relatedTarget=me,Ue=null,Yi(Le)===ke&&(st=new st(he,ae+"enter",ot,p,Le),st.target=me,st.relatedTarget=ar,Ue=st),ar=Ue,Xe&&ot)t:{for(st=Xe,he=ot,ae=0,me=st;me;me=rl(me))ae++;for(me=0,Ue=he;Ue;Ue=rl(Ue))me++;for(;0<ae-me;)st=rl(st),ae--;for(;0<me-ae;)he=rl(he),me--;for(;ae--;){if(st===he||he!==null&&st===he.alternate)break t;st=rl(st),he=rl(he)}st=null}else st=null;Xe!==null&&iv(ze,Ae,Xe,st,!1),ot!==null&&ar!==null&&iv(ze,ar,ot,st,!0)}}e:{if(Ae=ke?sl(ke):window,Xe=Ae.nodeName&&Ae.nodeName.toLowerCase(),Xe==="select"||Xe==="input"&&Ae.type==="file")var ct=Rp;else if(gd(Ae))if(as)ct=yd;else{ct=Op;var Et=wd}else(Xe=Ae.nodeName)&&Xe.toLowerCase()==="input"&&(Ae.type==="checkbox"||Ae.type==="radio")&&(ct=kc);if(ct&&(ct=ct(i,ke))){mc(ze,ct,p,Le);break e}Et&&Et(i,Ae,ke),i==="focusout"&&(Et=Ae._wrapperState)&&Et.controlled&&Ae.type==="number"&&zt(Ae,"number",Ae.value)}switch(Et=ke?sl(ke):window,i){case"focusin":(gd(Et)||Et.contentEditable==="true")&&(Ss=Et,tl=ke,ti=null);break;case"focusout":ti=tl=Ss=null;break;case"mousedown":nl=!0;break;case"contextmenu":case"mouseup":case"dragend":nl=!1,xc(ze,p,Le);break;case"selectionchange":if(xd)break;case"keydown":case"keyup":xc(ze,p,Le)}var St;if(Xa)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?fc(i,p)&&(Ot="onCompositionEnd"):i==="keydown"&&p.keyCode===229&&(Ot="onCompositionStart");Ot&&(qi&&p.locale!=="ko"&&(Co||Ot!=="onCompositionStart"?Ot==="onCompositionEnd"&&Co&&(St=Ir()):(ko=Le,Ba="value"in ko?ko.value:ko.textContent,Co=!0)),Et=_d(ke,Ot),0<Et.length&&(Ot=new Ka(Ot,i,null,p,Le),ze.push({event:Ot,listeners:Et}),St?Ot.data=St:(St=Xs(p),St!==null&&(Ot.data=St)))),(St=mr?hc(i,p):Ip(i,p))&&(ke=_d(ke,"onBeforeInput"),0<ke.length&&(Le=new Ka("onBeforeInput","beforeinput",null,p,Le),ze.push({event:Le,listeners:ke}),Le.data=St))}ov(ze,l)})}function Tc(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,E=b.stateNode;b.tag===5&&E!==null&&(b=E,E=Re(i,p),E!=null&&k.unshift(Tc(i,E,b)),E=Re(i,l),E!=null&&k.push(Tc(i,E,b))),i=i.return}return k}function rl(i){if(i===null)return null;do i=i.return;while(i&&i.tag!==5);return i||null}function iv(i,l,p,k,b){for(var E=l._reactName,M=[];p!==null&&p!==k;){var V=p,ee=V.alternate,ke=V.stateNode;if(ee!==null&&ee===k)break;V.tag===5&&ke!==null&&(V=ke,b?(ee=Re(p,E),ee!=null&&M.unshift(Tc(p,ee,V))):b||(ee=Re(p,E),ee!=null&&M.push(Tc(p,ee,V)))),p=p.return}M.length!==0&&i.push({event:l,listeners:M})}var FC=/\r\n?/g,BC=/\u0000|\uFFFD/g;function av(i){return(typeof i=="string"?i:""+i).replace(FC,`
39
- `).replace(BC,"")}function Nd(i,l,p){if(l=av(l),av(i)!==l&&p)throw Error(n(425))}function Td(){}var zp=null,Fp=null;function Bp(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 Up=typeof setTimeout=="function"?setTimeout:void 0,UC=typeof clearTimeout=="function"?clearTimeout:void 0,lv=typeof Promise=="function"?Promise:void 0,HC=typeof queueMicrotask=="function"?queueMicrotask:typeof lv<"u"?function(i){return lv.resolve(null).then(i).catch(WC)}:Up;function WC(i){setTimeout(function(){throw i})}function Hp(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),Bi(l);return}k--}else p!=="$"&&p!=="$?"&&p!=="$!"||k++;p=b}while(p);Bi(l)}function oi(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 cv(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 ol=Math.random().toString(36).slice(2),ls="__reactFiber$"+ol,jc="__reactProps$"+ol,_s="__reactContainer$"+ol,Wp="__reactEvents$"+ol,KC="__reactListeners$"+ol,qC="__reactHandles$"+ol;function Yi(i){var l=i[ls];if(l)return l;for(var p=i.parentNode;p;){if(l=p[_s]||p[ls]){if(p=l.alternate,l.child!==null||p!==null&&p.child!==null)for(i=cv(i);i!==null;){if(p=i[ls])return p;i=cv(i)}return l}i=p,p=i.parentNode}return null}function $c(i){return i=i[ls]||i[_s],!i||i.tag!==5&&i.tag!==6&&i.tag!==13&&i.tag!==3?null:i}function sl(i){if(i.tag===5||i.tag===6)return i.stateNode;throw Error(n(33))}function jd(i){return i[jc]||null}var Kp=[],il=-1;function si(i){return{current:i}}function Hn(i){0>il||(i.current=Kp[il],Kp[il]=null,il--)}function Pn(i,l){il++,Kp[il]=i.current,i.current=l}var ii={},Fr=si(ii),no=si(!1),Xi=ii;function al(i,l){var p=i.type.contextTypes;if(!p)return ii;var k=i.stateNode;if(k&&k.__reactInternalMemoizedUnmaskedChildContext===l)return k.__reactInternalMemoizedMaskedChildContext;var b={},E;for(E in p)b[E]=l[E];return k&&(i=i.stateNode,i.__reactInternalMemoizedUnmaskedChildContext=l,i.__reactInternalMemoizedMaskedChildContext=b),b}function ro(i){return i=i.childContextTypes,i!=null}function $d(){Hn(no),Hn(Fr)}function uv(i,l,p){if(Fr.current!==ii)throw Error(n(168));Pn(Fr,l),Pn(no,p)}function dv(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,fe(i)||"Unknown",b));return q({},p,k)}function Cd(i){return i=(i=i.stateNode)&&i.__reactInternalMemoizedMergedChildContext||ii,Xi=Fr.current,Pn(Fr,i),Pn(no,no.current),!0}function fv(i,l,p){var k=i.stateNode;if(!k)throw Error(n(169));p?(i=dv(i,l,Xi),k.__reactInternalMemoizedMergedChildContext=i,Hn(no),Hn(Fr),Pn(Fr,i)):Hn(no),Pn(no,p)}var Ns=null,Ad=!1,qp=!1;function hv(i){Ns===null?Ns=[i]:Ns.push(i)}function ZC(i){Ad=!0,hv(i)}function ai(){if(!qp&&Ns!==null){qp=!0;var i=0,l=Vt;try{var p=Ns;for(Vt=1;i<p.length;i++){var k=p[i];do k=k(!0);while(k!==null)}Ns=null,Ad=!1}catch(b){throw Ns!==null&&(Ns=Ns.slice(i+1)),Bt(rn,ai),b}finally{Vt=l,qp=!1}}return null}var ll=[],cl=0,Id=null,Rd=0,Ao=[],Io=0,Qi=null,Ts=1,js="";function Ji(i,l){ll[cl++]=Rd,ll[cl++]=Id,Id=i,Rd=l}function pv(i,l,p){Ao[Io++]=Ts,Ao[Io++]=js,Ao[Io++]=Qi,Qi=i;var k=Ts;i=js;var b=32-dn(k)-1;k&=~(1<<b),p+=1;var E=32-dn(l)+b;if(30<E){var M=b-b%5;E=(k&(1<<M)-1).toString(32),k>>=M,b-=M,Ts=1<<32-dn(l)+b|p<<b|k,js=E+i}else Ts=1<<E|p<<b|k,js=i}function Zp(i){i.return!==null&&(Ji(i,1),pv(i,1,0))}function Gp(i){for(;i===Id;)Id=ll[--cl],ll[cl]=null,Rd=ll[--cl],ll[cl]=null;for(;i===Qi;)Qi=Ao[--Io],Ao[Io]=null,js=Ao[--Io],Ao[Io]=null,Ts=Ao[--Io],Ao[Io]=null}var yo=null,vo=null,Gn=!1,Wo=null;function mv(i,l){var p=Lo(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 gv(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=oi(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=Qi!==null?{id:Ts,overflow:js}:null,i.memoizedState={dehydrated:l,treeContext:p,retryLane:1073741824},p=Lo(18,null,null,0),p.stateNode=l,p.return=i,i.child=p,yo=i,vo=null,!0):!1;default:return!1}}function Vp(i){return(i.mode&1)!==0&&(i.flags&128)===0}function Yp(i){if(Gn){var l=vo;if(l){var p=l;if(!gv(i,l)){if(Vp(i))throw Error(n(418));l=oi(p.nextSibling);var k=yo;l&&gv(i,l)?mv(k,p):(i.flags=i.flags&-4097|2,Gn=!1,yo=i)}}else{if(Vp(i))throw Error(n(418));i.flags=i.flags&-4097|2,Gn=!1,yo=i}}}function kv(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(!Gn)return kv(i),Gn=!0,!1;var l;if((l=i.tag!==3)&&!(l=i.tag!==5)&&(l=i.type,l=l!=="head"&&l!=="body"&&!Bp(i.type,i.memoizedProps)),l&&(l=vo)){if(Vp(i))throw wv(),Error(n(418));for(;l;)mv(i,l),l=oi(l.nextSibling)}if(kv(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=oi(i.nextSibling);break e}l--}else p!=="$"&&p!=="$!"&&p!=="$?"||l++}i=i.nextSibling}vo=null}}else vo=yo?oi(i.stateNode.nextSibling):null;return!0}function wv(){for(var i=vo;i;)i=oi(i.nextSibling)}function ul(){vo=yo=null,Gn=!1}function Xp(i){Wo===null?Wo=[i]:Wo.push(i)}var GC=T.ReactCurrentBatchConfig;function Cc(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,E=""+i;return l!==null&&l.ref!==null&&typeof l.ref=="function"&&l.ref._stringRef===E?l.ref:(l=function(M){var V=b.refs;M===null?delete V[E]:V[E]=M},l._stringRef=E,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 yv(i){var l=i._init;return l(i._payload)}function vv(i){function l(he,ae){if(i){var me=he.deletions;me===null?(he.deletions=[ae],he.flags|=16):me.push(ae)}}function p(he,ae){if(!i)return null;for(;ae!==null;)l(he,ae),ae=ae.sibling;return null}function k(he,ae){for(he=new Map;ae!==null;)ae.key!==null?he.set(ae.key,ae):he.set(ae.index,ae),ae=ae.sibling;return he}function b(he,ae){return he=mi(he,ae),he.index=0,he.sibling=null,he}function E(he,ae,me){return he.index=me,i?(me=he.alternate,me!==null?(me=me.index,me<ae?(he.flags|=2,ae):me):(he.flags|=2,ae)):(he.flags|=1048576,ae)}function M(he){return i&&he.alternate===null&&(he.flags|=2),he}function V(he,ae,me,Ue){return ae===null||ae.tag!==6?(ae=Um(me,he.mode,Ue),ae.return=he,ae):(ae=b(ae,me),ae.return=he,ae)}function ee(he,ae,me,Ue){var ct=me.type;return ct===C?Le(he,ae,me.props.children,Ue,me.key):ae!==null&&(ae.elementType===ct||typeof ct=="object"&&ct!==null&&ct.$$typeof===se&&yv(ct)===ae.type)?(Ue=b(ae,me.props),Ue.ref=Cc(he,ae,me),Ue.return=he,Ue):(Ue=sf(me.type,me.key,me.props,null,he.mode,Ue),Ue.ref=Cc(he,ae,me),Ue.return=he,Ue)}function ke(he,ae,me,Ue){return ae===null||ae.tag!==4||ae.stateNode.containerInfo!==me.containerInfo||ae.stateNode.implementation!==me.implementation?(ae=Hm(me,he.mode,Ue),ae.return=he,ae):(ae=b(ae,me.children||[]),ae.return=he,ae)}function Le(he,ae,me,Ue,ct){return ae===null||ae.tag!==7?(ae=aa(me,he.mode,Ue,ct),ae.return=he,ae):(ae=b(ae,me),ae.return=he,ae)}function ze(he,ae,me){if(typeof ae=="string"&&ae!==""||typeof ae=="number")return ae=Um(""+ae,he.mode,me),ae.return=he,ae;if(typeof ae=="object"&&ae!==null){switch(ae.$$typeof){case I:return me=sf(ae.type,ae.key,ae.props,null,he.mode,me),me.ref=Cc(he,null,ae),me.return=he,me;case R:return ae=Hm(ae,he.mode,me),ae.return=he,ae;case se:var Ue=ae._init;return ze(he,Ue(ae._payload),me)}if(Yt(ae)||Z(ae))return ae=aa(ae,he.mode,me,null),ae.return=he,ae;Md(he,ae)}return null}function Ae(he,ae,me,Ue){var ct=ae!==null?ae.key:null;if(typeof me=="string"&&me!==""||typeof me=="number")return ct!==null?null:V(he,ae,""+me,Ue);if(typeof me=="object"&&me!==null){switch(me.$$typeof){case I:return me.key===ct?ee(he,ae,me,Ue):null;case R:return me.key===ct?ke(he,ae,me,Ue):null;case se:return ct=me._init,Ae(he,ae,ct(me._payload),Ue)}if(Yt(me)||Z(me))return ct!==null?null:Le(he,ae,me,Ue,null);Md(he,me)}return null}function Xe(he,ae,me,Ue,ct){if(typeof Ue=="string"&&Ue!==""||typeof Ue=="number")return he=he.get(me)||null,V(ae,he,""+Ue,ct);if(typeof Ue=="object"&&Ue!==null){switch(Ue.$$typeof){case I:return he=he.get(Ue.key===null?me:Ue.key)||null,ee(ae,he,Ue,ct);case R:return he=he.get(Ue.key===null?me:Ue.key)||null,ke(ae,he,Ue,ct);case se:var Et=Ue._init;return Xe(he,ae,me,Et(Ue._payload),ct)}if(Yt(Ue)||Z(Ue))return he=he.get(me)||null,Le(ae,he,Ue,ct,null);Md(ae,Ue)}return null}function ot(he,ae,me,Ue){for(var ct=null,Et=null,St=ae,Ot=ae=0,_r=null;St!==null&&Ot<me.length;Ot++){St.index>Ot?(_r=St,St=null):_r=St.sibling;var yn=Ae(he,St,me[Ot],Ue);if(yn===null){St===null&&(St=_r);break}i&&St&&yn.alternate===null&&l(he,St),ae=E(yn,ae,Ot),Et===null?ct=yn:Et.sibling=yn,Et=yn,St=_r}if(Ot===me.length)return p(he,St),Gn&&Ji(he,Ot),ct;if(St===null){for(;Ot<me.length;Ot++)St=ze(he,me[Ot],Ue),St!==null&&(ae=E(St,ae,Ot),Et===null?ct=St:Et.sibling=St,Et=St);return Gn&&Ji(he,Ot),ct}for(St=k(he,St);Ot<me.length;Ot++)_r=Xe(St,he,Ot,me[Ot],Ue),_r!==null&&(i&&_r.alternate!==null&&St.delete(_r.key===null?Ot:_r.key),ae=E(_r,ae,Ot),Et===null?ct=_r:Et.sibling=_r,Et=_r);return i&&St.forEach(function(gi){return l(he,gi)}),Gn&&Ji(he,Ot),ct}function st(he,ae,me,Ue){var ct=Z(me);if(typeof ct!="function")throw Error(n(150));if(me=ct.call(me),me==null)throw Error(n(151));for(var Et=ct=null,St=ae,Ot=ae=0,_r=null,yn=me.next();St!==null&&!yn.done;Ot++,yn=me.next()){St.index>Ot?(_r=St,St=null):_r=St.sibling;var gi=Ae(he,St,yn.value,Ue);if(gi===null){St===null&&(St=_r);break}i&&St&&gi.alternate===null&&l(he,St),ae=E(gi,ae,Ot),Et===null?ct=gi:Et.sibling=gi,Et=gi,St=_r}if(yn.done)return p(he,St),Gn&&Ji(he,Ot),ct;if(St===null){for(;!yn.done;Ot++,yn=me.next())yn=ze(he,yn.value,Ue),yn!==null&&(ae=E(yn,ae,Ot),Et===null?ct=yn:Et.sibling=yn,Et=yn);return Gn&&Ji(he,Ot),ct}for(St=k(he,St);!yn.done;Ot++,yn=me.next())yn=Xe(St,he,Ot,yn.value,Ue),yn!==null&&(i&&yn.alternate!==null&&St.delete(yn.key===null?Ot:yn.key),ae=E(yn,ae,Ot),Et===null?ct=yn:Et.sibling=yn,Et=yn);return i&&St.forEach(function(TA){return l(he,TA)}),Gn&&Ji(he,Ot),ct}function ar(he,ae,me,Ue){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 I:e:{for(var ct=me.key,Et=ae;Et!==null;){if(Et.key===ct){if(ct=me.type,ct===C){if(Et.tag===7){p(he,Et.sibling),ae=b(Et,me.props.children),ae.return=he,he=ae;break e}}else if(Et.elementType===ct||typeof ct=="object"&&ct!==null&&ct.$$typeof===se&&yv(ct)===Et.type){p(he,Et.sibling),ae=b(Et,me.props),ae.ref=Cc(he,Et,me),ae.return=he,he=ae;break e}p(he,Et);break}else l(he,Et);Et=Et.sibling}me.type===C?(ae=aa(me.props.children,he.mode,Ue,me.key),ae.return=he,he=ae):(Ue=sf(me.type,me.key,me.props,null,he.mode,Ue),Ue.ref=Cc(he,ae,me),Ue.return=he,he=Ue)}return M(he);case R:e:{for(Et=me.key;ae!==null;){if(ae.key===Et)if(ae.tag===4&&ae.stateNode.containerInfo===me.containerInfo&&ae.stateNode.implementation===me.implementation){p(he,ae.sibling),ae=b(ae,me.children||[]),ae.return=he,he=ae;break e}else{p(he,ae);break}else l(he,ae);ae=ae.sibling}ae=Hm(me,he.mode,Ue),ae.return=he,he=ae}return M(he);case se:return Et=me._init,ar(he,ae,Et(me._payload),Ue)}if(Yt(me))return ot(he,ae,me,Ue);if(Z(me))return st(he,ae,me,Ue);Md(he,me)}return typeof me=="string"&&me!==""||typeof me=="number"?(me=""+me,ae!==null&&ae.tag===6?(p(he,ae.sibling),ae=b(ae,me),ae.return=he,he=ae):(p(he,ae),ae=Um(me,he.mode,Ue),ae.return=he,he=ae),M(he)):p(he,ae)}return ar}var dl=vv(!0),bv=vv(!1),Ld=si(null),Pd=null,fl=null,Qp=null;function Jp(){Qp=fl=Pd=null}function em(i){var l=Ld.current;Hn(Ld),i._currentValue=l}function tm(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 hl(i,l){Pd=i,Qp=fl=null,i=i.dependencies,i!==null&&i.firstContext!==null&&((i.lanes&l)!==0&&(oo=!0),i.firstContext=null)}function Ro(i){var l=i._currentValue;if(Qp!==i)if(i={context:i,memoizedValue:l,next:null},fl===null){if(Pd===null)throw Error(n(308));fl=i,Pd.dependencies={lanes:0,firstContext:i}}else fl=fl.next=i;return l}var ea=null;function nm(i){ea===null?ea=[i]:ea.push(i)}function xv(i,l,p,k){var b=l.interleaved;return b===null?(p.next=p,nm(l)):(p.next=b.next,b.next=p),l.interleaved=p,$s(i,k)}function $s(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 li=!1;function rm(i){i.updateQueue={baseState:i.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Ev(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 Cs(i,l){return{eventTime:i,lane:l,tag:0,payload:null,callback:null,next:null}}function ci(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,$s(i,p)}return b=k.interleaved,b===null?(l.next=l,nm(k)):(l.next=b.next,b.next=l),k.interleaved=l,$s(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,os(i,p)}}function Sv(i,l){var p=i.updateQueue,k=i.alternate;if(k!==null&&(k=k.updateQueue,p===k)){var b=null,E=null;if(p=p.firstBaseUpdate,p!==null){do{var M={eventTime:p.eventTime,lane:p.lane,tag:p.tag,payload:p.payload,callback:p.callback,next:null};E===null?b=E=M:E=E.next=M,p=p.next}while(p!==null);E===null?b=E=l:E=E.next=l}else b=E=l;p={baseState:k.baseState,firstBaseUpdate:b,lastBaseUpdate:E,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;li=!1;var E=b.firstBaseUpdate,M=b.lastBaseUpdate,V=b.shared.pending;if(V!==null){b.shared.pending=null;var ee=V,ke=ee.next;ee.next=null,M===null?E=ke:M.next=ke,M=ee;var Le=i.alternate;Le!==null&&(Le=Le.updateQueue,V=Le.lastBaseUpdate,V!==M&&(V===null?Le.firstBaseUpdate=ke:V.next=ke,Le.lastBaseUpdate=ee))}if(E!==null){var ze=b.baseState;M=0,Le=ke=ee=null,V=E;do{var Ae=V.lane,Xe=V.eventTime;if((k&Ae)===Ae){Le!==null&&(Le=Le.next={eventTime:Xe,lane:0,tag:V.tag,payload:V.payload,callback:V.callback,next:null});e:{var ot=i,st=V;switch(Ae=l,Xe=p,st.tag){case 1:if(ot=st.payload,typeof ot=="function"){ze=ot.call(Xe,ze,Ae);break e}ze=ot;break e;case 3:ot.flags=ot.flags&-65537|128;case 0:if(ot=st.payload,Ae=typeof ot=="function"?ot.call(Xe,ze,Ae):ot,Ae==null)break e;ze=q({},ze,Ae);break e;case 2:li=!0}}V.callback!==null&&V.lane!==0&&(i.flags|=64,Ae=b.effects,Ae===null?b.effects=[V]:Ae.push(V))}else Xe={eventTime:Xe,lane:Ae,tag:V.tag,payload:V.payload,callback:V.callback,next:null},Le===null?(ke=Le=Xe,ee=ze):Le=Le.next=Xe,M|=Ae;if(V=V.next,V===null){if(V=b.shared.pending,V===null)break;Ae=V,V=Ae.next,Ae.next=null,b.lastBaseUpdate=Ae,b.shared.pending=null}}while(!0);if(Le===null&&(ee=ze),b.baseState=ee,b.firstBaseUpdate=ke,b.lastBaseUpdate=Le,l=b.shared.interleaved,l!==null){b=l;do M|=b.lane,b=b.next;while(b!==l)}else E===null&&(b.shared.lanes=0);ra|=M,i.lanes=M,i.memoizedState=ze}}function _v(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 Ac={},cs=si(Ac),Ic=si(Ac),Rc=si(Ac);function ta(i){if(i===Ac)throw Error(n(174));return i}function om(i,l){switch(Pn(Rc,l),Pn(Ic,i),Pn(cs,Ac),i=l.nodeType,i){case 9:case 11:l=(l=l.documentElement)?l.namespaceURI:at(null,"");break;default:i=i===8?l.parentNode:l,l=i.namespaceURI||null,i=i.tagName,l=at(l,i)}Hn(cs),Pn(cs,l)}function pl(){Hn(cs),Hn(Ic),Hn(Rc)}function Nv(i){ta(Rc.current);var l=ta(cs.current),p=at(l,i.type);l!==p&&(Pn(Ic,i),Pn(cs,p))}function sm(i){Ic.current===i&&(Hn(cs),Hn(Ic))}var Qn=si(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 im=[];function am(){for(var i=0;i<im.length;i++)im[i]._workInProgressVersionPrimary=null;im.length=0}var Bd=T.ReactCurrentDispatcher,lm=T.ReactCurrentBatchConfig,na=0,Jn=null,gr=null,Er=null,Ud=!1,Oc=!1,Mc=0,VC=0;function Br(){throw Error(n(321))}function cm(i,l){if(l===null)return!1;for(var p=0;p<l.length&&p<i.length;p++)if(!to(i[p],l[p]))return!1;return!0}function um(i,l,p,k,b,E){if(na=E,Jn=l,l.memoizedState=null,l.updateQueue=null,l.lanes=0,Bd.current=i===null||i.memoizedState===null?JC:eA,i=p(k,b),Oc){E=0;do{if(Oc=!1,Mc=0,25<=E)throw Error(n(301));E+=1,Er=gr=null,l.updateQueue=null,Bd.current=tA,i=p(k,b)}while(Oc)}if(Bd.current=Kd,l=gr!==null&&gr.next!==null,na=0,Er=gr=Jn=null,Ud=!1,l)throw Error(n(300));return i}function dm(){var i=Mc!==0;return Mc=0,i}function us(){var i={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Er===null?Jn.memoizedState=Er=i:Er=Er.next=i,Er}function Oo(){if(gr===null){var i=Jn.alternate;i=i!==null?i.memoizedState:null}else i=gr.next;var l=Er===null?Jn.memoizedState:Er.next;if(l!==null)Er=l,gr=i;else{if(i===null)throw Error(n(310));gr=i,i={memoizedState:gr.memoizedState,baseState:gr.baseState,baseQueue:gr.baseQueue,queue:gr.queue,next:null},Er===null?Jn.memoizedState=Er=i:Er=Er.next=i}return Er}function Lc(i,l){return typeof l=="function"?l(i):l}function fm(i){var l=Oo(),p=l.queue;if(p===null)throw Error(n(311));p.lastRenderedReducer=i;var k=gr,b=k.baseQueue,E=p.pending;if(E!==null){if(b!==null){var M=b.next;b.next=E.next,E.next=M}k.baseQueue=b=E,p.pending=null}if(b!==null){E=b.next,k=k.baseState;var V=M=null,ee=null,ke=E;do{var Le=ke.lane;if((na&Le)===Le)ee!==null&&(ee=ee.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:Le,action:ke.action,hasEagerState:ke.hasEagerState,eagerState:ke.eagerState,next:null};ee===null?(V=ee=ze,M=k):ee=ee.next=ze,Jn.lanes|=Le,ra|=Le}ke=ke.next}while(ke!==null&&ke!==E);ee===null?M=k:ee.next=V,to(k,l.memoizedState)||(oo=!0),l.memoizedState=k,l.baseState=M,l.baseQueue=ee,p.lastRenderedState=k}if(i=p.interleaved,i!==null){b=i;do E=b.lane,Jn.lanes|=E,ra|=E,b=b.next;while(b!==i)}else b===null&&(p.lanes=0);return[l.memoizedState,p.dispatch]}function hm(i){var l=Oo(),p=l.queue;if(p===null)throw Error(n(311));p.lastRenderedReducer=i;var k=p.dispatch,b=p.pending,E=l.memoizedState;if(b!==null){p.pending=null;var M=b=b.next;do E=i(E,M.action),M=M.next;while(M!==b);to(E,l.memoizedState)||(oo=!0),l.memoizedState=E,l.baseQueue===null&&(l.baseState=E),p.lastRenderedState=E}return[E,k]}function Tv(){}function jv(i,l){var p=Jn,k=Oo(),b=l(),E=!to(k.memoizedState,b);if(E&&(k.memoizedState=b,oo=!0),k=k.queue,pm(Av.bind(null,p,k,i),[i]),k.getSnapshot!==l||E||Er!==null&&Er.memoizedState.tag&1){if(p.flags|=2048,Pc(9,Cv.bind(null,p,k,b,l),void 0,null),Sr===null)throw Error(n(349));(na&30)!==0||$v(p,l,b)}return b}function $v(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 Cv(i,l,p,k){l.value=p,l.getSnapshot=k,Iv(l)&&Rv(i)}function Av(i,l,p){return p(function(){Iv(l)&&Rv(i)})}function Iv(i){var l=i.getSnapshot;i=i.value;try{var p=l();return!to(i,p)}catch{return!0}}function Rv(i){var l=$s(i,1);l!==null&&Go(l,i,1,-1)}function Ov(i){var l=us();return typeof i=="function"&&(i=i()),l.memoizedState=l.baseState=i,i={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:Lc,lastRenderedState:i},l.queue=i,i=i.dispatch=QC.bind(null,Jn,i),[l.memoizedState,i]}function Pc(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 Mv(){return Oo().memoizedState}function Hd(i,l,p,k){var b=us();Jn.flags|=i,b.memoizedState=Pc(1|l,p,void 0,k===void 0?null:k)}function Wd(i,l,p,k){var b=Oo();k=k===void 0?null:k;var E=void 0;if(gr!==null){var M=gr.memoizedState;if(E=M.destroy,k!==null&&cm(k,M.deps)){b.memoizedState=Pc(l,p,E,k);return}}Jn.flags|=i,b.memoizedState=Pc(1|l,p,E,k)}function Lv(i,l){return Hd(8390656,8,i,l)}function pm(i,l){return Wd(2048,8,i,l)}function Pv(i,l){return Wd(4,2,i,l)}function Dv(i,l){return Wd(4,4,i,l)}function zv(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 Fv(i,l,p){return p=p!=null?p.concat([i]):null,Wd(4,4,zv.bind(null,l,i),p)}function mm(){}function Bv(i,l){var p=Oo();l=l===void 0?null:l;var k=p.memoizedState;return k!==null&&l!==null&&cm(l,k[1])?k[0]:(p.memoizedState=[i,l],i)}function Uv(i,l){var p=Oo();l=l===void 0?null:l;var k=p.memoizedState;return k!==null&&l!==null&&cm(l,k[1])?k[0]:(i=i(),p.memoizedState=[i,l],i)}function Hv(i,l,p){return(na&21)===0?(i.baseState&&(i.baseState=!1,oo=!0),i.memoizedState=p):(to(p,l)||(p=pn(),Jn.lanes|=p,ra|=p,i.baseState=!0),l)}function YC(i,l){var p=Vt;Vt=p!==0&&4>p?p:4,i(!0);var k=lm.transition;lm.transition={};try{i(!1),l()}finally{Vt=p,lm.transition=k}}function Wv(){return Oo().memoizedState}function XC(i,l,p){var k=hi(i);if(p={lane:k,action:p,hasEagerState:!1,eagerState:null,next:null},Kv(i))qv(l,p);else if(p=xv(i,l,p,k),p!==null){var b=Xr();Go(p,i,k,b),Zv(p,l,k)}}function QC(i,l,p){var k=hi(i),b={lane:k,action:p,hasEagerState:!1,eagerState:null,next:null};if(Kv(i))qv(l,b);else{var E=i.alternate;if(i.lanes===0&&(E===null||E.lanes===0)&&(E=l.lastRenderedReducer,E!==null))try{var M=l.lastRenderedState,V=E(M,p);if(b.hasEagerState=!0,b.eagerState=V,to(V,M)){var ee=l.interleaved;ee===null?(b.next=b,nm(l)):(b.next=ee.next,ee.next=b),l.interleaved=b;return}}catch{}finally{}p=xv(i,l,b,k),p!==null&&(b=Xr(),Go(p,i,k,b),Zv(p,l,k))}}function Kv(i){var l=i.alternate;return i===Jn||l!==null&&l===Jn}function qv(i,l){Oc=Ud=!0;var p=i.pending;p===null?l.next=l:(l.next=p.next,p.next=l),i.pending=l}function Zv(i,l,p){if((p&4194240)!==0){var k=l.lanes;k&=i.pendingLanes,p|=k,l.lanes=p,os(i,p)}}var Kd={readContext:Ro,useCallback:Br,useContext:Br,useEffect:Br,useImperativeHandle:Br,useInsertionEffect:Br,useLayoutEffect:Br,useMemo:Br,useReducer:Br,useRef:Br,useState:Br,useDebugValue:Br,useDeferredValue:Br,useTransition:Br,useMutableSource:Br,useSyncExternalStore:Br,useId:Br,unstable_isNewReconciler:!1},JC={readContext:Ro,useCallback:function(i,l){return us().memoizedState=[i,l===void 0?null:l],i},useContext:Ro,useEffect:Lv,useImperativeHandle:function(i,l,p){return p=p!=null?p.concat([i]):null,Hd(4194308,4,zv.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=us();return l=l===void 0?null:l,i=i(),p.memoizedState=[i,l],i},useReducer:function(i,l,p){var k=us();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=XC.bind(null,Jn,i),[k.memoizedState,i]},useRef:function(i){var l=us();return i={current:i},l.memoizedState=i},useState:Ov,useDebugValue:mm,useDeferredValue:function(i){return us().memoizedState=i},useTransition:function(){var i=Ov(!1),l=i[0];return i=YC.bind(null,i[1]),us().memoizedState=i,[l,i]},useMutableSource:function(){},useSyncExternalStore:function(i,l,p){var k=Jn,b=us();if(Gn){if(p===void 0)throw Error(n(407));p=p()}else{if(p=l(),Sr===null)throw Error(n(349));(na&30)!==0||$v(k,l,p)}b.memoizedState=p;var E={value:p,getSnapshot:l};return b.queue=E,Lv(Av.bind(null,k,E,i),[i]),k.flags|=2048,Pc(9,Cv.bind(null,k,E,p,l),void 0,null),p},useId:function(){var i=us(),l=Sr.identifierPrefix;if(Gn){var p=js,k=Ts;p=(k&~(1<<32-dn(k)-1)).toString(32)+p,l=":"+l+"R"+p,p=Mc++,0<p&&(l+="H"+p.toString(32)),l+=":"}else p=VC++,l=":"+l+"r"+p.toString(32)+":";return i.memoizedState=l},unstable_isNewReconciler:!1},eA={readContext:Ro,useCallback:Bv,useContext:Ro,useEffect:pm,useImperativeHandle:Fv,useInsertionEffect:Pv,useLayoutEffect:Dv,useMemo:Uv,useReducer:fm,useRef:Mv,useState:function(){return fm(Lc)},useDebugValue:mm,useDeferredValue:function(i){var l=Oo();return Hv(l,gr.memoizedState,i)},useTransition:function(){var i=fm(Lc)[0],l=Oo().memoizedState;return[i,l]},useMutableSource:Tv,useSyncExternalStore:jv,useId:Wv,unstable_isNewReconciler:!1},tA={readContext:Ro,useCallback:Bv,useContext:Ro,useEffect:pm,useImperativeHandle:Fv,useInsertionEffect:Pv,useLayoutEffect:Dv,useMemo:Uv,useReducer:hm,useRef:Mv,useState:function(){return hm(Lc)},useDebugValue:mm,useDeferredValue:function(i){var l=Oo();return gr===null?l.memoizedState=i:Hv(l,gr.memoizedState,i)},useTransition:function(){var i=hm(Lc)[0],l=Oo().memoizedState;return[i,l]},useMutableSource:Tv,useSyncExternalStore:jv,useId:Wv,unstable_isNewReconciler:!1};function Ko(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 gm(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)?bn(i)===i:!1},enqueueSetState:function(i,l,p){i=i._reactInternals;var k=Xr(),b=hi(i),E=Cs(k,b);E.payload=l,p!=null&&(E.callback=p),l=ci(i,E,b),l!==null&&(Go(l,i,b,k),Dd(l,i,b))},enqueueReplaceState:function(i,l,p){i=i._reactInternals;var k=Xr(),b=hi(i),E=Cs(k,b);E.tag=1,E.payload=l,p!=null&&(E.callback=p),l=ci(i,E,b),l!==null&&(Go(l,i,b,k),Dd(l,i,b))},enqueueForceUpdate:function(i,l){i=i._reactInternals;var p=Xr(),k=hi(i),b=Cs(p,k);b.tag=2,l!=null&&(b.callback=l),l=ci(i,b,k),l!==null&&(Go(l,i,k,p),Dd(l,i,k))}};function Gv(i,l,p,k,b,E,M){return i=i.stateNode,typeof i.shouldComponentUpdate=="function"?i.shouldComponentUpdate(k,E,M):l.prototype&&l.prototype.isPureReactComponent?!Vi(p,k)||!Vi(b,E):!0}function Vv(i,l,p){var k=!1,b=ii,E=l.contextType;return typeof E=="object"&&E!==null?E=Ro(E):(b=ro(l)?Xi:Fr.current,k=l.contextTypes,E=(k=k!=null)?al(i,b):ii),l=new l(p,E),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=E),l}function Yv(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 km(i,l,p,k){var b=i.stateNode;b.props=p,b.state=i.memoizedState,b.refs={},rm(i);var E=l.contextType;typeof E=="object"&&E!==null?b.context=Ro(E):(E=ro(l)?Xi:Fr.current,b.context=al(i,E)),b.state=i.memoizedState,E=l.getDerivedStateFromProps,typeof E=="function"&&(gm(i,l,E,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 ml(i,l){try{var p="",k=l;do p+=je(k),k=k.return;while(k);var b=p}catch(E){b=`
40
- Error generating stack: `+E.message+`
41
- `+E.stack}return{value:i,source:l,stack:b,digest:null}}function wm(i,l,p){return{value:i,source:null,stack:p??null,digest:l??null}}function ym(i,l){try{console.error(l.value)}catch(p){setTimeout(function(){throw p})}}var nA=typeof WeakMap=="function"?WeakMap:Map;function Xv(i,l,p){p=Cs(-1,p),p.tag=3,p.payload={element:null};var k=l.value;return p.callback=function(){Jd||(Jd=!0,Om=k),ym(i,l)},p}function Qv(i,l,p){p=Cs(-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(){ym(i,l)}}var E=i.stateNode;return E!==null&&typeof E.componentDidCatch=="function"&&(p.callback=function(){ym(i,l),typeof k!="function"&&(di===null?di=new Set([this]):di.add(this));var M=l.stack;this.componentDidCatch(l.value,{componentStack:M!==null?M:""})}),p}function Jv(i,l,p){var k=i.pingCache;if(k===null){k=i.pingCache=new nA;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=gA.bind(null,i,l,p),l.then(i,i))}function e0(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 t0(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=Cs(-1,1),l.tag=2,ci(p,l,1))),p.lanes|=1),i):(i.flags|=65536,i.lanes=b,i)}var rA=T.ReactCurrentOwner,oo=!1;function Yr(i,l,p,k){l.child=i===null?bv(l,null,p,k):dl(l,i.child,p,k)}function n0(i,l,p,k,b){p=p.render;var E=l.ref;return hl(l,b),k=um(i,l,p,k,E,b),p=dm(),i!==null&&!oo?(l.updateQueue=i.updateQueue,l.flags&=-2053,i.lanes&=~b,As(i,l,b)):(Gn&&p&&Zp(l),l.flags|=1,Yr(i,l,k,b),l.child)}function r0(i,l,p,k,b){if(i===null){var E=p.type;return typeof E=="function"&&!Bm(E)&&E.defaultProps===void 0&&p.compare===null&&p.defaultProps===void 0?(l.tag=15,l.type=E,o0(i,l,E,k,b)):(i=sf(p.type,null,k,l,l.mode,b),i.ref=l.ref,i.return=l,l.child=i)}if(E=i.child,(i.lanes&b)===0){var M=E.memoizedProps;if(p=p.compare,p=p!==null?p:Vi,p(M,k)&&i.ref===l.ref)return As(i,l,b)}return l.flags|=1,i=mi(E,k),i.ref=l.ref,i.return=l,l.child=i}function o0(i,l,p,k,b){if(i!==null){var E=i.memoizedProps;if(Vi(E,k)&&i.ref===l.ref)if(oo=!1,l.pendingProps=k=E,(i.lanes&b)!==0)(i.flags&131072)!==0&&(oo=!0);else return l.lanes=i.lanes,As(i,l,b)}return vm(i,l,p,k,b)}function s0(i,l,p){var k=l.pendingProps,b=k.children,E=i!==null?i.memoizedState:null;if(k.mode==="hidden")if((l.mode&1)===0)l.memoizedState={baseLanes:0,cachePool:null,transitions:null},Pn(kl,bo),bo|=p;else{if((p&1073741824)===0)return i=E!==null?E.baseLanes|p:p,l.lanes=l.childLanes=1073741824,l.memoizedState={baseLanes:i,cachePool:null,transitions:null},l.updateQueue=null,Pn(kl,bo),bo|=i,null;l.memoizedState={baseLanes:0,cachePool:null,transitions:null},k=E!==null?E.baseLanes:p,Pn(kl,bo),bo|=k}else E!==null?(k=E.baseLanes|p,l.memoizedState=null):k=p,Pn(kl,bo),bo|=k;return Yr(i,l,b,p),l.child}function i0(i,l){var p=l.ref;(i===null&&p!==null||i!==null&&i.ref!==p)&&(l.flags|=512,l.flags|=2097152)}function vm(i,l,p,k,b){var E=ro(p)?Xi:Fr.current;return E=al(l,E),hl(l,b),p=um(i,l,p,k,E,b),k=dm(),i!==null&&!oo?(l.updateQueue=i.updateQueue,l.flags&=-2053,i.lanes&=~b,As(i,l,b)):(Gn&&k&&Zp(l),l.flags|=1,Yr(i,l,p,b),l.child)}function a0(i,l,p,k,b){if(ro(p)){var E=!0;Cd(l)}else E=!1;if(hl(l,b),l.stateNode===null)Gd(i,l),Vv(l,p,k),km(l,p,k,b),k=!0;else if(i===null){var M=l.stateNode,V=l.memoizedProps;M.props=V;var ee=M.context,ke=p.contextType;typeof ke=="object"&&ke!==null?ke=Ro(ke):(ke=ro(p)?Xi:Fr.current,ke=al(l,ke));var Le=p.getDerivedStateFromProps,ze=typeof Le=="function"||typeof M.getSnapshotBeforeUpdate=="function";ze||typeof M.UNSAFE_componentWillReceiveProps!="function"&&typeof M.componentWillReceiveProps!="function"||(V!==k||ee!==ke)&&Yv(l,M,k,ke),li=!1;var Ae=l.memoizedState;M.state=Ae,zd(l,k,M,b),ee=l.memoizedState,V!==k||Ae!==ee||no.current||li?(typeof Le=="function"&&(gm(l,p,Le,k),ee=l.memoizedState),(V=li||Gv(l,p,V,k,Ae,ee,ke))?(ze||typeof M.UNSAFE_componentWillMount!="function"&&typeof M.componentWillMount!="function"||(typeof M.componentWillMount=="function"&&M.componentWillMount(),typeof M.UNSAFE_componentWillMount=="function"&&M.UNSAFE_componentWillMount()),typeof M.componentDidMount=="function"&&(l.flags|=4194308)):(typeof M.componentDidMount=="function"&&(l.flags|=4194308),l.memoizedProps=k,l.memoizedState=ee),M.props=k,M.state=ee,M.context=ke,k=V):(typeof M.componentDidMount=="function"&&(l.flags|=4194308),k=!1)}else{M=l.stateNode,Ev(i,l),V=l.memoizedProps,ke=l.type===l.elementType?V:Ko(l.type,V),M.props=ke,ze=l.pendingProps,Ae=M.context,ee=p.contextType,typeof ee=="object"&&ee!==null?ee=Ro(ee):(ee=ro(p)?Xi:Fr.current,ee=al(l,ee));var Xe=p.getDerivedStateFromProps;(Le=typeof Xe=="function"||typeof M.getSnapshotBeforeUpdate=="function")||typeof M.UNSAFE_componentWillReceiveProps!="function"&&typeof M.componentWillReceiveProps!="function"||(V!==ze||Ae!==ee)&&Yv(l,M,k,ee),li=!1,Ae=l.memoizedState,M.state=Ae,zd(l,k,M,b);var ot=l.memoizedState;V!==ze||Ae!==ot||no.current||li?(typeof Xe=="function"&&(gm(l,p,Xe,k),ot=l.memoizedState),(ke=li||Gv(l,p,ke,k,Ae,ot,ee)||!1)?(Le||typeof M.UNSAFE_componentWillUpdate!="function"&&typeof M.componentWillUpdate!="function"||(typeof M.componentWillUpdate=="function"&&M.componentWillUpdate(k,ot,ee),typeof M.UNSAFE_componentWillUpdate=="function"&&M.UNSAFE_componentWillUpdate(k,ot,ee)),typeof M.componentDidUpdate=="function"&&(l.flags|=4),typeof M.getSnapshotBeforeUpdate=="function"&&(l.flags|=1024)):(typeof M.componentDidUpdate!="function"||V===i.memoizedProps&&Ae===i.memoizedState||(l.flags|=4),typeof M.getSnapshotBeforeUpdate!="function"||V===i.memoizedProps&&Ae===i.memoizedState||(l.flags|=1024),l.memoizedProps=k,l.memoizedState=ot),M.props=k,M.state=ot,M.context=ee,k=ke):(typeof M.componentDidUpdate!="function"||V===i.memoizedProps&&Ae===i.memoizedState||(l.flags|=4),typeof M.getSnapshotBeforeUpdate!="function"||V===i.memoizedProps&&Ae===i.memoizedState||(l.flags|=1024),k=!1)}return bm(i,l,p,k,E,b)}function bm(i,l,p,k,b,E){i0(i,l);var M=(l.flags&128)!==0;if(!k&&!M)return b&&fv(l,p,!1),As(i,l,E);k=l.stateNode,rA.current=l;var V=M&&typeof p.getDerivedStateFromError!="function"?null:k.render();return l.flags|=1,i!==null&&M?(l.child=dl(l,i.child,null,E),l.child=dl(l,null,V,E)):Yr(i,l,V,E),l.memoizedState=k.state,b&&fv(l,p,!0),l.child}function l0(i){var l=i.stateNode;l.pendingContext?uv(i,l.pendingContext,l.pendingContext!==l.context):l.context&&uv(i,l.context,!1),om(i,l.containerInfo)}function c0(i,l,p,k,b){return ul(),Xp(b),l.flags|=256,Yr(i,l,p,k),l.child}var xm={dehydrated:null,treeContext:null,retryLane:0};function Em(i){return{baseLanes:i,cachePool:null,transitions:null}}function u0(i,l,p){var k=l.pendingProps,b=Qn.current,E=!1,M=(l.flags&128)!==0,V;if((V=M)||(V=i!==null&&i.memoizedState===null?!1:(b&2)!==0),V?(E=!0,l.flags&=-129):(i===null||i.memoizedState!==null)&&(b|=1),Pn(Qn,b&1),i===null)return Yp(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):(M=k.children,i=k.fallback,E?(k=l.mode,E=l.child,M={mode:"hidden",children:M},(k&1)===0&&E!==null?(E.childLanes=0,E.pendingProps=M):E=af(M,k,0,null),i=aa(i,k,p,null),E.return=l,i.return=l,E.sibling=i,l.child=E,l.child.memoizedState=Em(p),l.memoizedState=xm,i):Sm(l,M));if(b=i.memoizedState,b!==null&&(V=b.dehydrated,V!==null))return oA(i,l,M,k,V,b,p);if(E){E=k.fallback,M=l.mode,b=i.child,V=b.sibling;var ee={mode:"hidden",children:k.children};return(M&1)===0&&l.child!==b?(k=l.child,k.childLanes=0,k.pendingProps=ee,l.deletions=null):(k=mi(b,ee),k.subtreeFlags=b.subtreeFlags&14680064),V!==null?E=mi(V,E):(E=aa(E,M,p,null),E.flags|=2),E.return=l,k.return=l,k.sibling=E,l.child=k,k=E,E=l.child,M=i.child.memoizedState,M=M===null?Em(p):{baseLanes:M.baseLanes|p,cachePool:null,transitions:M.transitions},E.memoizedState=M,E.childLanes=i.childLanes&~p,l.memoizedState=xm,k}return E=i.child,i=E.sibling,k=mi(E,{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 Sm(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&&Xp(k),dl(l,i.child,null,p),i=Sm(l,l.pendingProps.children),i.flags|=2,l.memoizedState=null,i}function oA(i,l,p,k,b,E,M){if(p)return l.flags&256?(l.flags&=-257,k=wm(Error(n(422))),Zd(i,l,M,k)):l.memoizedState!==null?(l.child=i.child,l.flags|=128,null):(E=k.fallback,b=l.mode,k=af({mode:"visible",children:k.children},b,0,null),E=aa(E,b,M,null),E.flags|=2,k.return=l,E.return=l,k.sibling=E,l.child=k,(l.mode&1)!==0&&dl(l,i.child,null,M),l.child.memoizedState=Em(M),l.memoizedState=xm,E);if((l.mode&1)===0)return Zd(i,l,M,null);if(b.data==="$!"){if(k=b.nextSibling&&b.nextSibling.dataset,k)var V=k.dgst;return k=V,E=Error(n(419)),k=wm(E,k,void 0),Zd(i,l,M,k)}if(V=(M&i.childLanes)!==0,oo||V){if(k=Sr,k!==null){switch(M&-M){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|M))!==0?0:b,b!==0&&b!==E.retryLane&&(E.retryLane=b,$s(i,b),Go(k,i,b,-1))}return Fm(),k=wm(Error(n(421))),Zd(i,l,M,k)}return b.data==="$?"?(l.flags|=128,l.child=i.child,l=kA.bind(null,i),b._reactRetry=l,null):(i=E.treeContext,vo=oi(b.nextSibling),yo=l,Gn=!0,Wo=null,i!==null&&(Ao[Io++]=Ts,Ao[Io++]=js,Ao[Io++]=Qi,Ts=i.id,js=i.overflow,Qi=l),l=Sm(l,k.children),l.flags|=4096,l)}function d0(i,l,p){i.lanes|=l;var k=i.alternate;k!==null&&(k.lanes|=l),tm(i.return,l,p)}function _m(i,l,p,k,b){var E=i.memoizedState;E===null?i.memoizedState={isBackwards:l,rendering:null,renderingStartTime:0,last:k,tail:p,tailMode:b}:(E.isBackwards=l,E.rendering=null,E.renderingStartTime=0,E.last=k,E.tail=p,E.tailMode=b)}function f0(i,l,p){var k=l.pendingProps,b=k.revealOrder,E=k.tail;if(Yr(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&&d0(i,p,l);else if(i.tag===19)d0(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(Pn(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),_m(l,!1,b,p,E);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}_m(l,!0,p,null,E);break;case"together":_m(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 As(i,l,p){if(i!==null&&(l.dependencies=i.dependencies),ra|=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=mi(i,i.pendingProps),l.child=p,p.return=l;i.sibling!==null;)i=i.sibling,p=p.sibling=mi(i,i.pendingProps),p.return=l;p.sibling=null}return l.child}function sA(i,l,p){switch(l.tag){case 3:l0(l),ul();break;case 5:Nv(l);break;case 1:ro(l.type)&&Cd(l);break;case 4:om(l,l.stateNode.containerInfo);break;case 10:var k=l.type._context,b=l.memoizedProps.value;Pn(Ld,k._currentValue),k._currentValue=b;break;case 13:if(k=l.memoizedState,k!==null)return k.dehydrated!==null?(Pn(Qn,Qn.current&1),l.flags|=128,null):(p&l.child.childLanes)!==0?u0(i,l,p):(Pn(Qn,Qn.current&1),i=As(i,l,p),i!==null?i.sibling:null);Pn(Qn,Qn.current&1);break;case 19:if(k=(p&l.childLanes)!==0,(i.flags&128)!==0){if(k)return f0(i,l,p);l.flags|=128}if(b=l.memoizedState,b!==null&&(b.rendering=null,b.tail=null,b.lastEffect=null),Pn(Qn,Qn.current),k)break;return null;case 22:case 23:return l.lanes=0,s0(i,l,p)}return As(i,l,p)}var h0,Nm,p0,m0;h0=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}},Nm=function(){},p0=function(i,l,p,k){var b=i.memoizedProps;if(b!==k){i=l.stateNode,ta(cs.current);var E=null;switch(p){case"input":b=Ce(i,b),k=Ce(i,k),E=[];break;case"select":b=q({},b,{value:void 0}),k=q({},k,{value:void 0}),E=[];break;case"textarea":b=qe(i,b),k=qe(i,k),E=[];break;default:typeof b.onClick!="function"&&typeof k.onClick=="function"&&(i.onclick=Td)}un(p,k);var M;p=null;for(ke in b)if(!k.hasOwnProperty(ke)&&b.hasOwnProperty(ke)&&b[ke]!=null)if(ke==="style"){var V=b[ke];for(M in V)V.hasOwnProperty(M)&&(p||(p={}),p[M]="")}else ke!=="dangerouslySetInnerHTML"&&ke!=="children"&&ke!=="suppressContentEditableWarning"&&ke!=="suppressHydrationWarning"&&ke!=="autoFocus"&&(o.hasOwnProperty(ke)?E||(E=[]):(E=E||[]).push(ke,null));for(ke in k){var ee=k[ke];if(V=b!=null?b[ke]:void 0,k.hasOwnProperty(ke)&&ee!==V&&(ee!=null||V!=null))if(ke==="style")if(V){for(M in V)!V.hasOwnProperty(M)||ee&&ee.hasOwnProperty(M)||(p||(p={}),p[M]="");for(M in ee)ee.hasOwnProperty(M)&&V[M]!==ee[M]&&(p||(p={}),p[M]=ee[M])}else p||(E||(E=[]),E.push(ke,p)),p=ee;else ke==="dangerouslySetInnerHTML"?(ee=ee?ee.__html:void 0,V=V?V.__html:void 0,ee!=null&&V!==ee&&(E=E||[]).push(ke,ee)):ke==="children"?typeof ee!="string"&&typeof ee!="number"||(E=E||[]).push(ke,""+ee):ke!=="suppressContentEditableWarning"&&ke!=="suppressHydrationWarning"&&(o.hasOwnProperty(ke)?(ee!=null&&ke==="onScroll"&&Un("scroll",i),E||V===ee||(E=[])):(E=E||[]).push(ke,ee))}p&&(E=E||[]).push("style",p);var ke=E;(l.updateQueue=ke)&&(l.flags|=4)}},m0=function(i,l,p,k){p!==k&&(l.flags|=4)};function Dc(i,l){if(!Gn)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 Ur(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 iA(i,l,p){var k=l.pendingProps;switch(Gp(l),l.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Ur(l),null;case 1:return ro(l.type)&&$d(),Ur(l),null;case 3:return k=l.stateNode,pl(),Hn(no),Hn(Fr),am(),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,Wo!==null&&(Pm(Wo),Wo=null))),Nm(i,l),Ur(l),null;case 5:sm(l);var b=ta(Rc.current);if(p=l.type,i!==null&&l.stateNode!=null)p0(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 Ur(l),null}if(i=ta(cs.current),Od(l)){k=l.stateNode,p=l.type;var E=l.memoizedProps;switch(k[ls]=l,k[jc]=E,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<_c.length;b++)Un(_c[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":Ne(k,E),Un("invalid",k);break;case"select":k._wrapperState={wasMultiple:!!E.multiple},Un("invalid",k);break;case"textarea":xt(k,E),Un("invalid",k)}un(p,E),b=null;for(var M in E)if(E.hasOwnProperty(M)){var V=E[M];M==="children"?typeof V=="string"?k.textContent!==V&&(E.suppressHydrationWarning!==!0&&Nd(k.textContent,V,i),b=["children",V]):typeof V=="number"&&k.textContent!==""+V&&(E.suppressHydrationWarning!==!0&&Nd(k.textContent,V,i),b=["children",""+V]):o.hasOwnProperty(M)&&V!=null&&M==="onScroll"&&Un("scroll",k)}switch(p){case"input":ue(k),Je(k,E,!0);break;case"textarea":ue(k),De(k);break;case"select":case"option":break;default:typeof E.onClick=="function"&&(k.onclick=Td)}k=b,l.updateQueue=k,k!==null&&(l.flags|=4)}else{M=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=M.createElement("div"),i.innerHTML="<script><\/script>",i=i.removeChild(i.firstChild)):typeof k.is=="string"?i=M.createElement(p,{is:k.is}):(i=M.createElement(p),p==="select"&&(M=i,k.multiple?M.multiple=!0:k.size&&(M.size=k.size))):i=M.createElementNS(i,p),i[ls]=l,i[jc]=k,h0(i,l,!1,!1),l.stateNode=i;e:{switch(M=vn(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<_c.length;b++)Un(_c[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":Ne(i,k),b=Ce(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":xt(i,k),b=qe(i,k),Un("invalid",i);break;default:b=k}un(p,b),V=b;for(E in V)if(V.hasOwnProperty(E)){var ee=V[E];E==="style"?Rn(i,ee):E==="dangerouslySetInnerHTML"?(ee=ee?ee.__html:void 0,ee!=null&&Nt(i,ee)):E==="children"?typeof ee=="string"?(p!=="textarea"||ee!=="")&&Zt(i,ee):typeof ee=="number"&&Zt(i,""+ee):E!=="suppressContentEditableWarning"&&E!=="suppressHydrationWarning"&&E!=="autoFocus"&&(o.hasOwnProperty(E)?ee!=null&&E==="onScroll"&&Un("scroll",i):ee!=null&&j(i,E,ee,M))}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",""+te(k.value));break;case"select":i.multiple=!!k.multiple,E=k.value,E!=null?_t(i,!!k.multiple,E,!1):k.defaultValue!=null&&_t(i,!!k.multiple,k.defaultValue,!0);break;default:typeof b.onClick=="function"&&(i.onclick=Td)}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 Ur(l),null;case 6:if(i&&l.stateNode!=null)m0(i,l,i.memoizedProps,k);else{if(typeof k!="string"&&l.stateNode===null)throw Error(n(166));if(p=ta(Rc.current),ta(cs.current),Od(l)){if(k=l.stateNode,p=l.memoizedProps,k[ls]=l,(E=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)}E&&(l.flags|=4)}else k=(p.nodeType===9?p:p.ownerDocument).createTextNode(k),k[ls]=l,l.stateNode=k}return Ur(l),null;case 13:if(Hn(Qn),k=l.memoizedState,i===null||i.memoizedState!==null&&i.memoizedState.dehydrated!==null){if(Gn&&vo!==null&&(l.mode&1)!==0&&(l.flags&128)===0)wv(),ul(),l.flags|=98560,E=!1;else if(E=Od(l),k!==null&&k.dehydrated!==null){if(i===null){if(!E)throw Error(n(318));if(E=l.memoizedState,E=E!==null?E.dehydrated:null,!E)throw Error(n(317));E[ls]=l}else ul(),(l.flags&128)===0&&(l.memoizedState=null),l.flags|=4;Ur(l),E=!1}else Wo!==null&&(Pm(Wo),Wo=null),E=!0;if(!E)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?kr===0&&(kr=3):Fm())),l.updateQueue!==null&&(l.flags|=4),Ur(l),null);case 4:return pl(),Nm(i,l),i===null&&Nc(l.stateNode.containerInfo),Ur(l),null;case 10:return em(l.type._context),Ur(l),null;case 17:return ro(l.type)&&$d(),Ur(l),null;case 19:if(Hn(Qn),E=l.memoizedState,E===null)return Ur(l),null;if(k=(l.flags&128)!==0,M=E.rendering,M===null)if(k)Dc(E,!1);else{if(kr!==0||i!==null&&(i.flags&128)!==0)for(i=l.child;i!==null;){if(M=Fd(i),M!==null){for(l.flags|=128,Dc(E,!1),k=M.updateQueue,k!==null&&(l.updateQueue=k,l.flags|=4),l.subtreeFlags=0,k=p,p=l.child;p!==null;)E=p,i=k,E.flags&=14680066,M=E.alternate,M===null?(E.childLanes=0,E.lanes=i,E.child=null,E.subtreeFlags=0,E.memoizedProps=null,E.memoizedState=null,E.updateQueue=null,E.dependencies=null,E.stateNode=null):(E.childLanes=M.childLanes,E.lanes=M.lanes,E.child=M.child,E.subtreeFlags=0,E.deletions=null,E.memoizedProps=M.memoizedProps,E.memoizedState=M.memoizedState,E.updateQueue=M.updateQueue,E.type=M.type,i=M.dependencies,E.dependencies=i===null?null:{lanes:i.lanes,firstContext:i.firstContext}),p=p.sibling;return Pn(Qn,Qn.current&1|2),l.child}i=i.sibling}E.tail!==null&&ln()>wl&&(l.flags|=128,k=!0,Dc(E,!1),l.lanes=4194304)}else{if(!k)if(i=Fd(M),i!==null){if(l.flags|=128,k=!0,p=i.updateQueue,p!==null&&(l.updateQueue=p,l.flags|=4),Dc(E,!0),E.tail===null&&E.tailMode==="hidden"&&!M.alternate&&!Gn)return Ur(l),null}else 2*ln()-E.renderingStartTime>wl&&p!==1073741824&&(l.flags|=128,k=!0,Dc(E,!1),l.lanes=4194304);E.isBackwards?(M.sibling=l.child,l.child=M):(p=E.last,p!==null?p.sibling=M:l.child=M,E.last=M)}return E.tail!==null?(l=E.tail,E.rendering=l,E.tail=l.sibling,E.renderingStartTime=ln(),l.sibling=null,p=Qn.current,Pn(Qn,k?p&1|2:p&1),l):(Ur(l),null);case 22:case 23:return zm(),k=l.memoizedState!==null,i!==null&&i.memoizedState!==null!==k&&(l.flags|=8192),k&&(l.mode&1)!==0?(bo&1073741824)!==0&&(Ur(l),l.subtreeFlags&6&&(l.flags|=8192)):Ur(l),null;case 24:return null;case 25:return null}throw Error(n(156,l.tag))}function aA(i,l){switch(Gp(l),l.tag){case 1:return ro(l.type)&&$d(),i=l.flags,i&65536?(l.flags=i&-65537|128,l):null;case 3:return pl(),Hn(no),Hn(Fr),am(),i=l.flags,(i&65536)!==0&&(i&128)===0?(l.flags=i&-65537|128,l):null;case 5:return sm(l),null;case 13:if(Hn(Qn),i=l.memoizedState,i!==null&&i.dehydrated!==null){if(l.alternate===null)throw Error(n(340));ul()}return i=l.flags,i&65536?(l.flags=i&-65537|128,l):null;case 19:return Hn(Qn),null;case 4:return pl(),null;case 10:return em(l.type._context),null;case 22:case 23:return zm(),null;case 24:return null;default:return null}}var Vd=!1,Hr=!1,lA=typeof WeakSet=="function"?WeakSet:Set,et=null;function gl(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 Tm(i,l,p){try{p()}catch(k){or(i,l,k)}}var g0=!1;function cA(i,l){if(zp=vs,i=bc(),el(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,E=k.focusNode;k=k.focusOffset;try{p.nodeType,E.nodeType}catch{p=null;break e}var M=0,V=-1,ee=-1,ke=0,Le=0,ze=i,Ae=null;t:for(;;){for(var Xe;ze!==p||b!==0&&ze.nodeType!==3||(V=M+b),ze!==E||k!==0&&ze.nodeType!==3||(ee=M+k),ze.nodeType===3&&(M+=ze.nodeValue.length),(Xe=ze.firstChild)!==null;)Ae=ze,ze=Xe;for(;;){if(ze===i)break t;if(Ae===p&&++ke===b&&(V=M),Ae===E&&++Le===k&&(ee=M),(Xe=ze.nextSibling)!==null)break;ze=Ae,Ae=ze.parentNode}ze=Xe}p=V===-1||ee===-1?null:{start:V,end:ee}}else p=null}p=p||{start:0,end:0}}else p=null;for(Fp={focusedElem:i,selectionRange:p},vs=!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 ot=l.alternate;if((l.flags&1024)!==0)switch(l.tag){case 0:case 11:case 15:break;case 1:if(ot!==null){var st=ot.memoizedProps,ar=ot.memoizedState,he=l.stateNode,ae=he.getSnapshotBeforeUpdate(l.elementType===l.type?st:Ko(l.type,st),ar);he.__reactInternalSnapshotBeforeUpdate=ae}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(Ue){or(l,l.return,Ue)}if(i=l.sibling,i!==null){i.return=l.return,et=i;break}et=l.return}return ot=g0,g0=!1,ot}function zc(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 E=b.destroy;b.destroy=void 0,E!==void 0&&Tm(l,p,E)}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 jm(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 k0(i){var l=i.alternate;l!==null&&(i.alternate=null,k0(l)),i.child=null,i.deletions=null,i.sibling=null,i.tag===5&&(l=i.stateNode,l!==null&&(delete l[ls],delete l[jc],delete l[Wp],delete l[KC],delete l[qC])),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 w0(i){return i.tag===5||i.tag===3||i.tag===4}function y0(i){e:for(;;){for(;i.sibling===null;){if(i.return===null||w0(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 $m(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=Td));else if(k!==4&&(i=i.child,i!==null))for($m(i,l,p),i=i.sibling;i!==null;)$m(i,l,p),i=i.sibling}function Cm(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(Cm(i,l,p),i=i.sibling;i!==null;)Cm(i,l,p),i=i.sibling}var Or=null,qo=!1;function ui(i,l,p){for(p=p.child;p!==null;)v0(i,l,p),p=p.sibling}function v0(i,l,p){if(wt&&typeof wt.onCommitFiberUnmount=="function")try{wt.onCommitFiberUnmount(kt,p)}catch{}switch(p.tag){case 5:Hr||gl(p,l);case 6:var k=Or,b=qo;Or=null,ui(i,l,p),Or=k,qo=b,Or!==null&&(qo?(i=Or,p=p.stateNode,i.nodeType===8?i.parentNode.removeChild(p):i.removeChild(p)):Or.removeChild(p.stateNode));break;case 18:Or!==null&&(qo?(i=Or,p=p.stateNode,i.nodeType===8?Hp(i.parentNode,p):i.nodeType===1&&Hp(i,p),Bi(i)):Hp(Or,p.stateNode));break;case 4:k=Or,b=qo,Or=p.stateNode.containerInfo,qo=!0,ui(i,l,p),Or=k,qo=b;break;case 0:case 11:case 14:case 15:if(!Hr&&(k=p.updateQueue,k!==null&&(k=k.lastEffect,k!==null))){b=k=k.next;do{var E=b,M=E.destroy;E=E.tag,M!==void 0&&((E&2)!==0||(E&4)!==0)&&Tm(p,l,M),b=b.next}while(b!==k)}ui(i,l,p);break;case 1:if(!Hr&&(gl(p,l),k=p.stateNode,typeof k.componentWillUnmount=="function"))try{k.props=p.memoizedProps,k.state=p.memoizedState,k.componentWillUnmount()}catch(V){or(p,l,V)}ui(i,l,p);break;case 21:ui(i,l,p);break;case 22:p.mode&1?(Hr=(k=Hr)||p.memoizedState!==null,ui(i,l,p),Hr=k):ui(i,l,p);break;default:ui(i,l,p)}}function b0(i){var l=i.updateQueue;if(l!==null){i.updateQueue=null;var p=i.stateNode;p===null&&(p=i.stateNode=new lA),l.forEach(function(k){var b=wA.bind(null,i,k);p.has(k)||(p.add(k),k.then(b,b))})}}function Zo(i,l){var p=l.deletions;if(p!==null)for(var k=0;k<p.length;k++){var b=p[k];try{var E=i,M=l,V=M;e:for(;V!==null;){switch(V.tag){case 5:Or=V.stateNode,qo=!1;break e;case 3:Or=V.stateNode.containerInfo,qo=!0;break e;case 4:Or=V.stateNode.containerInfo,qo=!0;break e}V=V.return}if(Or===null)throw Error(n(160));v0(E,M,b),Or=null,qo=!1;var ee=b.alternate;ee!==null&&(ee.return=null),b.return=null}catch(ke){or(b,l,ke)}}if(l.subtreeFlags&12854)for(l=l.child;l!==null;)x0(l,i),l=l.sibling}function x0(i,l){var p=i.alternate,k=i.flags;switch(i.tag){case 0:case 11:case 14:case 15:if(Zo(l,i),ds(i),k&4){try{zc(3,i,i.return),Yd(3,i)}catch(st){or(i,i.return,st)}try{zc(5,i,i.return)}catch(st){or(i,i.return,st)}}break;case 1:Zo(l,i),ds(i),k&512&&p!==null&&gl(p,p.return);break;case 5:if(Zo(l,i),ds(i),k&512&&p!==null&&gl(p,p.return),i.flags&32){var b=i.stateNode;try{Zt(b,"")}catch(st){or(i,i.return,st)}}if(k&4&&(b=i.stateNode,b!=null)){var E=i.memoizedProps,M=p!==null?p.memoizedProps:E,V=i.type,ee=i.updateQueue;if(i.updateQueue=null,ee!==null)try{V==="input"&&E.type==="radio"&&E.name!=null&&Ie(b,E),vn(V,M);var ke=vn(V,E);for(M=0;M<ee.length;M+=2){var Le=ee[M],ze=ee[M+1];Le==="style"?Rn(b,ze):Le==="dangerouslySetInnerHTML"?Nt(b,ze):Le==="children"?Zt(b,ze):j(b,Le,ze,ke)}switch(V){case"input":Be(b,E);break;case"textarea":ht(b,E);break;case"select":var Ae=b._wrapperState.wasMultiple;b._wrapperState.wasMultiple=!!E.multiple;var Xe=E.value;Xe!=null?_t(b,!!E.multiple,Xe,!1):Ae!==!!E.multiple&&(E.defaultValue!=null?_t(b,!!E.multiple,E.defaultValue,!0):_t(b,!!E.multiple,E.multiple?[]:"",!1))}b[jc]=E}catch(st){or(i,i.return,st)}}break;case 6:if(Zo(l,i),ds(i),k&4){if(i.stateNode===null)throw Error(n(162));b=i.stateNode,E=i.memoizedProps;try{b.nodeValue=E}catch(st){or(i,i.return,st)}}break;case 3:if(Zo(l,i),ds(i),k&4&&p!==null&&p.memoizedState.isDehydrated)try{Bi(l.containerInfo)}catch(st){or(i,i.return,st)}break;case 4:Zo(l,i),ds(i);break;case 13:Zo(l,i),ds(i),b=i.child,b.flags&8192&&(E=b.memoizedState!==null,b.stateNode.isHidden=E,!E||b.alternate!==null&&b.alternate.memoizedState!==null||(Rm=ln())),k&4&&b0(i);break;case 22:if(Le=p!==null&&p.memoizedState!==null,i.mode&1?(Hr=(ke=Hr)||Le,Zo(l,i),Hr=ke):Zo(l,i),ds(i),k&8192){if(ke=i.memoizedState!==null,(i.stateNode.isHidden=ke)&&!Le&&(i.mode&1)!==0)for(et=i,Le=i.child;Le!==null;){for(ze=et=Le;et!==null;){switch(Ae=et,Xe=Ae.child,Ae.tag){case 0:case 11:case 14:case 15:zc(4,Ae,Ae.return);break;case 1:gl(Ae,Ae.return);var ot=Ae.stateNode;if(typeof ot.componentWillUnmount=="function"){k=Ae,p=Ae.return;try{l=k,ot.props=l.memoizedProps,ot.state=l.memoizedState,ot.componentWillUnmount()}catch(st){or(k,p,st)}}break;case 5:gl(Ae,Ae.return);break;case 22:if(Ae.memoizedState!==null){_0(ze);continue}}Xe!==null?(Xe.return=Ae,et=Xe):_0(ze)}Le=Le.sibling}e:for(Le=null,ze=i;;){if(ze.tag===5){if(Le===null){Le=ze;try{b=ze.stateNode,ke?(E=b.style,typeof E.setProperty=="function"?E.setProperty("display","none","important"):E.display="none"):(V=ze.stateNode,ee=ze.memoizedProps.style,M=ee!=null&&ee.hasOwnProperty("display")?ee.display:null,V.style.display=Jt("display",M))}catch(st){or(i,i.return,st)}}}else if(ze.tag===6){if(Le===null)try{ze.stateNode.nodeValue=ke?"":ze.memoizedProps}catch(st){or(i,i.return,st)}}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;Le===ze&&(Le=null),ze=ze.return}Le===ze&&(Le=null),ze.sibling.return=ze.return,ze=ze.sibling}}break;case 19:Zo(l,i),ds(i),k&4&&b0(i);break;case 21:break;default:Zo(l,i),ds(i)}}function ds(i){var l=i.flags;if(l&2){try{e:{for(var p=i.return;p!==null;){if(w0(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&&(Zt(b,""),k.flags&=-33);var E=y0(i);Cm(i,E,b);break;case 3:case 4:var M=k.stateNode.containerInfo,V=y0(i);$m(i,V,M);break;default:throw Error(n(161))}}catch(ee){or(i,i.return,ee)}i.flags&=-3}l&4096&&(i.flags&=-4097)}function uA(i,l,p){et=i,E0(i)}function E0(i,l,p){for(var k=(i.mode&1)!==0;et!==null;){var b=et,E=b.child;if(b.tag===22&&k){var M=b.memoizedState!==null||Vd;if(!M){var V=b.alternate,ee=V!==null&&V.memoizedState!==null||Hr;V=Vd;var ke=Hr;if(Vd=M,(Hr=ee)&&!ke)for(et=b;et!==null;)M=et,ee=M.child,M.tag===22&&M.memoizedState!==null?N0(b):ee!==null?(ee.return=M,et=ee):N0(b);for(;E!==null;)et=E,E0(E),E=E.sibling;et=b,Vd=V,Hr=ke}S0(i)}else(b.subtreeFlags&8772)!==0&&E!==null?(E.return=b,et=E):S0(i)}}function S0(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:Hr||Yd(5,l);break;case 1:var k=l.stateNode;if(l.flags&4&&!Hr)if(p===null)k.componentDidMount();else{var b=l.elementType===l.type?p.memoizedProps:Ko(l.type,p.memoizedProps);k.componentDidUpdate(b,p.memoizedState,k.__reactInternalSnapshotBeforeUpdate)}var E=l.updateQueue;E!==null&&_v(l,E,k);break;case 3:var M=l.updateQueue;if(M!==null){if(p=null,l.child!==null)switch(l.child.tag){case 5:p=l.child.stateNode;break;case 1:p=l.child.stateNode}_v(l,M,p)}break;case 5:var V=l.stateNode;if(p===null&&l.flags&4){p=V;var ee=l.memoizedProps;switch(l.type){case"button":case"input":case"select":case"textarea":ee.autoFocus&&p.focus();break;case"img":ee.src&&(p.src=ee.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 Le=ke.memoizedState;if(Le!==null){var ze=Le.dehydrated;ze!==null&&Bi(ze)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(n(163))}Hr||l.flags&512&&jm(l)}catch(Ae){or(l,l.return,Ae)}}if(l===i){et=null;break}if(p=l.sibling,p!==null){p.return=l.return,et=p;break}et=l.return}}function _0(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 N0(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(ee){or(l,p,ee)}break;case 1:var k=l.stateNode;if(typeof k.componentDidMount=="function"){var b=l.return;try{k.componentDidMount()}catch(ee){or(l,b,ee)}}var E=l.return;try{jm(l)}catch(ee){or(l,E,ee)}break;case 5:var M=l.return;try{jm(l)}catch(ee){or(l,M,ee)}}}catch(ee){or(l,l.return,ee)}if(l===i){et=null;break}var V=l.sibling;if(V!==null){V.return=l.return,et=V;break}et=l.return}}var dA=Math.ceil,Xd=T.ReactCurrentDispatcher,Am=T.ReactCurrentOwner,Mo=T.ReactCurrentBatchConfig,mn=0,Sr=null,ur=null,Mr=0,bo=0,kl=si(0),kr=0,Fc=null,ra=0,Qd=0,Im=0,Bc=null,so=null,Rm=0,wl=1/0,Is=null,Jd=!1,Om=null,di=null,ef=!1,fi=null,tf=0,Uc=0,Mm=null,nf=-1,rf=0;function Xr(){return(mn&6)!==0?ln():nf!==-1?nf:nf=ln()}function hi(i){return(i.mode&1)===0?1:(mn&2)!==0&&Mr!==0?Mr&-Mr:GC.transition!==null?(rf===0&&(rf=pn()),rf):(i=Vt,i!==0||(i=window.event,i=i===void 0?16:ic(i.type)),i)}function Go(i,l,p,k){if(50<Uc)throw Uc=0,Mm=null,Error(n(185));zr(i,p,k),((mn&2)===0||i!==Sr)&&(i===Sr&&((mn&2)===0&&(Qd|=p),kr===4&&pi(i,Mr)),io(i,k),p===1&&mn===0&&(l.mode&1)===0&&(wl=ln()+500,Ad&&ai()))}function io(i,l){var p=i.callbackNode;Kt(i,l);var k=ge(i,i===Sr?Mr: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?ZC(j0.bind(null,i)):hv(j0.bind(null,i)),HC(function(){(mn&6)===0&&ai()}),p=null;else{switch(yt(k)){case 1:p=rn;break;case 4:p=Ht;break;case 16:p=Ut;break;case 536870912:p=Ge;break;default:p=Ut}p=L0(p,T0.bind(null,i))}i.callbackPriority=l,i.callbackNode=p}}function T0(i,l){if(nf=-1,rf=0,(mn&6)!==0)throw Error(n(327));var p=i.callbackNode;if(yl()&&i.callbackNode!==p)return null;var k=ge(i,i===Sr?Mr: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 E=C0();(Sr!==i||Mr!==l)&&(Is=null,wl=ln()+500,sa(i,l));do try{pA();break}catch(V){$0(i,V)}while(!0);Jp(),Xd.current=E,mn=b,ur!==null?l=0:(Sr=null,Mr=0,l=kr)}if(l!==0){if(l===2&&(b=Mt(i),b!==0&&(k=b,l=Lm(i,b))),l===1)throw p=Fc,sa(i,0),pi(i,k),io(i,ln()),p;if(l===6)pi(i,k);else{if(b=i.current.alternate,(k&30)===0&&!fA(b)&&(l=of(i,k),l===2&&(E=Mt(i),E!==0&&(k=E,l=Lm(i,E))),l===1))throw p=Fc,sa(i,0),pi(i,k),io(i,ln()),p;switch(i.finishedWork=b,i.finishedLanes=k,l){case 0:case 1:throw Error(n(345));case 2:ia(i,so,Is);break;case 3:if(pi(i,k),(k&130023424)===k&&(l=Rm+500-ln(),10<l)){if(ge(i,0)!==0)break;if(b=i.suspendedLanes,(b&k)!==k){Xr(),i.pingedLanes|=i.suspendedLanes&b;break}i.timeoutHandle=Up(ia.bind(null,i,so,Is),l);break}ia(i,so,Is);break;case 4:if(pi(i,k),(k&4194240)===k)break;for(l=i.eventTimes,b=-1;0<k;){var M=31-dn(k);E=1<<M,M=l[M],M>b&&(b=M),k&=~E}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*dA(k/1960))-k,10<k){i.timeoutHandle=Up(ia.bind(null,i,so,Is),k);break}ia(i,so,Is);break;case 5:ia(i,so,Is);break;default:throw Error(n(329))}}}return io(i,ln()),i.callbackNode===p?T0.bind(null,i):null}function Lm(i,l){var p=Bc;return i.current.memoizedState.isDehydrated&&(sa(i,l).flags|=256),i=of(i,l),i!==2&&(l=so,so=p,l!==null&&Pm(l)),i}function Pm(i){so===null?so=i:so.push.apply(so,i)}function fA(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],E=b.getSnapshot;b=b.value;try{if(!to(E(),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 pi(i,l){for(l&=~Im,l&=~Qd,i.suspendedLanes|=l,i.pingedLanes&=~l,i=i.expirationTimes;0<l;){var p=31-dn(l),k=1<<p;i[p]=-1,l&=~k}}function j0(i){if((mn&6)!==0)throw Error(n(327));yl();var l=ge(i,0);if((l&1)===0)return io(i,ln()),null;var p=of(i,l);if(i.tag!==0&&p===2){var k=Mt(i);k!==0&&(l=k,p=Lm(i,k))}if(p===1)throw p=Fc,sa(i,0),pi(i,l),io(i,ln()),p;if(p===6)throw Error(n(345));return i.finishedWork=i.current.alternate,i.finishedLanes=l,ia(i,so,Is),io(i,ln()),null}function Dm(i,l){var p=mn;mn|=1;try{return i(l)}finally{mn=p,mn===0&&(wl=ln()+500,Ad&&ai())}}function oa(i){fi!==null&&fi.tag===0&&(mn&6)===0&&yl();var l=mn;mn|=1;var p=Mo.transition,k=Vt;try{if(Mo.transition=null,Vt=1,i)return i()}finally{Vt=k,Mo.transition=p,mn=l,(mn&6)===0&&ai()}}function zm(){bo=kl.current,Hn(kl)}function sa(i,l){i.finishedWork=null,i.finishedLanes=0;var p=i.timeoutHandle;if(p!==-1&&(i.timeoutHandle=-1,UC(p)),ur!==null)for(p=ur.return;p!==null;){var k=p;switch(Gp(k),k.tag){case 1:k=k.type.childContextTypes,k!=null&&$d();break;case 3:pl(),Hn(no),Hn(Fr),am();break;case 5:sm(k);break;case 4:pl();break;case 13:Hn(Qn);break;case 19:Hn(Qn);break;case 10:em(k.type._context);break;case 22:case 23:zm()}p=p.return}if(Sr=i,ur=i=mi(i.current,null),Mr=bo=l,kr=0,Fc=null,Im=Qd=ra=0,so=Bc=null,ea!==null){for(l=0;l<ea.length;l++)if(p=ea[l],k=p.interleaved,k!==null){p.interleaved=null;var b=k.next,E=p.pending;if(E!==null){var M=E.next;E.next=b,k.next=M}p.pending=k}ea=null}return i}function $0(i,l){do{var p=ur;try{if(Jp(),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(na=0,Er=gr=Jn=null,Oc=!1,Mc=0,Am.current=null,p===null||p.return===null){kr=1,Fc=l,ur=null;break}e:{var E=i,M=p.return,V=p,ee=l;if(l=Mr,V.flags|=32768,ee!==null&&typeof ee=="object"&&typeof ee.then=="function"){var ke=ee,Le=V,ze=Le.tag;if((Le.mode&1)===0&&(ze===0||ze===11||ze===15)){var Ae=Le.alternate;Ae?(Le.updateQueue=Ae.updateQueue,Le.memoizedState=Ae.memoizedState,Le.lanes=Ae.lanes):(Le.updateQueue=null,Le.memoizedState=null)}var Xe=e0(M);if(Xe!==null){Xe.flags&=-257,t0(Xe,M,V,E,l),Xe.mode&1&&Jv(E,ke,l),l=Xe,ee=ke;var ot=l.updateQueue;if(ot===null){var st=new Set;st.add(ee),l.updateQueue=st}else ot.add(ee);break e}else{if((l&1)===0){Jv(E,ke,l),Fm();break e}ee=Error(n(426))}}else if(Gn&&V.mode&1){var ar=e0(M);if(ar!==null){(ar.flags&65536)===0&&(ar.flags|=256),t0(ar,M,V,E,l),Xp(ml(ee,V));break e}}E=ee=ml(ee,V),kr!==4&&(kr=2),Bc===null?Bc=[E]:Bc.push(E),E=M;do{switch(E.tag){case 3:E.flags|=65536,l&=-l,E.lanes|=l;var he=Xv(E,ee,l);Sv(E,he);break e;case 1:V=ee;var ae=E.type,me=E.stateNode;if((E.flags&128)===0&&(typeof ae.getDerivedStateFromError=="function"||me!==null&&typeof me.componentDidCatch=="function"&&(di===null||!di.has(me)))){E.flags|=65536,l&=-l,E.lanes|=l;var Ue=Qv(E,V,l);Sv(E,Ue);break e}}E=E.return}while(E!==null)}I0(p)}catch(ct){l=ct,ur===p&&p!==null&&(ur=p=p.return);continue}break}while(!0)}function C0(){var i=Xd.current;return Xd.current=Kd,i===null?Kd:i}function Fm(){(kr===0||kr===3||kr===2)&&(kr=4),Sr===null||(ra&268435455)===0&&(Qd&268435455)===0||pi(Sr,Mr)}function of(i,l){var p=mn;mn|=2;var k=C0();(Sr!==i||Mr!==l)&&(Is=null,sa(i,l));do try{hA();break}catch(b){$0(i,b)}while(!0);if(Jp(),mn=p,Xd.current=k,ur!==null)throw Error(n(261));return Sr=null,Mr=0,kr}function hA(){for(;ur!==null;)A0(ur)}function pA(){for(;ur!==null&&!Dr();)A0(ur)}function A0(i){var l=M0(i.alternate,i,bo);i.memoizedProps=i.pendingProps,l===null?I0(i):ur=l,Am.current=null}function I0(i){var l=i;do{var p=l.alternate;if(i=l.return,(l.flags&32768)===0){if(p=iA(p,l,bo),p!==null){ur=p;return}}else{if(p=aA(p,l),p!==null){p.flags&=32767,ur=p;return}if(i!==null)i.flags|=32768,i.subtreeFlags=0,i.deletions=null;else{kr=6,ur=null;return}}if(l=l.sibling,l!==null){ur=l;return}ur=l=i}while(l!==null);kr===0&&(kr=5)}function ia(i,l,p){var k=Vt,b=Mo.transition;try{Mo.transition=null,Vt=1,mA(i,l,p,k)}finally{Mo.transition=b,Vt=k}return null}function mA(i,l,p,k){do yl();while(fi!==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 E=p.lanes|p.childLanes;if(qn(i,E),i===Sr&&(ur=Sr=null,Mr=0),(p.subtreeFlags&2064)===0&&(p.flags&2064)===0||ef||(ef=!0,L0(Ut,function(){return yl(),null})),E=(p.flags&15990)!==0,(p.subtreeFlags&15990)!==0||E){E=Mo.transition,Mo.transition=null;var M=Vt;Vt=1;var V=mn;mn|=4,Am.current=null,cA(i,p),x0(p,i),bd(Fp),vs=!!zp,Fp=zp=null,i.current=p,uA(p),lr(),mn=V,Vt=M,Mo.transition=E}else i.current=p;if(ef&&(ef=!1,fi=i,tf=b),E=i.pendingLanes,E===0&&(di=null),on(p.stateNode),io(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=Om,Om=null,i;return(tf&1)!==0&&i.tag!==0&&yl(),E=i.pendingLanes,(E&1)!==0?i===Mm?Uc++:(Uc=0,Mm=i):Uc=0,ai(),null}function yl(){if(fi!==null){var i=yt(tf),l=Mo.transition,p=Vt;try{if(Mo.transition=null,Vt=16>i?16:i,fi===null)var k=!1;else{if(i=fi,fi=null,tf=0,(mn&6)!==0)throw Error(n(331));var b=mn;for(mn|=4,et=i.current;et!==null;){var E=et,M=E.child;if((et.flags&16)!==0){var V=E.deletions;if(V!==null){for(var ee=0;ee<V.length;ee++){var ke=V[ee];for(et=ke;et!==null;){var Le=et;switch(Le.tag){case 0:case 11:case 15:zc(8,Le,E)}var ze=Le.child;if(ze!==null)ze.return=Le,et=ze;else for(;et!==null;){Le=et;var Ae=Le.sibling,Xe=Le.return;if(k0(Le),Le===ke){et=null;break}if(Ae!==null){Ae.return=Xe,et=Ae;break}et=Xe}}}var ot=E.alternate;if(ot!==null){var st=ot.child;if(st!==null){ot.child=null;do{var ar=st.sibling;st.sibling=null,st=ar}while(st!==null)}}et=E}}if((E.subtreeFlags&2064)!==0&&M!==null)M.return=E,et=M;else e:for(;et!==null;){if(E=et,(E.flags&2048)!==0)switch(E.tag){case 0:case 11:case 15:zc(9,E,E.return)}var he=E.sibling;if(he!==null){he.return=E.return,et=he;break e}et=E.return}}var ae=i.current;for(et=ae;et!==null;){M=et;var me=M.child;if((M.subtreeFlags&2064)!==0&&me!==null)me.return=M,et=me;else e:for(M=ae;et!==null;){if(V=et,(V.flags&2048)!==0)try{switch(V.tag){case 0:case 11:case 15:Yd(9,V)}}catch(ct){or(V,V.return,ct)}if(V===M){et=null;break e}var Ue=V.sibling;if(Ue!==null){Ue.return=V.return,et=Ue;break e}et=V.return}}if(mn=b,ai(),wt&&typeof wt.onPostCommitFiberRoot=="function")try{wt.onPostCommitFiberRoot(kt,i)}catch{}k=!0}return k}finally{Vt=p,Mo.transition=l}}return!1}function R0(i,l,p){l=ml(p,l),l=Xv(i,l,1),i=ci(i,l,1),l=Xr(),i!==null&&(zr(i,1,l),io(i,l))}function or(i,l,p){if(i.tag===3)R0(i,i,p);else for(;l!==null;){if(l.tag===3){R0(l,i,p);break}else if(l.tag===1){var k=l.stateNode;if(typeof l.type.getDerivedStateFromError=="function"||typeof k.componentDidCatch=="function"&&(di===null||!di.has(k))){i=ml(p,i),i=Qv(l,i,1),l=ci(l,i,1),i=Xr(),l!==null&&(zr(l,1,i),io(l,i));break}}l=l.return}}function gA(i,l,p){var k=i.pingCache;k!==null&&k.delete(l),l=Xr(),i.pingedLanes|=i.suspendedLanes&p,Sr===i&&(Mr&p)===p&&(kr===4||kr===3&&(Mr&130023424)===Mr&&500>ln()-Rm?sa(i,0):Im|=p),io(i,l)}function O0(i,l){l===0&&((i.mode&1)===0?l=1:(l=vr,vr<<=1,(vr&130023424)===0&&(vr=4194304)));var p=Xr();i=$s(i,l),i!==null&&(zr(i,l,p),io(i,p))}function kA(i){var l=i.memoizedState,p=0;l!==null&&(p=l.retryLane),O0(i,p)}function wA(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),O0(i,p)}var M0;M0=function(i,l,p){if(i!==null)if(i.memoizedProps!==l.pendingProps||no.current)oo=!0;else{if((i.lanes&p)===0&&(l.flags&128)===0)return oo=!1,sA(i,l,p);oo=(i.flags&131072)!==0}else oo=!1,Gn&&(l.flags&1048576)!==0&&pv(l,Rd,l.index);switch(l.lanes=0,l.tag){case 2:var k=l.type;Gd(i,l),i=l.pendingProps;var b=al(l,Fr.current);hl(l,p),b=um(null,l,k,i,b,p);var E=dm();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,ro(k)?(E=!0,Cd(l)):E=!1,l.memoizedState=b.state!==null&&b.state!==void 0?b.state:null,rm(l),b.updater=qd,l.stateNode=b,b._reactInternals=l,km(l,k,i,p),l=bm(null,l,k,!0,E,p)):(l.tag=0,Gn&&E&&Zp(l),Yr(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=vA(k),i=Ko(k,i),b){case 0:l=vm(null,l,k,i,p);break e;case 1:l=a0(null,l,k,i,p);break e;case 11:l=n0(null,l,k,i,p);break e;case 14:l=r0(null,l,k,Ko(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:Ko(k,b),vm(i,l,k,b,p);case 1:return k=l.type,b=l.pendingProps,b=l.elementType===k?b:Ko(k,b),a0(i,l,k,b,p);case 3:e:{if(l0(l),i===null)throw Error(n(387));k=l.pendingProps,E=l.memoizedState,b=E.element,Ev(i,l),zd(l,k,null,p);var M=l.memoizedState;if(k=M.element,E.isDehydrated)if(E={element:k,isDehydrated:!1,cache:M.cache,pendingSuspenseBoundaries:M.pendingSuspenseBoundaries,transitions:M.transitions},l.updateQueue.baseState=E,l.memoizedState=E,l.flags&256){b=ml(Error(n(423)),l),l=c0(i,l,k,p,b);break e}else if(k!==b){b=ml(Error(n(424)),l),l=c0(i,l,k,p,b);break e}else for(vo=oi(l.stateNode.containerInfo.firstChild),yo=l,Gn=!0,Wo=null,p=bv(l,null,k,p),l.child=p;p;)p.flags=p.flags&-3|4096,p=p.sibling;else{if(ul(),k===b){l=As(i,l,p);break e}Yr(i,l,k,p)}l=l.child}return l;case 5:return Nv(l),i===null&&Yp(l),k=l.type,b=l.pendingProps,E=i!==null?i.memoizedProps:null,M=b.children,Bp(k,b)?M=null:E!==null&&Bp(k,E)&&(l.flags|=32),i0(i,l),Yr(i,l,M,p),l.child;case 6:return i===null&&Yp(l),null;case 13:return u0(i,l,p);case 4:return om(l,l.stateNode.containerInfo),k=l.pendingProps,i===null?l.child=dl(l,null,k,p):Yr(i,l,k,p),l.child;case 11:return k=l.type,b=l.pendingProps,b=l.elementType===k?b:Ko(k,b),n0(i,l,k,b,p);case 7:return Yr(i,l,l.pendingProps,p),l.child;case 8:return Yr(i,l,l.pendingProps.children,p),l.child;case 12:return Yr(i,l,l.pendingProps.children,p),l.child;case 10:e:{if(k=l.type._context,b=l.pendingProps,E=l.memoizedProps,M=b.value,Pn(Ld,k._currentValue),k._currentValue=M,E!==null)if(to(E.value,M)){if(E.children===b.children&&!no.current){l=As(i,l,p);break e}}else for(E=l.child,E!==null&&(E.return=l);E!==null;){var V=E.dependencies;if(V!==null){M=E.child;for(var ee=V.firstContext;ee!==null;){if(ee.context===k){if(E.tag===1){ee=Cs(-1,p&-p),ee.tag=2;var ke=E.updateQueue;if(ke!==null){ke=ke.shared;var Le=ke.pending;Le===null?ee.next=ee:(ee.next=Le.next,Le.next=ee),ke.pending=ee}}E.lanes|=p,ee=E.alternate,ee!==null&&(ee.lanes|=p),tm(E.return,p,l),V.lanes|=p;break}ee=ee.next}}else if(E.tag===10)M=E.type===l.type?null:E.child;else if(E.tag===18){if(M=E.return,M===null)throw Error(n(341));M.lanes|=p,V=M.alternate,V!==null&&(V.lanes|=p),tm(M,p,l),M=E.sibling}else M=E.child;if(M!==null)M.return=E;else for(M=E;M!==null;){if(M===l){M=null;break}if(E=M.sibling,E!==null){E.return=M.return,M=E;break}M=M.return}E=M}Yr(i,l,b.children,p),l=l.child}return l;case 9:return b=l.type,k=l.pendingProps.children,hl(l,p),b=Ro(b),k=k(b),l.flags|=1,Yr(i,l,k,p),l.child;case 14:return k=l.type,b=Ko(k,l.pendingProps),b=Ko(k.type,b),r0(i,l,k,b,p);case 15:return o0(i,l,l.type,l.pendingProps,p);case 17:return k=l.type,b=l.pendingProps,b=l.elementType===k?b:Ko(k,b),Gd(i,l),l.tag=1,ro(k)?(i=!0,Cd(l)):i=!1,hl(l,p),Vv(l,k,b),km(l,k,b,p),bm(null,l,k,!0,i,p);case 19:return f0(i,l,p);case 22:return s0(i,l,p)}throw Error(n(156,l.tag))};function L0(i,l){return Bt(i,l)}function yA(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 Lo(i,l,p,k){return new yA(i,l,p,k)}function Bm(i){return i=i.prototype,!(!i||!i.isReactComponent)}function vA(i){if(typeof i=="function")return Bm(i)?1:0;if(i!=null){if(i=i.$$typeof,i===W)return 11;if(i===Y)return 14}return 2}function mi(i,l){var p=i.alternate;return p===null?(p=Lo(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,E){var M=2;if(k=i,typeof i=="function")Bm(i)&&(M=1);else if(typeof i=="string")M=5;else e:switch(i){case C:return aa(p.children,b,E,l);case O:M=8,b|=8;break;case A:return i=Lo(12,p,l,b|2),i.elementType=A,i.lanes=E,i;case U:return i=Lo(13,p,l,b),i.elementType=U,i.lanes=E,i;case Q:return i=Lo(19,p,l,b),i.elementType=Q,i.lanes=E,i;case H:return af(p,b,E,l);default:if(typeof i=="object"&&i!==null)switch(i.$$typeof){case D:M=10;break e;case B:M=9;break e;case W:M=11;break e;case Y:M=14;break e;case se:M=16,k=null;break e}throw Error(n(130,i==null?i:typeof i,""))}return l=Lo(M,p,l,b),l.elementType=i,l.type=k,l.lanes=E,l}function aa(i,l,p,k){return i=Lo(7,i,k,l),i.lanes=p,i}function af(i,l,p,k){return i=Lo(22,i,k,l),i.elementType=H,i.lanes=p,i.stateNode={isHidden:!1},i}function Um(i,l,p){return i=Lo(6,i,null,l),i.lanes=p,i}function Hm(i,l,p){return l=Lo(4,i.children!==null?i.children:[],i.key,l),l.lanes=p,l.stateNode={containerInfo:i.containerInfo,pendingChildren:null,implementation:i.implementation},l}function bA(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=_n(0),this.expirationTimes=_n(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=_n(0),this.identifierPrefix=k,this.onRecoverableError=b,this.mutableSourceEagerHydrationData=null}function Wm(i,l,p,k,b,E,M,V,ee){return i=new bA(i,l,p,V,ee),l===1?(l=1,E===!0&&(l|=8)):l=0,E=Lo(3,null,null,l),i.current=E,E.stateNode=i,E.memoizedState={element:k,isDehydrated:p,cache:null,transitions:null,pendingSuspenseBoundaries:null},rm(E),i}function xA(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 P0(i){if(!i)return ii;i=i._reactInternals;e:{if(bn(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(ro(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(ro(p))return dv(i,p,l)}return l}function D0(i,l,p,k,b,E,M,V,ee){return i=Wm(p,k,!0,i,b,E,M,V,ee),i.context=P0(null),p=i.current,k=Xr(),b=hi(p),E=Cs(k,b),E.callback=l??null,ci(p,E,b),i.current.lanes=b,zr(i,b,k),io(i,k),i}function lf(i,l,p,k){var b=l.current,E=Xr(),M=hi(b);return p=P0(p),l.context===null?l.context=p:l.pendingContext=p,l=Cs(E,M),l.payload={element:i},k=k===void 0?null:k,k!==null&&(l.callback=k),i=ci(b,l,M),i!==null&&(Go(i,b,M,E),Dd(i,b,M)),M}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 z0(i,l){if(i=i.memoizedState,i!==null&&i.dehydrated!==null){var p=i.retryLane;i.retryLane=p!==0&&p<l?p:l}}function Km(i,l){z0(i,l),(i=i.alternate)&&z0(i,l)}function EA(){return null}var F0=typeof reportError=="function"?reportError:function(i){console.error(i)};function qm(i){this._internalRoot=i}uf.prototype.render=qm.prototype.render=function(i){var l=this._internalRoot;if(l===null)throw Error(n(409));lf(i,l,null,null)},uf.prototype.unmount=qm.prototype.unmount=function(){var i=this._internalRoot;if(i!==null){this._internalRoot=null;var l=i.containerInfo;oa(function(){lf(null,i,null,null)}),l[_s]=null}};function uf(i){this._internalRoot=i}uf.prototype.unstable_scheduleHydration=function(i){if(i){var l=br();i={blockedOn:null,target:i,priority:l};for(var p=0;p<vt.length&&l!==0&&l<vt[p].priority;p++);vt.splice(p,0,i),p===0&&ir(i)}};function Zm(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 B0(){}function SA(i,l,p,k,b){if(b){if(typeof k=="function"){var E=k;k=function(){var ke=cf(M);E.call(ke)}}var M=D0(l,k,i,0,null,!1,!1,"",B0);return i._reactRootContainer=M,i[_s]=M.current,Nc(i.nodeType===8?i.parentNode:i),oa(),M}for(;b=i.lastChild;)i.removeChild(b);if(typeof k=="function"){var V=k;k=function(){var ke=cf(ee);V.call(ke)}}var ee=Wm(i,0,!1,null,null,!1,!1,"",B0);return i._reactRootContainer=ee,i[_s]=ee.current,Nc(i.nodeType===8?i.parentNode:i),oa(function(){lf(l,ee,p,k)}),ee}function ff(i,l,p,k,b){var E=p._reactRootContainer;if(E){var M=E;if(typeof b=="function"){var V=b;b=function(){var ee=cf(M);V.call(ee)}}lf(l,M,i,b)}else M=SA(p,l,i,b,k);return cf(M)}ys=function(i){switch(i.tag){case 3:var l=i.stateNode;if(l.current.memoizedState.isDehydrated){var p=X(l.pendingLanes);p!==0&&(os(l,p|1),io(l,ln()),(mn&6)===0&&(wl=ln()+500,ai()))}break;case 13:oa(function(){var k=$s(i,1);if(k!==null){var b=Xr();Go(k,i,1,b)}}),Km(i,1)}},An=function(i){if(i.tag===13){var l=$s(i,134217728);if(l!==null){var p=Xr();Go(l,i,134217728,p)}Km(i,134217728)}},sn=function(i){if(i.tag===13){var l=hi(i),p=$s(i,l);if(p!==null){var k=Xr();Go(p,i,l,k)}Km(i,l)}},br=function(){return Vt},Cr=function(i,l){var p=Vt;try{return Vt=i,l()}finally{Vt=p}},We=function(i,l,p){switch(l){case"input":if(Be(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=jd(k);if(!b)throw Error(n(90));le(k),Be(k,b)}}}break;case"textarea":ht(i,p);break;case"select":l=p.value,l!=null&&_t(i,!!p.multiple,l,!1)}},$e=Dm,Fe=oa;var _A={usingClientEntryPoint:!1,Events:[$c,sl,jd,P,oe,Dm]},Hc={findFiberByHostInstance:Yi,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},NA={bundleType:Hc.bundleType,version:Hc.version,rendererPackageName:Hc.rendererPackageName,rendererConfig:Hc.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:T.ReactCurrentDispatcher,findHostInstanceByFiber:function(i){return i=dt(i),i===null?null:i.stateNode},findFiberByHostInstance:Hc.findFiberByHostInstance||EA,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{kt=hf.inject(NA),wt=hf}catch{}}return ao.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=_A,ao.createPortal=function(i,l){var p=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!Zm(l))throw Error(n(200));return xA(i,l,null,p)},ao.createRoot=function(i,l){if(!Zm(i))throw Error(n(299));var p=!1,k="",b=F0;return l!=null&&(l.unstable_strictMode===!0&&(p=!0),l.identifierPrefix!==void 0&&(k=l.identifierPrefix),l.onRecoverableError!==void 0&&(b=l.onRecoverableError)),l=Wm(i,1,!1,null,null,p,!1,k,b),i[_s]=l.current,Nc(i.nodeType===8?i.parentNode:i),new qm(l)},ao.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=dt(l),i=i===null?null:i.stateNode,i},ao.flushSync=function(i){return oa(i)},ao.hydrate=function(i,l,p){if(!df(l))throw Error(n(200));return ff(null,i,l,!0,p)},ao.hydrateRoot=function(i,l,p){if(!Zm(i))throw Error(n(405));var k=p!=null&&p.hydratedSources||null,b=!1,E="",M=F0;if(p!=null&&(p.unstable_strictMode===!0&&(b=!0),p.identifierPrefix!==void 0&&(E=p.identifierPrefix),p.onRecoverableError!==void 0&&(M=p.onRecoverableError)),l=D0(l,null,i,1,p??null,b,!1,E,M),i[_s]=l.current,Nc(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)},ao.render=function(i,l,p){if(!df(l))throw Error(n(200));return ff(null,i,l,!1,p)},ao.unmountComponentAtNode=function(i){if(!df(i))throw Error(n(40));return i._reactRootContainer?(oa(function(){ff(null,null,i,!1,function(){i._reactRootContainer=null,i[_s]=null})}),!0):!1},ao.unstable_batchedUpdates=Dm,ao.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)},ao.version="18.3.1-next-f1338f8080-20240426",ao}var V0;function qE(){if(V0)return Ym.exports;V0=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(),Ym.exports=LA(),Ym.exports}var ZE=qE(),pf={},Y0;function PA(){if(Y0)return pf;Y0=1;var e=qE();return pf.createRoot=e.createRoot,pf.hydrateRoot=e.hydrateRoot,pf}var DA=PA();const Ci="shell",GE="check",_a="ToolSearch",iw="AskUserQuestion",zA="handoff",FA="worktrees";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 BA=new Set(["edit","delete","move","execute"]),UA=new Set(["Edit","Write","MultiEdit","NotebookEdit","Bash"]);function VE(e){return e.kind?BA.has(e.kind):UA.has(e.name)}const HA=["read","edit","delete","move","search","execute","fetch"];function aw(e){return HA.includes(e??"")}function YE(e,t){return(aw(e.kind)||e.name===iw||e.name===_a)&&$h(t)}const WA=/^(?:mcp__(.+?)__(.+)|([A-Za-z0-9_-]+)\/([A-Za-z0-9_-]+))$/;function KA(e){const t=WA.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 $h(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 Ch=[{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"}],Ug="auto";function qA(e){return e.branch.startsWith("toyon/")}function ZA(e){return e.unread===!0||e.lastTurn!=null&&(e.seenAt==null||e.seenAt<e.lastTurn.at)}const Do="shell",Ds="login";function GA(e,t){return`${e}/${t}`}function VA(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 ns=e=>e==="working"||e==="waiting",YA=["use","always","off"];function XE(e){return e.find(t=>t.id==="default")}function XA(e,t){const n=XE(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 QA(e,t){if(t.some(o=>o.id===e))return e;const n=X0(e);if(n===void 0)return;if(t.some(o=>o.id===n))return n;if(n!==lw(e))return;let r;for(const o of t){if(X0(o.id)!==n)continue;const s=JA(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 QE=/(?:^|[./])claude-(?:(\d{1,2})(?:-(\d{1,2})(?!\d))?-)?([a-z]+)(?:-(\d{1,2})(?!\d)(?:-(\d{1,2})(?!\d))?)?/;function lw(e){return e.replace(/\[[^\]]*\]$/,"")}function X0(e){var r;const t=lw(e),n=(r=t.match(QE))==null?void 0:r[3];return n||(/^[a-z]+$/.test(t)?t:void 0)}function JA(e){const t=lw(e).match(QE);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 jn(e){return e.worktree!==void 0}function Na(e){return e.kind==="main"}function Bu(e){return e.kind==="spare"}function jr(e){return Bu(e)||Na(e)}function Ah(e){return e.kind==="worktree"}function JE(e){return e.kind==="worktree"&&qA(e)}function ma(e){var t;return e.kind==="worktree"&&((t=e.from)==null?void 0:t.kind)!=="pr"}function Df(e){return e.kind==="worktree"}function Ih(e){return!!e.branch&&!e.locked&&!(e.worktree&&jr(e.worktree))}const Ta=e=>{var t;return e.promptedAt??((t=e.lastTurn)==null?void 0:t.at)??e.createdAt},Q0=e=>jr(e)?0:1;function eI(e){return[...e].sort((t,n)=>Q0(t.worktree)-Q0(n.worktree)||Ta(n.worktree)-Ta(t.worktree))}function J0(e,t){const n=new Map;for(const r of e)n.set(r.id,r.promptedAt??0);for(const r of t){if(!jn(r)||r.worktree.kind==="spare")continue;const o=r.worktree.repoId;n.set(o,Math.max(n.get(o)??0,Ta(r.worktree)))}return[...e].sort((r,o)=>(n.get(o.id)??0)-(n.get(r.id)??0))}function tI(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":ZA(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 eb="not opened in ";function nI(e){const t=e.lastIndexOf(eb);return t<0?{what:e}:{what:e.slice(0,t).replace(/,\s*$/,""),idle:e.slice(t+eb.length)}}const eS={image:6,paste:4,file:8,pick:8},rI={image:"image",paste:"paste",file:"file",pick:"element"},oI={image:"Image",paste:"Pasted text"},tS=(e,t)=>`${oI[e]} ${t}`,cw=e=>`at most ${eS[e]} ${rI[e]}s per message`,sI=(e,t)=>e.filter(n=>n.kind===t).length,iI=(e,t)=>Math.max(0,eS[t]-sI(e,t));function Hg(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 uw(e,t){const n={...t};return e.map(r=>[r,n[r.kind]++])}function lu(e,t){const n={...e};for(const r of t)n[r.kind]++;return n}function dw(e){return e>=1024*1024?`${(e/1024/1024).toFixed(1)} MB`:`${Math.max(1,Math.round(e/1024))} KB`}const Ll=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},{id:"panel-tab-next",key:"ArrowRight",alt:!0,textKeeps:!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"}],aI=new Set(["zen","close","back","forward","wt-back","wt-forward"]),lI={"wt-back":"back","wt-forward":"forward"};function cI(e){if(!e||e.id==="worktree")return e;const t=lI[e.id];return t?{id:t}:e}function nS(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 uI(e){return e.altKey||e.key.toLowerCase()!=="s"?!1:!!e.ctrlKey!==e.metaKey}function rS(e){const t=zf.find(n=>n.id===e);if(!t)throw new Error(`unknown chord ${e}`);return t}function dI(e,t){return e===t-1?"⌘9":e<8?`⌘${e+1}`:void 0}function fI(e,t){return t===0?null:e===9?t-1:e-1<t?e-1:null}function hI(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 pI(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 mI(e,t){const n=rS(e);return!!n.textKeeps&&hI(t)&&!(n.emptyGives&&pI(t))}const gI=["Find","Preview","Panels","Worktrees"],cu={"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"}},kI={ArrowUp:"↑",ArrowDown:"↓",ArrowLeft:"←",ArrowRight:"→",Backspace:"⌫",Tab:"Tab"};function wI(e,t={}){var c;const n=rS(e),r=cu[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":kI[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 yI(e){return Object.keys(cu).filter(t=>cu[t].section===e&&!cu[t].hidden)}const tb={m:6e4,h:60*6e4};function vI(e){const[t,n]=bI(e);return`${t}${n.charAt(0)}`}function bI(e){const t=e/tb.h;if(t>=1&&Number.isInteger(t))return[t,"hour"];const n=e/tb.m;return n>=1&&Number.isInteger(n)?[n,"minute"]:n>=60?[Math.round(n),"minute"]:[Math.max(1,Math.round(e/1e3)),"second"]}const gu={folder:{shared:".toyon/settings.json",local:".toyon/settings.local.json"},root:{shared:"toyon.json",local:"toyon.local.json"}};function oS(e){return typeof e=="string"?e:e.cmd}function xI(e){return typeof e!="string"&&e.from==="trunk"}function EI(e){return[...e.setup??[],...e.teardown??[],...Object.values(e.run).map(oS),...Object.values(e.profiles??{}).flatMap(n=>Object.values(n.env??{}))].some(n=>n.includes("TOYON_WORKTREE"))}function SI(e){return e===gu.folder.local||e===gu.root.local}function _I(e){return SI(e)?"local":"shared"}function NI(e,t){return(Object.values(gu).find(r=>r.shared===e||r.local===e)??gu.folder)[t]}const TI=e=>`https://${e}/`;function jI(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 CI(n.origin)?n.origin:null}function $I(e){return e.toLowerCase().endsWith(".fly.dev")}function CI(e){let t;try{t=new URL(e)}catch{return!1}return t.origin!==e?!1:t.protocol==="https:"||t.protocol==="http:"&&Rh(t.hostname)}const AI="toyon_grant";function Rh(e){return e==="127.0.0.1"||e==="::1"||e==="[::1]"||e==="localhost"||e.endsWith(".localhost")}function II(e,t,n){return e.replace("{id}",t).replace("{port}",String(n))}const RI=4401,OI=25e4;function MI(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(...LI(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 LI(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)>OI)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 PI=/[\p{L}\p{N}_$]+|\s+|[^\s\p{L}\p{N}_$]/gu;function nb(e){return e.match(PI)??[]}const DI=.4;function zI(e,t){if(e===t)return null;const n=MI(nb(e),nb(t));let r=0;for(const o of n)o.mark===" "&&(r+=o.value.length);return r<DI*Math.max(e.length,t.length)?null:{before:rb(n,"-"),after:rb(n,"+")}}function rb(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 sS(n)}function ob(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(sS)}function sS(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 FI=[{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"}],BI=[{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"}],UI=[{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"}],Wg="merge",Kg="merge";function Ni(e){var n,r,o;const t=((n=e.land)==null?void 0:n.route)??Wg;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 Oh(e){return e.base??e.defaultBranch}function HI(e){return e.base!==void 0&&e.base!==e.defaultBranch}function WI(e){return!!e.pr&&(e.lands??[]).some(t=>{var n;return t.pr===((n=e.pr)==null?void 0:n.number)})}function KI(e){return{land:"a land",commit:"a commit","sync-main":"a sync","pull-main":"a pull"}[e]}function Mh(e){return WI(e)&&!e.landed?void 0:e.pr}function fw(e,t){const n=Mh(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??Kg];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 iS(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 sb(e,t="|"){return e.map(n=>cS(n)).join(t)}function qg(e,t){return typeof t=="bigint"?t.toString():t}function Lh(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function qI(e){return e==null}function hw(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function ZI(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 po(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function Oi(...e){const t={};for(const n of e){const r=Object.getOwnPropertyDescriptors(n);Object.assign(t,r)}return Object.defineProperties({},t)}function GI(e){return JSON.stringify(e)}function VI(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const aS="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function ku(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const YI=Lh(()=>{var e;if(rs.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 wu(e){if(ku(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!(ku(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function lS(e){return wu(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}const XI=new Set(["string","number","symbol"]);function Ul(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Mi(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 ft(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 cS(e){return typeof e=="bigint"?e.toString()+"n":typeof e=="string"?`"${e}"`:`${e}`}function QI(e){return Object.keys(e).filter(t=>e[t]._zod.optin!==void 0&&e[t]._zod.optout==="optional")}const JI={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 eR(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=Oi(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]&&po(a,c,n.shape[c])}return po(this,"shape",a),a},checks:[]});return Mi(e,s)}function tR(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=Oi(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 po(this,"shape",a),a},checks:[]});return Mi(e,s)}function nR(e,t){if(!wu(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=Oi(e._zod.def,{get shape(){const s={...e._zod.def.shape,...t};return po(this,"shape",s),s}});return Mi(e,o)}function rR(e,t){if(!wu(t))throw new Error("Invalid input to safeExtend: expected a plain object");const n=Oi(e._zod.def,{get shape(){const r={...e._zod.def.shape,...t};return po(this,"shape",r),r}});return Mi(e,n)}function oR(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=Oi(e._zod.def,{get shape(){const s={...e._zod.def.shape,...t._zod.def.shape};return po(this,"shape",s),s},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return Mi(e,n)}function ib(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=Oi(t._zod.def,{get shape(){const u=t._zod.def.shape,h={...u};if(n)for(const f of Reflect.ownKeys(n)){if(!Object.prototype.hasOwnProperty.call(u,f))throw new Error(`Unrecognized key: "${String(f)}"`);n[f]&&(h[f]=e?new e({type:"optional",innerType:u[f]}):u[f])}else for(const f of Reflect.ownKeys(u))h[f]=e?new e({type:"optional",innerType:u[f]}):u[f];return po(this,"shape",h),h},checks:[]});return Mi(t,c)}function sR(e,t,n){const r=Oi(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 po(this,"shape",s),s}});return Mi(t,r)}function jl(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 iR(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 Ph(e,t){return t.map(n=>{var r;return(r=n).path??(r.path=[]),n.path.unshift(e),n})}function Kc(e){return typeof e=="string"?e:e==null?void 0:e.message}function ab(e,t,n){var r;for(let o=t;o<e.length;o++)(r=e[o]).schema??(r.schema=n)}function Jl(e,t,n){var g,y,w,v,N,x,_,j,T,I;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:Kc((_=(x=(N=e.inst)==null?void 0:N._zod.def)==null?void 0:x.error)==null?void 0:_.call(x,e))??Kc(s==null?void 0:s(e))??Kc((j=t==null?void 0:t.error)==null?void 0:j.call(t,e))??Kc((T=n.customError)==null?void 0:T.call(n,e))??Kc((I=n.localeError)==null?void 0:I.call(n,e))??"Invalid input",{inst:c,schema:u,continue:h,input:f,...m}=e;return m.path??(m.path=[]),m.message=a,t!=null&&t.reportInput&&(m.input=f),m}const aR=/[\uD800-\uDBFF]/;function pw(e){const t=e.length;if(!aR.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 mw(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function lR(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 yu(...e){const[t,n,r]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:r}:{...t}}function cR(e,t){for(const n in t){const r=Object.getOwnPropertyDescriptor(t,n);r.get?Object.defineProperty(e,n,{...r,enumerable:!1}):uR(e,n,r.value)}}function Hl(e,t,n,r=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:r,value:n}),n}function uS(e,t,n){return Hl(e,t,n,!1)}function uR(e,t,n){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?n:Hl(this,t,n.bind(this))},set(r){Hl(this,t,r)}})}function dR(e,t){const n=Object.getPrototypeOf(e);return t in n?void 0:n}let Jm,xi=!1;const fR={configurable:!0,get(){xi=!0}};function $n(e,t,n){const r=Object.getPrototypeOf(e._zod);if(t in r&&Jm!==e._zod){Jm=void 0;return}Jm=e._zod,Object.defineProperty(r,t,{configurable:!0,get(){Object.defineProperty(this,t,fR);const o=xi;xi=!1;try{const s=n(this);return xi?delete this[t]:Object.defineProperty(this,t,{configurable:!0,writable:!0,value:s}),xi=xi||o,s}catch(s){throw delete this[t],xi=xi||o,s}},set(o){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:o})}})}function hR(e,t,n,r){const o=dR(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 pR="~constantCatch";function mR(e){const t=()=>e;return t[pR]=!0,t}var lb;const eg={value:void 0,enumerable:!1};let cb="captureStackTrace"in Error?Error:null;function gR(e){const t=cb;if(t){const n=t.stackTraceLimit;if(typeof n=="number"){try{t.stackTraceLimit=0}catch{return cb=null,new e}try{return new e}finally{t.stackTraceLimit=n}}}return new e}function Se(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){eg.value=new s(y);try{Object.defineProperty(g,"_zod",eg)}finally{eg.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),N=g._zod.constr.prototype;let x=v;for(;x&&x!==N;)x=Object.getPrototypeOf(x);const _=x??v;c.has(_)||(c.add(_),cR(_,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 h=(r==null?void 0:r.Parent)??Object;class f extends h{}Object.defineProperty(f,"name",{value:e});function m(g){var N;const y=r!=null&&r.Parent?gR(f):this;u(y,g);const w=y._zod.deferred;if(w){for(const x of w)x();y._zod.deferred=void 0}const v=(N=globalThis.__zod_globalConfig)==null?void 0:N.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 Pl extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class dS extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}(lb=globalThis).__zod_globalConfig??(lb.__zod_globalConfig={});const rs=globalThis.__zod_globalConfig;function Li(e){return e&&Object.assign(rs,e),rs}function kR(){const e=this._zod;return e.message??(e.message=JSON.stringify(e.def,qg,2)),e.message}function wR(e){this._zod.message=e}const yR={get:kR,set:wR,enumerable:!0,configurable:!0},tg={value:void 0,enumerable:!1},ng={value:void 0,enumerable:!1},ub=new WeakSet([Object.prototype,Error.prototype]),fS=(e,t)=>{e.name="$ZodError",tg.value=e._zod,Object.defineProperty(e,"_zod",tg),ng.value=t,Object.defineProperty(e,"issues",ng),tg.value=void 0,ng.value=void 0,Object.defineProperty(e,"message",yR);const n=Object.getPrototypeOf(e);ub.has(n)||(ub.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})}}))},hS=Se("$ZodError",fS),pS=Se("$ZodError",fS,void 0,{Parent:Error});function vR(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 bR(e,t=n=>n.message){const n={},r=[];for(const o of e.issues)o.path.length>0?vR(n,o.path[0],()=>[]).push(t(o)):r.push(t(o));return{formErrors:r,fieldErrors:n}}function xR(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,h=0;for(;h<c.length;){const f=c[h],m=h===c.length-1;if(f==="_errors"){m&&u._errors.push(t(a)),h++;continue}Object.prototype.hasOwnProperty.call(u,f)||Object.defineProperty(u,f,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});const g=u[f];m&&g._errors.push(t(a)),u=g,h++}}}};return r(e),n}function Dh(e,t){return{callee:(t==null?void 0:t.callee)??e,Err:t==null?void 0:t.Err}}const gw=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 Pl;if(c.issues.length){const u=new((s==null?void 0:s.Err)??e)(c.issues.map(h=>Jl(h,a,Li())));throw aS(u,(s==null?void 0:s.callee)??t),u}return c.value};return t},kw=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(h=>Jl(h,a,Li())));throw aS(u,(s==null?void 0:s.callee)??t),u}return c.value};return t},zh=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 Pl;return s.issues.length?{success:!1,error:new(e??hS)(s.issues.map(a=>Jl(a,o,Li())))}:{success:!0,data:s.value}},ER=zh(pS),Fh=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=>Jl(a,o,Li())))}:{success:!0,data:s.value}},SR=Fh(pS),_R=e=>{const t=gw(e),n=(r,o,s,a)=>{const c=s?{...s,direction:"backward"}:{direction:"backward"};return t(r,o,c,Dh(n,a))};return n},NR=e=>{const t=gw(e),n=(r,o,s,a)=>t(r,o,s,Dh(n,a));return n},TR=e=>{const t=kw(e),n=async(r,o,s,a)=>{const c=s?{...s,direction:"backward"}:{direction:"backward"};return await t(r,o,c,Dh(n,a))};return n},jR=e=>{const t=kw(e),n=async(r,o,s,a)=>await t(r,o,s,Dh(n,a));return n},$R=e=>(t,n,r)=>{const o=r?{...r,direction:"backward"}:{direction:"backward"};return zh(e)(t,n,o)},CR=e=>(t,n,r)=>zh(e)(t,n,r),AR=e=>async(t,n,r)=>{const o=r?{...r,direction:"backward"}:{direction:"backward"};return Fh(e)(t,n,o)},IR=e=>async(t,n,r)=>Fh(e)(t,n,r),RR=/^[cC][0-9a-z]{6,}$/,OR=/^[0-9a-z]+$/,MR=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,LR=/^[0-9a-vA-V]{20}$/,PR=/^[A-Za-z0-9]{27}$/,DR=/^[a-zA-Z0-9_-]{21}$/;function zR(e){return new RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}const FR=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,BR=/^([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})$/,db=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)$/,UR=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,HR="^[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$";function WR(){return new RegExp(HR,"u")}const KR=/^(?:(?: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])$/,qR=/^(([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}|:))$/,ZR=/^((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])$/,GR=/^(([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])$/,VR=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,mS=/^[A-Za-z0-9_-]*$/,YR=/^https?$/,XR=/^\+[1-9]\d{6,14}$/,gS="(?:(?:\\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 QR(e){return new RegExp(`^${e}$`)}const JR=QR(gS);function Zg(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 eO(e){return new RegExp(`^${Zg(e)}$`)}function tO(e){const t=["Z"];e.offset&&t.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const n=`${Zg({precision:e.precision,seconds:!0})}(?:${t.join("|")})`,r=e.local?`${n}|${Zg({precision:e.precision})}`:n;return new RegExp(`^${gS}T(?:${r})$`)}const nO=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}$`)},rO=/^-?\d+$/,oO=/^-?\d+(?:\.\d+)?$/,sO=/^(?:true|false)$/i,iO=/^[^A-Z]*$/,aO=/^[^a-z]*$/,go=Se("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),ww=e=>{const t=e.value;return!qI(t)&&t.length!==void 0},Qf={number:"number",bigint:"bigint",object:"date"},kS=Se("$ZodCheckLessThan",(e,t)=>{go.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})}}),wS=Se("$ZodCheckGreaterThan",(e,t)=>{go.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})}}),lO=Se("$ZodCheckMultipleOf",(e,t)=>{go.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):ZI(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})}}),cO=Se("$ZodCheckNumberFormat",(e,t)=>{var a;go.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]=JI[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=rO)}),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})}}),uO=Se("$ZodCheckMaxLength",(e,t)=>{var n;go.init(e,t),(n=e._zod.def).when??(n.when=ww),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?pw(o):s)<=t.maximum)return;const c=mw(o);r.issues.push({origin:c,code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),dO=Se("$ZodCheckMinLength",(e,t)=>{var n;go.init(e,t),(n=e._zod.def).when??(n.when=ww),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?pw(o):s)>=t.minimum)return;const c=mw(o);r.issues.push({origin:c,code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),fO=Se("$ZodCheckLengthEquals",(e,t)=>{var n;go.init(e,t),(n=e._zod.def).when??(n.when=ww),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?pw(o):s;if(a===t.length)return;const c=mw(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})}}),Bh=Se("$ZodCheckStringFormat",(e,t)=>{var n,r;go.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=()=>{})}),hO=Se("$ZodCheckRegex",(e,t)=>{Bh.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})}}),pO=Se("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=iO),Bh.init(e,t)}),mO=Se("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=aO),Bh.init(e,t)}),gO=Se("$ZodCheckIncludes",(e,t)=>{go.init(e,t);const n=Ul(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})}}),kO=Se("$ZodCheckStartsWith",(e,t)=>{go.init(e,t);const n=new RegExp(`^${Ul(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})}}),wO=Se("$ZodCheckEndsWith",(e,t)=>{go.init(e,t);const n=new RegExp(`.*${Ul(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})}}),yO=Se("$ZodCheckOverwrite",(e,t)=>{go.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});class vO{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 bO={major:4,minor:5,patch:4},Vn=Se("$ZodType",(e,t)=>{var s;var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=bO;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,h,f)=>{if(u.memo)return u;let m=jl(u),g;for(const y of h){if(y._zod.def.when){if(iR(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&&(f==null?void 0:f.async)===!1)throw new Pl;if(g||v instanceof Promise)g=(g??Promise.resolve()).then(async()=>{await v,u.issues.length!==w&&(ab(u.issues,w,e),m||(m=jl(u,w)))});else{if(u.issues.length===w)continue;ab(u.issues,w,e),m||(m=jl(u,w))}}return g?g.then(()=>u):u},c=(u,h,f)=>{if(jl(u))return u.aborted=!0,u;const m=a(h,o,f);if(m instanceof Promise){if(f.async===!1)throw new Pl;return m.then(g=>e._zod.parse(g,f))}return e._zod.parse(m,f)};e._zod.run=(u,h)=>{if(h.skipChecks)return e._zod.parse(u,h);if(h.direction==="backward"){const m=e._zod.parse({value:u.value,issues:[]},{...h,skipChecks:!0});return m instanceof Promise?m.then(g=>c(g,u,h)):c(m,u,h)}const f=e._zod.parse(u,h);if(f instanceof Promise){if(h.async===!1)throw new Pl;return f.then(m=>a(m,o,h))}return a(f,o,h)}}},{get"~standard"(){return uS(this,"~standard",yS(this))},set"~standard"(e){Hl(this,"~standard",e)}}),fb=e=>{var t;return e.success?{value:e.data}:{issues:(t=e.error)==null?void 0:t.issues}};function yS(e){return{validate:t=>{try{return fb(ER(e,t))}catch{return SR(e,t).then(fb)}},vendor:"zod",version:1}}const yw=Se("$ZodString",(e,t)=>{var n;Vn.init(e,t),e._zod.pattern=[...((n=e==null?void 0:e._zod.bag)==null?void 0:n.patterns)??[]].pop()??nO(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}}),Yn=Se("$ZodStringFormat",(e,t)=>{Bh.init(e,t),yw.init(e,t)}),xO=Se("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=BR),Yn.init(e,t)}),EO=Se("$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=db(r))}else t.pattern??(t.pattern=db());Yn.init(e,t)}),SO=Se("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=UR),Yn.init(e,t)}),vS=1,bS=2;function _O(e,t){var n;if(!t.normalize&&((n=t.protocol)==null?void 0:n.source)===YR.source&&!/^https?:\/\//i.test(e))return vS;try{return new URL(e)}catch{return bS}}const NO=/[\t\n\r]/g;function TO(e){return e.replace(NO,"")}function jO(e,t){return t.lastIndex=0,t.test(e.hostname)}function $O(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(":")?e.protocol.slice(0,-1):e.protocol)}const CO=Se("$ZodURL",(e,t)=>{Yn.init(e,t),e._zod.check=n=>{try{const r=n.value.trim(),o=_O(r,t);if(o===vS){n.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:n.value,inst:e,continue:!t.abort});return}if(o===bS){n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort});return}t.hostname&&!jO(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&&!$O(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:TO(r);return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),AO=Se("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=WR()),Yn.init(e,t)}),IO=Se("$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?DR:zR(t.length)),Yn.init(e,t)}),RO=Se("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=RR),Yn.init(e,t)}),OO=Se("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=OR),Yn.init(e,t)}),MO=Se("$ZodULID",(e,t)=>{t.pattern??(t.pattern=MR),Yn.init(e,t)}),LO=Se("$ZodXID",(e,t)=>{t.pattern??(t.pattern=LR),Yn.init(e,t)}),PO=Se("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=PR),Yn.init(e,t)}),DO=Se("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=tO(t)),Yn.init(e,t),(t.local||t.precision===-1)&&(e._zod.bag.laxFormat=!0,e._zod.onattach.push(n=>{n._zod.bag.laxFormat=!0}))}),zO=Se("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=JR),Yn.init(e,t)}),FO=Se("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=eO(t)),Yn.init(e,t)}),BO=Se("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=FR),Yn.init(e,t)}),UO=Se("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=KR),Yn.init(e,t),e._zod.bag.format="ipv4"}),HO=/^[0-9a-fA-F:.]+$/;function xS(e){if(!HO.test(e))return!1;try{return new URL(`http://[${e}]`),!0}catch{return!1}}const WO=Se("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=qR),Yn.init(e,t),e._zod.bag.format="ipv6",e._zod.check=n=>{xS(n.value)||n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}}),KO=Se("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=ZR),Yn.init(e,t)});function qO(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:xS(n)}const ZO=Se("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=GR),Yn.init(e,t),e._zod.check=n=>{qO(n.value)||n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}});function ES(e){if(e==="")return!0;if(/\s/.test(e)||e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const GO=Se("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=VR),Yn.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{ES(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});function VO(e){if(!mS.test(e))return!1;const t=e.replace(/[-_]/g,r=>r==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return ES(n)}const YO=Se("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=mS),Yn.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{VO(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),XO=Se("$ZodE164",(e,t)=>{t.pattern??(t.pattern=XR),Yn.init(e,t)});function QO(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 JO=Se("$ZodJWT",(e,t)=>{Yn.init(e,t),e._zod.check=n=>{QO(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),SS=Se("$ZodNumber",(e,t)=>{Vn.init(e,t),e._zod.pattern=e._zod.bag.pattern??oO,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}}),e2=Se("$ZodNumberFormat",(e,t)=>{cO.init(e,t),SS.init(e,t)}),t2=Se("$ZodBoolean",(e,t)=>{Vn.init(e,t),e._zod.pattern=sO,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}}),n2=Se("$ZodUnknown",(e,t)=>{Vn.init(e,t),e._zod.parse=n=>n}),r2=Se("$ZodNever",(e,t)=>{Vn.init(e,t),e._zod.parse=(n,r)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)});function hb(e,t,n){e.issues.length&&t.issues.push(...Ph(n,e.issues)),t.value[n]=e.value}const o2=Se("$ZodArray",(e,t)=>{Vn.init(e,t);const n=rs.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],h=t.element._zod.run({value:u,issues:[]},o);h instanceof Promise?a.push(h.then(f=>hb(f,r,c))):hb(h,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(...Ph(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 s2=[];function _S(e){var a,c,u,h;const t=Object.keys(e.shape),n=Object.getOwnPropertySymbols(e.shape),r=n.length?n:s2,o=r.length?[...t,...r]:t;for(const f of o)if(!((h=(u=(c=(a=e.shape)==null?void 0:a[f])==null?void 0:c._zod)==null?void 0:u.traits)!=null&&h.has("$ZodType")))throw new Error(`Invalid element at key "${String(f)}": expected a Zod schema`);const s=QI(e.shape);return{...e,allKeys:o,symbolKeys:r,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(s)}}function NS(e,t,n,r,o,s){const a=[],c=o.keySet,u=o.catchall._zod,h=u.def.type,f=u.optin,m=u.optout;for(const g in t){if(c.has(g))continue;if(g==="__proto__"){h==="never"&&a.push(g);continue}if(h==="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,f,m))):Jf(y,n,g,t,f,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 Gg=new WeakMap,i2=Se("$ZodObject",(e,t)=>{Vn.init(e,t);const n=Object.getOwnPropertyDescriptor(t,"shape");if(!(n!=null&&n.get)){const u=t.shape;Gg.set(t,u),Object.defineProperty(t,"shape",{get:()=>{const h={...u};return Object.defineProperty(t,"shape",{value:h}),Gg.set(t,h),h}})}const r=Lh(()=>_S(t));$n(e,"propValues",u=>{const h=u.def.shape,f={};for(const m in h){const g=h[m]._zod;if(g.values){Object.prototype.hasOwnProperty.call(f,m)||po(f,m,new Set);for(const y of g.values)f[m].add(y);g.optin!==void 0&&f[m].add(void 0)}}return f});const o=ku,s=t.catchall;let a;const c=rs.memoizer;c==null||c.attach(e),e._zod.parse=(u,h)=>{a??(a=r.value);const f=u.value;if(!o(f))return u.issues.push({expected:"object",code:"invalid_type",input:f,inst:e}),u;u.value=c?c.alloc(e,u,{},h):{};const m=[],g=a.shape;for(const y of a.allKeys){if(y==="__proto__")continue;const w=g[y],v=w._zod.optin,N=w._zod.optout,x=w._zod.run({value:f[y],issues:[]},h);x instanceof Promise?m.push(x.then(_=>Jf(_,u,y,f,v,N))):Jf(x,u,y,f,v,N)}return s?NS(m,f,u,h,r.value,e):m.length?Promise.all(m).then(()=>u):u}}),a2=Se("$ZodObjectJIT",(e,t)=>{i2.init(e,t);const n=e._zod.parse,r=Lh(()=>_S(t)),o=rs.memoizer,s=y=>{var I,R;const w=r.value,v=w.symbolKeys,N=new vO(["payload","ctx"],{shape:y,inst:e,memo:o,syms:v}),x=C=>`shape[${C}]._zod.run({ value: input[${C}], issues: [] }, ctx)`,_=(C,O)=>`
47
- for (let i = 0; i < ${C}.issues.length; i++) {
48
- const iss = ${C}.issues[i];
49
- iss.path = iss.path ? [${O}, ...iss.path] : [${O}];
50
- payload.issues.push(iss);
51
- }`;N.write("const input = payload.value;");const j=Object.create(null);let T=0;for(const C of w.allKeys)j[C]=`key_${T++}`;N.write(o?"const newResult = memo.alloc(inst, payload, {}, ctx);":"const newResult = {};");for(const C of w.allKeys){if(C==="__proto__")continue;const O=j[C],A=typeof C=="symbol"?`syms[${v.indexOf(C)}]`:GI(C),D=`${A} in input`,B=y[C],W=(I=B==null?void 0:B._zod)==null?void 0:I.optin,U=W!==void 0,Q=((R=B==null?void 0:B._zod)==null?void 0:R.optout)==="optional";if(N.write(`const ${O} = ${x(A)};`),U&&Q){const Y=W==="optional"?`${O}_present`:`${O}.value !== undefined || ${O}_present`;N.write(`
52
- const ${O}_present = ${D};
53
- if (!${O}.issues.length || ${O}_present) {
54
- if (${O}.issues.length) {${_(O,A)}
55
- }
56
-
57
- if (${Y}) {
58
- newResult[${A}] = ${O}.value;
59
- }
60
- }
61
-
62
- `)}else U?N.write(`
63
- if (${O}.issues.length) {${_(O,A)}
64
- }
65
-
66
- if (${O}.value === undefined) {
67
- if (${D}) {
68
- newResult[${A}] = undefined;
69
- }
70
- } else {
71
- newResult[${A}] = ${O}.value;
72
- }
73
-
74
- `):N.write(`
75
- const ${O}_present = ${D};
76
- if (${O}.issues.length) {${_(O,A)}
77
- }
78
- if (!${O}_present && !${O}.issues.length) {
79
- payload.issues.push({
80
- code: "invalid_type",
81
- expected: "nonoptional",
82
- input: undefined,
83
- path: [${A}]
84
- });
85
- }
86
-
87
- if (${O}_present) {
88
- newResult[${A}] = ${O}.value;
89
- }
90
-
91
- `)}return N.write("payload.value = newResult;"),N.write("return payload;"),N.compile()};let a;const c=ku,u=!rs.jitless,f=u&&YI.value,m=t.catchall;let g;e._zod.parse=(y,w)=>{g??(g=r.value);const v=y.value;return c(v)?u&&f&&(w==null?void 0:w.async)===!1&&w.jitless!==!0?(a||(a=s(t.shape)),y=a(y,w),m?NS([],v,y,w,g,e):y):n(y,w):(y.issues.push({expected:"object",code:"invalid_type",input:v,inst:e}),y)}});function pb(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=>!jl(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=>Jl(a,r,Li())))}),t)}const TS=Se("$ZodUnion",(e,t)=>{Vn.init(e,t),$n(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),$n(e,"optout",r=>r.def.options.some(o=>o._zod.optout==="optional")?"optional":void 0),$n(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)))}),$n(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=>hw(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=>pb(c,r,e,o)):pb(a,r,e,o)}}),l2=Se("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,TS.init(e,t);const n=e._zod.parse;$n(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,h]of Object.entries(c)){Object.prototype.hasOwnProperty.call(s,u)||po(s,u,new Set);for(const f of h)s[u].add(f)}}return s}),t.options.forEach((o,s)=>{const a=Gg.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=Lh(()=>{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 h of u){if(s.has(h))throw new Error(`Duplicate discriminator value "${String(h)}"`);s.set(h,c)}}return s});e._zod.parse=(o,s)=>{const a=o.value;if(!ku(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)}}),c2=Se("$ZodIntersection",(e,t)=>{Vn.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,h])=>mb(n,u,h)):mb(n,s,a)}});function Vg(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(wu(e)&&wu(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=Vg(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=Vg(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 mb(e,t,n){const r=new Map;let o;const s=new Map,a=(h,f)=>{var g,y;let m;if(h.code==="unrecognized_keys"&&!((g=h.path)!=null&&g.length))o??(o=h),m=h.keys;else if(h.code==="invalid_key"&&h.origin==="record"&&((y=h.path)==null?void 0:y.length)===1){const w=String(h.path[0]);s.has(w)||s.set(w,h),m=[w]}else return!1;for(const w of m)r.has(w)||r.set(w,{}),r.get(w)[f]=!0;return!0};for(const h of t.issues)a(h,"l")||e.issues.push(h);for(const h of n.issues)a(h,"r")||e.issues.push(h);const c=[...r].filter(([,h])=>h.l&&h.r).map(([h])=>h);if(c.length){const h=o?c.filter(f=>o.keys.includes(f)):[];h.length&&e.issues.push({...o,keys:h});for(const f of c)!h.includes(f)&&s.has(f)&&e.issues.push(s.get(f))}const u=Vg(t.value,n.value);if(!u.valid){if(jl(e))return e;throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(u.mergeErrorPath)}`)}return e.value=u.data,e}const u2=Se("$ZodTuple",(e,t)=>{Vn.init(e,t);const n=t.items,r=rs.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=gb(n,"optin"),h=gb(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 f=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=>{f[m]=y})):f[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=>kb(v,o,m))):kb(w,o,m)}}return c.length?Promise.all(c).then(()=>wb(f,o,n,a,h)):wb(f,o,n,a,h)}});function gb(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 kb(e,t,n){e.issues.length&&t.issues.push(...Ph(n,e.issues)),t.value[n]=e.value}function wb(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(...Ph(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 d2=Se("$ZodEnum",(e,t)=>{Vn.init(e,t);const n=iS(t.entries),r=new Set(n);e._zod.values=r;const o=n.filter(s=>XI.has(typeof s));e._zod.pattern=new RegExp(o.length?`^(${o.map(s=>Ul(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}}),f2=Se("$ZodLiteral",(e,t)=>{Vn.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"?Ul(r):r?Ul(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}}),h2=Se("$ZodTransform",(e,t)=>{var n;Vn.init(e,t),e._zod.optin="optional",(n=rs.memoizer)==null||n.guard(e),e._zod.parse=(r,o)=>{if(o.direction==="backward")throw new dS(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 Pl;return r.value=s,r}});function yb(e,t){return e.value=t.issues.length?void 0:t.value,e}const jS=Se("$ZodOptional",(e,t)=>{Vn.init(e,t),$n(e,"optin",n=>n.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),e._zod.optout="optional",$n(e,"values",n=>{const r=n.def.innerType._zod.values;return r?new Set([...r,void 0]):void 0}),$n(e,"pattern",n=>{const r=n.def.innerType._zod.pattern;return r?new RegExp(`^(${hw(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=>yb(n,s)):yb(n,o)}return t.innerType._zod.run(n,r)}}),p2=Se("$ZodExactOptional",(e,t)=>{jS.init(e,t),$n(e,"values",n=>n.def.innerType._zod.values),$n(e,"pattern",n=>n.def.innerType._zod.pattern),e._zod.parse=(n,r)=>t.innerType._zod.run(n,r)}),m2=Se("$ZodNullable",(e,t)=>{Vn.init(e,t),$n(e,"optin",n=>n.def.innerType._zod.optin),$n(e,"optout",n=>n.def.innerType._zod.optout),$n(e,"pattern",n=>{const r=n.def.innerType._zod.pattern;return r?new RegExp(`^(${hw(r.source)}|null)$`):void 0}),$n(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)}),g2=Se("$ZodDefault",(e,t)=>{Vn.init(e,t),e._zod.optin="defaulted",$n(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=>vb(s,t)):vb(o,t)}});function vb(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const k2=Se("$ZodPrefault",(e,t)=>{Vn.init(e,t),e._zod.optin="defaulted",$n(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))}),w2=Se("$ZodNonOptional",(e,t)=>{Vn.init(e,t),$n(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=>bb(s,e)):bb(o,e)}});function bb(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 xb(e,t,n,r){return t.issues.length?(e.value=n.catchValue({...t,value:e.value,error:{issues:t.issues.map(o=>Jl(o,r,Li()))},input:e.value}),e):(e.value=t.value,t.memo&&(e.memo=!0),e)}const y2=Se("$ZodCatch",(e,t)=>{Vn.init(e,t),$n(e,"optin",n=>n.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),$n(e,"optout",n=>n.def.innerType._zod.optout),$n(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=>xb(n,s,t,r)):xb(n,o,t,r)}}),v2=Se("$ZodPipe",(e,t)=>{Vn.init(e,t),$n(e,"values",n=>n.def.in._zod.values),$n(e,"optin",n=>n.def.in._zod.optin),$n(e,"optout",n=>n.def.out._zod.optout),$n(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 b2=Se("$ZodReadonly",(e,t)=>{Vn.init(e,t),$n(e,"propValues",n=>n.def.innerType._zod.propValues),$n(e,"values",n=>n.def.innerType._zod.values),$n(e,"optin",n=>{var r,o;return(o=(r=n.def.innerType)==null?void 0:r._zod)==null?void 0:o.optin}),$n(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(Eb):Eb(o)}});function Eb(e){return e.memo||(e.value=Object.freeze(e.value)),e}const x2=Se("$ZodCustom",(e,t)=>{go.init(e,t),Vn.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=>Sb(s,n,r,e));Sb(o,n,r,e)}});function Sb(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(yu(o))}}class E2 extends Error{constructor(){super("Cannot parse a reference cycle that closes through a transform"),this.name="ZodCyclicError"}}const Yg="~memo",_b=[];function rg(e){return e.map(t=>t.path?{...t,path:t.path.slice()}:{...t})}const Nb=new WeakMap;function $S(e,t){const n=Nb.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)&&$S(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 h=u.value;if(!(!h||typeof h!="object")){if(h._zod)o(h);else if(Array.isArray(h))for(const f of h)o(f)}}}return t.delete(e),Nb.set(e,r),r}function S2(e,t){let n=e.buckets.get(t);return n||(n=new Map,e.buckets.set(t,n)),n}let kf;const wf=[],_2={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"&&T2(s,o.value))throw new E2;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=$S(e,new Set),!n))return e._zod.parse=s,e._zod.run===a&&(e._zod.run=s),s(c,u);const h=c.value;if(h===null||typeof h!="object")return s(c,u);let f=u[Yg];f||(f={buckets:new Map,backEdges:void 0},u[Yg]=f);let m;r===u?m=o:(m=S2(f,e),r=u,o=m);const g=m.get(h);if(g)return c.value=g.value,g.issues?g.issues.length&&c.issues.push(...rg(g.issues)):(c.memo=!0,f.backEdges??(f.backEdges=new Set),f.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(N=>(v&&(v.issues=N.issues.length?rg(N.issues):_b),N)):(v&&(v.issues=w.issues.length?rg(w.issues):_b),w)};e._zod.parse=a,e._zod.run===s&&(e._zod.run=a)})}};function N2(){return _2}function T2(e,t){var r;const n=(r=e[Yg])==null?void 0:r.backEdges;return n!==void 0&&t!==null&&typeof t=="object"&&n.has(t)}const j2=()=>{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=lR(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 ${cS(s.values[0])}`:`Invalid option: expected one of ${sb(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":""}: ${sb(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 $2(){return{localeError:j2()}}var Tb;class C2{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 A2(){return new C2}(Tb=globalThis).__zod_globalRegistry??(Tb.__zod_globalRegistry=A2());const eu=globalThis.__zod_globalRegistry;function I2(e,t){return new e({type:"string",...ft(t)})}function R2(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...ft(t)})}function O2(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...ft(t)})}function M2(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...ft(t)})}function L2(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...ft(t)})}function P2(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...ft(t)})}function D2(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...ft(t)})}function z2(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...ft(t)})}function F2(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...ft(t)})}function B2(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...ft(t)})}function U2(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...ft(t)})}function H2(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...ft(t)})}function W2(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...ft(t)})}function K2(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...ft(t)})}function q2(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...ft(t)})}function Z2(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...ft(t)})}function G2(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...ft(t)})}function V2(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...ft(t)})}function Y2(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...ft(t)})}function X2(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...ft(t)})}function Q2(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...ft(t)})}function J2(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...ft(t)})}function eM(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...ft(t)})}function tM(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...ft(t)})}function nM(e,t){return new e({type:"string",format:"date",check:"string_format",...ft(t)})}function rM(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...ft(t)})}function oM(e,t){return new e({type:"string",format:"duration",check:"string_format",...ft(t)})}function sM(e,t){return new e({type:"number",checks:[],...ft(t)})}function iM(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...ft(t)})}function aM(e,t){return new e({type:"boolean",...ft(t)})}function lM(e){return new e({type:"unknown"})}function cM(e,t){return new e({type:"never",...ft(t)})}function jb(e,t){return new kS({check:"less_than",...ft(t),value:e,inclusive:!1})}function og(e,t){return new kS({check:"less_than",...ft(t),value:e,inclusive:!0})}function $b(e,t){return new wS({check:"greater_than",...ft(t),value:e,inclusive:!1})}function sg(e,t){return new wS({check:"greater_than",...ft(t),value:e,inclusive:!0})}function Cb(e,t){return new lO({check:"multiple_of",...ft(t),value:e})}function CS(e,t){return new uO({check:"max_length",...ft(t),maximum:e})}function eh(e,t){return new dO({check:"min_length",...ft(t),minimum:e})}function AS(e,t){return new fO({check:"length_equals",...ft(t),length:e})}function uM(e,t){return new hO({check:"string_format",format:"regex",...ft(t),pattern:e})}function dM(e){return new pO({check:"string_format",format:"lowercase",...ft(e)})}function fM(e){return new mO({check:"string_format",format:"uppercase",...ft(e)})}function hM(e,t){return new gO({check:"string_format",format:"includes",...ft(t),includes:e})}function pM(e,t){return new kO({check:"string_format",format:"starts_with",...ft(t),prefix:e})}function mM(e,t){return new wO({check:"string_format",format:"ends_with",...ft(t),suffix:e})}function ec(e){return new yO({check:"overwrite",tx:e})}function gM(e){return ec(t=>t.normalize(e))}function kM(){return ec(e=>e.trim())}function wM(){return ec(e=>e.toLowerCase())}function yM(){return ec(e=>e.toUpperCase())}function vM(){return ec(e=>VI(e))}function bM(e,t,n){return new e({type:"array",element:t,...ft(n)})}function xM(e,t,n){return new e({type:"custom",check:"custom",fn:t,...ft(n)})}function EM(e,t){const n=SM(r=>(r.addIssue=o=>{if(typeof o=="string")r.issues.push(yu(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(yu(s))}},e(r.value,r)),t);return n}function SM(e,t){const n=new go({check:"custom",...ft(t)});return n._zod.check=e,n}function uu(e,...t){for(const n of t)for(const r of Reflect.ownKeys(n))Object.prototype.propertyIsEnumerable.call(n,r)&&po(e,r,n[r]);return e}function IS(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)??eu,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 Ai(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 yr(e,t,n={path:[],schemaPath:[]}){var f,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=(f=e._zod).toJSONSchema)==null?void 0:m.call(f);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),yr(y,t,g),t.seen.get(y).isParent=!0)}const u=t.metadataRegistry.get(e);return u&&uu(a.schema,u),t.io==="input"&&Jr(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 Ab(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function RS(e,t){var a,c,u,h;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 f of e.seen.entries()){const m=(a=e.metadataRegistry.get(f[0]))==null?void 0:a.id;if(m){const g=r.get(m);if(g&&g!==f[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,f[0])}}const o=f=>{var v;const m=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){const N=(v=e.external.registry.get(f[0]))==null?void 0:v.id,x=e.external.uri??(j=>j);if(N)return{ref:x(N)};const _=f[1].defId??f[1].schema.id??`schema${e.counter++}`;return f[1].defId=_,{defId:_,ref:`${x("__shared")}#/${m}/${Ab(_)}`}}const g="#",y=`${g}/${m}/`;if(f[1]===n&&!f[1].schema.id)return{ref:g};const w=f[1].schema.id??`__schema${e.counter++}`;return{defId:w,ref:y+Ab(w)}},s=f=>{if(f[1].schema.$ref)return;const m=f[1],{ref:g,defId:y}=o(f);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 f of e.seen.entries()){const m=f[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 f of e.seen.entries()){const m=f[1];if(t===f[0]){s(f);continue}if(e.external){const y=(u=e.external.registry.get(f[0]))==null?void 0:u.id;if(t!==f[0]&&y){s(f);continue}}if((h=e.metadataRegistry.get(f[0]))==null?void 0:h.id){s(f);continue}if(m.cycle){s(f);continue}if(m.count>1&&e.reused==="ref"){s(f);continue}}e.external&&(e.sharedDefsExtractedFor=e.external)}function OS(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;OS(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 MS=new Set(["type","properties","required","additionalProperties"]),Ib=["oneOf","anyOf"];function Rb(e){const t=e.additionalProperties;return t===void 0||t===!1||typeof t!="object"||t===null?null:Object.keys(t).length?t:null}function Xg(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(!MS.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 f of t){const m=((s=f.properties)==null?void 0:s[c])??Rb(f);m!=null&&(u.some(g=>JSON.stringify(g)===JSON.stringify(m))||u.push(m))}const h=u.length===1?u[0]:Xg(u)??{allOf:u};po(n,c,h)}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=Rb(c);u&&!a.some(h=>JSON.stringify(h)===JSON.stringify(u))&&a.push(u)}a.length===1?o.additionalProperties=a[0]:a.length>1&&(o.additionalProperties={allOf:a})}return o}function _M(e){const t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(const o of MS)if(o in e)return;const n=t.filter(o=>Ib.some(s=>Array.isArray(o[s])));let r=null;if(!n.length)r=Xg(t);else{const o=n[0],s=Ib.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=>Xg([...a,u]));if(c.some(u=>!u))return;r={[s]:c}}r&&(delete e.allOf,uu(e,r))}function LS(e,t){var c,u,h,f;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),_=x.schema;if(_.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(y.allOf=y.allOf??[],y.allOf.push(_)):uu(y,_),uu(y,w),m._zod.parent===v)for(const T in y)T==="$ref"||T==="allOf"||T in w||delete y[T];if(_.$ref&&x.def)for(const T in y)T==="$ref"||T==="allOf"||T in x.def&&JSON.stringify(y[T])===JSON.stringify(x.def[T])&&delete y[T]}const N=m._zod.parent;if(N&&N!==v){r(N);const x=e.seen.get(N);if(x!=null&&x.schema.$ref&&(y.$ref=x.schema.$ref,x.def))for(const _ in y)_==="$ref"||_==="allOf"||_ in x.def&&JSON.stringify(y[_])===JSON.stringify(x.def[_])&&delete y[_]}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())OS(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)??[])_M(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)}uu(o,n.defId?n.schema:n.def??n.schema);const s=(h=e.metadataRegistry.get(t))==null?void 0:h.id;s!==void 0&&o.id===s&&delete o.id;const a=((f=e.external)==null?void 0:f.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,po(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 Jr(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 Jr(r.element,n);if(r.type==="set")return Jr(r.valueType,n);if(r.type==="lazy")return Jr(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 Jr(r.innerType,n);if(r.type==="intersection")return Jr(r.left,n)||Jr(r.right,n);if(r.type==="record"||r.type==="map")return Jr(r.keyType,n)||Jr(r.valueType,n);if(r.type==="pipe")return e._zod.traits.has("$ZodCodec")?!0:Jr(r.in,n)||Jr(r.out,n);if(r.type==="object"){for(const o in r.shape)if(Jr(r.shape[o],n))return!0;return!1}if(r.type==="union"){for(const o of r.options)if(Jr(o,n))return!0;return!1}if(r.type==="tuple"){for(const o of r.items)if(Jr(o,n))return!0;return!!(r.rest&&Jr(r.rest,n))}return!1}const NM=(e,t={})=>n=>{const r=IS({...n,processors:t});return yr(e,r),RS(r,e),LS(r,e)},th=(e,t,n={})=>r=>{const{libraryOptions:o,target:s}=r??{},a=IS({...o??{},target:s,io:t,processors:n});return yr(e,a),RS(a,e),LS(a,e)},TM={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},jM=(e,t,n,r)=>{const o=n;o.type="string";const{minimum:s,maximum:a,format:c,patterns:u,contentEncoding:h,laxFormat:f}=e._zod.bag;if(typeof s=="number"&&(o.minLength=s),typeof a=="number"&&(o.maxLength=a),c&&(o.format=TM[c]??c,o.format===""&&delete o.format,(c==="time"||f)&&delete o.format),h&&(o.contentEncoding=h),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}))])}},$M=(e,t,n,r)=>{const o=n,{minimum:s,maximum:a,format:c,multipleOf:u,exclusiveMaximum:h,exclusiveMinimum:f}=e._zod.bag;typeof c=="string"&&c.includes("int")?o.type="integer":o.type="number";const m=typeof f=="number"&&f>=(s??Number.NEGATIVE_INFINITY),g=typeof h=="number"&&h<=(a??Number.POSITIVE_INFINITY),y=t.target==="draft-04"||t.target==="openapi-3.0";m?y?(o.minimum=f,o.exclusiveMinimum=!0):o.exclusiveMinimum=f:typeof s=="number"&&(o.minimum=s),g?y?(o.maximum=h,o.exclusiveMaximum=!0):o.exclusiveMaximum=h:typeof a=="number"&&(o.maximum=a),typeof u=="number"&&(Number.isFinite(u)&&u!==0?o.multipleOf=Math.abs(u):Ai(e,t,o,r,`A multipleOf divisor of ${u} cannot be represented in JSON Schema`))},CM=(e,t,n,r)=>{n.type="boolean"},AM=(e,t,n,r)=>{n.not={}},IM=(e,t,n,r)=>{},RM=(e,t,n,r)=>{const o=e._zod.def,s=iS(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},OM=(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(Ai(e,t,n,r,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof a=="bigint"){if(Ai(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},MM=(e,t,n,r)=>{Ai(e,t,n,r,"Custom types cannot be represented in JSON Schema")},LM=(e,t,n,r)=>{Ai(e,t,n,r,"Transforms cannot be represented in JSON Schema")},PM=(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=yr(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 DM=(e,t,n,r)=>{var f;const o=n,s=e._zod.def,a=s.shape;if(Object.getOwnPropertySymbols(a).length&&Ai(e,t,o,r,"Symbol keys cannot be represented in JSON Schema"))return;o.type="object",o.properties={};for(const m in a)po(o.properties,m,yr(a[m],t,{...r,path:[...r.path,"properties",m]}));const u=new Set(Object.keys(a)),h=new Set([...u].filter(m=>{const g=s.shape[m];return t.io==="input"?nh(g)===void 0:g._zod.optout===void 0}));h.size>0&&(o.required=Array.from(h)),((f=s.catchall)==null?void 0:f._zod.def.type)==="never"?o.additionalProperties=!1:s.catchall?s.catchall&&(o.additionalProperties=yr(s.catchall,t,{...r,path:[...r.path,"additionalProperties"]})):t.io==="output"&&(o.additionalProperties=!1)},zM=(e,t,n,r)=>{const o=e._zod.def,s=o.inclusive===!1,a=o.options.map((c,u)=>yr(c,t,{...r,path:[...r.path,s?"oneOf":"anyOf",u]}));s?n.oneOf=a:n.anyOf=a},FM=(e,t,n,r)=>{const o=e._zod.def,s=yr(o.left,t,{...r,path:[...r.path,"allOf",0]}),a=yr(o.right,t,{...r,path:[...r.path,"allOf",1]}),c=h=>"allOf"in h&&Object.keys(h).length===1,u=[...c(s)?s.allOf:[s],...c(a)?a.allOf:[a]];n.allOf=u,t.intersections.push(u)},BM=(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,N)=>yr(v,t,{...r,path:[...r.path,a,N]})),h=s.rest?yr(s.rest,t,{...r,path:[...r.path,c,...t.target==="openapi-3.0"?[s.items.length]:[]]}):null;let f=s.items.length;for(;f>0;){const v=s.items[f-1];if(!(t.io==="input"?nh(v)!==void 0:v._zod.optout==="optional"))break;f--}const m=s.items.length,g=!s.rest;t.target==="draft-2020-12"?(o.prefixItems=u,g?o.items=!1:h&&(o.items=h),f>0&&(o.minItems=f),g&&(o.maxItems=m)):t.target==="openapi-3.0"?(o.items={anyOf:u},h&&o.items.anyOf.push(h),f>0&&(o.minItems=f),g&&(o.maxItems=m)):(o.items=u,g?o.additionalItems=!1:h&&(o.additionalItems=h),f>0&&(o.minItems=f),g&&(o.maxItems=m));const{minimum:y,maximum:w}=e._zod.bag;typeof y=="number"&&(o.minItems=y),typeof w=="number"&&(o.maxItems=w)},UM=(e,t,n,r)=>{const o=e._zod.def,s=yr(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"}]},HM=(e,t,n,r)=>{const o=e._zod.def;yr(o.innerType,t,r);const s=t.seen.get(e);s.ref=o.innerType},vw=Symbol();function PS(e,t,n,r,o){let s=!1;const a=JSON.stringify(e,(c,u)=>typeof u!="bigint"?u:(s=!0,null));return s?(Ai(t,n,r,o,"BigInt defaults cannot be represented in JSON Schema"),vw):JSON.parse(a)}const WM=(e,t,n,r)=>{const o=e._zod.def;yr(o.innerType,t,r);const s=t.seen.get(e);s.ref=o.innerType;const a=PS(o.defaultValue,e,t,n,r);a!==vw&&(n.default=a)},KM=(e,t,n,r)=>{const o=e._zod.def;yr(o.innerType,t,r);const s=t.seen.get(e);if(s.ref=o.innerType,t.io!=="input")return;const a=PS(o.defaultValue,e,t,n,r);a!==vw&&(n._prefault=a)},qM=(e,t,n,r)=>{const o=e._zod.def;yr(o.innerType,t,r);const s=t.seen.get(e);s.ref=o.innerType;let a;try{a=o.catchValue(void 0)}catch{Ai(e,t,n,r,"Dynamic catch values are not supported in JSON Schema");return}n.default=a},ZM=(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;yr(a,t,r);const c=t.seen.get(e);c.ref=a},GM=(e,t,n,r)=>{const o=e._zod.def;yr(o.innerType,t,r);const s=t.seen.get(e);s.ref=o.innerType,n.readOnly=!0},DS=(e,t,n,r)=>{const o=e._zod.def;yr(o.innerType,t,r);const s=t.seen.get(e);s.ref=o.innerType},Ob=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 VM=(e,t)=>{hS.init(e,t),e.name="ZodError";const n=Object.getPrototypeOf(e);Ob.has(n)||(Ob.add(n),yf(n,"format",r=>o=>xR(r,o)),yf(n,"flatten",r=>o=>bR(r,o)),yf(n,"addIssue",r=>o=>{r.issues.push(o),r.message=JSON.stringify(r.issues,qg,2)}),yf(n,"addIssues",r=>o=>{r.issues.push(...o),r.message=JSON.stringify(r.issues,qg,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},Ho=Se("ZodError",VM,void 0,{Parent:Error}),YM=gw(Ho),XM=kw(Ho),QM=zh(Ho),JM=Fh(Ho),eL=_R(Ho),tL=NR(Ho),nL=TR(Ho),rL=jR(Ho),oL=$R(Ho),sL=CR(Ho),iL=AR(Ho),aL=IR(Ho);function lL(){rs.localeError||Li($2())}function Uh(){rs.memoizer||Li({memoizer:N2()})}const er=Se("ZodType",(e,t)=>(lL(),Vn.init(e,t),e.def=t,e.type=t.type,e),{check(...e){const t=this.def;return this.clone(Oi(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 Mi(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(iP(e,t))},superRefine(e,t){return this.check(aP(e,t))},overwrite(e){return this.check(ec(e))},optional(){return Pb(this)},exactOptional(){return GL(this)},nullable(){return Db(this)},nullish(){return Pb(Db(this))},nonoptional(e){return eP(this,e)},array(){return va(this)},or(e){return zL([this,e])},and(e){return HL(this,e)},transform(e){return zb(this,ZL(e))},default(e){return XL(this,e)},prefault(e){return JL(this,e)},catch(e){return nP(this,e)},pipe(e){return zb(this,e)},readonly(){return sP(this)},describe(e){const t=this.clone();return eu.add(t,{description:e}),t},meta(...e){if(e.length===0)return eu.get(this);const t=this.clone();return eu.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 uS(this,"~standard",{...yS(this),jsonSchema:{input:th(this,"input"),output:th(this,"output")}})},set"~standard"(e){Hl(this,"~standard",e)},parse:function e(t,n){return YM(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await XM(this,t,n,{callee:e})},safeParse(e,t){return QM(this,e,t)},async safeParseAsync(e,t){return JM(this,e,t)},get spa(){return this==null?void 0:this.safeParseAsync},set spa(e){Hl(this,"spa",e)},encode:function e(t,n){return eL(this,t,n,{callee:e})},decode:function e(t,n){return tL(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await nL(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await rL(this,t,n,{callee:e})},safeEncode(e,t){return oL(this,e,t)},safeDecode(e,t){return sL(this,e,t)},async safeEncodeAsync(e,t){return iL(this,e,t)},async safeDecodeAsync(e,t){return aL(this,e,t)},toJSONSchema(e){return NM(this,{})(e)},get description(){var e;return(e=eu.get(this))==null?void 0:e.description},get _def(){return this._zod.def}}),zS=Se("_ZodString",(e,t)=>{yw.init(e,t),er.init(e,t),e._zod.processJSONSchema=(r,o,s)=>jM(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(uM(...e))},includes(...e){return this.check(hM(...e))},startsWith(...e){return this.check(pM(...e))},endsWith(...e){return this.check(mM(...e))},min(...e){return this.check(eh(...e))},max(...e){return this.check(CS(...e))},length(...e){return this.check(AS(...e))},nonempty(...e){return this.check(eh(1,...e))},lowercase(e){return this.check(dM(e))},uppercase(e){return this.check(fM(e))},trim(){return this.check(kM())},normalize(...e){return this.check(gM(...e))},toLowerCase(){return this.check(wM())},toUpperCase(){return this.check(yM())},slugify(){return this.check(vM())}}),cL=Se("ZodString",(e,t)=>{yw.init(e,t),zS.init(e,t)},{email(e){return this.check(R2(pL,e))},url(e){return this.check(z2(gL,e))},jwt(e){return this.check(eM(AL,e))},emoji(e){return this.check(F2(kL,e))},guid(e){return this.check(O2(mL,e))},uuid(e){return this.check(M2(vf,e))},uuidv4(e){return this.check(L2(vf,e))},uuidv6(e){return this.check(P2(vf,e))},uuidv7(e){return this.check(D2(vf,e))},nanoid(e){return this.check(B2(wL,e))},cuid(e){return this.check(U2(yL,e))},cuid2(e){return this.check(H2(vL,e))},ulid(e){return this.check(W2(bL,e))},base64(e){return this.check(X2(jL,e))},base64url(e){return this.check(Q2($L,e))},xid(e){return this.check(K2(xL,e))},ksuid(e){return this.check(q2(EL,e))},ipv4(e){return this.check(Z2(SL,e))},ipv6(e){return this.check(G2(_L,e))},cidrv4(e){return this.check(V2(NL,e))},cidrv6(e){return this.check(Y2(TL,e))},e164(e){return this.check(J2(CL,e))},datetime(e){return this.check(tM(uL,e))},date(e){return this.check(nM(dL,e))},time(e){return this.check(rM(fL,e))},duration(e){return this.check(oM(hL,e))}});function In(e){return I2(cL,e)}const tr=Se("ZodStringFormat",(e,t)=>{Yn.init(e,t),zS.init(e,t)}),uL=Se("ZodISODateTime",(e,t)=>{DO.init(e,t),tr.init(e,t)}),dL=Se("ZodISODate",(e,t)=>{zO.init(e,t),tr.init(e,t)}),fL=Se("ZodISOTime",(e,t)=>{FO.init(e,t),tr.init(e,t)}),hL=Se("ZodISODuration",(e,t)=>{BO.init(e,t),tr.init(e,t)}),pL=Se("ZodEmail",(e,t)=>{SO.init(e,t),tr.init(e,t)}),mL=Se("ZodGUID",(e,t)=>{xO.init(e,t),tr.init(e,t)}),vf=Se("ZodUUID",(e,t)=>{EO.init(e,t),tr.init(e,t)}),gL=Se("ZodURL",(e,t)=>{CO.init(e,t),tr.init(e,t)}),kL=Se("ZodEmoji",(e,t)=>{AO.init(e,t),tr.init(e,t)}),wL=Se("ZodNanoID",(e,t)=>{IO.init(e,t),tr.init(e,t)}),yL=Se("ZodCUID",(e,t)=>{RO.init(e,t),tr.init(e,t)}),vL=Se("ZodCUID2",(e,t)=>{OO.init(e,t),tr.init(e,t)}),bL=Se("ZodULID",(e,t)=>{MO.init(e,t),tr.init(e,t)}),xL=Se("ZodXID",(e,t)=>{LO.init(e,t),tr.init(e,t)}),EL=Se("ZodKSUID",(e,t)=>{PO.init(e,t),tr.init(e,t)}),SL=Se("ZodIPv4",(e,t)=>{UO.init(e,t),tr.init(e,t)}),_L=Se("ZodIPv6",(e,t)=>{WO.init(e,t),tr.init(e,t)}),NL=Se("ZodCIDRv4",(e,t)=>{KO.init(e,t),tr.init(e,t)}),TL=Se("ZodCIDRv6",(e,t)=>{ZO.init(e,t),tr.init(e,t)}),jL=Se("ZodBase64",(e,t)=>{GO.init(e,t),tr.init(e,t)}),$L=Se("ZodBase64URL",(e,t)=>{YO.init(e,t),tr.init(e,t)}),CL=Se("ZodE164",(e,t)=>{XO.init(e,t),tr.init(e,t)}),AL=Se("ZodJWT",(e,t)=>{JO.init(e,t),tr.init(e,t)}),FS=Se("ZodNumber",(e,t)=>{SS.init(e,t),er.init(e,t),e._zod.processJSONSchema=(r,o,s)=>$M(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($b(e,t))},gte(e,t){return this.check(sg(e,t))},min(e,t){return this.check(sg(e,t))},lt(e,t){return this.check(jb(e,t))},lte(e,t){return this.check(og(e,t))},max(e,t){return this.check(og(e,t))},int(e){return this.check(Mb(e))},safe(e){return this.check(Mb(e))},positive(e){return this.check($b(0,e))},nonnegative(e){return this.check(sg(0,e))},negative(e){return this.check(jb(0,e))},nonpositive(e){return this.check(og(0,e))},multipleOf(e,t){return this.check(Cb(e,t))},step(e,t){return this.check(Cb(e,t))},finite(){return this}});function Os(e){return sM(FS,e)}const IL=Se("ZodNumberFormat",(e,t)=>{e2.init(e,t),FS.init(e,t)});function Mb(e){return iM(IL,e)}const RL=Se("ZodBoolean",(e,t)=>{t2.init(e,t),er.init(e,t),e._zod.processJSONSchema=(n,r,o)=>CM(e,n,r)});function Po(e){return aM(RL,e)}const OL=Se("ZodUnknown",(e,t)=>{n2.init(e,t),er.init(e,t),e._zod.processJSONSchema=(n,r,o)=>IM()});function Lb(){return lM(OL)}const ML=Se("ZodNever",(e,t)=>{r2.init(e,t),er.init(e,t),e._zod.processJSONSchema=(n,r,o)=>AM(e,n,r)});function LL(e){return cM(ML,e)}const PL=Se("ZodArray",(e,t)=>{Uh(),o2.init(e,t),er.init(e,t),e._zod.processJSONSchema=(n,r,o)=>PM(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(CS(e,t))},length(e,t){return this.check(AS(e,t))},unwrap(){return this.element}});function va(e,t){return bM(PL,e,t)}const DL=Se("ZodObject",(e,t)=>{Uh(),a2.init(e,t),er.init(e,t),e._zod.processJSONSchema=(n,r,o)=>DM(e,n,r,o),hR(e,"shape",n=>n._zod.def.shape,!1)},{keyof(){return $l(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:Lb()})},loose(){return this.clone({...this._zod.def,catchall:Lb()})},strict(){return this.clone({...this._zod.def,catchall:LL()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return nR(this,e)},safeExtend(e){return rR(this,e)},merge(e){return oR(this,e)},pick(e){return eR(this,e)},omit(e){return tR(this,e)},partial(...e){return ib(bw,this,e[0])},exactPartial(...e){return ib(HS,this,e[0],"exactPartial")},required(...e){return sR(WS,this,e[0])}});function Nr(e,t){const n={type:"object",shape:e??{},...ft(t)};return new DL(n)}const BS=Se("ZodUnion",(e,t)=>{TS.init(e,t),er.init(e,t),e._zod.processJSONSchema=(n,r,o)=>zM(e,n,r,o),e.options=t.options});function zL(e,t){return new BS({type:"union",options:e,...ft(t)})}const FL=Se("ZodDiscriminatedUnion",(e,t)=>{BS.init(e,t),l2.init(e,t)});function BL(e,t,n){return new FL({type:"union",options:t,discriminator:e,...ft(n)})}const UL=Se("ZodIntersection",(e,t)=>{c2.init(e,t),er.init(e,t),e._zod.processJSONSchema=(n,r,o)=>FM(e,n,r,o)});function HL(e,t){return new UL({type:"intersection",left:e,right:t})}const WL=Se("ZodTuple",(e,t)=>{Uh(),u2.init(e,t),er.init(e,t),e._zod.processJSONSchema=(n,r,o)=>BM(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 bw({type:"optional",innerType:n}))})}});function US(e,t,n){const r=t instanceof Vn,o=r?n:t,s=r?t:null;return new WL({type:"tuple",items:e,rest:s,...ft(o)})}const Qg=Se("ZodEnum",(e,t)=>{d2.init(e,t),er.init(e,t),e._zod.processJSONSchema=(r,o,s)=>RM(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 Qg({...t,checks:[],...ft(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 Qg({...t,checks:[],...ft(o),entries:s})}});function $l(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(r=>[r,r])):e;return new Qg({type:"enum",entries:n,...ft(t)})}const KL=Se("ZodLiteral",(e,t)=>{f2.init(e,t),er.init(e,t),e._zod.processJSONSchema=(n,r,o)=>OM(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 Qr(e,t){return new KL({type:"literal",values:Array.isArray(e)?e:[e],...ft(t)})}const qL=Se("ZodTransform",(e,t)=>{Uh(),h2.init(e,t),er.init(e,t),e._zod.processJSONSchema=(n,r,o)=>LM(e,n,r,o),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new dS(e.constructor.name);n.addIssue=s=>{if(typeof s=="string")n.issues.push(yu(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(yu(a))}};const o=t.transform(n.value,n);return o instanceof Promise?o.then(s=>(n.value=s,n)):(n.value=o,n)}});function ZL(e){return new qL({type:"transform",transform:e})}const bw=Se("ZodOptional",(e,t)=>{jS.init(e,t),er.init(e,t),e._zod.processJSONSchema=(n,r,o)=>DS(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function Pb(e){return new bw({type:"optional",innerType:e})}const HS=Se("ZodExactOptional",(e,t)=>{p2.init(e,t),er.init(e,t),e._zod.processJSONSchema=(n,r,o)=>DS(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function GL(e){return new HS({type:"optional",innerType:e})}const VL=Se("ZodNullable",(e,t)=>{m2.init(e,t),er.init(e,t),e._zod.processJSONSchema=(n,r,o)=>UM(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function Db(e){return new VL({type:"nullable",innerType:e})}const YL=Se("ZodDefault",(e,t)=>{g2.init(e,t),er.init(e,t),e._zod.processJSONSchema=(n,r,o)=>WM(e,n,r,o),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function XL(e,t){return new YL({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():lS(t)}})}const QL=Se("ZodPrefault",(e,t)=>{k2.init(e,t),er.init(e,t),e._zod.processJSONSchema=(n,r,o)=>KM(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function JL(e,t){return new QL({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():lS(t)}})}const WS=Se("ZodNonOptional",(e,t)=>{w2.init(e,t),er.init(e,t),e._zod.processJSONSchema=(n,r,o)=>HM(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function eP(e,t){return new WS({type:"nonoptional",innerType:e,...ft(t)})}const tP=Se("ZodCatch",(e,t)=>{y2.init(e,t),er.init(e,t),e._zod.processJSONSchema=(n,r,o)=>qM(e,n,r,o),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function nP(e,t){return new tP({type:"catch",innerType:e,catchValue:typeof t=="function"?t:mR(t)})}const rP=Se("ZodPipe",(e,t)=>{v2.init(e,t),er.init(e,t),e._zod.processJSONSchema=(n,r,o)=>ZM(e,n,r,o),e.in=t.in,e.out=t.out});function zb(e,t){return new rP({type:"pipe",in:e,out:t})}const oP=Se("ZodReadonly",(e,t)=>{b2.init(e,t),er.init(e,t),e._zod.processJSONSchema=(n,r,o)=>GM(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function sP(e){return new oP({type:"readonly",innerType:e})}const KS=Se("ZodCustom",(e,t)=>{x2.init(e,t),er.init(e,t),e._zod.processJSONSchema=(n,r,o)=>MM(e,n,r,o)});function iP(e,t={}){return xM(KS,e,t)}function aP(e,t){return EM(e,t)}function lP(e,t={}){const n=new KS({type:"custom",check:"custom",fn:r=>r instanceof e,abort:!0,...ft(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 cP=["off","tailscale","any"],uP={updates:!0,deploy:!0,remote:"any",agents:null,customAgents:!0,brandedListener:!0,planSignIn:!0};Nr({updates:Po().optional(),deploy:Po().optional(),remote:$l(cP).optional(),agents:va(In()).optional(),customAgents:Po().optional(),brandedListener:Po().optional(),planSignIn:Po().optional()});const dP={...uP,source:null,problem:null};function fP(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 ig=6e3,Fb=1500;function hP(e){if(e.length<=ig)return e;const t=e.length-ig;return`${e.slice(0,Fb)}
94
- [${t} characters cut here]
95
- ${e.slice(e.length-(ig-Fb))}`}const ga=143,pP=2e3,rh=5e6,mP=["image/png","image/jpeg","image/gif","image/webp"],Bb=2576,ag=5*1024*1024,gP=1200,kP=10,wP=1e5,Ub=100*1024*1024,yP="pasted-text.txt";function vP(e){return e.t==="term-data"||e.t==="term-snapshot"||e.t==="term-exit"}function bP(e){return e.t==="file-read"||e.t==="file-written"||e.t==="file-blame"}const xP=80;function xw(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,xP)}}function qS(e){return e.length>=gP||e.split(`
97
- `).length>=kP}function EP({startLine:e,endLine:t}){return e===t?`${e}`:`${e}-${t}`}function SP(e){return`${e.path.slice(e.path.lastIndexOf("/")+1)} (${EP(e)})`}const _P=/\u001B(?:\[[0-?]*[ -/]*[@-~]|\][^\u0007]*(?:\u0007|\u001B\\))/g;function NP(e){return e.replace(_P,"")}function ZS(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 TP(e){const t=e.plan.trim();return ZS(t).title===null?`# ${e.title}
98
-
99
- ${t}
100
- `:`${t}
101
- `}const GS="Projects";function jP(e){for(const t of e){const n=t.codePointAt(0)??0;if(n<32||n===127)return!0}return!1}function vu(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":jP(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 $P=/^(?:https?|ssh|git|file):\/\/\S+$/i,VS=/^[\w.-]+@[\w.-]+:\S+$/,CP=/^[\w-]+(?:\.[\w-]+)+\/\S+$/;function Hb(e){const t=e.trim(),n=CP.test(t)?`https://${t}`:t;if(!$P.test(n)&&!VS.test(n))return null;const r=AP(n),o=RP((r==null?void 0:r.url)??n);return!o||vu(o)?null:r?{url:r.url,name:o,...r.branch?{branch:r.branch}:{}}:{url:n,name:o}}const lg={"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 AP(e){var o;if(!/^https?:\/\//i.test(e))return null;let t;try{t=new URL(e)}catch{return null}const n=(o=lg[t.hostname.toLowerCase()])==null?void 0:o.call(lg,t.pathname.split("/").filter(Boolean));if(!n)return null;const r=n.branch?IP(n.branch).replace(/\/+$/,""):"";return{url:`${t.protocol}//${t.host}/${n.repo.join("/")}`,...r?{branch:r}:{}}}function IP(e){try{return decodeURIComponent(e)}catch{return e}}function RP(e){var o;const t=((o=e.split(/[?#]/)[0])==null?void 0:o.replace(/\/+$/,""))??"";return((VS.test(t)?t.split(":")[1]??"":t).split("/").pop()??"").replace(/\.git$/i,"")}const OP=Nr({component:In().nullable(),file:In().nullable(),line:Os().nullable(),callFile:In().nullable().default(null),callLine:Os().nullable().default(null),tag:In(),selector:In()}),MP=Nr({tag:In().max(40),id:In().max(200),classes:va(In().max(120)).max(16),text:In().max(200),attrs:va(US([In().max(40),In().max(200)])).max(12)}),LP=US([Os(),Os()]),PP=OP.extend({classes:In(),text:In(),html:In(),route:In(),element:MP}),DP=BL("type",[Nr({type:Qr("loaded"),url:In(),title:In()}),Nr({type:Qr("navigated"),url:In(),title:In().optional()}),Nr({type:Qr("traversed"),dir:$l(["back","forward"]).optional()}),Nr({type:Qr("title"),title:In()}),Nr({type:Qr("links"),links:va(Nr({path:In().max(2048),text:In().max(120)})).max(200)}),Nr({type:Qr("hmr")}),Nr({type:Qr("touch"),phase:$l(["start","move","end","cancel"]),x:Os(),y:Os()}),Nr({type:Qr("page-error"),message:In(),source:In().optional(),line:Os().optional()}),PP.extend({type:Qr("picked"),verb:$l(["chat","code"]).default("chat"),site:$l(["call","source"]).default("source")}),Nr({type:Qr("pick-cancel")}),Nr({type:Qr("highlight-miss"),path:In(),fileMatched:Os(),withSource:Os(),ranges:va(LP).nullable()}),Nr({type:Qr("drag-files"),over:Po().default(!0)}),Nr({type:Qr("drop-files"),files:va(lP(File))}),Nr({type:Qr("focus"),gesture:Po()}),Nr({type:Qr("key"),key:In(),code:In().optional(),meta:Po(),ctrl:Po().optional(),shift:Po().optional(),alt:Po().optional(),up:Po().optional()})]);function YS(e){const t=DP.safeParse(e);return t.success?t.data:null}const zP=["rows","repos","visits","themes"];function FP(e){return zP.map(t=>e[t]??"").join(".")}const BP=/["“”]([^"“”]*)["“”]?|(\S+)/g;function XS(e){const t=new Set;for(const n of e.matchAll(BP)){const r=(n[1]??n[2]??"").replace(/\s+/g," ").trim().toLowerCase();r&&t.add(r)}return[...t]}const UP="now",HP="http://preview.invalid",WP=200;function Wb(e){const t=e==null?void 0:e.replace(/\s+/g," ").trim().slice(0,WP).trim();return t||void 0}function Hh(e){let t;try{t=new URL(e,HP)}catch{return null}if(t.pathname.startsWith("/__toyon"))return null;const n=Kb(t.pathname)||"/",r=t.hash.startsWith("#/")?Kb(t.hash.split("?")[0]??""):"";return r.length>1?`${n}${r}`:n}const Kb=e=>e.replace(/\/+$/,""),KP={static:4,mixed:3.5,param:3,optional:2,"optional-static":2,splat:1},oh=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");function QS(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 h of e.matchAll(/\[([^\]=]+)(?:=[^\]]*)?\]|\{\$([\w-]+)\}/g)){const f=e.slice(c,h.index);f&&(s.push({text:f}),a+=oh(f)),s.push({name:h[1]??h[2]??"param"}),a+="[^/]+?",c=(h.index??0)+h[0].length}const u=e.slice(c);if(u&&(s.push({text:u}),a+=oh(u)),s.some(h=>"name"in h))return{kind:"mixed",pattern:a,parts:s}}return{kind:"static",text:e}}function qP(e){const t=e.split("/").filter(Boolean).map(QS);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+KP[o.kind],0),statics:t.filter(r=>r.kind==="static").length}}function ZP(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 Wh(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(QS))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"},JS={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"},GP={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"}},VP={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"}},YP={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"}},XP={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"}},QP={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"}},JP={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"}},eD={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"}},tD={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"}},nD={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"}},rD={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"}},oD={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"}},sD={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"}},iD={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"}},aD={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"}},lD={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"}},cD={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"}},uD={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"}},dD=[eD,tD,nD,rD,oD,sD,iD,aD,lD,cD,uD],Ff=[Uu,JS,GP,VP,YP,XP,QP,JP,...dD],fD={mode:"dark",light:JS.id,dark:Uu.id},hD=["surface0","surface1","surface2","element0","element1","border0","border1","text0","text1","text2","red","orange","yellow","green","aqua","blue","purple","diffAdd","diffDel"];function pD(e){return`--${e.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`)}`}function Jg(e){return e_(ba(e))}function e_(e){return e>.008856?116*e**(1/3)-16:903.3*e}function Ew(e,t){const n=Jg(e)+t,r=ja(e);if(!r)return e;let o=0,s=2;for(let a=0;a<24;a++){const c=(o+s)/2,u=Wl(Math.min(255,r[0]*c),Math.min(255,r[1]*c),Math.min(255,r[2]*c));Jg(u)<n?o=c:s=c}return Wl(Math.min(255,r[0]*o),Math.min(255,r[1]*o),Math.min(255,r[2]*o))}function mD(e){return Ew(e.colors.surface1,-4)}function gD(e){return Ew(e.colors.surface0,-4)}const qb=["surface0","surface1","surface2","element0","element1","border0","border1"];function kD(e){if(e.kind!=="dark")return e;const t=qb.reduce((o,s)=>ba(e.colors[s])<ba(e.colors[o])?s:o),n=e.colors[t];if(ba(n)<=0)return e;const r={...e.colors};for(const o of[...qb,"text1","text2"]){const s=jD(e.colors[o],n)*.05-.05;r[o]=Ew(r[o],e_(s)-Jg(r[o]))}return r.surface0="#000000",r.surface1="#000000",{...e,colors:r}}function Zb(e){return TD(e,.55)}function wD(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 yD(e){const t={};for(const n of hD)t[pD(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(wD(e)))t[`--syntax-${n}`]=r;return t["--accent"]=Sw(e),t["--fault"]=vD(e),t["--link"]=bD(e),t["--sunken"]=mD(e),t["--sunken-floor"]=gD(e),t["--scrim"]=ND(e.colors.surface0,.7),t["--shadow"]=e.kind==="dark"?"#00000066":"#0000002e",t["--diff-add-word"]=Zb(e.colors.diffAdd),t["--diff-del-word"]=Zb(e.colors.diffDel),t}function Sw(e){return Nw(e.accent??"")??e.colors.orange}function vD(e){return Sw(e)===Nw(e.colors.orange)?e.colors.red:e.colors.orange}function bD(e){return Nw(e.link??"")??e.colors.blue}function xD(e){return e==="system"||e==="daylight"}function _w(e,t){return e.mode==="system"?t.system?"dark":"light":e.mode==="daylight"?t.daylight?"dark":"light":e.mode}function Kh(e,t,n){const r=_w(e,n);return t.find(o=>o.id===e[r])??Ff.find(o=>o.kind===r)??Uu}function ED(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 SD(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=ED(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 _D(e,t){const n={...e};return t.dark&&(n.dark=t.dark.id),t.light&&(n.light=t.light.id),!xD(n.mode)&&!t[n.mode]&&(n.mode=t.dark?"dark":"light"),n}function ja(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 Nw(e){const t=ja(e);return t?Wl(t[0],t[1],t[2],t[3]):null}function Wl(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 ND(e,t){const n=ja(e);return n?Wl(n[0],n[1],n[2],t):e}function TD(e,t){const n=ja(e);return n?Wl(n[0],n[1],n[2],Math.min(1,n[3]*t)):e}function hY(e,t){const n=ja(e),r=ja(t);if(!n||!r)return e;const o=n[3];return Wl(n[0]*o+r[0]*(1-o),n[1]*o+r[1]*(1-o),n[2]*o+r[2]*(1-o))}function ba(e){const t=ja(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 jD(e,t){const n=ba(e),r=ba(t);return(Math.max(n,r)+.05)/(Math.min(n,r)+.05)}function $D(e){return ba(e)>.179?"#1d2021":"#fbf1c7"}function ek(e){if(e===null||e==="")return"the npm registry";try{return new URL(e).host}catch{return e}}function t_(e,t){const n=Gb(e),r=Gb(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 Gb(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 CD=[[/\.(png|jpe?g|gif|webp|avif|bmp|ico)$/i,"image"],[/\.(mp4|m4v|webm|mov)$/i,"video"]];function AD(e){var t;return((t=CD.find(([n])=>n.test(e)))==null?void 0:t[1])??null}const ID=[[/\.(md|markdown)$/i,"markdown"],[/\.html?$/i,"html"],[/\.svg$/i,"svg"]];function qh(e){var t;return((t=ID.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"},RD=[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}`,OD="toyon",qc="snapshots",uo={hello:e=>`hello@${e}`,chat:(e,t)=>`chat@${e}/${t}`,chats:e=>`chat@${e}/`};function MD(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 tk(a).filter(u=>u.endsWith(`@${e}`)))try{a==null||a.removeItem(c)}catch{}}}}function tk(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 LD="orch-";function PD(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=LD+a.slice(6);Vb(r,c,a)}for(const[r,o]of[[t,RD.filter(s=>s!==tt.phoneRow)],[n,[tt.phoneRow]]]){const s=tk(r).filter(a=>!a.includes("@"));for(const a of o)for(const c of s.filter(u=>u===a))Vb(r,c,Bf(c,e))}for(const r of tk(t))DD.some(o=>r.startsWith(o))&&zD(t,r)}const DD=["toyon-profile-","toyon-mode-","toyon-model-","toyon-effort-"];function zD(e,t){try{e==null||e.removeItem(t)}catch{}}function Vb(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 n_(){const e=location.hash.match(/token=([a-f0-9]+)/);if(e!=null&&e[1])return r_(e[1]),e[1];try{return localStorage.getItem(tt.token)??sessionStorage.getItem(tt.token)??""}catch{return""}}function r_(e){try{localStorage.setItem(tt.token,e)}catch{}}function sh(){return n_()!==""}function Tw(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?`&${UP}`:""}`,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 Ra=e=>({authorization:`Bearer ${e.token}`});async function FD(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",Ra(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 BD(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 o_(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 UD(e){var t;try{const n=await fetch(e.changelog,{headers:Ra(e)});return!n.ok||!((t=n.headers.get("content-type"))!=null&&t.startsWith("text/markdown"))?null:await n.text()}catch{return null}}async function HD(e,t){try{const n=await fetch(t,{headers:Ra(e)});return n.ok?await n.json():null}catch{return null}}async function Zh(e,t,n,r){try{const o=await fetch(t,{method:"POST",headers:{...Ra(e),"content-type":"application/json"},body:JSON.stringify(n)});return o.ok?null:await o.text()||`refused (${o.status})`}catch{return r}}const WD=e=>HD(e,e.tailnet),KD=e=>Zh(e,e.remote,{tailscale:!0},"Toyon is not answering; try again once it is back."),qD=e=>Zh(e,e.remote,{off:!0},"Toyon is not answering; try again once it is back.");async function s_(e,t,n){try{const r=await fetch(t,{method:"POST",headers:{...Ra(e),"content-type":"application/json"},body:JSON.stringify(n)});return r.ok?await r.json():null}catch{return null}}const i_="Toyon is not answering; try again once it is back.",ZD=async e=>{const t=await s_(e,e.tailscale,{up:!0});return t===null?i_:t.refused},GD=async e=>await s_(e,e.tailscale,{login:!0})??{why:i_},VD=(e,t,n)=>Zh(e,e.machines,{origin:t,token:n},"Toyon here is not answering; the machine is not listed yet."),YD=(e,t,n)=>Zh(e,e.knockAnswer(t),{letIn:n},"Toyon is not answering");async function a_(e){try{const t=await fetch(e.previewGrant,{method:"POST",headers:Ra(e)});return t.ok?await t.json():null}catch{return null}}async function XD(e,t){try{const n=await fetch(e.frame,{method:"POST",headers:{...Ra(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 QD=2e3;async function l_(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,QD))}return"gone"}async function nk(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 JD=1e3,e4=3e4,t4=1500,n4=5e3,Yb=50,r4=e=>e.t==="chat"||e.t==="create-worktree"||e.t==="restore-worktree";class o4{constructor(t,n,r,o={},s={}){Tt(this,"ws",null);Tt(this,"queue",[]);Tt(this,"closed",!1);Tt(this,"attempt",0);Tt(this,"timer",null);Tt(this,"downAt",null);Tt(this,"downCode",0);Tt(this,"sayTimer",null);Tt(this,"sentDown",new Set);Tt(this,"drops",0);Tt(this,"urls");Tt(this,"suspended",!1);Tt(this,"connectDeadline");Tt(this,"settle");Tt(this,"backoffMin");Tt(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??n4,this.settle=o.settle??t4,this.backoffMin=o.backoffMin??JD,this.urls=Tw(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===RI)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(e4,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)),r4(t)&&t.boxId&&this.sentDown.add(t.boxId),this.queue.push({key:r,raw:n}),this.queue.length>Yb&&this.queue.splice(0,this.queue.length-Yb)}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 jw(e){return e==="cancelled"||e==="expired"}function c_(e){const t=e.findLast(n=>n.kind==="ask"||Hu(n));return(t==null?void 0:t.kind)!=="ask"||t.ask.kind!=="question"?null:jw(t.outcome)?t:null}function s4(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 i4(e){return e.map(()=>({selected:[]}))}function Xb(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 Qb(e,t,n,r){return e.map((o,s)=>s!==t?o:{selected:n&&!r?[]:o.selected,note:o.note??""})}function tu(e,t){const n=e[t];return n&&n.note!==void 0&&!n.note.trim()?ih(e,t,void 0):e}function a4(e){return e?e.options.length+(e.note?1:0):0}function Jb(e,t){return!!(e!=null&&e.note)&&t===e.options.length}function u_(e,t){return!!e&&e.note!==void 0&&(t||e.selected.length===0)}function xa(e){var t;return!!e&&(e.selected.length>0||!!((t=e.note)!=null&&t.trim()))}function l4(e,t){return!!(e!=null&&e.multi)&&xa(t)}function cg(e,t){return e.every((n,r)=>!n.required||xa(t[r]))}function c4(e,t){var o;const n=((t==null?void 0:t.selected)??[]).map(s=>{var a;return Cw(((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 u4(e,t){var o;const n=((t==null?void 0:t.selected)??[]).map(s=>{var a;return Cw(((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 $w(e,t){return e.map((n,r)=>{const o=c4(n,t==null?void 0:t[r]);return e.length>1&&n.header?`${n.header} · ${o}`:o})}function d4(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 f4(e){return e.outcome!=="answered"||e.ask.kind!=="question"?null:{message:e.ask.message,questions:e.ask.questions,answers:e.answers}}function h4(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 p4(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 Cl(e,t){if(!e)return 0;if(u_(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 m4(e,t,n){return Math.max(0,Math.min(n-1,e+t))}function g4(e,t,n){const r=e.length;for(let o=1;o<=r;o++){const s=(n+o)%r;if(!xa(t[s]))return s}return-1}function Al(e){return e.length>1?e.length:-1}function k4(e){return e.length+(Al(e)===-1?0:1)}function w4(e,t,n){const r=g4(e,t,n);if(r!==-1)return{current:r,cursor:Cl(e[r],t[r]),send:!1};const o=Al(e);return o!==-1?{current:o,cursor:0,send:!1}:{current:n,cursor:Cl(e[n],t[n]),send:!0}}const d_=/\s*\(recommended\)\s*$/i;function y4(e){return d_.test(e)}function Cw(e){return e.replace(d_,"")}const v4={skipped:"you skipped this",cancelled:"the turn was stopped before you answered",expired:"Toyon restarted before you answered"};function b4(e,t){const n=t??0;return n===0?null:`${n} behind ${e}`}function Gh(e){const t=new Date(e);return`${String(t.getHours()).padStart(2,"0")}:${String(t.getMinutes()).padStart(2,"0")}`}function f_(e,t){if(t.fetchFailed)return`could not reach origin${t.fetchedAt?` since ${Gh(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 x4(e){return e.stale!=="diverged"}function h_(e,t,n,r){return n!==null&&r===n.host?`${II(n.previews,e,t)}/`:r.endsWith(".localhost")?`http://w${e}.${r}:${t}/`:Rh(r)?`http://${r==="localhost"?"127.0.0.1":r}:${t}/`:`https://${r}:${t}/`}function ex(e){return e.ranges.map(([t,n])=>[t+e.offset,n+e.offset])}function p_(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 E4(e){var r;const t=(r=e.source)==null?void 0:r.replace(/[?#].*$/,""),n=t?` (${p_(t)}:${e.line??"?"})`:"";return`${e.message}${n}`.slice(0,pP)}function bf(e,t){return!Number.isFinite(e)||e<=0?t:Math.min(Math.max(e,170),Math.floor(window.innerWidth*.5))}const S4=new Set(["running","starting","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=>S4.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==="asleep")?"asleep":"idle"}const _4={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",asleep:"Asleep",idle:"Idle"};function Aw(e,t=!1){const n=Fs(e);return n==="idle"&&t?"Not set up":n==="background"&&e.wakes?`Wakes ${Gh(e.wakes)}`:_4[n]}const N4={starting:"Starting",running:"Running",unreachable:"Not answering",crashed:"Crashed",stopped:"Stopped",asleep:"Asleep"};function T4(e){return N4[e]}const j4=new Set(["idle","asleep","running","starting","background","landed"]);function Vh(e,t){return t&&j4.has(Fs(e))?t:null}const $4={land:"Landing",commit:"Committing","sync-main":"Syncing with main","pull-main":"Pulling"};function Iw(e){return $4[e]}function m_(e,t){return Vh(e,t??void 0)?"background":Fs(e)}function g_(e,t,n=!1){const r=Vh(e,t??void 0);return r?Iw(r):Aw(e,n)}function k_(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 w_(e){const t=e.lastIndexOf("/");return t<0?{name:e,dir:""}:{name:e.slice(t+1),dir:e.slice(0,t)}}const y_=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 v_(e){const t=new Set;for(const n of e)for(const r of ah(n))t.add(r);return[...t].sort(y_)}function Rw(e){return e.includes("A")||e==="??"?"added":e.includes("D")?"deleted":""}function Ow(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 C4=/Firefox\//.test(navigator.userAgent);function Mw(){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 A4=/Chrome\//.test(navigator.userAgent)&&Mw(),Dt=e=>wI(e,{firefox:C4,pwa:A4});function Lw(e){return e.component?`<${e.component} />`:`<${e.tag}>`}function rk(e,t){return e.worktree&&jr(e.worktree)&&t?t.defaultBranch:e.name}function Pw(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 fr(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 ka(e){const t=Math.max(0,Math.floor(e));return t<100?`${t}s`:`${Math.floor(t/60)}m ${t%60}s`}function I4(e,t,n,r){var a;if(!t)return null;const o=e.filter(jn).filter(c=>c.repoId===t&&(c.worktree.agent??r)===n);return((a=o.find(c=>jr(c.worktree))??o[0])==null?void 0:a.id)??null}const R4=200;function O4(e,t){const n=new Map(e.map(r=>[r.path,r]));for(const r of t){if(n.size>=R4)break;const o=Hh(r.path);o&&!n.has(o)&&n.set(o,{path:o,text:r.text})}return n.size===e.length?e:[...n.values()]}function b_(e){return e!==void 0&&!e.routes.some(t=>!t.endpoint)}const Ii=e=>"uploading"in e&&e.uploading===!0;function Dl(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 Dw=e=>e.filter(t=>!Ii(t)).map(Dl);let M4=0;function ok(e,t){const n=new Map(t.filter(o=>!Ii(o)).map(o=>[JSON.stringify(Dl(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${++M4}`;return o.kind==="paste"?{...o,key:c,...xw(o.text)}:{...o,key:c}}),...t.filter(Ii)]}const sk="out:",L4=(e,t,n)=>`${sk}${e}:${t}:${n}`;function ps(e){if(!e.startsWith(sk))return null;const t=e.slice(sk.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 nu(e,t,n,r){const o=r.length?Dw(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 P4(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(Ii)){n.add(o.log);continue}r.push(o.id)}return r}const x_=e=>e.flatMap(t=>"upload"in t&&t.upload?[t.upload]:[]);function D4(e){const t=n=>x_(n.items).some(r=>!n.before.includes(r));return[...e.filter(t),...e.filter(n=>!t(n))]}function z4(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 vl=300,F4=20;function B4(e,t){return e.rows.length===0&&e.repos.length===0?null:{protocol:ga,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 tx=e=>(e==null?void 0:e.protocol)===ga,U4={rows:"",repos:"",visits:"",themes:""};function H4(e){const{at:t,...n}=e;return{t:"hello",...n,rows:e.rows.map(W4),trunks:Object.fromEntries(Object.entries(e.trunks).map(([r,o])=>[r,K4(o)])),stamps:U4,themes:[],drafts:{},attachments:{},knocks:[],letIn:!1,self:null,update:null,globalInstall:null,pending:[]}}function W4(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 K4(e){const{shipping:t,...n}=e;return n}function q4(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 Z4(e,t,n=F4){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 G4{constructor(){Tt(this,"events",[]);Tt(this,"seq",-1);Tt(this,"whole",!1)}reset(t,n,r){this.events=xf(mf(t),vl),this.seq=n,this.whole=r}extend(t,n){this.events.push(...t),n>this.seq&&(this.seq=n),this.events.length>vl*2&&(this.events=xf(mf(this.events),vl))}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>vl*2&&(this.events=xf(mf(this.events),vl))}snapshot(t,n){return this.events=xf(mf(this.events),vl),{protocol:ga,at:n,events:[...this.events],seq:this.seq,...t?{draft:t}:{}}}}const V4={ids:[],at:-1};function nx(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 Y4(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 E_(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 S_(e){return e.map(t=>Hu(t)?t.attachments:void 0)}const Uf=["files","changes","history"],X4=e=>Uf.includes(e),Oa=e=>(e==null?void 0:e.worktree.id)??null,Kl="new-project",Ma=Object.freeze({chat:[],log:[],queue:[],page:{},turn:{edits:!1,hmr:!1},changedRanges:{},commitFiles:{},search:null,design:null,draft:"",attachments:[],commands:[],termStream:Do}),Yh=e=>({...e,phase:"editing",repoId:null}),__=()=>Yh({mode:"create",name:"",parent:`~/${GS}`}),Q4=Object.freeze({changes:!1,changesTab:"files",chat:!0,term:!1,design:!1});function J4(e){if(!e||typeof e!="object")return!1;const t=e;return typeof t.changes=="boolean"&&X4(t.changesTab)&&typeof t.chat=="boolean"&&typeof t.term=="boolean"&&typeof t.design=="boolean"}function lo(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 zw(e,t){return{...e,layout:t,changesAuto:!1}}const Ri=e=>qh(e)?"preview":"file",ez=(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),Zc=(e,t)=>e.worktreeId===t.worktreeId&&e.path===t.path&&e.ref===t.ref&&e.since===t.since;function N_(e,t,n,r){var s;if(!r.fiber)return r;const o=(s=Zr(e,t).changedRanges[n])==null?void 0:s.offset;return o===void 0?r:{n:r.n-o}}function tz(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:V4,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:Q4,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:{...fD,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:dP,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?zw(n,r):n}function T_(e){var t;return{system:e.systemDark,daylight:((t=e.daylight)==null?void 0:t.dark)??e.systemDark}}function nz(e){return e.previewTheme??Kh(e.themePrefs,e.themes,T_(e))}function Zr(e,t){return t&&e.local[t]||Ma}function Fw(e,t){const n=Zr(e,t);return n.draft.trim()!==""||n.attachments.length>0}function $o(e,t){return t&&e.rows.find(n=>n.id===t)||null}function j_(e,t){const n=$o(e,t);return n?ns(n.agent)||!!e.shipping[n.id]||(n.queued??0)>0:!1}function qt(e,t){const n=$o(e,t);return n&&jn(n)?n:null}function $_(e){var o;const t=qt(e,e.activeId);if(!t||!Na(t.worktree)||t.agent!=="idle"||!((o=ql(e,t.repoId))!=null&&o.empty))return!1;const n=Pi(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&&Zr(e,t.id).chat.length===0}function Xh(e){return e.newProject!==null||$_(e)}function rz(e){return e.incompatible||Xh(e)}function oz(e){return(!e.needsSetup||!!e.assumed)&&Object.keys(e.config.run).length===0}function lh(e){return!!(e!=null&&e.needsSetup)&&!e.assumed}function Bw(e){const t=e.archivedPage?null:$o(e,e.activeId);return(t==null?void 0:t.repoId)??e.activeRepoId}function No(e){const t=Pi(e,Bw(e));return!!t&&oz(t)}function C_(e){return e.layout.chat&&!No(e)&&!e.archivedPage&&!Hw(e)?{a:"toggle-chat"}:{a:"focus-chat"}}function A_(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 Xo(e){return No(e)?e:lo(e,{chat:!0})}function Pi(e,t){return t&&e.repos.find(n=>n.id===t)||null}function I_(e,t){if(!t)return null;const n=e.rows.filter(jn).filter(r=>r.repoId===t);return n.find(r=>Bu(r.worktree))??n.find(r=>Na(r.worktree))??null}function ql(e,t){return t&&e.trunks[t]||null}function Il(e){return No(e)||e.archivedPage||e.notesPage?null:e.activeId}function Qh(e){return e.procs.some(t=>t.status==="running"||t.status==="starting")}function bu(e){if(e.archivedPage||e.notesPage)return null;const t=qt(e,e.activeId);return t&&Qh(t)?{worktreeId:t.worktree.id,repoId:t.repoId}:null}function ik(e){const t=Il(e),n=qt(e,t);return n?{id:n.worktree.id,act:Qh(n)?"frame":"start"}:null}function Uw(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&&jn(o)&&o.repoId===t?o:null}function sz(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&&jn(o)?o.worktree.title:((s=n.find(a=>a.id===r.origin.id))==null?void 0:s.title)??null}function R_(e,t){return e.repoId!==t&&(e.agent==="waiting"||!!e.unseen)}function Jh(e,t,n,r){return e.repoId===t||Uw(e,t,n)!==null||R_(e,t)||e.id===r}function O_(e,t,n){return!e||!t||!jn(e)||e.repoId===t||Uw(e,t,n)?null:R_(e,t)?e.id:null}function M_(e,t){return t.length?e.filter(n=>!t.includes(n.id)):e}function iz(e,t,n,r){const o=M_(e,n).filter(jn);return eI(t?o.filter(s=>Jh(s,t,o,r)):o)}function az(e,t){const n=e.filter(r=>!jn(r));return t?n.filter(r=>r.repoId===t):n}function Zl(e,t,n=e.rows){var c;const r=n.filter(jn),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=>Bu(u.worktree))??a.find(u=>Na(u.worktree))??a[0])==null?void 0:c.id)??null}function rx(e,t){const n=Object.entries(e),r=n.filter(([o])=>!t(o));return r.length===n.length?e:Object.fromEntries(r)}function L_(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)||K_({trunks:n},a))&&(r[a]=c);const o=Object.keys(r);return o.length===Object.keys(e).length&&o.every(a=>lz(e[a],r[a]))?e:r}const lz=(e,t)=>!!e&&!!t&&e.op===t.op&&e.step===t.step&&e.sent===t.sent;function fa(e,t){var m;const n=$o(e,t),r=!!n&&jn(n)&&!!e.activeRepoId&&Jh(n,e.activeRepoId,e.rows,e.lent),o=r&&e.lent!==t?O_(n,e.activeRepoId,e.rows):r?e.lent:null,s=r?e.activeRepoId:(n==null?void 0:n.repoId)??e.activeRepoId,a=n&&jn(n)?{...e.lastActive,[n.repoId]:n.id}:e.lastActive,c=e.activeId!==t?e.activeId:null,u=c?e.local[c]:void 0,h=u&&((m=u.mark)==null?void 0:m.by)==="reveal"?Rl(u,"reveal"):null,f=c&&h?{...e.local,[c]:h}:e.local;return{...e,activeId:t,activeRepoId:s,lent:o,lastActive:a,editor:null,archivedPage:null,notesPage:!1,local:f}}function Gl(e){return Bo(e)?"history":e.layout.changesTab}function cz(e,t){const n=Gl(e);if(Bo(e))return n;const r=Uf.length;return Uf[(Uf.indexOf(n)+t+r)%r]??"changes"}function Hw(e){if(e.archivedPage)return null;const t=$o(e,e.activeId);return t&&!jn(t)?t:null}function uz(e){return e.notesSeen||e.ranBefore===null||!t_(e.version,e.ranBefore)?null:e.version}const dz=800;function P_(e,t){return e.left&&t-e.left.at<dz?e.left.face:null}function fz(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 hz(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 Bo(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 Rl(e,t){var o;if(((o=e.mark)==null?void 0:o.by)!==t)return e;const{mark:n,...r}=e;return r}const D_=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 pz=0;function xu(e){if(!e.sending)return e;const{sending:t,...n}=e;return n}function mz(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]=xu(r[o]);return{...e,local:r}}function gz(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]??Ma,u=c.chat.some(h=>h.kind==="user")?{at:s.at}:s;o={...o,[n]:xu(o[n]),[r]:{...c,sending:u}}}for(const c of t){const u=o[c.id];u!=null&&u.sending&&!u.sending.message&&ns(c.agent)&&(o={...o,[c.id]:xu(u)})}return o}function bt(e,t,n){return{...e,local:{...e.local,[t]:n(e.local[t]??Ma)}}}function ox(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 kz(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"&&jw(t.outcome),s=t.type==="agent-ask-end"&&t.outcome==="expired"?t.id:null,{card:a,cardParked:c,askRevived:u,...h}=e;return{...h,...a&&!n&&(a.id!==r||o)?{card:a}:{},...c&&!n&&c!==r?{cardParked:c}:{},...s?{askRevived:s}:u&&!n?{askRevived:u}:{}}}function wz(e,t,n){return bt(e,t,r=>({...r,chat:[...r.chat,n],chatAt:Date.now()}))}function z_(e,t,n){return wz(Xo(e),t,{kind:"error",text:n})}function ak(e,t){const n=Oa(qt(e,e.activeId));return n?bt(Xo(e),n,r=>({...r,notice:t})):e}function sx(e,t,n){return qt(e,t)?z_(e,t,n):ak(e,n)}function yz(e,t){const n=e.paletteReturn;return!t||!n?{overlay:null,paletteReturn:null}:{overlay:{kind:n.mode},paletteReturn:n}}function vz(e){const t=e.activeRepoId;if(!t)return e;const n=e.layouts[t];return n?zw(e,n):e.frame==="desk"?{...e,layouts:{...e.layouts,[t]:e.layout}}:e}function bz(e){return e.a==="server"&&e.msg.t==="git-status"}function xz(e){return{agent:e.defaultAgent}}function Ez(e){const t=qt(e,e.activeId);return!!t&&jr(t.worktree)&&!e.archivedPage&&!Xh(e)?e.draft?e:{...e,draft:xz(e)}:e.draft?{...e,draft:null}:e}function F_(e){var r;const t=e.archivedPage,n=t!==null&&((r=e.editor)==null?void 0:r.worktreeId)===t&&qt(e,t)===null;return{...e,archivedPage:null,...n?{editor:null}:{}}}function Sz(e){const t=e.activeRepoId;if(!t)return e;const n=qt(e,e.activeId);return!n||n.repoId===t||Jh(n,t,M_(e.rows,e.archiving),e.lent)?e:fa(e,Zl(e,t))}function B_(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?Ti(o,{a:"open",overlay:{kind:"devices"}}):o}const _z=e=>{var t;return e.frame==="desk"&&(e.remote!==null||((t=e.tailscale)==null?void 0:t.state)==="ready")};function Ti(e,t){let n=Ez(Sz(Nz(e,t)));return n.unreadHold!==null&&n.activeId!==n.unreadHold&&(n={...n,unreadHold:null}),n.archivedPage!==null&&(Bo(n)===null||qt(n,n.archivedPage)!==null)&&(n=F_(n)),n.activeRepoId!==e.activeRepoId?n=vz(n):n.frame==="desk"&&n.activeRepoId&&!bz(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:iz(n.rows,n.activeRepoId,n.archiving,n.lent),visibleDiscovered:az(n.rows,n.activeRepoId)}}function Nz(e,t){var n,r,o,s,a,c,u,h;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:Az(e.local)};case"activate":return{...fa(e,t.id),viewed:nx(e.viewed,e.activeId,t.id),carryTo:null,screen:t.id?"chat":"home"};case"viewed-land":{const f=e.viewed.ids[t.at];return f===void 0||!e.rows.some(m=>m.id===f)?e:{...fa(e,f),viewed:{...e.viewed,at:t.at},carryTo:null,screen:"chat"}}case"open-draft":{if(Xh(e))return e;const f=((n=I_(e,e.activeRepoId))==null?void 0:n.id)??null;return f?Xo({...fa(e,f),viewed:nx(e.viewed,e.activeId,f),carryTo:f,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"draft-profile":return e.draft?{...e,draft:{...e.draft,profile:t.profile}}:e;case"open-archived":return A_(e,t.id);case"close-archived":return e.archivedPage?F_(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,f=>({...f,sending:{message:t.message,at:Date.now()}}));case"sent-box":return bt(e,t.id,({notice:f,...m})=>({...Rl(m,"walk"),draft:"",attachments:[],sent:(m.sent??0)+1}));case"answered":return bt(e,t.id,f=>({...f,sent:(f.sent??0)+1}));case"hold-send":{const f=e.local[t.id];if(!f)return e;const m=L4(e.clientId,++pz,t.id),g={...Ma,draft:t.text,attachments:f.attachments,outgoing:{frame:t.frame,log:t.log}},y=bt(e,t.id,({notice:w,...v})=>({...Rl(v,"walk"),draft:"",attachments:[]}));return{...y,local:{...y.local,[m]:g},outbox:[...e.outbox,{id:m,log:t.log,kinds:f.attachments.map(w=>w.kind)}]}}case"sent-out":{const f=e.local[t.id],m=f==null?void 0:f.outgoing;if(!f||!m)return e;const{[t.id]:g,...y}=e.local,w={...e,local:y,outbox:e.outbox.filter(j=>j.id!==t.id)},v=f.draft,N=f.attachments.length?Dw(f.attachments):void 0,x=j=>({...j,sent:(j.sent??0)+1});if(m.frame.t==="restore-worktree"||m.frame.t==="adopt-worktree")return bt(w,m.log,j=>({...x(j),sending:{message:{text:v,attachments:N},at:Date.now()}}));if(m.frame.t==="agent-answer")return bt(w,m.log,x);const _=m.frame.t==="chat"&&j_(e,m.log);return bt(w,m.log,j=>_?x(j):{...x(j),sending:{message:{text:v,attachments:N},at:Date.now()}})}case"unsend":{const f=e.local[t.id],m=(r=ps(t.id))==null?void 0:r.source;if(!(f!=null&&f.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(Xo(w),m,v=>({...v,draft:v.draft||f.draft,attachments:[...f.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]:f,...m}=e.local;return{...e,local:m,outbox:e.outbox.filter(g=>g.id!==t.id)}}case"archive-worktrees":{const f=t.ids.filter(I=>!e.archiving.includes(I)&&qt(e,I));if(f.length===0)return e;const m=Date.now();let g=e.archived;for(const I of f){const R=qt(e,I);R&&(g={...g,[R.repoId]:[fz(R,m),...g[R.repoId]??[]]})}const y={...e,archiving:[...e.archiving,...f],archived:g};if(!e.activeId||!f.includes(e.activeId))return y;const w=e.visible.filter(I=>I.id===e.activeId||!y.archiving.includes(I.id)),v=w.findIndex(I=>I.id===e.activeId),N=[I=>I.agent==="waiting",I=>Ah(I.worktree)&&!!I.worktree.landed&&I.agent==="idle",I=>!!I.unseen,I=>I.agent==="working",I=>!jr(I.worktree)&&Fs(I)==="running"],x=I=>{for(const R of N){const C=I(R);if(C)return C.id}},_=x(I=>w.findLast((R,C)=>C<v&&I(R))),T=fa(y,_??x(I=>w.find((R,C)=>C>v&&I(R)))??Zl(y,e.activeRepoId));return e.frame==="phone"?{...T,screen:"home"}:T}case"shipping":return e.shipping[t.id]||!($o(e,t.id)||K_(e,t.id))?e:{...e,shipping:{...e.shipping,[t.id]:{op:t.op,sent:!0}}};case"activate-repo":{if(!Pi(e,t.id))return e;const f=e.newProject?{...e,newProject:null}:e;if(t.id===e.activeRepoId)return f;const m=Zl(f,t.id);return{...fa(f,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 f="name"in t.v||"parent"in t.v||"url"in t.v||"mode"in t.v,{error:m,...g}=e.newProject;return{...e,newProject:{...f?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 f=t.v,m=e.editor,g=m&&Zc(m,f)?m:null,y=f.line&&N_(e,f.worktreeId,f.path,f.line);return{...e,editor:{worktreeId:f.worktreeId,path:f.path,...f.ref?{ref:f.ref}:{},...f.since?{since:f.since}:{},view:f.view??(g==null?void 0:g.view)??null,seq:f.seq,disk:(g==null?void 0:g.disk)??null,...y?{line:y}:{},...f.piece?{piece:f.piece}:{},focus:f.focus,conflict:(g==null?void 0:g.conflict)??null,blame:(g==null?void 0:g.blame)??null}}}case"open-loose":{const f=t.v,m={before:f.text,after:f.text,version:null,writable:(f.source.kind==="handle"||f.source.kind==="grant")&&!f.tooLarge&&!f.binary,binary:f.binary,tooLarge:f.tooLarge};return{...e,editor:{worktreeId:f.worktreeId,path:f.name,view:Ri(f.name),seq:f.seq,disk:m,focus:!0,conflict:null,blame:null,loose:{source:f.source}}}}case"editor-read":{const f=e.editor;if(!f||f.loose||!Zc(f,t.file))return e;const m=t.disk;if(!m){const w=z_(e,f.worktreeId,t.error??`could not read ${f.path}`);return f.disk?w:{...w,editor:null}}const g=Ri(f.path),y=m.before===""?f.view&&f.view!=="diff"?f.view:g:f.view??(m.before===m.after?g:"diff");return{...e,editor:{...f,view:y,disk:m}}}case"editor-conflict":{const f=e.editor;return f&&!f.loose&&Zc(f,t.file)?{...e,editor:{...f,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 f=e.editor;if(!f||!Zc(f,t.file))return e;const m=f.loose&&f.disk?{...f.disk,writable:!1}:f.disk;return{...e,editor:{...f,refused:t.message,disk:m}}}case"editor-blame":{const f=e.editor;return f&&!f.loose&&Zc(f,t.file)?{...e,editor:{...f,blame:t.blame}}:e}case"notice":return bt(Xo(e),((s=ps(t.id))==null?void 0:s.source)??t.id,f=>({...f,notice:t.text}));case"link-refused":return bt(e,t.id,({refusedLink:f,...m})=>t.v?{...m,refusedLink:t.v}:m);case"card-draft":return bt(e,t.id,f=>({...f,card:t.card}));case"card-park":return bt(e,t.id,f=>({...f,cardParked:t.cardId}));case"card-unpark":return bt(e,t.id,({cardParked:f,...m})=>m);case"ask-revive":return bt(e,t.id,({askRevived:f,...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,f=>{const{notice:m,...g}=Rl(f,"walk");return{...g,draft:t.text,...m!==void 0&&t.text===""?{notice:m}:{}}});case"move-box":return W_(e,t.from,t.to);case"walk":return bt(e,t.id,f=>({...Rl(f,"walk"),draft:t.text,...t.walk?{mark:{by:"walk",at:t.walk.at,from:t.walk.from}}:{}}));case"reveal":return bt(Xo(e),t.id,f=>{var m;return{...f,mark:{by:"reveal",seq:t.seq,n:((m=f.mark)==null?void 0:m.by)==="reveal"?f.mark.n+1:1}}});case"attach":return bt(Xo(e),t.id,({notice:f,...m})=>({...m,attachments:[...m.attachments,...t.items]}));case"upload-progress":return(a=e.local[t.id])!=null&&a.attachments.some(f=>f.key===t.key&&Ii(f))?bt(e,t.id,f=>({...f,attachments:f.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(f=>f.key===t.key)?bt(e,t.id,f=>({...f,attachments:f.attachments.map(m=>m.key===t.key?t.item:m)})):e;case"detach":{const f=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?Ti(f,{a:"unsend",id:t.id}):f}case"clear-attachments":return bt(e,t.id,({notice:f,...m})=>m.attachments.length?{...m,attachments:[]}:m);case"hmr":return bt(e,t.id,f=>({...f,turn:{...f.turn,hmr:!0}}));case"page":return bt(e,t.id,f=>({...f,page:{url:t.url??f.page.url,title:t.title??f.page.title}}));case"links":return bt(e,t.id,f=>{const m=O4(f.links??[],t.links);return m===f.links?f:{...f,links:m}});case"drag-files":return ez(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:D_(t.overlay)?e.paletteReturn:null};case"choosing-folder":return{...e,choosingFolder:t.v};case"close":return{...e,previewTheme:null,...yz(e,t.back)};case"toggle":return((h=e.overlay)==null?void 0:h.kind)===t.overlay.kind?Ti(e,{a:"close"}):Ti(e,{a:"open",overlay:t.overlay});case"palette-return":return{...e,paletteReturn:t.v};case"toggle-changes":return{...lo(e,{changes:!e.layout.changes}),changesAuto:!1};case"focus-changes":return{...lo(e,{changes:!0,changesTab:t.tab&&!Bo(e)?t.tab:e.layout.changesTab}),changesAuto:!1,focusChanges:e.focusChanges+1};case"changes-tab":return lo(e,{changesTab:t.v});case"edit-commit":return{...lo(e,{changes:!0}),changesAuto:!1,editCommit:e.editCommit+1};case"toggle-chat":return No(e)?e:lo(e,{chat:!e.layout.chat});case"focus-chat":return{...Xo(e),focusChat:e.focusChat+1};case"walked":return{...e,walked:e.walked+1};case"show-chat":return Xo(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"?lo(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 f={...e,frame:t.v};if(t.v!=="desk"||!f.activeRepoId)return f;const m=f.layouts[f.activeRepoId];return m?zw(f,m):f}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 f=e.activeRepoId;return f?{...e,discoveredOpen:{...e.discoveredOpen,[f]:!e.discoveredOpen[f]}}:e}case"toggle-archived":{const f=e.activeRepoId;return f?{...e,archivedOpen:{...e.archivedOpen,[f]:!e.archivedOpen[f]}}:e}case"toggle-committed":{const f=e.activeRepoId;return f?{...e,committedShut:{...e.committedShut,[f]:!e.committedShut[f]}}:e}case"toggle-turn":{const f=e.activeRepoId;return f?{...e,turnOpen:{...e.turnOpen,[f]:!e.turnOpen[f]}}:e}case"tree-folder":{const f=e.treeOpen[t.worktreeId]??[];if(f.includes(t.path)===t.open)return e;const m=t.open?[...f,t.path]:f.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 f=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=>!f.includes(w)),y=g.length?{...e.treeOpen,[t.worktreeId]:[...f,...g]}:e.treeOpen;return{...lo(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,f=>({...f,filesFor:t.key}));case"toggle-zen":return No(e)?e:{...e,zen:!e.zen};case"toggle-terminal":return lo(e,{term:!e.layout.term});case"focus-terminal":return{...lo(e,{term:!0}),focusTerm:e.focusTerm+1};case"toggle-design":return No(e)?e:lo(e,{design:!e.layout.design});case"term-stream":return bt({...lo(e,{term:!0}),termTall:t.tall?e.termTall+1:e.termTall},t.id,f=>({...f,termStream:t.stream}));case"term-run":return bt({...lo(e,{term:!0}),focusTerm:e.focusTerm+1,termRun:{id:t.id,command:t.command}},t.id,f=>({...f,termStream:Do}));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 Pz(e,t.msg);case"recall":return Lz(e,t.hello,t.chats)}}function U_(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 H_(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 Tz(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(h=>{var f;return h.id===s.id&&((f=h.worktree)==null?void 0:f.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 jz(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 h=new Map(e==null?void 0:e.files.map(y=>[y.path,y])),f=r.map(y=>{const w=h.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:f,...g?{extras:g}:{}}}function $z(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 Cz(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 Az(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 Iz(e,t){let n=e;for(const[r,o]of Object.entries(t)){const s=n[r];s!=null&&s.draft||ps(r)||(n===e&&(n={...e}),n[r]={...s??Ma,draft:o})}return n}function Rz(e,t){let n=e;for(const[r,o]of Object.entries(t)){const s=n[r];s!=null&&s.attachments.length||ps(r)||(n===e&&(n={...e}),n[r]={...s??Ma,attachments:ok(o,[])})}return n}function Oz(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 Ei(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 ix(e){const t=e.newProject;if((t==null?void 0:t.phase)!=="creating"||!t.repoId)return e;const n=I_(e,t.repoId);if(!n)return e;const r=Zr(e,Kl);return!r.draft.trim()&&r.attachments.length===0?{...e,newProject:null}:{...W_(e,Kl,n.id),newProject:null,autoSend:n.id}}function W_(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 Mz(e){return e.stamps?FP(e.stamps):null}function K_(e,t){return Object.values(e.trunks).some(n=>n.id===t)}function q_(e,t,n){var w;const{rows:r,repos:o,trunks:s,visits:a}=t.same?e:t,c=v=>!!v&&r.some(N=>N.id===v),u=v=>!!v&&o.some(N=>N.id===v),h=u(e.activeRepoId)?e.activeRepoId:u(e.storedRepo)?e.storedRepo:null,f=c(e.activeId)?e.activeId:c(e.storedActive)?e.storedActive:Zl(e,h,r),m=r.find(v=>v.id===f),g=!!h&&!!m&&jn(m)&&Jh(m,h,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:f,lent:g?e.lent===f?e.lent:O_(m??null,h,r):null,activeRepoId:g?h:(m==null?void 0:m.repoId)??h??((w=o[0])==null?void 0:w.id)??null,trunks:s,archiving:e.archiving.length?[]:e.archiving,shipping:L_({},r,s),local:Cz(H_(Rz(Iz(e.local,t.drafts),t.attachments),r,e.archivedPage)),lastActive:Oz(e.lastActive,r),viewed:E_(e.viewed,new Set(r.map(v=>v.id))),treeOpen:U_(e.treeOpen,r),discoveredOpen:Ei(e.discoveredOpen,o),archivedOpen:Ei(e.archivedOpen,o),committedShut:Ei(e.committedShut,o),turnOpen:Ei(e.turnOpen,o),refs:Ei(e.refs,o),chats:Ei(e.chats,o),archived:Ei(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?__():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:B_(y,t.knocks,t.letIn)}function lk(e,t=[]){let n=t,r;for(const{seq:o,event:s}of e)n=G_(n,s,o),s.type==="usage"&&(r=Z_(s));return r?{chat:n,usage:r}:{chat:n}}function Lz(e,t,n){var s;let r=q_(e,H4(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:h}=lk(c.events);r=bt(r,a,f=>({...f,chat:V_(u),chatAt:q4(c.events)??t.at,running:void 0,...h?{usage:h}:{},...c.draft&&!f.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 Pz(e,t){var n,r,o,s,a,c,u,h,f,m,g,y,w,v,N;switch(t.t){case"hello":return q_(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 B_(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,..._}=t;return{...e,agentConfigs:{...e.agentConfigs,[_.agent]:_}}}case"pending-repos":{const x=new Set(e.pending.map(R=>R.id)),_=t.pending.find(R=>!x.has(R.id)),j=_&&e.pendingOpen?_.id:e.activeImportId,T=t.pending.some(R=>R.id===j),I=t.pending.some(R=>R.id===j&&R.error);return{...e,pending:t.pending,activeImportId:T?j:null,pendingOpen:I?!1:e.pendingOpen,newProject:_&&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(_=>e.archiving.includes(_.id)&&!t.items.some(j=>j.id===_.id));return{...e,archived:{...e.archived,[t.repoId]:x.length?[...x,...t.items]:t.items}}}case"draft":return t.clientId===e.clientId||ps(t.boxId)?e:bt(e,t.boxId,x=>{var _;return x.draft===t.text||((_=x.mark)==null?void 0:_.by)==="walk"?x:{...x,draft:t.text}});case"attachments":return t.clientId===e.clientId||ps(t.boxId)?e:bt(e,t.boxId,x=>({...x,attachments:ok(t.items,x.attachments)}));case"repos":{const x=new Set(e.repos.map(A=>A.id)),_=t.repos.find(A=>!x.has(A.id));let j=e.activeRepoId,T=e.pendingOpen,I=e.newProject;_&&(T||!j)?(j=_.id,T=!1,I&&I.phase!=="unmaking"&&(I={...I,phase:"creating",repoId:_.id})):t.repos.some(A=>A.id===j)||(j=((c=t.repos[0])==null?void 0:c.id)??null),(I==null?void 0:I.phase)==="unmaking"&&!t.repos.some(A=>A.id===(I==null?void 0:I.repoId))&&(I={...I,phase:"editing",repoId:null}),t.repos.length===0&&!I&&(I=__());const R=e.gitIdentity||t.repos.some(A=>A.made&&!x.has(A.id)),C=Ef(e,"repos",t.stamp),O=Ei(e.visits,t.repos);return j===e.activeRepoId?{...e,repos:t.repos,stamps:C,visits:O,pendingOpen:T,newProject:I,gitIdentity:R}:ix({...e,repos:t.repos,stamps:C,visits:O,pendingOpen:T,newProject:I,gitIdentity:R,activeRepoId:j,activeId:Zl(e,j),editor:null})}case"worktrees":{const{rows:x,complete:_}=z4(e.rows,t),j=t.trunks??e.trunks;let T=e.activeId;(!T||!x.some(A=>A.id===T))&&(T=Zl(e,e.activeRepoId,x));const I=new Set(e.rows.map(A=>A.id)),R=A=>{var D;return((D=A.worktree)==null?void 0:D.kind)==="worktree"&&A.worktree.createdBy===e.clientId},C=x.find(A=>!I.has(A.id)&&R(A));C&&e.rows.length>0&&(T=C.id);const O=e.archiving.filter(A=>x.some(D=>D.id===A));return ix({...fa({...e,rows:x,trunks:j,stamps:Ef(e,"rows",_?t.stamp:""),archiving:O.length===e.archiving.length?e.archiving:O,shipping:L_(e.shipping,x,j),local:H_(gz(Tz(e.local,e.rows,x),x,e.activeId,T===(C==null?void 0:C.id)?C.id:void 0),x,e.archivedPage),treeOpen:U_(e.treeOpen,x),viewed:E_(e.viewed,new Set(x.map(A=>A.id)))},T),editor:T===e.activeId?e.editor:null,...C&&T===C.id?{carryTo:C.id}:{},...T===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:VA(x.log.slice(-400),t.proc,t.line,t.retract)}));case"agent":{const x=t.event,_=t.worktreeId;let j=bt(e,_,T=>{const I=G_(T.chat,x,t.seq),R=x.type==="turn-end",C=R||x.type==="agent-error"||x.type==="agent-auth-required",A=x.type==="tool-start"||x.type==="tool-end"||R||x.type==="tool-update"&&x.background?ox(I,T.running):T.running;let D=T.turn;x.type==="turn-start"?D={edits:!1,hmr:!1}:x.type==="tool-start"&&VE(x)&&(D={...D,edits:!0});const B=x.type==="session-info"&&x.model?x.model:T.model,W=x.type==="session-info"&&x.effort?x.effort:T.effort,U=x.type==="usage"?{...Z_(x),heard:Date.now()}:T.usage,Q=e.rows.find($=>$.id===_),Y=ns(Q==null?void 0:Q.agent),se=T.sending?Y?xu(T):{...T,sending:{at:T.sending.at}}:T,H=kz(x.type==="user-message"?se:C?xu(T):T,x);return{...x.type==="user-message"?Rl(H,"reveal"):H,chat:I,...I!==T.chat?{chatAt:Date.now()}:{},...A!==T.running?{running:A}:{},turn:D,...B!==T.model?{model:B}:{},...W!==T.effort?{effort:W}:{},...U!==T.usage?{usage:U}:{}}});if(x.type==="agent-ask-end"&&!jw(x.outcome)&&((u=j.local[Ll(x.id)])!=null&&u.attachments.length)&&(j=bt(j,Ll(x.id),T=>({...T,attachments:[]}))),x.type==="user-message"){const T=c_(((h=e.local[_])==null?void 0:h.chat)??[]),I=T?Ll(T.id):null,R=I?((f=j.local[I])==null?void 0:f.attachments)??[]:[];I&&R.length&&(j=bt(j,I,C=>({...C,attachments:[]})),j=bt(j,_,C=>({...C,attachments:[...C.attachments,...R]})))}if(x.type==="turn-end"){const T=j.local[_].turn;T.edits&&!T.hmr&&(j={...j,reloadReq:{id:_,n:(((m=j.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")&&_===e.activeId&&(j=Xo(j)),j}case"backfill":{const x=_=>t.events.some(({event:j})=>j.type==="user-message"&&j.text===_);return bt(e,t.worktreeId,({sending:_,...j})=>{const{chat:T,usage:I}=t.after!==void 0?lk(t.events,j.chat):lk(t.events);return{...j,..._&&!(_.message&&x(_.message.text))?{sending:_}:{},chat:T,chatAt:Date.now(),running:ox(T,j.running),log:t.log??j.log,...I?{usage:I}:{}}})}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 _=e.layout.changes,j=e.changesAuto;const T=((y=t.extras)==null?void 0:y.committed.length)??0;e.changesAuto&&t.worktreeId===e.activeId&&!_&&(t.files.length>0||T>0)&&(_=!0,j=!1);const I=t.worktreeId===e.archivedPage?Bo(e):null;I&&(t.files.length>0||T>0||I.landed)&&(_=!0);const R=bt(e,t.worktreeId,C=>{const O=jz(C.git,t);return{...C,git:O,changedRanges:$z(C.git,O,C.changedRanges)}});return{...lo(R,{changes:_}),changesAuto:j}}case"pr-comments":return bt(e,t.worktreeId,x=>({...x,prComments:t.comments}));case"changed-ranges":{const x=bt(e,t.worktreeId,j=>({...j,changedRanges:{...j.changedRanges,[t.path]:{ranges:t.ranges,offset:t.lineOffset}}})),_=x.editor;return!((w=_==null?void 0:_.line)!=null&&w.fiber)||_.worktreeId!==t.worktreeId||_.path!==t.path?x:{...x,editor:{..._,line:N_(x,_.worktreeId,_.path,_.line)}}}case"shipped":{const x=t.worktreeId,_={...e,shipping:rx(e.shipping,j=>{var T;return j===x&&((T=e.shipping[j])==null?void 0:T.sent)===!0}),openUrl:t.ok&&t.url?t.url:e.openUrl};return!t.ok&&!t.asked?x?sx(_,x,t.message):ak(_,t.message):_}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,j=>({...j,notice:"nothing in the source matches this element"}));if(!t.sure)return Ti(e,{a:"open",overlay:{kind:"element-sources",worktreeId:t.worktreeId,hits:t.hits}});const _=Ti(e,{a:"open-file",v:{worktreeId:t.worktreeId,path:x.path,view:"file",line:{n:x.line},focus:!0,seq:t.seq}});return _.layout.changes?_:Ti(_,{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,_=e.newProject,j=(_==null?void 0:_.phase)==="creating"&&!_.repoId,T=x?e.archiving.includes(x)?[x]:[]:e.archiving,I={...mz(e,x),archiving:T.length?e.archiving.filter(R=>!T.includes(R)):e.archiving,archived:T.length?hz(e.archived,T):e.archived,shipping:rx(e.shipping,R=>!x||R===x),newProject:j?{..._,phase:"editing",error:t.message}:(_==null?void 0:_.phase)==="unmaking"?null:_,pendingOpen:j?!1:e.pendingOpen,updateCheck:!x&&e.updateCheck==="asking"?null:e.updateCheck};return j?I:x?sx(I,x,t.message):ak(I,t.message)}case"unsent":{const x=((v=ps(t.boxId))==null?void 0:v.source)??t.boxId,_=!$o(e,x)&&!!e.activeRepoId&&((N=e.archived[e.activeRepoId])==null?void 0:N.some(j=>j.id===x));return bt(Xo(_?A_(e,x):e),x,({sending:j,...T})=>({...T,draft:T.draft||t.text,attachments:[...ok(t.items,[]),...T.attachments],notice:t.message}))}default:return e}}function Z_(e){return{used:e.used,size:e.size,...e.cost!==void 0?{cost:e.cost}:{}}}function Dz(e,t){const n=t.trim();return n!==""&&(e.trim()===n||e.trim().endsWith(`: ${n}`))}function G_(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 h=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 f=t.messageId===void 0?-1:zz(e,t.messageId);if(f!==-1){const m=e.slice(),g=m[f];return m[f]={...g,text:g.text+t.text},m}return[...e,{kind:"assistant",text:t.text,...o,...h}]}case"picture":{const{type:h,...f}=t;let m=e.findLastIndex(w=>w.kind==="assistant"&&w.text.includes(f.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!==f.path),f]},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 h=e.findLastIndex(g=>g.kind==="tool"&&g.id===t.toolId);if(h===-1)return e;const f=e.slice(),m=f[h];return f[h]={...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}:{}},f}case"tool-delta":{const h=e.findLastIndex(g=>g.kind==="tool"&&g.id===t.toolId);if(h===-1)return e;const f=e.slice(),m=f[h];return f[h]={...m,output:(m.output??"")+t.text},f}case"tool-end":{const h=e.findLastIndex(g=>g.kind==="tool"&&g.id===t.toolId);if(h===-1)return e;const f=e.slice(),m=f[h];return f[h]={...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},f}case"agent-error":return(r==null?void 0:r.kind)==="assistant"&&Dz(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 h=t.held?e.findLast(m=>m.kind==="ask"&&!m.outcome&&m.ask.kind==="permission"&&!!m.ask.plan):void 0,f=(h==null?void 0:h.kind)==="ask"&&h.ask.kind==="permission"?{companion:h.id,plan:h.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}:{},...f,state:t.held?"held":"proposed",outcomes:[],later:[],ts:t.ts}]}case"handoff-stale":{const h=bl(e,t.id,["held","proposed"]);return h===-1?e:e.with(h,{...e[h],stale:!0})}case"handoff-shown":{const h=bl(e,t.id,["held","proposed"]);if(h===-1)return e;const f=e[h];return e.with(h,{...f,state:"proposed",...t.plan?{plan:t.plan}:{}})}case"handoff-fate":{const h=bl(e,t.id,["held","proposed"]);if(h===-1)return e;const f=e[h];return e.with(h,{...f,fates:{...f.fates,[t.pieceId]:t.fate}})}case"handoff-go":{const h=bl(e,t.id,["held","proposed"]);if(h===-1)return e;const f=e[h];if(f.state!=="proposed")return e.with(h,{...f,state:"going"});const m={go:!0,...t.note?{note:t.note}:{}};return ax(e,h,{...f,state:"going",answered:m,ts:t.ts})}case"handoff":{const h=bl(e,t.id,["held","proposed","going"]);return h===-1?[...e,{kind:"handoff",id:t.id,pieces:[],fates:{},mode:Ug,state:"done",outcomes:t.outcomes,later:[],ts:t.ts}]:e.with(h,{...e[h],state:"done",outcomes:t.outcomes})}case"handoff-declined":{const h=bl(e,t.id,["held","proposed","going"]);if(h===-1)return e;const f=e[h],{companion:m,...g}=f,y=t.plan?{...g,plan:t.plan}:f;return y.state==="proposed"&&!t.reason?ax(e,h,{...y,state:"declined",answered:{go:!1},ts:t.ts}):e.with(h,{...y,state:"declined",...t.reason?{reason:t.reason}:{}})}case"piece-made":case"piece-dropped":{const h=e.findLastIndex(v=>v.kind==="handoff"&&v.id===t.id),f=h===-1?void 0:e[h],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=f==null?void 0:f.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[...f?e.with(h,{...f,later:[...f.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"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(h=>h.kind==="auth"&&!h.done)?e.map(h=>h.kind==="auth"&&!h.done?{...h,done:!0}:h):e;case"agent-question":return lx(e,t.toolId,{kind:"ask",id:t.id,ask:{kind:"question",message:t.message,questions:t.questions}});case"agent-permission":{const h={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}},f=t.handoff?e.findLastIndex(y=>y.kind==="handoff"&&y.id===t.handoff):-1,m=f===-1?e:e.with(f,{...e[f],companion:t.id,...t.plan&&!e[f].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"?lx(m,t.toolId,h):[...m,{...h,toolId:g.id}]}case"agent-ask-end":{const h=e.findLastIndex(g=>g.kind==="ask"&&g.id===t.id&&!g.outcome);if(h===-1)return e;const f=e[h];if(f.toolId&&Fz(f,t.choiceId))return[...e.slice(0,h),...e.slice(h+1)];const m=e.slice();return m[h]={...m[h],outcome:t.outcome,...t.answers?{answers:t.answers}:{},...t.choiceId?{choiceId:t.choiceId}:{}},m}case"turn-end":{const h=V_(e);return t.stopReason==="interrupted"?[...h,{kind:"stopped",...o}]:h}default:return e}}function V_(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 zz(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 bl(e,t,n){return e.findLastIndex(r=>r.kind==="handoff"&&r.id===t&&n.includes(r.state))}function ax(e,t,n){return[...e.slice(0,t),...e.slice(t+1),n]}function Fz(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 lx(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 Bz(e){let t=e;const n=new Set;return{getState:()=>t,dispatch(r){const o=Ti(t,r);if(o!==t){t=o;for(const s of n)s()}},subscribe(r){return n.add(r),()=>n.delete(r)}}}const Y_=S.createContext(null),Ww=S.createContext(null),X_=S.createContext(null);function Uz({store:e,sock:t,files:n,children:r}){return d.jsx(Y_.Provider,{value:e,children:d.jsx(Ww.Provider,{value:t,children:d.jsx(X_.Provider,{value:n,children:r})})})}const Q_=S.createContext(null),J_=S.createContext(null);function Hz({machines:e,children:t}){const n=S.useSyncExternalStore(e.subscribe,e.active);return d.jsx(Q_.Provider,{value:e,children:d.jsx(J_.Provider,{value:n,children:d.jsx(Uz,{store:n.store,sock:n.sock,files:n.files,children:d.jsx(S.Fragment,{children:t},n.origin)})})})}function ks(){const e=S.useContext(Q_);if(!e)throw new Error("useMachines outside <MachinesProvider>");return e}function Bs(){const e=S.useContext(J_);if(!e)throw new Error("useMachine outside <MachinesProvider>");return e}function Kw(){const e=ks();return S.useSyncExternalStore(e.subscribe,e.list)}function Gc(e,t){return S.useSyncExternalStore(e.store.subscribe,()=>t(e.store.getState()))}const ck=(e,t)=>e.length===t.length&&e.every((n,r)=>n===t[r]);function eN(){const e=ks(),t=Bs(),n=Kw(),r=S.useMemo(()=>n.filter(c=>c!==t),[n,t]),o=S.useRef(null),s=S.useCallback(c=>{const u=r.map(h=>h.store.subscribe(c));return()=>{for(const h of u)h()}},[r]),a=S.useCallback(()=>{const c=r.map(m=>e.displayName(m.origin)),u=r.map(m=>m.store.getState().repos),h=o.current;if(h&&h.others===r&&ck(h.names,c)&&ck(h.repos,u))return h.value;const f=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:f},f},[r,e]);return S.useSyncExternalStore(s,a)}function tN(){const e=Bs(),t=Kw(),n=S.useMemo(()=>t.filter(a=>a!==e),[t,e]),r=S.useRef(null),o=S.useCallback(a=>{const c=n.map(u=>u.store.subscribe(a));return()=>{for(const u of c)u()}},[n]),s=S.useCallback(()=>{const a=n.map(h=>{const f=h.store.getState();return f.connected&&!f.incompatible?f.rows:cx}),c=r.current;if(c&&c.others===n&&ck(c.rows,a))return c.value;const u=n.map((h,f)=>({origin:h.origin,rows:(a[f]??cx).filter(jn)}));return r.current={others:n,rows:a,value:u},u},[n]);return S.useSyncExternalStore(o,s)}const cx=[];function pY(){return Bs().terminals}function zn(){const e=S.useContext(Y_);if(!e)throw new Error("useStore outside <StoreProvider>");return e}function L(e){const t=zn();return S.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 ut(){return zn().dispatch}function Qe(){return S.useContext(Ww)}function Pr(){const e=S.useContext(Ww);return(e==null?void 0:e.urls)??Tw(location.origin,"")}function Zw(){return S.useContext(X_)}function Wz(e=!1,t=!0){const n=S.useRef(null);return S.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 hs(e,t,n,r=Kz){const o=()=>{try{return n(r.get(e))??t}catch{return t}},[s,a]=S.useState(()=>({key:e,value:o()}));return s.key!==e&&a({key:e,value:o()}),[s.key===e?s.value:o(),h=>{a({key:e,value:h});try{r.set(e,typeof h=="boolean"?h?"1":"0":String(h))}catch{}}]}const Kz={get:e=>localStorage.getItem(e),set:(e,t)=>localStorage.setItem(e,t)};function zl(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 nN(e,t){const[n,r]=S.useState(!1);return S.useEffect(()=>{if(!e){r(!1);return}const o=setTimeout(()=>r(!0),t);return()=>clearTimeout(o)},[e,t]),n}function Gw(e,t){const[n,r]=S.useState(void 0);return S.useEffect(()=>{if(e===void 0){r(void 0);return}const o=setTimeout(()=>r(e),t);return()=>clearTimeout(o)},[e,t]),n}const Vw=1500;function ji(e){const[t,n]=S.useState(()=>Date.now()),r=e!==void 0;return S.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 qz(){const[e,t]=S.useState(window.innerWidth);return S.useEffect(()=>{const n=()=>t(window.innerWidth);return window.addEventListener("resize",n),()=>window.removeEventListener("resize",n)},[]),e}function Zz(e){const t=S.useRef(null);return S.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 ug=40,Gz=1200,Vz=150,Yz=new Set(["ArrowUp","ArrowDown","PageUp","PageDown","Home","End"," "]);function rN(e,t){const n=S.useRef(!0),r=S.useRef(Number.NEGATIVE_INFINITY),o=S.useRef(!1),[s,a]=S.useState(!1),[c,u]=S.useState(!1),[h,f]=S.useState(!1),[m,g]=S.useState(null),y=S.useCallback(I=>{n.current=I,e.current&&(e.current.style.overflowAnchor=I?"none":"")},[e]),w=S.useRef(null),v=S.useRef(null);it([t],()=>{n.current||f(!0)});const N=S.useCallback(()=>n.current,[]),x=S.useCallback(()=>{const I=e.current;I&&(y(I.scrollHeight-I.scrollTop-I.clientHeight<ug),a(!n.current),u(I.scrollTop>=ug),n.current&&f(!1))},[e,y]),_=S.useCallback(I=>{Math.abs(I)<4||(g(I<0?"up":"down"),v.current&&clearTimeout(v.current),v.current=setTimeout(()=>g(null),Gz))},[]),j=S.useCallback(()=>{const I=e.current;I&&(I.scrollTop=I.scrollHeight,y(!0),a(!1),f(!1))},[e,y]),T=S.useCallback(()=>{const I=e.current;I&&(r.current=performance.now(),I.scrollTop=0)},[e]);return S.useEffect(()=>{const I=e.current;if(!I)return;y(n.current);const R=()=>o.current||performance.now()-r.current<Vz,C=()=>{n.current&&!R()?u(I.scrollTop>=ug):x()};I.addEventListener("scroll",C,{passive:!0});const O=()=>{r.current=performance.now()},A=$=>{O(),_($.deltaY)},D=$=>{var Z;O(),w.current=((Z=$.touches[0])==null?void 0:Z.clientY)??null},B=$=>{var q;O();const Z=(q=$.touches[0])==null?void 0:q.clientY;Z===void 0||w.current===null||(_(w.current-Z),w.current=Z)},W=()=>{o.current=!0},U=()=>{o.current=!1},Q=$=>{if(!Yz.has($.key))return;const Z=$.target;(Z===document.body||Z instanceof Node&&I.contains(Z))&&O()};I.addEventListener("wheel",A,{passive:!0}),I.addEventListener("touchstart",D,{passive:!0}),I.addEventListener("touchmove",B,{passive:!0}),I.addEventListener("pointerdown",W,{passive:!0}),window.addEventListener("pointerup",U,{passive:!0}),window.addEventListener("pointercancel",U,{passive:!0}),document.addEventListener("keydown",Q);const Y=()=>{I.scrollTop=I.scrollHeight},se=new ResizeObserver(()=>{n.current&&Y()});se.observe(I);for(const $ of I.children)se.observe($);const H=new MutationObserver($=>{for(const Z of $){for(const q of Z.addedNodes)q instanceof Element&&se.observe(q);for(const q of Z.removedNodes)q instanceof Element&&se.unobserve(q)}n.current&&Y()});return H.observe(I,{childList:!0}),()=>{I.removeEventListener("scroll",C),I.removeEventListener("wheel",A),I.removeEventListener("touchstart",D),I.removeEventListener("touchmove",B),I.removeEventListener("pointerdown",W),window.removeEventListener("pointerup",U),window.removeEventListener("pointercancel",U),document.removeEventListener("keydown",Q),H.disconnect(),se.disconnect(),v.current&&clearTimeout(v.current)}},[e,x,_,y]),{offEnd:s,offStart:c,away:h,moving:m,pinned:N,jump:j,start:T,read:x}}function ux(e,t,n){const r=document.createRange();return r.selectNodeContents(e),r.setEnd(t,n),r.toString().length}function dx(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 oN(e,t){S.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)?ux(n,r.anchorNode,r.anchorOffset):null,a=r&&r.rangeCount>0&&o(r.focusNode)?ux(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,h]=s===null?[c[0],c[1]]:dx(n,s),[f,m]=a===null?[c[2],c[3]]:dx(n,a);u&&f&&r.setBaseAndExtent(u,h,f,m)},[e,t])}function it(e,t){const n=S.useRef(t);n.current=t,S.useEffect(()=>n.current(),e)}function sN(e){const[t,n]=S.useState({left:0,right:0});return S.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 f=u.getBoundingClientRect(),m=u.offsetWidth/f.width;a=u.offsetLeft+(a-f.left)*m,c=u.offsetLeft+(c-f.left)*m}const h={left:Math.round(a),right:Math.round(c)};n(f=>f.left===h.left&&f.right===h.right?f:h)};r();const o=new ResizeObserver(r);return o.observe(e),window.addEventListener("resize",r),()=>{o.disconnect(),window.removeEventListener("resize",r)}},[e]),t}function fx(){const[e,t]=S.useState(null);return[t,sN(e)]}function mY(e){e.ctrlKey&&e.stopPropagation()}function iN(e,t){return e.defaultPrevented||e.ctrlKey?!1:t<1.01}function gY(e){S.useEffect(()=>{const t=e.current;if(!t)return;const n=r=>{var o;iN(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 aN={axis:null,dx:0,dy:0,at:Number.NEGATIVE_INFINITY},Xz=2,Qz=4,Jz=300;function e3(e,t,n){const r=Math.abs(t.deltaX),o=Math.abs(t.deltaY),s=r>o?"x":"y",a=n-e.at<=Jz?e:aN;if(a.axis===null){const u=a.dx+r,h=a.dy+o,f=Math.max(u,h)>=Xz?u>h?"x":"y":null;return{scrolls:f!==null&&f===s,next:{axis:f,dx:u,dy:h,at:n}}}return s===a.axis?{scrolls:!0,next:{...a,at:n}}:(s==="x"?r:o)>=Qz?{scrolls:!0,next:{...a,axis:s,at:n}}:{scrolls:!1,next:{...a,at:n}}}function kY(e){S.useEffect(()=>{const t=e.current;if(!t)return;let n=aN;const r=o=>{var c;if(o.ctrlKey)return;const{scrolls:s,next:a}=e3(n,o,o.timeStamp);n=a,!s&&(o.stopPropagation(),iN(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 t3(e){S.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 n3(e){S.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 r3(e){S.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 o3(e,t,n){const[r,o]=S.useState(),s=S.useRef(e);return s.current=e,S.useEffect(()=>{if(!n)return;let a=!0,c;const u=()=>void s.current().then(h=>{a&&(o(h),c=setTimeout(u,t))});return u(),()=>{a=!1,clearTimeout(c)}},[t,n]),r}const tc=()=>L(e=>e.activeId),lN=()=>nN(!L(e=>e.connected),900),s3=e=>!e.connected&&(e.connectFailure==="down"||e.connectFailure==="blocked"),cN=()=>L(s3),Us=()=>L(e=>qt(e,e.activeId)),Yw=()=>L(e=>$o(e,e.activeId)),uN=()=>L(e=>e.rows),Xw=()=>L(e=>e.visible),i3=()=>L(e=>e.visibleDiscovered),a3=()=>L(e=>e.activeRepoId?e.discoveredOpen[e.activeRepoId]??!1:!1),hx=[],l3=()=>L(e=>e.activeRepoId?e.archived[e.activeRepoId]??hx:hx),c3=()=>L(e=>e.activeRepoId?e.archivedOpen[e.activeRepoId]??!1:!1),u3=()=>L(e=>!(e.activeRepoId&&e.committedShut[e.activeRepoId])),d3=()=>L(e=>!!(e.activeRepoId&&e.turnOpen[e.activeRepoId])),La=()=>L(Bo),Qw=()=>L(Hw),f3=()=>L(e=>Pi(e,e.activeRepoId)),nc=()=>L(e=>Pi(e,Bw(e))),dN=e=>L(t=>Zr(t,e)),At=(e,t)=>L(n=>Zr(n,e)[t]),h3=()=>L(e=>e.overlay),ep=()=>L(nz),fN=()=>L($_),Wu=()=>L(rz),Ku=()=>L(No),p3=()=>L(e=>e.newProject),Di=()=>L(e=>e.touch),qu=e=>L(t=>t.chatSide==="left"==(e==="chat")?"right":"left"),m3=()=>L(e=>e.draft),Jw=()=>L(Il),g3=()=>L(e=>{const t=$o(e,e.activeId),n=t?e.repos.find(r=>r.id===t.repoId):null;return lh(n)?n:null});function k3(e){return e.image?{kind:"image",blob:e.image,sig:`image:${e.image.type}:${e.image.size}`}:e.text&&qS(e.text)?{kind:"text",text:e.text,sig:`text:${e.text}`}:null}function w3(){try{return localStorage.getItem(tt.clipboardOffer)==="1"}catch{return!1}}let zs={access:"none",on:typeof localStorage<"u"&&w3(),offer:null},uk="";const dk=new Set;function tp(e){zs={...zs,...e};for(const t of dk)t()}async function y3(){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 k3({image:e,text:t})}async function np({taken:e=!1,asking:t=!1}={}){if(!zs.on||!(zs.access==="granted"||t&&zs.access==="prompt"))return;let n;try{n=await y3()}catch{return}e&&(uk=(n==null?void 0:n.sig)??""),tp({offer:n&&n.sig!==uk?n:null})}const v3=()=>void np();let px=!1;function b3(){var e,t;px||(px=!0,!(!((e=navigator.clipboard)!=null&&e.read)||!((t=navigator.permissions)!=null&&t.query))&&navigator.permissions.query({name:"clipboard-read"}).then(n=>{const r=()=>{tp({access:n.state,...n.state==="denied"?{offer:null}:{}})};n.onchange=r,r(),window.addEventListener("focus",v3),document.hasFocus()&&np()},()=>{}))}function x3(e){return dk.add(e),b3(),()=>{dk.delete(e)}}const E3=()=>zs;function S3(e){try{localStorage.setItem(tt.clipboardOffer,e?"1":"0")}catch{}tp({on:e,offer:null}),e&&np({asking:!0})}function hN(){zs.offer&&(uk=zs.offer.sig),tp({offer:null})}const _3=()=>void np({taken:!0});function N3(){return S.useSyncExternalStore(x3,()=>zs.offer)}const pN="application/x-toyon-source";function wY(e){const t=e.endColumn===1&&e.endLineNumber>e.startLineNumber?e.endLineNumber-1:e.endLineNumber;return{startLine:e.startLineNumber,endLine:t}}function T3(e,t){e.setData(pN,JSON.stringify(t))}const mx=e=>typeof e=="number"&&Number.isInteger(e)&&e>=1;function j3(e,t){const n=e.getData(pN);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!mx(o)||!mx(s)||s<o?null:{path:r.path,startLine:o,endLine:s,...typeof a=="string"?{ref:a}:{}}}const mN=e=>({left:e.x,top:e.y,right:e.x,bottom:e.y});function $3(e,t){return t.matchWidth===void 0?void 0:Math.max(0,e.right-e.left+t.matchWidth)}const C3=new Set(["top","bottom"]),dg={top:"bottom",bottom:"top",left:"right",right:"left"};function fg(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 gx(e,t,n,r,o){return n==="top"||n==="left"?e>=o:e+t<=r-o}function hg(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 kx(e,t,n,r,o){return n==="start"?e+t<=r-o:e>=o}const wx=(e,t,n,r)=>n||!r?e:t,yx=(e,t,n,r)=>Math.max(r,Math.min(e,n-r-t));function A3(e,t,n,r){const{offset:o=0,alignOffset:s=0,cover:a=!1,flip:c="none",margin:u=8}=r,h=C3.has(r.side),f=h?{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=h?{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 N=fg(f.a,f.size,g,o,a),x=fg(f.a,f.size,dg[g],o,a);g=wx(g,dg[g],gx(N,f.size,g,f.limit,u),gx(x,f.size,dg[g],f.limit,u))}let y=r.align??"center";if((c==="align"||c==="both")&&y!=="center"){const N=y==="start"?"end":"start",x=hg(m.a,m.size,y,s),_=hg(m.a,m.size,N,s);y=wx(y,N,kx(x,m.size,y,m.limit,u),kx(_,m.size,N,m.limit,u))}const w=yx(fg(f.a,f.size,g,o,a),f.size,f.limit,u),v=yx(hg(m.a,m.size,y,s),m.size,m.limit,u);return h?{x:v,y:w,side:g,align:y}:{x:w,y:v,side:g,align:y}}function I3(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 gN={sep:!0},ms=e=>!("sep"in e);function rp(e){const t=[];for(const n of e)(ms(n)||t.length>0&&ms(t[t.length-1]))&&t.push(n);for(;t.length>0&&!ms(t[t.length-1]);)t.pop();return t}const Wn=e=>rp(e.flatMap((t,n)=>n?[gN,...t]:t));let xl=null,R3=0;const fk=new Set,vx=()=>{for(const e of fk)e()},ho={get:()=>xl,subscribe(e){return fk.add(e),()=>{fk.delete(e)}},open(e){const t=rp(e.items);if(t.length===0)return ho.close();xl={...e,items:t,id:++R3},vx()},close(){xl&&(xl=null,vx())},toggle(e){xl&&xl.target===e.target?ho.close():ho.open(e)}};function ey(){return S.useSyncExternalStore(ho.subscribe,ho.get)}function kN(e){const t=e.nativeEvent;return t&&"pointerType"in t?t.pointerType==="":e.clientX===0&&e.clientY===0}function O3(e,t){return kN(e)?{anchor:(t.querySelector('[data-state~="cursor"]')??t).getBoundingClientRect()}:{at:{x:e.clientX,y:e.clientY}}}function M3(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:mN(e.at??{x:0,y:0}),placement:{side:"bottom",align:"start",margin:4}}}function xn(e){return S.useMemo(()=>({contextMenu(t,n){return{onContextMenu:r=>{const o=rp(t(kN(r)?"keyboard":"pointer",r.target));if(o.length===0)return;r.preventDefault(),r.stopPropagation();const s=r.currentTarget;ho.open({items:o,owner:e,key:n,target:s,...O3(r,s)})}}},dropdown(t,n="left",r,o){return{"aria-haspopup":"menu",onClick:s=>{s.stopPropagation();const a=s.currentTarget;ho.toggle({items:t(),...o?{head:o()}:{},owner:e,key:r,target:a,toggles:!0,anchor:a.getBoundingClientRect(),align:n})}}},openUnder(t,n,r){ho.open({items:n(),owner:e,key:r,target:t,toggles:!0,anchor:t.getBoundingClientRect(),align:"left"})}}),[e])}const wN=e=>({id:"open-out",label:Mw()?"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 yN(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 vN=e=>yN("text/plain",fetch(e).then(t=>t.blob())),L3=e=>yN("image/png",P3(e));async function P3(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 op(e){return Rh(e)}function mo(e){return(e==null?void 0:e.urls.host)??(typeof location=="object"?location.hostname:"127.0.0.1")}function Uo(e,t,n="reveal in Finder"){return!e||!op(t)?[]:[{id:"reveal",label:n,onClick:e}]}function D3(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 sp(e,t,{sock:n,dispatch:r}){var a,c;if(!n)return;const o=t.local[e]??Ma,s=D3((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 z3=["diff","file","preview"],bN=(e,t)=>z3.filter(n=>!(n==="preview"&&!qh(e))&&!(n==="diff"&&t));let F3=0;const _o=()=>++F3;function Dn({dispatch:e},{focus:t=!0,...n}){e({a:"open-file",v:{...n,focus:t,seq:_o()}})}function B3({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 hk=new Map;function xN(e,t,n=""){const{sock:r}=e;if(!r)return Promise.resolve("not connected to the daemon");const o=_o();return new Promise(s=>{hk.set(o,a=>{a.ok?(Dn(e,{...t,view:Ri(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 U3(e){const t=hk.get(e.seq);return t?(hk.delete(e.seq),t(e),!0):!1}function H3({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},h){const{sock:f,dispatch:m}=h,g=bN(t,a).filter(_=>_!==s).map(_=>({id:`view:${_}`,label:`view ${_}`,onClick:()=>s?m({a:"editor-view",v:_}):Dn(h,{worktreeId:e.id,path:t,view:_,ref:r,since:o})})),y=`${e.dir}/${t}`,w=c?[]:Uo(()=>f==null?void 0:f.send({t:"reveal",worktreeId:e.id,path:t}),mo(f));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(EN([t]))&&(f==null||f.send({t:"discard-files",worktreeId:e.id,paths:[t]}))}}]:[]])}function EN(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 To=(e,t,n)=>e.dispatch({a:"notice",id:t,text:n});function ip(e,t,n){var o;const r=iI(((o=e.getState().local[t])==null?void 0:o.attachments)??[],n);return r===0&&To(e,t,cw(n)),r}const W3=1e3,K3=1e4,SN=new WeakMap;function q3(e,t){SN.set(e,t)}async function _N(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 N;return(N=Object.entries(e.getState().local).find(([,x])=>x.attachments.some(_=>_.key===n.key)))==null?void 0:N[0]},c=SN.get(e);let u=-1;const h=N=>{const x=Math.min(99,Math.floor(N*100)),_=a();x===u||_===void 0||(u=x,e.dispatch({a:"upload-progress",id:_,key:n.key,progress:x}))},f=()=>(u=-1,c?FD(c,n.kind,r,h):Promise.resolve(null));let m=await f();const g=m===null;g&&To(e,a()??t,`${n.name}: Toyon is not answering; it attaches once it is back`);for(let N=W3;m===null&&a()!==void 0;N=Math.min(N*2,K3))await new Promise(x=>setTimeout(x,N)),a()!==void 0&&(m=await f());const y=a();if(!(m===null||y===void 0))if(typeof m=="string")e.dispatch({a:"detach",id:y,key:n.key}),To(e,y,`${n.name}: ${m}`);else{const N=s.kind==="file"?{...s,...m}:{...s,upload:m.upload,bytes:m.bytes};e.dispatch({a:"attached",id:y,key:n.key,item:N});const x=(v=e.getState().local[((w=ps(y))==null?void 0:w.source)??y])==null?void 0:v.notice;g&&(x!=null&&x.startsWith(`${n.name}: Toyon is not answering`))&&To(e,y,"")}o&&URL.revokeObjectURL(o)}function ty(e,t,n){if(!t||n.length===0)return;const r=ip(e,t,"file");if(r!==0){for(const o of n.slice(0,r)){const s=o.name||"file";if(o.size>Ub){To(e,t,`${s}: larger than ${dw(Ub)}`);continue}const a={kind:"file",key:crypto.randomUUID(),upload:"",name:s,bytes:o.size,text:!1};_N(e,t,a,o)}n.length>r&&To(e,t,`kept ${r} of ${n.length}: ${cw("file")}`)}}function ny(e,t,n,r={}){if(!t)return;const o=NP(r.source?n.replace(/\r?\n$/,""):n);if(o.length>wP)return r.source?To(e,t,"that paste is too large; save it in the worktree and reference it with @path"):ty(e,t,[new File([o],yP,{type:"text/plain"})]);ip(e,t,"paste")!==0&&e.dispatch({a:"attach",id:t,items:[{kind:"paste",key:crypto.randomUUID(),text:o,...r,...xw(o)}]})}function NN(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=qt(n,n.activeId),o=Oa(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:h,startLine:f,endLine:m,ref:g}=t.source;return((y=u.source)==null?void 0:y.path)===h&&u.source.startLine===f&&u.source.endLine===m&&u.source.ref===g})||ny(e,o,t.text,a)}e.dispatch(t?{a:"focus-chat"}:C_(n))}function ry(e,t){return t!==e.activeId?null:Oa(qt(e,t))}const TN=(e,t)=>`@${e}${t?"/":""}`,oy=e=>`${e.map(t=>TN(t.path,t.folder)).join(" ")} `;function jN(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 $N(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:jN(r,r.length,n).text}),e.dispatch({a:"focus-chat"})}function sy(e,t,n){const r=ry(e.getState(),t);r&&$N(e,r,n)}function Z3(e,t,n,r){sy(e,t,oy([{path:n,folder:r}]))}function G3(e,t,n){n.length!==0&&sy(e,t,oy(n.map(r=>({path:r,folder:!1}))))}function bx(e,t,n){sy(e,t,n)}function V3(e,t){return qt(e,t)?t:null}function Y3(e,t){var r;const n=(r=qt(e,t))==null?void 0:r.worktree;return n?[n.path]:[]}function xx(e,t){if(!e)return e;const n=t.find(r=>e.startsWith(`${r}/`));return n?e.slice(n.length+1):e}function X3(e,t,n){var g;e.dispatch({a:"set-picking",v:!1});const r=e.getState(),o=V3(r,t);if(!o)return;const{classes:s,route:a,element:c,...u}=n,h=Y3(r,t),f={...u,file:xx(u.file,h),callFile:xx(u.callFile,h)};!(((g=r.local[o])==null?void 0:g.attachments)??[]).some(y=>y.kind==="pick"&&y.selector===f.selector)&&ip(e,o,"pick")>0&&e.dispatch({a:"attach",id:o,items:[{kind:"pick",key:crypto.randomUUID(),...f}]}),e.dispatch({a:"focus-chat"})}function Q3(e,t=[],n=[]){const r={path:"",name:"",kind:"folder",children:[],ignored:!1},o=new Map([["",r]]),s=u=>{const h=o.get(u);if(h)return h;const f=u.lastIndexOf("/"),m={path:u,name:u.slice(f+1),kind:"folder",children:[],ignored:!1};return s(f===-1?"":u.slice(0,f)).children.push(m),o.set(u,m),m},a=(u,h,f=!1)=>{const m=u.lastIndexOf("/");s(m===-1?"":u.slice(0,m)).children.push({path:u,name:u.slice(m+1),kind:h,children:[],ignored:f})};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 h=f=>f.kind==="file"?1:0;u.children.sort((f,m)=>h(f)-h(m)||y_(f.name,m.name));for(const f of u.children)f.kind==="folder"&&c(f)};return c(r),r.children}function J3(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 CN=e=>{const t=e.lastIndexOf("/");return t===-1?"":e.slice(0,t)};function e6(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 t6(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 AN(e){const t=e.findLast(n=>n.kind==="handoff"&&n.state!=="declined");return(t==null?void 0:t.kind)==="handoff"?t:null}function n6(e){return!!e.plan&&!e.companion}function zi(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 IN(e){const t={worktrees:0,queued:0,sent:0,here:0,skipped:0};for(const n of e.pieces){const r=zi(e,n);r==="worktree"?n.after?t.queued++:t.worktrees++:r==="send"?t.sent++:r==="here"?t.here++:t.skipped++}return t}const RN=(e,t,n=`${t}s`)=>`${e} ${e===1?t:n}`,r6=e=>e.length<=1?e[0]??"":`${e.slice(0,-1).join(", ")} and ${e.at(-1)}`;function o6(e,t){const n=IN(e),r=[];if(n.here&&r.push("this plan here"),n.worktrees&&r.push(`${RN(n.worktrees,"worktree")} now`),n.queued){const s=e.pieces.filter(u=>zi(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 ${r6(r)}${o}.`}function pk(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=IN(e),o=[n.worktrees?`start ${RN(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 ON(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 s6(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 i6(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 a6(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=ON(e,n).find(a=>a.fate===zi(e,n)))==null?void 0:s.label:void 0)??"go";return t.note?`${o}
108
- ${t.note}`:o}function Ex(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 MN(e,t,n,r){return{t:"handoff-fate",worktreeId:t,id:e.id,pieceId:n,fate:r}}function l6(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 Eu=e=>e.state==="held"||e.state==="proposed";function LN(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 c6(e,t){const n=Zu(e,t),r=n?{word:`after ${n.title}`}:null;if(Eu(e)){const s=zi(e,t);return s==="worktree"?{word:t.after?"queued":"worktree"}:s==="send"?{word:"sent"}:s==="here"&&r?r:{word:s}}const o=Su(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 u6(e,t,n){if(n||Eu(e))return!0;const r=Su(e,t);return r.kind==="here"?!!t.after:r.kind!=="skipped"&&r.kind!=="starting"}function Su(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 d6(e,t){var o;if(t)return"plan";const n=LN(e),r=Eu(e)?void 0:n.find(s=>zi(e,s)==="here");return(r==null?void 0:r.id)??((o=n[0])==null?void 0:o.id)??"plan"}function f6(e){if(e.state!=="done")return[];const t=new Map;for(const n of e.pieces){const r=n.after;if(!r||zi(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?Su(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 iy(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 h6(e){const t=e?iy(e.chat):null;return(t==null?void 0:t.kind)!=="ask"||t.ask.kind!=="question"||(e==null?void 0:e.cardParked)===t.id?null:Ll(t.id)}function p6(e){return e.kind==="ask"?s4(e):pk(e)}const PN=new Set(mP),m6=/^image\.[a-z0-9]+$/i,g6=e=>m6.test(e.name),k6=(e,t)=>e===t||e.name===t.name&&e.size===t.size&&e.type===t.type&&e.lastModified===t.lastModified;function w6(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=>k6(a,s))||n.push(s);const r=n.filter(s=>!g6(s));if(r.length>0)return r;const o=n.find(s=>PN.has(s.type))??n[0];return o?[o]:[]}function y6(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 v6(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 b6(e){try{return await createImageBitmap(e)}catch{throw new Error(`${e.name||"image"}: not a readable image`)}}function Sx(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 x6(e){const t=await b6(e);try{const n=Math.max(t.width,t.height);let r=e,o=e.type,s=t.width,a=t.height;if(!PN.has(o)||n>Bb||e.size>ag){const c=o==="image/jpeg"?"image/jpeg":"image/png";let u=Math.min(1,Bb/n);for(r=await Sx(t,u,c);r.size>ag&&u>.1;)u*=.7,r=await Sx(t,u,c);if(r.size>ag)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 du={el:null},E6=80,S6=2e3;let jo=null,mk;const DN=(e,t)=>{clearTimeout(mk),mk=setTimeout(()=>ly(e),t)};function ay(e,t){jo??(jo={refused:!1}),e.dispatch({a:"drag-files",v:jo.refused?null:t}),DN(e,S6)}function zN(e){jo&&DN(e,E6)}const _6=()=>(jo==null?void 0:jo.refused)??!1;function ly(e){jo&&(clearTimeout(mk),jo=null,e.dispatch({a:"drag-files",v:null}))}function N6(e){jo&&(jo.refused=!0,e.dispatch({a:"drag-files",v:null}))}let T6=0;function j6(e){const{blob:t,...n}=e;return{kind:"image",key:`img${++T6}`,...n,upload:"",bytes:t.size,local:URL.createObjectURL(t)}}async function ap(e,t,n){var a;if(!t||n.length===0)return;const r=ip(e,t,"image");if(r===0)return;const o=await Promise.allSettled(n.slice(0,r).map(x6));for(const c of o)c.status==="fulfilled"&&_N(e,t,j6(c.value),c.value.blob);const s=o.find(c=>c.status==="rejected");s?To(e,t,String(((a=s.reason)==null?void 0:a.message)??s.reason)):n.length>r&&To(e,t,`kept ${r} of ${n.length}: ${cw("image")}`)}function $6(e,t,n){n.kind==="image"?ap(e,t,[new File([n.blob],"image.png",{type:n.blob.type})]):ny(e,t,n.text),hN()}function ch(e,t,n){const r=o=>o.type.startsWith("image/");ap(e,t,n.filter(r)),ty(e,t,n.filter(o=>!r(o)))}function FN(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 Pa(e){const t=e.getState();if(t.newProject)return Kl;const n=Bo(t)??Hw(t);if(n)return n.id;const r=qt(t,t.activeId);return h6(r?t.local[r.worktree.id]:void 0)??Oa(r)}function BN(e,t,n=Pa(e)){ch(e,n,t.filter(o=>!o.folder).map(o=>o.file));const r=t.find(o=>o.folder);n&&r&&To(e,n,`${r.file.name}: a folder cannot be attached; drop its files`)}const gk=Promise.resolve(null);function C6(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))??gk;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:gk});return t}const A6=e=>e.map(t=>({file:t,handle:gk}));async function UN(e){const t=rh*4;if(e.size>t)return{text:"",tooLarge:!0};const n=await v6(e,t);return n===null?null:n.length>rh?{text:"",tooLarge:!0}:{text:n,tooLarge:!1}}async function I6(e,t){const n=Pa(e),r=e.getState().activeId,o=f=>n&&To(e,n,f),s=t.filter(f=>f.file.type.startsWith("image/")).map(f=>f.file);s.length&&ap(e,n,s);const a=t.filter(f=>!f.file.type.startsWith("image/")),c=a[0];if(!c||!r)return;const u=await UN(c.file);if(!u)return void o(`${c.file.name}: not a text file`);const h=await c.handle;e.dispatch({a:"open-loose",v:{worktreeId:r,name:c.file.name,...u,binary:!1,source:h?{kind:"handle",handle:h}:{kind:"bytes"},seq:_o()}}),a.length>1&&o(`opened ${c.file.name}; one file opens at a time`)}async function R6(e,t,n,r){const o=ry(e.getState(),n.worktreeId)??Pa(e),s=c=>o&&To(e,o,c),a={sock:t,dispatch:c=>e.dispatch(c)};for(const{file:c}of r){const u=await UN(c);if(!u){s(`${c.name}: not a text file`);continue}if(u.tooLarge){s(`${c.name}: too large to add here`);continue}const h=n.dir?`${n.dir}/${c.name}`:c.name,f=await xN(a,{worktreeId:n.worktreeId,path:h},u.text);f&&s(`${c.name}: ${f}`)}}function O6(e){const t=Pa(e);t&&To(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 HN(e,t,n,r){const o=(jo==null?void 0:jo.refused)??!1;ly(e),!(o||r.length===0)&&(n?n.at==="chat"||n.at==="centre"&&e.getState().newProject?BN(e,r):n.at==="centre"?I6(e,r):n.at==="rail"?M6(e,n,r):R6(e,t,n,r):O6(e))}function M6(e,t,n){const r=qt(e.getState(),t.worktreeId);r&&(e.dispatch(jr(r.worktree)?{a:"open-draft"}:{a:"activate",id:r.worktree.id}),BN(e,n,Oa(r)))}const kk=e=>!!e&&Array.from(e.types).includes("Files");function _x(e,t){var c,u;const n=t instanceof Element?t:t instanceof Node?t.parentElement:null;if(!n)return null;if((c=du.el)!=null&&c.contains(n))return Pa(e)?{at:"chat"}:null;const r=(u=n.closest(".rail [data-wt]"))==null?void 0:u.dataset.wt;if(r)return qt(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 h=n.closest("[data-path]"),f=h==null?void 0:h.dataset.kind;if(f==="submodule")return null;const m=(h==null?void 0:h.dataset.path)??"";return{at:"tree",worktreeId:s,dir:f==="file"?CN(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 L6(){const e=zn(),t=Qe();S.useEffect(()=>{const n=a=>{a.defaultPrevented||!kk(a.dataTransfer)||(a.preventDefault(),ay(e,_x(e,a.target)),a.dataTransfer&&(a.dataTransfer.dropEffect=e.getState().dragFiles?"copy":"none"))},r=a=>{a.defaultPrevented||!kk(a.dataTransfer)||(a.preventDefault(),HN(e,t,_x(e,a.target),C6(a.dataTransfer)))},o=()=>zN(e),s=a=>{a.key==="Escape"&&N6(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 WN(e,t,n){const r=zn(),o=S.useRef(!1);return{onPaste:u=>{_3();const h=w6(u.clipboardData);if(h.length>0)return u.preventDefault(),void ap(r,e,h);const f=y6(u.clipboardData);if(f.length>0)return u.preventDefault(),ty(r,e,f);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()?j3(u.clipboardData,t):null;!(g&&m.includes(`
109
- `))&&!qS(m)||(u.preventDefault(),ny(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 P6(e,t,n){const r=S.useRef(n);r.current=n,S.useEffect(()=>{const o=e.current;if(!o)return;const s=a=>{const{inputType:c,data:u,isComposing:h}=a;a.target!==t.current||h||!u||c!=="insertText"&&c!=="insertFromPaste"||r.current(u)&&a.preventDefault()};return o.addEventListener("beforeinput",s),()=>o.removeEventListener("beforeinput",s)},[e,t])}const D6=640,z6=1e3,KN=`(max-width: ${D6}px), ((hover: none) and (max-width: ${z6}px))`,qN="(hover: none)",cy=()=>{var e;return(e=window.matchMedia)!=null&&e.call(window,KN).matches?"phone":"desk"},F6=()=>{var e;return((e=window.matchMedia)==null?void 0:e.call(window,qN).matches)??!1},ZN=()=>window.top!==window;function B6(e){const t=(o,s)=>{var u;const a=(u=window.matchMedia)==null?void 0:u.call(window,o);if(!a)return()=>{};const c=h=>s(h.matches);return a.addEventListener("change",c),()=>a.removeEventListener("change",c)},n=t(KN,o=>e.dispatch({a:"frame",v:o?"phone":"desk"})),r=t(qN,o=>e.dispatch({a:"touch",v:o}));return()=>{n(),r()}}const GN=(e,t)=>{const n=e.indexOf("#"),[r,o]=n===-1?[e,""]:[e.slice(0,n),e.slice(n)];return`${r}${r.includes("?")?"&":"?"}${AI}=${encodeURIComponent(t)}${o}`},wk=(e,t)=>!e.serving&&t!==null,U6=3e3;function VN(e,t,n){const[r,o]=S.useState(()=>new Map),s=S.useRef(new Set),a=S.useRef(t);a.current=t;const c=S.useRef(new Map),u=S.useCallback((h,f)=>{s.current.has(h)||(s.current.add(h),a_(e.sock.urls).then(m=>{if(s.current.delete(h),!!a.current.some(y=>y.id===h&&y.url===f)){if(!m){c.current.set(h,setTimeout(()=>{c.current.delete(h),a.current.some(y=>y.id===h&&y.url===f)&&u(h,f)},U6));return}o(y=>new Map(y).set(h,{url:f,src:GN(f,m.code)}))}}))},[e]);return S.useEffect(()=>{const h=c.current;return()=>{for(const f of h.values())clearTimeout(f);h.clear()}},[]),S.useEffect(()=>{var f;if(!n)return;for(const m of t)((f=r.get(m.id))==null?void 0:f.url)!==m.url&&u(m.id,m.url);const h=new Set(t.map(m=>m.id));[...r.keys()].some(m=>!h.has(m))&&o(m=>new Map([...m].filter(([g])=>h.has(g))))},[n,t,r,u]),{urlOf:h=>{var f,m;return n?((f=r.get(h))==null?void 0:f.src)??null:((m=t.find(g=>g.id===h))==null?void 0:m.url)??null},renew:h=>{const f=t.find(m=>m.id===h);!f||!n||(o(m=>{const g=new Map(m);return g.delete(h),g}),u(h,f.url))}}}function H6(e,t,n){var o;const r=S.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}]),VN(e,r.current,n).urlOf("one")}function W6(e,t,n){if(!n){window.open(t,"_blank");return}const r=window.open("","_blank");a_(e.sock.urls).then(o=>{const s=o?GN(t,o.code):t;r?r.location.href=s:window.open(s,"_blank")})}function Ke(...e){return e.filter(Boolean).join(" ")}const K6={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",layers:"M6 2.5h7.5V10 M2.5 6h8v7.5h-8z",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",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 mt({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:K6[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 q6='button, a[href], input, textarea, select, summary, label, [role="button"], [role="menuitem"]';function Nx(e){var n;const t=e;return((n=t==null?void 0:t.closest)==null?void 0:n.call(t,q6))??t??null}function Z6(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 G6(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 V6(e,t){const n=new Set;for(const r of e)if(Z6(r,t))for(let o=r;o;o=o.parent)n.add(o);return e.filter(r=>!n.has(r)&&r.dismiss).reverse()}const Y6=e=>{setTimeout(e,0)};function X6({schedule:e=Y6}={}){let t=[],n=null,r=!1;const o=new Set,s=()=>{for(const c of[...o])c()},a=c=>{var u;for(const h of[...t].reverse())(u=h.dismiss)==null||u.call(h,c)};return{register(c){const u=c.trigger??(c.from===void 0?n:null),h={box:c.box,trigger:u,parent:G6(t,c.from??u),dismiss:c.dismiss,onKey:c.onKey,back:c.back};return t=[...t,h],s(),h},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,h=v=>{var _;const N=v.target,x=N?V6(t,N):[];for(const j of x)(_=j.dismiss)==null||_.call(j,"outside");r=x.length>0&&v.pointerType==="touch",r&&v.preventDefault(),n=Nx(v.target)},f=()=>e(()=>n=null),m=()=>{r=!1,f()},g=v=>{if(r){r=!1,v.preventDefault(),v.stopPropagation();return}n||(n=Nx(v.target),f())},y=v=>{var x;const N=t[t.length-1];(x=N==null?void 0:N.onKey)==null||x.call(N,v)},w=()=>e(()=>{var v;((v=u.activeElement)==null?void 0:v.tagName)==="IFRAME"&&a("frame")});return u.addEventListener("pointerdown",h,!0),u.addEventListener("pointerup",f,!0),u.addEventListener("pointercancel",m,!0),u.addEventListener("click",g,!0),c.addEventListener("keydown",y,!0),c.addEventListener("blur",w),()=>{u.removeEventListener("pointerdown",h,!0),u.removeEventListener("pointerup",f,!0),u.removeEventListener("pointercancel",m,!0),u.removeEventListener("click",g,!0),c.removeEventListener("keydown",y,!0),c.removeEventListener("blur",w)}}}}const Vl=X6(),Q6=()=>Vl.open().some(e=>!!e.dismiss);function J6(){return S.useSyncExternalStore(Vl.watch,Q6,()=>!1)}const pg=typeof HTMLElement<"u"&&"showPopover"in HTMLElement.prototype,Tx=e=>(e==null?void 0:e.getBoundingClientRect())??null;function e5(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 Hs({className:e,anchor:t,placement:n,coverBy:r,track:o=t==="parent",raiseKey:s,onDismiss:a,onKey:c,onBack:u,trigger:h,from:f,boxRef:m,handle:g,children:y,...w}){const v=S.useRef(null),N=S.useRef({anchor:t,placement:n,coverBy:r,onDismiss:a,onKey:c,onBack:u,trigger:h,from:f});N.current={anchor:t,placement:n,coverBy:r,onDismiss:a,onKey:c,onBack:u,trigger:h,from:f};const x=S.useCallback(()=>{const j=v.current,{anchor:T,placement:I,coverBy:R}=N.current;if(!j||!T||!I)return;const C=T==="parent"?Tx(j.parentElement):T();if(!C)return;const O=$3(C,I);O!==void 0&&(j.style.width=`${O}px`);for(let A=0;A<2;A++){const D=R?e5(j,R,j.dataset.side??"",j.dataset.align??""):null,B=A3(C,{w:j.offsetWidth,h:j.offsetHeight},{w:window.innerWidth,h:window.innerHeight},D?{...I,...D}:I);j.style.left=`${B.x}px`,j.style.top=`${B.y}px`;const W=j.dataset.side!==B.side||j.dataset.align!==B.align;if(j.dataset.side=B.side,j.dataset.align=B.align,!W)break}},[]);S.useImperativeHandle(g,()=>({update:x}),[x]),S.useLayoutEffect(()=>{const j=v.current;if(!j)return;m&&(m.current=j),pg&&(j.popover="manual",j.matches(":popover-open")||j.showPopover());const{onDismiss:T,onKey:I,onBack:R,trigger:C,from:O}=N.current,A=T||I?Vl.register({box:j,trigger:C,from:O,dismiss:T?D=>{var B,W;return(W=(B=N.current).onDismiss)==null?void 0:W.call(B,D)}:void 0,onKey:I?D=>{var B,W;return(W=(B=N.current).onKey)==null?void 0:W.call(B,D)}:void 0,back:R?()=>{var D,B;return(B=(D=N.current).onBack)==null?void 0:B.call(D)}:void 0}):null;return()=>{A&&Vl.unregister(A),m&&(m.current=null),pg&&j.isConnected&&j.matches(":popover-open")&&j.hidePopover()}},[m]),S.useLayoutEffect(x),S.useLayoutEffect(()=>{if(!o)return;let j=0,T="";const I=()=>{const R=v.current,{anchor:C}=N.current,O=R&&C?C==="parent"?Tx(R.parentElement):C():null;if(R&&O){const A=`${O.left},${O.top},${O.right},${O.bottom},${R.offsetWidth},${R.offsetHeight},${window.innerWidth},${window.innerHeight}`;A!==T&&(T=A,x())}j=requestAnimationFrame(I)};return j=requestAnimationFrame(I),()=>cancelAnimationFrame(j)},[o,x]);const _=S.useRef(!0);return it([s],()=>{if(_.current){_.current=!1;return}const j=v.current;!pg||!(j!=null&&j.matches(":popover-open"))||(j.hidePopover(),j.showPopover(),x())}),d.jsx("div",{ref:v,className:Ke("float",e),...w,children:y})}const t5=/^[⌘⇧⌥⌃]+/;function ts({k:e,chip:t=!1,className:n}){var a;const r=(a=e.match(t5))==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:h}={}){const f=c?`${e}: ${c}`:e,m=(Array.isArray(o)?o:[o]).filter(y=>!!y),g=[f,...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":h==null?void 0:h.text,"data-tip-also-key":h==null?void 0:h.key,"aria-label":t?`${g} (${t})`:g}}const n5=120,r5=600,o5=150,jx=6,s5=18,mg=8;function $x(e){const t=e.dataset.tipPlacement;return t==="follow"||t==="top"||t==="bottom"||t==="left"||t==="right"?t:"bottom"}function i5(e){const t=e.dataset.tipAlign;return t==="start"||t==="center"||t==="end"?t:void 0}function YN(e,t){return e==="follow"?{side:"bottom",align:"start",offset:s5,alignOffset:-12,flip:"both",margin:mg}:e==="left"||e==="right"?{side:e,align:t??"start",offset:jx,flip:"both",margin:mg}:{side:e,align:t??"center",offset:jx,flip:"both",margin:mg}}function a5(e,t){return e.placement==="follow"?mN(t):e.el.getBoundingClientRect()}function XN(){var u;const[e,t]=S.useState(null),n=S.useRef(null),r=S.useRef(null),o=S.useRef({x:0,y:0}),s=Di();if(S.useEffect(()=>{if(s)return;let h=0,f=0,m=null,g=!1,y=0;const w=()=>{window.clearTimeout(h),window.clearTimeout(f)},v=()=>{w(),g&&(y=Date.now()),g=!1,m=null,t(null)},N=(O,A)=>{var B,W;const D=O.dataset.tip;if(!D)return v();w(),g=!0,t({el:O,text:D,key:O.dataset.tipKey,detail:(B=O.dataset.tipDetail)==null?void 0:B.split(`
112
- `),card:O.dataset.tipCard!==void 0,dot:O.dataset.tipDot,name:O.dataset.tipName,aside:(W=O.dataset.tipAside)==null?void 0:W.split(`
113
- `),also:O.dataset.tipAlso&&O.dataset.tipAlsoKey?{text:O.dataset.tipAlso,key:O.dataset.tipAlsoKey}:void 0,placement:A,align:i5(O)})},x=O=>{const A=O.target;if(!(A instanceof Element))return null;const D=A.closest("[data-tip], .float");return(D==null?void 0:D.dataset.tip)!==void 0?D:null},_=O=>{o.current={x:O.clientX,y:O.clientY};const A=x(O);if(A===m)return;if(w(),m=A,!A){g&&(f=window.setTimeout(v,o5));return}const D=$x(A);if(g||Date.now()-y<r5)return N(A,D);h=window.setTimeout(()=>N(A,D),n5)},j=O=>{O.relatedTarget||v()},T=O=>{const A=x(O);if(A!=null&&A.matches(":focus-visible")){w(),m=A;const D=$x(A);N(A,D==="follow"?"bottom":D)}},I=()=>v(),R=O=>{O.key!=="Shift"&&O.key!=="Control"&&O.key!=="Alt"&&O.key!=="Meta"&&v()},C=O=>{m&&O.target instanceof Node&&O.target.contains(m)&&v()};return document.addEventListener("mouseover",_),document.addEventListener("mouseout",j),document.addEventListener("mousedown",v),document.addEventListener("keydown",R),document.addEventListener("scroll",C,!0),document.addEventListener("focusin",T),document.addEventListener("focusout",I),window.addEventListener("blur",v),()=>{w(),document.removeEventListener("mouseover",_),document.removeEventListener("mouseout",j),document.removeEventListener("mousedown",v),document.removeEventListener("keydown",R),document.removeEventListener("scroll",C,!0),document.removeEventListener("focusin",T),document.removeEventListener("focusout",I),window.removeEventListener("blur",v)}},[s]),S.useLayoutEffect(()=>{e&&!e.el.isConnected&&t(null)},[e]),S.useEffect(()=>{if((e==null?void 0:e.placement)!=="follow")return;const h=f=>{var m;o.current={x:f.clientX,y:f.clientY},(m=r.current)==null||m.update()};return document.addEventListener("mousemove",h),()=>document.removeEventListener("mousemove",h)},[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(ts,{k:e.key,className:"tooltip-key"})]});return d.jsxs(Hs,{className:Ke("tooltip",e.card&&"tooltip-card"),role:"tooltip",boxRef:n,handle:r,anchor:()=>a5(e,o.current),placement:YN(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(ts,{k:e.key,className:"tooltip-key"}):d.jsx("span",{}),d.jsx("span",{className:"tooltip-also",children:e.also.text}),d.jsx(ts,{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((h,f)=>d.jsx("div",{className:"tooltip-detail",children:h},f)),e.aside&&d.jsx("div",{className:"tooltip-foot",children:e.aside.map(h=>d.jsx("span",{children:h},h))})]})}const l5={sm:"",md:"btn-md",lg:"btn-lg"},c5={ghost:"",outline:"btn-outline",field:"btn-outline btn-field",inline:"btn-inline"},QN={primary:"tone-primary",quiet:"tone-quiet",danger:"tone-danger",strong:"tone-strong",chrome:"tone-chrome"};function Pe({variant:e="ghost",size:t="sm",tone:n,on:r,mono:o,busy:s,className:a,type:c="button",disabled:u,children:h,...f}){const m=Ke("btn",c5[e],l5[t],n&&QN[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,...f,children:[s&&d.jsx(uh,{}),h]})}function It({icon:e,label:t,hint:n,detail:r,also:o,placement:s,tipAlign:a,silent:c,badge:u,tone:h,on:f,className:m,type:g="button",...y}){const w=Ke("btn-icon",h&&QN[h],f&&"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(mt,{name:e}):e,u]})}function Gu(e,t,n){return n===0?0:(e+t+n)%n}function Cx(e,t,n){return e>=0?Gu(e,t,n):n===0?-1:t>0?0:n-1}function JN(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 gg(e,t){return e&&e.length>t.length&&e.toLowerCase().startsWith(t.toLowerCase())?e.slice(t.length):null}function u5(e,t){if(e==null)return null;if(typeof e=="string"){const o=gg(e,t);return o?{text:o,accept:o,params:[]}:null}const n=gg(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:gg(e.accept,t),params:r}}function eT(e){const{results:t,keyOf:n,q:r,onPick:o,listRef:s,onActive:a,onSide:c,completionOf:u,narrowTo:h,setQ:f,tabPicks:m,onIdlePick:g}=e,[y,w]=S.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,N=S.useRef(a);N.current=a,it([v],()=>{var R,C,O;(C=(R=s.current)==null?void 0:R.querySelector('.picker-item[data-state~="cursor"]'))==null||C.scrollIntoView({block:"nearest"}),(O=N.current)==null||O.call(N,y>=0?t[y]??null:null)});const x=y<0?-1:Math.min(y,Math.max(0,t.length-1)),_=x>=0?t[x]??null:null,j=_?u5(u==null?void 0:u(_,r),r):null,T=R=>{const C=h==null?void 0:h(R,r);if(C==null)return o(R,r);f==null||f(C),w(0)};return{index:x,active:_,ghost:j,setIndex:w,pick:T,onKeyDown:R=>{if(R.key==="ArrowDown")R.preventDefault(),w(Cx(x,1,t.length));else if(R.key==="ArrowUp")R.preventDefault(),w(Cx(x,-1,t.length));else if((R.key==="ArrowLeft"||R.key==="ArrowRight")&&c&&_)R.preventDefault(),c(_,R.key==="ArrowLeft"?-1:1);else if(R.key==="Tab"&&(j!=null&&j.accept))R.preventDefault(),f==null||f(r+j.accept),w(0);else if(R.key==="Tab"&&m&&_)R.preventDefault(),T(_);else if(R.key==="Enter"&&_)R.preventDefault(),T(_);else if(R.key==="Enter"&&x<0&&g)R.preventDefault(),g(r);else return!1;return!0}}}function hr(e){const t=Object.keys(e).filter(n=>e[n]);return t.length>0?t.join(" "):void 0}const d5=new Set(["Shift","Meta","Control","Alt","CapsLock","Fn"]);function tT(){const e=ey(),t=zn();return S.useEffect(()=>{if(!e)return;const n=()=>{e.target.isConnected||ho.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(f5,{spec:e},e.id):null}function f5({spec:e}){const t=e.items,n=t.filter(ms),[r,o]=S.useState(-1),s=S.useRef({idx:r,items:n});s.current={idx:r,items:n};const a=S.useRef(null),c=m=>{var g,y;{const w=()=>ho.close(),{idx:v,items:N}=s.current;if(d5.has(m.key))return;if(m.key==="ArrowDown"||m.key==="ArrowUp"){m.preventDefault(),m.stopPropagation();const x=m.key==="ArrowDown"?1:-1;o(I3(N,v,x));return}if((m.key==="Enter"||m.key===" ")&&v>=0&&N[v]&&!N[v].disabled){m.preventDefault(),m.stopPropagation(),N[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"))??[],j=>j.textContent??""),_=JN(x,v,m.key);_>=0&&!((y=N[_])!=null&&y.disabled)&&o(_);return}w()}};S.useEffect(()=>{const m=()=>ho.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:h}=M3(e),f=n.some(m=>m.checked);return d.jsxs(Hs,{className:Ke("menu",e.head!==void 0&&"menu-headed"),role:"menu",boxRef:a,anchor:()=>u,placement:h,track:!1,from:e.target,trigger:e.toggles?e.target:null,onDismiss:()=>ho.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(!ms(m))return d.jsx("hr",{className:"menu-sep"},`sep-${g}`);const y=n.indexOf(m);return d.jsx(h5,{item:m,gutter:f,cursor:y===r,onEnter:()=>o(y)},m.id)})]})}function h5({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":hr({cursor:n,checked:e.checked}),onMouseMove:o||n?void 0:r,onClick:()=>{o||(e.onClick(),ho.close())},children:[t&&d.jsx("span",{className:"menu-check",children:e.checked&&d.jsx(mt,{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(ts,{k:e.key,className:"menu-key row-dim"})]})}const dh=8,p5=104,m5=.25,nT=220,yk=.5,g5=100;function k5(e,t){return Math.max(0,-rT(e,t))}function rT(e,t){const n=e.filter(a=>t-a.t<=g5);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 w5(e,t,n){return e>0?e:n>0&&t>=yk?1:0}function y5({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 v5(e,t,n=p5){const r=Math.max(0,-e),o=t*n,s=Math.min(t,Math.floor(r/n)),a=r<=o?r:o+(r-o)*m5,c=Math.min(1,r/(n/2));return{step:s,x:-a,well:c}}function oT(e,t){const n=S.useRef(t);n.current=t,S.useEffect(()=>{const r=e.current;if(!r)return;let o=null,s=null,a=!1,c=0,u=[],h=0,f=0;const m=(j,T,I,R)=>{j.el.dataset.slide!==R&&(j.el.dataset.slide=R,j.el.offsetWidth),j.el.style.setProperty("--slide-x",`${T}px`),j.el.style.setProperty("--slide-well",`${Math.round(I*100)}%`)},g=j=>{j.el.style.removeProperty("--slide-x"),j.el.style.removeProperty("--slide-well"),delete j.el.dataset.slide},y=(j=0)=>{var O;const T=o,I=a,R=T?w5(c,j,T.rungs):0,C=R!==c;o=null,s=null,a=!1,c=0,u=[],!(!T||!I)&&(C&&(n.current.onSlide({key:T.key,step:R}),(O=navigator.vibrate)==null||O.call(navigator,8)),m(T,0,0,"settle"),R>0&&n.current.onPick(T.key,R),h=window.setTimeout(()=>{g(T),n.current.onSlide(null)},nT))};let w=null;const v=j=>{if(!j.isPrimary||j.pointerType==="mouse"&&j.button!==0)return y();const T=j.target instanceof Element?n.current.rowOf(j.target):null;!T||T.el.dataset.slide||(window.clearTimeout(h),o=T,w=j.pointerId,s={x:j.clientX,y:j.clientY})},N=j=>{var O;const T=o;if(!T||!s||j.pointerId!==w)return;const I=j.clientX-s.x,R=j.clientY-s.y;if(!a){const A=y5({dx:I,dy:R});if(A==="other"&&(o=null,s=null,w=null),A!=="slide")return;a=!0;try{T.el.setPointerCapture(j.pointerId)}catch{}n.current.onSlide({key:T.key,step:0})}u.push({x:j.clientX,t:j.timeStamp}),u.length>8&&u.shift();const C=v5(I,T.rungs,T.rung);m(T,C.x,C.well,"drag"),C.step!==c&&(c=C.step,n.current.onSlide({key:T.key,step:c}),c>0&&((O=navigator.vibrate)==null||O.call(navigator,8)))},x=j=>{j.pointerId===w&&(a&&(f=j.timeStamp+400),w=null,y(j.type==="pointerup"?k5(u,j.timeStamp):0))},_=j=>{j.timeStamp>=f||(j.preventDefault(),j.stopPropagation())};return r.addEventListener("pointerdown",v),r.addEventListener("pointermove",N),r.addEventListener("pointerup",x),r.addEventListener("pointercancel",x),r.addEventListener("click",_,!0),()=>{window.clearTimeout(h),r.removeEventListener("pointerdown",v),r.removeEventListener("pointermove",N),r.removeEventListener("pointerup",x),r.removeEventListener("pointercancel",x),r.removeEventListener("click",_,!0)}},[e])}const sT=1/3,b5=220;function x5({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 E5(e,t,n){return n==="left"?Math.min(0,Math.max(-t,e)):Math.max(0,Math.min(t,e))}function S5(e,t,n,r){const o=n==="left"?-r:r;return o>=yk?!0:o<=-yk?!1:Math.abs(e)>=t*sT}function _5(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 Ax=-1;function N5(e,t){const n=S.useRef(t);n.current=t;const r=S.useRef(()=>{});return S.useEffect(()=>{const o=e.current;if(!o)return;let s=null,a=null,c=null,u=!1,h=0,f=null,m=null,g=0,y=null,w=[],v=0,N=0;const x=(W,U)=>{const Q=m;Q&&(Q.dataset.swipe!==U&&(Q.dataset.swipe=U,Q.offsetWidth),Q.style.translate=`${W}px`)},_=()=>{const W=m;m=null,W&&(delete W.dataset.swipe,W.offsetWidth,W.style.removeProperty("translate"))},j=()=>{s=null,a=null,c=null,u=!1,f=null,g=0,y=null,w=[]},T=W=>{try{o.setPointerCapture(W.pointerId)}catch{}},I=W=>{var Y,se;const U=f,Q=(m==null?void 0:m.clientWidth)??0;j(),U&&(x(W?U==="left"?-Q:Q:0,"settle"),(se=(Y=n.current).onSettle)==null||se.call(Y,W),v=window.setTimeout(()=>{ZE.flushSync(()=>n.current.onEnd(W)),_()},b5))},R=W=>{var Q;if(W.pointerType==="mouse")return;if(!W.isPrimary)return f?I(!1):j();if(m||(((Q=window.visualViewport)==null?void 0:Q.scale)??1)>1.01)return;const U=W.target instanceof Element?W.target:null;!U||U.closest("textarea, input, [contenteditable], iframe, .float")||(window.clearTimeout(v),s={x:W.clientX,y:W.clientY},a=U,c=_5(U,o),y=W.pointerId,h=W.clientX)},C=(W,U,Q,Y)=>{if(!s||!a)return;const se=W-s.x,H=U-s.y;if(u&&c){c.scrollLeft-=W-h,h=W;return}if(!f){const $=x5({dx:se,dy:H});if($===null)return;if($==="other")return j();if(c){u=!0,h=W,Y&&T(Y);return}const Z=n.current.take(a,$);if(!Z)return j();m=Z,f=$,Y&&T(Y)}w.push({x:W,t:Q}),w.length>8&&w.shift(),g=E5(se,(m==null?void 0:m.clientWidth)??0,f),x(g,"drag")},O=(W,U)=>{var H;if(!f)return j();const Q=(m==null?void 0:m.clientWidth)??0,Y=U?rT(w,W):0,se=U&&S5(g,Q,f,Y);se&&Math.abs(g)<Q*sT&&((H=navigator.vibrate)==null||H.call(navigator,8)),I(se)},A=W=>{W.pointerId===y&&C(W.clientX,W.clientY,W.timeStamp,W)},D=W=>{W.pointerId===y&&((f||u)&&(N=W.timeStamp+400),O(W.timeStamp,W.type==="pointerup"))};r.current=W=>{const U=performance.now();if(W.phase==="start"){if(m||s)return;s={x:W.x,y:W.y},a=o,c=null,y=Ax;return}if(y===Ax){if(W.phase==="move")return C(W.x+g,W.y,U);O(U,W.phase==="end")}};const B=W=>{W.timeStamp>=N||(W.preventDefault(),W.stopPropagation())};return o.addEventListener("pointerdown",R),o.addEventListener("pointermove",A),o.addEventListener("pointerup",D),o.addEventListener("pointercancel",D),o.addEventListener("click",B,!0),()=>{r.current=()=>{},window.clearTimeout(v),o.removeEventListener("pointerdown",R),o.removeEventListener("pointermove",A),o.removeEventListener("pointerup",D),o.removeEventListener("pointercancel",D),o.removeEventListener("click",B,!0)}},[e]),S.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:h}){const f=xn(h),m=S.useRef(null),g=Math.max(0,e.findIndex(w=>w.id===t)),y=w=>{var x,_;if(w.key!=="ArrowLeft"&&w.key!=="ArrowRight")return;w.preventDefault();const v=e.findIndex(j=>j.id===t),N=e[Gu(v,w.key==="ArrowRight"?1:-1,e.length)];N&&(n(N.id),(_=(x=m.current)==null?void 0:x.querySelectorAll('[role="tab"]')[e.indexOf(N)])==null||_.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":hr({current:v}),...w.menu?f.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 ws({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 iT=e=>`Toyon restarts once ${e.join(", ")} ${e.length===1?"finishes":"finish"}`,T5=(e,t)=>[...e,...t.filter(n=>!e.includes(n))];function j5(e,t,n){const r=[...t],o=[...n],s=(c,u)=>{const h=c.indexOf(u);return h===-1?!1:(c.splice(h,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 $5(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 C5(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:iT(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 vk=!1;function A5(){vk=!0}function _u({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 Ix={title:"Toyon was updated",body:"This page is still running the old build. Reload to pick up the new one."};class uy extends S.Component{constructor(){super(...arguments);Tt(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(_u,{pane:this.props.pane,title:vk?Ix.title:"Toyon hit an error",body:vk?Ix.body:n.message||String(n),action:d.jsx(Pe,{variant:"outline",onClick:()=>window.location.reload(),children:"reload"})}):this.props.children}}const bk={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.`},I5=1e3,Rx={held:[],asking:[],seen:[]};async function Ox(e,t,n){for(;;){await new Promise(s=>setTimeout(s,I5));const[r,o]=await Promise.all([nk(e),o_(e)]);if(r!==null&&r!==t)break;n(o??{waiting:[],asking:[]})}window.location.reload()}function aT({foreign:e}={}){return e?d.jsx(R5,{name:e}):d.jsx(O5,{})}function R5({name:e}){const t=ks(),n=t.list()[0];return d.jsx(_u,{title:`Toyon on ${e} was updated`,body:bk.foreign(e),action:n&&d.jsxs(Pe,{variant:"outline",onClick:()=>t.activate(n.origin),children:["back to ",t.displayName(n.origin)]})})}function O5(){const e=Pr(),[t,n]=S.useState(!0),[r,o]=S.useState(null),[s,a]=S.useState(Rx),c=S.useRef(null),u=S.useCallback(w=>a(v=>({held:w.waiting,asking:w.asking,seen:T5(v.seen,w.waiting)})),[]),h=S.useCallback(async w=>{n(!0),o(null);const v=c.current??{pid:await nk(e)},N=await BD(e,w);if(N){n(c.current!==null),o(N);return}w&&a(Rx),!c.current&&(c.current=v,Ox(e,v.pid,u))},[u,e]);S.useEffect(()=>{let w=!0;return(async()=>{const[v,N]=await Promise.all([nk(e),o_(e)]);if(!(!w||c.current)){if(N===null){h(!1);return}c.current={pid:v},u(N),Ox(e,v,u)}})(),()=>{w=!1}},[u,h,e]);const f=t&&s.held.length>0,m=f?j5(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(_u,{title:bk.title,body:r??(f?$5(g,y):bk.waiting),action:f?d.jsx(Pe,{variant:"outline",onClick:()=>void h(!0),children:"restart now"}):d.jsx(Pe,{variant:"outline",busy:t,onClick:()=>void h(!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 wa=(e,t=!1)=>({text:e,live:t}),M5={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"},L5={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`},P5="no access token for this address.\nrun `toyon` or `toyon open` in your repo to get a signed-in page";function lT(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?wa(L5[e.connectFailure??"probing"](e.machine),t):e.hasToken?wa(M5[e.connectFailure??"probing"],t):wa(P5)}return e.title===null?wa(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 D5(e){const t=lT(e);return t!==null?t:e.needsSetup&&e.busy?wa(`building in ${e.title}; the preview appears once it starts`,!0):e.needsSetup&&e.treeEmpty?wa(`${e.title} is empty so far; say what to build`):e.treeEmpty&&e.landsFrom?wa(`nothing runs on main until ${e.landsFrom} lands`):null}const cn={post:(e,t)=>{},broadcast:e=>{}};function Nu(e,t,n,r){const o=t===r;cn.post(e,o?{type:"pick-cancel"}:{type:"pick-start",verb:r}),n({a:"set-picking",v:o?!1:r})}function cT(e){return[{id:"copy-sha",label:`copy ${e.short}`,onClick:()=>tn(e.sha)},{id:"copy-subject",label:"copy subject",onClick:()=>tn(e.subject)}]}function lp(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 uT="application/x-toyon-mention";let $a=null;const cp=()=>!Di();function z5(e){return e.kind==="worktree"?`@${e.title} `:oy(e.items)}function F5(e){return e.kind==="worktree"?e.branch:e.items.map(t=>t.path).join(" ")}function Tu(e,t){e.dataTransfer.setData(uT,"1"),e.dataTransfer.setData("text/plain",F5(t)),e.dataTransfer.effectAllowed="copy",$a=t}function Yu(e){$a=null,ly(e)}function dT(e,t){const n=e.getState().activeId;return(t.kind==="paths"?t.worktreeId===n:t.worktreeId!==n)?Pa(e):null}const fT=e=>$a!==null&&Array.from(e.dataTransfer.types).includes(uT);function B5(e,t){if(!fT(t)||!$a)return;t.preventDefault();const n=dT(e,$a)!==null;t.dataTransfer.dropEffect=n?"copy":"none",n&&ay(e,{at:"chat"})}function hT(e,t){if(!fT(t)||!$a)return null;t.preventDefault();const n=$a,r=_6();if(Yu(e),r)return null;const o=dT(e,n);return o?{boxId:o,words:z5(n)}:null}function U5(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}function up(e){return e!=null&&e.config.profiles?Object.keys(e.config.profiles):[]}function pT(e,t){const n=up(t);if(n.length!==0)return e.profile&&n.includes(e.profile)?e.profile:t==null?void 0:t.config.defaultProfile}const H5=e=>Xf(Ni((e==null?void 0:e.config)??{}),e==null?void 0:e.defaultBranch).toLowerCase();function $i(e,t,n){t({a:"shipping",id:n.worktreeId,op:n.t}),e==null||e.send(n)}const mT=(e,t)=>tI(e.worktree,{pending:()=>e.agent!=="idle"||(e.queued??0)>0||!!e.shipping,drafted:t,counts:()=>({dirty:e.dirty,ahead:e.ahead})});function Fl(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 gT(e,t,n){t({a:"hold-unread",id:n}),e==null||e.send({t:"mark-unread",worktreeId:n})}function kT(e,t,n){return{rename(r){if(!JE(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()}))},setProfile(r,o){e==null||e.send({t:"set-worktree-profile",worktreeId:r.worktree.id,profile:o})},ownProcs(r){e==null||e.send({t:"own-procs",worktreeId:r.worktree.id})},shareProcs(r){const o=(r.worktree.owns??[]).join(", ");window.confirm(`Stop this worktree's own ${o} and use main's?
118
-
119
- What they hold that main's do not (a database of their own) is not carried over.`)&&(e==null||e.send({t:"share-procs",worktreeId:r.worktree.id}))},archive(r){var a;if(!Ah(r.worktree))return;const o=mT(r,n);if(!o)return Fl(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.`)&&Fl(e,t,[r.worktree.id])}}}function wT(e,t,n,{sock:r,dispatch:o},s){var R,C;const a=e.worktree.id,c=kT(r,o,n.drafted),u=[],h=[],f=[],m=[],g=[],y=[];ns(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"})}}),h.push({id:"copy-branch",label:"copy branch name",onClick:()=>tn(e.worktree.branch)}),h.push(...Uo(()=>r==null?void 0:r.send({t:"reveal",worktreeId:a}),s.hostname)),v||h.push({id:"copy-path",label:"copy path",onClick:()=>tn(e.path)});const{transcript:N,sessionId:x}=e,_=!!N&&!jr(e.worktree);_&&op(s.hostname)&&h.push({id:"reveal-transcript",label:"reveal transcript in Finder",onClick:()=>r==null?void 0:r.send({t:"reveal-transcript",worktreeId:a})});const j=!v&&!!s.palette;j&&_&&h.push({id:"copy-transcript",label:"copy transcript path",onClick:()=>tn(N)}),j&&x&&h.push({id:"copy-session",label:"copy session id",onClick:()=>tn(x)});const T=pT(e.worktree,t);for(const O of Bu(e.worktree)?[]:up(t))g.push({id:`profile:${O}`,label:`run with ${O}`,checked:O===T,onClick:()=>c.setProfile(e,O)});if(!Na(e.worktree)&&((R=e.borrowed)!=null&&R.length)&&g.push({id:"own-procs",label:`run ${e.borrowed.join(", ")} here`,detail:"on main now",onClick:()=>c.ownProcs(e)}),!Na(e.worktree)&&((C=e.worktree.owns)!=null&&C.length)&&g.push({id:"share-procs",label:`use main's ${e.worktree.owns.join(", ")}…`,detail:"runs here now",danger:!0,onClick:()=>c.shareProcs(e)}),JE(e.worktree)&&f.push({id:"rename",label:"rename…",onClick:()=>c.rename(e)}),s.graft&&Df(e.worktree)){const O=s.graft;f.push({id:"graft",label:"graft with…",onClick:()=>O(a)})}f.push({id:"unread",label:"mark as unread",key:Dt("mark-unread"),disabled:e.unseen?"already unread":void 0,onClick:()=>gT(r,o,a)});const I=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(Ih(e)&&(e.behind??0)>0){const O=ns(e.agent)&&(e.dirty??0)>0;m.push({id:"sync",label:`sync from main${O?" after the turn":""} (${e.behind} behind)`,disabled:I,onClick:()=>$i(r,o,{t:"sync-main",worktreeId:a})})}return ma(e.worktree)&&!(e.worktree.landed&&e.dirty===0)&&m.push({id:"land",label:fw(Ni((t==null?void 0:t.config)??{}),e.worktree),detail:H5(t),disabled:I,onClick:()=>$i(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}})}),Ah(e.worktree)&&y.push({id:"archive",label:mT(e,n.drafted)?"archive…":"archive",key:Dt("wt-archive"),danger:!0,onClick:()=>c.archive(e)}),Wn([u,h,f,m,g,y])}function W5(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 Ih(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(...Uo(()=>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 K5={sm:"",md:"field-md",lg:"field-lg"};function yT({size:e="sm",font:t,bare:n,rule:r,className:o}){const s=t??(e==="lg"?"ui":"mono");return Ke("field",K5[e],s==="ui"&&"field-ui",s==="lead"&&"field-lead",n&&"field-bare",r&&"field-rule",o)}const Fo=S.forwardRef(function({size:t,font:n,bare:r,rule:o,className:s,...a},c){return d.jsx("input",{ref:c,className:yT({size:t,font:n,bare:r,rule:o,className:s}),...a})}),ju=S.forwardRef(function({size:t,font:n,bare:r,rule:o,className:s,...a},c){return d.jsx("textarea",{ref:c,className:yT({size:t,font:n,bare:r,rule:o,className:s}),...a})}),eo=e=>/[.!?…]$/.test(e)?e:`${e}.`,vT=160;function dp(e,t=vT){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 dy(e){return e.subjects.length?dp(e.subjects.join("; ")):void 0}function bT(e){const t=dy(e);if(t)return e.pr===void 0?t:dp(`PR #${e.pr}: ${t}`)}function fy(e,t=3){const n=[];for(const a of e??[]){const c=bT(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?eo(c):`${hy(So(fr(a)))}: ${eo(c)}`);return o>0?[`${o} earlier landing${o===1?"":"s"}.`,...s]:s}const q5="checks running",Z5="checks failed",xT="preview up";function G5(e){if(e.state!=="open")return[];const t=[];return(e.checks==="pending"||e.checks==="fail")&&t.push({text:e.checks==="fail"?Z5:q5,url:`${e.url}/checks`,tip:"Open the checks on GitHub",open:"open the checks"}),e.preview&&t.push({text:xT,url:e.preview,tip:`Open the branch on ${new URL(e.preview).hostname}`,open:"open the preview"}),t}function V5(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 Rs(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?`; ${xT}.`:".";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 ET(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 ST(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 hy=e=>`${e.charAt(0).toUpperCase()}${e.slice(1)}`;function py(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 _T(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 Y5(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?`: ${eo(a)}`:"."}`}return py(e,t,n)==="unasked"?Y5(r):null}function Mx(e,t){const n=X5(e,t);return n?eo(hy(n)):""}function X5(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 NT=e=>/^[A-Z][a-z]+(\s|$)/.test(e)?`${e.charAt(0).toLowerCase()}${e.slice(1)}`:e;function Q5(e,t){const n=t??0;return n>0?`${n} behind ${e}; land takes it in first.`:""}function J5(e){return e>0?eo(hy(`${e} ${e===1?"file":"files"} changed`)):""}function eF(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: ${eo(NT(e.why))}`:null}function _f(e){return eo(e)}const So=e=>e==="now"?"just now":`${e} ago`;function tF(e,t,n){switch(e){case"asking":return`Waiting on you${n==="now"?"":` for ${n}`}${t.ask?`: ${eo(t.ask)}`:"."}`;case"failed":return t.auth?`Stopped ${So(n)}: not logged in.`:t.error?`Failed ${So(n)}: ${eo(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 my(e){var n;const t=(n=e.recap)==null?void 0:n.text;return t?eo(t):tF(e.end,e.facts,fr(e.at))}function nF(e){var n;const t=(n=e.recap)==null?void 0:n.text;return t?`Last stop, ${So(fr(e.at))}: ${eo(NT(t))}`:void 0}function $u(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 gy(e){return(e==null?void 0:e.status)==="running"||(e==null?void 0:e.status)==="detached"}function TT(e){const t=e&&e.status!=="terminated"?e.since:void 0,n=Gw(t,Vw);return t!==void 0&&n===t?e:void 0}function jT(e,t){const n=e.stage?[e.stage]:[];switch(e.status){case"queued":return[...n,"queued"];case"running":return[...n,`${ka(t)} of ${vI(e.timeoutMs)}`];case"detached":return[...n,ka(t),"detached"];case"terminated":return[e.why??"stopped"]}}function fh(e,t,n){return[e,...jT(t,n)].join(" · ")}const xk={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 $T(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 rF({active:e,ahead:t,behind:n,unpushed:r,dirty:o}){var nt,at,Xt;const s=Qe(),a=ut(),c=xn("changes"),u=jn(e)?e.worktree:null,h=e.id,f=L(Nt=>{var Zt;return(Zt=Nt.shipping[h])==null?void 0:Zt.op}),m=L(Nt=>{var Zt;return(Zt=Nt.shipping[h])==null?void 0:Zt.step}),g=Gw(m,Vw),y=$u(e,"commit"),w=$u(e,"check"),v=f?y:w,N=TT(v),x=ji(gy(N)?N==null?void 0:N.since:void 0),[_,j]=S.useState("");it([h],()=>j("")),it([o],()=>{o||j("")});const T=S.useRef(null),I=(nt=u==null?void 0:u.landing)!=null&&nt.subject?u.landing.body?`${u.landing.subject}
123
-
124
- ${u.landing.body}`:u.landing.subject:null,R=()=>{_===""&&I&&j(I);const Nt=T.current;Nt&&(Nt.focus(),requestAnimationFrame(()=>Nt.setSelectionRange(Nt.value.length,Nt.value.length)))},C=L(Nt=>Nt.editCommit);it([C],()=>{C&&R()});const O=_.trim()||void 0,A=L(Nt=>{var Zt;return!!((Zt=Nt.agents.find(gt=>gt.id===((u==null?void 0:u.agent)??Nt.defaultAgent)))!=null&&Zt.quick)}),D=u==null?void 0:u.landing,B=O?null:py(D,o?1:0,A),W=(D==null?void 0:D.check)==="pending",U=!!(D!=null&&D.stale),Q=()=>{f||s==null||s.send({t:"judge",worktreeId:h})},Y=()=>{f||!O&&!I||$i(s,a,{t:"commit",worktreeId:h,message:O??I??""})},se=()=>{f||$i(s,a,{t:"land",worktreeId:h,...O?{message:O}:{}})},H=((at=u==null?void 0:u.landing)==null?void 0:at.check)==="fail",$=!!(u!=null&&u.landed)&&!o,Z=u?Mh({...u,landed:$}):void 0,q=(Z==null?void 0:Z.state)==="open",K=q&&(o||r>0),ne=W||U||!!B,de=!!u&&ma(u)&&!$&&(o||t>0)&&!H&&!q&&!ne,pe=!!u&&K&&!H&&!ne,je=!!u&&ma(u)&&!W&&(U||B==="unwritten"||B==="unanswered")&&!ns(e.agent),_e=L(Nt=>Nt.repos.find(Zt=>Zt.id===e.repoId)??null),fe=Ni((_e==null?void 0:_e.config)??{}),te=Xf(fe,_e==null?void 0:_e.defaultBranch),re=fw(fe,u??{}),we=_e?Oh(_e):"main",ue=Ih(e)?b4(we,n):null,le=ns(e.agent),be=o&&!u?"commit or discard the changes here first":void 0,Ce=!!e.syncQueued,Ne=o&&le?`Merge ${we} into this worktree once the turn ends, uncommitted changes kept`:`Merge ${we} into this worktree${o?", uncommitted changes kept":""}`,Ie=q&&!K&&ST(Z),Be=de?re:pe?"update":Ie?"land":(Z==null?void 0:Z.state)==="merged"?"pull":"land",Je=f==="commit"?g??"commit":f==="land"?g?`${Be}: ${g}`:Be:null,zt=Je&&N?fh(Je,N,x):Je,Yt=S.useRef(!1);zt?o&&(Yt.current=!0):Yt.current=!1;const _t=!!u&&(o||Yt.current),qe=_t&&!!zt,xt=f?null:v?N?jT(N,x).join(" · "):null:W?"writing the message":null,ht=N&&(N.status==="running"||N.status==="detached")?N:null,De=ht&&d.jsx(It,{icon:"stop",tone:"danger",label:$T(ht.kind),onClick:()=>s==null?void 0:s.send({t:"run-stop",worktreeId:h,kind:ht.kind})});return d.jsxs("div",{className:"composer commit-box",children:[_t&&d.jsx("div",{className:"composer-field",children:qe?d.jsx("div",{className:"commit-running live-text","data-tip":N?xk[N.status]:void 0,children:zt}):d.jsx(ju,{size:"lg",bare:!0,ref:T,value:_,onChange:Nt=>j(Nt.target.value),onKeyDown:Nt=>{Nt.key==="Enter"&&(Nt.metaKey||Nt.ctrlKey)?(Nt.preventDefault(),Y()):Nt.key==="Tab"&&!Nt.shiftKey&&_===""&&I&&(Nt.preventDefault(),R())},placeholder:I??(B==="unanswered"?"no message yet: the model did not answer. Check again, or write one here":B==="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(mt,{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 ${we}`,children:[t," ahead"]}),$&&d.jsxs("span",{className:"badge-landed","data-tip":`Merged into ${we}`,children:[d.jsx(mt,{name:"check",className:"icon-inline"})," landed"]})]}),d.jsxs("span",{className:"commit-acts",children:[zt?d.jsxs(d.Fragment,{children:[!qe&&d.jsx("span",{className:"live-text",children:zt}),De]}):d.jsxs(d.Fragment,{children:[u&&o&&d.jsx(Pe,{disabled:!O&&!I||!!f,onClick:Y,...Lt(I&&!O?"Commit with the suggested message":"git add -A && git commit","⌘⏎"),children:"commit"}),u&&de&&d.jsx(Pe,{tone:"primary",disabled:!!f,"data-tip":te,onClick:se,children:re}),je&&d.jsx(Pe,{tone:"primary",disabled:!!f,"data-tip":_T(D,!!((Xt=_e==null?void 0:_e.config.check)!=null&&Xt.trim()),B),onClick:Q,children:"check"}),W&&d.jsx("span",{className:"live-text",children:"check"}),pe&&Z&&d.jsx(Pe,{tone:"primary",disabled:!!f,"data-tip":`Commit, take ${we} in and push the branch; PR #${Z.number} takes the new commits`,onClick:se,children:"update"}),Ie&&d.jsx(Pe,{tone:"primary",disabled:!!f,"data-tip":ET(Z),onClick:se,children:"land"})]}),Z&&d.jsxs(Pe,{"data-tip":`Open PR #${Z.number} on GitHub`,onClick:()=>window.open(Z.url,"_blank"),...c.contextMenu(()=>[{id:"open-pr",label:"open on GitHub",onClick:()=>window.open(Z.url,"_blank")},{id:"copy-link",label:"copy link",onClick:()=>tn(Z.url)}]),children:["view ",d.jsx(mt,{name:"external",className:"icon-inline"})]}),(Z==null?void 0:Z.preview)&&d.jsxs(Pe,{"data-tip":`Open the branch on ${new URL(Z.preview).hostname}`,onClick:()=>window.open(Z.preview,"_blank"),...c.contextMenu(()=>[{id:"open-preview",label:"open the preview",onClick:()=>window.open(Z.preview,"_blank")},{id:"copy-preview",label:"copy link",onClick:()=>tn(Z.preview??"")}]),children:["preview ",d.jsx(mt,{name:"external",className:"icon-inline"})]})]})]}),(ue||xt)&&d.jsxs("div",{className:"composer-notes",children:[xt&&d.jsxs("div",{className:"hint composer-note","data-tip":N?xk[N.status]:void 0,children:[d.jsx("span",{children:xt}),De]}),ue&&d.jsxs("div",{className:"hint composer-note",children:[d.jsx("span",{children:ue}),f==="sync-main"?d.jsx("span",{className:"live-text",children:g?`sync: ${g}`:"sync"}):Ce?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(Pe,{variant:"outline",disabled:!!f||!!be,"data-tip":be??Ne,onClick:()=>$i(s,a,{t:"sync-main",worktreeId:h}),children:"sync"})]})]})]})}const oF=S.memo(function({c:t,id:n,selected:r,onToggle:o}){const s=xn("changes"),a=qu("changes");return d.jsxs("button",{className:"row row-sm log-row row-edge",id:n,"data-state":hr({current:r,cursor:r}),role:"option","aria-selected":r,tabIndex:-1,onClick:()=>o(t.sha),...s.contextMenu(()=>cT(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:fr(t.at)})]})});function sF(e,t){const n=$o(e,t);if(!n||!jn(n))return"take this worktree over to change files here";if(Na(n.worktree))return"start a worktree to change files"}function CT(e,t,n,r){return{id:"new-file",label:"new file…",disabled:sF(e.getState(),t),onClick:()=>r(n)}}function iF(e,t,n,r){const{worktreeId:o,dir:s,path:a,folder:c,newIn:u}=e,h=ry(t.getState(),o)?void 0:"take this worktree over to talk to an agent here",f=TN(a,c),m=[...c?[]:[{id:"open",label:"open",onClick:()=>Dn(n,{worktreeId:o,path:a,view:Ri(a)})}],{id:"add-to-chat",label:"add to chat",disabled:h,onClick:()=>Z3(t,o,a,c)}],g=[CT(t,o,u,r),{id:"ask-rename",label:"ask the agent to rename…",disabled:h,onClick:()=>bx(t,o,`Rename ${f} to `)},{id:"ask-delete",label:"ask the agent to delete…",disabled:h,onClick:()=>bx(t,o,`Delete ${f} and update whatever still uses it`)}],y=[...Uo(()=>{var w;return(w=n.sock)==null?void 0:w.send({t:"reveal",worktreeId:o,path:a})},mo(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 aF(e,t,n,r){return Wn([[CT(t,e.worktreeId,"",r)],Uo(()=>{var o;return(o=n.sock)==null?void 0:o.send({t:"reveal",worktreeId:e.worktreeId})},mo(n.sock))])}const Nf=[],lF=[],Lx=new Set,Px=e=>`tree-row-${e}`;function cF({worktreeId:e,dir:t,openPath:n,openRef:r,rootRef:o}){const s=zn(),a=Qe(),c=ut(),u=At(e,"files"),h=At(e,"submodules"),f=At(e,"ignored"),m=At(e,"git"),g=(m==null?void 0:m.files)??lF,y=m==null?void 0:m.version,w=L(le=>le.connected);it([e,y,w,a],()=>sp(e,s.getState(),{sock:a,dispatch:c}));const v=L(le=>{var be;return((be=le.dragFiles)==null?void 0:be.at)==="tree"&&le.dragFiles.worktreeId===e?le.dragFiles.dir:null}),N=L(le=>le.treeOpen[e]??Nf),x=S.useMemo(()=>new Set(N),[N]),[_,j]=S.useState(Lx);it([e,n,r],()=>j(n&&!r?new Set(ah(n).filter(le=>!x.has(le))):Lx));const T=S.useCallback(le=>x.has(le)||_.has(le),[x,_]),I=S.useCallback(le=>{const be=x.has(le)||_.has(le);if(be&&_.has(le)){const Ce=new Set(_);Ce.delete(le),j(Ce)}c({a:"tree-folder",worktreeId:e,path:le,open:!be})},[x,_,e,c]),R=S.useMemo(()=>Q3(u??Nf,h??Nf,f??Nf),[u,h,f]),C=S.useMemo(()=>J3(R,T),[R,T]),O=S.useMemo(()=>t6(g),[g]),A=L(le=>le.treeReveal),D=A&&A.worktreeId===e?A:null,[B,W]=S.useState(()=>(D==null?void 0:D.path)??null),[U,Q]=S.useState({worktreeId:e,linked:D});(U.worktreeId!==e||U.linked!==D)&&(Q({worktreeId:e,linked:D}),W((D==null?void 0:D.path)??null));const[Y,se]=S.useState(!1),H=S.useMemo(()=>{if(B===null)return-1;const le=C.findIndex(be=>be.path===B);if(le>=0)return le;for(const be of ah(B).reverse()){const Ce=C.findIndex(Ne=>Ne.path===be);if(Ce>=0)return Ce}return-1},[C,B]);it([H,Y],()=>{var le,be;Y&&((be=(le=o.current)==null?void 0:le.querySelector('[data-state~="cursor"]'))==null||be.scrollIntoView({block:"nearest"}))});const $=S.useCallback((le,be)=>Dn({dispatch:c},{worktreeId:e,path:le,view:Ri(le),focus:be}),[e,a,c]),Z=S.useCallback(le=>{W(le.path),le.kind==="folder"?I(le.path):le.kind==="file"&&$(le.path,!1)},[I,$]),q=le=>{var Ne;if(le.metaKey||le.ctrlKey||le.altKey)return;const be=C[H],Ce=Ie=>{const Be=C[Ie];Be&&(W(Be.path),Be.kind==="file"&&$(Be.path,!1))};switch(le.key){case"ArrowDown":case"ArrowUp":le.preventDefault(),Ce(H<0?0:Gu(H,le.key==="ArrowDown"?1:-1,C.length));return;case" ":le.preventDefault(),(be==null?void 0:be.kind)==="file"?$(be.path,!1):(be==null?void 0:be.kind)==="folder"&&I(be.path);return;case"Enter":le.preventDefault(),(be==null?void 0:be.kind)==="file"?$(be.path,!0):(be==null?void 0:be.kind)==="folder"&&I(be.path);return;case"ArrowRight":case"ArrowLeft":{le.preventDefault();const Ie=C.map(Je=>Je.kind==="folder"?{depth:Je.depth,open:Je.open}:{depth:Je.depth}),Be=lp(Ie,H,le.key);(Be==null?void 0:Be.do)==="to"?Ce(Be.at):Be&&be&&I(be.path);return}case"Escape":le.stopPropagation(),n!==null?c({a:"close-editor"}):(Ne=document.activeElement)==null||Ne.blur();return}if(le.key.length===1){const Ie=JN(C.map(Be=>Be.name),H,le.key);Ie>=0&&(le.preventDefault(),Ce(Ie))}},[K,ne]=S.useState(null),de=S.useRef(0),pe=S.useCallback(le=>{le&&!T(le)&&I(le),de.current++,ne({dir:le,error:null,busy:!1})},[T,I]),je=S.useCallback(()=>{de.current++,ne(null)},[]),_e=S.useCallback(le=>{if(!K||K.busy)return;const be=e6(K.dir,le);if("error"in be){ne({...K,error:be.error});return}const Ce=++de.current;ne({...K,error:null,busy:!0}),xN({sock:a,dispatch:c},{worktreeId:e,path:be.path}).then(Ne=>{Ne===null&&W(be.path),Ce===de.current&&ne(Ne===null?null:{...K,error:Ne,busy:!1})})},[K,e,a,c]),fe=xn("tree"),te=S.useCallback(le=>iF({worktreeId:e,dir:t,path:le.path,folder:le.kind!=="file",newIn:le.kind==="folder"||le.kind==="ignored"?le.path:CN(le.path)},s,{sock:a,dispatch:c},pe),[e,t,s,a,c,pe]),re=S.useCallback((le,be)=>{le.kind==="file"&&cn.post(e,be?{type:"highlight-file",path:le.path,ranges:null}:{type:"highlight-clear"})},[e]),we=S.useCallback((le,be)=>Tu(be,{kind:"paths",worktreeId:e,items:[{path:le.path,folder:le.kind!=="file"}]}),[e]),ue=S.useCallback(()=>Yu(s),[s]);return d.jsx("div",{className:Ke("tree",v===""&&"drop-over"),role:"tree","aria-label":"files","data-worktree":e,"aria-activedescendant":Y&&H>=0?Px(H):void 0,tabIndex:0,ref:o,onKeyDown:q,onFocus:()=>{var le;se(!0),B===null&&W(n&&C.some(be=>be.path===n)?n:((le=C[0])==null?void 0:le.path)??null)},onBlur:le=>!le.currentTarget.contains(le.relatedTarget)&&se(!1),onMouseDown:le=>{if(le.button!==0)return;const be=le.target.closest("[data-path]");(be==null?void 0:be.dataset.path)!==void 0&&W(be.dataset.path)},...fe.contextMenu(le=>{const be=C[H];return le==="keyboard"&&be?te(be):aF({worktreeId:e},s,{sock:a},pe)}),children:u===void 0?d.jsx("div",{className:"empty",children:d.jsx("span",{className:"live-text",children:"listing files"})}):C.length===0&&!K?d.jsx("div",{className:"empty",children:"no files"}):uF(C.map((le,be)=>d.jsx(fF,{row:le,id:Px(be),status:O.files.get(le.path),changedInside:le.kind!=="file"&&O.folders.has(le.path),current:Y?be===H:!r&&le.path===n,cursor:Y&&be===H,dropOver:v===le.path,onPress:Z,menu:te,onHover:re,onDragStart:we,onDragEnd:ue},le.path)),K&&(()=>{var be;const le=K.dir===""?-1:C.findIndex(Ce=>Ce.path===K.dir);return{at:le,node:d.jsx(dF,{depth:le>=0?(((be=C[le])==null?void 0:be.depth)??0)+1:0,error:K.error,onSubmit:_e,onCancel:je},"new-file")}})())})}function uF(e,t){return t?[...e.slice(0,t.at+1),t.node,...e.slice(t.at+1)]:e}function dF({depth:e,error:t,onSubmit:n,onCancel:r}){const[o,s]=S.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(Fo,{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 fF=S.memo(function({row:t,id:n,status:r,changedInside:o,current:s,cursor:a,dropOver:c,onPress:u,menu:h,onHover:f,onDragStart:m,onDragEnd:g}){const y=xn("tree"),w=cp(),v=qu("changes"),N=t.kind==="submodule",x=N?"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":hr({current:s,cursor:a}),"data-kind":t.kind,"data-path":t.path,style:{"--tree-depth":t.depth},draggable:w&&!N,onDragStart:_=>m(t,_),onDragEnd:g,onClick:()=>u(t),onMouseEnter:()=>f(t,!0),onMouseLeave:()=>f(t,!1),...y.contextMenu(()=>h(t)),...x?Lt(x,void 0,{placement:v}):{},children:[d.jsx("span",{className:"tree-caret row-dim",children:t.kind==="folder"&&d.jsx(mt,{name:"caret",className:Ke("icon-inline disc-caret",!t.open&&"shut")})}),d.jsx("span",{className:Ke("tree-name",(N||t.ignored)&&"row-dim"),children:t.name}),r?d.jsx("span",{className:`xy ${Rw(r.xy)}`,children:Ow(r.xy)}):o&&d.jsx("span",{className:"dot tree-changed"})]})});function AT({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 Tf=S.memo(function({f:t,id:n,active:r,selected:o,checking:s=!1,checked:a=!1,onOpen:c,onCheck:u,menu:h,onHover:f,onDragStart:m,onDragEnd:g}){const y=xn("changes"),w=cp(),v=qu("changes"),{name:N,dir:x}=w_(t.path);return d.jsxs("button",{className:"row row-sm git-file row-edge",id:n,"data-state":hr({current:r,cursor:o,checked:a}),role:"option","aria-selected":o,tabIndex:-1,onClick:_=>u&&(s||_.shiftKey)?u(t.path):c(t.path),draggable:w&&!!m,onDragStart:m&&(_=>m(t.path,_)),onDragEnd:g,...y.contextMenu(()=>h(t.path)),onMouseEnter:()=>f(t.path,!0),onMouseLeave:()=>f(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 ${Rw(t.xy)}`,children:Ow(t.xy)}),d.jsxs("span",{className:"path",children:[d.jsx("span",{className:"name",children:N}),x&&d.jsx("span",{className:"dir row-dim",children:x})]}),d.jsx(AT,{f:t})]})}),Dx=new Set(["test","tests","__tests__","spec","e2e","__snapshots__","__mocks__","fixtures","testdata"]),hF=/([._-]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("/")&&Dx.has(n.toLowerCase())?!0:t.some(r=>Dx.has(r.toLowerCase()))||hF.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 jf=[];function pF(e,t){var a,c;const n=Wf((e==null?void 0:e.files)??jf),r=(a=e==null?void 0:e.extras)==null?void 0:a.turn,o=Wf(r&&t.turn?r.files:jf),s=Wf(t.committed?((c=e==null?void 0:e.extras)==null?void 0:c.committed)??jf:jf);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 mF={added:"A",changed:"M",removed:"D"},gF={added:"added",changed:"",removed:"deleted"},kF=S.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":hr({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 ${gF[s.change]}`,children:mF[s.change]}),d.jsx("span",{className:"name",children:s.name})]},a))}),Ek="(?<q>[\"'`])(?<name>(?:\\\\.|(?!\\k<q>).)*)\\k<q>",zx={tests:[new RegExp(`^\\s*(?:test|it)(?:\\.(?!each\\b)\\w+)*(?:\\.each\\(.*\\))?\\(\\s*${Ek}`)],groups:[new RegExp(`^\\s*describe(?:\\.(?!each\\b)\\w+)*(?:\\.each\\(.*\\))?\\(\\s*${Ek}`)]},wF={js:zx,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*${Ek}`),/^\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*\(/,...zx.tests]}},yF={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"},vF=3,bF=/^\s*(?:[)}\]]|end\b)/,kg=e=>e.length-e.trimStart().length;function Fx(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 Bx(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=kg(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 f=!e.mark||c-s<=vF?Fx(a,e.tests):null,m=f??Fx(a,e.groups);if(m!==null){if(f!==null){s=Number.NEGATIVE_INFINITY;let v=c+1;for(;v<n.length&&(((w=n[v])==null?void 0:w.trim())===""||kg(n[v]??"")>u);)v++;v<n.length&&kg(n[v]??"")===u&&bF.test(n[v]??"")&&v++;const N=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:N})}o.push({indent:u,name:m})}}),r}function Ux(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 xF(e,t,n){const r=wF[yF[e.slice(e.lastIndexOf(".")+1).toLowerCase()]??""];if(!r)return[];const o=Ux(Bx(r,t)),s=Ux(Bx(r,n)),a=[];for(const[f,m]of s){const g=o.get(f);(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[f,m]of o){const g=s.get(f);g?u=Math.min(g.end+1,c):a.push({name:m.name,group:m.group,change:"removed",line:u})}const h=f=>f.change==="removed"?0:1;return a.sort((f,m)=>f.line-m.line||h(f)-h(m))}const EF=[];function SF(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=fr(r.at);return`${o}, last commit ${s==="now"?"just now":`${s} ago`}`}const Hx='[role="option"]:not([data-sub])',Wx=[];function IT({width:e,placement:t="dock"}){var Ln,vr;const n=t==="screen",r=Qe(),o=ut(),s=zn(),a=tc(),c=La(),u=(c==null?void 0:c.id)??a,h=Us(),f=L(X=>X.layout.changes),m=Wu(),g=L(X=>X.focusChanges),y=At(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),N=L(X=>X.editor&&X.editor.worktreeId===u?X.editor.since??null:null),x=(((Ln=y==null?void 0:y.extras)==null?void 0:Ln.committed)??EF).length>0,_=u3(),j=(vr=y==null?void 0:y.extras)==null?void 0:vr.turn,T=d3(),I=S.useMemo(()=>pF(y,{turn:T,committed:_}),[y,T,_]),{files:R,fileSource:C,turned:O,turnedSource:A,turnBase:D,committed:B,committedSource:W}=I,U=R.length,Q=R.length+O.length,Y=L(X=>X.editor&&X.editor.worktreeId===u?X.editor.disk:null),se=S.useMemo(()=>w!==null&&Y&&hh(w)?xF(w,Y.before,Y.after):Wx,[w,Y]),[H,$]=S.useState(!1);it([w,v,N],()=>$(!1));const Z=C>0?R.length-C:0,q=W>0?B.length-W:0,K=A>0?O.length-A:0,ne=R.length===0,de=S.useMemo(()=>{if(R.length===0)return;const X=R.reduce((Mt,pn)=>Mt+(pn.add??0),0),ge=R.reduce((Mt,pn)=>Mt+(pn.del??0),0),Ve=[X>0&&`+${X}`,ge>0&&`−${ge}`].filter(Boolean).join(" "),Kt=`${R.length} uncommitted ${R.length===1?"file":"files"}`;return Ve?`${Kt}, ${Ve}`:Kt},[R]),pe=!!y&&ne&&(y.ahead??0)===0,je=L(Gl),_e=c!==null||je==="changes",fe=c!==null||je==="history",te=S.useCallback(X=>o({a:"changes-tab",v:X}),[o]),re=S.useRef(je);re.current=je;const we=S.useRef(null),ue=Yw(),le=L(X=>{const ge=Pi(X,ue==null?void 0:ue.repoId);return ge?Oh(ge):"main"}),be=At(u,"commits"),Ce=At(u,"commitFiles"),[Ne,Ie]=S.useState(null),Be=S.useRef(null);Be.current=Ne;const Je=S.useRef(null),zt=At(u,"changedRanges"),Yt=S.useCallback((X,ge)=>{if(!u||c)return;if(!ge){Je.current=null,cn.post(u,{type:"highlight-clear"});return}Je.current=X;const Ve=zt[X];Ve?cn.post(u,{type:"highlight-file",path:X,ranges:ex(Ve)}):r==null||r.send({t:"changed-ranges",worktreeId:u,path:X})},[u,c,zt,r]);S.useEffect(()=>{const X=Je.current;if(!X||!u)return;const ge=zt[X];ge&&cn.post(u,{type:"highlight-file",path:X,ranges:ex(ge)})},[zt,u]);const _t=c&&R.length>0?(y==null?void 0:y.head)??null:null,qe=S.useCallback((X,ge=!1,Ve)=>u&&Dn({dispatch:o},{worktreeId:u,path:X,focus:ge,ref:_t??void 0,since:Ve}),[u,_t,r,o]),xt=S.useMemo(()=>c?R:[...R,...O,...B],[c,R,O,B]),ht=S.useMemo(()=>{const X=[];for(const ge of be??[])if(X.push({commit:ge}),ge.sha===Ne)for(const Ve of Wf(Ce[ge.sha]??[]).files)X.push({commit:ge,file:Ve});return X},[be,Ne,Ce]),De=S.useMemo(()=>ht.filter(X=>!X.file&&X.commit.ahead).length,[ht]),nt=S.useMemo(()=>ht.findIndex(X=>!X.file&&!X.commit.ahead),[ht]),at=c?xt.length:0,Xt=(_e?xt.length:0)+(fe?ht.length:0),Nt=S.useMemo(()=>{const X=new Map;if(!c||R.length===0&&ht.every(Ve=>Ve.commit.landedAt))return X;let ge;return ht.forEach((Ve,Kt)=>{const Mt=!!Ve.commit.landedAt;Mt!==ge&&(ge=Mt,X.set(Kt,Mt?"landed":"not landed"))}),X},[c,R,ht]),Zt=S.useRef(null),[{row:gt,at:nr},Jt]=S.useReducer((X,ge)=>typeof ge=="number"?{row:ge,at:-1}:ge,{row:0,at:-1}),[Rn,Kn]=S.useState(!1),un=(X,ge)=>Rn?sr(X):ge,vn=X=>`changes-row-${X}`,[J,ye]=S.useState(!1),[We,rt]=S.useState([]),jt=S.useCallback(()=>{ye(!1),rt([])},[]),Ft=S.useCallback(X=>{ye(!0),rt(ge=>ge.includes(X)?ge.filter(Ve=>Ve!==X):[...ge,X])},[]),P=S.useMemo(()=>R.filter(X=>We.includes(X.path)).map(X=>X.path),[R,We]);it([R],()=>rt(X=>{const ge=X.filter(Ve=>R.some(Kt=>Kt.path===Ve));return ge.length===X.length?X:ge})),it([J],()=>{if(!J)return;const X=ge=>ge.key==="Escape"&&jt();return window.addEventListener("keydown",X),()=>window.removeEventListener("keydown",X)}),it([u,je],()=>{Jt(0),jt()});const oe=y==null?void 0:y.head,$e=S.useRef("");S.useEffect(()=>{if(!(fe||pe)||!u)return;const X=`${u}:${oe??""}`;$e.current!==X&&($e.current=X,r==null||r.send({t:"git-log",worktreeId:u}))},[fe,pe,u,oe,r]);const Fe=S.useCallback(X=>{Ie(ge=>ge===X?null:X),u&&!Ce[X]&&(r==null||r.send({t:"git-commit",worktreeId:u,sha:X}))},[u,Ce,r]);it([gt,nr,Rn],()=>{var X,ge;Rn&&((ge=(X=Zt.current)==null?void 0:X.querySelector('[data-state~="cursor"]'))==null||ge.scrollIntoView({block:"nearest"}))});const Rt=S.useRef(-1),Gt=X=>X>=U&&X<Q?D:void 0,Re=X=>{var ge;return((ge=xt[X])==null?void 0:ge.path)===w&&(N??void 0)===Gt(X)&&(X<U?v===_t:!v)};Rt.current=_e?xt.findIndex((X,ge)=>Re(ge)):-1,S.useEffect(()=>{if(!g)return;const X=re.current==="files";Rt.current>=0&&Jt(Rt.current);const ge=requestAnimationFrame(()=>{var Ve;return(Ve=(X?we:Zt).current)==null?void 0:Ve.focus()});return()=>cancelAnimationFrame(ge)},[g]);const He=S.useCallback((X,ge=!1)=>{const Ve=xt[X];Ve&&(Jt(X),qe(Ve.path,ge,X>=U&&X<Q?D:void 0),Yt(Ve.path,!0))},[xt,qe,Yt,U,Q,D]),Ze=S.useCallback((X,ge=!1)=>{const Ve=Be.current;u&&Ve&&Dn({dispatch:o},{worktreeId:u,path:X,ref:Ve,focus:ge})},[u,r,o]),Qt=S.useCallback(X=>{const ge=ht[X-at];ge&&(Jt(X),ge.file&&Ze(ge.file.path))},[ht,at,Ze]),Wt=S.useCallback(X=>{const ge=ht[X-at];ge&&(Jt(X),ge.file?Ze(ge.file.path,!0):Fe(ge.commit.sha))},[ht,at,Ze,Fe]),En=X=>fe&&X>=at,Sn=X=>{if(w===null)return!1;if(_e&&X<xt.length)return Re(X);const ge=En(X)?ht[X-at]:void 0;return!!(ge!=null&&ge.file)&&v===ge.commit.sha&&ge.file.path===w},Ct=X=>Sn(X)&&!H?se:Wx,nn=nr<Ct(gt).length?nr:-1,sr=X=>Rn&&gt===X&&nn<0,Pt=()=>{var ge,Ve;const X=[];for(let Kt=0;Kt<Xt;Kt++){const Mt=En(Kt)?ht[Kt-at]:void 0,pn=Mt?(ge=Mt.file)==null?void 0:ge.path:(Ve=xt[Kt])==null?void 0:Ve.path,_n=Mt!=null&&Mt.file?1:0,zr=Ct(Kt);Mt&&!Mt.file?X.push({row:Kt,at:-1,depth:_n,open:Mt.commit.sha===Ne}):pn!==void 0&&hh(pn)?X.push({row:Kt,at:-1,depth:_n,open:zr.length>0}):X.push({row:Kt,at:-1,depth:_n});for(let qn=0;qn<zr.length;qn++)X.push({row:Kt,at:qn,depth:_n+1})}return X},bn=(X,ge=!1)=>{const Ve=se[X];!Ve||!u||w===null||Dn({dispatch:o},{worktreeId:u,path:w,ref:v??void 0,since:N??void 0,line:{n:Ve.line},focus:ge})},fn=X=>Ct(X).length>0&&d.jsx(kF,{tests:se,id:vn(X),cursor:Rn&&gt===X?nn:-1,onPick:ge=>{Jt({row:X,at:ge}),bn(ge)}}),ie=X=>{var ge;if(J&&X.key==="Escape")X.preventDefault(),X.stopPropagation(),jt();else if(J&&X.key===" "){X.preventDefault();const Ve=_e&&gt<R.length?R[gt]:void 0;Ve&&Ft(Ve.path)}else if(X.key==="ArrowDown"&&nn+1<Ct(gt).length)X.preventDefault(),Jt({row:gt,at:nn+1}),bn(nn+1);else if(X.key==="ArrowUp"&&nn>=0)X.preventDefault(),nn===0?Jt(gt):(Jt({row:gt,at:nn-1}),bn(nn-1));else if(X.key==="Enter"&&nn>=0)X.preventDefault(),bn(nn,!0);else if(X.key==="ArrowDown"||X.key==="ArrowUp"){X.preventDefault();const Ve=Gu(gt,X.key==="ArrowDown"?1:-1,Xt);En(Ve)?Qt(Ve):He(Ve)}else if(X.key==="Enter")X.preventDefault(),En(gt)?Wt(gt):He(gt,!0);else if(X.key==="ArrowRight"||X.key==="ArrowLeft"){X.preventDefault();const Ve=Pt(),Kt=lp(Ve,Ve.findIndex(_n=>_n.row===gt&&_n.at===nn),X.key),Mt=Kt&&Ve[Kt.at];if(!Kt||!Mt)return;const pn=En(Mt.row)?ht[Mt.row-at]:void 0;Kt.do==="to"?Mt.at>=0?(Jt({row:Mt.row,at:Mt.at}),bn(Mt.at)):pn!=null&&pn.file&&Mt.row>gt?Qt(Mt.row):Jt(Mt.row):pn&&!pn.file?Fe(pn.commit.sha):Kt.do==="close"?$(!0):Sn(Mt.row)?$(!1):pn!=null&&pn.file?Qt(Mt.row):He(Mt.row)}else X.key==="Escape"&&(X.stopPropagation(),w!==null?o({a:"close-editor"}):(ge=document.activeElement)==null||ge.blur())},Te=c?c.id:h==null?void 0:h.worktree.id,dt=c?c.path:h?h.worktree.path:"",lt=c!==null,Bt=S.useMemo(()=>Te?(X,ge)=>Tu(ge,{kind:"paths",worktreeId:Te,items:[{path:X,folder:!1}]}):void 0,[Te]),kn=S.useRef(P);kn.current=P;const Dr=S.useMemo(()=>Te?(X,ge)=>{const Ve=kn.current;if(!Ve.includes(X))return Bt==null?void 0:Bt(X,ge);Tu(ge,{kind:"paths",worktreeId:Te,items:Ve.map(Kt=>({path:Kt,folder:!1}))})}:void 0,[Te,Bt]),lr=S.useCallback(()=>Yu(s),[s]),ln=S.useCallback(X=>Te?Ls({id:Te,dir:dt},X,{discard:!lt,kept:lt,ref:_t??void 0,select:lt?void 0:Ft},{sock:r,dispatch:o}):[],[Te,dt,lt,_t,Ft,r,o]),cr=S.useCallback(X=>Te?Ls({id:Te,dir:dt},X,{kept:lt},{sock:r,dispatch:o}):[],[Te,dt,lt,r,o]),rn=S.useCallback(X=>Te?Ls({id:Te,dir:dt},X,{kept:lt,since:D},{sock:r,dispatch:o}):[],[Te,dt,lt,D,r,o]),Ht=S.useCallback(X=>Te?Ls({id:Te,dir:dt},X,{ref:Be.current??void 0,kept:lt},{sock:r,dispatch:o}):[],[Te,dt,lt,r,o]),Ut=xn("changes"),xe=()=>{if(_e&&gt<xt.length){const ge=xt[gt];return ge?(gt<U?ln:gt<Q?rn:cr)(ge.path):[]}const X=En(gt)?ht[gt-at]:void 0;return X?X.file?Ht(X.file.path):cT(X.commit):[]},Ge=(X,ge)=>{const Ve=xt.findIndex((Kt,Mt)=>Mt>=X&&Kt.path===ge);Jt(Ve),Re(Ve)&&se.length>0?$(Kt=>!Kt):qe(ge,!1,Gt(Ve))},kt=S.useRef(Ge);kt.current=Ge;const wt=S.useCallback(X=>kt.current(0,X),[]),on=S.useCallback(X=>kt.current(U,X),[U]),dn=S.useCallback(X=>kt.current(Q,X),[Q]),Cn=S.useCallback(X=>{Jt(at+ht.findIndex(ge=>!ge.file&&ge.commit.sha===X)),Fe(X)},[ht,at,Fe]),wn=S.useCallback(X=>{Jt(at+ht.findIndex(ge=>{var Ve;return((Ve=ge.file)==null?void 0:Ve.path)===X})),X===w&&v===Be.current&&se.length>0?$(ge=>!ge):Ze(X)},[ht,at,Ze,w,v,se]),hn=S.useCallback(()=>{},[]);return d.jsxs("div",{className:Ke("changes-dock",n&&"changes-screen",!n&&(!f||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(mt,{name:"folder",className:"icon-inline"}),fit:!0,ariaLabel:"files",tip:Lt("files",Dt("files"))},{id:"changes",label:"changes",tip:Lt("changes",Dt("changes"),{detail:de})},{id:"history",label:"history"}],current:je,onPick:te}),je==="files"&&u?d.jsx(cF,{worktreeId:u,dir:h?h.worktree.path:(ue==null?void 0:ue.path)??"",openPath:w,openRef:v,rootRef:we}):d.jsxs("div",{className:Ke("changes-list",fe&&"history"),role:"listbox","aria-label":c?"kept work":fe?"commits":"changed files","aria-activedescendant":Rn&&gt>=0&&gt<Xt?nn<0?vn(gt):`${vn(gt)}-t${nn}`:void 0,tabIndex:0,ref:Zt,onKeyDown:ie,onFocus:()=>Kn(!0),onMouseDown:X=>{var Kt;if(X.button!==0)return;X.preventDefault();const ge=X.target.closest(Hx),Ve=ge?Array.from(X.currentTarget.querySelectorAll(Hx)).indexOf(ge):-1;Ve>=0&&Jt(Ve),(Kt=Zt.current)==null||Kt.focus()},onBlur:X=>!X.currentTarget.contains(X.relatedTarget)&&Kn(!1),...Ut.contextMenu(X=>X==="keyboard"?xe():[]),children:[_e&&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(S.Fragment,{children:[Z>0&&ge===C&&d.jsx("div",{className:"section-title changes-sub",children:"tests"}),d.jsx(Tf,{f:X,id:vn(ge),active:un(ge,Sn(ge)),selected:sr(ge),checking:J,checked:We.includes(X.path),onOpen:wt,onCheck:lt?void 0:Ft,menu:ln,onHover:Yt,onDragStart:Dr,onDragEnd:lr}),fn(ge)]},`${X.xy}:${X.path}`))]}),_e&&!c&&j&&d.jsxs(d.Fragment,{children:[d.jsxs("button",{type:"button",className:"section-title section-row section-fold","aria-expanded":T,"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(mt,{name:"caret",className:Ke("icon-inline disc-caret",!T&&"shut")})]}),O.map((X,ge)=>d.jsxs(S.Fragment,{children:[K>0&&ge===A&&d.jsx("div",{className:"section-title changes-sub",children:"tests"}),d.jsx(Tf,{f:X,id:vn(U+ge),active:un(U+ge,Sn(U+ge)),selected:sr(U+ge),onOpen:on,menu:rn,onHover:Yt,onDragStart:Bt,onDragEnd:lr}),fn(U+ge)]},`t-${X.path}`))]}),_e&&!c&&x&&d.jsxs(d.Fragment,{children:[d.jsxs("button",{type:"button",className:"section-title section-row section-fold","aria-expanded":_,"data-tip":`Committed on this branch, not yet on ${le}`,"data-tip-placement":"follow",onClick:()=>o({a:"toggle-committed"}),onKeyDown:X=>(X.key==="Enter"||X.key===" ")&&X.stopPropagation(),children:["committed",d.jsx(mt,{name:"caret",className:Ke("icon-inline disc-caret",!_&&"shut")})]}),B.map((X,ge)=>d.jsxs(S.Fragment,{children:[q>0&&ge===W&&d.jsx("div",{className:"section-title changes-sub",children:"tests"}),d.jsx(Tf,{f:X,id:vn(Q+ge),active:un(Q+ge,Sn(Q+ge)),selected:sr(Q+ge),onOpen:dn,menu:cr,onHover:Yt,onDragStart:Bt,onDragEnd:lr}),fn(Q+ge)]},`c-${X.path}`))]}),_e&&!c&&pe&&d.jsx("div",{className:"empty",children:SF(le,!!ue&&Ih(ue),(y==null?void 0:y.behind)??0,be==null?void 0:be[0])}),fe&&ht.map((X,ge)=>d.jsxs(S.Fragment,{children:[c&&Nt.has(ge)&&d.jsx("div",{className:"section-title section-row",children:Nt.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:le}),X.file?d.jsxs(d.Fragment,{children:[d.jsx(Tf,{f:X.file,id:vn(at+ge),active:un(at+ge,Sn(at+ge)),selected:sr(at+ge),onOpen:wn,menu:Ht,onHover:hn,onDragStart:Bt,onDragEnd:lr}),fn(at+ge)]}):d.jsx(oF,{c:X.commit,id:vn(at+ge),selected:sr(at+ge),onToggle:Cn})]},X.file?`${X.commit.sha}:${X.file.path}`:X.commit.sha)),fe&&be===void 0&&d.jsx("div",{className:"empty",children:d.jsx("span",{className:"live-text",children:"reading history"})}),fe&&(be==null?void 0:be.length)===0&&R.length===0&&d.jsx("div",{className:"empty",children:"no commits yet"})]}),J&&d.jsxs("div",{className:"changes-pick",children:[d.jsxs(Pe,{size:"md",tone:"danger",disabled:P.length===0,"data-tip":"Throw away the uncommitted changes to every checked file",onClick:()=>{!Te||P.length===0||window.confirm(EN(P))&&(r==null||r.send({t:"discard-files",worktreeId:Te,paths:P}),jt())},children:["discard ",P.length,"…"]}),d.jsx(Pe,{size:"md",disabled:P.length===0,"data-tip":"Name every checked file in the chat",onClick:()=>{Te&&G3(s,Te,P),jt()},children:"add to chat"}),d.jsx(It,{icon:"close",label:"Cancel",hint:"esc",onClick:jt})]}),ue&&!c&&d.jsx(rF,{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:!ne})]})}function _F(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 Kx(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 NF(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 TF(e){if(!(e<.5))return e<.8?"worth compacting between tasks":"compact before the next task"}const RT=["five_hour","seven_day","seven_day_overage_included"],jF={five_hour:"the 5-hour window",seven_day:"the week",seven_day_overage_included:"the Fable week"},$F={five_hour:"5-hour",seven_day:"this week",seven_day_overage_included:"Fable week"};function OT(e,t){return RT.flatMap(n=>{const r=e.windows[n];return r&&r.resetsAt>t?[{key:n,used:r.used,resetsAt:r.resetsAt}]:[]})}function CF(e,t){return Math.min(1,Math.max(0,...OT(e,t).map(n=>n.used)))}const AF=e=>`${Math.round(100*e)}%`;function qx(e,t){const n=OT(e,t).map(r=>`${AF(r.used)} of ${jF[r.key]}`);return n.length?n.join(", "):"plan windows reset"}function IF(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 RF(e,t,n=r=>IF(r,t)){return RT.flatMap(r=>{const o=e.windows[r];if(!o)return[];const s=$F[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 OF(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 MT(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(fr(e.archivedAt)),t.filter(Boolean).join(" · ")}function LT({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:()=>{LT({sock:n},e.id,t.clientId),r({a:"close"})}}],s=[{id:"copy-branch",label:"copy branch name",onClick:()=>tn(e.branch)}];s.push(...Uo(()=>n==null?void 0:n.send({t:"reveal-transcript",worktreeId:e.id}),mo(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 MF=new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"});function PT(e){const[t,n]=S.useState(()=>Date.now());return S.useEffect(()=>{const r=setInterval(()=>n(Date.now()),6e4);return()=>clearInterval(r)},[]),`${Pw(t-e)} ago`}function Tr({icon:e,word:t,tone:n,at:r,below:o,children:s,...a}){const c=r!==void 0?{"data-tip":`${t} ${MF.format(r)}`,"data-tip-placement":"top"}:null,u=(Array.isArray(o)?o:[o]).filter(h=>h!=null&&h!==!1);return d.jsx("div",{...a,className:"daemon-row row-edge","data-tone":n,children:d.jsxs("div",{className:"daemon-head",children:[d.jsxs("span",{...c,className:"daemon-tag",children:[d.jsx(mt,{name:e,className:"icon-inline"}),t]}),d.jsxs("div",{className:"daemon-body",children:[d.jsx("div",{className:"daemon-line",children:s}),u.map((h,f)=>d.jsx("div",{className:"daemon-below row-dim",children:h},f))]})]})})}function LF({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=PT(e.archivedAt),c=fy(e.lands);return d.jsxs(Tr,{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(Pe,{variant:"inline",tone:"strong",onClick:()=>LT({sock:t},e.id,n),children:"restore"})]})}function Ea(e,t,n,r,o){const{layout:s}=e.getState();Dn({dispatch:e.dispatch},{worktreeId:n,path:r,view:"file",line:{n:o,fiber:!0}}),s.changes||e.dispatch({a:"toggle-changes"})}function PF(e){let t=0;return e.map(n=>{const r={start:t,len:n};return t+=n,r})}function DF(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 Zx(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 zF(e,t){return{from:Zx(e,t.start,!1),to:Zx(e,t.end,!0)}}function Gx(e,t){if(e.length===0)return-1;const n=e.findIndex(r=>r.start>=t);return n===-1?0:n}function FF(e,t,n){return t===0?-1:(e+n+t)%t}function ky(e){return e.key==="f"&&(e.metaKey||e.ctrlKey)&&!e.altKey&&!e.shiftKey}function BF({label:e,query:t,onQuery:n,seed:r,seq:o,status:s,none:a,onStep:c,onClose:u}){const h=S.useRef(null);return it([o],()=>{var f,m;r&&n(r),(f=h.current)==null||f.focus(),(m=h.current)==null||m.select()}),d.jsxs("div",{className:"find",children:[d.jsx(Fo,{ref:h,autoFocus:!0,value:t,onChange:f=>n(f.target.value),placeholder:"find…","aria-label":e,className:"find-field",spellCheck:!1,onKeyDown:f=>{if(f.key==="Escape"){f.preventDefault(),f.stopPropagation(),u();return}if(f.key==="Enter"){f.preventDefault(),c(f.shiftKey?-1:1);return}if(ky(f)){f.preventDefault(),f.stopPropagation(),f.currentTarget.select();return}f.key.toLowerCase()==="g"&&(f.metaKey||f.ctrlKey)&&!f.altKey&&(f.preventDefault(),f.stopPropagation(),c(f.shiftKey?-1:1))}}),d.jsx("span",{className:"find-count","aria-live":"polite",children:s}),d.jsx(It,{icon:"caret",label:"Previous match",hint:"⇧↩",className:"find-prev",disabled:a,onClick:()=>c(-1)}),d.jsx(It,{icon:"caret",label:"Next match",hint:"↩",disabled:a,onClick:()=>c(1)}),d.jsx(It,{icon:"close",label:"Close",hint:"esc",onClick:u})]})}const DT="find",zT="find-current",FT=typeof CSS<"u"&&"highlights"in CSS;function UF(e){const t=e.parentElement;return t?typeof t.checkVisibility=="function"?t.checkVisibility():!0:!1}function HF(e,t){const n=e instanceof Element?e:e.parentElement;return!!(n!=null&&n.closest(t))}function WF(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&&UF(s)&&r.push(s)}return r}const Sk={matches:[],ranges:[]};function KF(e,t,n){if(!t)return Sk;const r=WF(e,n),o=DF(r.map(c=>c.data).join(""),t),s=PF(r.map(c=>c.data.length)),a=o.map(c=>{const{from:u,to:h}=zF(s,c),f=document.createRange();return f.setStart(r[u.i],u.at),f.setEnd(r[h.i],h.at),f});return{matches:o,ranges:a}}function qF(e,t){FT&&(CSS.highlights.set(DT,new Highlight(...e.filter((n,r)=>r!==t))),CSS.highlights.set(zT,new Highlight(...e[t]?[e[t]]:[])))}function ZF(){FT&&(CSS.highlights.delete(DT),CSS.highlights.delete(zT))}function GF(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 Vx=48;function VF(e,t){const n=t.getBoundingClientRect(),r=e.getBoundingClientRect(),o=parseFloat(getComputedStyle(e).getPropertyValue("--scroll-foot"))||0;n.top>=r.top+Vx&&n.bottom<=r.bottom-o-Vx||(e.scrollTop+=n.top-r.top-r.height/3)}function BT({root:e,body:t,seed:n,seq:r,onClose:o,onReveal:s,skip:a}){const[c,u]=S.useState(n),[h,f]=S.useState(Sk),[m,g]=S.useState(-1),y=S.useRef({found:Sk,at:-1}),w=S.useRef(""),v=S.useRef(!1),[N,x]=S.useState(0);S.useLayoutEffect(()=>{const I=t.current;if(!I)return;let R=0;const C=new MutationObserver(O=>{a&&O.every(A=>HF(A.target,a))||R||(R=requestAnimationFrame(()=>{R=0,x(A=>A+1)}))});return C.observe(I,{childList:!0,characterData:!0,subtree:!0,attributes:!0}),()=>{C.disconnect(),R&&cancelAnimationFrame(R)}},[t,a]),S.useLayoutEffect(()=>{const I=t.current;if(!I)return;const R=KF(I,c,a),C=c!==w.current;w.current=c,C&&(v.current=!0);const{found:O,at:A}=y.current;let D;C?O.matches[A]?D=Gx(R.matches,O.matches[A].start):D=e.current?GF(R.ranges,e.current):Gx(R.matches,0):D=Math.min(A,R.matches.length-1),y.current={found:R,at:D},f(R),g(D)},[c,N,a]),S.useLayoutEffect(()=>{qF(h.ranges,m);const I=h.ranges[m];I&&(v.current&&e.current&&(VF(e.current,I),s==null||s()),v.current=!1)},[h,m,e,s]),S.useLayoutEffect(()=>ZF,[]);const _=h.matches.length,j=I=>{if(_===0)return;v.current=!0;const R=FF(y.current.at,_,I);y.current={...y.current,at:R},g(R)},T=()=>o(h.ranges[m]??null);return d.jsx(BF,{label:"find in this document",query:c,onQuery:u,seed:n,seq:r,status:c?_===0?"no matches":`${m+1}/${_}`:"",none:_===0,onStep:j,onClose:T})}function UT(e){return e.key==="a"&&(e.metaKey||e.ctrlKey)&&!e.altKey&&!e.shiftKey}function HT(e,t,n,r,o){S.useEffect(()=>{let s=!1;const a=u=>{const h=u.target instanceof Element?u.target:null;s=!!e.current&&!!h&&e.current.contains(h)&&!(o&&h.closest(o))},c=u=>{const h=e.current;if(!h||u.defaultPrevented||!t(u))return;const f=document.activeElement;o&&(f!=null&&f.closest(o))||!(f&&f!==document.body?h.contains(f):s)&&!(r!=null&&r(f))||(u.preventDefault(),n(h,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 YF(e,t){const n=S.useCallback(r=>{var o;return WT(r,(o=t==null?void 0:t.upTo)==null?void 0:o.call(t,r))},[t]);HT(e,UT,n,void 0,t==null?void 0:t.except)}function _k(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 WT(e,t){const n=document.createRange();n.selectNodeContents(e),t&&n.setEndBefore(t);const r=window.getSelection();r&&(r.removeAllRanges(),r.addRange(n))}function XF(e){return e.shiftKey||e.altKey||e.metaKey||e.ctrlKey?null:e.key==="ArrowLeft"?-1:e.key==="ArrowRight"?1:null}function QF(e,t,n){const r=e+n;return r<0||r>=t?null:r}const KT=S.createContext(null),JF="input, textarea, [contenteditable]";function Yx(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 fp({children:e}){const t=S.useRef(new Map),[n,r]=S.useState(null),o=S.useRef(n);o.current=n;const s=S.useMemo(()=>{const c=u=>{const h=Yx(t.current),f=h.findIndex(m=>m.id===u);r(f<0?null:{id:u,at:f,of:h.length})};return{register(u){return t.current.set(u.id,u),()=>{var h;t.current.delete(u.id),((h=o.current)==null?void 0:h.id)===u.id&&r(null)}},open:c,step(u){const h=o.current;if(!h)return;const f=Yx(t.current),m=f.findIndex(w=>w.id===h.id),g=m<0?null:QF(m,f.length,u),y=g===null?void 0:f[g];y&&c(y.id)},close(){var f,m,g;const u=o.current;if(r(null),!u)return;const h=document.activeElement;h!=null&&h.matches(JF)||(g=(m=(f=t.current.get(u.id))==null?void 0:f.el())==null?void 0:m.querySelector(".chip-link"))==null||g.focus({preventScroll:!0})}}},[]),a=S.useMemo(()=>({api:s,shown:n}),[s,n]);return d.jsx(KT.Provider,{value:a,children:e})}function e8(e,t){const n=S.useContext(KT),r=S.useId(),[o,s]=S.useState(!1),a=n==null?void 0:n.api;if(S.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 Nk(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 qT(e,t,n){const r=h=>e.map((f,m)=>h(f)&&f.id!==t?m:-1).filter(f=>f>=0),s=[()=>r(h=>h.agent==="waiting"),()=>r(h=>!!h.unseen),()=>r(h=>h.agent==="working")].reduce((h,f)=>h.length>0?h:f(),[]),a=e.findIndex(h=>h.id===t),c=n>0?s.find(h=>h>a)??s[0]:s.findLast(h=>h<a)??s[s.length-1],u=c===void 0?void 0:e[c];return u?{activate:u.id}:null}function wy(e,t,n){const r=qT(e,t,n);if(r)return r;const o=e[0];return o&&o.id!==t?{activate:o.id}:null}function t8(e,t,n){const r=[Nk(e,t),...n.map(o=>Nk(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 n8(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=qT(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=wy(e,t,1);return o&&{origin:null,activate:o.activate}}function ZT(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=qt(e,e.activeId))==null?void 0:m.worktree.id,a=[];o&&(a.push({id:"new",label:"new worktree…",key:Dt("new"),onClick:()=>n({a:"open-draft"})}),a.push({id:"refs",label:"open a branch or PR…",key:Dt("refs"),onClick:()=>n({a:"open",overlay:{kind:"refs"}})})),s&&(a.push({id:"jump",label:"jump to file…",key:Dt("quick-open"),onClick:()=>n({a:"open",overlay:{kind:"quick-open"}})}),a.push({id:"search",label:"search in files…",key:Dt("search"),onClick:()=>n({a:"open",overlay:{kind:"search"}})})),bu(e)&&a.push({id:"routes",label:"go to page…",key:Dt("routes"),onClick:()=>n({a:"open",overlay:{kind:"routes"}})}),o&&a.push({id:"chats",label:"search chats…",key:Dt("chats"),onClick:()=>n({a:"open",overlay:{kind:"chats"}})});const c=wy(e.visible,e.activeId,1);c&&a.push({id:"wt-unseen-next",label:"next that needs you",key:Dt("wt-unseen-next"),onClick:()=>n({a:"activate",id:c.activate})}),a.push({id:"project",label:e.repos.length>1?"switch project…":"open project…",key:Dt("project"),onClick:()=>n({a:"open",overlay:{kind:"projects",form:"center"}})});const u=[{id:"changes",label:`${r(e.layout.changes)} changes panel`,key:Dt("changes"),onClick:()=>n({a:"toggle-changes"})},{id:"files",label:`${r(e.layout.changes&&Gl(e)==="files")} files`,key:Dt("files"),onClick:()=>n(e.layout.changes&&Gl(e)==="files"?{a:"toggle-changes"}:{a:"focus-changes",tab:"files"})},{id:"chat",label:`${r(e.layout.chat)} chat panel`,key:Dt("composer"),onClick:()=>n({a:"toggle-chat"})},{id:"terminal",label:`${r(e.layout.term)} terminal`,key:Dt("terminal"),onClick:()=>n({a:"toggle-terminal"})},{id:"rail",label:`${r(e.railOpen)} worktree panel`,key:Dt("rail"),onClick:()=>n({a:"toggle-rail"})},{id:"design",label:`${r(e.layout.design)} design system`,key:Dt("design"),onClick:()=>n({a:"toggle-design"})},{id:"zen",label:"full-bleed preview",key:Dt("zen"),onClick:()=>n({a:"toggle-zen"})}],h=[{id:"commands",label:"command palette",key:Dt("commands"),onClick:()=>n({a:"open",overlay:{kind:"commands"}})},{id:"keys",label:"settings & shortcuts",key:Dt("keys"),onClick:()=>n({a:"open",overlay:{kind:"keys"}})}];(g=e.self)!=null&&g.restart&&h.push({id:"restart-daemon",label:"restart Toyon",onClick:()=>t==null?void 0:t.send({t:"restart-daemon"})}),h.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 f=No(e)?new Set(["chat","design","zen"]):null;return Wn([a,f?u.filter(y=>!f.has(y.id)):u,h])}function Tk(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 yy(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 GT(e,{sock:t}){return[{id:"restart:shell",label:"restart shell",onClick:()=>t==null?void 0:t.send({t:"term-restart",worktreeId:e,stream:Do})}]}function r8(e,t,n,r){return Wn([[...e.flatMap(o=>yy(o,t,r)),...GT(t,r)],[{id:"terminal",label:`${n?"hide":"show"} terminal`,onClick:()=>r.dispatch({a:"toggle-terminal"})}]])}function Cu({sock:e,dispatch:t},n){t({a:"open-repo"}),e==null||e.send(n)}function VT(e,t){const{parent:n,name:r}=by(t);Cu(e,{t:"create-repo",mode:"init",parent:n,name:r})}function o8(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 hp(e,t,{sock:n,dispatch:r},o){const s=o.filter(u=>jn(u)&&u.worktree.repoId===e.id&&Ah(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(s8(e.name,s))&&(n==null||n.send({t:"forget-repo",repoId:e.id}))}}];return Wn([a,c])}function s8(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 i8(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 YT(e,{sock:t,dispatch:n}){var a;const r=e.themePrefs,o=c=>{var u;return((u=e.themes.find(h=>h.id===c))==null?void 0:u.name)??c},s=E3();return Wn([[{id:"theme",label:"theme…",detail:Kh(r,e.themes,T_(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:()=>S3(!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:()=>i8((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 a8(e,t,n,r,o,s={machines:[],switchTo:()=>{},forget:()=>{}}){const a=[],c=(g,y,w,v,N)=>a.push({id:g,label:y,hint:v,run:w,sub:N}),u=(g,y)=>{for(const w of g){if(!ms(w)||w.disabled!==void 0||w.checked)continue;const v=w.key??(typeof w.detail=="string"?w.detail:void 0),N=y?`${y.scope}:${w.id}`:w.id,x=w.topic?`${w.topic}: ${w.label}`:w.label;c(N,y?`${x} · ${y.name}`:x,w.onClick,v,w.sub)}},h={sock:n,dispatch:t},f=r,m=f==null?void 0:f.worktree.id;if(u(ZT(e,h).filter(g=>!ms(g)||g.id!=="commands")),o&&u(hp(o,o.id,h,e.rows),{scope:"project",name:o.name}),m&&!No(e)){c("pick",e.picking==="chat"?"cancel element picker":"pick an element for the chat",()=>Nu(m,e.picking,t,"chat"),Dt("pick")),c("inspect",e.picking==="code"?"cancel element picker":"pick an element to open its code",()=>Nu(m,e.picking,t,"code"),Dt("inspect"));const g=ik(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",()=>cn.post(m,{type:"reload"}))}if(u(YT(e,h)),f&&m){const g=e.repos.find(y=>y.id===f.worktree.repoId)??null;u(wT(f,g,e,h,{hostname:e.hostname,palette:!0}),{scope:"wt",name:rk(f,g)});for(const y of f.procs)u(yy(y,m,h))}e.visible.forEach((g,y)=>{var N;if(g.worktree.id===m)return;const v=!!e.activeRepoId&&g.repoId!==e.activeRepoId?` in ${((N=e.repos.find(x=>x.id===g.repoId))==null?void 0:N.name)??g.repoId}`:"";c(`go:${g.worktree.id}`,`switch to ${rk(g,o)}${v}`,()=>t({a:"activate",id:g.worktree.id}),dI(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 XT(){const e=ut(),t=Qe(),{host:n}=Pr(),r=zn(),o=ks(),s=eN(),a=L(H=>H.picking),c=L(H=>H.layout),u=L(H=>H.chatSide),h=L(H=>H.blackGround),f=L(H=>H.keepAwake),m=L(H=>H.railOpen),g=L(H=>H.themePrefs),y=L(H=>H.themes),w=L(H=>H.systemDark),v=L(H=>H.daylight),N=L(H=>H.rows),x=L(H=>H.visible),_=L(H=>H.activeId),j=L(H=>H.activeRepoId),T=L(H=>H.repos),I=L(H=>H.agents),R=L(H=>H.defaultAgent),C=L(H=>H.shipping),O=L(H=>H.remote),A=L(H=>H.managed),D=L(H=>H.frame),B=L(H=>H.self),W=L(H=>H.archivedPage),U=L(H=>H.notesPage),Q=L(H=>H.archived),Y=L(H=>H.knocks),se=L(H=>H.tailscale);return S.useMemo(()=>{const H={picking:a,layout:c,chatSide:u,blackGround:h,keepAwake:f,railOpen:m,themePrefs:g,themes:y,systemDark:w,daylight:v,rows:N,visible:x,activeId:_,activeRepoId:j,repos:T,agents:I,defaultAgent:R,shipping:C,frame:D,self:B,archivedPage:W,notesPage:U,archived:Q,knocks:Y,hostname:n,drafted:Z=>Fw(r.getState(),Z)},$={machines:s,switchTo:(Z,q)=>{var K;(K=o.get(Z))==null||K.store.dispatch({a:"activate-repo",id:q}),o.activate(Z)},forget:Z=>{const q=Tk(o,Z).find(K=>ms(K)&&K.id.startsWith("forget-machine:"));q&&ms(q)&&q.onClick()}};return a8(H,e,t,qt(H,_),Pi(H,j),$)},[a,c,u,h,f,m,g,y,w,v,N,x,_,j,T,I,R,C,O,A,D,B,W,U,Q,Y,se,e,t,n,r,o,s])}function QT(e,t){const n=t.trim().toLowerCase();if(!n)return e;const r=[];for(const o of e){const s=jk(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 jk(e,t){const n=vy(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+(JT(e,a)?3:0),s=a;return r+Math.max(0,40-e.length/4)}const JT=(e,t)=>t===0||/[\s:\-–—·/.(]/.test(e[t-1]);function vy(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(JT(n,c)){a=c;break}if(a===-1)return null;r.push(a),o=a+1}return r}const es=(e,...t)=>{const n=e.trim().toLowerCase();return!n||t.some(r=>r==null?void 0:r.toLowerCase().includes(n))},Au=e=>/^(~|\/|\.\.?\/)/.test(e.trim());function by(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 l8(e,t,n){const r=e.map(h=>h.path.slice(0,h.path.lastIndexOf("/"))).filter(Boolean),o=e.find(h=>h.id===t),s=o==null?void 0:o.path.slice(0,o.path.lastIndexOf("/")),a=new Map;for(const h of r)a.set(h,(a.get(h)??0)+1);let c="",u=0;for(const[h,f]of[...a].sort(([m],[g])=>m.localeCompare(g)))(f>u||f===u&&h===s)&&(c=h,u=f);return c?xy(c,n):`~/${GS}`}function xy(e,t){return t&&(e===t||e.startsWith(`${t}/`))?`~${e.slice(t.length)}`:e}function ej(e,t){return`${e.replace(/\/+$/,"")}/${t.trim()}`}function c8(e){const t=e.query.trim();if(e.urlOnly){const a=Hb(t);return a?[{kind:"clone",...a}]:[]}const n=()=>e.entries.map(a=>({kind:a.isFile?"file":"dir",entry:a}));if(!Au(t)){const a=e.repos.filter(g=>es(t,g.name,g.path)).map(g=>({kind:"repo",repo:g})),c=e.pending.filter(g=>es(t,g.name,g.url)).map(g=>({kind:"pending",pending:g})),u=[...a,...c],h=(e.others??[]).flatMap(g=>g.repos.length===0?es(t,g.name)?[{kind:"machine",machine:g}]:[]:g.repos.filter(y=>es(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"},...h]}const f=Hb(t);if(f)return u.length>0?u:[{kind:"clone",...f}];const m=g=>g.toLowerCase()===t.toLowerCase();return e.repos.some(g=>m(g.name))||e.pending.some(g=>m(g.name))?[...u,...h]:vu(t)?[...u,...h]:[...u,{kind:"create",name:t,parent:null},...h]}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=Yl(a,e.home);return c==="/"||c===e.home||e.repos.some(h=>h.path.startsWith(`${c}/`))?n():[...n(),{kind:"init",path:a}]}if(t.endsWith("/"))return n();if(!r.parentExists)return[];const{parent:o,name:s}=by(t);return vu(s)?n():[...n(),{kind:"create",name:s,parent:o}]}function Yl(e,t){return t&&(e==="~"||e.startsWith("~/"))?`${t}${e.slice(1)}`:e}function tj(e,t){const n=Yl(e,t).replace(/\/+$/,"");return n.startsWith("/")?xy(n.slice(0,n.lastIndexOf("/"))||"/",t):null}function $k(e,t){const n=Yl(e,t).replace(/\/+$/,"");return n.slice(n.lastIndexOf("/")+1)||"/"}function u8(e){const t=e.query.trim(),n=t.lastIndexOf("/"),r=n<0?"":t.slice(0,n)||"/",o=Yl(r,e.home);if(!Au(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(f=>{if(f.isRepo||f.isFile)return!1;const m=Yl(f.path,e.home);return(m.slice(0,m.lastIndexOf("/"))||"/")===o&&f.name.toLowerCase().startsWith(s)}),h=tj(r,e.home);return[...c?[{kind:"here",path:r}]:[],...h?[{kind:"up",path:h}]:[],...u.map(f=>({kind:"dir",entry:f}))]}const d8=e=>e.t==="open-path"||e.t==="open-loose"||e.t==="open-clone",ya=new Map,f8=16;function Ck({sock:e,dispatch:t},n,r){const o=nj({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 h8(e,t){e==null||e.send({t:"open-by-path",path:t,seq:nj(null)})}function nj(e){const t=_o();ya.set(t,e);for(const n of ya.keys()){if(ya.size<=f8)break;ya.delete(n)}return t}function p8(e,t){if(!ya.has(t.seq))return;const n=ya.get(t.seq);ya.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 m8(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:Yh({mode:"clone",parent:xy(c,r.home),...u})});return}if(n.t==="open-path"){const a={dispatch:u=>e.dispatch(u)};if($o(r,n.worktreeId)){r.activeId!==n.worktreeId&&e.dispatch({a:"activate",id:n.worktreeId}),Dn(a,{worktreeId:n.worktreeId,path:n.path});return}const c=Object.keys(r.trunks).find(u=>{var h;return((h=r.trunks[u])==null?void 0:h.id)===n.worktreeId});if(!c)return;if(((s=$o(r,r.activeId))==null?void 0:s.repoId)!==c){const u=r.rows.find(h=>h.repoId===c);if(!u)return;e.dispatch({a:"activate",id:u.id})}Dn(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 Ey({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}]:[],...Uo(o,mo(r),"reveal the copy")],s?[{id:"copy-path",label:"copy path",onClick:()=>vN(s)}]:[],t?[{id:"remove",label:"remove",onClick:t}]:[]]}function Ca(e,t={},n){return Wn([[{id:"copy-image",label:"copy image",onClick:()=>L3(e)}],...Ey(t,n)])}function rj({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:()=>vN(t)}]:[]}function g8(e,t={}){return Wn([rj(e),...Ey(t)])}function k8(e,t={},n){return Wn([rj(e),...Ey(t,n)])}function oj(e){return[wN(e),{id:"copy-link",label:"copy link",onClick:()=>tn(e)}]}function pp(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 w8(e.path,n);if(!t)return null;if(e.kind==="outside")return()=>Ck(n,t,e);if(e.kind==="path")return()=>Ck(n,t,{href:e.path,path:e.path});if(e.kind!=="file")return null;const r=e.file;return r.folder?()=>H3(n,{worktreeId:t,path:r.path}):()=>Dn(n,{worktreeId:t,path:r.path,...r.line?{line:{n:r.line}}:{}})}function w8(e,{sock:t}){return!t||!op(mo(t))?null:()=>t.send({t:"reveal-path",path:e})}function y8(e,t,n){const r=e.kind==="outside"&&e.folder?null:pp(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}]:[],...Uo(s,mo(o))],[{id:"copy-path",label:"copy path",onClick:()=>tn(a)}]]}function v8(e,t){const n=pp(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 Ak(e){return e?[{id:"copy-code",label:"copy code",onClick:()=>tn(e)}]:[]}function ki(e,t,n,r={}){const{dispatch:o,sock:s}=n,a=r.link,c=a?a.kind==="out"?[oj(a.href)]:a.kind==="worktree"?v8(a,n):y8(a,t,n):[],u=[{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 f=e.seq;if(f===void 0||!s)return o({a:"set-draft",id:t,text:e.text});o({a:"set-draft",id:t,text:""}),s.send({t:"redraft",worktreeId:t,seq:f})}}),Wn([Ak(r.code),...c,u,h])}function sj(e,t,n){return[Uo(t,n),[{id:"copy-path",label:"copy path",onClick:()=>tn(e)}]]}function Sy(e,t,n){return Wn(sj(e,t,n))}function b8(e,t){const n=e.callFile??e.file,r=n?sj(n,void 0,t.host):[],o=t.remove?[{id:"remove",label:"remove",onClick:t.remove}]:[];return Wn([...r,o])}const Xx=8,x8=.7,E8=100,S8=80,_8=220;function Qx({dx:e,dy:t}){return Math.abs(e)<Xx&&Math.abs(t)<Xx?null:Math.abs(t)>Math.abs(e)?"away":"other"}function N8(e,t){const n=e.filter(s=>t-s.t<=E8),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 T8=e=>Math.abs(e)>=x8;function j8(e,t){return Math.min(_8,Math.max(S8,e/Math.abs(t)))}const Ol={s:1,x:0,y:0},$8=2.5,Jx=.5,e1=4,Nl=e=>e.s===1&&e.x===0&&e.y===0;function C8(e,t){return Math.max(e1,t>0?e/t:e1)}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 ha(e,t){return{s:e.s,x:t1(e.x,(t.w*e.s-t.W)/2),y:t1(e.y,(t.h*e.s-t.H)/2)}}const t1=(e,t)=>t<=0?0:Math.min(t,Math.max(-t,e));function n1(e,t){const n=Math.min(t.max,Math.max(1,e.s));return n===1?Ol:ha({...e,s:n},t)}function r1(e,t,n){return Nl(e)?ha(qf(e,Math.min($8,n.max),t,t),n):Ol}const A8=400,o1=300,I8=32,s1=260,R8=.01,i1=(e,t)=>Math.hypot(t.clientX-e.clientX,t.clientY-e.clientY),a1=(e,t)=>({x:(e.clientX+t.clientX)/2,y:(e.clientY+t.clientY)/2}),El=(e,t)=>({x:e.x-t.x,y:e.y-t.y}),wg=(e,t,n)=>Math.min(n,Math.max(t,e));function O8(e,t,n){const r=S.useRef(n);r.current=n,S.useEffect(()=>{const o=e.current;if(!o)return;let s=null,a=!1,c=[],u=0,h=Ol,f=null,m=null,g=null,y=0,w=0;const v=()=>{const U=o.querySelector(t);if(!U)return null;const Q=o.getBoundingClientRect(),Y=U.offsetWidth,se=U.offsetHeight,H=U instanceof HTMLImageElement?U.naturalWidth:Y;return{centre:{x:Q.left+U.offsetLeft+Y/2,y:Q.top+U.offsetTop+se/2},bounds:{w:Y,h:se,W:o.clientWidth,H:o.clientHeight,max:C8(H,Y)}}},N=(U,Q,Y)=>{Y!==void 0&&o.style.setProperty("--swipe-ms",`${Y}ms`),o.dataset.swipe!==Q&&(o.dataset.swipe=Q,o.offsetWidth),o.style.setProperty("--swipe-y",`${U}px`),o.style.setProperty("--swipe-fade",`${Math.min(1,Math.abs(U)/(window.innerHeight/2))}`)},x=()=>{o.style.removeProperty("--swipe-y"),o.style.removeProperty("--swipe-fade"),o.style.removeProperty("--swipe-ms"),delete o.dataset.swipe},_=(U,Q)=>{if(h=U,window.clearTimeout(w),Q?(o.dataset.zoom!==Q&&(o.dataset.zoom=Q,o.offsetWidth),w=window.setTimeout(()=>delete o.dataset.zoom,s1)):delete o.dataset.zoom,Nl(U)){o.style.removeProperty("--zoom-s"),o.style.removeProperty("--zoom-x"),o.style.removeProperty("--zoom-y");return}o.style.setProperty("--zoom-s",`${U.s}`),o.style.setProperty("--zoom-x",`${U.x}px`),o.style.setProperty("--zoom-y",`${U.y}px`)},j=()=>{const U=a;s=null,a=!1,c=[],f=null,m=null,U&&(N(0,"settle"),u=window.setTimeout(x,s1))},T=U=>{var $;const Q=U.target,Y=Q===o||!!(Q!=null&&Q.closest(t));if(((($=window.visualViewport)==null?void 0:$.scale)??1)>1.01)return j();if(o.dataset.swipe==="leave")return;const se=U.touches[0],H=U.touches[1];if(se&&H&&U.touches.length===2&&Y){j(),window.clearTimeout(y),g=null,f={d:i1(se,H),m:a1(se,H),z:h};return}if(U.touches.length!==1||!se||!Y)return j();window.clearTimeout(u),s={x:se.clientX,y:se.clientY,at:U.timeStamp},c=[{y:se.clientY,t:U.timeStamp}],m=Nl(h)?null:h},I=U=>{const Q=U.touches[0],Y=U.touches[1];if(f&&Q&&Y){U.preventDefault();const $=v();if(!$)return;const Z=wg(f.z.s*i1(Q,Y)/f.d,Jx,$.bounds.max);_(ha(qf(f.z,Z,El(f.m,$.centre),El(a1(Q,Y),$.centre)),$.bounds));return}if(!s||!Q)return;const se=Q.clientX-s.x,H=Q.clientY-s.y;if(m){U.preventDefault();const $=v();$&&_(ha({s:m.s,x:m.x+se,y:m.y+H},$.bounds));return}if(!a){const $=Qx({dx:se,dy:H});if($==="other"&&(s=null),$!=="away")return;a=!0}U.preventDefault(),c.push({y:Q.clientY,t:U.timeStamp}),c.length>16&&c.shift(),N(H,"drag")},R=U=>{if(f){if(U.touches.length>=2)return;const ne=v();_(ne?n1(h,ne.bounds):Ol,"settle"),f=null;const de=U.touches[0];de&&!Nl(h)&&(s={x:de.clientX,y:de.clientY,at:U.timeStamp},m=h);return}const Q=U.changedTouches[0];if(!s||!Q)return;const Y={x:Q.clientX,y:Q.clientY},se=Y.y-s.y,H=U.timeStamp-s.at;if(!a&&H<A8&&U.target!==o&&Qx({dx:Y.x-s.x,dy:se})===null){if(U.preventDefault(),s=null,m=null,g&&U.timeStamp-g.t<o1&&Math.hypot(Y.x-g.p.x,Y.y-g.p.y)<I8){window.clearTimeout(y),g=null;const ne=v();_(ne?r1(h,El(Y,ne.centre),ne.bounds):Ol,"settle");return}g={p:Y,t:U.timeStamp},Nl(h)&&(y=window.setTimeout(()=>r.current(),o1));return}if(m){m=null,s=null,c=[];return}const Z=N8(c,U.timeStamp);if(!a||!T8(Z))return j();s=null,a=!1,c=[];const q=Math.sign(Z)*window.innerHeight,K=j8(Math.abs(q-se),Z);N(q,"leave",K),u=window.setTimeout(()=>r.current(),K)},C=U=>{var Y;if(!((Y=U.target)!=null&&Y.closest(t)))return;const Q=v();Q&&_(r1(h,El({x:U.clientX,y:U.clientY},Q.centre),Q.bounds),"settle")},O=U=>{const Q=v();if(Q)if(U.ctrlKey){U.preventDefault();const Y=El({x:U.clientX,y:U.clientY},Q.centre),se=wg(h.s*Math.exp(-U.deltaY*R8),1,Q.bounds.max);_(ha(qf(h,se,Y,Y),Q.bounds))}else Nl(h)||(U.preventDefault(),_(ha({s:h.s,x:h.x-U.deltaX,y:h.y-U.deltaY},Q.bounds)))};let A=null;const D=U=>{if(f)return;U.preventDefault();const Q=v(),Y=U;Q&&(A={z:h,p:El({x:Y.clientX,y:Y.clientY},Q.centre)})},B=U=>{if(f)return;U.preventDefault();const Q=v();if(!A||!Q)return;const Y=wg(A.z.s*U.scale,Jx,Q.bounds.max);_(ha(qf(A.z,Y,A.p,A.p),Q.bounds))},W=U=>{if(f)return;U.preventDefault(),A=null;const Q=v();_(Q?n1(h,Q.bounds):Ol,"settle")};return o.addEventListener("touchstart",T,{passive:!0}),o.addEventListener("touchmove",I,{passive:!1}),o.addEventListener("touchend",R),o.addEventListener("touchcancel",j),o.addEventListener("dblclick",C),o.addEventListener("wheel",O,{passive:!1}),o.addEventListener("gesturestart",D),o.addEventListener("gesturechange",B),o.addEventListener("gestureend",W),()=>{window.clearTimeout(u),window.clearTimeout(y),window.clearTimeout(w),o.removeEventListener("touchstart",T),o.removeEventListener("touchmove",I),o.removeEventListener("touchend",R),o.removeEventListener("touchcancel",j),o.removeEventListener("dblclick",C),o.removeEventListener("wheel",O),o.removeEventListener("gesturestart",D),o.removeEventListener("gesturechange",B),o.removeEventListener("gestureend",W)}},[e,t])}function Qu({owner:e,onClose:t,menu:n,nav:r,children:o}){const s=xn(e),a=S.useRef(null);return O8(a,"img",t),d.jsxs(Hs,{className:"attach-full scrim",boxRef:a,onDismiss:t,onKey:c=>{if(c.key==="Escape"){c.stopPropagation(),t();return}const u=r&&XF(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(It,{icon:"close",label:"Close",tone:"quiet",onClick:t})]})]})}function M8({item:e}){if(!e.outcome)return null;const t=v4[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 ij(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 L8=e=>e.slice(0,Math.max(0,e.lastIndexOf("/")));function aj(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(f=>f===".."))return null;if(a)return{path:c,folder:!0};const u=(r==null?void 0:r[1])??(o==null?void 0:o[1]),h=u?Number.parseInt(u,10):void 0;return h&&h>0?{path:c,line:h}:{path:c}}function lj(e){var t;return((t=e.match(/^file:\/\/(?:localhost)?(\/.*)$/i))==null?void 0:t[1])??e}function cj(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 P8(e){return e.length<2||!e.startsWith("/")||e.startsWith("//")||/\s/.test(e)?null:e}function mp(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?aj(t,a):null;if(c)return{kind:"file",file:c};const u=cj(a);return u?{kind:"outside",href:a,...u}:{kind:"out",href:a}}function _y(e,t,n,r){var s;const o=mp(e.target,t);!o||o.kind==="path"||o.kind==="out"||(e.preventDefault(),(s=pp(o,n,r))==null||s())}const D8=150,z8=e=>({side:e,align:"center",offset:12,flip:"side",margin:8});function uj({chip:e,className:t,children:n}){const[r,o]=S.useState(!1),s=qu("chat");S.useEffect(()=>{const c=e.current;if(!c)return;let u=0;const h=()=>{window.clearTimeout(u),o(!1)},f=()=>{window.clearTimeout(u),u=window.setTimeout(()=>o(!0),D8)};return c.addEventListener("mouseenter",f),c.addEventListener("mouseleave",h),c.addEventListener("mousedown",h),()=>{window.clearTimeout(u),c.removeEventListener("mouseenter",f),c.removeEventListener("mouseleave",h),c.removeEventListener("mousedown",h)}},[e]);const a=()=>{var f;const c=e.current;if(!c)return null;const u=c.getBoundingClientRect(),h=((f=c.closest(".chat-log"))==null?void 0:f.getBoundingClientRect())??u;return{left:h.left,right:h.right,top:u.top,bottom:u.bottom}};return r?d.jsx(Hs,{className:Ke("chip-peek",t),anchor:a,placement:z8(s),track:!0,children:n}):null}function Ny({className:e,label:t,tip:n,peek:r,full:o,menu:s,removeLabel:a,onRemove:c}){const u=S.useRef(null),h=xn("chat"),f=o!==void 0,m=e8(u,f);return d.jsxs("div",{ref:u,className:Ke("pick-chip row row-sm",e),"data-tip":f?"Open full size":n,"data-tip-placement":"follow",...h.contextMenu(()=>s({open:f?m.show:void 0,remove:c})),children:[f?d.jsx("button",{type:"button",className:"chip-link",onClick:m.show,children:t}):t,c&&d.jsx(It,{icon:"close",label:a,tone:"quiet",onClick:c}),f&&r!==void 0&&d.jsx(uj,{chip:u,children:r}),m.open&&f&&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 l1(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 F8(e){if(Array.isArray(e))return e}function B8(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,h=!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(f){h=!0,o=f}finally{try{if(!u&&n.return!=null&&(a=n.return(),Object(a)!==a))return}finally{if(h)throw o}}return c}}function U8(){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 H8(e,t){return F8(e)||B8(e,t)||W8(e,t)||U8()}function W8(e,t){if(e){if(typeof e=="string")return l1(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)?l1(e,t):void 0}}const dj=Object.entries,c1=Object.setPrototypeOf,K8=Object.isFrozen,q8=Object.getPrototypeOf,Z8=Object.getOwnPropertyDescriptor;let wr=Object.freeze,$r=Object.seal,Tl=Object.create,fj=typeof Reflect<"u"&&Reflect,Ik=fj.apply,Rk=fj.construct;wr||(wr=function(t){return t});$r||($r=function(t){return t});Ik||(Ik=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)});Rk||(Rk=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 ua=pr(Array.prototype.forEach),G8=pr(Array.prototype.lastIndexOf),u1=pr(Array.prototype.pop),Vc=pr(Array.prototype.push),V8=pr(Array.prototype.splice),Bl=Array.isArray,ru=pr(String.prototype.toLowerCase),yg=pr(String.prototype.toString),d1=pr(String.prototype.match),Yc=pr(String.prototype.replace),f1=pr(String.prototype.indexOf),Y8=pr(String.prototype.trim),X8=pr(Number.prototype.toString),Q8=pr(Boolean.prototype.toString),h1=typeof BigInt>"u"?null:pr(BigInt.prototype.toString),p1=typeof Symbol>"u"?null:pr(Symbol.prototype.toString),co=pr(Object.prototype.hasOwnProperty),Xc=pr(Object.prototype.toString),Wr=pr(RegExp.prototype.test),la=J8(TypeError);function pr(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 Ik(e,t,r)}}function J8(e){return function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return Rk(e,n)}}function gn(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:ru;if(c1&&c1(e,null),!Bl(t))return e;let r=t.length;for(;r--;){let o=t[r];if(typeof o=="string"){const s=n(o);s!==o&&(K8(t)||(t[r]=s),o=s)}e[o]=!0}return e}function e9(e){for(let t=0;t<e.length;t++)co(e,t)||(e[t]=null);return e}function Eo(e){const t=Tl(null);for(const r of dj(e)){var n=H8(r,2);const o=n[0],s=n[1];co(e,o)&&(Bl(s)?t[o]=e9(s):s&&typeof s=="object"&&s.constructor===Object?t[o]=Eo(s):t[o]=s)}return t}function t9(e){switch(typeof e){case"string":return e;case"number":return X8(e);case"boolean":return Q8(e);case"bigint":return h1?h1(e):"0";case"symbol":return p1?p1(e):"Symbol()";case"undefined":return Xc(e);case"function":case"object":{if(e===null)return Xc(e);const t=e,n=Yo(t,"toString");if(typeof n=="function"){const r=n(t);return typeof r=="string"?r:Xc(r)}return Xc(e)}default:return Xc(e)}}function Yo(e,t){for(;e!==null;){const r=Z8(e,t);if(r){if(r.get)return pr(r.get);if(typeof r.value=="function")return pr(r.value)}e=q8(e)}function n(){return null}return n}function n9(e){try{return Wr(e,""),!0}catch{return!1}}const m1=wr(["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"]),vg=wr(["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"]),bg=wr(["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"]),r9=wr(["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"]),xg=wr(["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"]),o9=wr(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),g1=wr(["#text"]),k1=wr(["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"]),Eg=wr(["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"]),w1=wr(["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=wr(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),s9=$r(/{{[\w\W]*|^[\w\W]*}}/g),i9=$r(/<%[\w\W]*|^[\w\W]*%>/g),a9=$r(/\${[\w\W]*/g),l9=$r(/^data-[\-\w.\u00B7-\uFFFF]+$/),c9=$r(/^aria-[\-\w]+$/),y1=$r(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),u9=$r(/^(?:\w+script|data):/i),d9=$r(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),f9=$r(/^html$/i),h9=$r(/^[a-z][.\w]*(-[.\w]+)+$/i),v1=$r(/<[/\w!]/g),b1=$r(/<[/\w]/g),p9=$r(/<\/no(script|embed|frames)/i),m9=$r(/\/>/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},hj=["style","script","xmp","iframe","noembed","noframes","plaintext","noscript"],g9=wr(gn({},hj)),k9=(function(){const e={};return ua(hj,t=>{e[t]=$r(new RegExp("</"+t+"(?=[\\t\\n\\f\\r />])","i"))}),wr(e)})(),w9=function(){return typeof window>"u"?null:window},y9=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}},x1=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},wi=function(t,n,r,o){return co(t,n)&&Bl(t[n])?gn(o.base?Eo(o.base):{},t[n],o.transform):r},Sg=function(t,n,r){const o=co(t,n)?t[n]:void 0;return o&&typeof o=="object"?Eo(o):r()};function pj(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:w9();const t=Oe=>pj(Oe);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,h=e.NamedNodeMap;h===void 0&&(e.NamedNodeMap||e.MozNamedAttrMap),e.HTMLFormElement;const f=e.DOMParser,m=e.trustedTypes,g=c.prototype,y=Yo(g,"cloneNode"),w=Yo(g,"remove"),v=Yo(g,"nextSibling"),N=Yo(g,"childNodes"),x=Yo(g,"parentNode"),_=Yo(g,"shadowRoot"),j=Yo(g,"attributes"),T=a&&a.prototype?Yo(a.prototype,"nodeType"):null,I=a&&a.prototype?Yo(a.prototype,"nodeName"):null,R=a&&a.prototype?Yo(a.prototype,"ownerDocument"):null,C=function(F){return T?T(F):F.nodeType},O=function(F){return I?I(F):F.nodeName};if(typeof s=="function"){const Oe=n.createElement("template");Oe.content&&Oe.content.ownerDocument&&(n=Oe.content.ownerDocument)}let A,D="",B,W=!1,U=0;const Q=function(){if(U>0)throw la('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.')},Y=function(F){Q(),U++;try{return A.createHTML(F)}finally{U--}},se=function(F){Q(),U++;try{return A.createScriptURL(F)}finally{U--}},H=function(){return W||(B=y9(m,o),W=!0),B},$=n,Z=$.implementation,q=$.createNodeIterator,K=$.createDocumentFragment,ne=$.getElementsByTagName,de=r.importNode;let pe=x1();t.isSupported=typeof dj=="function"&&typeof x=="function"&&Z&&Z.createHTMLDocument!==void 0;const je=s9,_e=i9,fe=a9,te=l9,re=c9,we=u9,ue=d9,le=h9;let be=y1,Ce=null;const Ne=gn({},[...m1,...vg,...bg,...xg,...g1]);let Ie=null;const Be=gn({},[...k1,...Eg,...w1,...$f]);let Je=Object.seal(Tl(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}})),zt=null,Yt=null;const _t=Object.seal(Tl(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let qe=!0,xt=!0,ht=!1,De=!0,nt=!1,at=!0,Xt=!1,Nt=!1,Zt=null,gt=null,nr=!1,Jt=!1,Rn=!1,Kn=!1,un=!0,vn=!1;const J="user-content-";let ye=!0,We=!1,rt={},jt=null;const Ft=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 oe=gn({},["audio","video","img","source","image","track"]);let $e=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",Gt="http://www.w3.org/2000/svg",Re="http://www.w3.org/1999/xhtml";let He=Re,Ze=!1,Qt=null;const Wt=gn({},[Rt,Gt,Re],yg),En=wr(["mi","mo","mn","ms","mtext"]);let Sn=gn({},En);const Ct=wr(["annotation-xml"]);let nn=gn({},Ct);const sr=gn({},["title","style","font","a","script"]);let Pt=null;const bn=["application/xhtml+xml","text/html"],fn="text/html";let ie=null,Te=null;const dt=n.createElement("form"),lt=function(F){return F instanceof RegExp||F instanceof Function},Bt=function(){let F=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(Te&&Te===F)return;(!F||typeof F!="object")&&(F={}),F=Eo(F),Pt=bn.indexOf(F.PARSER_MEDIA_TYPE)===-1?fn:F.PARSER_MEDIA_TYPE,ie=Pt==="application/xhtml+xml"?yg:ru,Ce=wi(F,"ALLOWED_TAGS",Ne,{transform:ie}),Ie=wi(F,"ALLOWED_ATTR",Be,{transform:ie}),Qt=wi(F,"ALLOWED_NAMESPACES",Wt,{transform:yg}),$e=wi(F,"ADD_URI_SAFE_ATTR",Fe,{transform:ie,base:Fe}),P=wi(F,"ADD_DATA_URI_TAGS",oe,{transform:ie,base:oe}),jt=wi(F,"FORBID_CONTENTS",Ft,{transform:ie}),zt=wi(F,"FORBID_TAGS",Eo({}),{transform:ie}),Yt=wi(F,"FORBID_ATTR",Eo({}),{transform:ie}),rt=co(F,"USE_PROFILES")?F.USE_PROFILES&&typeof F.USE_PROFILES=="object"?Eo(F.USE_PROFILES):F.USE_PROFILES:!1,qe=F.ALLOW_ARIA_ATTR!==!1,xt=F.ALLOW_DATA_ATTR!==!1,ht=F.ALLOW_UNKNOWN_PROTOCOLS||!1,De=F.ALLOW_SELF_CLOSE_IN_ATTR!==!1,nt=F.SAFE_FOR_TEMPLATES||!1,at=F.SAFE_FOR_XML!==!1,Xt=F.WHOLE_DOCUMENT||!1,Jt=F.RETURN_DOM||!1,Rn=F.RETURN_DOM_FRAGMENT||!1,Kn=F.RETURN_TRUSTED_TYPE||!1,nr=F.FORCE_BODY||!1,un=F.SANITIZE_DOM!==!1,vn=F.SANITIZE_NAMED_PROPS||!1,ye=F.KEEP_CONTENT!==!1,We=F.IN_PLACE||!1,be=n9(F.ALLOWED_URI_REGEXP)?F.ALLOWED_URI_REGEXP:y1,He=typeof F.NAMESPACE=="string"?F.NAMESPACE:Re,Sn=Sg(F,"MATHML_TEXT_INTEGRATION_POINTS",()=>gn({},En)),nn=Sg(F,"HTML_INTEGRATION_POINTS",()=>gn({},Ct));const G=Sg(F,"CUSTOM_ELEMENT_HANDLING",()=>Tl(null));if(Je=Tl(null),co(G,"tagNameCheck")&&lt(G.tagNameCheck)&&(Je.tagNameCheck=G.tagNameCheck),co(G,"attributeNameCheck")&&lt(G.attributeNameCheck)&&(Je.attributeNameCheck=G.attributeNameCheck),co(G,"allowCustomizedBuiltInElements")&&typeof G.allowCustomizedBuiltInElements=="boolean"&&(Je.allowCustomizedBuiltInElements=G.allowCustomizedBuiltInElements),$r(Je),nt&&(xt=!1),Rn&&(Jt=!0),rt&&(Ce=gn({},g1),Ie=Tl(null),rt.html===!0&&(gn(Ce,m1),gn(Ie,k1)),rt.svg===!0&&(gn(Ce,vg),gn(Ie,Eg),gn(Ie,$f)),rt.svgFilters===!0&&(gn(Ce,bg),gn(Ie,Eg),gn(Ie,$f)),rt.mathMl===!0&&(gn(Ce,xg),gn(Ie,w1),gn(Ie,$f))),_t.tagCheck=null,_t.attributeCheck=null,co(F,"ADD_TAGS")&&(typeof F.ADD_TAGS=="function"?_t.tagCheck=F.ADD_TAGS:Bl(F.ADD_TAGS)&&(Ce===Ne&&(Ce=Eo(Ce)),gn(Ce,F.ADD_TAGS,ie))),co(F,"ADD_ATTR")&&(typeof F.ADD_ATTR=="function"?_t.attributeCheck=F.ADD_ATTR:Bl(F.ADD_ATTR)&&(Ie===Be&&(Ie=Eo(Ie)),gn(Ie,F.ADD_ATTR,ie))),co(F,"ADD_FORBID_CONTENTS")&&Bl(F.ADD_FORBID_CONTENTS)&&(jt===Ft&&(jt=Eo(jt)),gn(jt,F.ADD_FORBID_CONTENTS,ie)),ye&&(Ce["#text"]=!0),Xt&&gn(Ce,["html","head","body"]),Ce.table&&(gn(Ce,["tbody"]),delete zt.tbody),F.TRUSTED_TYPES_POLICY){if(typeof F.TRUSTED_TYPES_POLICY.createHTML!="function")throw la('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof F.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw la('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');const ce=A;A=F.TRUSTED_TYPES_POLICY;try{D=Y("")}catch(Ee){throw A=ce,Ee}}else F.TRUSTED_TYPES_POLICY===null?(A=void 0,D=""):(A===void 0&&(A=H()),A&&typeof D=="string"&&(D=Y("")));wr&&wr(F),Te=F},kn=gn({},[...vg,...bg,...r9]),Dr=gn({},[...xg,...o9]),lr=function(F,G,ce){return G.namespaceURI===Re?F==="svg":G.namespaceURI===Rt?F==="svg"&&(ce==="annotation-xml"||Sn[ce]):!!kn[F]},ln=function(F,G,ce){return G.namespaceURI===Re?F==="math":G.namespaceURI===Gt?F==="math"&&nn[ce]:!!Dr[F]},cr=function(F,G,ce){return G.namespaceURI===Gt&&!nn[ce]||G.namespaceURI===Rt&&!Sn[ce]?!1:!Dr[F]&&(sr[F]||!kn[F])},rn=function(F){let G=x(F);(!G||!G.tagName)&&(G={namespaceURI:He,tagName:"template"});const ce=ru(F.tagName),Ee=ru(G.tagName);return Qt[F.namespaceURI]?F.namespaceURI===Gt?lr(ce,G,Ee):F.namespaceURI===Rt?ln(ce,G,Ee):F.namespaceURI===Re?cr(ce,G,Ee):!!(Pt==="application/xhtml+xml"&&Qt[F.namespaceURI]):!1},Ht=function(F){Vc(t.removed,{element:F});try{x(F).removeChild(F)}catch{if(w(F),!x(F))throw la("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},Ut=function(F,G,ce){try{F.removeAttributeNode(G)}catch{try{F.removeAttribute(ce)}catch{}}},xe=function(F){wt(F);const G=N(F);if(G){const Ee=[];ua(G,ve=>{Vc(Ee,ve)}),ua(Ee,ve=>{try{w(ve)}catch{}})}const ce=j(F);if(ce)for(let Ee=ce.length-1;Ee>=0;--Ee){const ve=ce[Ee],Ye=ve&&ve.name;typeof Ye=="string"&&Ut(F,ve,Ye)}},Ge=function(F,G,ce){if(!ce)try{ce=G.getAttributeNode(F)}catch{ce=null}Vc(t.removed,{attribute:ce||null,from:G});try{ce?G.removeAttributeNode(ce):G.removeAttribute(F)}catch{try{G.removeAttribute(F)}catch{}}if(F==="is")if(Jt||Rn)try{Ht(G)}catch{}else try{G.setAttribute(F,"")}catch{}},kt=function(F){const G=j(F);if(G)for(let ce=G.length-1;ce>=0;--ce){const Ee=G[ce],ve=Ee&&Ee.name;typeof ve!="string"||Ie[ie(ve)]||Ut(F,Ee,ve)}},wt=function(F){const G=[F];for(;G.length>0;){const ce=G.pop();C(ce)===xo.element&&kt(ce);const ve=N(ce);if(ve)for(let Ye=ve.length-1;Ye>=0;--Ye)G.push(ve[Ye])}},on=function(F,G){return at?F==="patchsrc"?!0:F==="for"&&G!=="label"&&G!=="output":!1},dn=function(F){if(!at)return;const G=[F];for(;G.length>0;){const ce=G.pop(),Ee=C(ce);if(Ee===xo.processingInstruction||Ee===xo.comment&&Wr(b1,ce.data)){try{w(ce)}catch{}continue}if(Ee===xo.element){const Ye=ce,vt=ie(O(ce));try{Ye.hasAttribute&&Ye.hasAttribute("patchsrc")&&Ye.removeAttribute("patchsrc"),Ye.hasAttribute&&Ye.hasAttribute("for")&&on("for",vt)&&Ye.removeAttribute("for")}catch{}}const ve=N(ce);if(ve)for(let Ye=ve.length-1;Ye>=0;--Ye)G.push(ve[Ye])}},Cn=function(F){let G=null,ce=null;if(nr)F="<remove></remove>"+F;else{const Ye=d1(F,/^[\r\n\t ]+/);ce=Ye&&Ye[0]}Pt==="application/xhtml+xml"&&He===Re&&(F='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+F+"</body></html>");const Ee=A?Y(F):F;if(He===Re)try{G=new f().parseFromString(Ee,Pt)}catch{}if(!G||!G.documentElement){G=Z.createDocument(He,"template",null);try{G.documentElement.innerHTML=Ze?D:Ee}catch{}}const ve=G.body||G.documentElement;return F&&ce&&ve.insertBefore(n.createTextNode(ce),ve.childNodes[0]||null),He===Re?ne.call(G,Xt?"html":"body")[0]:Xt?G.documentElement:ve},wn=function(F){const G=R?R(F):F.ownerDocument;return q.call(G||F,F,u.SHOW_ELEMENT|u.SHOW_COMMENT|u.SHOW_TEXT|u.SHOW_PROCESSING_INSTRUCTION|u.SHOW_CDATA_SECTION,null)},hn=function(F){return F=Yc(F,je," "),F=Yc(F,_e," "),F=Yc(F,fe," "),F},Ln=function(F){var G;F.normalize();const ce=R?R(F):F.ownerDocument,Ee=q.call(ce||F,F,u.SHOW_TEXT|u.SHOW_COMMENT|u.SHOW_CDATA_SECTION|u.SHOW_PROCESSING_INSTRUCTION,null);let ve=Ee.nextNode();for(;ve;)ve.data=hn(ve.data),ve=Ee.nextNode();const Ye=(G=F.querySelectorAll)===null||G===void 0?void 0:G.call(F,"template");Ye&&ua(Ye,vt=>{X(vt.content)&&Ln(vt.content)})},vr=function(F){const G=I?I(F):null;return typeof G!="string"||ie(G)!=="form"?!1:typeof F.nodeName!="string"||typeof F.textContent!="string"||typeof F.removeChild!="function"||F.attributes!==j(F)||typeof F.removeAttribute!="function"||typeof F.setAttribute!="function"||typeof F.namespaceURI!="string"||typeof F.insertBefore!="function"||typeof F.hasChildNodes!="function"||F.nodeType!==T(F)||F.childNodes!==N(F)},X=function(F){if(!T||typeof F!="object"||F===null)return!1;try{return T(F)===xo.documentFragment}catch{return!1}},ge=function(F){if(!T||typeof F!="object"||F===null)return!1;try{return typeof T(F)=="number"}catch{return!1}};function Ve(Oe,F,G){Oe.length!==0&&ua(Oe,ce=>{ce.call(t,F,G,Te)})}const Kt=function(F,G){return!!(at&&F.hasChildNodes()&&!ge(F.firstElementChild)&&Wr(v1,F.textContent)&&Wr(v1,F.innerHTML)||at&&F.namespaceURI===Re&&g9[G]&&(ge(F.firstElementChild)||typeof F.textContent=="string"&&Wr(k9[G],F.textContent))||F.nodeType===xo.processingInstruction||at&&F.nodeType===xo.comment&&Wr(b1,F.data))},Mt=function(F,G){if(F instanceof RegExp)return Wr(F,G);if(F instanceof Function){for(var ce=arguments.length,Ee=new Array(ce>2?ce-2:0),ve=2;ve<ce;ve++)Ee[ve-2]=arguments[ve];return!!F(G,...Ee)}return!1},pn=function(F,G,ce){if(!zt[G]&&yt(G)&&Mt(Je.tagNameCheck,G))return!1;if(ye&&!jt[G]){const Ee=x(F),ve=N(F);if(ve&&Ee){const Ye=ve.length;for(let vt=Ye-1;vt>=0;--vt){const Nn=F===ce?y(ve[vt],!0):ve[vt];Ee.insertBefore(Nn,v(F))}}}return Ht(F),!0},_n=function(F,G,ce,Ee){return F.length===0?G:G===ce||G===Ee?Eo(G):G},zr=function(F,G){return F===G||x(F)!==null?!1:(We&&wt(F),!0)},qn=function(F,G){if(Ve(pe.beforeSanitizeElements,F,null),zr(F,G))return!0;if(vr(F))return Ht(F),!0;const ce=ie(O(F));if(Ce=_n(pe.uponSanitizeElement,Ce,Ne,Zt),Ve(pe.uponSanitizeElement,F,{tagName:ce,allowedTags:Ce}),zr(F,G))return!0;if(Kt(F,ce))return Ht(F),!0;if(zt[ce]||!(_t.tagCheck instanceof Function&&_t.tagCheck(ce))&&!Ce[ce]){const ve=pn(F,ce,G);return ve===!1&&Ve(pe.afterSanitizeElements,F,null),ve}if(C(F)===xo.element&&!rn(F)||(ce==="noscript"||ce==="noembed"||ce==="noframes")&&Wr(p9,F.innerHTML))return Ht(F),!0;if(nt&&F.nodeType===xo.text){const ve=hn(F.textContent);F.textContent!==ve&&(Vc(t.removed,{element:F.cloneNode()}),F.textContent=ve)}return Ve(pe.afterSanitizeElements,F,null),!1},os=function(F,G,ce){if(Yt[G]||on(G,F)||un&&(G==="id"||G==="name")&&(ce in n||ce in dt))return!1;const Ee=Ie[G]||_t.attributeCheck instanceof Function&&_t.attributeCheck(G,F);return xt&&Wr(te,G)||qe&&Wr(re,G)?!0:Ee?$e[G]||Wr(be,Yc(ce,ue,""))||(G==="src"||G==="xlink:href"||G==="href")&&F!=="script"&&f1(ce,"data:")===0&&P[F]||ht&&!Wr(we,Yc(ce,ue,""))?!0:!ce:yt(F)&&Mt(Je.tagNameCheck,F)&&Mt(Je.attributeNameCheck,G,F)||G==="is"&&Je.allowCustomizedBuiltInElements&&Mt(Je.tagNameCheck,ce)},Vt=gn({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),yt=function(F){return!Vt[ru(F)]&&Wr(le,F)},ys=function(F,G,ce,Ee){if(A&&typeof m=="object"&&typeof m.getAttributeType=="function"&&!ce)switch(m.getAttributeType(F,G)){case"TrustedHTML":return Y(Ee);case"TrustedScriptURL":return se(Ee)}return Ee},An=function(F,G,ce,Ee){try{ce?F.setAttributeNS(ce,G,Ee):F.setAttribute(G,Ee),vr(F)?Ht(F):u1(t.removed)}catch{Ge(G,F)}},sn=function(F){Ve(pe.beforeSanitizeAttributes,F,null);const G=F.attributes;if(!G||vr(F))return;Ie=_n(pe.uponSanitizeAttribute,Ie,Be,gt);const ce={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:Ie,forceKeepAttr:void 0};let Ee=G.length;const ve=ie(F.nodeName);for(;Ee--;){const Ye=G[Ee],vt=Ye.name,Nn=Ye.namespaceURI,Fn=Ye.value,Xn=ie(vt),Ar=Fn;let ir=vt==="value"?Ar:Y8(Ar);if(ce.attrName=Xn,ce.attrValue=ir,ce.keepAttr=!0,ce.forceKeepAttr=void 0,Ve(pe.uponSanitizeAttribute,F,ce),ir=ce.attrValue,vn&&(Xn==="id"||Xn==="name")&&f1(ir,J)!==0&&(Ge(vt,F,Ye),ir=J+ir),at&&Wr(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,ir)){Ge(vt,F,Ye);continue}if(Xn==="attributename"&&d1(ir,"href")){Ge(vt,F,Ye);continue}if(!ce.forceKeepAttr){if(!ce.keepAttr){Ge(vt,F,Ye);continue}if(!De&&Wr(m9,ir)){Ge(vt,F,Ye);continue}if(nt&&(ir=hn(ir)),!os(ve,Xn,ir)){Ge(vt,F,Ye);continue}ir=ys(ve,Xn,Nn,ir),ir!==Ar&&An(F,vt,Nn,ir)}}Ve(pe.afterSanitizeAttributes,F,null)},br=function(F){let G=null;const ce=wn(F);for(Ve(pe.beforeSanitizeShadowDOM,F,null);G=ce.nextNode();)if(Ve(pe.uponSanitizeShadowNode,G,null),qn(G,F),sn(G),X(G.content)&&br(G.content),C(G)===xo.element){const Ee=_(G);X(Ee)&&(Cr(Ee),br(Ee))}Ve(pe.afterSanitizeShadowDOM,F,null)},Cr=function(F){const G=[{node:F,shadow:null}];for(;G.length>0;){const ce=G.pop();if(ce.shadow){br(ce.shadow);continue}const Ee=ce.node,Ye=C(Ee)===xo.element,vt=N(Ee);if(vt)for(let Nn=vt.length-1;Nn>=0;--Nn)G.push({node:vt[Nn],shadow:null});if(Ye){const Nn=I?I(Ee):null;if(typeof Nn=="string"&&ie(Nn)==="template"){const Fn=Ee.content;X(Fn)&&G.push({node:Fn,shadow:null})}}if(Ye){const Nn=_(Ee);X(Nn)&&G.push({node:null,shadow:Nn},{node:Nn,shadow:null})}}};return t.sanitize=function(Oe){let F=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},G=null,ce=null,Ee=null,ve=null;if(Ze=!Oe,Ze&&(Oe="<!-->"),typeof Oe!="string"&&!ge(Oe)&&(Oe=t9(Oe),typeof Oe!="string"))throw la("dirty is not a string, aborting");if(!t.isSupported)return Oe;Nt?(Ce=Zt,Ie=gt):Bt(F),(pe.uponSanitizeElement.length>0||pe.uponSanitizeAttribute.length>0)&&(Ce=Eo(Ce)),pe.uponSanitizeAttribute.length>0&&(Ie=Eo(Ie)),t.removed=[];const Ye=We&&typeof Oe!="string"&&ge(Oe);if(Ye){dn(Oe);const Fn=O(Oe);if(typeof Fn=="string"){const Xn=ie(Fn);if(!Ce[Xn]||zt[Xn])throw xe(Oe),la("root node is forbidden and cannot be sanitized in-place")}if(vr(Oe))throw xe(Oe),la("root node is clobbered and cannot be sanitized in-place");try{Cr(Oe)}catch(Xn){throw xe(Oe),Xn}}else if(ge(Oe))G=Cn("<!---->"),ce=G.ownerDocument.importNode(Oe,!0),ce.nodeType===xo.element&&ce.nodeName==="BODY"||ce.nodeName==="HTML"?G=ce:G.appendChild(ce),Cr(ce);else{if(!Jt&&!nt&&!Xt&&Oe.indexOf("<")===-1)return A&&Kn?Y(Oe):Oe;if(G=Cn(Oe),!G)return Jt?null:Kn?D:""}G&&nr&&Ht(G.firstChild);const vt=Ye?Oe:G;try{const Fn=wn(vt);for(;Ee=Fn.nextNode();)qn(Ee,vt),sn(Ee),X(Ee.content)&&br(Ee.content)}catch(Fn){throw Ye&&(xe(Oe),ua(t.removed,Xn=>{Xn.element&&wt(Xn.element)})),Fn}if(Ye)return ua(t.removed,Fn=>{Fn.element&&wt(Fn.element)}),nt&&Ln(Oe),Oe;if(Jt){if(nt&&Ln(G),Rn)for(ve=K.call(G.ownerDocument);G.firstChild;)ve.appendChild(G.firstChild);else ve=G;return(Ie.shadowroot||Ie.shadowrootmode)&&(ve=de.call(r,ve,!0)),ve}let Nn=Xt?G.outerHTML:G.innerHTML;return Xt&&Ce["!doctype"]&&G.ownerDocument&&G.ownerDocument.doctype&&G.ownerDocument.doctype.name&&Wr(f9,G.ownerDocument.doctype.name)&&(Nn="<!DOCTYPE "+G.ownerDocument.doctype.name+`>
139
- `+Nn),nt&&(Nn=hn(Nn)),A&&Kn?Y(Nn):Nn},t.setConfig=function(){let Oe=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Bt(Oe),Nt=!0,Zt=Ce,gt=Ie},t.clearConfig=function(){Te=null,Nt=!1,Zt=null,gt=null,A=B,D=""},t.isValidAttribute=function(Oe,F,G){Te||Bt({});const ce=ie(Oe),Ee=ie(F);return os(ce,Ee,G)},t.addHook=function(Oe,F){typeof F=="function"&&co(pe,Oe)&&Vc(pe[Oe],F)},t.removeHook=function(Oe,F){if(co(pe,Oe)){if(F!==void 0){const G=G8(pe[Oe],F);return G===-1?void 0:V8(pe[Oe],G,1)[0]}return u1(pe[Oe])}},t.removeHooks=function(Oe){co(pe,Oe)&&(pe[Oe]=[])},t.removeAllHooks=function(){pe=x1()},t}var v9=pj();function Ty(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var Da=Ty();function mj(e){Da=e}var pa={exec:()=>null};function Sl(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(qr.caret,"$1"),n=n.replace(o,a),r},getRegex:()=>new RegExp(n,t)};return r}var b9=((e="")=>{try{return!!new RegExp("(?<=1)(?<!1)"+e)}catch{return!1}})(),qr={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:Sl(e=>new RegExp(`^ {0,${e}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`)),hrRegex:Sl(e=>new RegExp(`^ {0,${e}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`)),fencesBeginRegex:Sl(e=>new RegExp(`^ {0,${e}}(?:\`\`\`|~~~)`)),headingBeginRegex:Sl(e=>new RegExp(`^ {0,${e}}#`)),htmlBeginRegex:Sl(e=>new RegExp(`^ {0,${e}}<(?:[a-z].*>|!--)`,"i")),blockquoteBeginRegex:Sl(e=>new RegExp(`^ {0,${e}}>`))},x9=/^(?:[ \t]*(?:\n|$))+/,E9=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,S9=/^ {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+|$)/,_9=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,jy=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,gj=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,kj=an(gj).replace(/bull/g,jy).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(),N9=an(gj).replace(/bull/g,jy).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(),$y=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table|[ \t]+\n)[^\n]+)*)/,T9=/^[^\n]+/,Cy=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,j9=an(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Cy).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),$9=an(/^(bull)([ \t][^\n]*?)?(?:\n|$)/).replace(/bull/g,jy).getRegex(),gp="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",Ay=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,C9=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",Ay).replace("tag",gp).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),wj=e=>an($y).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",gp).getRegex(),A9=wj(/ {0,3}(?:[*+-]|1[.)])[ \t]+[^ \t\n]/),I9=wj(/ {0,3}(?:[*+-]|\d{1,9}[.)])(?:[ \t]|\n|$)/),R9=an(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",I9).getRegex(),Iy={blockquote:R9,code:E9,def:j9,fences:S9,heading:_9,hr:Ju,html:C9,lheading:kj,list:$9,newline:x9,paragraph:A9,table:pa,text:T9},E1=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",gp).getRegex(),O9={...Iy,lheading:N9,table:E1,paragraph:an($y).replace("hr",Ju).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",E1).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",gp).getRegex()},M9={...Iy,html:an(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Ay).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:pa,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:an($y).replace("hr",Ju).replace("heading",` *#{1,6} *[^
140
- ]`).replace("lheading",kj).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},L9=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,P9=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,yj=/^( {2,}|\\)\n(?!\s*$)/,D9=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,Ws=/[\p{P}\p{S}]/u,rc=/[\s\p{P}\p{S}]/u,ed=/[^\s\p{P}\p{S}]/u,z9=an(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,rc).getRegex(),F9=/[\p{Pi}\p{Ps}"']/u,vj=/(?!~)[\p{P}\p{S}]/u,B9=/(?!~)[\s\p{P}\p{S}]/u,U9=/(?:[^\s\p{P}\p{S}]|~)/u,H9=an(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",b9?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),bj=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,W9=an(bj,"u").replace(/punct/g,Ws).getRegex(),K9=an(bj,"u").replace(/punct/g,vj).getRegex(),q9=/^(?:\*+(?:((?!\*)(?!openQuote)punct)|([^\s*]))?)|^_+(?:((?!_)(?!openQuote)punct)|([^\s_]))?/,Z9=an(q9,"u").replace(/openQuote/g,F9).replace(/punct/g,Ws).getRegex(),xj="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",G9=an(xj,"gu").replace(/notPunctSpace/g,ed).replace(/punctSpace/g,rc).replace(/punct/g,Ws).getRegex(),V9=an(xj,"gu").replace(/notPunctSpace/g,U9).replace(/punctSpace/g,B9).replace(/punct/g,vj).getRegex(),Y9="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)[\\s](\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|(?:(?!\\*)punct|notPunctSpace)(\\*+)(?!\\*)(?=notPunctSpace)",X9=an(Y9,"gu").replace(/notPunctSpace/g,ed).replace(/punctSpace/g,rc).replace(/punct/g,Ws).getRegex(),Q9=an("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,ed).replace(/punctSpace/g,rc).replace(/punct/g,Ws).getRegex(),J9="^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)[\\s](_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)|(?:(?!_)punct|notPunctSpace)(_+)(?!_)(?=notPunctSpace)",eB=an(J9,"gu").replace(/notPunctSpace/g,ed).replace(/punctSpace/g,rc).replace(/punct/g,Ws).getRegex(),tB=an(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,Ws).getRegex(),nB="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",rB=an(nB,"gu").replace(/notPunctSpace/g,ed).replace(/punctSpace/g,rc).replace(/punct/g,Ws).getRegex(),oB=an(/\\(punct)/,"gu").replace(/punct/g,Ws).getRegex(),sB=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(),iB=an(Ay).replace("(?:-->|$)","-->").getRegex(),aB=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",iB).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),gh=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,lB=an(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",gh).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]+|(?=\))/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Ej=an(/^!?\[(label)\]\[(ref)\]/).replace("label",gh).replace("ref",Cy).getRegex(),Sj=an(/^!?\[(ref)\](?:\[\])?/).replace("ref",Cy).getRegex(),cB=an("reflink|nolink(?!\\()","g").replace("reflink",Ej).replace("nolink",Sj).getRegex(),S1=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,Ry={_backpedal:pa,anyPunctuation:oB,autolink:sB,blockSkip:H9,br:yj,code:P9,del:pa,delLDelim:pa,delRDelim:pa,emStrongLDelim:W9,emStrongRDelimAst:G9,emStrongRDelimUnd:Q9,escape:L9,link:lB,nolink:Sj,punctuation:z9,reflink:Ej,reflinkSearch:cB,tag:aB,text:D9,url:pa},uB={...Ry,emStrongLDelim:Z9,emStrongRDelimAst:X9,emStrongRDelimUnd:eB,link:an(/^!?\[(label)\]\((.*?)\)/).replace("label",gh).getRegex(),reflink:an(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",gh).getRegex()},Ok={...Ry,emStrongRDelimAst:V9,emStrongLDelim:K9,delLDelim:tB,delRDelim:rB,url:an(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",S1).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",S1).getRegex()},dB={...Ok,br:an(yj).replace("{2,}","*").getRegex(),text:an(Ok.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},Cf={normal:Iy,gfm:O9,pedantic:M9},Qc={normal:Ry,gfm:Ok,breaks:dB,pedantic:uB},fB={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},_1=e=>fB[e];function fs(e,t){if(t){if(qr.escapeTest.test(e))return e.replace(qr.escapeReplace,_1)}else if(qr.escapeTestNoEncode.test(e))return e.replace(qr.escapeReplaceNoEncode,_1);return e}function N1(e){try{e=encodeURI(e).replace(qr.percentDecode,"%")}catch{return null}return e}function T1(e,t){var s;let n=e.replace(qr.findPipe,(a,c,u)=>{let h=!1,f=c;for(;--f>=0&&u[f]==="\\";)h=!h;return h?"|":" |"}),r=n.split(qr.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(qr.slashPipe,"|");return r}function yi(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 j1(e){let t=e.split(`
141
- `),n=t.length-1;for(;n>=0&&qr.blankLine.test(t[n]);)n--;return t.length-n<=2?e:t.slice(0,n+1).join(`
142
- `)}function hB(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 pB(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 $1(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 h=r.state.linkEmitted,f=r.state.inRawBlock;r.state.linkEmitted=!1;let m=r.inlineTokens(c),g=r.state.linkEmitted;if(r.state.linkEmitted=h,r.state.inLink=!1,!u){if(g){r.state.inRawBlock=f;return}r.state.linkEmitted=!0}return{type:u?"image":"link",raw:n,href:s,title:a,text:c,tokens:m}}function mB(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){Tt(this,"options");Tt(this,"rules");Tt(this,"lexer");this.options=e||Da}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]:j1(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=mB(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=yi(n,"#");(this.options.pedantic||!r||this.rules.other.endingSpaceChar.test(r))&&(n=r.trim())}return{type:"heading",raw:yi(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:yi(t[0],`
146
- `)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let n=yi(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 h=c.join(`
149
- `),f=h.replace(this.rules.other.blockquoteSetextReplace,`
150
- $1`).replace(this.rules.other.blockquoteSetextReplace2,"");r=r?`${r}
151
- ${h}`:h,o=o?`${o}
152
- ${f}`:f;let m=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(f,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,""),N=this.blockquote(v);s[s.length-1]=N,r=`${r}
155
- ${w}`,o=o.substring(0,o.length-y.text.length)+N.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,h="",f="";if(!(t=s.exec(e))||this.rules.block.hr.test(e))break;h=t[0],e=e.substring(h.length);let m=pB(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,f=m.trimStart()):y?w=t[1].length+1:(w=m.search(this.rules.other.nonSpaceChar),w=w>4?1:w,f=m.slice(w),w+=t[1].length),y&&this.rules.other.blankLine.test(g)&&(h+=g+`
161
- `,e=e.substring(g.length+1),u=!0),!u){let v=this.rules.other.nextBulletRegex(w),N=this.rules.other.hrRegex(w),x=this.rules.other.fencesBeginRegex(w),_=this.rules.other.headingBeginRegex(w),j=this.rules.other.htmlBeginRegex(w),T=this.rules.other.blockquoteBeginRegex(w);for(;e;){let I=e.split(`
162
- `,1)[0],R;if(g=I,this.options.pedantic?(g=g.replace(this.rules.other.listReplaceNesting," "),R=g):R=g.replace(this.rules.other.tabCharGlobal," "),x.test(g)||_.test(g)||j.test(g)||T.test(g)||v.test(g)||N.test(g))break;if(R.search(this.rules.other.nonSpaceChar)>=w||!g.trim())f+=`
163
- `+R.slice(w);else{if(y||m.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||x.test(m)||_.test(m)||N.test(m))break;f+=`
164
- `+g}y=!g.trim(),h+=I+`
165
- `,e=e.substring(I.length+1),m=R.slice(w)}}o.loose||(a?o.loose=!0:this.rules.other.doubleBlankLine.test(h)&&(a=!0)),o.items.push({type:"list_item",raw:h,task:!!this.options.gfm&&this.rules.other.listIsTask.test(f),loose:!1,text:f,tokens:[]}),o.raw+=h}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 h=u.tokens.filter(m=>m.type==="space"),f=h.length>0&&h.some(m=>this.rules.other.anyLine.test(m.raw));o.loose=f}for(let u of o.items){let h=u.tokens[0];if(u.task&&((h==null?void 0:h.type)==="text"||(h==null?void 0:h.type)==="paragraph")){u.text=u.text.replace(this.rules.other.listReplaceTask,""),h.raw=h.raw.replace(this.rules.other.listReplaceTask,""),h.text=h.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 f=this.rules.other.listTaskCheckbox.exec(u.raw);if(f){let m={type:"checkbox",raw:f[0]+" ",checked:f[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 h of u.tokens)h.type==="text"&&(h.type="paragraph")}return o}}html(e){let t=this.rules.block.html.exec(e);if(t){let n=j1(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:yi(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=T1(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:yi(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(T1(c,s.header.length).map((u,h)=>({text:u,tokens:this.lexer.inline(u),header:!1,align:s.align[h]})));return s}}lheading(e){let t=this.rules.block.lheading.exec(e);if(t){let n=t[1].trim();return{type:"heading",raw:yi(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=yi(n.slice(0,-1),"\\");if((n.length-s.length)%2===0)return}else{let s=hB(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)),$1(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 $1(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,h=r[0][0],f=n===h,m=h==="*"?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(f)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 h=[...r[0]][0].length,f=e.slice(0,o+r.index+h+a),m=f.slice(o,-o);return{type:"del",raw:f,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}}}},Qo=class Mk{constructor(t){Tt(this,"tokens");Tt(this,"options");Tt(this,"state");Tt(this,"inlineQueue");Tt(this,"tokenizer");this.tokens=[],this.tokens.links=Object.create(null),this.options=t||Da,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:qr,block:Cf.normal,inline:Qc.normal};this.options.pedantic?(n.block=Cf.pedantic,n.inline=Qc.pedantic):this.options.gfm&&(n.block=Cf.gfm,this.options.breaks?n.inline=Qc.breaks:n.inline=Qc.gfm),this.tokenizer.rules=n}static get rules(){return{block:Cf,inline:Qc}}static lex(t,n){return new Mk(n).lex(t)}static lexInline(t,n){return new Mk(n).inlineTokens(t)}lex(t){t=t.replace(qr.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(qr.tabCharGlobal," ").replace(qr.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(f=>(u=f.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 f=n.at(-1);u.raw.length===1&&f!==void 0?f.raw+=`
172
- `:n.push(u);continue}if(u=this.tokenizer.code(t)){t=t.substring(u.raw.length);let f=n.at(-1);(f==null?void 0:f.type)==="paragraph"||(f==null?void 0:f.type)==="text"?(f.raw+=(f.raw.endsWith(`
173
- `)?"":`
174
- `)+u.raw,f.text+=`
175
- `+u.text,this.inlineQueue.at(-1).src=f.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 f=n.at(-1);(f==null?void 0:f.type)==="paragraph"||(f==null?void 0:f.type)==="text"?(f.raw+=(f.raw.endsWith(`
176
- `)?"":`
177
- `)+u.raw,f.text+=`
178
- `+u.raw,this.inlineQueue.at(-1).src=f.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 h=t;if((c=this.options.extensions)!=null&&c.startBlock){let f=1/0,m=t.slice(1),g;this.options.extensions.startBlock.forEach(y=>{g=y.call({lexer:this},m),typeof g=="number"&&g>=0&&(f=Math.min(f,g))}),f<1/0&&f>=0&&(h=t.substring(0,f+1))}if(this.state.top&&(u=this.tokenizer.paragraph(h))){let f=n.at(-1);r&&(f==null?void 0:f.type)==="paragraph"?(f.raw+=(f.raw.endsWith(`
179
- `)?"":`
180
- `)+u.raw,f.text+=`
181
- `+u.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=f.text):n.push(u),r=h.length!==t.length,t=t.substring(u.raw.length);continue}if(u=this.tokenizer.text(t)){t=t.substring(u.raw.length);let f=n.at(-1);(f==null?void 0:f.type)==="text"?(f.raw+=(f.raw.endsWith(`
182
- `)?"":`
183
- `)+u.raw,f.text+=`
184
- `+u.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=f.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,h,f,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 N=w.slice(1,v-1);if(this.linkInText(N))return"["+N.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((f=(h=this.options.extensions)==null?void 0:h.inline)!=null&&f.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),N;this.options.extensions.startInline.forEach(x=>{N=x.call({lexer:this},v),typeof N=="number"&&N>=0&&(w=Math.min(w,N))}),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)}},Iu=class{constructor(e){Tt(this,"options");Tt(this,"parser");this.options=e||Da}space(e){return""}code({text:e,lang:t,escaped:n}){var s;let r=(s=(t||"").match(qr.notSpaceStart))==null?void 0:s[0],o=e.replace(qr.endingNewline,"")+`
185
- `;return r?'<pre><code class="language-'+fs(r)+'">'+(n?o:fs(o,!0))+`</code></pre>
186
- `:"<pre><code>"+(n?o:fs(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>${fs(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=N1(e);if(o===null)return r;e=o;let s='<a href="'+e+'"';return t&&(s+=' title="'+fs(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=N1(e);if(o===null)return fs(n);e=o;let s=`<img src="${e}" alt="${fs(n)}"`;return t&&(s+=` title="${fs(t)}"`),s+=">",s}text(e){return"tokens"in e&&e.tokens?this.parser.parseInline(e.tokens):"escaped"in e&&e.escaped?e.text:fs(e.text)}},Oy=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}},Jo=class Lk{constructor(t){Tt(this,"options");Tt(this,"renderer");Tt(this,"textRenderer");this.options=t||Da,this.options.renderer=this.options.renderer||new Iu,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Oy}static parse(t,n){return new Lk(n).parse(t)}static parseInline(t,n){return new Lk(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,h=this.options.extensions.renderers[u.type].call({parser:this},u);if(h!==!1||!["space","hr","heading","code","table","blockquote","list","checkbox","html","def","paragraph","text"].includes(u.type)){n+=h||"";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 h=this.options.extensions.renderers[c.type].call({parser:this},c);if(h!==!1||!["escape","html","link","image","checkbox","strong","em","codespan","br","del","text"].includes(c.type)){r+=h||"";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 h='Token with "'+u.type+'" type was not found.';if(this.options.silent)return console.error(h),"";throw new Error(h)}}}return r}},Pf,ou=(Pf=class{constructor(e){Tt(this,"options");Tt(this,"block");this.options=e||Da}preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(e=this.block){return e?Qo.lex:Qo.lexInline}provideParser(e=this.block){return e?Jo.parse:Jo.parseInline}},Tt(Pf,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens","emStrongMask"])),Tt(Pf,"passThroughHooksRespectAsync",new Set(["preprocess","postprocess","processAllTokens"])),Pf),gB=class{constructor(...e){Tt(this,"defaults",Ty());Tt(this,"options",this.setOptions);Tt(this,"parse",this.parseMarkdown(!0));Tt(this,"parseInline",this.parseMarkdown(!1));Tt(this,"Parser",Jo);Tt(this,"Renderer",Iu);Tt(this,"TextRenderer",Oy);Tt(this,"Lexer",Qo);Tt(this,"Tokenizer",kh);Tt(this,"Hooks",ou);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 Iu(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]=(...h)=>{let f=c.apply(o,h);return f===!1&&(f=u.apply(o,h)),f||""}}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]=(...h)=>{let f=c.apply(o,h);return f===!1&&(f=u.apply(o,h)),f}}r.tokenizer=o}if(n.hooks){let o=this.defaults.hooks||new ou;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];ou.passThroughHooks.has(s)?o[a]=h=>{if(this.defaults.async&&ou.passThroughHooksRespectAsync.has(s))return(async()=>{let m=await c.call(o,h);return u.call(o,m)})();let f=c.call(o,h);return u.call(o,f)}:o[a]=(...h)=>{if(this.defaults.async)return(async()=>{let m=await c.apply(o,h);return m===!1&&(m=await u.apply(o,h)),m})();let f=c.apply(o,h);return f===!1&&(f=u.apply(o,h)),f}}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 Qo.lex(e,t??this.defaults)}parser(e,t){return Jo.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?Qo.lex:Qo.lexInline)(a,o),u=o.hooks?await o.hooks.processAllTokens(c):c;o.walkTokens&&await Promise.all(this.walkTokens(u,o.walkTokens));let h=await(o.hooks?await o.hooks.provideParser(e):e?Jo.parse:Jo.parseInline)(u,o);return o.hooks?await o.hooks.postprocess(h):h})().catch(s);try{o.hooks&&(t=o.hooks.preprocess(t));let a=(o.hooks?o.hooks.provideLexer(e):e?Qo.lex:Qo.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?Jo.parse:Jo.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>"+fs(n.message+"",!0)+"</pre>";return t?Promise.resolve(r):r}if(t)return Promise.reject(n);throw n}}},Aa=new gB;function Tn(e,t){return Aa.parse(e,t)}Tn.options=Tn.setOptions=function(e){return Aa.setOptions(e),Tn.defaults=Aa.defaults,mj(Tn.defaults),Tn};Tn.getDefaults=Ty;Tn.defaults=Da;function kB(...e){return Aa.use(...e),Tn.defaults=Aa.defaults,mj(Tn.defaults),Tn}Tn.use=kB;Tn.walkTokens=function(e,t){return Aa.walkTokens(e,t)};Tn.parseInline=Aa.parseInline;Tn.Parser=Jo;Tn.parser=Jo.parse;Tn.Renderer=Iu;Tn.TextRenderer=Oy;Tn.Lexer=Qo;Tn.lexer=Qo.lex;Tn.Tokenizer=kh;Tn.Hooks=ou;Tn.parse=Tn;Tn.options;Tn.setOptions;Tn.walkTokens;Tn.parseInline;Jo.parse;Qo.lex;const Ia=100,wB=e=>e.type==="text-delta"||e.type==="thinking-delta"||e.type==="tool-delta";function yB(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 vB={now:()=>performance.now(),after:(e,t)=>void setTimeout(t,e)};function bB(e,t=vB){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"&&wB(a.event)){const c={...a,event:{...a.event}},u=t.now();if(n.length===0&&u-o>=Ia){o=u,e(c);return}const h=n[n.length-1];h&&yB(h,c)?h.event={...h.event,text:h.event.text+c.event.text}:n.push(c),r||(r=!0,t.after(Math.max(0,o+Ia-u),s));return}s(),e(a)}}const _j="#toyon-link-pending",xB=/!?\[([^[\]\n]*)(?:\]\(([^()\s]*))?$/;function EB(e){const t=e.lastIndexOf(`
204
- `)+1,n=e.slice(t),r=xB.exec(n);return!r||SB(e.slice(0,t))||_B(n.slice(0,r.index))?e:`${e.slice(0,t)}${n.slice(0,r.index)}[${r[1]}](${_j})`}function SB(e){let t=!1;for(const n of e.split(`
205
- `))/^\s*(```|~~~)/.test(n)&&(t=!t);return t}function _B(e){let t=0;for(const n of e)n==="`"&&t++;return t%2===1}const _g="__[a-z][a-z0-9_]*[a-z0-9]__",NB=new RegExp(`^(?:${_g}\\.)+${_g}|^${_g}(?=\\.\\w|\\(|["'])`),TB={name:"dunder",level:"inline",start:e=>e.indexOf("__"),tokenizer(e){const t=NB.exec(e);if(t)return{type:"dunder",raw:t[0],text:t[0]}},renderer:e=>e.text},zo=e=>e.replace(/[&<>]/g,t=>t==="&"?"&amp;":t==="<"?"&lt;":"&gt;");function jB({text:e}){return zo(e)}const $B="[A-Za-z0-9](?:[A-Za-z0-9-]{0,38})?",CB="[\\w.-]*[\\w-]",My=`(${$B}\\/${CB})#(\\d+)`,Nj=new RegExp(`(^|[^\\w./@-])${My}(?![\\w-])`),AB=new RegExp(`^${My}(?![\\w-])`),IB=new RegExp(`^${My}$`),RB=new RegExp(Nj.source,"g"),OB=/^https?:\/\/\S+$/;function MB(e){const t=[];for(const n of e.matchAll(RB)){const r=n.index+(n[1]??"").length;t.push({start:r,end:n.index+n[0].length})}return t}function Ly(e){const t=IB.exec(e);return t?`https://github.com/${t[1]}/issues/${t[2]}`:null}function Tj(e){return OB.test(e)?e:Ly(e)}function LB({text:e}){const t=`<code>${zo(e)}</code>`,n=Tj(e);return n?`<a href="${jj(n)}">${t}</a>`:t}const jj=e=>zo(e).replace(/"/g,"&quot;"),PB={name:"githubRef",level:"inline",start:e=>{const t=Nj.exec(e);return t?t.index+t[1].length:void 0},tokenizer(e){const t=AB.exec(e);if(t)return{type:"githubRef",raw:t[0],text:t[0],href:Ly(t[0])}},renderer:e=>`<a href="${jj(e.href)}">${zo(e.text)}</a>`};function DB(e){return`<div class="md-table">${zB.call(this,e)}</div>
206
- `}function zB(e){if(e.header.some(n=>n.text.trim()))return Iu.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 FB(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:/\\"/},h={className:"string",begin:/'/,end:/'/},f={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"],N=["true","false"],x={match:/(\/[a-z._-]+)+/},_=["break","cd","continue","eval","exec","exit","export","getopts","hash","pwd","readonly","return","shift","test","times","trap","umask","unset"],j=["alias","bind","builtin","caller","command","declare","echo","enable","help","let","local","logout","mapfile","printf","read","readarray","source","sudo","type","typeset","ulimit","unalias"],T=["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"],I=["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:N,built_in:[..._,...j,"set","shopt",...T,...I]},contains:[y,e.SHEBANG(),w,m,s,a,x,c,u,h,f,n]}}const BB=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_-]*/}}),UB=["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"],HB=["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"],WB=[...UB,...HB],KB=["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(),qB=["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(),ZB=["after","backdrop","before","cue","cue-region","first-letter","first-line","grammar-error","marker","part","placeholder","selection","slotted","spelling-error"].sort().reverse(),GB=["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 VB(e){const t=e.regex,n=BB(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:":("+qB.join("|")+")"},{begin:":(:)?("+ZB.join("|")+")"}]},n.CSS_VARIABLE,{className:"attribute",begin:"\\b("+GB.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:KB.join(" ")},contains:[{begin:/[a-z-]+(?=:)/,className:"attribute"},...c,n.CSS_NUMBER_MODE]}]},{className:"selector-tag",begin:"\\b("+WB.join("|")+")\\b"}]}}function YB(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 XB(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_-]+/,h=/"(\\"|[^"])*"/,f=/'[^']*'/,m=t.either(u,h,f),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 C1="[A-Za-z$_][0-9A-Za-z$_]*",QB=["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"],JB=["true","false","null","undefined","NaN","Infinity"],$j=["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"],Cj=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],Aj=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],eU=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","self","global"],tU=[].concat(Aj,$j,Cj);function nU(e){const t=e.regex,n=($,{after:Z})=>{const q="</"+$[0].slice(1);return $.input.indexOf(q,Z)!==-1},r=C1,o={begin:"<>",end:"</>"},s=/<[A-Za-z0-9\\._:-]+\s*\/>/,a={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:($,Z)=>{const q=$[0].length+$.index,K=$.input[q];if(K==="<"||K===","){Z.ignoreMatch();return}K===">"&&(n($,{after:q})||Z.ignoreMatch());let ne;const de=$.input.substring(q);if(ne=de.match(/^\s*=/)){Z.ignoreMatch();return}if((ne=de.match(/^\s+extends\s+/))&&ne.index===0){Z.ignoreMatch();return}}},c={$pattern:C1,keyword:QB,literal:JB,built_in:tU,"variable.language":eU},u="[0-9](_?[0-9])*",h=`\\.(${u})`,f="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",m={className:"number",variants:[{begin:`(\\b(${f})((${h})|\\.)?|(${h}))[eE][+-]?(${u})\\b`},{begin:`\\b(${f})\\b((${h})\\b|\\.)?|(${h})\\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"}},N={className:"string",begin:"`",end:"`",contains:[e.BACKSLASH_ESCAPE,g]},_={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]},j=[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,y,w,v,N,{match:/\$\d+/},m];g.contains=j.concat({begin:/\{/,end:/\}/,keywords:c,contains:["self"].concat(j)});const T=[].concat(_,g.contains),I=T.concat([{begin:/(\s*)\(/,end:/\)/,keywords:c,contains:["self"].concat(T)}]),R={className:"params",begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:c,contains:I},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"}}]},O={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:{_:[...$j,...Cj]}},A={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:/%/},B={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"};function W($){return t.concat("(?!",$.join("|"),")")}const U={match:t.concat(/\b/,W([...Aj,"super","import","await"].map($=>`${$}\\s*\\(`)),r,t.lookahead(/\s*\(/)),className:"title.function",relevance:0},Q={begin:t.concat(/\./,t.lookahead(t.concat(r,/(?![0-9A-Za-z$_(])/))),end:r,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},Y={match:[/get|set/,/\s+/,r,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},R]},se="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+e.UNDERSCORE_IDENT_RE+")\\s*=>",H={match:[/const|var|let/,/\s+/,r,/\s*/,/=\s*/,/(async\s*)?/,t.lookahead(se)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[R]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:c,exports:{PARAMS_CONTAINS:I,CLASS_REFERENCE:O},illegal:/#(?![$_A-Za-z])/,contains:[e.SHEBANG({label:"shebang",binary:"node",relevance:5}),A,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,y,w,v,N,_,{match:/\$\d+/},m,O,{scope:"attr",match:r+t.lookahead(":"),relevance:0},H,{begin:"("+e.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",relevance:0,contains:[_,e.REGEXP_MODE,{className:"function",begin:se,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:I}]}]},{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},Q,{match:"\\$"+r,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[R]},U,B,C,Y,{match:/\$[(.]/}]}}const rU="([-+]?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)|NaN|[-+]?Infinity",oU={scope:"number",match:rU,relevance:0};function sU(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,oU,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE],illegal:"\\S"}}function iU(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}]},h={className:"strong",contains:[],variants:[{begin:/_{2}(?!\s)/,end:/_{2}/},{begin:/\*{2}(?!\s)/,end:/\*{2}/}]},f={className:"emphasis",contains:[],variants:[{begin:/\*(?![*\s])/,end:/\*/},{begin:/_(?![_\s])/,end:/_/,relevance:0}]},m=e.inherit(h,{contains:[]}),g=e.inherit(f,{contains:[]});h.contains.push(g),f.contains.push(m);let y=[n,u];return[h,f,m,g].forEach(x=>{x.contains=x.contains.concat(y)}),y=y.concat(h,f),{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,h,f,{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 aU(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:/^(>>>|\.\.\.) /},h={className:"subst",begin:/\{/,end:/\}/,keywords:c,illegal:/#/},f={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,f,h]},{begin:/([fFtT][rR]|[rR][fFtT]|[fFtT])"""/,end:/"""/,contains:[e.BACKSLASH_ESCAPE,u,f,h]},{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,f,h]},{begin:/([fFtT][rR]|[rR][fFtT]|[fFtT])"/,end:/"/,contains:[e.BACKSLASH_ESCAPE,f,h]},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})`}]},N={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 h.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,N,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 lU(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"],h=["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!"],f=["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:f,keyword:c,literal:u,built_in:h},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:h,type:f}},{scope:"punctuation",begin:"->"},s]}}const wh="[A-Za-z$_][0-9A-Za-z$_]*",Ij=["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"],Rj=["true","false","null","undefined","NaN","Infinity"],Oj=["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"],Mj=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],Lj=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],Pj=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","self","global"],Dj=[].concat(Lj,Oj,Mj);function cU(e){const t=e.regex,n=($,{after:Z})=>{const q="</"+$[0].slice(1);return $.input.indexOf(q,Z)!==-1},r=wh,o={begin:"<>",end:"</>"},s=/<[A-Za-z0-9\\._:-]+\s*\/>/,a={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:($,Z)=>{const q=$[0].length+$.index,K=$.input[q];if(K==="<"||K===","){Z.ignoreMatch();return}K===">"&&(n($,{after:q})||Z.ignoreMatch());let ne;const de=$.input.substring(q);if(ne=de.match(/^\s*=/)){Z.ignoreMatch();return}if((ne=de.match(/^\s+extends\s+/))&&ne.index===0){Z.ignoreMatch();return}}},c={$pattern:wh,keyword:Ij,literal:Rj,built_in:Dj,"variable.language":Pj},u="[0-9](_?[0-9])*",h=`\\.(${u})`,f="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",m={className:"number",variants:[{begin:`(\\b(${f})((${h})|\\.)?|(${h}))[eE][+-]?(${u})\\b`},{begin:`\\b(${f})\\b((${h})\\b|\\.)?|(${h})\\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"}},N={className:"string",begin:"`",end:"`",contains:[e.BACKSLASH_ESCAPE,g]},_={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]},j=[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,y,w,v,N,{match:/\$\d+/},m];g.contains=j.concat({begin:/\{/,end:/\}/,keywords:c,contains:["self"].concat(j)});const T=[].concat(_,g.contains),I=T.concat([{begin:/(\s*)\(/,end:/\)/,keywords:c,contains:["self"].concat(T)}]),R={className:"params",begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:c,contains:I},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"}}]},O={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:{_:[...Oj,...Mj]}},A={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:/%/},B={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"};function W($){return t.concat("(?!",$.join("|"),")")}const U={match:t.concat(/\b/,W([...Lj,"super","import","await"].map($=>`${$}\\s*\\(`)),r,t.lookahead(/\s*\(/)),className:"title.function",relevance:0},Q={begin:t.concat(/\./,t.lookahead(t.concat(r,/(?![0-9A-Za-z$_(])/))),end:r,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},Y={match:[/get|set/,/\s+/,r,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},R]},se="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+e.UNDERSCORE_IDENT_RE+")\\s*=>",H={match:[/const|var|let/,/\s+/,r,/\s*/,/=\s*/,/(async\s*)?/,t.lookahead(se)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[R]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:c,exports:{PARAMS_CONTAINS:I,CLASS_REFERENCE:O},illegal:/#(?![$_A-Za-z])/,contains:[e.SHEBANG({label:"shebang",binary:"node",relevance:5}),A,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,y,w,v,N,_,{match:/\$\d+/},m,O,{scope:"attr",match:r+t.lookahead(":"),relevance:0},H,{begin:"("+e.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",relevance:0,contains:[_,e.REGEXP_MODE,{className:"function",begin:se,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:I}]}]},{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},Q,{match:"\\$"+r,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[R]},U,B,C,Y,{match:/\$[(.]/}]}}function uU(e){const t=e.regex,n=cU(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"],h={$pattern:wh,keyword:Ij.concat(u),literal:Rj,built_in:Dj.concat(o),"variable.language":Pj},f={className:"meta",begin:"@"+r},m=(v,N,x)=>{const _=v.contains.findIndex(j=>j.label===N);if(_===-1)throw new Error("can not find mode to replace");v.contains.splice(_,1,x)};Object.assign(n.keywords,h),n.exports.PARAMS_CONTAINS.push(f);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([f,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 dU(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"}),h={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:[h],starts:{end:/<\/style>/,returnEnd:!0,subLanguage:"css"}},{className:"tag",begin:/<script(?=\s|>)/,end:/>/,keywords:{name:"script"},contains:[h],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:h}]},{className:"tag",begin:t.concat(/<\//,t.lookahead(t.concat(n,/>/))),contains:[{className:"name",begin:n,relevance:0},{begin:/>/,relevance:0,endsParent:!0}]}]}}function fU(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},N=[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=[...N];return x.pop(),x.push(c),y.contains=x,{name:"YAML",case_insensitive:!0,aliases:["yml"],contains:N}}var Ng,A1;function hU(){if(A1)return Ng;A1=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(oe=>{const $e=P[oe],Fe=typeof $e;(Fe==="object"||Fe==="function")&&!Object.isFrozen($e)&&e($e)}),P}class t{constructor(oe){oe.data===void 0&&(oe.data={}),this.data=oe.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,...oe){const $e=Object.create(null);for(const Fe in P)$e[Fe]=P[Fe];return oe.forEach(function(Fe){for(const Rt in Fe)$e[Rt]=Fe[Rt]}),$e}const o="</span>",s=P=>!!P.scope,a=(P,{prefix:oe})=>{if(P.startsWith("language:"))return P.replace("language:","language-");if(P.includes(".")){const $e=P.split(".");return[`${oe}${$e.shift()}`,...$e.map((Fe,Rt)=>`${Fe}${"_".repeat(Rt+1)}`)].join(" ")}return`${oe}${P}`};class c{constructor(oe,$e){this.buffer="",this.classPrefix=$e.classPrefix,oe.walk(this)}addText(oe){this.buffer+=n(oe)}openNode(oe){if(!s(oe))return;const $e=a(oe.scope,{prefix:this.classPrefix});this.span($e)}closeNode(oe){s(oe)&&(this.buffer+=o)}value(){return this.buffer}span(oe){this.buffer+=`<span class="${oe}">`}}const u=(P={})=>{const oe={children:[]};return Object.assign(oe,P),oe};class h{constructor(){this.rootNode=u(),this.stack=[this.rootNode]}get top(){return this.stack[this.stack.length-1]}get root(){return this.rootNode}add(oe){this.top.children.push(oe)}openNode(oe){const $e=u({scope:oe});this.add($e),this.stack.push($e)}closeNode(){if(this.stack.length>1)return this.stack.pop()}closeAllNodes(){for(;this.closeNode(););}toJSON(){return JSON.stringify(this.rootNode,null,4)}walk(oe){return this.constructor._walk(oe,this.rootNode)}static _walk(oe,$e){return typeof $e=="string"?oe.addText($e):$e.children&&(oe.openNode($e),$e.children.forEach(Fe=>this._walk(oe,Fe)),oe.closeNode($e)),oe}static _collapse(oe){typeof oe!="string"&&oe.children&&(oe.children.every($e=>typeof $e=="string")?oe.children=[oe.children.join("")]:oe.children.forEach($e=>{h._collapse($e)}))}}class f extends h{constructor(oe){super(),this.options=oe}addText(oe){oe!==""&&this.add(oe)}startScope(oe){this.openNode(oe)}endScope(){this.closeNode()}__addSublanguage(oe,$e){const Fe=oe.root;$e&&(Fe.scope=`language:${$e}`),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($e=>m($e)).join("")}function N(P){const oe=P[P.length-1];return typeof oe=="object"&&oe.constructor===Object?(P.splice(P.length-1,1),oe):{}}function x(...P){return"("+(N(P).capture?"":"?:")+P.map(Fe=>m(Fe)).join("|")+")"}function _(P){return new RegExp(P.toString()+"|").exec("").length-1}function j(P,oe){const $e=P&&P.exec(oe);return $e&&$e.index===0}const T=/\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)|\\./;function I(P,{joinWith:oe}){let $e=0;return P.map(Fe=>{$e+=1;const Rt=$e;let Gt=m(Fe),Re="";for(;Gt.length>0;){const He=T.exec(Gt);if(!He){Re+=Gt;break}Re+=Gt.substring(0,He.index),Gt=Gt.substring(He.index+He[0].length),He[0][0]==="\\"&&He[1]?Re+="\\"+String(Number(He[1])+Rt):(Re+=He[0],He[0]==="("&&$e++)}return Re}).map(Fe=>`(${Fe})`).join(oe)}const R=/\b\B/,C="[a-zA-Z]\\w*",O="[a-zA-Z_]\\w*",A="\\b\\d+(\\.\\d+)?",D="(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)",B="\\b(0b[01]+)",W="!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~",U=(P={})=>{const oe=/^#![ ]*\//;return P.binary&&(P.begin=v(oe,/.*\b/,P.binary,/\b.*/)),r({scope:"meta",begin:oe,end:/$/,relevance:0,"on:begin":($e,Fe)=>{$e.index!==0&&Fe.ignoreMatch()}},P)},Q={begin:"\\\\[\\s\\S]",relevance:0},Y={scope:"string",begin:"'",end:"'",illegal:"\\n",contains:[Q]},se={scope:"string",begin:'"',end:'"',illegal:"\\n",contains:[Q]},H={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,oe,$e={}){const Fe=r({scope:"comment",begin:P,end:oe,contains:[]},$e);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},Z=$("//","$"),q=$("/\\*","\\*/"),K=$("#","$"),ne={scope:"number",begin:A,relevance:0},de={scope:"number",begin:D,relevance:0},pe={scope:"number",begin:B,relevance:0},je={scope:"regexp",begin:/\/(?=[^/\n]*\/)/,end:/\/[gimuy]*/,contains:[Q,{begin:/\[/,end:/\]/,relevance:0,contains:[Q]}]},_e={scope:"title",begin:C,relevance:0},fe={scope:"title",begin:O,relevance:0},te={begin:"\\.\\s*"+O,relevance:0};var we=Object.freeze({__proto__:null,APOS_STRING_MODE:Y,BACKSLASH_ESCAPE:Q,BINARY_NUMBER_MODE:pe,BINARY_NUMBER_RE:B,COMMENT:$,C_BLOCK_COMMENT_MODE:q,C_LINE_COMMENT_MODE:Z,C_NUMBER_MODE:de,C_NUMBER_RE:D,END_SAME_AS_BEGIN:function(P){return Object.assign(P,{"on:begin":(oe,$e)=>{$e.data._beginMatch=oe[1]},"on:end":(oe,$e)=>{$e.data._beginMatch!==oe[1]&&$e.ignoreMatch()}})},HASH_COMMENT_MODE:K,IDENT_RE:C,MATCH_NOTHING_RE:R,METHOD_GUARD:te,NUMBER_MODE:ne,NUMBER_RE:A,PHRASAL_WORDS_MODE:H,QUOTE_STRING_MODE:se,REGEXP_MODE:je,RE_STARTERS_RE:W,SHEBANG:U,TITLE_MODE:_e,UNDERSCORE_IDENT_RE:O,UNDERSCORE_TITLE_MODE:fe});function ue(P,oe){P.input[P.index-1]==="."&&oe.ignoreMatch()}function le(P,oe){P.className!==void 0&&(P.scope=P.className,delete P.className)}function be(P,oe){oe&&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 Ce(P,oe){Array.isArray(P.illegal)&&(P.illegal=x(...P.illegal))}function Ne(P,oe){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 Ie(P,oe){P.relevance===void 0&&(P.relevance=1)}const Be=(P,oe)=>{if(!P.beforeMatch)return;if(P.starts)throw new Error("beforeMatch cannot be used with starts");const $e=Object.assign({},P);Object.keys(P).forEach(Fe=>{delete P[Fe]}),P.keywords=$e.keywords,P.begin=v($e.beforeMatch,g($e.begin)),P.starts={relevance:0,contains:[Object.assign($e,{endsParent:!0})]},P.relevance=0,delete $e.beforeMatch},Je=["of","and","for","in","not","or","if","then","parent","list","value"],zt="keyword";function Yt(P,oe,$e=zt){const Fe=Object.create(null);return typeof P=="string"?Rt($e,P.split(" ")):Array.isArray(P)?Rt($e,P):Object.keys(P).forEach(function(Gt){Object.assign(Fe,Yt(P[Gt],oe,Gt))}),Fe;function Rt(Gt,Re){oe&&(Re=Re.map(He=>He.toLowerCase())),Re.forEach(function(He){const Ze=He.split("|");Fe[Ze[0]]=[Gt,_t(Ze[0],Ze[1])]})}}function _t(P,oe){return oe?Number(oe):qe(P)?0:1}function qe(P){return Je.includes(P.toLowerCase())}const xt={},ht=P=>{console.error(P)},De=(P,...oe)=>{console.log(`WARN: ${P}`,...oe)},nt=(P,oe)=>{xt[`${P}/${oe}`]||(console.log(`Deprecated as of ${P}. ${oe}`),xt[`${P}/${oe}`]=!0)},at=new Error;function Xt(P,oe,{key:$e}){let Fe=0;const Rt=P[$e],Gt={},Re={};for(let He=1;He<=oe.length;He++)Re[He+Fe]=Rt[He],Gt[He+Fe]=!0,Fe+=_(oe[He-1]);P[$e]=Re,P[$e]._emit=Gt,P[$e]._multi=!0}function Nt(P){if(Array.isArray(P.begin)){if(P.skip||P.excludeBegin||P.returnBegin)throw ht("skip, excludeBegin, returnBegin not compatible with beginScope: {}"),at;if(typeof P.beginScope!="object"||P.beginScope===null)throw ht("beginScope must be object"),at;Xt(P,P.begin,{key:"beginScope"}),P.begin=I(P.begin,{joinWith:""})}}function Zt(P){if(Array.isArray(P.end)){if(P.skip||P.excludeEnd||P.returnEnd)throw ht("skip, excludeEnd, returnEnd not compatible with endScope: {}"),at;if(typeof P.endScope!="object"||P.endScope===null)throw ht("endScope must be object"),at;Xt(P,P.end,{key:"endScope"}),P.end=I(P.end,{joinWith:""})}}function gt(P){P.scope&&typeof P.scope=="object"&&P.scope!==null&&(P.beginScope=P.scope,delete P.scope)}function nr(P){gt(P),typeof P.beginScope=="string"&&(P.beginScope={_wrap:P.beginScope}),typeof P.endScope=="string"&&(P.endScope={_wrap:P.endScope}),Nt(P),Zt(P)}function Jt(P){function oe(Re,He){return new RegExp(m(Re),"m"+(P.case_insensitive?"i":"")+(P.unicodeRegex?"u":"")+(He?"g":""))}class $e{constructor(){this.matchIndexes={},this.regexes=[],this.matchAt=1,this.position=0}addRule(He,Ze){Ze.position=this.position++,this.matchIndexes[this.matchAt]=Ze,this.regexes.push([Ze,He]),this.matchAt+=_(He)+1}compile(){this.regexes.length===0&&(this.exec=()=>null);const He=this.regexes.map(Ze=>Ze[1]);this.matcherRe=oe(I(He,{joinWith:"|"}),!0),this.lastIndex=0}exec(He){this.matcherRe.lastIndex=this.lastIndex;const Ze=this.matcherRe.exec(He);if(!Ze)return null;const Qt=Ze.findIndex((En,Sn)=>Sn>0&&En!==void 0),Wt=this.matchIndexes[Qt];return Ze.splice(0,Qt),Object.assign(Ze,Wt)}}class Fe{constructor(){this.rules=[],this.multiRegexes=[],this.count=0,this.lastIndex=0,this.regexIndex=0}getMatcher(He){if(this.multiRegexes[He])return this.multiRegexes[He];const Ze=new $e;return this.rules.slice(He).forEach(([Qt,Wt])=>Ze.addRule(Qt,Wt)),Ze.compile(),this.multiRegexes[He]=Ze,Ze}resumingScanAtSamePosition(){return this.regexIndex!==0}considerAll(){this.regexIndex=0}addRule(He,Ze){this.rules.push([He,Ze]),Ze.type==="begin"&&this.count++}exec(He){const Ze=this.getMatcher(this.regexIndex);Ze.lastIndex=this.lastIndex;let Qt=Ze.exec(He);if(this.resumingScanAtSamePosition()&&!(Qt&&Qt.index===this.lastIndex)){const Wt=this.getMatcher(0);Wt.lastIndex=this.lastIndex+1,Qt=Wt.exec(He)}return Qt&&(this.regexIndex+=Qt.position+1,this.regexIndex===this.count&&this.considerAll()),Qt}}function Rt(Re){const He=new Fe;return Re.contains.forEach(Ze=>He.addRule(Ze.begin,{rule:Ze,type:"begin"})),Re.terminatorEnd&&He.addRule(Re.terminatorEnd,{type:"end"}),Re.illegal&&He.addRule(Re.illegal,{type:"illegal"}),He}function Gt(Re,He){const Ze=Re;if(Re.isCompiled)return Ze;[le,Ne,nr,Be].forEach(Wt=>Wt(Re,He)),P.compilerExtensions.forEach(Wt=>Wt(Re,He)),Re.__beforeBegin=null,[be,Ce,Ie].forEach(Wt=>Wt(Re,He)),Re.isCompiled=!0;let Qt=null;return typeof Re.keywords=="object"&&Re.keywords.$pattern&&(Re.keywords=Object.assign({},Re.keywords),Qt=Re.keywords.$pattern,delete Re.keywords.$pattern),Qt=Qt||/\w+/,Re.keywords&&(Re.keywords=Yt(Re.keywords,P.case_insensitive)),Ze.keywordPatternRe=oe(Qt,!0),He&&(Re.begin||(Re.begin=/\B|\b/),Ze.beginRe=oe(Ze.begin),!Re.end&&!Re.endsWithParent&&(Re.end=/\B|\b/),Re.end&&(Ze.endRe=oe(Ze.end)),Ze.terminatorEnd=m(Ze.end)||"",Re.endsWithParent&&He.terminatorEnd&&(Ze.terminatorEnd+=(Re.end?"|":"")+He.terminatorEnd)),Re.illegal&&(Ze.illegalRe=oe(Re.illegal)),Re.contains||(Re.contains=[]),Re.contains=[].concat(...Re.contains.map(function(Wt){return Kn(Wt==="self"?Re:Wt)})),Re.contains.forEach(function(Wt){Gt(Wt,Ze)}),Re.starts&&Gt(Re.starts,He),Ze.matcher=Rt(Ze),Ze}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||{}),Gt(P)}function Rn(P){return P?P.endsWithParent||Rn(P.starts):!1}function Kn(P){return P.variants&&!P.cachedVariants&&(P.cachedVariants=P.variants.map(function(oe){return r(P,{variants:null},oe)})),P.cachedVariants?P.cachedVariants:Rn(P)?r(P,{starts:P.starts?r(P.starts):null}):Object.isFrozen(P)?r(P):P}var un="11.11.2";class vn extends Error{constructor(oe,$e){super(oe),this.name="HTMLInjectionError",this.html=$e}}const J=n,ye=r,We=Symbol("nomatch"),rt=7,jt=function(P){const oe=Object.create(null),$e=Object.create(null),Fe=[];let Rt=!0;const Gt="Could not find the language '{}', did you forget to load/include a language module?",Re={disableAutodetect:!0,name:"Plain text",contains:[]};let He={ignoreUnescapedHTML:!1,throwUnescapedHTML:!1,noHighlightRe:/^(no-?highlight)$/i,languageDetectRe:/\blang(?:uage)?-([\w-]+)\b/i,classPrefix:"hljs-",cssSelector:"pre code",languages:null,__emitter:f};function Ze(xe){return He.noHighlightRe.test(xe)}function Qt(xe){let Ge=xe.className+" ";Ge+=xe.parentNode?xe.parentNode.className:"";const kt=He.languageDetectRe.exec(Ge);if(kt){const wt=kn(kt[1]);return wt||(De(Gt.replace("{}",kt[1])),De("Falling back to no-highlight mode for this block.",xe)),wt?kt[1]:"no-highlight"}return Ge.split(/\s+/).find(wt=>Ze(wt)||kn(wt))}function Wt(xe,Ge,kt){let wt="",on="";typeof Ge=="object"?(wt=xe,kt=Ge.ignoreIllegals,on=Ge.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`),on=xe,wt=Ge),kt===void 0&&(kt=!0);const dn={code:wt,language:on};Ht("before:highlight",dn);const Cn=dn.result?dn.result:En(dn.language,dn.code,kt);return Cn.code=dn.code,Ht("after:highlight",Cn),Cn}function En(xe,Ge,kt,wt){const on=Object.create(null);function dn(G,ce){return G.keywords[ce]}function Cn(){if(!yt.keywords){An.addText(sn);return}let G=0;yt.keywordPatternRe.lastIndex=0;let ce=yt.keywordPatternRe.exec(sn),Ee="";for(;ce;){Ee+=sn.substring(G,ce.index);const ve=qn.case_insensitive?ce[0].toLowerCase():ce[0],Ye=dn(yt,ve);if(Ye){const[vt,Nn]=Ye;if(An.addText(Ee),Ee="",on[ve]=(on[ve]||0)+1,on[ve]<=rt&&(br+=Nn),vt.startsWith("_"))Ee+=ce[0];else{const Fn=qn.classNameAliases[vt]||vt;Ln(ce[0],Fn)}}else Ee+=ce[0];G=yt.keywordPatternRe.lastIndex,ce=yt.keywordPatternRe.exec(sn)}Ee+=sn.substring(G),An.addText(Ee)}function wn(){if(sn==="")return;let G=null;if(typeof yt.subLanguage=="string"){if(!oe[yt.subLanguage]){An.addText(sn);return}G=En(yt.subLanguage,sn,!0,ys[yt.subLanguage]),ys[yt.subLanguage]=G._top}else G=Ct(sn,yt.subLanguage.length?yt.subLanguage:null);yt.relevance>0&&(br+=G.relevance),An.__addSublanguage(G._emitter,G.language)}function hn(){yt.subLanguage!=null?wn():Cn(),sn=""}function Ln(G,ce){G!==""&&(An.startScope(ce),An.addText(G),An.endScope())}function vr(G,ce){let Ee=1;const ve=ce.length-1;for(;Ee<=ve;){if(!G._emit[Ee]){Ee++;continue}const Ye=qn.classNameAliases[G[Ee]]||G[Ee],vt=ce[Ee];Ye?Ln(vt,Ye):(sn=vt,Cn(),sn=""),Ee++}}function X(G,ce){return G.scope&&typeof G.scope=="string"&&An.openNode(qn.classNameAliases[G.scope]||G.scope),G.beginScope&&(G.beginScope._wrap?(Ln(sn,qn.classNameAliases[G.beginScope._wrap]||G.beginScope._wrap),sn=""):G.beginScope._multi&&(vr(G.beginScope,ce),sn="")),yt=Object.create(G,{parent:{value:yt}}),yt}function ge(G,ce,Ee){let ve=j(G.endRe,Ee);if(ve){if(G["on:end"]){const Ye=new t(G);G["on:end"](ce,Ye),Ye.isMatchIgnored&&(ve=!1)}if(ve){for(;G.endsParent&&G.parent;)G=G.parent;return G}}if(G.endsWithParent)return ge(G.parent,ce,Ee)}function Ve(G){return yt.matcher.regexIndex===0?(sn+=G[0],1):(F=!0,0)}function Kt(G){const ce=G[0],Ee=G.rule,ve=new t(Ee),Ye=[Ee.__beforeBegin,Ee["on:begin"]];for(const vt of Ye)if(vt&&(vt(G,ve),ve.isMatchIgnored))return Ve(ce);return Ee.skip?sn+=ce:(Ee.excludeBegin&&(sn+=ce),hn(),!Ee.returnBegin&&!Ee.excludeBegin&&(sn=ce)),X(Ee,G),Ee.returnBegin?0:ce.length}function Mt(G){const ce=G[0],Ee=Ge.substring(G.index),ve=ge(yt,G,Ee);if(!ve)return We;const Ye=yt;yt.endScope&&yt.endScope._wrap?(hn(),Ln(ce,yt.endScope._wrap)):yt.endScope&&yt.endScope._multi?(hn(),vr(yt.endScope,G)):Ye.skip?sn+=ce:(Ye.returnEnd||Ye.excludeEnd||(sn+=ce),hn(),Ye.excludeEnd&&(sn=ce));do yt.scope&&An.closeNode(),!yt.skip&&!yt.subLanguage&&(br+=yt.relevance),yt=yt.parent;while(yt!==ve.parent);return ve.starts&&X(ve.starts,G),Ye.returnEnd?0:ce.length}function pn(){const G=[];for(let ce=yt;ce!==qn;ce=ce.parent)ce.scope&&G.unshift(ce.scope);G.forEach(ce=>An.openNode(ce))}let _n={};function zr(G,ce){const Ee=ce&&ce[0];if(sn+=G,Ee==null)return hn(),0;if(_n.type==="begin"&&ce.type==="end"&&_n.index===ce.index&&Ee===""){if(sn+=Ge.slice(ce.index,ce.index+1),!Rt){const ve=new Error(`0 width match regex (${xe})`);throw ve.languageName=xe,ve.badRule=_n.rule,ve}return 1}if(_n=ce,ce.type==="begin")return Kt(ce);if(ce.type==="illegal"&&!kt){const ve=new Error('Illegal lexeme "'+Ee+'" for mode "'+(yt.scope||"<unnamed>")+'"');throw ve.mode=yt,ve}else if(ce.type==="end"){const ve=Mt(ce);if(ve!==We)return ve}if(ce.type==="illegal"&&Ee==="")return ce.index===Ge.length||(sn+=`
210
- `),1;if(Oe>1e5&&Oe>ce.index*3)throw new Error("potential infinite loop, way more iterations than matches");return sn+=Ee,Ee.length}const qn=kn(xe);if(!qn)throw ht(Gt.replace("{}",xe)),new Error('Unknown language: "'+xe+'"');const os=Jt(qn);let Vt="",yt=wt||os;const ys={},An=new He.__emitter(He);pn();let sn="",br=0,Cr=0,Oe=0,F=!1;try{if(qn.__emitTokens)qn.__emitTokens(Ge,An);else{for(yt.matcher.considerAll();;){Oe++,F?F=!1:yt.matcher.considerAll(),yt.matcher.lastIndex=Cr;const G=yt.matcher.exec(Ge);if(!G)break;const ce=Ge.substring(Cr,G.index),Ee=zr(ce,G);Cr=G.index+Ee}zr(Ge.substring(Cr))}return An.finalize(),Vt=An.toHTML(),{language:xe,value:Vt,relevance:br,illegal:!1,_emitter:An,_top:yt}}catch(G){if(G.message&&G.message.includes("Illegal"))return{language:xe,value:J(Ge),illegal:!0,relevance:0,_illegalBy:{message:G.message,index:Cr,context:Ge.slice(Cr-100,Cr+100),mode:G.mode,resultSoFar:Vt},_emitter:An};if(Rt)return{language:xe,value:J(Ge),illegal:!1,relevance:0,errorRaised:G,_emitter:An,_top:yt};throw G}}function Sn(xe){const Ge={value:J(xe),illegal:!1,relevance:0,_top:Re,_emitter:new He.__emitter(He)};return Ge._emitter.addText(xe),Ge}function Ct(xe,Ge){Ge=Ge||He.languages||Object.keys(oe);const kt=Sn(xe),wt=Ge.filter(kn).filter(lr).map(hn=>En(hn,xe,!1));wt.unshift(kt);const on=wt.sort((hn,Ln)=>{if(hn.relevance!==Ln.relevance)return Ln.relevance-hn.relevance;if(hn.language&&Ln.language){if(kn(hn.language).supersetOf===Ln.language)return 1;if(kn(Ln.language).supersetOf===hn.language)return-1}return 0}),[dn,Cn]=on,wn=dn;return wn.secondBest=Cn,wn}function nn(xe,Ge,kt){const wt=Ge&&$e[Ge]||kt;xe.classList.add("hljs"),xe.classList.add(`language-${wt}`)}function sr(xe){let Ge=null;const kt=Qt(xe);if(Ze(kt))return;if(Ht("before:highlightElement",{el:xe,language:kt}),xe.dataset.highlighted){console.log("Element previously highlighted. To highlight again, first unset `dataset.highlighted`.",xe);return}if(xe.children.length>0&&(He.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(xe)),He.throwUnescapedHTML))throw new vn("One of your code blocks includes unescaped HTML.",xe.innerHTML);Ge=xe;const wt=Ge.textContent,on=kt?Wt(wt,{language:kt,ignoreIllegals:!0}):Ct(wt);xe.innerHTML=on.value,xe.dataset.highlighted="yes",nn(xe,kt,on.language),xe.result={language:on.language,re:on.relevance,relevance:on.relevance},on.secondBest&&(xe.secondBest={language:on.secondBest.language,relevance:on.secondBest.relevance}),Ht("after:highlightElement",{el:xe,result:on,text:wt})}function Pt(xe){He=ye(He,xe)}const bn=()=>{Te(),nt("10.6.0","initHighlighting() deprecated. Use highlightAll() now.")};function fn(){Te(),nt("10.6.0","initHighlightingOnLoad() deprecated. Use highlightAll() now.")}let ie=!1;function Te(){function xe(){Te()}if(document.readyState==="loading"){ie||window.addEventListener("DOMContentLoaded",xe,!1),ie=!0;return}document.querySelectorAll(He.cssSelector).forEach(sr)}function dt(xe,Ge){let kt=null;try{kt=Ge(P)}catch(wt){if(ht("Language definition for '{}' could not be registered.".replace("{}",xe)),Rt)ht(wt);else throw wt;kt=Re}kt.name||(kt.name=xe),oe[xe]=kt,kt.rawDefinition=Ge.bind(null,P),kt.aliases&&Dr(kt.aliases,{languageName:xe})}function lt(xe){delete oe[xe];for(const Ge of Object.keys($e))$e[Ge]===xe&&delete $e[Ge]}function Bt(){return Object.keys(oe)}function kn(xe){return xe=(xe||"").toLowerCase(),oe[xe]||oe[$e[xe]]}function Dr(xe,{languageName:Ge}){typeof xe=="string"&&(xe=[xe]),xe.forEach(kt=>{$e[kt.toLowerCase()]=Ge})}function lr(xe){const Ge=kn(xe);return Ge&&!Ge.disableAutodetect}function ln(xe){xe["before:highlightBlock"]&&!xe["before:highlightElement"]&&(xe["before:highlightElement"]=Ge=>{xe["before:highlightBlock"](Object.assign({block:Ge.el},Ge))}),xe["after:highlightBlock"]&&!xe["after:highlightElement"]&&(xe["after:highlightElement"]=Ge=>{xe["after:highlightBlock"](Object.assign({block:Ge.el},Ge))})}function cr(xe){ln(xe),Fe.push(xe)}function rn(xe){const Ge=Fe.indexOf(xe);Ge!==-1&&Fe.splice(Ge,1)}function Ht(xe,Ge){const kt=xe;Fe.forEach(function(wt){wt[kt]&&wt[kt](Ge)})}function Ut(xe){return nt("10.7.0","highlightBlock will be removed entirely in v12.0"),nt("10.7.0","Please use highlightElement now."),sr(xe)}Object.assign(P,{highlight:Wt,highlightAuto:Ct,highlightAll:Te,highlightElement:sr,highlightBlock:Ut,configure:Pt,initHighlighting:bn,initHighlightingOnLoad:fn,registerLanguage:dt,unregisterLanguage:lt,listLanguages:Bt,getLanguage:kn,registerAliases:Dr,autoDetection:lr,inherit:ye,addPlugin:cr,removePlugin:rn}),P.debugMode=function(){Rt=!1},P.safeMode=function(){Rt=!0},P.versionString=un,P.regex={concat:v,lookahead:g,either:x,optional:w,anyNumberOfTimes:y};for(const xe in we)typeof we[xe]=="object"&&e(we[xe]);return Object.assign(P,we),P},Ft=jt({});return Ft.newInstance=()=>jt({}),Ng=Ft,Ft.HighlightJS=Ft,Ft.default=Ft,Ng}var pU=hU();const mU=KE(pU),I1={},gU="hljs-";function kU(e){const t=mU.newInstance();return e&&s(e),{highlight:n,highlightAuto:r,listLanguages:o,register:s,registerAlias:a,registered:c};function n(u,h,f){const m=f||I1,g=typeof m.prefix=="string"?m.prefix:gU;if(!t.getLanguage(u))throw new Error("Unknown language: `"+u+"` is not registered");t.configure({__emitter:wU,classPrefix:g});const y=t.highlight(h,{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,h){const m=(h||I1).subset||o();let g=-1,y=0,w;for(;++g<m.length;){const v=m[g];if(!t.getLanguage(v))continue;const N=n(v,u,h);N.data&&N.data.relevance!==void 0&&N.data.relevance>y&&(y=N.data.relevance,w=N)}return w||{type:"root",children:[],data:{language:void 0,relevance:y}}}function o(){return t.listLanguages()}function s(u,h){if(typeof u=="string")t.registerLanguage(u,h);else{let f;for(f in u)Object.hasOwn(u,f)&&t.registerLanguage(f,u[f])}}function a(u,h){if(typeof u=="string")t.registerAliases(typeof h=="string"?h:[...h],{languageName:u});else{let f;for(f in u)if(Object.hasOwn(u,f)){const m=u[f];t.registerAliases(typeof m=="string"?m:[...m],{languageName:f})}}}function c(u){return!!t.getLanguage(u)}}class wU{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 zj=kU({bash:FB,css:VB,go:YB,ini:XB,javascript:nU,json:sU,markdown:iU,python:aU,rust:lU,typescript:uU,xml:dU,yaml:fU}),R1={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 kp(e,t){const n=e&&(R1[e]??(zj.registered(e)?e:null));if(n)return n;const r=t.lastIndexOf("."),o=r<0?"":t.slice(r+1).toLowerCase();return(o?R1[o]:null)??null}const yU=/^(?:diff --git a\/\S+ b\/(\S+)|\+\+\+ (?:b\/)?(\S+))$/gm;function vU(e){const t=new Set;for(const n of e.matchAll(yU)){const r=n[1]??n[2]??"";r&&r!=="/dev/null"&&t.add(r)}return t.size===1?[...t][0]:""}const bU={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 Fj(e,t){const n=[[]],r=(s,a)=>{const c=s.split(`
211
- `);for(const[u,h]of c.entries()){if(u>0&&n.push([]),!h)continue;const f=n[n.length-1],m=f[f.length-1];m&&m.scope===a?m.text+=h:f.push({text:h,scope:a})}},o=(s,a)=>{for(const c of s)c.type==="text"?r(c.value,a):c.type==="element"&&o(c.children,xU(c)??a)};try{o(zj.highlight(t,e).children,"")}catch{return e.split(`
212
- `).map(s=>s?[{text:s,scope:""}]:[])}return n}function xU(e){var r;const t=((r=e.properties)==null?void 0:r.className)??[];let n=null;for(const o of t){const s=bU[o.startsWith("hljs-")?o.slice(5):o];s&&(n=s)}return n}const O1=/^\d+\t/;function wp(e,t){if(!t)return[];const n=e.split(`
213
- `),r=O1.test(n[0]??""),o=r?n.map(a=>{var c;return((c=O1.exec(a))==null?void 0:c[0])??""}):[],s=r?n.map((a,c)=>a.slice(o[c].length)).join(`
214
- `):e;return Fj(s,t).map((a,c)=>{const u=a.map(f=>({text:f.text,changed:!1,scope:f.scope})),h=o[c];return h?[{text:h,changed:!1,scope:""},...u]:u})}function EU(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"||(SU(e,o,s,t,n),o=s+1)}}return e.map((o,s)=>TU(o.spans,n[s],o.text))}function SU(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 h=u.map(m=>{var g;return((g=e[m])==null?void 0:g.text)??""}).join(`
215
- `),f=Fj(h,r);for(const[m,g]of u.entries())(c==="add"||((a=e[g])==null?void 0:a.kind)==="del")&&(o[g]=f[m])}}const yp="link",_U=/https?:\/\/[^\s<>"'`]+/g,Bj=/https?:\/\//;function Uj(e){const t=[];for(const n of e.matchAll(_U)){const r=n.index+NU(n[0]).length;r>n.index&&t.push({start:n.index,end:r})}return t}const M1={")":"(","]":"[","}":"{"};function NU(e){let t=e.length;for(;t>0;){const n=e[t-1];if(".,;:!?".includes(n))t--;else if(M1[n]&&L1(e.slice(0,t),M1[n])<L1(e.slice(0,t),n))t--;else break}return e.slice(0,t)}function L1(e,t){let n=0;for(const r of e)r===t&&n++;return n}function Hj(e){const t=e.map(c=>c.text).join("");if(!Bj.test(t))return e;const n=Uj(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 h=n[s],f=o+u;if(h&&f>=h.start){const m=Math.min(h.end,o+c.text.length)-f;a||(a={text:"",changed:!1,scope:yp},r.push(a)),a.text+=c.text.slice(u,u+m),a.changed||(a.changed=c.changed),u+=m,f+m>=h.end&&(a=null,s++)}else{const m=h?Math.min(h.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(Hj);function Py(e){return Bj.test(e)?e.split(`
216
- `).map(t=>Hj(t?[{text:t,changed:!1,scope:""}]:[])):[]}function Wj(e){const t=e[e.length-1],n=t==null?void 0:t[t.length-1];return!n||n.scope!==yp?e:[...e.slice(0,-1),[...t.slice(0,-1),{...n,scope:""}]]}function TU(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,h=0;for(;a<o.length&&c<s.length;){const f=o[a],m=s[c],g=Math.min(f.text.length-u,m.text.length-h);if(g>0){const y={text:f.text.slice(u,u+g),changed:f.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,h+=g,u>=f.text.length&&(a++,u=0),h>=m.text.length&&(c++,h=0)}return r}const jU=/^[^\s]*$/,$U=e=>e.split(/\s+/).slice(1).every(t=>!t||/[a-z0-9]/i.test(t));function Tg(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(!jU.test(o)&&!($U(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 Pk=new Map,P1={files:new Set,folders:new Set,worktrees:Pk,titled:[]},D1=new WeakMap;function Kj(e,t=Pk){let n;if(e?(n=D1.get(e),n||(n={...P1,files:new Set(e),folders:new Set(v_(e))},D1.set(e,n))):n=P1,t===Pk)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 qj(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 CU=/^[ \t]*(?<ticks>`{3,})[ \t]*(?<lang>[^`\s]*)[^`\n]*$/;function AU(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),h=(s=CU.exec(e.slice(c,u===-1?e.length:u)))==null?void 0:s.groups;if(h!=null&&h.ticks){const w=h.ticks.length,v=new RegExp(`^[ \\t]*\`{${w},}[ \\t]*$`,"m"),N=u===-1?e.length:u+1,x=v.exec(e.slice(N));let _=e.length,j=e.slice(N);x&&(j=e.slice(N,N+x.index),_=N+x.index+x[0].length,e[_]===`
219
- `&&_++),n(e.slice(o,c)),t.push({kind:"block",text:e.slice(c,_),code:j.replace(/\n$/,""),lang:h.lang??""}),o=r=_;continue}let f=1;for(;e[a+f]==="`";)f++;const m=new RegExp(`(?<!\`)\`{${f}}(?!\`)`,"g");m.lastIndex=a+f;const g=m.exec(e);if(!g){r=a+f;continue}let y=e.slice(a+f,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+f),code:y}),o=r=g.index+f}return n(e.slice(o)),t}const IU=/(^|\s)(@\S+)/g,RU=/[.,;:!?)\]}'"]$/,OU=/^[.,;:!?)\]}'"]*(\s|$)/;function z1(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 MU(e,t){const n=e.toLowerCase();for(const r of t.titled){const o=r.title.toLowerCase();if(o&&n.startsWith(o)&&OU.test(e.slice(o.length)))return{kind:"worktree",text:`@${e.slice(0,o.length)}`,...r}}return null}function vp(e){const t=[];return e.archived?t.push("archived"):(e.state&&t.push(e.state),e.at!==void 0&&t.push(`last sent ${So(fr(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 LU(e,t,n){let r=0;for(const o of Dy(e,n)){if(r===t)return o.kind!=="text";r+=o.text.length}return!1}function Dy(e,t){const n=[];for(const r of AU(e))r.kind==="prose"?PU(r.text,n.length===0,t,n):n.push(r);return n}function PU(e,t,n,r){const o=[];for(const c of e.matchAll(IU)){if(c.index===0&&!c[1]&&!t)continue;const u=c.index+(c[1]??"").length,h=MU(e.slice(u+1),n);let f=(c[2]??"").slice(1),m=h&&/\s/.test(h.text)?h:z1(f,n);for(;!m&&RU.test(f);)f=f.slice(0,-1),m=f?z1(f,n):null;m??(m=h),m&&o.push({start:u,span:m})}for(const c of Uj(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 MB(e)){const u=e.slice(c.start,c.end);o.push({start:c.start,span:{kind:"url",text:u,href:Ly(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 F1(e,t){return Dy(e,t).map(n=>n.kind==="worktree"?`@${n.branch}`:n.text).join("")}function DU(e,t,n){return{text:e.slice(0,t.from)+n+e.slice(t.to),caret:t.from+n.length}}function zU(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=>jk(s.name,n));return o.length>0?o:r(s=>jk(s.description,n))}const B1=e=>e.slice(e.lastIndexOf("/")+1);function FU(e,t,n){const r=[],o=new Set;for(const s of e){const a=s.worktree;if(a.repoId!==n)continue;const c=B1(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=B1(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 U1=new WeakMap;function BU(e,t){let n=U1.get(e.visible);n||(n=new Map,U1.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(FU(e.visible,r,t));return n.set(t,{archived:r,key:s}),s}function UU(e){const t=new Map;for(const n of JSON.parse(e))t.set(n.dir,n);return n=>t.get(n)??null}const Zj="wt-[0-9a-f]{4}",HU=new RegExp(`(^|[^\\w\\-/\`])\`?${Zj}(?![\\w\\-/\`])`),WU=new RegExp(`^(\`?)(${Zj})\\1(?![\\w\\-/\`])`),ca=e=>zo(e).replace(/"/g,"&quot;");function KU(e){return{name:"worktree",level:"inline",start:t=>{const n=HU.exec(t);return n?n.index+n[1].length:void 0},tokenizer(t){const n=WU.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=vp({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="${ca(o.dot)}"`:"";return`<span class="chat-mention" data-worktree="${ca(r.id)}" data-branch="${ca(r.branch)}" data-dir="${ca(n)}"${s} data-tip="${ca(o.text)}" data-tip-detail="${ca(o.detail.join(`
220
- `))}"${a} data-tip-placement="follow">@${zo(r.title)}<span class="chat-mention-dot"><span class="dot${o.dot?` ${ca(o.dot)}`:""}"></span></span></span>`}}}const qU=4*Ia;function ZU(e,t,n){if(!e)return{from:t,to:t,at:n,span:Ia};const r=Math.min(Gj(e,n),t),o=Math.min(Math.max(n-e.at,Ia),qU);return{from:r,to:t,at:n,span:o}}function Gj(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 GU(e,t){if(t>=e.length)return e;const n=e.charCodeAt(t);return e.slice(0,n>=56320&&n<=57343?t+1:t)}Tn.use({extensions:[TB,PB,KU(()=>On==null?void 0:On.worktrees)],renderer:{code({text:e,lang:t}){const n=kp((t??"").trim().toLowerCase().split(/\s+/)[0]??"","");let r=n?yh(wp(e,n)):Py(e);return r.length?(On!=null&&On.streaming&&Zf.trimEnd().endsWith(e.trimEnd())&&(r=Wj(r)),`<pre><code>${r.map(s=>s.map(a=>a.scope===yp?`<a href="${zo(a.text)}">${zo(a.text)}</a>`:a.scope?`<span class="sy-${a.scope}">${zo(a.text)}</span>`:zo(a.text)).join("")).join(`
221
- `)}</code></pre>
222
- `):!1},codespan:LB,html(e){return On!=null&&On.keepHtml?!1:jB(e)},image({href:e,text:t}){if(On!=null&&On.base||/^(https?:|data:)/i.test(e))return!1;const n=On==null?void 0:On.stills,r=n==null?void 0:n.pictures.find(u=>u.path===e),o=zo(t);if(r&&n){const u=n.urls.attachment(n.worktreeId,r.file);return`<button type="button" class="md-still" data-file="${Af(r.file)}" data-tip="Open full size" data-tip-placement="follow"><img src="${Af(u)}" alt="${Af(t)}"></button>`}const s=lj(e),a=On==null?void 0:On.fileRoot,c=s.startsWith("/")?s:a?`${a}/${s}`:null;return c?`<a href="${Af(c)}">${o}</a>`:o},table:DB}});const Af=e=>zo(e).replace(/"/g,"&quot;"),zy=v9(window);let On=null,Zf="";zy.addHook("uponSanitizeAttribute",(e,t)=>{e.tagName==="A"&&t.attrName==="href"&&(t.attrValue=lj(t.attrValue))});zy.addHook("afterSanitizeAttributes",e=>{const t=e.tagName==="A"?e.getAttribute("href")??"":"";if(t===_j){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=On!=null&&On.fileRoot?aj(On.fileRoot,t):null,r=n?null:cj(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=P8(e.textContent??"");s&&e.setAttribute("data-path",s)}const o=On==null?void 0:On.base;if(e.tagName==="IMG"&&o){const s=ij(o.dir,e.getAttribute("src")??"");s&&e.setAttribute("src",o.urls.worktreeFile(o.worktreeId,s,o.version))}});function Sa(e,t){On=t??null,Zf=t!=null&&t.streaming?EB(e):e;try{return zy.sanitize(Tn.parse(Zf,{async:!1,breaks:!(t!=null&&t.keepHtml)}))}finally{On=null,Zf=""}}function VU(e,t){const[n,r]=S.useState(e),o=S.useRef(null);return S.useEffect(()=>{if(!t){o.current=null;return}o.current=ZU(o.current,e.length,performance.now());let s=0;const a=()=>{const c=o.current;if(!c)return;const u=Gj(c,performance.now());r(GU(e,u)),u<c.to&&(s=requestAnimationFrame(a))};return a(),()=>cancelAnimationFrame(s)},[e,t]),t?n:e}function td(e,t){var v,N,x,_;const[n,r]=S.useState(()=>Sa(e,t)),o=S.useRef(0),s=(v=t==null?void 0:t.base)==null?void 0:v.worktreeId,a=(N=t==null?void 0:t.base)==null?void 0:N.dir,c=(x=t==null?void 0:t.base)==null?void 0:x.version,u=(_=t==null?void 0:t.base)==null?void 0:_.urls,h=t==null?void 0:t.fileRoot,f=t==null?void 0:t.worktrees,m=t==null?void 0:t.stills,g=!!(t!=null&&t.keepHtml),y=!!(t!=null&&t.streaming),w=VU(e,y);return S.useEffect(()=>{const j=s!==void 0&&a!==void 0&&u!==void 0?{worktreeId:s,dir:a,version:c??null,urls:u}:void 0,T=j||h||f||m||g||y?{base:j,fileRoot:h,worktrees:f,stills:m,keepHtml:g,streaming:y}:void 0,I=performance.now()-o.current;if(y||I>=Ia){o.current=performance.now(),r(Sa(w,T));return}const R=setTimeout(()=>{o.current=performance.now(),r(Sa(w,T))},Ia-I);return()=>clearTimeout(R)},[w,s,a,c,u,h,f,m,g,y]),n}const YU=/^ {0,3}(`{3,}|~{3,})/,XU=/^#{1,6} \S/,QU=/^\s*(?:[-*+]|\d+[.)]) \S/,JU=/^> ?\S/,e7=/^\s*\|?\s*:?-{3,}:?\s*(?:\|\s*:?-{3,}:?\s*)+\|?\s*$/,t7=/\[[^\]\n]+\]\((?:https?:|\.{0,2}\/|#)[^)\s]*\)/,n7=/\*\*[^\s*][^*\n]*\*\*/;function r7(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],h=(s=YU.exec(u))==null?void 0:s[1];if(r){h!=null&&h.startsWith(r)&&(r=null,n.add("fence"));continue}if(h){r=h;continue}XU.test(u)&&!((a=t[c+1])!=null&&a.trim())&&n.add("heading"),QU.test(u)&&++o===2&&n.add("list"),JU.test(u)&&n.add("quote"),e7.test(u)&&n.add("table"),t7.test(u)&&n.add("link"),n7.test(u)&&n.add("bold")}return n.size}function o7(e,t){if(t)return qh(t)==="markdown"?"rendered":"plain";const n=r7(e);return n>=2?"rendered":n===1?"source":"plain"}function bp({n:e,name:t,source:n,lines:r,chars:o,preview:s,text:a,href:c,onRemove:u,className:h=""}){const f=(n==null?void 0:n.path)??t??"",m=f.includes("/")?f.slice(0,f.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(mt,{name:"text",className:"icon-inline"}),d.jsxs("span",{className:"pick-target",children:[d.jsx("b",{children:t?t.slice(t.lastIndexOf("/")+1):n?SP(n):tS("paste",e)}),g&&d.jsxs("span",{className:"pick-file row-dim",children:[" · ",g]})]})]}),w=a!==void 0||c!==void 0;return d.jsx(Ny,{className:Ke("paste-chip",h),label:y,tip:s||void 0,peek:w?d.jsx(Xj,{text:a,href:c}):void 0,full:w?d.jsx(Yj,{text:a,href:c,path:f||void 0}):void 0,menu:v=>g8({text:a,href:c},v),removeLabel:"Remove attachment",onRemove:u})}function Vj(e,t){const[n,r]=S.useState(e??null),[o,s]=S.useState(!1);return S.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 Yj({text:e,href:t,path:n}){const{text:r,failed:o}=Vj(e,t),s=S.useMemo(()=>r?o7(r,n):"plain",[r,n]),[a,c]=S.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(Pe,{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(mt,{name:u?"text":"book",className:"icon-inline"})," ",u?"text":"preview"]})}),u?d.jsx(s7,{text:r}):d.jsx("pre",{className:"paste-doc-body paste-text",children:r})]})}function s7({text:e}){const t=S.useMemo(()=>Sa(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 i7=2e4;function Xj({text:e,href:t}){const{text:n}=Vj(e,t);return n?d.jsx("pre",{className:"paste-peek paste-text",children:n.slice(0,i7)}):null}function xp({name:e,bytes:t,href:n,kept:r,uploading:o,progress:s,onRemove:a,className:c=""}){const u=Qe();return d.jsx(Ny,{className:Ke("file-chip",c),label:d.jsxs(d.Fragment,{children:[d.jsx(mt,{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:[" ","· ",dw(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(Xj,{href:n}):void 0,full:n?d.jsx(Yj,{href:n,path:e}):void 0,menu:h=>k8({href:n},h,r&&{...r,sock:u}),removeLabel:"Remove attachment",onRemove:a})}function Qj(e){return e.replace(/^([\t ]*)\*\*(\S(?:[^\n]*\S)?)\*\*([\t ]*)$/gm,"$1$2$3")}const Jj=120,a7=/^\*\*(\S(?:[^\n]*\S)?)\*\*$/;function e$(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=a7.exec(s))==null?void 0:n[1])==null?void 0:r.replace(/`/g,""))??"";if(!a||a.length>Jj)return[];t.push(a)}return t}function t$(e){const t=e$(e);if(t.length)return t.at(-1);const n=Qj(e).trim().replace(/`/g,"");return n&&!n.includes(`
224
- `)&&n.length<=Jj?n:""}const l7={read:"read",edit:"edit",delete:"delete",move:"move",search:"search",execute:"run",think:"think",fetch:"fetch",switch_mode:"mode",other:"tool"},H1={read:"book",edit:"edit",delete:"trash",move:"move",search:"search",execute:"run",think:"bulb",fetch:"globe",switch_mode:"swap",other:"dot"},n$="Skill",r$="ScheduleWakeup",jg=new Map([[iw,"chat"],["Monitor","clock"],[r$,"clock"],["TaskOutput","terminal"],[n$,"layers"],[zA,"handoff"],[FA,"worktrees"],["EnterPlanMode","swap"]]),c7=new Map([["Read","read"],["Edit","edit"],["Write","edit"],["MultiEdit","edit"],["NotebookEdit","edit"],["Bash","execute"],["Grep","search"],["Glob","search"],["WebSearch","search"],["WebFetch","fetch"],["EnterPlanMode","switch_mode"],["ExitPlanMode","switch_mode"]]);function Dk(e){var o,s;if(e.name!==_a)return null;const t=/^select:(.*)$/.exec(Lr(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=c7.get(n);return r?{name:n,kind:r}:{name:n}}function u7(e){if(e.name!==n$)return"";const t=Lr(e,"skill").trim();if(!t)return"";const n=Lr(e,"args").trim();return n?`/${t} ${n}`:`/${t}`}const zk={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)/,W1=String.raw`(?:"[^"]*"|'[^']*'|[^\s;&|]+)`,K1=new RegExp(String.raw`^\s*(?:(?:cd|echo)\s+${W1}\s*(?:&&|;)|mkdir(?:\s+${W1})+\s*(?:&&|;)|(?:export\s+)?[A-Za-z_]\w*=(?:"[^"]*"|'[^']*'|[^\s;&|()\`]*)\s*(?:&&|;|(?=\s)))\s*`),f7=/^python[\d.]*$/,h7=new RegExp(`open\\([^)]*,\\s*["'][wax]|(?<!std(?:out|err))\\.write\\(|\\.write_text\\(`);function o$(e){let t=e;for(let n=t.replace(K1,"");n!==t;n=t.replace(K1,""))t=n;return t}const p7=new RegExp("(?<![0-9&])>{1,2}\\s*(?!\\/dev\\/null|&)[^\\s&>]"),s$=/&&|;|\n|\|/;function m7(e){return e.split(s$).some(t=>/^\s*(?:\S*\/)?sed\s/.test(t)&&d7.test(t))}function g7(e){return e.split(/&&|;|\n/).map(t=>o$(t).trim().split(/\s+/)[0]??"").filter(Boolean).every(t=>zk[t.slice(t.lastIndexOf("/")+1)]==="trash")}function k7(e){const t=o$(e).trim(),n=t.split(/\s+/)[0]??"",r=n.slice(n.lastIndexOf("/")+1),o=r==="sed"?m7(e)?void 0:"book":zk[r];if(o==="book"||o==="search"){const s=t.split(s$)[0]??"";if(p7.test(s))return r==="cat"&&s.includes("<<")?"edit":void 0}if(!(o==="trash"&&!g7(t)))return o||(f7.test(r)?t.includes("<<")&&h7.test(t)?"edit":void 0:zk[r])}function Lr(e,t){const n=e.input,r=n?n[t]:void 0;return typeof r=="string"?r:""}const w7=/^(?:\/(?:usr\/)?bin\/)?(?:ba|z|da)?sh\s+(?:-[a-zA-Z]+\s+)*(?:'([^']*)'|"((?:[^"\\]|\\.)*)")\s*$/;function i$(e){const t=w7.exec(e.trim());return t?t[1]!==void 0?t[1]:(t[2]??"").replace(/\\(["\\$`])/g,"$1"):e}const y7="Guardian Review";function a$(e){return e.toolKind==="think"&&e.title===y7}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 Ru(e,t=[]){const n=i$(Lr(e,"command")),r=e.name===_a?"":Lr(e,"query"),o=e.name===r$?Lr(e,"reason"):"",s=l$(e)||n||Lr(e,"path")||Lr(e,"pattern")||r||o,a=KA(e.name),c=s||u7(e)||(e.title&&e.title!==e.name?e.title:"")||(a?a.tool:""),u=Ep(Lr(e,"description")||(a?Lr(e,"rationale"):"")||c,t),h=e.toolKind&&e.toolKind in H1?e.toolKind:"other",f=l7[h],m=e.name===iw,g=h!=="other"||jg.has(e.name),y=e.name===e.title||e.name===Ci||e.name===GE,w=a?a.server:u&&(g||y||e.name===_a)?"":e.name,v=w&&w.toLowerCase()!==f?w:u?"":f,N=(h==="execute"||h==="other")&&n?k7(n):void 0;return{label:m?"ask":f,name:v,icon:jg.get(e.name)??jg.get(e.title??"")??N??(a&&h==="other"?"cube":H1[h]),hint:u===v?"":u,command:n&&n!==u?n:""}}const b7=/^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&&b7.test(e.output)}const E7={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 S7(e){const t=e.toolKind;return e.subagent?Lr(e,"prompt")?"":"writing the brief":!$h(e.input)||!YE({name:e.name,kind:t},e.input)?"":aw(t)?E7[t]:"writing the question"}function Fk(e,t){const n=c$(t),r=n[0],o=Lr(e,"description");return o&&r&&!r.code&&r.text===o?n.slice(1):n}function Xl(e){return l$(e)||Lr(e,"path")}function _7(e){return Lr(e,"description")}function l$(e){return Lr(e,"file_path")||Lr(e,"filepath")||Lr(e,"filePath")||N7(e)}function N7(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 Ep(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 T7=/^(`{3,})([\w+#.-]*)\s*$/;function c$(e){var c;const t=[];let n=[],r="",o=!1,s=0;const a=()=>{const u=n.join(`
225
- `).replace(/^\n+|\n+$/g,"");u.trim()&&t.push({code:o,diff:j7(u,r),lang:o?r:"",text:u}),n=[]};for(const u of e.split(`
226
- `)){const h=T7.exec(u),f=((c=h==null?void 0:h[1])==null?void 0:c.length)??0;if(!h||o&&(f<s||h[2])){n.push(u);continue}a(),o=!o,s=o?f:0,r=o?(h[2]??"").toLowerCase():""}return a(),t}function j7(e,t){return t==="diff"||t==="patch"||/^diff --git /m.test(e)||/^@@ .*@@/m.test(e)?!0:/^--- /m.test(e)&&/^[+-]/m.test(e)}const $7=/^(diff --git |index [0-9a-f]+\.\.|new file mode |deleted file mode |similarity index |rename (from|to) |Binary files )/;function C7(e){const t=[];for(const n of e.split(`
227
- `)){const r=I7(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 A7(t),t}function A7(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),h=e.slice(a,c),f=u.length>0&&h.length>0?zI(u.map(m=>m.text).join(`
228
- `),h.map(m=>m.text).join(`
229
- `)):null;f&&(q1(u,ob(f.before)),q1(h,ob(f.after)));for(const m of[...u,...h])m.spans??(m.spans=[]);s=c}}function q1(e,t){if(t.length===e.length)for(const[n,r]of e.entries())r.spans=t[n]}function I7(e){return e.startsWith("@@")?"hunk":e.startsWith("+++")||e.startsWith("---")||$7.test(e)?"meta":e.startsWith("+")?"add":e.startsWith("-")?"del":""}function R7(e){const t=e.tools.at(-1);return t.done||t.parentToolId?!1:t.name===Ci?!t.background:!!t.background}const u$=new Set(["read","edit","fetch"]);function Fy(e,t){if(e.isError||!e.toolKind||!u$.has(e.toolKind)||aw(e.toolKind)&&$h(e.input))return"";const{hint:n}=Ru(e,t);return n?`${e.parentToolId??""}
230
- ${e.toolKind}
231
- ${n}`:""}function Z1(e,t,n){if(!t||!("tools"in t)||e.done||e.isError||!e.toolKind||!u$.has(e.toolKind))return!1;const r=t.tools[0];return r.toolKind===e.toolKind&&r.parentToolId===e.parentToolId&&Fy(r,n)!==""}function O7(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:Fy(o,t)?n:-1}function d$(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 M7(e){return!e.done||e.isError?!1:!!e.cut||!e.output&&YE({name:e.name,kind:e.toolKind},e.input)}const G1=new WeakMap;function L7(e,t,n){if(e.name!==_a||e.isError)return e;if(!e.done)return null;if(!Dk(e))return t?e:null;if(!t||!n)return null;let r=G1.get(e);if(!r){const o=Dk(e),{output:s,title:a,toolKind:c,...u}=e;r={...u,name:o.name,input:{},done:!1,...o.kind?{toolKind:o.kind}:{}},G1.set(e,r)}return r}function P7(e,t){return t&&(e==null?void 0:e.kind)==="tool"&&e.name===_a&&e.done&&!e.isError&&Dk(e)!==null}function D7(e,t,n=!1){const r=d$(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(M7(u))continue;const h=L7(u,c===e.length-1,n);if(!h)continue;if(r.has(h.id)){a="";const y={at:c,spawn:h,run:[],end:c};s.set(h.id,{entry:y,key:""}),o.push(y);continue}const f=Fy(h,t),m=h.parentToolId?s.get(h.parentToolId):void 0;if(m){const y=m.entry.run,w=y.at(-1);f&&f===m.key&&w?w.tools.push(h):!f&&Z1(h,w,t)?w.next=h:y.push({at:c,tools:[h]}),m.key=f,m.entry.end=c;continue}const g=o.at(-1);if(f&&f===a&&g&&"tools"in g){g.tools.push(h);continue}if(!f&&Z1(h,g,t)){g.next=h;continue}a=f,o.push({at:c,tools:[h]})}return o}function z7(e){return e.reduce((t,n)=>t+n.tools.length,0)}function F7(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 B7(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&&R7(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 U7(e,t=!1){const n=d$(e);return P7(e.at(-1),t)?!0:e.some(r=>r.kind==="tool"&&!r.done&&!r.parentToolId&&!r.background&&r.name!==_a&&(!n.has(r.id)||$h(r.input)))}function f$(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===Ci)return;const u=VE({name:c.name,kind:c.toolKind});(o||r&&u)&&n.add(a),r=!0,o||(o=u)}),n}function H7(e){return e.findIndex(t=>!t.tools.at(-1).done)}function By(e,t){return e.length===t.length&&e.every((n,r)=>n===t[r])}function h$(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)&&By(n.tools,t[r].tools)})}function W7(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&&K7(c,s)?c:s;return u!==e[a]&&(r=!1),u});return r?e:o}function K7(e,t){return"spawn"in e?"spawn"in t&&e.spawn===t.spawn&&e.end===t.end&&h$(e.run,t.run):"tools"in e?"tools"in t&&e.next===t.next&&By(e.tools,t.tools):"item"in t&&e.item===t.item}function q7(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"&&!a$(r))return t;continue}if(n.item.kind==="thinking"){if(!n.item.text.trim())continue;return t$(n.item.text)?-1:t}if(Z7(n.item))return-1}}return-1}function Z7(e){return e.kind==="assistant"?!!e.text.trim():e.kind==="ask"?e.ask.kind==="question"||!!e.outcome:!0}function G7(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 Sp(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:m_(a,u),state:g_(a,u),at:Ta(c)})}return o}function p$(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 V7(e,t){return/[/-]/.test(e)?p$(e,t):null}const V1=e=>e.toLowerCase().replace(/[^a-z0-9]/g,"");function Y1(e,t){const n=V1(e);if(!n)return!e.trim();const r=/\s$/.test(e);return[t.title,t.branch].some(o=>{const s=V1(o);return s.includes(n)&&(!r||!s.endsWith(n))})}function fo({id:e,title:t,inert:n}){const r=Qe(),o=ut(),s=L(w=>w.visible),a=L(w=>w.shipping),c=L(w=>qt(w,e)),u=L(w=>c?null:Object.values(w.archived).flat().find(v=>v.id===e)??null),h=S.useMemo(()=>c?Sp(s,c.worktree.repoId,null,a).find(w=>w.id===e)??null:null,[s,a,c,e]),f=(h==null?void 0:h.branch)??(u==null?void 0:u.branch);if(!f)return d.jsx("span",{children:t??e});const m=vp(h??{title:(u==null?void 0:u.title)??t??f,archived:!0,branch:f}),g=Lt(m.text,void 0,{placement:"follow",dot:m.dot,detail:m.detail}),y=pp({kind:"worktree",id:e,archived:!h},null,{sock:r,dispatch:o});return d.jsxs("span",{className:"chat-mention","data-worktree":e,"data-branch":f,"data-archived":h?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 Y7(e){const t=e.body??"";return e.note?`${t.trimEnd()}
232
-
233
- ---
234
-
235
- You added: ${e.note}
236
- `:t}function X7({item:e,worktreeId:t,marked:n,children:r}){Qe();const o=ut(),s=e.via==="plan",a=()=>{if(s&&e.path&&t){Dn({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:Y7(e),binary:!1,tooLarge:!1,source:{kind:"text"},seq:_o()}})};return d.jsx(Tr,{icon:"handoff",word:s?"plan":"piece",tone:"accent",at:e.ts,"data-state":hr({cursor:n}),below:[e.note?`you added: ${e.note}`:void 0,r],children:d.jsxs("span",{className:"daemon-text",children:["from ",d.jsx(fo,{id:e.origin.id,title:e.origin.title}),e.origin.project?` in ${e.origin.project}`:""," · ",d.jsx(Pe,{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 X1({item:e,worktreeId:t}){var y;Qe();const n=ut();if(e.state==="held"||e.state==="proposed")return null;const r=e.plan,o=r&&t?d.jsx(Pe,{variant:"inline",onClick:()=>Dn({dispatch:n},{worktreeId:t,path:r,view:"preview"}),children:e.companion?"the plan":"the list"}):null;if(e.state==="going")return d.jsx(Tr,{icon:"handoff",word:"handed off",tone:"accent",at:e.ts,children:d.jsx("span",{className:"daemon-text",children:d.jsx("span",{className:"live-text",children:"starting the worktrees"})})});if(e.state==="declined")return d.jsx(Tr,{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),h=e.outcomes.filter(w=>w.fate==="send"&&w.worktreeId),f=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(fo,{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(fo,{id:v.id,title:v.branch}):w.after]},w.pieceId))}for(const w of h)g.push(d.jsxs("span",{children:[a(w.pieceId)," sent to ",d.jsx(fo,{id:w.worktreeId,title:w.title}),w.repoName?` in ${w.repoName}`:""]},w.pieceId));return f&&g.push(d.jsx("span",{children:`${f} here`},"here")),d.jsx(Tr,{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 Q7({item:e}){return e.worktreeId?d.jsx(Tr,{icon:"handoff",word:"handed off",tone:"accent",at:e.ts,children:d.jsxs("span",{className:"daemon-text",children:[d.jsx(fo,{id:e.worktreeId,title:e.title??"the worktree"})," started, its branch having landed"]})}):d.jsx(Tr,{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 J7({item:e}){return d.jsx(Tr,{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(fo,{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(Pe,{variant:"inline",onClick:()=>window.open(e.url,"_blank"),children:"the PR"})]})]})})}function _p({src:e,n:t,name:n,width:r,height:o,bytes:s,kept:a,uploading:c,progress:u,onRemove:h,className:f=""}){const m=Qe();return d.jsx(Ny,{className:Ke("image-chip",f),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:tS("image",t)}),d.jsxs("span",{className:"pick-file row-dim",children:[" ","· ",n," · ",r,"×",o," · ",dw(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=>Ca(e,g,a&&{...a,sock:m}),removeLabel:"Remove image",onRemove:h})}function eH({img:e,worktreeId:t,src:n}){return d.jsx(_p,{className:"in-chat",src:n,...e,kept:{worktreeId:t,file:e.file}})}function fu({pieces:e}){return d.jsx(d.Fragment,{children:e.map((t,n)=>{if(t.scope===yp)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(S.Fragment,{children:t.text},n)})})}function tH({code:e,lang:t}){const n=kp(t.toLowerCase(),""),r=n?yh(wp(e,n)):Py(e);return d.jsx("pre",{children:d.jsx("code",{children:r.length?r.map((o,s)=>d.jsxs(S.Fragment,{children:[s>0&&`
237
- `,d.jsx(fu,{pieces:o})]},s)):e})})}const nH=/(^|\s)@\S/;function Ou({text:e,worktreeId:t,root:n,inField:r}){const o=zn(),s=Qe(),a=L(v=>{var N;return t?(N=v.local[t])==null?void 0:N.files:void 0}),c=L(v=>v.visible),u=L(v=>v.shipping),h=L(v=>{var N;return(N=qt(v,t))==null?void 0:N.worktree.repoId}),f=L(v=>h?v.archived[h]:void 0),m=S.useMemo(()=>qj(Sp(c,h,t,u),f),[c,u,f,h,t]),g=S.useMemo(()=>Kj(a,m),[a,m]),y=S.useMemo(()=>Dy(e,g),[e,g]),w=a===void 0&&t&&nH.test(e)?t:null;return S.useEffect(()=>{w&&sp(w,o.getState(),{sock:s,dispatch:o.dispatch})},[w,o,s]),d.jsx(d.Fragment,{children:y.map((v,N)=>{if(v.kind==="text")return v.text;if(v.kind==="code"){if(r)return v.text;const T=Tj(v.code),I=d.jsx("code",{children:v.code},N);return T?d.jsx("a",{className:"chat-url",href:T,target:"_blank",rel:"noreferrer",children:I},N):I}if(v.kind==="block")return r?v.text:d.jsx(tH,{code:v.code,lang:v.lang},N);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},N);if(v.kind==="changes"){const T=Lt("this worktree's uncommitted files",void 0,{placement:"follow"});return d.jsx("span",{className:"chat-mention","data-changes":"",...T,children:v.text},N)}if(v.kind==="worktree"){const T=vp(v),I=Lt(T.text,void 0,{placement:"follow",dot:T.dot,detail:T.detail});return d.jsx("span",{className:"chat-mention","data-worktree":v.id,"data-branch":v.branch,"data-archived":v.archived?"":void 0,...I,children:r?v.text:d.jsxs(d.Fragment,{children:["@",T.text,T.dot&&d.jsx("span",{className:"chat-mention-dot",children:d.jsx("span",{className:`dot ${T.dot}`})})]})},N)}if(!n||!t)return v.text;const x=v.kind==="folder",_=`${n}/${v.path}${x?"/":""}`,j=Lt(x?`${v.path}/`:v.path,void 0,{placement:"follow"});return d.jsx("a",{className:"chat-mention",href:_,tabIndex:r?-1:void 0,...j,children:v.text},N)})})}function Mu(e,t,n,r){if(e.target.closest("[data-changes]")){n&&r.dispatch({a:"focus-changes",tab:"changes"});return}_y(e,t,n,r)}function rH(e){return e.length<2||!e.every(t=>{var n;return t.length===1&&((n=t[0])==null?void 0:n.diff)})?null:sH(e.map(t=>t[0].text))}const oH=/^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@/;function sH(e,t=3){let n=[];for(const r of e){const o=iH(r);if(!o)return null;const s=aH(n,o);if(!s)return null;n=s}return n.some(r=>r.kind!=="same")?lH(n,t):null}function iH(e){const t=[];let n=null;for(const r of e.split(`
238
- `)){const o=oH.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 aH(e,t){const n=[];let r=0,o=0,s=0,a=0;const c=f=>{f.kind==="same"?o=f.a-f.c:f.kind==="add"?o-=1:o+=1},u=()=>{for(;r<e.length&&e[r].kind==="del";)n.push(e[r]),c(e[r]),r++},h=f=>{for(let m=f;m<e.length;m++){const g=e[m];if(g.kind!=="del")return g.c}return Number.POSITIVE_INFINITY};for(const f of t){if(f.oldStart<=a)return null;for(;r<e.length;){const y=e[r];if((y.kind==="del"?h(r):y.c)>=f.oldStart)break;n.push(y.kind==="del"?y:{...y,c:y.c+s}),c(y),r++}let m=f.oldStart,g=f.newStart;for(const y of f.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 f=e[r];n.push(f.kind==="del"?f:{...f,c:f.c+s})}return n}function lH(e,t){const n=[];for(const r of uH(e))for(const[o,s]of dH(r.rows,t)){const a=cH(r.rows.slice(o,s)),c=a.filter(m=>m.kind!=="add").length,u=a.filter(m=>m.kind!=="del").length,h=a.find(m=>m.kind!=="add"),f=a.find(m=>m.kind!=="del");n.push(`@@ -${h?h.a:r.oldAt[o]},${c} +${f?f.c:r.newAt[o]},${u} @@`,...a.map(m=>`${m.kind==="add"?"+":m.kind==="del"?"-":" "}${m.text}`))}return n.join(`
239
- `)}function cH(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 uH(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 dH(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 Np({pick:e,worktreeId:t,tipText:n,onHover:r,onOpen:o,onRemove:s,className:a=""}){const c=e.callFile,u=e.file,h=c?{path:c,line:e.callLine}:u?{path:u,line:e.line}:null,f=c&&u?{path:u,line:e.line}:null,m=(_,j)=>`${_}${j?`:${j}`:""}`,g=_=>_.split("/").pop()??_,y=(_,j,T,I)=>o?d.jsx("button",{className:"pick-open","data-tip":I,onClick:()=>o(_,j??1),children:T}):T,w=xn("chat"),{host:v}=Pr(),N=S.useRef(null),x=s?()=>{r==null||r(!1),s()}:void 0;return d.jsxs("div",{ref:N,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(()=>b8(e,{remove:x,host:v})),children:[d.jsxs("span",{className:"pick-target",children:[d.jsx(mt,{name:"pick",className:"icon-inline"})," ",Lw(e),h&&d.jsxs("span",{className:"pick-file row-dim",children:[" ","· ",y(h.path,h.line,m(g(h.path),h.line),`Open ${m(h.path,h.line)}`)]}),f&&d.jsxs("span",{className:"pick-file row-dim",children:[" ","·"," ",y(f.path,f.line,m(f.path.split("/").pop()??f.path,f.line),`Open the component: ${m(f.path,f.line)}`)]})]}),x&&d.jsx(It,{icon:"close",label:"Remove attachment",tone:"quiet",onClick:x}),t&&(h==null?void 0:h.line)&&d.jsx(uj,{chip:N,children:d.jsx(pH,{worktreeId:t,path:h.path,line:h.line})})]})}const fH=6,hH=16;function pH({worktreeId:e,path:t,line:n}){const r=Zw(),o=Qe(),s=L(m=>{var g;return((g=Bo(m))==null?void 0:g.id)===e}),a=L(m=>{var g;return s?0:(g=Zr(m,e).changedRanges[t])==null?void 0:g.offset}),[c,u]=S.useState(null);S.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 h=S.useMemo(()=>{if(c===null||a===void 0)return null;const m=c.split(`
240
- `),g=n-a,y=Math.max(1,g-fH),w=Math.min(m.length,g+hH);if(y>w)return null;const v=m.slice(y-1,w);return{from:y,at:g,slice:v,painted:wp(v.join(`
241
- `),kp("",t))}},[c,a,n,t]);if(!h)return null;const f=String(h.from+h.slice.length-1).length;return d.jsx("pre",{className:"pick-peek",children:h.slice.map((m,g)=>{const y=h.from+g,w=h.painted[g];return d.jsxs("span",{className:"pick-peek-line","data-state":y===h.at?"current":void 0,children:[d.jsx("span",{className:"pick-peek-n",children:String(y).padStart(f)}),w!=null&&w.length?d.jsx(fu,{pieces:w}):m||" "]},y)})})}function mH(e){return e.startsWith("!")?e.slice(1).trim():null}function Uy(e){if(e.kind!=="tool"||e.name!==Ci&&e.name!==GE)return null;const t=e.input;return typeof(t==null?void 0:t.command)=="string"?t.command:null}function m$(e){var t;return e.kind!=="tool"||e.name!==Ci||(t=e.input)!=null&&t.landing?null:Uy(e)}function gH(e){return e.length>0&&e.every(t=>t.kind==="tool"&&m$(t)!==null&&t.done&&!t.isError)}function kH(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=Uy(o);if(s===null)continue;const a=c$(o.output??"").map(u=>u.text).join(`
242
- `),c=hP(a);t.unshift(`$ ${s}${c?`
243
- ${c}`:""}`)}if(t.length!==0)return`Shell commands the user ran since their last message, and what each printed:
244
- ${t.join(`
245
- `)}`}const Q1={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 g$(e,t,n,r){const o=e[0];if(!o||!n)return[];const s=Ep(Xl(o),t);return s?s.startsWith("/")?[{label:"open",tip:Q1.file,open:()=>Ck(r,n.id,{href:s,path:s})}]:[...Ri(s)==="preview"?["preview"]:[],...o.toolKind==="edit"?["diff"]:[],"file"].map(c=>({label:`open ${c}`,tip:Q1[c],open:()=>Dn(r,{worktreeId:n.id,path:s,view:c})})):[]}const wH=(...e)=>g$(...e)[0]??null;function yH(e,t,n,r,o,s){const{sock:a}=r,c=e[0];if(!c)return[];const u=s?oj(s):[],h=[],f=Ep(Xl(c),t),m=g$(e,t,n,r).map(_=>({id:_.label.replace(" ","-"),label:_.label,onClick:_.open}));f&&!f.startsWith("/")&&n?h.push(...m,...Uo(()=>a==null?void 0:a.send({t:"reveal",worktreeId:n.id,path:f}),mo(a))):f.startsWith("/")&&h.push(...m,...Uo(()=>a==null?void 0:a.send({t:"reveal-path",path:f}),mo(a)));const g=[],y=Xl(c);f&&y&&g.push({id:"copy-path",label:"copy path",onClick:()=>tn(y)});const w=Ru(c,t).command,v=_7(c);v&&v!==w&&g.push({id:"copy-description",label:"copy description",onClick:()=>tn(v)}),w&&g.push({id:"copy-command",label:"copy command",onClick:()=>tn(w)});const N=e.map(_=>_.output??"").filter(Boolean).join(`
246
- `);N&&g.push({id:"copy-output",label:"copy output",onClick:()=>tn(N)});const x=o.leaf?[]:[{id:"fold",label:o.open?"collapse":"expand",onClick:o.toggle}];return Wn([u,h,g,x])}const k$=e=>e.replace(/\n$/,""),vH=1500,J1=4;function w$(e){return e.closest(".md pre, .card-code pre")}function Bk(e){const t=w$(e);return t?k$(t.textContent??""):null}function bH(e,t){const n=e.getBoundingClientRect(),r=t.getBoundingClientRect();return{pre:t,top:r.top-n.top+e.scrollTop+J1,right:n.left+e.clientLeft+e.clientWidth-r.right+J1}}function Hy(e){const[t,n]=S.useState(null),[r,o]=S.useState(null);if(S.useEffect(()=>{const h=e.current;if(!h)return;const f=g=>{if(!(g.target instanceof Element)||g.target.closest(".code-copy"))return;const y=w$(g.target);n(y&&h.contains(y)?bH(h,y):null)},m=()=>n(null);return h.addEventListener("pointerover",f),h.addEventListener("pointerleave",m),()=>{h.removeEventListener("pointerover",f),h.removeEventListener("pointerleave",m)}},[e]),S.useEffect(()=>{if(!r)return;const h=setTimeout(()=>o(null),vH);return()=>clearTimeout(h)},[r]),!(t!=null&&t.pre.isConnected))return null;const{pre:s,top:a,right:c}=t,u=r===s;return d.jsx(It,{className:"code-copy",style:{top:a,right:c},icon:u?"check":"copy",label:u?"Copied":"Copy code",onClick:()=>{tn(k$(s.textContent??"")),o(s)}})}function xH(e){for(const t of e.split(`
247
- `)){const n=/^#{1,6}\s+(.+?)\s*#*\s*$/.exec(t);if(n)return n[1];if(t.trim()&&!t.startsWith("<!--"))return null}return null}function EH(e){return e.slice(e.lastIndexOf("/")+1).replace(/\.md$/,"")}const If=new Map;function Wy(e,t){var c;const n=Zw(),r=(c=At(e,"git"))==null?void 0:c.version,o=e&&t?`${e}
248
- ${t}`:null,[,s]=S.useState(0);return it([n,e,t,r],()=>{if(!n||!o||!e||!t)return;let u=!0;return n.look(e,t).then(h=>{if(!u||h===null)return;const f=xH(h);If.has(o)&&If.get(o)===f||(If.set(o,f),s(m=>m+1))}),()=>{u=!1}}),(o?If.get(o)??null:null)??(t?EH(t):"")}function y$(e){const t=L(r=>{var o;return(o=qt(r,e))==null?void 0:o.worktree.repoId}),n=L(r=>t?BU(r,t):"");return S.useMemo(()=>n?UU(n):void 0,[n])}function $g({text:e,menu:t,marked:n,worktreeId:r,fileRoot:o,streaming:s,pictures:a}){const c=y$(r),u=Pr(),h=S.useMemo(()=>r&&(a!=null&&a.length)?{worktreeId:r,urls:u,pictures:a}:void 0,[r,u,a]),f=td(e,{fileRoot:o,streaming:s,worktrees:c,stills:h}),m=Qe(),g=ut(),y=xn("chat"),[w,v]=S.useState(null),N=I=>{const R=I.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=S.useRef(null);oN(x,f);const _=L(I=>{var R;return r?(R=I.local[r])==null?void 0:R.refusedLink:void 0});it([f,_],()=>{var R;const I=x.current;if(I)for(const C of I.querySelectorAll("a.file-link, code[data-path]")){const O=C.getAttribute("href")??C.dataset.path,A=_!==void 0&&O===_.href;C.classList.toggle("file-link-refused",A),A?((R=C.dataset).tipWas??(R.tipWas=C.dataset.tip??""),C.dataset.tip=_.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 j=S.useRef(null),T=Hy(j);return d.jsxs("div",{ref:j,className:"msg-assistant md row-edge","data-state":hr({cursor:n}),...y.contextMenu((I,R)=>{const C=N(R);return C?Ca(C.src,{open:()=>v(C)},C.kept):t(mp(R,o),Bk(R))}),onClick:I=>{const R=N(I.target);R?v(R):_y(I,o,r,{sock:m,dispatch:g})},children:[d.jsx("div",{ref:x}),T,w&&r&&d.jsx(Qu,{owner:"chat",onClose:()=>v(null),menu:()=>Ca(w.src,{},{worktreeId:r,file:w.file,sock:m}),children:d.jsx("img",{src:w.src,alt:w.alt})})]})}const Cg=40;function v$(e,t,n=!1){return e.map((r,o)=>{const s=kp(r.lang,t||(r.diff?vU(r.text):"")),a=r.diff?C7(r.text):[];let c=r.diff?yh(EU(a,s)):r.code&&s?yh(wp(r.text,s)):Py(r.text);return n&&o===e.length-1&&(c=Wj(c)),{...r,lines:a,painted:c}})}function b$({blocks:e,path:t,worktreeId:n}){Qe();const r=ut();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,Cg).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(fu,{pieces:o.painted[c]}):a.text||" "},c)}),o.lines.length>Cg&&d.jsxs("button",{type:"button",className:"dl more",disabled:!t||!n,"data-tip":t&&n?"Open this file's diff":void 0,onClick:()=>n&&Dn({dispatch:r},{worktreeId:n,path:t,view:"diff"}),children:[o.lines.length-Cg," more lines"]})]},s):o.code?d.jsx("pre",{className:"tool-block",children:o.painted.length?o.painted.map((a,c)=>d.jsxs(S.Fragment,{children:[c>0?`
249
- `:null,d.jsx(fu,{pieces:a})]},c)):o.text},s):d.jsx("p",{className:"tool-note",children:o.painted.length?o.painted.map((a,c)=>d.jsxs(S.Fragment,{children:[c>0?`
250
- `:null,d.jsx(fu,{pieces:a})]},c)):o.text},s))})}function SH({image:e,worktreeId:t}){const n=Pr().attachment(t,e.file),r={worktreeId:t,file:e.file,sock:Qe()},[o,s]=S.useState(!1),a=xn("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(()=>Ca(n,{open:()=>s(!0)},r)),children:d.jsx("img",{src:n,alt:e.file})}),o&&d.jsx(Qu,{owner:"chat",onClose:()=>s(!1),menu:()=>Ca(n,{},r),children:d.jsx("img",{src:n,alt:e.file})})]})}const _H=S.memo(function({item:t,roots:n,worktreeId:r}){const o=S.useMemo(()=>v$(Fk(t,t.output??""),Xl(t),!t.done),[t]),s=Ru(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(b$,{blocks:o,path:x$(t,n),worktreeId:r}),a.length>0&&r&&d.jsx("div",{className:"tool-out",children:a.map(c=>d.jsx(SH,{image:c,worktreeId:r},c.file))})]})});function x$(e,t){const n=Ep(Xl(e),t??[]);return n.startsWith("/")?"":n}const NH=S.memo(function({text:t,item:n,roots:r,worktreeId:o}){const s=Xl(n),a=S.useMemo(()=>v$([{code:!0,diff:!0,lang:"diff",text:t}],s),[t,s]);return d.jsx("div",{className:"tool-part",children:d.jsx(b$,{blocks:a,path:x$(n,r),worktreeId:o})})});function Uk({className:e,state:t,auto:n,leaf:r,growing:o,label:s,summary:a,menu:c,children:u}){const[h,f]=S.useState(null),m=S.useRef(null),g=S.useRef(null),y=rN(g),w=Zz(".chat-log"),v=!r&&(h??n),[N,x]=S.useState(v);S.useEffect(()=>{v&&x(!0)},[v]);const _=()=>{r||(v||w(m.current),f(!v))},j=xn("chat");return d.jsxs("details",{ref:m,className:Ke(e,r&&"leaf"),"data-state":t,open:v,onToggle:T=>{if(!T.currentTarget.open||o)return;const I=g.current;I&&(I.scrollTop=0,y.read())},...j.contextMenu((T,I)=>c({open:v,leaf:!!r,toggle:_},I)),tabIndex:-1,onPointerDown:()=>{var T;return(T=m.current)==null?void 0:T.focus({preventScroll:!0})},onKeyDown:T=>{if((T.key==="ArrowLeft"||T.key==="ArrowRight")&&!r){if(T.shiftKey||T.altKey||T.metaKey||T.ctrlKey)return;lp([{depth:0,open:v}],0,T.key)&&_();return}T.key!=="Escape"||!v||(T.stopPropagation(),f(!1))},children:[d.jsx("summary",{"aria-label":s,tabIndex:r?-1:void 0,onClick:T=>{T.preventDefault(),_()},children:a}),d.jsx("div",{className:"tool-body",ref:g,children:v||N?u:null})]})}function TH({markdown:e,streaming:t,worktreeId:n,fileRoot:r}){const o=y$(n),s=td(e,r||t||o?{fileRoot:r,streaming:t,worktrees:o}:void 0),a=Qe(),c=ut(),u=S.useRef(null);oN(u,s);const h=S.useRef(null),f=Hy(h);return d.jsx("div",{className:"tool-part",children:d.jsxs("div",{ref:h,className:"tool-out thought-out md",onClick:m=>_y(m,r,n,{sock:a,dispatch:c}),children:[d.jsx("div",{ref:u}),f]})})}const jH=S.memo(function({item:t,open:n,streaming:r,worktreeId:o,fileRoot:s}){const a=e$(t.text),c=a.slice(0,-1),u=r?"Thinking":"Thought",h=d.jsx(TH,{markdown:a.length?c.join(`
251
-
252
- `):Qj(t.text),streaming:r,worktreeId:o,fileRoot:s}),f=a.at(-1)??(r?"":t$(t.text));if(f){const m=c.length===0;return d.jsx(Uk,{className:"tool-row",auto:!1,leaf:m,growing:r,label:f,menu:(g,y)=>Wn([Ak(Bk(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(mt,{name:"bulb",className:"tool-icon"}),d.jsx("span",{className:"tool-hint thought-line",children:r?d.jsx("span",{className:"live-text",children:f}):f})]}),children:m?null:h})}return d.jsx(Uk,{className:"tool-row",auto:!!n,growing:r,label:u,menu:(m,g)=>Wn([Ak(Bk(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(mt,{name:"bulb",className:"tool-icon"}),d.jsx("span",{className:Ke("tool-name",r&&"live-text"),children:u})]}),children:h})}),da=6,$H={land:"the land",commit:"the commit","sync-main":"the sync","pull-main":"the pull"},Rf=S.memo(function e({tools:t,run:n,next:r,live:o,working:s,held:a,since:c,queued:u,roots:h,worktreeId:f,marked:m}){const g=t[0],y=S.useMemo(()=>rH(t.map(fe=>Fk(fe,fe.output??""))),[t]),w=t.at(-1)??g,v=!w.done,N=v&&!!w.background,_=(v||!!r||!!a)&&!u||!!s,j=v&&!!u,T=ji((v||s)&&!w.until?c:void 0),I=n?H7(n):-1,R=S.useMemo(()=>n?f$(n,!0):void 0,[n]),C=!!o,O=Ru(g,h),A=v?S7(g):"",{label:D,icon:B}=O,W=a$(g),U=A?"":W?"Guardian":O.name,Q=A&&g.subagent?O.hint:"",Y=Q||A||(W?v7(g.output??""):O.hint),se=!(n&&n.length>0)&&!y&&t.every(fe=>{var te;return!Ru(fe,h).command&&Fk(fe,fe.output??"").length===0&&!((te=fe.images)!=null&&te.length)}),H=n?z7(n):0,$=gH(t),Z=N?w.until?`wakes ${Gh(w.until)}`:"in the background":"",q=[D,Y].filter(Boolean).join(" ")+(Z?`, ${Z}`:"")+(j?", queued":"")+($?", done":""),K=A?"":n?`${H} ${H===1?"call":"calls"}`:t.length>1?`×${t.length}`:"",ne=zn(),de=Qe(),pe=L(fe=>{var te;return f?(te=fe.shipping[f])==null?void 0:te.op:void 0}),je=v&&g.name===Ci&&f?{worktreeId:f,toolId:w.id}:null,_e=v?null:(()=>{const fe=qt(ne.getState(),f);return wH(t,h??[],fe?{id:fe.worktree.id}:null,{sock:de,dispatch:ne.dispatch})})();return d.jsxs(Uk,{className:Ke("tool-row",t.some(fe=>fe.isError)&&"error",g.parentToolId&&"nested",n&&"spawn",j&&"queued"),state:hr({cursor:m}),auto:C,leaf:se,growing:_,label:n&&K?`${q}, ${K}`:t.length>1?`${q}, ${t.length} calls`:q,menu:(fe,te)=>{const re=qt(ne.getState(),f),we=re?{id:re.worktree.id}:null,ue=mp(te,null),le=(ue==null?void 0:ue.kind)==="out"?ue.href:null;return yH(t,h??[],we,{sock:de,dispatch:ne.dispatch},fe,le)},summary:d.jsxs(d.Fragment,{children:[d.jsx(mt,{name:n?"spawn":B,className:"tool-icon"}),U&&d.jsx("span",{className:Ke("tool-name",_&&!Y&&"live-text"),children:U}),A&&!Q?d.jsx("span",{className:"tool-writing","data-tip":Y,children:d.jsx(uh,{})}):Y&&d.jsx("span",{className:"tool-hint",children:_?d.jsx("span",{className:"live-text",children:Y}):Y}),Z&&d.jsx("span",{className:"tool-status",children:Z}),j&&d.jsx("span",{className:"tool-status",children:"queued"}),$&&d.jsx(mt,{name:"check",className:"tool-done"}),T>=da&&d.jsx("span",{className:Ke("tool-age",I>=0&&"tool-age-folded"),children:ka(T)}),K&&d.jsx("span",{className:"tool-count",children:K}),Q&&d.jsx("span",{className:"tool-writing","data-tip":A,children:d.jsx(uh,{})}),je&&d.jsx(It,{icon:"stop",className:"tool-stop",label:pe?`Stop ${$H[pe]}: this step is killed, and what it printed so far stays`:N?"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:fe=>{fe.preventDefault(),fe.stopPropagation(),de==null||de.send({t:"exec-stop",...je})}}),_e&&d.jsx(It,{icon:"eye",className:"tool-open",label:_e.tip,onClick:fe=>{fe.preventDefault(),fe.stopPropagation(),_e.open()}})]}),children:[n&&n.length>0&&d.jsx("div",{className:"spawn-run",children:n.map((fe,te)=>d.jsx(e,{tools:fe.tools,next:fe.next,since:te===I?c:void 0,queued:R==null?void 0:R.has(te),roots:h,worktreeId:f},fe.at))}),y?d.jsx(NH,{text:y,item:g,roots:h,worktreeId:f}):t.map(fe=>d.jsx(_H,{item:fe,roots:h,worktreeId:f},fe.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&&By(e.tools,t.tools)&&h$(e.run,t.run));function CH({item:e}){const t=Qe(),n=ut(),r=L(v=>v.activeId),o=L(v=>v.layout.term),s=L(v=>{var N;return((N=v.rows.find(x=>x.id===v.activeId))==null?void 0:N.login)??!1}),a=L(v=>v.managed.problem),[c,u]=S.useState(""),[h,f]=S.useState(null),m=S.useRef(!1);if(it([s],()=>{s&&m.current&&r&&n({a:"term-stream",id:r,stream:Ds,tall:!0})}),it([e.done],()=>{e.done&&m.current&&o&&n({a:"toggle-terminal"}),m.current=!1}),!r)return null;const g=e.provider==="aws",y=(v,N)=>{t==null||t.send({t:"agent-auth",worktreeId:r,methodId:v,...N?{apiKey:N}:{}})},w=e.methods.find(v=>v.id===h);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,N)=>v.needsKey?d.jsx(Pe,{variant:"outline",on:h===v.id,"data-tip":v.description,onClick:()=>f(h===v.id?null:v.id),children:v.name},v.id):d.jsx(Pe,{variant:"outline",tone:g&&N===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(Pe,{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(""),f(null))},children:[d.jsx(Fo,{type:"password",autoFocus:!0,placeholder:`${w.name} for ${e.agentName}`,value:c,onChange:v=>u(v.target.value)}),d.jsx(Pe,{type:"submit",children:"use key"})]})]})}const AH=S.memo(function({item:t,worktreeId:n,onPickHover:r,marked:o,streaming:s}){const a=zn(),c=Qe(),u=Pr(),h=xn("chat"),f={sock:c,dispatch:a.dispatch},m=()=>{var y;return(y=qt(a.getState(),n))==null?void 0:y.worktree.path},g=y=>y&&n&&d.jsx(fp,{children:d.jsx("div",{className:"msg-attachments",children:y.map(w=>w.kind==="image"?d.jsx(eH,{img:w,worktreeId:n,src:u.attachment(n,w.file)},`${w.kind}-${w.n}`):w.kind==="file"?d.jsx(xp,{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(bp,{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(Np,{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,N)=>Ea(a,c,n,v,N)},`${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":hr({cursor:o}),...h.contextMenu((v,N)=>ki(t,n??null,f,{link:mp(N,w)})),onClick:v=>Mu(v,w,n,f),children:[y,d.jsx(Ou,{text:t.text,worktreeId:n,root:w})]})}case"assistant":return d.jsx($g,{text:t.text,menu:(y,w)=>ki(t,n??null,f,{link:y,code:w}),marked:o,worktreeId:n,fileRoot:m(),streaming:s,pictures:t.pictures});case"error":return d.jsx("div",{className:"msg-assistant msg-error",...h.contextMenu(()=>ki(t,n??null,f)),children:t.text});case"auth":return d.jsx(CH,{item:t});case"ask":{const y=f4(t);if(y){const x=$w(y.questions,y.answers),j={kind:"assistant",text:x.join(`
253
- `)};return d.jsxs(d.Fragment,{children:[d.jsx($g,{text:y.message,menu:(T,I)=>ki({kind:"assistant",text:y.message},n??null,f,{link:T,code:I}),worktreeId:n,fileRoot:m()}),d.jsx("div",{className:"msg-user row-edge","data-state":hr({cursor:o}),...h.contextMenu(()=>ki(j,n??null,f)),children:y.questions.map((T,I)=>{var R;return d.jsxs("div",{children:[x[I],d4(T,(R=y.answers)==null?void 0:R[I]).map((C,O)=>d.jsx("div",{children:C},O))]},T.id)})})]})}const w=p4(t);if(!w)return d.jsx(M8,{item:t});const v=w.file,N={kind:"assistant",text:w.choice};return d.jsxs(d.Fragment,{children:[v?d.jsx(IH,{file:v,worktreeId:n}):w.text&&d.jsx($g,{text:w.text,menu:(x,_)=>ki({kind:"assistant",text:w.text},n??null,f,{link:x,code:_}),worktreeId:n,fileRoot:m()}),d.jsx("div",{className:"msg-user",...h.contextMenu(()=>ki(N,n??null,f)),children:w.choice})]})}case"blocked":return d.jsxs(Tr,{icon:"lock",word:"blocked",tone:"red",below:t.reason,...h.contextMenu(()=>Sy(t.path,void 0,mo(f.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(Tr,{icon:"layers",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(Tr,{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(Tr,{icon:"send",word:"asked",tone:"quiet",children:d.jsx("span",{className:"daemon-text",children:t.why})});case"stopped":return d.jsx(Tr,{icon:"stop",word:"stopped",tone:"quiet"});case"landed":return d.jsx(OH,{item:t});case"handed":return d.jsx(X7,{item:t,worktreeId:n,marked:o,children:g(t.attachments)});case"piece-landed":return d.jsx(J7,{item:t});case"handoff":{const y=a6(t);if(!y)return d.jsx(X1,{item:t,worktreeId:n});const w={kind:"assistant",text:y};return d.jsxs(d.Fragment,{children:[d.jsx("div",{className:"msg-user",...h.contextMenu(()=>ki(w,n??null,f)),children:y}),d.jsx(X1,{item:t,worktreeId:n})]})}case"piece-later":return d.jsx(Q7,{item:t});case"restored":return d.jsx(RH,{item:t});case"adopted":return d.jsx(Tr,{icon:"branch",word:"taken over",tone:"quiet",at:t.ts,children:d.jsxs("span",{className:"daemon-text",children:["on ",t.branch,", its own branch"]})})}});function IH({file:e,worktreeId:t}){const n=Qe(),r=ut(),o=xn("chat"),s=Wy(t??void 0,e);return d.jsx(Tr,{icon:"file",word:"plan",tone:"quiet",...o.contextMenu(()=>Sy(e,t?()=>n==null?void 0:n.send({t:"reveal",worktreeId:t,path:e}):void 0,mo(n))),children:d.jsx("span",{className:"daemon-text",children:d.jsx(Pe,{variant:"inline",tone:"strong","data-tip":e,onClick:()=>t&&Dn({dispatch:r},{worktreeId:t,path:e,view:"preview"}),children:s})})})}function RH({item:e}){return d.jsx(Tr,{icon:"reload",word:"restored",tone:"quiet",at:e.ts,children:d.jsxs("span",{className:"daemon-text",children:["after ",Pw(e.ts-e.archivedAt)," in the archive, back on ",e.branch,e.uncommitted?" with its uncommitted changes":""]})})}function OH({item:e}){const t=PT(e.ts),n=e.mark&&dy(e.mark),r=`${e.text}, ${t}`,o=e.url&&d.jsx(Pe,{variant:"inline",onClick:()=>window.open(e.url,"_blank"),children:"the PR"}),s=e.held&&`Not marked landed: ${eo(e.held)}`;return d.jsx(Tr,{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 Tp=".jump-seat, .draft-intro, .chat-input";function MH(e){const t=e instanceof Element?e:e.parentElement;return!!(t!=null&&t.closest(Tp))}function eE(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(${Tp}) *)`)){const o=n.get(r.dataset.worktree??"");if(!o)continue;const s=vp({...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(`
254
- `);r.dataset.tipDetail!==u&&(r.dataset.tipDetail=u),r.dataset.tipDot!==o.dot&&(r.dataset.tipDot=o.dot)}}function LH(e,t){const n=L(s=>s.visible),r=L(s=>s.shipping),o=L(s=>{var a;return(a=qt(s,t))==null?void 0:a.worktree.repoId});S.useEffect(()=>{const s=e.current;if(!s||!o)return;const a=Sp(n,o,null,r);eE(s,a);let c=0;const u=new MutationObserver(h=>{h.every(f=>MH(f.target))||(cancelAnimationFrame(c),c=requestAnimationFrame(()=>eE(s,a)))});return u.observe(s,{childList:!0,subtree:!0}),()=>{u.disconnect(),cancelAnimationFrame(c)}},[e,n,r,o])}const E$=e=>e===""||e==="!";function tE(e,t){const n=new Set,r=[];for(let o=e.length-1;o>=0;o--){const s=e[o],a=m$(s),c=a!==null?`!${a}`:t?null:s.kind==="user"?s.text:s.kind==="ask"?h4(s):null;c===null||!c.trim()||n.has(c)||(n.add(c),r.push({text:c,at:o}))}return r}function PH(e,t,n,r){if(!t){if(r!=="up"&&r!=="first"||!E$(n))return null;const c=tE(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=tE(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 DH(e,t,n,r){const o=new Map;return{rows:t.map((a,c)=>{const u=n(a,c),h=e.get(a.at),f=h&&h.row.kind===u.kind&&zH(h.row.props,u.props)?h.el:r(a,u);return o.set(a.at,{row:u,el:f}),f}),cache:o}}function zH(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 FH=4;function BH(e,t,n){const r=Math.max(t,0);return n?e>=r+1:e>=r+FH}function UH(e,t,n){S.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,h=0;const f=()=>o.style.setProperty("--cover",`${c?h:u}px`),m=()=>{if(u=s.offsetHeight,h=u,t&&s.classList.contains("foldable")){const N=r.scrollTop;s.classList.add("fold-measure"),h=s.offsetHeight,s.classList.remove("fold-measure"),r.scrollTop=N}a=u-h,o.style.setProperty("--fold",`${a}px`),o.style.setProperty("--keep",`${h}px`),f()},g=()=>{if(!t)return;const N=BH(r.scrollHeight-r.scrollTop-r.clientHeight,a,c);N!==c&&(c=N,f(),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 N of["--fold","--keep","--cover"])o.style.removeProperty(N);n(!1)}},[e,t,n])}const HH={get current(){return du.el}},WH={upTo:e=>e.querySelector(":scope > .jump-seat"),except:Tp};function Hk({items:e,next:t,worktreeId:n,onOpen:r}){const o=Pr();return d.jsx(fp,{children:d.jsx("div",{className:"msg-attachments",children:uw(e,t).map(([s,a])=>s.kind==="image"?d.jsx(_p,{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(xp,{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(bp,{className:"in-chat",n:a,name:s.name,source:s.source,...xw(s.text),text:s.text},`paste-${a}`):d.jsx(Np,{className:"in-chat",pick:s,worktreeId:n,onOpen:r},`pick-${a}`))})})}function KH({entry:e,next:t,worktreeId:n,root:r,onOpen:o}){const s=ut(),a=Qe(),c=At(e.id,"draft"),u=At(e.id,"attachments");return d.jsxs("div",{className:"msg-user queued-msg",onClick:h=>Mu(h,r,n,{sock:a,dispatch:s}),children:[d.jsxs("span",{className:"queued-tag",children:[d.jsx(mt,{name:"clock",className:"icon-inline"}),d.jsx("span",{className:"live-text",children:"uploading"})]}),d.jsxs("span",{className:"queued-actions",children:[d.jsx(It,{icon:"edit",label:"Edit: puts it back in the input",onClick:()=>s({a:"unsend",id:e.id})}),d.jsx(It,{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(Hk,{items:u,next:t,worktreeId:n,onOpen:o}),d.jsx(Ou,{text:c,worktreeId:n,root:r})]})]})}const qH=new Set;function Ag({active:e,archived:t,found:n,lead:r,tail:o,foot:s}){var Ft;const a=Qe(),c=zn(),u=ut(),h=L(P=>P.frame==="phone"),f=(e==null?void 0:e.worktree.id)??(t==null?void 0:t.id)??(n==null?void 0:n.id)??null,m=At(f,"chat"),g=At(f,"queue"),y=At(f,"sending"),w=S.useMemo(()=>Hg(S_(m)),[m]),v=S.useMemo(()=>{let P=w;return g.map(oe=>{const $e=P;return P=lu(P,oe.attachments??[]),$e})},[g,w]),N=L(P=>P.outbox),x=S.useMemo(()=>{let P=g.reduce((oe,$e)=>lu(oe,$e.attachments??[]),w);return N.filter(oe=>oe.log===f).map(oe=>{const $e=P;return P=lu(P,oe.kinds.map(Fe=>({kind:Fe}))),{entry:oe,next:$e}})},[N,f,g,w]),_=y!=null&&y.message?g.findIndex(P=>{var oe;return P.text===((oe=y.message)==null?void 0:oe.text)}):-1,j=S.useRef(null);LH(j,f),YF(j,WH);const[T,I]=S.useState(null),R=S.useCallback(()=>{const P=(j.current&&_k(j.current))??"";I(oe=>({seed:P||(oe==null?void 0:oe.seed)||"",seq:((oe==null?void 0:oe.seq)??0)+1}))},[]),C=S.useCallback(P=>!(P!=null&&P.closest("[data-pane]"))&&!c.getState().overlay,[c]);HT(HH,ky,R,C);const O=P=>{if(I(null),P){const oe=window.getSelection();oe==null||oe.removeAllRanges(),oe==null||oe.addRange(P)}},A=rN(j,m);it([f],()=>A.jump());const D=A.offStart&&A.moving==="up",B=A.offEnd&&(A.moving==="down"||A.away),W=P=>P.preventDefault(),U=(D||B)&&d.jsxs("div",{className:Ke("jump",A.away&&"jump-news"),children:[D&&d.jsx("button",{className:"jump-up",onMouseDown:W,onClick:A.start,"data-tip":"Jump to start",children:d.jsx(mt,{name:"caret-up",className:"icon-inline"})}),B&&d.jsxs("button",{className:"jump-down",onMouseDown:W,onClick:A.jump,"data-tip":"Jump to latest",children:[d.jsx(mt,{name:"caret",className:"icon-inline"}),A.away&&" new messages"]})]}),Q=S.useCallback(P=>u({a:"reading",on:P}),[u]);UH(j,h,Q);const Y=At(f,"mark"),se=(Y==null?void 0:Y.by)==="walk"?Y.at:void 0,H=S.useRef(null),$=()=>{const P=j.current,oe=P==null?void 0:P.querySelector(':scope > [data-state~="cursor"]');if(!P||!oe)return;const $e=parseFloat(getComputedStyle(P).paddingTop)||0;P.scrollTop+=oe.getBoundingClientRect().top-P.getBoundingClientRect().top-$e,A.read()};it([se],()=>{const P=j.current;if(P){if(se===void 0){const oe=H.current;if(H.current=null,!oe||!E$(Zr(c.getState(),f).draft))return;oe.bottom?A.jump():(P.scrollTop=oe.top,A.read());return}H.current??(H.current={bottom:A.pinned(),top:P.scrollTop}),$()}});const Z=At(f,"sent");it([Z],()=>{Z&&A.jump()});const q=x.length,K=S.useRef(q);it([q],()=>{q>K.current&&A.jump(),K.current=q});const ne=(Y==null?void 0:Y.by)==="reveal"?Y:void 0,de=S.useMemo(()=>ne?G7(m,ne.seq):-1,[m,ne]),pe=se??(de>=0?de:void 0);it([ne==null?void 0:ne.n,de],()=>{de>=0&&$()});const je=S.useCallback((P,oe)=>{f&&(oe?cn.post(f,{type:"highlight-selector",selector:P.selector,label:Lw(P)}):cn.post(f,{type:"highlight-clear"}))},[f]),_e=ns(e==null?void 0:e.agent),fe=At(f,"cardParked"),te=S.useMemo(()=>{const P=iy(m);return!!P&&fe!==P.id},[m,fe]),re=e==null?void 0:e.worktree,we=(re==null?void 0:re.path)??(t==null?void 0:t.path)??(n==null?void 0:n.path),ue=S.useMemo(()=>we?[we]:[],[we]),le=S.useMemo(()=>D7(m,ue,_e),[m,ue,_e]),be=S.useMemo(()=>_e?F7(m):qH,[_e,m]),Ce=S.useMemo(()=>B7(le,be),[le,be]),Ne=Ce.floating,Ie=S.useRef([]),Be=S.useMemo(()=>(Ie.current=W7(Ie.current,Ce.flow),Ie.current),[Ce]),Je=(e==null?void 0:e.agent)==="working",zt=Je||(e==null?void 0:e.agent)==="waiting",Yt=S.useMemo(()=>zt?q7(Be):-1,[zt,Be]),_t=Be.at(-1),qe=Je&&_t&&"item"in _t&&(_t.item.kind==="thinking"||_t.item.kind==="assistant")?Be.length-1:-1,xt=(Ft=le.findLast(P=>{var oe;return"tools"in P&&((oe=P.tools[0])==null?void 0:oe.name)===Ci}))==null?void 0:Ft.at,ht=At(f,"chatAt"),De=ji(_e?ht:void 0),nt=At(f,"usage"),at=(nt==null?void 0:nt.heard)!==void 0&&ht!==void 0&&nt.heard>ht?nt.heard:void 0,Xt=ji(_e?at:void 0),Nt=ji(y&&!_e?y.at:void 0),Zt=U7(m,_e),gt=Ne.length>0,nr=qe>=0||Zt||gt,Jt=Je&&!nr&&De<da?O7(Be,ue):-1,Rn=S.useMemo(()=>f$(Be),[Be]),Kn=At(f,"running"),un=P=>Kn&&P.tools.some(oe=>oe.id===Kn.id)?Kn.at:void 0,vn=e==null?void 0:e.worktree.path,J=P=>`${f??""}:${P}`,ye=(P,oe)=>"spawn"in P?{kind:"tool",props:{tools:[P.spawn],run:P.run,roots:ue,worktreeId:f}}:"tools"in P?{kind:"tool",props:{tools:P.tools,next:P.next,live:oe===Yt||P.at===xt,held:oe===Jt,since:un(P),queued:Rn.has(oe),roots:ue,worktreeId:f,marked:P.at===pe}}:P.item.kind==="thinking"?{kind:"thought",props:{item:P.item,open:oe===Yt,streaming:oe===qe,worktreeId:f,fileRoot:vn}}:{kind:"item",props:{item:P.item,worktreeId:f,onPickHover:je,marked:P.at===pe,streaming:Je&&oe===Be.length-1}},We=S.useRef(new Map),rt=DH(We.current,Be,ye,(P,oe)=>oe.kind==="tool"?d.jsx(Rf,{...oe.props},J(P.at)):oe.kind==="thought"?d.jsx(jH,{...oe.props},J(P.at)):d.jsx(AH,{...oe.props},J(P.at)));We.current=rt.cache;const jt=d.jsxs("div",{className:"chat-wrap",children:[d.jsxs("div",{className:"chat-log",ref:j,children:[r,rt.rows,Ne.map(P=>{var oe;return"spawn"in P?d.jsx(Rf,{tools:[P.spawn],run:P.run,working:!0,since:ht,roots:ue,worktreeId:f},J(P.at)):((oe=P.tools[0])==null?void 0:oe.name)===Ci?d.jsx(Rf,{tools:P.tools,live:P.at===xt,since:un(P),roots:ue,worktreeId:f,marked:P.at===pe},J(P.at)):d.jsx(Rf,{tools:P.tools,since:ht,roots:ue,worktreeId:f},J(P.at))}),f&&(y==null?void 0:y.message)&&d.jsxs("div",{className:"msg-user",onClick:P=>Mu(P,we,f,{sock:a,dispatch:u}),children:[y.message.attachments&&d.jsx(Hk,{items:y.message.attachments,next:w,worktreeId:f,onOpen:(P,oe)=>Ea(c,a,f,P,oe)}),d.jsx(Ou,{text:y.message.text,worktreeId:f,root:we})]}),e&&(y||_e&&!(e.agent==="waiting"&&te)&&!Zt&&!gt&&Jt<0&&!(nr&&De<da))&&d.jsx("div",{className:"working-row",children:e.agent==="waiting"?"waiting for your answer…":nr?De>=da&&d.jsxs("span",{children:["quiet for",d.jsx("span",{className:"working-num",children:ka(De)})]}):d.jsxs("span",{className:"working-mark",children:[d.jsx(uh,{}),!_e&&y?Nt>=da&&d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"working-word",children:"waiting for the agent"}),d.jsx("span",{className:"working-num",children:ka(Nt)})]}):at!==void 0?Xt>=da&&d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"working-word",children:"thinking"}),d.jsx("span",{className:"working-num",children:ka(Xt)})]}):De>=da&&d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"working-word",children:"waiting for the model"}),d.jsx("span",{className:"working-num",children:ka(De)})]})]})}),f&&g.map((P,oe)=>oe===_?null:d.jsxs("div",{className:"msg-user queued-msg",onClick:$e=>Mu($e,we,f,{sock:a,dispatch:u}),children:[d.jsxs("span",{className:"queued-tag",children:[d.jsx(mt,{name:"clock",className:"icon-inline"}),"queued"]}),d.jsxs("span",{className:"queued-actions",children:[d.jsx(It,{icon:"edit",label:"Edit: removes from queue, puts it back in the input",onClick:()=>NN(c,a,f,oe)}),d.jsx(It,{icon:"close",label:"Remove from queue",onClick:()=>a==null?void 0:a.send({t:"unqueue",worktreeId:f,index:oe})})]}),d.jsxs("div",{className:"queued-text",children:[P.attachments&&d.jsx(Hk,{items:P.attachments,next:v[oe]??w,worktreeId:f,onOpen:($e,Fe)=>Ea(c,a,f,$e,Fe)}),d.jsx(Ou,{text:P.text,worktreeId:f,root:we})]})]},`q-${oe}`)),f&&x.map(({entry:P,next:oe})=>d.jsx(KH,{entry:P,next:oe,worktreeId:f,root:we,onOpen:($e,Fe)=>Ea(c,a,f,$e,Fe)},P.id)),o,d.jsx("div",{className:"jump-seat",children:U}),h&&s]}),T&&d.jsx(BT,{root:j,body:j,skip:Tp,seed:T.seed,seq:T.seq,onClose:O,onReveal:A.read})]});return h?jt:d.jsxs(d.Fragment,{children:[jt,s]})}function ZH(e){return e.offer?e.offer.state!=="offered"?!0:e.agent==="idle"&&e.chat.some(t=>t.kind==="assistant"):!1}const GH=/EACCES|EPERM|permission denied/i,VH="https://docs.npmjs.com/resolving-eacces-permissions-errors-when-installing-packages-globally";function YH(e){return{why:e.line.replace(/\.$/,""),permissions:GH.test(e.line),command:e.command}}function XH(){try{return localStorage.getItem(tt.installOffered)==="1"}catch{return!1}}let vh={prompt:null,offered:typeof localStorage<"u"&&XH()};const Wk=new Set;function Kk(e){vh={...vh,...e};for(const t of Wk)t()}typeof window<"u"&&(window.addEventListener("beforeinstallprompt",e=>{e.preventDefault(),Kk({prompt:e})}),window.addEventListener("appinstalled",()=>Kk({prompt:null})));function S$(e){return Wk.add(e),()=>{Wk.delete(e)}}function _$(){return S.useSyncExternalStore(S$,()=>vh.prompt)}function QH(){return S.useSyncExternalStore(S$,()=>vh.offered)}function nE(){try{localStorage.setItem(tt.installOffered,"1")}catch{}Kk({offered:!0})}function JH(e){return!e.prompt||e.offered||e.agent!=="idle"?!1:e.chat.some(t=>t.kind==="assistant")}function Ky(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=qy(e);return r&&n.push({id:"install",label:r,onClick:()=>t==null?void 0:t.send(N$(e))}),n}function qy(e){return e.install?e.install==="missing"?"install":e.install.held?"install anyway":"install again":null}function N$(e){const t=qy(e)==="install anyway";return{t:"install-agent",agent:e.id,...t?{anyway:!0}:{}}}const jp=e=>e.reason??"not installed";function T$({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(ts,{k:r}),o]},r)),t&&d.jsx("span",{className:"key-note",children:t})]})}const eW={side:"top",align:"start",offset:4,alignOffset:-10,matchWidth:-20,flip:"side",margin:8};function tW({results:e,keyOf:t,row:n,rowClass:r,nav:o,listRef:s,empty:a,note:c,groupOf:u,groupHead:h}){const f=new Set(u?e.map(u):[]);return d.jsxs(Hs,{className:"inline-picker",anchor:"parent",placement:eW,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&&f.size>1&&(g===0||(u==null?void 0:u(e[g-1]))!==y)?d.jsx("div",{className:"picker-group",children:(h==null?void 0:h(y))??y}):null;return d.jsxs(S.Fragment,{children:[w,d.jsx("button",{className:Ke("picker-item",r==null?void 0:r(m)),"data-state":hr({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(T$,{hints:[["↑↓","moves"],["tab","inserts"],["esc","dismisses"]],note:c})]})}const rE=e=>Math.max(0,Math.min(1,Number.isFinite(e)?e:0));function nW({fraction:e,level:t,className:n}){const o=2*Math.PI*5.5,s=rE(e),a=S.useId(),c=3.5,u=2*c*rE(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 rW(e,t=gu.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}.`}function Lu({anchored:e=!1,...t}){return e?d.jsx(oW,{...t,anchored:e===!0?{}:e}):d.jsx(sW,{...t})}function oW({onClose:e,onEscape:t,boxClass:n="",bare:r=!1,anchored:o,coverBy:s,id:a,children:c}){const{onKey:u,back:h}=j$(t);return d.jsx(Hs,{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:()=>h()||(e==null?void 0:e()),children:c})}function sW({onClose:e,onEscape:t,boxClass:n="",bare:r=!1,id:o,children:s}){const{onKey:a,back:c}=j$(t);return d.jsx(Hs,{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 j$(e){const t=zn(),n=()=>{if(e)return e(),!0;const o=t.getState();return!o.overlay||o.choosingFolder?!1:(t.dispatch({a:"close",back:D_(o.overlay)}),!0)};return{onKey:o=>{o.key==="Escape"&&n()&&o.stopPropagation()},back:n}}function iW(e){const t=e.value.length;e.setSelectionRange(t,t)}function aW({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 Gr({items:e,filter:t,keyOf:n,row:r,rowClass:o,rowTitle:s,onPick:a,onBack:c,onActive:u,onSide:h,onTab:f,onQuery:m,completionOf:g,narrowTo:y,placeholder:w,initialQuery:v="",initialIndex:N,selectOnMount:x=!1,idleWhen:_,onIdlePick:j,anchored:T=!1,onEscape:I,lead:R,trailing:C,empty:O="no matches",footer:A,keys:D,rowMenu:B,groupOf:W,groupHead:U,headAlone:Q=!1,field:Y}){const se=xn("picker"),[H,$]=S.useState(v),Z=S.useMemo(()=>t(e,H),[e,H,t]),q=S.useRef(null),K=Di(),ne=Wz(x,!K&&!Y);S.useEffect(()=>{if(!m)return;const Ce=setTimeout(()=>m(H),150);return()=>clearTimeout(Ce)},[H,m]);const de=eT({results:Z,keyOf:n,q:H,onPick:a,listRef:q,onActive:u,onSide:h,completionOf:g,narrowTo:y,setQ:$,initialIndex:N,idle:(_==null?void 0:_(v))??!1,onIdlePick:j}),{index:pe,ghost:je}=de,_e=Y?Y.open:!0;it([_e,v],()=>{!Y||_e||($(v),de.setIndex(_!=null&&_(v)?-1:0))}),it([_e],()=>{if(!Y||!_e||K)return;const Ce=()=>{const Ie=ne.current;!Ie||document.activeElement===Ie||(Ie.focus(),x&&Ie.select())};Ce();const Ne=requestAnimationFrame(Ce);return()=>cancelAnimationFrame(Ne)});const fe=S.useRef(!1),te=typeof D=="function"?D(de.active,H):D,re=[];te!=null&&te.nav&&re.push(["↑↓",te.nav]),te!=null&&te.side&&h&&re.push(["←→",te.side]),te!=null&&te.complete&&(je!=null&&je.accept)&&re.push(["tab",te.complete]),te!=null&&te.tab&&f&&re.push(["tab",te.tab]),te!=null&&te.pick&&re.push(["enter",te.pick]),te!=null&&te.back&&re.push(["esc",te.back]);const we=Ce=>d.jsxs("div",{...Y==null?void 0:Y.attrs,className:Ke("picker-input",Y&&"picker-field",Y==null?void 0:Y.className),"data-open":(Y==null?void 0:Y.open)||void 0,onMouseDown:Ne=>{var Ie;Ne.target.closest("input, .float")||(Ne.preventDefault(),(Ie=ne.current)==null||Ie.focus())},children:[R,d.jsxs("div",{className:"picker-caret",children:[d.jsx(Fo,{font:"mono",bare:!0,ref:ne,value:H,spellCheck:!1,"aria-controls":Y==null?void 0:Y.id,"aria-expanded":Y?Y.open:void 0,onFocus:()=>{Y&&!Y.open&&Y.onOpen()},onBlur:Ne=>{const Ie=Ne.relatedTarget;Y!=null&&Y.open&&Ie instanceof Element&&!Ie.closest(".float")&&c()},onMouseDown:Ne=>{const Ie=document.activeElement!==Ne.currentTarget;if(fe.current=Ie,Y&&Ie){const Be=document.getSelection();Be&&(!Be.isCollapsed||Be.toString()!=="")&&Be.removeAllRanges()}},onClick:Ne=>{if(!Y||!fe.current)return;fe.current=!1;const Ie=Ne.currentTarget;setTimeout(()=>{document.activeElement===Ie&&Ie.selectionStart===Ie.selectionEnd&&Ie.select()},0)},onChange:Ne=>{$(Ne.target.value),de.setIndex(_!=null&&_(Ne.target.value)?-1:0),Y&&!Y.open&&Y.onOpen()},onKeyDown:Ne=>{var Ie;if(Y&&!Y.open){if(Ne.key==="ArrowDown"||Ne.key==="ArrowUp")Y.onOpen();else if(Ne.key==="Escape"){iW(Ne.currentTarget),Ne.currentTarget.blur();return}}if(B&&de.active&&(Ne.key==="ContextMenu"||Ne.key==="F10"&&Ne.shiftKey)){const Be=(Ie=q.current)==null?void 0:Ie.querySelector('[data-state~="cursor"]');if(Be){Ne.preventDefault(),Ne.stopPropagation(),ho.open({items:B(de.active),owner:"picker",target:Be,anchor:Be.getBoundingClientRect()});return}}de.onKeyDown(Ne)||!f||Ne.key!=="Tab"||Ne.shiftKey||(Ne.preventDefault(),f())},placeholder:w}),je&&d.jsxs("div",{className:"picker-ghost","aria-hidden":"true",children:[d.jsx("span",{className:"picker-typed",children:H}),aW(je)]})]}),C,Ce]}),ue=new Map;if(W)for(const Ce of Z)ue.set(W(Ce),(ue.get(W(Ce))??0)+1);const le=d.jsxs("div",{className:"picker-list",ref:q,onMouseDown:Ce=>{Y&&Ce.target!==Ce.currentTarget&&Ce.preventDefault()},children:[Z.map((Ce,Ne)=>{const Ie=W==null?void 0:W(Ce),Be=Ie!==void 0&&(Q||ue.size>1)&&(Ne===0||(W==null?void 0:W(Z[Ne-1]))!==Ie)?d.jsx("div",{className:"picker-group",children:(U==null?void 0:U(Ie,ue.get(Ie)??0))??Ie}):null;return d.jsxs(S.Fragment,{children:[Be,d.jsx("button",{className:Ke("picker-item",o==null?void 0:o(Ce)),"data-state":hr({cursor:Ne===pe}),title:s==null?void 0:s(Ce),onMouseMove:()=>Ne!==pe&&de.setIndex(Ne),onClick:()=>{var Je;de.pick(Ce),(Je=ne.current)==null||Je.focus()},...se.contextMenu(()=>(B==null?void 0:B(Ce))??[]),children:r(Ce,Ne===pe,H)})]},n(Ce))}),Z.length===0&&d.jsx("div",{className:"empty",children:typeof O=="function"?O(H):O}),A==null?void 0:A(H,Z)]}),be=re.length>0&&d.jsx(T$,{hints:re});return Y?we(Y.open&&d.jsxs(Lu,{onClose:c,onEscape:I,boxClass:"picker",anchored:T,id:Y.id,children:[le,be]})):d.jsxs(Lu,{onClose:c,onEscape:I,boxClass:"picker",anchored:T,coverBy:R?".picker-input > *:first-child":C?".picker-input > *:last-child":void 0,children:[we(),le,be]})}function _i({value:e,reads:t,options:n,onChange:r,placeholder:o,hint:s,className:a,onClose:c}){const[u,h]=S.useState(!1),f=()=>{h(!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(Pe,{variant:"ghost",tone:"chrome",mono:!0,on:u,className:Ke("chip-picker-btn",a),...Lt(s),onClick:()=>u?f():h(!0),children:y}),u&&d.jsx(Gr,{anchored:{flip:"both",margin:0},onEscape:f,items:n,filter:(w,v)=>{const N=v.trim().toLowerCase().split(/\s+/).filter(Boolean);return w.filter(x=>{const _=`${x.prefix??""} ${x.label??x.id} ${x.suffix??""} ${x.id}`.toLowerCase();return N.every(j=>_.includes(j))})},keyOf:w=>w.id,initialIndex:w=>Math.max(0,w.findIndex(v=>v.id===e)),lead:d.jsx(Pe,{tone:"chrome",mono:!0,on:!0,className:"chip-picker-lead",onClick:f,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),f())},onBack:f})]})}const Ps="";function $$(e,t){return!e||t.length===0?e:QA(e,t)??Ps}function lW(e){var h;const t=uW(e.name);if(t){const f=[t.qualifier,e.description||e.name].filter(Boolean).join(" · ");return{label:t.label,version:t.version,description:f}}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]??((h=e.name.match(/\(([^)]*)\)$/))==null?void 0:h[1]),...o].filter(Boolean).join(" · ");return{label:s,version:a[2],...u?{description:u}:{}}}const cW=/(?:^|[./])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 uW(e){const t=e.match(cW),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 C$(e,t,n,r,o){const s=XE(e),a=XA(e,o),c=N=>a&&N===(s==null?void 0:s.id)?a.id:N,u=$$(t,e),h=c(u||n||(s==null?void 0:s.id)||Ps),f=c(u||(s==null?void 0:s.id)||Ps),m=a?e.filter(N=>N!==s):e,g=m.some(N=>N.id===h),y=m.map(N=>({c:N,words:lW(N)})),w=N=>[N.label,N.version].filter(Boolean).join(" "),v=[...s?[]:[{id:Ps,label:r.label,description:r.description}],...y.map(({c:N,words:x})=>{const _=y.filter(T=>w(T.words)===w(x)).length===1?x:void 0,j=_?_.description:N.description;return{id:N.id,label:_?_.label:N.name,..._!=null&&_.version?{suffix:_.version}:{},..._!=null&&_.version&&y.some(T=>T.c!==N&&T.words.label===_.label)?{chip:w(_)}:{},description:N===a?["default",j].filter(Boolean).join(" · "):j}}),...h&&!g?[{id:h,label:h}]:[]];if(h!==f){const N=v.find(j=>j.id===h),x=v.findIndex(j=>j.id===f),_=v[x];if(_){const j=(N==null?void 0:N.chip)??(N==null?void 0:N.label)??h;v[x]={..._,description:[`${j} now`,_.description].filter(Boolean).join(" · ")}}}return{rows:v,shown:h,picked:f}}const Jc=(e,t)=>`${e} ${t}`;function dW(e){const t=e.indexOf(" ");return t<0?{agent:e,model:Ps}:{agent:e.slice(0,t),model:e.slice(t+1)}}function fW(e,t,n){const r=e.length>1;let o=Jc(t,n);return{rows:e.flatMap(a=>{var f;const c=a.short??a.name,u=a.id===t;if(!a.available||!((f=a.models)!=null&&f.length))return u&&(o=Jc(a.id,Ps)),[{id:Jc(a.id,Ps),label:c,description:a.available?a.checkFailed??"its own default model; the rest are listed once it has run":jp(a),disabled:!a.available}];const h=C$(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=Jc(a.id,h.shown)),h.rows.map(m=>({...m,id:Jc(a.id,m.id),...r&&m.id!==Ps?{prefix:c}:{}}))}),shown:o}}function A$({choices:e,value:t,current:n,runs:r,what:o,defaultLabel:s,defaultDescription:a,placeholder:c,className:u,onChange:h,onClose:f}){const{rows:m,shown:g,picked:y}=S.useMemo(()=>C$(e,t,n,{label:s,description:a},r),[e,t,n,r,s,a]);if(e.length===0)return null;const w=m.find(N=>N.id===g),v=(w==null?void 0:w.chip)??(w==null?void 0:w.label)??g;return d.jsx(_i,{value:y,reads:g,options:m,onChange:h,onClose:f,className:u,hint:$$(t,e)?`asked for ${v}; click to change`:`${v}, the agent's choice; click to pick ${o}`,placeholder:c})}function oE({efforts:e,value:t,current:n,runs:r,onChange:o,onClose:s}){return d.jsx(A$,{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 hW=e=>{var t;return((t=Ch.find(n=>n.id===e))==null?void 0:t.description)??""};function sE({value:e,onChange:t,onClose:n}){return d.jsx(_i,{value:e,options:Ch.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}: ${hW(e)}. Click to change`,placeholder:"what the agent may do without asking"})}function iE({models:e,value:t,current:n,runs:r,onChange:o,onClose:s}){return d.jsx(A$,{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 pW({agents:e,agent:t,model:n,onChange:r,onClose:o}){const{rows:s,shown:a}=S.useMemo(()=>fW(e,t,n),[e,t,n]);if(s.length===0)return null;const c=s.find(h=>h.id===a),u=c?[c.prefix,c.label,c.suffix].filter(Boolean).join(" "):n;return d.jsx(_i,{value:a,options:s,onChange:h=>{const f=dW(h);r(f.agent,f.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 mW(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 Zy=e=>e.line===void 0?null:e.startLine!==void 0?`${e.startLine}-${e.line}`:String(e.line);function I$(e){return e==="changes_requested"?"requested changes":e==="approved"?"approved":"reviewed"}const aE=e=>e.split(`
255
- `).map(t=>t?`> ${t}`:">").join(`
256
- `);function gW({root:e,replies:t}){const n=Zy(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":I$(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(aE(e.body));for(const a of t)s.push(`${a.author} replied:
257
- ${aE(a.body)}`);return s.join(`
258
-
259
- `)}function kW({root:e}){if(!e.path)return`review from ${e.author}`;const t=e.path.slice(e.path.lastIndexOf("/")+1),n=Zy(e);return`${t}${n?` (${n})`:""} from ${e.author}`}function R$(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 Ql(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 wW({c:e,query:t}){const n=t.trim();return d.jsxs(d.Fragment,{children:[d.jsxs("span",{className:"picker-name",children:["/",Ql(e.name,n?vy(e.name,n):null,0)]}),d.jsx("span",{className:"picker-desc row-dim",children:e.description})]})}function Mn({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 yW(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 vW=/ \| | - | \u2013 | \u2014 | \u00b7 |: /,bW=/^(\d+|[0-9a-f]{8}-[0-9a-f-]{27}|[0-9a-f]{12,})$/i,xW=/^[[:$*{]|\[/;function EW(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(vW).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 h;return(((h=o.get(u))==null?void 0:h.size)??0)<2});c.length>0&&t.set(s,c.join(" "))}return t}function Gy(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(bW.test(r)||xW.test(r))continue;const o=r.replace(/[-_.]+/g," ").trim();if(o)return o[0].toUpperCase()+o.slice(1)}return"Home"}const Ig=8,SW=3,_W=50,NW=3;function TW(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?qP(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:EW(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 $W(e){const t=e.trim();return/^[/?#]/.test(t)?t:`/${t}`}function CW(e,t){const n=/^[/?#]/.test(t)?e:e.replace(/^\//,"");return t&&n.toLowerCase().startsWith(t.toLowerCase())?n:null}const O$=e=>/^\[\[?\.\.\.|^\*$|^\$$/.test(e),su=e=>O$(e)||/[[:$*{]/.test(e)&&!/^[^[{:$*]+\?$/.test(e),AW=e=>Wh(`/${e}`).text.slice(1),Vy=e=>e.split("/").filter(Boolean);function Yy(e,t){const n=t.startsWith("/"),r=t.replace(/^\//,"").split("/"),o=Vy(e);let s="";const a=[],c=m=>{const g=AW(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(O$(y))return{show:t,accept:t};if(su(y)){if(!g)return null}else if(g.toLowerCase()!==y.toLowerCase())return null;s+=`${su(y)?g:y}/`;continue}if(su(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+="/",su(m)?c(m):s+=m;const u=n?1:0,h=(n?"/":"")+s,f=a[0];return{show:h,accept:f?h.slice(0,f[0]+u):h,params:a.map(([m,g])=>[m+u,g+u])}}function IW(e,t){const n=Yy(e,t);return n?n.accept.length>t.length?n.accept:t:Wh(e).literal}function M$(e,t){if(e.kind==="go")return null;if(e.template){const n=Yy(e.path,t);return n&&n.show.length>t.length?n:null}return CW(e.path,t)}const RW=e=>e.trim().replace(/^\//,"").toLowerCase();function L$(e,t){for(let n=0;n<e.length;n++)if("/-_.#".includes(e[n])&&e.startsWith(t,n+1))return!0;return!1}function OW(e,t,n){const r=e.replace(/^\//,"").toLowerCase(),o=t.toLowerCase();return r===n?100:r.startsWith(n)?80:L$(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 MW(e,t){const{text:n,literal:r}=Wh(e);return r.replace(/^\//,"").toLowerCase().startsWith(t)?80:Yy(e,t)?70:L$(n.replace(/^\//,"").toLowerCase(),t)?60:0}function LW(e,t){const n=Vy(e).findIndex(su);return n>=0&&t.split("/").length>n}function hu(e,t,n){var c;const r=e.statics.get(t),o=r?null:ZP(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)||Gy(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 P$(e,t){const n=e.unseen[t.file];return{kind:"page",path:t.path,title:Gy(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=>Vy(e).length,xh=e=>e.badge==="new"?0:e.badge==="changed"?1:2;function PW(e,t){const n=new Set,r=[];e.history.forEach((f,m)=>{if(f.path===t)return;const g=hu(e,f.path,m);n.has(g.group)||(n.add(g.group),r.push(g))});const o=new Set(r.map(f=>f.path)),s=r.filter(f=>f.badge);for(const[f,m]of e.statics)e.unseen[m.file]&&f!==t&&!o.has(f)&&s.push(hu(e,f,Number.POSITIVE_INFINITY));for(const f of e.templateRoutes.values())e.unseen[f.file]&&!n.has(f.path)&&s.push(P$(e,f));s.sort((f,m)=>xh(f)-xh(m)||f.rank-m.rank);const a=r.filter(f=>!f.badge),c=s.slice(0,Ig-Math.min(SW,a.length));for(const f of a)c.length<Ig&&c.push(f);const u=new Set(c.map(f=>f.path)),h=[...e.statics.keys(),...[...e.links.keys()].filter(f=>!e.statics.has(f))].filter(f=>f!==t&&!u.has(f)&&!o.has(f)).sort((f,m)=>bh(f)-bh(m)||(f<m?-1:f>m?1:0));for(const f of h){if(c.length>=Ig)break;c.push(hu(e,f,Number.POSITIVE_INFINITY))}return c.map(Gf)}function DW(e,t,n){const r=RW(t),o=$W(t),s=new Map;e.history.forEach((y,w)=>{y.path!==n&&s.set(y.path,hu(e,y.path,w))});for(const y of[...e.statics.keys(),...e.links.keys()])y!==n&&!s.has(y)&&s.set(y,hu(e,y,Number.POSITIVE_INFINITY));const a=[];for(const y of s.values()){const w=OW(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=MW(y.path,r);v>=60&&a.push({...P$(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,h=[];for(const y of a){if(!y.template&&y.group!==y.path){const w=u.get(y.group)??0;if(w>=NW&&!LW(y.group,r))continue;u.set(y.group,w+1)}if(h.push(y),h.length>=_W)break}if(h.some(y=>y.score===100))return h.map(Gf);const f={kind:"go",path:o,...c?{title:Gy(c.path)}:{}},m=h[0];return!c&&m!==void 0&&m.score>=80&&zW(m.path,r)?[...h.map(Gf),f]:[f,...h.map(Gf)]}function zW(e,t){const n=e.replace(/^\//,"").toLowerCase().slice(t.length);return!t.endsWith("/")&&n.length>0&&!/^[/?#]/.test(n)}function D$(e,{query:t,current:n,here:r}){return t===n||t.trim()===""?PW(e,r):DW(e,t,r)}const FW=[],BW=[];function z$(e,t){const n=L(s=>(t?s.visits[t]:void 0)??FW),r=At(e,"pages"),o=At(e,"links");return it([e],()=>{b_(r)&&cn.post(e,{type:"links"})}),S.useMemo(()=>TW(n,r,o),[n,r,o])}function UW({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}=Wh(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 F$({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(UW,{row:e}),e.badge?d.jsx("span",{className:e.badge==="new"?"badge-new":"badge-changed",children:e.badge}):null]})}const B$=e=>e.kind==="page"&&e.file?e.file:e.path,U$=(e,t)=>e.kind==="page"&&e.template?IW(e.path,t):null,H$=e=>e.kind==="page"&&e.template?"fills in the parameter":"goes there";function W$(e,t,n){return e.kind!=="page"?[]:rp([...e.file&&t.dir?Ls({id:t.worktreeId,dir:t.dir},e.file,{},n):[],gN,...e.visited?yW(t.repoId,e.path,n):[]])}function HW({worktreeId:e,repoId:t,url:n,open:r}){const o=ut(),s=Qe(),a=L(w=>{const v=qt(w,e);return v?v.worktree.path:null}),c=z$(e,t),u=jW(n),h=n?Hh(n):null,f=S.useCallback((w,v)=>D$(c,{query:v,current:u,here:h}),[c,u,h]),m=S.useCallback(w=>w===u||w.trim()==="",[u]),g=()=>o({a:"close"}),y=S.useMemo(()=>({open:r,onOpen:()=>o({a:"open",overlay:{kind:"routes"}}),id:"routes",className:"bar-path",attrs:Lt("Go to a page",Dt("routes"))}),[r,o]);return d.jsx(Gr,{anchored:{matchWidth:0,cover:!1,offset:-1},field:y,items:BW,filter:f,initialQuery:u,selectOnMount:!0,idleWhen:m,onIdlePick:w=>{w.trim()===""?cn.post(e,{type:"navigate",path:"/"}):cn.post(e,{type:"reload"}),g()},keyOf:w=>`${w.kind}:${w.path}`,rowClass:()=>"picker-row",rowTitle:B$,completionOf:(w,v)=>m(v)?null:M$(w,v),narrowTo:U$,onPick:w=>{cn.post(e,{type:"navigate",path:w.path}),g()},onBack:g,rowMenu:w=>W$(w,{worktreeId:e,repoId:t,dir:a},{sock:s,dispatch:o}),placeholder:"type a path",keys:(w,v)=>({complete:"completes the path",pick:w?H$(w):v.trim()===""?"goes to the root":"reloads",back:"closes"}),empty:"no pages yet; type a path",row:w=>d.jsx(F$,{row:w})})}function K$(e,t){const n=t.trim();return d.jsx(Mn,{label:Ql(e.label,n?vy(e.label,n):null,0),hint:e.hint&&d.jsx(ts,{k:e.hint})})}function q$({anchored:e,trailing:t}){const n=ut(),r=XT(),o=L(s=>{var a;return((a=s.paletteReturn)==null?void 0:a.mode)==="commands"?s.paletteReturn.q:""});return d.jsx(Gr,{anchored:e,trailing:t,items:r,filter:QT,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)=>K$(s,c)})}function Z$(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 lE(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 G$(e,t,n,r=50){const o=Z$(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},h=o.filter(m=>m.status).sort((m,g)=>u(m)-u(g)||lE(m.path,g.path)),f=o.filter(m=>!m.status).sort((m,g)=>lE(m.path,g.path));return{rows:[...h,...f].slice(0,r),changed:Math.min(h.length,r)}}const a=Y$(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 V$(e,t){const n=e.toLowerCase(),r=cE(n,t);return r<=0?0:cE(n.slice(n.lastIndexOf("/")+1),t)>0?r+10:r}function Y$(e,t){const n=[];for(const r of e){const o=V$(r.path,t);o>0&&n.push({row:r,score:r.status?o+4:o})}return n}function WW(e,t,n,r,o){const s=r.trim().toLowerCase();if(!s)return G$(e,n,r,o).rows.map(u=>({kind:"file",path:u.path,status:u.status}));const a=Y$(Z$(e,n),s).map(({row:u,score:h})=>({row:{kind:"file",path:u.path,status:u.status},score:h}));for(const u of t){const h=V$(u,s);h>0&&a.push({row:{kind:"folder",path:u},score:h})}const c=u=>u.kind==="folder"?1:0;return a.sort((u,h)=>h.score-u.score||c(u.row)-c(h.row)||u.row.path.localeCompare(h.row.path)),a.slice(0,o).map(u=>u.row)}function KW(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 cE(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 qW(e){const t=e.lastIndexOf("/");return t===-1?[e,""]:[e.slice(t+1),e.slice(0,t+1)]}const uE=[],ZW=[],GW=[];function VW({worktreeId:e}){var N;const t=ut(),n=Qe(),r=zn(),o=L(x=>x.connected);it([e,o,n],()=>sp(e,r.getState(),{sock:n,dispatch:t}));const s=dN(e),a=s.files??ZW,c=((N=s.git)==null?void 0:N.files)??GW,u=XT(),h=L(x=>{var _;return((_=x.paletteReturn)==null?void 0:_.mode)==="quick-open"?x.paletteReturn.q:""}),f=L(x=>{var j;const _=(j=qt(x,e))==null?void 0:j.worktree;return _?_.path:null}),m=L(x=>{var _;return((_=qt(x,e))==null?void 0:_.repoId)??null}),g=L(x=>{var _;return((_=bu(x))==null?void 0:_.worktreeId)===e}),y=z$(e,m),w=s.page.url?Hh(s.page.url):null,v=S.useCallback((x,_)=>_.startsWith(">")?QT(u,_.slice(1)).map(j=>({kind:"cmd",c:j})):_.startsWith("/")?g?D$(y,{query:_,current:"/",here:w}).map(j=>({kind:"page",page:j})):uE:G$(a,c,_).rows.map(j=>({kind:"file",path:j.path,status:j.status})),[u,a,c,g,y,w]);return d.jsx(Gr,{items:uE,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"?B$(x.page):void 0,completionOf:(x,_)=>x.kind==="page"?M$(x.page,_):null,narrowTo:(x,_)=>x.kind==="page"?U$(x.page,_):null,onPick:(x,_)=>{x.kind==="cmd"?(x.c.sub?t({a:"palette-return",v:{mode:"quick-open",q:_}}):t({a:"close"}),x.c.run()):x.kind==="page"?(cn.post(e,{type:"navigate",path:x.page.path}),t({a:"close"})):(Dn({dispatch:t},{worktreeId:e,path:x.path,view:Ri(x.path)}),t({a:"close"}))},onBack:()=>t({a:"close"}),rowMenu:x=>x.kind==="file"&&f?Ls({id:e,dir:f},x.path,{},{sock:n,dispatch:t}):x.kind==="page"&&m?W$(x.page,{worktreeId:e,repoId:m,dir:f},{sock:n,dispatch:t}):[],placeholder:"jump to file · type > for commands, / for pages",keys:(x,_)=>_.startsWith("/")?{complete:"completes the path",pick:(x==null?void 0:x.kind)==="page"?H$(x.page):void 0,back:"closes"}:{pick:"opens",back:"closes"},initialQuery:h,empty:x=>x.startsWith(">")?"no matching command":x.startsWith("/")?g?"no pages yet; type a path":"no preview running":"no matches",row:(x,_,j)=>x.kind==="cmd"?K$(x.c,j.slice(1)):x.kind==="page"?d.jsx(F$,{row:x.page}):qk(x.path,x.status,j,{gutter:c.length>0})})}function qk(e,t,n,{folder:r=!1,gutter:o=!0}={}){const[s,a]=qW(e),c=n.trim()?KW(e,n.trim()):null;return d.jsxs(d.Fragment,{children:[o&&d.jsx("span",{className:`xy ${t?Rw(t.xy):""}`,children:t?Ow(t.xy):""}),d.jsxs("span",{className:"name",children:[Ql(s,c,a.length),r&&"/"]}),d.jsx("span",{className:"dir row-dim",children:a&&d.jsxs(d.Fragment,{children:["‎",Ql(a,c,0),"‎"]})}),t&&d.jsx(AT,{f:t})]})}function YW(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: ${jp(e)}`,retry:qy(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(mt,{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(Pe,{variant:"inline",tone:"strong","data-tip":n,onClick:r,children:t})," "]}),c]}),s&&d.jsx(It,{icon:"close",tone:"quiet",className:"composer-offer-close",label:"Not this one",onClick:s})]})}function X$({item:e,n:t,onRemove:n}){const r=Pr();return e.kind==="image"?d.jsx(_p,{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(xp,{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(bp,{n:t,name:e.name,source:e.source,lines:e.lines,chars:e.chars,preview:e.preview,text:e.text,onRemove:n})}function Q$({children:e}){return d.jsx("code",{className:"composer-offer-whole",children:e})}function XW({children:e}){var n;if(!e.includes("://"))return d.jsx(Q$,{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(S.Fragment,{children:[o>0&&" ",r.includes("://")?r.split(new RegExp("(?=\\/)(?<![:/])")).map((s,a)=>d.jsxs(S.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 QW({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(Q$,{children:"toyon restart"})," moves onto it."]});if(e.state==="failed"){const r=YH(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:VH,target:"_blank",rel:"noreferrer",children:"npm's guide"})," ","covers this error."," "]}),"By hand: ",d.jsx(XW,{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 Pu({rows:e,cursor:t,onCursor:n,onPick:r,onHint:o,hover:s=!1}){const a=Di(),c=S.useRef(null),[u,h]=S.useState(null),f=a&&!!o;oT(c,{rowOf:g=>{if(!f||g.closest("textarea"))return null;const y=g.closest(".slide"),w=y==null?void 0:y.dataset.row,v=w===void 0?void 0:e[Number(w)];return y&&w!==void 0&&(v!=null&&v.hint)&&!v.field?{el:y,key:w,rungs:1,rung:120}:null},onSlide:h,onPick:g=>o==null?void 0:o(Number(g))});const m=g=>{var y;g.target instanceof HTMLTextAreaElement||(g.preventDefault(),(y=g.currentTarget.querySelector("textarea"))==null||y.focus())};return d.jsx("div",{className:Ke("choices",s&&"choices-hover",a&&"choices-touch"),ref:c,children:e.map((g,y)=>{const w=!a&&t===y,v=hr({cursor:w,checked:g.checked}),N=g.tone==="deny"&&"choice-deny",x=()=>n==null?void 0:n(y),_=T=>{var C;if(!f)return T;const I=(u==null?void 0:u.key)===String(y)?u.step:null,R=I!==null&&I>0&&((C=g.hint)==null?void 0:C.on)!==!1;return d.jsxs("div",{className:"slide","data-row":y,children:[T,I!==null&&g.hint&&d.jsxs("span",{className:"slide-verb","data-rung":R?"hint":void 0,"aria-hidden":"true",children:[d.jsx("span",{className:"slide-word",children:g.hint.label}),d.jsx(mt,{name:g.hint.icon})]})]},y)},j=d.jsxs(d.Fragment,{children:[!a&&d.jsx(ts,{k:String(y+1),className:"choice-num row-dim"}),d.jsx("span",{className:"choice-label",children:g.label}),!a&&g.hint&&d.jsxs("span",{className:Ke("choice-hint row-dim",w&&g.hint.on!==!1&&"on"),children:[d.jsx(ts,{k:g.hint.k})," ",g.hint.label]}),g.description&&d.jsx("span",{className:"choice-desc",children:g.description}),g.sample&&d.jsx("pre",{className:"choice-sample",children:g.sample})]});return g.field?_(d.jsxs("div",{className:Ke("picker-item choice row-edge",N),"data-state":v,onMouseMove:x,onMouseDown:m,children:[j,d.jsx(ju,{ref:g.field.ref,bare:!0,font:"ui",rows:1,className:"choice-field",enterKeyHint:g.field.enterKeyHint,placeholder:g.field.placeholder,value:g.field.value,onChange:T=>{var I;return(I=g.field)==null?void 0:I.onChange(T.target.value)}}),a&&g.field.onSend&&d.jsx(It,{className:"choice-send",icon:"send",tone:"primary",label:"Send",onClick:g.field.onSend})]},y)):_(d.jsx("button",{type:"button",className:Ke("picker-item choice row-edge",N),"data-state":v,disabled:g.disabled,onMouseMove:x,onClick:()=>r(y),children:j},y))})})}function J$(e){return iu(e.key)&&(e.metaKey||e.ctrlKey)&&!e.altKey?!1:e.metaKey||e.ctrlKey||e.altKey}const eC=e=>e.length===1&&e>="1"&&e<="9",iu=e=>e==="Enter"||e==="NumpadEnter";function JW(e,t,n){const r=iu(e.key)&&(e.metaKey||e.ctrlKey);return t?e.key==="Escape"||e.key==="Tab"&&!e.shiftKey?{kind:"field-leave"}:r?{kind:"submit"}:iu(e.key)&&!e.shiftKey?{kind:"field-enter"}:{kind:"typing"}:J$(e)?{kind:"chord"}:e.key==="Escape"?{kind:"escape"}:r?{kind:"submit"}:iu(e.key)||e.key===" "&&n.spacePicks?n.cursor===void 0?{kind:"submit"}:{kind:"pick",at:n.cursor,by:iu(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)}:eC(e.key)&&Number(e.key)<=n.count?{kind:"pick",at:Number(e.key)-1,by:"digit"}:null}function Xy(e,t){var o,s,a,c;const n=e.target instanceof HTMLTextAreaElement,r=JW(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 tC(e){return!e||e===document.body?!1:e.closest(".monaco-editor, .xterm")?!0:(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement)&&!e.closest(".chat-input")}function eK(e,t){it([t],()=>{const o=requestAnimationFrame(()=>{var s;tC(document.activeElement)||(s=e.current)==null||s.focus()});return()=>cancelAnimationFrame(o)});const n=S.useRef(!1),r=S.useCallback(()=>{requestAnimationFrame(()=>{var o;document.activeElement===document.body&&((o=e.current)==null||o.focus())})},[e]);return S.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;tC(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=eK(e,t);return d.jsx("div",{ref:e,className:"card",tabIndex:-1,onKeyDown:n,onKeyUp:r,onPaste:o,onBlur:a,children:s})}function Du({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 Zk(e){const t=S.useRef(null),n=Hy(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 tK({children:e}){return d.jsx("div",{className:"card-foot",children:e})}const nK=[{selected:[]}];function rK({item:e,worktreeId:t,rootRef:n}){var Y,se;const r=Qe(),o=ut(),s=At(t,"card"),a=L(H=>{var $;return($=qt(H,t))==null?void 0:$.worktree.mode})??e.mode,c=a==="plan"?"auto":a,u=(s==null?void 0:s.id)===e.id?s.draft:nK,h=(Y=u[0])==null?void 0:Y.note,f=h!==void 0,m=f?Number(((se=u[0])==null?void 0:se.selected[0])??0):-1,g=(H,$=0)=>o({a:"card-draft",id:t,card:{id:e.id,draft:[{...H[0]??{selected:[]},selected:[String($)]}],current:0}}),y=S.useRef(null),[w,v]=S.useState(0),[N,x]=S.useState(null),_=N!==null,j=e.pieces.length===1?e.pieces[0]:void 0,T=e.plan,I=()=>{T&&Dn({dispatch:o},{worktreeId:t,path:T,view:"preview"})},R=S.useMemo(()=>j?Sa(j.plan):"",[j]),C=S.useMemo(()=>j?ON(e,j):[{fate:"worktree",label:"go"},{fate:null,label:"not now"}],[e,j]),O=H=>{if(_||!r)return;const $=C[H];$&&($.fate===null?r.send(Ex(e,t,!1,void 0)):(j&&$.fate!==zi(e,j)&&r.send(MN(e,t,j.id,$.fate)),r.send(Ex(e,t,!0,h)),x(H)),o({a:"answered",id:t}))},A=()=>{const H=C[w],$=H&&H.fate!==null?w:C.findIndex(Z=>Z.fate!==null);$!==-1&&((!f||m!==$)&&g(ih(u,0,h??""),$),v($),requestAnimationFrame(()=>{var Z;return(Z=y.current)==null?void 0:Z.focus()}))},D=()=>o({a:"card-park",id:t,cardId:e.id}),B=()=>{var $;const H=tu(u,0);H!==u&&g(H,m),($=n.current)==null||$.focus()},W=H=>{Xy(H,{count:C.length,cursor:w,onCursor:v,onPick:O,onEscape:D,onFieldEnter:()=>O(m),onFieldLeave:B})||(H.key==="n"?(H.preventDefault(),A()):H.key==="r"&&T&&!j&&(H.preventDefault(),I()))},U=C.map((H,$)=>({label:H.label,...N===$?{description:"starting"}:H.description?{description:H.description}:{},...H.fate!==null?{hint:{k:"n",label:"add context",icon:"edit",on:!f}}:{},tone:H.fate===null?"deny":void 0,checked:f&&$===m,field:f&&$===m?{ref:y,value:h??"",placeholder:j?H.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:Z=>g(ih(u,0,Z),m),onSend:()=>O(m)}:void 0,disabled:_}));if(j)return d.jsxs(Sh,{root:n,id:e.id,onKeyDown:W,children:[d.jsx(Du,{sub:d.jsxs(d.Fragment,{children:[j.project?`Starts a worktree in ${j.project.name}, in ${c} mode${c==="auto"?", which runs without asking":""}, with this as its plan. `:"","Nothing has started yet."]}),children:pk(e)}),d.jsx(Zk,{html:R}),d.jsx(Pu,{rows:U,cursor:w,onCursor:H=>{v(H),Eh(n)},onPick:O})]});const Q=T?d.jsx(Pe,{variant:"inline","data-tip":"Open it beside the box; any row can still be moved (r)",onClick:()=>I(),children:"The list is on its page"}):"The list is the agent's";return d.jsxs(Sh,{root:n,id:e.id,onKeyDown:W,children:[d.jsx(Du,{sub:d.jsxs(d.Fragment,{children:[Q,". Nothing has started yet."]}),children:pk(e)}),d.jsx(Pu,{rows:U,cursor:w,onCursor:H=>{v(H),Eh(n)},onPick:O})]})}function oK(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",...sK(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=Uy(n);return r===null?null:{verb:"fix",key:n.id,toolId:n.id,command:r}}function sK(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 Gk=new Set;const Vk=new Set;function iK(e){return Vk.add(e),()=>{Vk.delete(e)}}function dE(e){Gk=new Set(Gk).add(e);for(const t of Vk)t()}function aK(){return S.useSyncExternalStore(iK,()=>Gk)}const lK=e=>Ch.some(t=>t.id===e);function cK(e){return[...Ch.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 uK(e,t,n){const r=e.trim();if(!r)return{pick:!0};const o=t.find(f=>f.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(),h=u==="here"?o:t.find(f=>f.name.toLowerCase()===u);return h?{repo:h,...c?{text:c}:{}}:o?{repo:o,text:r}:{pick:!0}}function nC(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 fE(e,t){const n=nC(e,t);return[...n.yours,...n.own,...n.rest]}function hE(e,t){const n=nC(e,t);return{rows:[...n.yours,...n.own],more:n.rest.length}}function dK(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 fK(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 hK(e){const t=e.findIndex(n=>n.kind.startsWith("reject"));return t<0?null:t}function pK(e){const{key:t}=e;return t.length!==1||t===" "||t==="n"||eC(t)||J$(e)?null:t}const pE=[{selected:[]}];function mK({item:e,ask:t,worktreeId:n,rootRef:r}){var W;const o=Qe(),s=ut(),a=L(U=>U.activeId),c=At(n,"card"),u=(c==null?void 0:c.id)===e.id?c.draft:pE,h=(W=u[0])==null?void 0:W.note,f=h!==void 0,m=f?t.choices.findIndex(U=>{var Q;return U.id===((Q=u[0])==null?void 0:Q.selected[0])}):-1,g=S.useRef(null),[y,w]=S.useState(0),v=t.plan,N=S.useMemo(()=>t.detail&&!v?Sa(t.detail):"",[t.detail,v]),x=L(U=>U.frame==="phone"),_=()=>{v&&a===n&&!x&&Dn({dispatch:s},{worktreeId:n,path:v,view:"preview",focus:!1})};it([e.id,v],_);const j=t.handoff,T=L(U=>{var Y;const Q=j?(Y=Zr(U,n).chat)==null?void 0:Y.find(se=>se.kind==="handoff"&&se.id===j):null;return(Q==null?void 0:Q.kind)==="handoff"?Q:null}),I=U=>s({a:"card-draft",id:n,card:{id:e.id,draft:U,current:0}}),R=(U,Q)=>{const Y=t.choices[U];Y&&(I([{selected:[Y.id],note:Q}]),w(U),requestAnimationFrame(()=>{const se=g.current;se&&(se.focus(),se.setSelectionRange(se.value.length,se.value.length))}))},C=U=>{const Q=t.choices[U];if(!Q)return;const Y=h==null?void 0:h.trim();o==null||o.send({t:"agent-decide",worktreeId:n,askId:e.id,choiceId:Q.id,...Y?{note:Y}:{}}),s({a:"answered",id:n})},O=()=>s({a:"card-park",id:n,cardId:e.id}),A=()=>{var U;h!=null&&h.trim()||I(pE),(U=r.current)==null||U.focus()},D=U=>{if(Xy(U,{count:t.choices.length,cursor:y,onCursor:w,onPick:C,onEscape:O,onFieldEnter:()=>C(m),onFieldLeave:A}))return;if(U.key==="n"){U.preventDefault(),R(y,h??"");return}const Q=pK(U);Q!==null&&(U.preventDefault(),R(f?m:hK(t.choices)??y,(h??"")+Q))},B=t.choices.map((U,Q)=>{const Y=U.kind.startsWith("reject"),se=f&&Q===m;return{label:U.name,tone:Y?"deny":void 0,hint:{k:"n",label:"add context",icon:"edit",on:!f},checked:se,field:se?{ref:g,value:h,placeholder:Y?"what to change, sent with your no":"a note for the work, sent with your yes",enterKeyHint:"send",onChange:H=>I([{selected:[U.id],note:H}]),onSend:()=>C(m)}:void 0}});return d.jsxs(Sh,{root:r,id:e.id,onKeyDown:D,children:[d.jsx(Du,{sub:T?d.jsxs(d.Fragment,{children:[o6(T,n)," ",d.jsx(Pe,{variant:"inline","data-tip":"Read the list at the head of the plan; any row can still be moved",onClick:()=>v&&Dn({dispatch:s},{worktreeId:n,path:v,view:"preview"}),children:"The list is on the plan"}),"."]}):void 0,children:t.title}),t.command&&d.jsx(Zk,{code:i$(t.command)}),N&&d.jsx(Zk,{html:N}),d.jsx(Pu,{rows:B,cursor:y,onCursor:U=>{w(U),Eh(r)},onPick:C,onHint:U=>R(U,h??"")})]})}function gK({item:e,ask:t,worktreeId:n,rootRef:r,numbers:o,onAnswer:s}){const a=Qe(),c=ut(),u=zn(),h=L(re=>re.clientId),{message:f,questions:m}=t,g=Ll(e.id),y=At(g,"attachments"),w=WN(g,n),v=At(n,"card"),N=S.useMemo(()=>(v==null?void 0:v.id)===e.id?v:{id:e.id,draft:i4(m),current:0},[v,e.id,m]),{draft:x,current:_}=N,j=_===Al(m),T=m[_],I=x[_],R=!!(T!=null&&T.multi),[C,O]=S.useState(()=>Cl(T,I)),A=S.useRef(null);S.useEffect(()=>{const re=window.visualViewport;if(!re)return;const we=()=>{A.current&&A.current===document.activeElement&&A.current.scrollIntoView({block:"nearest"})};return re.addEventListener("resize",we),()=>re.removeEventListener("resize",we)},[]);const D=(re,we)=>c({a:"card-draft",id:n,card:{id:e.id,draft:re,current:we}}),B=cN(),W=re=>{if(B)return;if(s){re&&s(re);return}const we=re?y:[],ue={t:"agent-answer",worktreeId:n,askId:e.id,...re?{answers:re}:{}};we.some(Ii)?c({a:"hold-send",id:g,log:n,text:$w(m,re).join(`
260
- `),frame:ue}):(a==null||a.send({...ue,...we.length?{attachments:we.map(Dl),boxId:g,clientId:h}:{}}),we.length&&c({a:"clear-attachments",id:g})),c({a:"answered",id:n})},U=()=>c(s?{a:"ask-revive",id:n}:{a:"card-park",id:n,cardId:e.id}),Q=()=>{cg(m,x)&&W(x)},Y=re=>{O(Cl(m[re],x[re])),D(x,re)},se=re=>{T!=null&&T.note&&(D(Qb(x,_,re,R),_),requestAnimationFrame(()=>{var we;return(we=A.current)==null?void 0:we.focus()}))},H=re=>{if(!(T!=null&&T.note))return;const we=T.options[re];if(O(re),!we||R)return se(!we);D(Qb(Xb(x,_,we.value,!1),_,!1,!1),_),requestAnimationFrame(()=>{var ue;return(ue=A.current)==null?void 0:ue.focus()})},$=()=>H(C),Z=re=>{const we=w4(m,re,_);O(we.cursor),D(re,we.current),we.send&&cg(m,re)&&W(re)},q=re=>{if(Jb(T,re))return O(re),se(!0);const we=T==null?void 0:T.options[re];if(!T||!we)return;const ue=Xb(tu(x,_),_,we.value,R);if(R){O(re),D(ue,_);return}Z(ue)},K=re=>{if(!R||Jb(T,re)||!l4(T,x[_]))return q(re);Z(tu(x,_))},ne=()=>{var we;const re=tu(x,_);re!==x&&(D(re,_),O(Cl(T,re[_]))),(we=r.current)==null||we.focus()},de=()=>{var we;const re=tu(x,_);if((we=r.current)==null||we.focus(),!xa(re[_])){re!==x&&(D(re,_),O(Cl(T,re[_])));return}Z(re)},pe=re=>{if(w.onPasteKey(re),!Xy(re,{count:j?m.length:a4(T),cursor:j?void 0:C,spacePicks:R,onCursor:O,onPick:(we,ue)=>j?Y(we):ue==="enter"?K(we):q(we),onSubmit:Q,onEscape:U,onFieldEnter:de,onFieldLeave:ne})){if(re.key==="ArrowLeft"||re.key==="ArrowRight"||re.key==="Tab"){re.preventDefault();const we=re.key==="ArrowLeft"||re.key==="Tab"&&re.shiftKey;return Y(m4(_,we?-1:1,k4(m)))}if(re.key==="n"&&(T!=null&&T.note))return re.preventDefault(),$();if(re.key==="s"&&!s)return re.preventDefault(),W()}},je=re=>m.length===1&&!re.multi,_e=(re,we)=>d.jsxs(tK,{children:[(!re||!je(re))&&d.jsx(Pe,{variant:"outline",size:"md",disabled:B||!cg(m,x),onClick:Q,children:"send"}),(re==null?void 0:re.note)&&we&&we.selected.length>0&&we.note===void 0&&d.jsxs(Pe,{tone:"quiet",size:"md",onClick:()=>se(!1),children:[d.jsx(ts,{k:"n",chip:!0}),"add a note"]}),!s&&d.jsxs(Pe,{tone:"quiet",size:"md",onClick:()=>W(),children:[d.jsx(ts,{k:"s",chip:!0}),"skip"]}),d.jsx(It,{className:"card-attach",icon:"attach",tone:"chrome",label:"Attach a picture or a file",onClick:()=>FN(u,g)})]}),fe=y.length>0&&d.jsx(fp,{children:d.jsx("div",{className:"card-chips",children:uw(y,o).map(([re,we])=>{const ue=()=>c({a:"detach",id:g,key:re.key});return re.kind==="pick"?null:d.jsx(X$,{item:re,n:we,onRemove:ue},re.key)})})}),te=(re,we)=>{const ue=we===_,le=x[we],be=u_(le,!!re.multi),Ce=Ie=>({ref:ue?A:void 0,value:(le==null?void 0:le.note)??"",placeholder:Ie,enterKeyHint:Al(m)===-1?"send":"next",onChange:Be=>D(ih(x,we,Be),we),...Al(m)===-1?{onSend:de}:{}}),Ne=re.options.map(Ie=>{const Be=!!(le!=null&&le.selected.includes(Ie.value));return{label:d.jsxs(d.Fragment,{children:[Cw(Ie.label),y4(Ie.label)&&d.jsx("span",{className:"badge-recommended",children:"recommended"})]}),description:Ie.description,sample:Ie.preview,hint:re.note&&!re.multi?{k:"n",label:"add a note",icon:"edit",on:(le==null?void 0:le.note)===void 0}:void 0,checked:Be,field:Be&&!be&&(le==null?void 0:le.note)!==void 0?Ce("a note for the agent, sent with your pick"):void 0}});return re.note&&Ne.push({label:re.note.label,description:be?void 0:"your own answer",checked:be,field:be?Ce("your own answer"):void 0}),d.jsxs("div",{className:Ke("card-page",!ue&&"card-page-off"),children:[d.jsx(Du,{children:re.text||f}),ue&&fe,d.jsx(Pu,{rows:Ne,cursor:ue?C:void 0,onCursor:Ie=>{O(Ie),Eh(r)},onPick:Ie=>{var Be;q(Ie),(Be=r.current)==null||Be.focus()},onHint:H}),_e(re,le)]},re.id)};return d.jsxs(Sh,{root:r,id:e.id,onKeyDown:pe,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((re,we)=>({id:String(we),label:re.header||`question ${we+1}`,lead:d.jsx("span",{className:Ke("dot card-step",xa(x[we])&&"answered")})})),{id:String(m.length),label:"send",far:!0}],current:String(_),onPick:re=>{var we;Y(Number(re)),(we=r.current)==null||we.focus()}})}),d.jsxs("div",{className:"card-pages",children:[m.map(te),Al(m)!==-1&&d.jsxs("div",{className:Ke("card-page",!j&&"card-page-off"),children:[d.jsx(Du,{children:"Send these answers?"}),j&&fe,d.jsx(Pu,{hover:!0,rows:m.map((re,we)=>{const ue=xa(x[we])?u4(re,x[we]):void 0;return{label:d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"row-dim",children:re.header||`question ${we+1}`})," ",d.jsx("span",{className:Ke(!ue&&"row-dim"),children:ue?ue.pick:"no answer yet"})]}),description:ue==null?void 0:ue.note}}),onPick:re=>{var we;Y(re),(we=r.current)==null||we.focus()}}),_e()]})]})]})}const kK=YN("top"),wK=5*6e4;function rC({usage:e,limits:t,auth:n,now:r}){const o=t?RF(t,r):[],s=o.length?_F(n):void 0,a=t&&r-t.at>wK?Pw(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(mE,{name:"context",used:e.used/e.size,sub:`${Kx(e.used)} of ${Kx(e.size)}${c}`}),s&&d.jsx("div",{className:"usage-who section-title",children:s}),o.map(u=>d.jsx(mE,{name:u.name,used:u.used,sub:u.sub},u.key)),a&&d.jsxs("div",{className:"usage-stale hint",children:["read ",a," ago"]})]})}function yK({onClose:e,...t}){return d.jsx(Hs,{className:"usage-panel",anchor:"parent",placement:kK,onDismiss:e,onKey:n=>{n.key==="Escape"&&(n.stopPropagation(),e())},children:d.jsx(rC,{...t})})}function mE({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 oC(e,t,n){const r=S.useRef(n);r.current=n,it([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 gE="not answering; send once Toyon is back",kE=[],vK=[],bK=new Set(["ArrowLeft","ArrowRight","Home","End","PageUp","PageDown"]),xK=150,EK=3,wE=e=>({kind:"cmd",c:e});function SK(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 _K(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 NK(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 pu({active:e,draft:t,archived:n,found:r,project:o,greenfield:s,placement:a="dock"}){var wc,yc,vc,bc,el,bd,xd,Ss,tl,ti,nl,xc;const c=a==="screen",u=ut(),h=Qe(),f=zn(),m=!!t,g=(e==null?void 0:e.worktree.id)??null,y=e==null?void 0:e.worktree.repoId,w=o?Kl:n?n.id:r?r.id:Oa(e),v=!!n||!!r,N=n?n.restorable:!!r&&!r.locked,x=At(w,"draft"),_=At(w,"attachments"),j=At(w,"notice"),T=((wc=e==null?void 0:e.worktree.owns)==null?void 0:wc.join(", "))??"",I=S.useRef({id:g,owns:T});it([g,T],()=>{const z=I.current;I.current={id:g,owns:T},!(z.id!==g||z.owns===T||!T||!w||n)&&u({a:"notice",id:w,text:`Running its own ${T} here now: this branch changed it.`})});const R=At(w,"mark"),C=(R==null?void 0:R.by)==="walk"?R:void 0,O=At(g,"chat"),A=At(g,"queue"),D=S.useMemo(()=>g&&!m?iy(O):null,[g,m,O]),B=At(g,"cardParked"),W=At(g,"sending"),U=S.useMemo(()=>g&&!m&&!W?c_(O):null,[g,m,W,O]),Q=At(g,"askRevived"),Y=!D&&U&&Q===U.id?U:null,se=D&&B!==D.id?D:Y,H=Y?Ll(Y.id):null,$=At(H,"attachments"),Z=D?B===D.id?D:null:U&&!Y?U:null,q=S.useRef(null),K=Di(),ne=Jw(),de=At(ne,"page"),pe=Ku(),je=N3(),_e=_$(),fe=QH(),te=L(z=>z.globalInstall),re=!!_e&&!!g&&!m&&!se&&JH({prompt:_e,offered:fe,agent:e==null?void 0:e.agent,chat:O}),we=aK(),ue=S.useMemo(()=>g&&!m?oK(O,{queued:A.length,sending:!!W,card:!!(se||Z),dismissed:we}):null,[g,m,O,A.length,W,se,Z,we]),le=z=>w&&u({a:"set-draft",id:w,text:z}),be=L(z=>z.clientId),Ce=L(z=>z.repos),Ne=L(z=>z.repos.find(Me=>Me.id===(e==null?void 0:e.worktree.repoId))??null),Ie=L(z=>z.defaultAgent),Be=L(z=>z.agentChosen),Je=m||!!s||!!o,zt=!Je&&!!e&&!e.worktree.agent,Yt=Je||zt,_t=(t==null?void 0:t.agent)??Ie,qe=L(z=>z.agents.find(Me=>Me.id===(Yt?_t:e==null?void 0:e.worktree.agent)));oC(h,g??(Je?"new":null),qe);const xt=!!(qe!=null&&qe.quick),ht=(qe==null?void 0:qe.models)??kE,De=(qe==null?void 0:qe.efforts)??kE,nt=qe==null?void 0:qe.defaultModel,at=qe==null?void 0:qe.defaultEffort,Xt=((yc=qe==null?void 0:qe.picks)==null?void 0:yc.model)??"",Nt=((vc=qe==null?void 0:qe.picks)==null?void 0:vc.effort)??"",Zt=(z,Me,pt)=>h==null?void 0:h.send({t:"set-agent-pick",agent:z,field:Me,value:pt}),gt=z=>Zt(_t,"model",z),nr=z=>Zt(_t,"effort",z),Jt=L(z=>z.agents),Rn=(z,Me)=>{Zt(z,"model",Me),z!==_t&&Kn(z)},Kn=z=>{m?u({a:"draft-agent",id:z}):h==null||h.send({t:"set-default-agent",agent:z})},un=YW(qe,Jt,Yt),vn=un==null?void 0:un.other,J=At(g,"model"),ye=At(g,"effort"),We=At(g,"usage")??(e==null?void 0:e.usage),rt=((bc=Ne==null?void 0:Ne.picks)==null?void 0:bc.mode)??Ug,jt=z=>{Ne&&(h==null||h.send({t:"set-repo-pick",repoId:Ne.id,field:"mode",value:z}))},Ft=(e==null?void 0:e.worktree.mode)??Ug,P=L(z=>z.picking),oe=L(z=>z.layout.term),$e=k_((e==null?void 0:e.procs)??[]),Fe=xn("composer"),Rt=At(g,"files"),Gt=S.useMemo(()=>v_(Rt??vK),[Rt]),Re=L(z=>z.visible),He=L(z=>z.shipping),Ze=S.useMemo(()=>Sp(Re,y,g,He),[Re,y,g,He]),Qt=L(z=>y?z.archived[y]:void 0),Wt=S.useMemo(()=>qj(Ze,Qt),[Ze,Qt]),En=S.useMemo(()=>Kj(Rt,Wt),[Rt,Wt]),Sn=S.useMemo(()=>[...Ze,...(Qt??[]).map(z=>({title:z.title,branch:z.branch,dir:z.path.slice(z.path.lastIndexOf("/")+1)}))],[Ze,Qt]),Ct=At(g,"git"),nn=(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,Pt=L(z=>{var Me;return g?(Me=z.shipping[g])==null?void 0:Me.op:void 0}),bn=L(z=>{var Me;return g?(Me=z.shipping[g])==null?void 0:Me.step:void 0}),fn=L(z=>ql(z,y)),ie=L(z=>{var Me;return fn?(Me=z.shipping[fn.id])==null?void 0:Me.op:void 0}),Te=fn&&Ne&&Je?f_(Ne.defaultBranch,fn):null,dt=L(z=>m?I4(z.rows,y,_t,Ie):g),lt=At(dt,"commands"),Bt=lt.some(z=>z.name==="compact"),kn=ns(e==null?void 0:e.agent),Dr=L(z=>j_(z,g)),lr=kn&&!!g&&!m,ln=e==null?void 0:e.worktree.lastTurn,cr=!x.trim()&&_.length===0,rn=!m&&!s&&cr&&!kn?ln:void 0,Ht=!m&&!s&&e&&ma(e.worktree)?e.worktree.landing:void 0,Ut=!!(Ht!=null&&Ht.ready)&&!Ht.stale&&!Sf(Ht,nn,xt,qe==null?void 0:qe.name),xe=cr&&(!kn||Ut)?Ht:void 0,Ge=nn>0&&!!(xe!=null&&xe.subject),kt=nn||(((el=Ct==null?void 0:Ct.extras)==null?void 0:el.committed.length)??0),wt=!m&&!s&&cr&&!kn&&!!e,on=!!(e!=null&&e.worktree.landed)&&nn===0,dn=wt&&on,Cn=e?Mh({...e.worktree,landed:on}):void 0,wn=wt&&!dn?Cn:void 0,hn=!on&&(Cn==null?void 0:Cn.state)==="open"?Cn:void 0,Ln=!!hn&&(nn>0||sr>0),vr=(Cn==null?void 0:Cn.state)==="closed",X=Ni((Ne==null?void 0:Ne.config)??{}),ge=S.useMemo(()=>cK(Xf(Ni((Ne==null?void 0:Ne.config)??{}),Ne==null?void 0:Ne.defaultBranch)),[Ne]),Ve=()=>g&&(h==null?void 0:h.send({t:"chat",worktreeId:g,text:"/compact"})),Kt=Je?"nothing to compact until the first reply":Bt?kn?"wait for the turn to end":void 0:"this agent offers no compact command",Mt=Bt&&We?TF(We.used/We.size):void 0,pn=qe==null?void 0:qe.limits,_n=Je?void 0:We,zr=(!!g||Je)&&!!(_n||pn),qn=Date.now(),[os,Vt]=S.useState(!1),yt=S.useRef(0),ys=K?()=>d.jsx(rC,{usage:_n,limits:pn,auth:qe==null?void 0:qe.auth,now:Date.now()}):void 0,An=()=>{window.clearTimeout(yt.current),Vt(!1)};it([g],An);const sn=ey(),br=(sn==null?void 0:sn.owner)==="composer"&&sn.key==="usage";it([br],()=>{br&&An()});const Cr=()=>[{id:"compact",label:"compact the context",detail:Kt||!We?void 0:NF(We.used/We.size),disabled:Kt,onClick:Ve}],[Oe,F]=S.useState(0),[G,ce]=S.useState(null),Ee=S.useRef(null),ve=w&&!v&&!o?Tg(x,Oe,z=>Ze.some(Me=>Y1(z,Me))):null,Ye=ve==null?void 0:ve.kind,vt=ve==null?void 0:ve.query,Nn=S.useMemo(()=>{if(vt===void 0)return[];if(Ye==="command")return vt.trim()?zU(fE(ge,lt),vt).slice(0,8).map(wE):hE(ge,lt).rows.map(wE);const z=[],Me=(Ct==null?void 0:Ct.files.length)??0;Me>0&&"changes".startsWith(vt.toLowerCase())&&z.push({kind:"changes",n:Me});const pt=vt.trim(),$t=pt?Ze.filter(Zn=>Y1(pt,Zn)):Ze.slice(0,EK);return z.push(...$t.map(Zn=>({kind:"worktree",...Zn}))),z.push(...WW(Rt??[],Gt,(Ct==null?void 0:Ct.files)??[],vt,8)),z},[Ye,vt,Rt,Gt,Ct,lt,ge,Ze]),Fn=ve!==null&&ve.from!==G&&!C&&!(ve.kind==="file"&&LU(x,ve.from,En)),Xn=Ye==="command"&&vt!==void 0&&!vt.trim()?hE(ge,lt).more:0,Ar=S.useRef(null),ir=S.useRef(null),Ks=S.useRef(null),sc=(z,Me,pt,$t)=>{var ni;const{text:Zn,caret:rr}=jN(x.slice(0,Me)+x.slice(pt),Me,$t);le(Zn),ce(((ni=Tg(Zn,rr))==null?void 0:ni.from)??null),requestAnimationFrame(()=>{z.focus(),z.setSelectionRange(rr,rr),F(rr)})},rd=z=>{const Me=Ar.current;return!z||!Me?!1:(sc(Me,Me.selectionStart,Me.selectionEnd,z),!0)},{onPaste:Fi,onPasteKey:Bi,onPasteKeyUp:qs}=WN(w,g,z=>rd(p$(z,Sn)));P6(ir,Ar,z=>rd(V7(z,Sn)));const vs=()=>{var z;return(z=q.current??Ar.current)==null?void 0:z.focus()},bs=vs;it([s?e==null?void 0:e.worktree.id:null],()=>{if(!s)return;const z=requestAnimationFrame(()=>{var pt;const Me=document.activeElement;(!Me||Me===document.body)&&((pt=Ar.current)==null||pt.focus())});return()=>cancelAnimationFrame(z)});const za=L(z=>z.focusChat),Fa=S.useRef(za),xs=!!fN();it([za],()=>{if(za===Fa.current||(Fa.current=za,xs!==!!s))return;const z=requestAnimationFrame(vs);return()=>cancelAnimationFrame(z)});const Zs=se==null?void 0:se.id,ic=S.useRef({id:g,cardUpId:Zs});it([g,Zs],()=>{const z=ic.current;if(ic.current={id:g,cardUpId:Zs},Zs||!z.cardUpId||z.id!==g||xs!==!!s||K&&!Z)return;const Me=requestAnimationFrame(()=>{var $t;const pt=document.activeElement;(!pt||pt===document.body)&&(($t=Ar.current)==null||$t.focus())});return()=>cancelAnimationFrame(Me)});const ko=L(z=>z.walked),Ba=S.useRef(ko);it([ko],()=>{if(ko===Ba.current||(Ba.current=ko,xs!==!!s))return;const z=requestAnimationFrame(()=>{const Me=document.activeElement;(!Me||Me===document.body||Me.closest(".rail"))&&vs()});return()=>cancelAnimationFrame(z)});const Gs=eT({results:Nn,keyOf:z=>z.kind==="cmd"?`c:${z.c.name}`:z.kind==="changes"?"changes":z.kind==="worktree"?`w:${z.id}`:`f:${z.path}`,q:(ve==null?void 0:ve.query)??"",listRef:Ee,tabPicks:!0,onPick:z=>{if(!ve)return;const{text:Me,caret:pt}=DU(x,ve,NK(z));le(Me),ce(ve.from),requestAnimationFrame(()=>{const $t=Ar.current;$t&&($t.focus(),$t.setSelectionRange(pt,pt),F(pt))})}}),Ir=g||v?mH(x):null,Ua=S.useMemo(()=>fE(ge,lt),[ge,lt]),Ha=dK(x,Ua),od=Ir===""&&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,Rr=Ha??od,ss=(e==null?void 0:e.worktree.title)??"untitled",is=(bd=ln==null?void 0:ln.recap)==null?void 0:bd.text,Es=()=>{g&&$i(h,u,{t:"land",worktreeId:g})},sd=z=>{g&&(h==null||h.send({t:"judge",worktreeId:g,...z?{note:z}:{}}))},ac=!!((xd=Ne==null?void 0:Ne.config.check)!=null&&xd.trim()),Ui=py(Ht,nn,xt),Hi=wt&&!Pt&&!Je&&ma(e.worktree)&&!on&&!vr&&kt>0&&(!Ht||!!Ht.stale||Ui==="unanswered"),Wi="Archive this worktree when you are done here; the rail's archived section brings it back with its chat.",id=Ln?"update":fw(X,(e==null?void 0:e.worktree)??{}),ad=Ne?Oh(Ne):"main",Cp=Ln&&hn?`Commit, take ${ad} in and push the branch; PR #${hn.number} takes the new commits.`:`${Xf(X,Ne==null?void 0:Ne.defaultBranch)}.`,ld=wn&&!is?{links:G5(wn)}:{},xr=g?dn?{word:"archive",kind:"archive",line:(Cn==null?void 0:Cn.state)==="merged"?Rs(Cn):`landed on ${(Ne==null?void 0:Ne.defaultBranch)??"main"}.`,tip:Wi,run:()=>Fl(h,u,[g])}:(wn==null?void 0:wn.state)==="open"&&!Ln?ST(wn)?{word:"land",kind:"merge",line:_f(is??Rs(wn)),tip:`${Rs(wn)} ${ET(wn)}.`,...ld,run:Es,ships:!0}:{word:"view",kind:"view",line:_f(is??Rs(wn)),tip:`${Rs(wn)} Open the PR on GitHub.`,...ld,run:()=>window.open(wn.url,"_blank")}:(wn==null?void 0:wn.state)==="closed"?{word:"archive",kind:"archive",line:Rs(wn),tip:`${Rs(wn)} ${Wi}`,run:()=>Fl(h,u,[g])}:Hi?{word:"check",kind:"check",line:(Ht==null?void 0:Ht.subject)??_f(is??J5(kt)),tip:_T(Ht,ac,Ui),run:sd}:xe!=null&&xe.ready&&!Sf(xe,nn,xt,qe==null?void 0:qe.name)?{word:id,kind:"ship",line:xe.subject??_f(is??(Mx(xe,kt)||"ready")),tip:[Mx(xe,kt),Q5(ad,e==null?void 0:e.behind),Cp,xe.subject&&nn>0?"Tab from the word edits the message first.":""].filter(Boolean).join(" "),run:Es,ships:!0}:null:null,cd=(Ss=e==null?void 0:e.worktree.lands)==null?void 0:Ss.at(-1),ud=cd&&dy(cd),Wa=S.useMemo(()=>{const z=O?AN(O):null;return(z?f6(z):[]).filter(Me=>{const pt=Re.find($t=>$t.worktree.id===Me.id);return!!pt&&!pt.worktree.landed})},[O,Re]),Ap=Wa.length>0?d.jsxs(d.Fragment,{children:["After"," ",Wa.map((z,Me)=>d.jsxs(S.Fragment,{children:[Me>0&&(Me===Wa.length-1?" and ":", "),d.jsx(fo,{id:z.id,title:z.title})]},z.id))," ",Wa.length===1?"lands":"land","."]}):null,lc=((xr==null?void 0:xr.kind)==="ship"||(xr==null?void 0:xr.kind)==="check")&&xe?Ap??eF(xe,Ui):(xr==null?void 0:xr.word)==="archive"&&ud?eo(ud):null,Ka=S.useRef(null);Pt!=="land"&&(Ka.current=g&&(xr!=null&&xr.ships)?{id:g,verb:xr,under:lc}:null);const qa=Pt==="land"&&cr&&((tl=Ka.current)==null?void 0:tl.id)===g?Ka.current:null,Bn=qa?qa.verb:xr,dd=(ti=Bn==null?void 0:Bn.links)!=null&&ti.length?V5(Bn.line,Bn.links):null,Za=!!(Bn!=null&&Bn.ships)&&Pt==="land",Ki=Gw(bn,Vw),Ga=$u(e,"commit"),Va=$u(e,"check"),Vs=TT(Za?Ga:Va),cc=ji(gy(Vs)?Vs==null?void 0:Vs.since:void 0),uc=xe?xe.check==="pending"&&Va&&Vs===Va?fh("Checking the work",Va,cc):Sf(xe,nn,xt,qe==null?void 0:qe.name):null,dc=Bn&&Za?Ki?`${Bn.word}: ${Ki}`:`${Bn.word} ${Bn.line}`:null,fd=dc&&Ga&&Vs===Ga?fh(dc,Ga,cc):dc,hd=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?"":uc||(wn?Rs(wn):rn?my(rn):s?`describe ${ss}…`:Je?"describe a change":c?`message agent on ${ss}`:`message agent on ${ss}; / for a command, ! for a shell command`):"no worktree selected",Ya=x!==""||Rr||!e?null:Za?Ki?null:qa?qa.under:lc:Bn?lc:wn||uc?is??(xe==null?void 0:xe.subject)??null:null,pd=S.useRef(!1);S.useEffect(()=>{const z=Fn&&!pd.current;pd.current=Fn,z&&((ve==null?void 0:ve.kind)==="file"&&g?sp(g,f.getState(),{sock:h,dispatch:u}):(ve==null?void 0:ve.kind)==="command"&&dt&&lt.length===0&&(h==null||h.send({t:"list-commands",worktreeId:dt})))},[Fn,ve==null?void 0:ve.kind,lt.length,g,dt,h,f,u]);const Xa=()=>{if(!e)return;const z=[],Me=de;if(Me.url)try{const Zn=new URL(Me.url);z.push(`current route: ${Zn.pathname}${Zn.search}`)}catch{}Me.title&&z.push(`page title: ${Me.title}`);const pt=[];s&&pt.push(rW(e.worktree.title,Ne==null?void 0:Ne.configFile)),z.length>0&&pt.push(`What the user is looking at right now:
261
- ${z.join(`
262
- `)}`);const $t=kH(O);return $t&&pt.push($t),pt.length>0?pt:void 0},Ys=z=>{Je?jt(z):g&&z!==Ft&&(h==null||h.send({t:"set-worktree-mode",worktreeId:g,mode:z}))},mr=z=>w&&u({a:"notice",id:w,text:z}),qi=cN(),md=(z,Me="")=>{if(!e||!g)return;if(z==="handoff"){if(Je)return mr("a new worktree has nothing to continue yet");const $t=uK(Me,Ce,e.worktree.repoId);"pick"in $t?u({a:"open",overlay:{kind:"handoff",worktreeId:g}}):h==null||h.send({t:"handoff-ask",worktreeId:g,repoId:$t.repo.id,...$t.text?{text:$t.text}:{}});return}if(z==="archive"){on||vr?Fl(h,u,[g]):mr("archive is for a landed worktree; this one has not landed");return}if(z==="check"){Je||!ma(e.worktree)?mr("nothing to check from here"):kn?mr("wait for the turn to end"):kt===0?mr("nothing to check: no changes here"):sd(Me||void 0);return}const pt=Ht?Sf(Ht,nn,xt,qe==null?void 0:qe.name):null;Je||!ma(e.worktree)?mr("nothing to land from here"):on?mr(`already landed on ${(Ne==null?void 0:Ne.defaultBranch)??"main"}`):pt?mr(pt):kn&&(!Ht||Ht.stale)?mr("wait for the turn to end"):Ht!=null&&Ht.stale?mr("the work changed since this was checked; check again first"):Es()},Zi=_.some(Ii),fc=()=>{var z;K&&((z=Ar.current)==null||z.blur())},Xs=()=>{w&&(h==null||h.send({t:"set-draft",boxId:w,text:x,clientId:be})),fc()},Co=(z,Me,pt,$t)=>{u({a:"hold-send",id:z,log:Me,text:pt,frame:$t}),fc()},hc=()=>{if(!w)return;const z=fK(x,ge),Me=z&&lK(z.name)?z.name:void 0;if(o){if(o.busy)return;if(qi)return mr(gE);if(o.why)return mr(o.why);(_t!==Ie||!Be)&&(h==null||h.send({t:"set-default-agent",agent:_t})),Xs(),o.create();return}if(cr)return;if(qi&&!(Me&&!(z!=null&&z.args)))return mr(gE);const pt=Ir===null&&(!z||!!Me&&!!z.args);if(un&&un.kind!=="unready"&&qe&&pt){mr(un.kind==="installing"?`${qe.name} is still installing`:un.retry?`nothing runs here until ${qe.name} is installed`:un.text);return}const $t=F1(x.trim(),En),Zn=()=>({text:$t,attachments:_.length?_.map(Dl):void 0});if(n){if(!n.restorable)return;if(Ir!==null){mr("nothing runs here until it is restored");return}const wo={t:"restore-worktree",archiveId:n.id,clientId:be};if(Zi)return Co(w,w,$t,wo);Xs(),h==null||h.send(nu(wo,w,$t,_)),u({a:"sending",id:w,message:Zn()}),u({a:"sent-box",id:w});return}if(r){if(r.locked)return;if(Ir!==null){mr("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:be};if(Zi)return Co(w,w,$t,wo);Xs(),h==null||h.send(nu(wo,w,$t,_)),u({a:"sending",id:w,message:Zn()}),u({a:"sent-box",id:w});return}if(!e||!g)return;if(Ir!==null){if(Ir&&Pt&&!m){mr(`${KI(Pt)} is running here; run the command once it is done`);return}Ir&&m?u({a:"term-run",id:g,command:Ir}):Ir&&(h==null||h.send({t:"exec",worktreeId:g,command:Ir})),le("");return}if(z&&!Me){md(z.name,z.args),le("");return}if(Me&&!(z!=null&&z.args)){Ys(Me),le("");return}const rr=z?F1(z.args,En):$t,ni=Xa(),Ec=_.length?_.map(Dl):void 0;if(Me&&Ys(Me),Je){const wo=Bu(e.worktree)?{worktreeId:g}:{},Ed={clientId:be,repoId:e.worktree.repoId,context:ni,agent:_t,...t!=null&&t.profile?{profile:t.profile}:{},...Me?{mode:Me}:{},...t!=null&&t.carry?{carry:!0}:{}};(_t!==Ie||!Be)&&(h==null||h.send({t:"set-default-agent",agent:_t}));const Sc={t:"create-worktree",...Ed,...wo};Zi?Co(w,w,rr,Sc):(Xs(),h==null||h.send(nu(Sc,w,rr,_)),u({a:"sending",id:w,message:{text:rr,attachments:Ec}}),u({a:"sent-box",id:w}))}else{const wo={t:"chat",worktreeId:g,clientId:be,context:ni};Zi?Co(w,g,rr,wo):(Xs(),h==null||h.send(nu(wo,w,rr,_)),Dr||u({a:"sending",id:g,message:{text:rr,attachments:Ec}}),u({a:"sent-box",id:w}))}s&&u({a:"show-chat"})},Ip=z=>{if(!g||(Y==null?void 0:Y.ask.kind)!=="question")return;if(!z.some(xa))return u({a:"ask-revive",id:g});const Me=$w(Y.ask.questions,z).join(`
263
- `),pt={t:"chat",worktreeId:g,clientId:be,context:Xa()};if(H&&$.some(Ii))Co(H,g,Me,pt);else{const $t=$.length?$.map(Dl):void 0,Zn=$t&&H?{attachments:$t,boxId:H}:{};h==null||h.send({...pt,text:Me,...Zn}),$t&&H&&u({a:"clear-attachments",id:H}),u({a:"sending",id:g,message:{text:Me,attachments:$t}})}u({a:"answered",id:g}),u({a:"ask-revive",id:g})},pc=L(z=>z.autoSend);it([pc,g],()=>{!pc||pc!==g||cr||xs!==!!s||(u({a:"auto-sent"}),hc())});const gd=()=>{const z=_[_.length-1];return!w||!z?!1:(u({a:"detach",id:w,key:z.key}),!0)},mc=z=>{w&&(u({a:"walk",id:w,walk:z.walk,text:z.text}),requestAnimationFrame(()=>{var Me;(Me=Ar.current)==null||Me.setSelectionRange(z.text.length,z.text.length),F(z.text.length)}))},Qs=()=>{w&&C&&u({a:"walk",id:w,walk:null,text:x})},Js=Je?[]:S_(O),kd=Je?[]:A.flatMap(z=>z.attachments??[]),Vr=e==null?void 0:e.worktree.plan,Rp=Wy(e==null?void 0:e.worktree.id,Vr),as=((nl=e==null?void 0:e.worktree.from)==null?void 0:nl.kind)==="worktree"?e.worktree.from:null,ei=as?O.find(z=>z.kind==="handed"&&z.via==="plan"):void 0,gc=(ei==null?void 0:ei.kind)==="handed"?ei.origin.title:as==null?void 0:as.ref,Gi=hn&&((xc=e==null?void 0:e.worktree.prComments)==null?void 0:xc.pr)===hn.number?e.worktree.prComments:void 0,Qa=Gi&&Gi.count>0?R$(Gi.count,Gi.authors):null,Ja=(e==null?void 0:e.worktree.queued)??[],wd=lr&&!se,Op=L(z=>z.reading),[kc,yd]=S.useState(!1),vd=c&&!Z&&(se?!kc:cr&&!je),to=vd&&Op;S.useEffect(()=>{if(c)return u({a:"typing",on:kc}),()=>u({a:"typing",on:!1})},[c,kc,u]);const Vi=z=>{if(!to||z.target instanceof Element&&z.target.closest("button, a, [role=button]"))return;const Me=z.currentTarget.closest(".chat-log");Me&&(Me.scrollTop=Me.scrollHeight)};return d.jsxs("div",{ref:ir,className:Ke("composer chat-input",wd&&"stopping",vd&&"foldable",to&&"lean"),onClick:Vi,onFocus:z=>yd(z.target instanceof HTMLTextAreaElement),onBlur:()=>yd(!1),children:[(Vr||as)&&e&&d.jsxs("div",{className:"composer-plan",...Vr?Fe.contextMenu(()=>Sy(Vr,()=>h==null?void 0:h.send({t:"reveal",worktreeId:e.worktree.id,path:Vr}),mo(h))):{},children:[d.jsx(mt,{name:Vr?"text":"handoff",className:"icon-inline"}),Vr&&d.jsx(Pe,{variant:"inline",className:"composer-plan-path","data-tip":Vr,onClick:()=>Dn({dispatch:u},{worktreeId:e.worktree.id,path:Vr,view:"preview"}),children:Rp}),as&&d.jsxs("span",{className:"composer-plan-from",children:[Vr?" from ":"from ",d.jsx(fo,{id:as.origin.id,title:gc})]})]}),hn&&Qa&&e&&d.jsxs("div",{className:"composer-plan",children:[d.jsx(mt,{name:"pr",className:"icon-inline"}),d.jsx(Pe,{variant:"inline",tone:"strong","data-tip":"Read them beside the chat",onClick:()=>B3({dispatch:u},e.worktree.id,hn.number),children:Qa.count}),d.jsxs("span",{className:"row-dim",children:["on PR #",hn.number,Qa.rest,hn.review==="changes_requested"?", changes requested":hn.review==="approved"?", approved":""]})]}),Z&&g&&d.jsx(Ms,{icon:"chat",verb:"answer",tip:"Bring the question back into the box",onPress:()=>{u(Z.kind==="ask"&&Z.outcome?{a:"ask-revive",id:g,askId:Z.id}:{a:"card-unpark",id:g}),u({a:"focus-chat"})},children:p6(Z)}),(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:()=>h==null?void 0:h.send({t:"fix",worktreeId:g,toolId:ue.toolId}),onDismiss:()=>dE(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:()=>h==null?void 0:h.send({t:"continue",worktreeId:g}),onDismiss:()=>dE(ue.key),children:ue.after==="stop"?"where it stopped":ue.again?"after the same error again":"after the error"}),je&&w&&!se&&(e||N||o)&&d.jsx(Ms,{icon:"copy",verb:"attach",tip:"Attach it, as a paste would",onPress:()=>{$6(f,w,je),vs()},onDismiss:hN,children:je.kind==="image"?"the image you copied":`the text you copied, ${je.text.split(`
264
- `).length} lines`}),re&&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:()=>{nE(),_e==null||_e.prompt()},onDismiss:nE,children:"Toyon as a window of its own, with a Dock icon and no browser bar"}),te&&g&&!m&&!se&&!re&&op(mo(h))&&ZH({offer:te,agent:e==null?void 0:e.agent,chat:O})&&d.jsx(QW,{offer:te,onInstall:()=>h==null?void 0:h.send({t:"install-global"}),onDismiss:()=>h==null?void 0:h.send({t:"dismiss-global-install"})}),w&&!se&&Ir===null&&d.jsx(fp,{children:uw(_,lu(Hg(Js),kd)).map(([z,Me])=>{const pt=()=>u({a:"detach",id:w,key:z.key});return z.kind!=="pick"?d.jsx(X$,{item:z,n:Me,onRemove:pt},z.key):d.jsx(Np,{pick:z,tipText:z.html,onHover:$t=>ne&&cn.post(ne,$t?{type:"highlight-selector",selector:z.selector,label:Lw(z)}:{type:"highlight-clear"}),worktreeId:g,onOpen:($t,Zn)=>g&&Ea(f,h,g,$t,Zn),onRemove:pt},z.key)})}),Fn&&ve&&d.jsx(tW,{results:Nn,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:Gs,listRef:Ee,empty:_K(ve.kind,Rt,lt.length,dt!==null),note:Xn>0?`type to find ${Xn} more`:void 0,groupOf:z=>z.kind==="worktree"?"worktrees":z.kind==="cmd"?"commands":"files",row:z=>{const Me=((Ct==null?void 0:Ct.files.length)??0)>0;return z.kind==="file"?qk(z.path,z.status,ve.query,{gutter:Me}):z.kind==="folder"?qk(z.path,void 0,ve.query,{folder:!0,gutter:Me}):z.kind==="changes"?d.jsx(Mn,{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(Mn,{label:z.title,hint:fr(z.at)})]}):d.jsx(wW,{c:z.c,query:ve.query})}}),se&&g?se.kind==="handoff"?d.jsx(rK,{item:se,worktreeId:g,rootRef:q},se.id):se.ask.kind==="question"?d.jsx(gK,{item:se,ask:se.ask,worktreeId:g,rootRef:q,numbers:lu(Hg(Js),kd),onAnswer:Y?Ip:void 0},se.id):d.jsx(mK,{item:se,ask:se.ask,worktreeId:g,rootRef:q},se.id):d.jsxs("div",{className:Ke("composer-field",Ir!==null&&"shell",C&&"recalled"),children:[d.jsx(ju,{size:"lg",bare:!0,font:Ir!==null?"mono":"ui",ref:Ar,value:x,onChange:z=>{var rr;const Me=z.target.value,pt=z.target.selectionStart??Me.length;le(Me),F(pt),Gs.setIndex(0);const{inputType:$t}=z.nativeEvent;ce($t==="insertFromPaste"||$t==="insertFromDrop"?((rr=Tg(Me,pt))==null?void 0:rr.from)??null:null)},onKeyUp:z=>{qs(),F(z.currentTarget.selectionStart??0)},onClick:z=>{F(z.currentTarget.selectionStart??0),Qs()},onPaste:Fi,onDrop:z=>{const Me=hT(f,z);if(!Me)return;z.stopPropagation();const pt=z.currentTarget,$t=U5(pt,z.clientX,z.clientY)??x.length;sc(pt,$t,$t,Me.words)},onScroll:z=>{Ks.current&&(Ks.current.scrollTop=z.currentTarget.scrollTop)},onKeyDown:z=>{var Me;if(Bi(z),!z.nativeEvent.isComposing){if(Fn){if(z.key==="Escape"){z.preventDefault(),z.stopPropagation(),ce((ve==null?void 0:ve.from)??null);return}if(Gs.onKeyDown(z))return}if((z.key==="ArrowUp"||z.key==="ArrowDown")&&!z.altKey&&!z.ctrlKey){const pt=z.key==="ArrowUp",$t=A.at(-1);if(pt&&!z.metaKey&&!C&&x===""&&g&&!m&&$t!==void 0){z.preventDefault(),NN(f,h,g,A.length-1);return}const Zn=z.metaKey?pt?"first":"box":pt?"up":"down",rr=g?PH(O,C??null,x,Zn):null;if(rr){z.preventDefault(),(rr.walk!==C||rr.text!==x)&&mc(rr);return}}if(C&&z.key==="Escape"){z.preventDefault(),z.stopPropagation(),mc({walk:null,text:C.from});return}if(z.key==="Escape"&&kn&&g&&!m){z.preventDefault(),z.stopPropagation(),h==null||h.send({t:"stop-agent",worktreeId:g});return}if(C&&bK.has(z.key)&&Qs(),z.key==="Tab"&&!z.shiftKey&&x===""){const pt=(Me=z.currentTarget.closest(".composer"))==null?void 0:Me.querySelector(".composer-verb");if(pt&&!pt.disabled){z.preventDefault(),pt.focus();return}if(Ge){z.preventDefault(),u({a:"edit-commit"});return}}z.key==="Enter"&&(K?z.metaKey||z.ctrlKey:!z.shiftKey)?(z.preventDefault(),hc()):z.key==="Backspace"&&x===""&&gd()&&z.preventDefault()}},placeholder:Ya||Bn?"":hd,disabled:o?o.busy:!e&&!N}),Rr&&d.jsxs("div",{className:"composer-ghost","aria-hidden":"true",children:[d.jsx("span",{className:"picker-typed",children:x}),Rr]}),g&&Ir===null&&x.includes("@")&&d.jsx("div",{ref:Ks,className:"composer-ghost composer-marks","aria-hidden":"true",onClick:z=>Mu(z,e==null?void 0:e.worktree.path,g,{sock:h,dispatch:u}),children:d.jsx(Ou,{text:x,worktreeId:g,root:e==null?void 0:e.worktree.path,inField:!0})}),(Ya||Bn)&&d.jsxs("div",{className:"composer-ghost composer-standing","aria-hidden":Bn?void 0:"true",children:[d.jsx("span",{className:Ke("composer-placeholder",Za&&"live-text"),children:fd||(Bn?d.jsxs(d.Fragment,{children:[d.jsx(Pe,{variant:"inline",tone:"strong",className:"composer-verb",disabled:!!Bn.ships&&!!Pt||qi,...Lt(Bn.tip,void 0,{placement:"top"}),onClick:()=>{var z;Bn.run(),K||(z=Ar.current)==null||z.focus()},onKeyDown:z=>{z.key==="Tab"&&!z.shiftKey&&Ge&&(z.preventDefault(),u({a:"edit-commit"}))},children:Bn.word})," ",d.jsx("span",{className:"composer-verb-line",children:dd?dd.map(z=>typeof z=="string"?z:d.jsxs(Pe,{variant:"inline",className:"composer-verb-tail",...Lt(z.tip,void 0,{placement:"top"}),onClick:()=>{var Me;window.open(z.url,"_blank"),K||(Me=Ar.current)==null||Me.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(mt,{name:"external",className:"icon-inline"})]},z.text)):Bn.line})]}):hd)}),Ya&&d.jsxs(d.Fragment,{children:[`
265
- `,d.jsx("span",{className:"composer-subline",children:Ya})]})]}),wd&&d.jsx(It,{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${A.length?"; queued messages go next":""})`,hint:"esc",onClick:()=>g&&(h==null?void 0:h.send({t:"stop-agent",worktreeId:g}))})]}),j&&d.jsx("div",{className:"hint composer-notice",role:"status",children:j}),!se&&d.jsxs("div",{className:"hint composer-knobs",children:[d.jsxs("span",{className:"spawn-left",children:[Yt?Jt.length>1?d.jsx(pW,{agents:Jt,agent:_t,model:Xt,onChange:Rn,onClose:bs}):d.jsx(iE,{models:ht,value:Xt,runs:nt,onChange:gt,onClose:bs}):e&&d.jsx(iE,{models:ht,value:e.worktree.model??"",current:J,runs:nt,onChange:z=>h==null?void 0:h.send({t:"set-worktree-model",worktreeId:e.worktree.id,model:z}),onClose:bs}),Yt?d.jsx(oE,{efforts:De,value:Nt,runs:at,onChange:nr,onClose:bs}):e&&d.jsx(oE,{efforts:De,value:e.worktree.effort??"",current:ye,runs:at,onChange:z=>h==null?void 0:h.send({t:"set-worktree-effort",worktreeId:e.worktree.id,effort:z}),onClose:bs}),Je?!o&&d.jsx(sE,{value:rt,onChange:jt,onClose:bs}):e&&d.jsx(sE,{value:Ft,onChange:z=>h==null?void 0:h.send({t:"set-worktree-mode",worktreeId:e.worktree.id,mode:z}),onClose:bs}),zr&&d.jsxs("span",{className:"usage-knob",onMouseEnter:()=>{br||(window.clearTimeout(yt.current),yt.current=window.setTimeout(()=>Vt(!0),xK))},onMouseLeave:()=>{window.clearTimeout(yt.current),Vt(!1)},onFocus:z=>{br||!z.target.matches(":focus-visible")||(window.clearTimeout(yt.current),Vt(!0))},onBlur:An,children:[d.jsx(It,{icon:d.jsx(nW,{fraction:_n?_n.used/_n.size:0,level:pn?CF(pn,qn):void 0}),tone:"chrome",on:br,silent:!0,label:_n?`${Math.round(100*_n.used/_n.size)}% of context`:pn?qx(pn,qn):"",detail:[..._n&&pn?[qx(pn,qn)]:[],...Mt?[Mt]:[]],...Fe.dropdown(Cr,"left","usage",ys),...Fe.contextMenu(Cr,"usage")}),os&&d.jsx(yK,{usage:_n,limits:pn,auth:qe==null?void 0:qe.auth,now:qn,onClose:An})]})]}),d.jsxs("span",{className:"spawn-tools",children:[w&&(e||N||o)&&d.jsx(It,{icon:"attach",tone:"chrome",label:c?"Attach a picture or a file":"Attach a picture or a file, or drop one here",onClick:()=>FN(f,w)}),!s&&!v&&!c&&!o&&d.jsx(It,{icon:"terminal",tone:"chrome",on:oe,className:"composer-term",disabled:!e,label:$e?$e.tip:"Terminal",hint:Dt("terminal"),badge:$e&&d.jsx("span",{className:"composer-term-dot"}),onClick:()=>{u($e&&!oe&&g?{a:"term-stream",id:g,stream:$e.stream}:{a:"toggle-terminal"})},...Fe.contextMenu(()=>e&&g?r8(e.procs,g,oe,{sock:h,dispatch:f.dispatch}):[])}),!s&&!pe&&!v&&!c&&!o&&d.jsx(It,{icon:"pick",label:"Pick an element on the page to attach",hint:Dt("pick"),on:P==="chat",disabled:!ne,onClick:()=>ne&&Nu(ne,P,u,"chat")}),K&&w&&(e||N||o)&&d.jsx(It,{icon:"send",tone:"primary",label:o?"Create the project":"Send",disabled:qi||(o?o.busy:cr),onMouseDown:z=>z.preventDefault(),onClick:hc})]})]}),(un||Te&&fn||Ja.length>0)&&d.jsxs("div",{className:"composer-notes",children:[Ja.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(fo,{id:z.after.id}):SK(z,z.after.piece,Ja)," ","lands"]})},`${z.proposalId}/${z.pieceId}`)),un&&qe&&d.jsxs("div",{className:"hint composer-note",role:"status",children:[d.jsx("span",{children:un.text}),(un.retry||vn)&&d.jsxs("span",{className:"composer-note-actions",children:[un.retry&&d.jsx(Pe,{variant:"outline",onClick:()=>h==null?void 0:h.send(N$(qe)),children:un.retry}),vn&&d.jsxs(Pe,{variant:"outline","data-tip":`${vn.name} is installed and takes this message instead`,onClick:()=>Kn(vn.id),children:["use ",vn.name]})]})]}),Te&&fn&&d.jsxs("div",{className:"hint composer-note",children:[d.jsx("span",{children:Te}),x4(fn)&&d.jsx(Pe,{variant:"outline",busy:ie==="pull-main",disabled:!!ie,"data-tip":"Fast-forward main to origin",onClick:()=>$i(h,u,{t:"pull-main",worktreeId:fn.id}),children:"pull"})]})]})]})}function sC({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 TK(e){var r;const t=up(e);if(t.length===0)return;const n=(r=e==null?void 0:e.picks)==null?void 0:r.profile;return n&&t.includes(n)?n:e==null?void 0:e.config.defaultProfile}function jK({repo:e,value:t,onChange:n,onClose:r}){const o=up(e);if(o.length===0||!t)return null;const s=(e==null?void 0:e.config.profiles)??{},a=(e==null?void 0:e.configFile)??"the settings",c=u=>{var m;const h=((m=s[u])==null?void 0:m.run)??[],f=h.length>0?`runs ${h.join(", ")}`:"runs nothing";return u===(e==null?void 0:e.config.defaultProfile)?`${f}; the default in ${a}`:f};return d.jsx(_i,{value:t,options:o.map(u=>({id:u,description:c(u)})),onChange:n,onClose:r,hint:o.length>1?`${t}: ${c(t)}. Click to change`:`the only profile in ${a}`,placeholder:"the profile the worktree runs"})}function $K({draft:e,lead:t}){const n=ut(),r=Qe(),o=L(h=>Pi(h,t==null?void 0:t.repoId)),s=e.profile??TK(o),a=h=>{n({a:"draft-profile",profile:h}),o&&(r==null||r.send({t:"set-repo-pick",repoId:o.id,field:"profile",value:h}))},c=L(h=>{var f;return((f=ql(h,t==null?void 0:t.repoId))==null?void 0:f.dirty)??0}),u=!!t&&!!o&&c>0;return!s&&!u?null:d.jsxs("div",{className:"draft-intro",children:[s&&d.jsx("div",{className:"draft-row hint",children:d.jsx(jK,{repo:o,value:s,onChange:a})}),u&&d.jsx("div",{className:"draft-notes",children:d.jsxs(sC,{className:"hint draft-note",checked:!!e.carry,tip:`Move the ${c} uncommitted ${c===1?"file":"files"} into the new worktree, leaving ${o.defaultBranch} clean`,onChange:h=>n({a:"draft-carry",v:h.currentTarget.checked}),children:[d.jsxs("span",{className:"badge-dirty",children:["~",c]})," on ",o.defaultBranch," come along"]})})]})}function CK({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(Tr,{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(Pe,{variant:"inline",tone:"strong",onClick:()=>t==null?void 0:t.send({t:"adopt-worktree",worktreeId:e.id,clientId:n}),children:"take over"})]})}function mu({placement:e,className:t,width:n,archived:r,found:o}){const s=ut(),a=Us(),c=m3(),u=At(a==null?void 0:a.worktree.id,"sending"),h=nc(),f=e==="centre"&&!r&&(h!=null&&h.assumed)?h:null,m=L(v=>{var N;return((N=v.dragFiles)==null?void 0:N.at)==="chat"}),g=zn(),y=S.useMemo(()=>({onDragOver:v=>B5(g,v),onDrop:v=>{const N=hT(g,v);N&&$N(g,N.boxId,N.words)}}),[g]),w=d.jsxs(d.Fragment,{children:[!r&&!o&&c&&!u&&d.jsx($K,{draft:c,lead:a}),r?d.jsx(pu,{active:null,archived:r,placement:e}):o?d.jsx(pu,{active:null,found:o,placement:e}):d.jsx(pu,{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 N;v?du.el=v:(N=du.el)!=null&&N.isConnected||(du.el=null)},children:r?d.jsx(Ag,{active:null,archived:r,tail:d.jsx(LF,{item:r}),foot:w}):o?d.jsx(Ag,{active:null,found:o,tail:d.jsx(CK,{row:o}),foot:w}):d.jsx(Ag,{active:a,lead:f&&d.jsxs("p",{className:"hint chat-centre-note",children:[f.name," has ",d.jsx("code",{children:f.assumed})," and no dev server, so it is chat only for now."," ",d.jsx(Pe,{variant:"inline",onClick:()=>s({a:"open",overlay:{kind:"setup",repoId:f.id}}),children:"add a dev server"})]}),foot:w})})}const AK="modulepreload",IK=function(e){return"/"+e},yE={},Yk=function(t,n,r){let o=Promise.resolve();if(n&&n.length>0){let a=function(h){return Promise.all(h.map(f=>Promise.resolve(f).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(h=>{if(h=IK(h),h in yE)return;yE[h]=!0;const f=h.endsWith(".css"),m=f?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${h}"]${m}`))return;const g=document.createElement("link");if(g.rel=f?"stylesheet":AK,f||(g.as="script"),g.crossOrigin="",g.href=h,u&&g.setAttribute("nonce",u),document.head.appendChild(g),f)return new Promise((y,w)=>{g.addEventListener("load",y),g.addEventListener("error",()=>w(Error(`Unable to preload CSS for ${h}`)))})}))}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)})},Qy=800;function RK(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 Vo=e=>`${e.worktreeId}
266
- ${e.ref??""}
267
- ${e.since??""}
268
- ${e.path}`;class OK{constructor(t){Tt(this,"files",new Map);Tt(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(Vo(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(Vo(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=Vo(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(Vo(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(Vo(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||Vo(o)!==Vo(r))&&this.closed(Vo(o)),r&&(!o||o.seq!==r.seq)&&this.opened(r),!t.connected&&n.connected)for(const h of this.files.values())h.reread=!0,this.next(h);else r&&o&&o.seq===r.seq&&((c=Zr(t,r.worktreeId).git)==null?void 0:c.version)!==((u=Zr(n,r.worktreeId).git)==null?void 0:u.version)&&this.refresh(Vo(r))}opened(t){const n=Vo(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(Vo(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:h}=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:h}}),!u&&!h&&(a!==null||r.ref)&&this.askBlame(t,a));const f={after:t.buffer?t.buffer.normalize(s):s,version:a};if(!t.base){t.base={text:f.after,version:a};return}const m=((g=t.buffer)==null?void 0:g.text())??t.pending??t.base.text;switch(RK(t.base,m,t.pending,f)){case"same":break;case"adopt":t.base={text:f.after,version:a};break;case"apply":(y=t.buffer)==null||y.replace(f.after),t.base={text:f.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,f);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)},Qy))}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 iC={attach:()=>{},edited:()=>{},saveNow:()=>{}},MK=e=>({timers:{set:(t,n)=>setTimeout(t,n),clear:t=>clearTimeout(t)},win:typeof window>"u"?null:window,send:e}),Xk=new Map;function LK(e){const t=Xk.get(e.seq);return t?(Xk.delete(e.seq),t(e),!0):!1}function PK(e,t,n,r){if(e.kind==="bytes"||e.kind==="text"||e.kind==="pr-comments")return iC;if(e.kind==="grant")return DK(e,t,n,r);const o=e.handle;let s=null,a,c=null,u=Promise.resolve(),h=!1;const f=()=>(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=()=>{h||(h=!0,m(),n(`read-only: the browser would not save ${t}`))},y=async N=>{if(!await f())return g();const x=await o.createWritable();await x.write(N),await x.close()},w=()=>{if(!s||h)return;m();const N=s.text();u=u.then(()=>y(N)).catch(g)},v=()=>{a!==void 0&&w()};return{attach(N){var x,_;if(N){s=N,(x=r.win)==null||x.addEventListener("pagehide",v);return}a!==void 0&&w(),s=null,(_=r.win)==null||_.removeEventListener("pagehide",v)},edited(){!s||h||(f().then(N=>{N||g()}),m(),a=r.timers.set(w,Qy))},saveNow:w}}function DK(e,t,n,r){let o=null,s,a=e.version,c=!1,u=null,h=!1;const f=()=>{s!==void 0&&r.timers.clear(s),s=void 0},m=v=>{h||(h=!0,f(),u=null,n(v))},g=v=>{if(!r.send)return;const N=_o();c=!0,Xk.set(N,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&&!h){const _=u;u=null,g(_)}}),r.send({t:"write-loose",id:e.id,content:v,base:a,seq:N})},y=()=>{if(!o||h)return;f();const v=o.text();v.length>rh||(c?u=v:g(v))},w=()=>{s!==void 0&&y()};return{attach(v){var N,x;if(v){o=v,(N=r.win)==null||N.addEventListener("pagehide",w);return}s!==void 0&&y(),o=null,(x=r.win)==null||x.removeEventListener("pagehide",w)},edited(){!o||h||(f(),s=r.timers.set(y,Qy))},saveNow:y}}function Jy({kind:e,className:t,height:n,resizable:r=!0,onDragStart:o,title:s,tabs:a,actions:c,menu:u,full:h,onToggleFull:f,onClose:m,closeHint:g="esc",children:y}){const w=xn("pane"),v=f&&d.jsxs(Pe,{variant:"outline",tone:"quiet",mono:!0,className:"deep-link",onClick:f,"data-tip":h?"Split view: show the preview above":"Full height: hide the preview",children:[d.jsx(mt,{name:h?"split":"full",className:"icon-inline"})," ",h?"split":"full"]}),N=d.jsxs("span",{className:"pane-shape",children:[v,d.jsx(It,{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,N]})}):d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"pane-title",children:s}),c,N]})}),y]})}function zK({src:e,path:t,full:n,onFull:r}){const o=xn("editor");return d.jsxs(d.Fragment,{children:[d.jsx("button",{type:"button",className:"editor-image",onClick:()=>r(!0),...o.contextMenu(()=>Ca(e,{open:()=>r(!0)})),children:d.jsx("img",{src:e,alt:t})}),n&&d.jsx(Qu,{owner:"editor",onClose:()=>r(!1),menu:()=>Ca(e),children:d.jsx("img",{src:e,alt:t})})]})}function FK({src:e,path:t}){return d.jsx("div",{className:"editor-video",children:d.jsx("video",{src:e,controls:!0,preload:"metadata",title:t})})}const BK={image:zK,video:FK};function UK({kind:e,src:t,path:n,openSeq:r,focus:o,full:s,onFull:a}){const c=S.useRef(null);it([r],()=>{var h;o&&((h=c.current)==null||h.focus())});const u=BK[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 HK(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 WK(e){const t=new Map,n=Array.from(e.querySelectorAll("h1, h2, h3, h4, h5, h6")),r=HK(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}
269
- ${a}`,level:Number(o.tagName[1]),depth:r[s],text:a,el:o}})}const KK=48,qK=16;function ev({html:e,openSeq:t=0,focus:n=!0,onLink:r,onChat:o,lead:s}){const a=S.useRef(null),c=S.useRef(null),[u,h]=S.useState([]),[f,m]=S.useState(-1),[g,y]=S.useState(null),w=_=>{var j;if(y(null),_){const T=window.getSelection();T==null||T.removeAllRanges(),T==null||T.addRange(_)}(j=a.current)==null||j.focus()};it([t],()=>{var _;n&&((_=a.current)==null||_.focus())}),it([e],()=>{h(c.current?WK(c.current):[])}),S.useLayoutEffect(()=>{const _=a.current;if(!_)return;let j=0;const T=()=>{if(j=0,_.scrollTop+_.clientHeight>=_.scrollHeight-1){m(u.length-1);return}const R=_.scrollTop+KK;let C=-1;for(let O=0;O<u.length;O++)u[O].el.offsetTop<=R&&(C=O);m(C)},I=()=>{j||(j=requestAnimationFrame(T))};return T(),_.addEventListener("scroll",I),()=>{_.removeEventListener("scroll",I),j&&cancelAnimationFrame(j)}},[u]);const v=_=>{var T,I;const j=(T=u[_])==null?void 0:T.el;(I=a.current)==null||I.scrollTo({top:Math.max(0,j?j.offsetTop-qK:0),behavior:"smooth"})},N=_=>{const j=_.target.closest("a"),T=j==null?void 0:j.getAttribute("href");!T||(j==null?void 0:j.target)==="_blank"||(_.preventDefault(),r==null||r(T))},x=_=>{var j;if(ky(_)){_.preventDefault(),_.stopPropagation();const T=(c.current&&_k(c.current))??"";y(I=>({seed:T||(I==null?void 0:I.seed)||"",seq:((I==null?void 0:I.seq)??0)+1}));return}if(_.key==="Escape"&&g){_.stopPropagation(),w(null);return}if(UT(_)&&c.current){_.preventDefault(),WT(c.current);return}if(o&&((j=nS(_))==null?void 0:j.id)==="composer"&&c.current){const T=_k(c.current);if(!T)return;_.preventDefault(),_.stopPropagation(),o(T)}};return d.jsxs(d.Fragment,{children:[d.jsxs("div",{ref:a,className:"document",tabIndex:-1,onClick:N,onKeyDown:x,children:[s,d.jsx("div",{ref:c,className:"md md-preview",dangerouslySetInnerHTML:{__html:e}})]}),g&&d.jsx(BT,{root:a,body:c,seed:g.seed,seq:g.seq,onClose:w}),d.jsx(ZK,{heads:u,at:f,onJump:v})]})}function ZK({heads:e,at:t,onJump:n}){const[r,o]=S.useState(!1),s=S.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":hr({current:c===t})},a.id))}),r&&d.jsx(Hs,{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":hr({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 aC({text:e,path:t,worktreeId:n,version:r,openSeq:o,focus:s,onChat:a,lead:c}){Qe();const u=Pr(),h=ut(),f=L8(t),m=td(e,{keepHtml:!0,base:r===void 0?void 0:{worktreeId:n,dir:f,version:r,urls:u}}),g=y=>{const w=ij(f,y);w&&Dn({dispatch:h},{worktreeId:n,path:w,view:Ri(w)})};return d.jsx(ev,{html:m,openSeq:o,focus:s,onLink:g,onChat:a,lead:c})}function GK({refs:e,worktreeId:t}){const n=Pr();return e.length===0?null:d.jsx("div",{className:"editor-piece-chips",children:e.map(r=>r.kind==="image"?d.jsx(_p,{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(xp,{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(bp,{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(Np,{className:"in-chat",pick:r,worktreeId:t},`pick-${r.n}`))})}function VK(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 YK(e,t,n,r){const o=L(s=>s.visible);return S.useMemo(()=>{if(!e)return;const s=[];t!==null&&s.push({id:"plan",label:t});for(const a of LN(e)){const c=c6(e,a),u="worktreeId"in c?o.find(h=>h.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 XK({tabs:e}){const t=S.useRef(null),[n,r]=S.useState({start:!1,end:!1});return it([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,h=u>1,f=u+o.clientWidth<o.scrollWidth-1;r(m=>m.start===h&&m.end===f?m:{start:h,end:f})};s(),o.addEventListener("scroll",s,{passive:!0});const a=new ResizeObserver(s);return a.observe(o),()=>{o.removeEventListener("scroll",s),a.disconnect()}}),it([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(mt,{name:"handoff"})}),d.jsx(Vu,{...e})]})}function QK({item:e,piece:t}){var o,s;const n=Su(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:VK(n)});case"sent":return d.jsxs(d.Fragment,{children:["Sent to ",n.worktreeId?d.jsx(fo,{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(fo,{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(fo,{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(f=>f.id===a.piece):void 0,u=c?Su(e,c):null,h=a&&"id"in a?d.jsx(fo,{id:a.id,title:a.title}):u&&(u.kind==="worktree"||u.kind==="sent")&&u.worktreeId?d.jsx(fo,{id:u.worktreeId,title:u.title??(c==null?void 0:c.title)}):c?c.title:null;return h?d.jsxs(d.Fragment,{children:["This worktree's agent does it, once ",h," lands."]}):d.jsx(d.Fragment,{children:"This worktree's agent does it."})}}}function JK({item:e,piece:t,alone:n,worktreeId:r,path:o,version:s,openSeq:a,focus:c,onChat:u}){const h=Qe(),f=j=>h==null?void 0:h.send(MN(e,r,t.id,j)),m=zi(e,t),g=Zu(e,t),y=Eu(e)?l6(t,e.pieces).filter(j=>j!==m):[],{title:w,rest:v}=S.useMemo(()=>ZS(TP(t)),[t]),N=td(`# ${w}`),x=u6(e,t,n)&&d.jsx("p",{className:"editor-piece-line hint",children:Eu(e)?d.jsxs(d.Fragment,{children:[e.stale&&"The plan changed since these were read. ",i6(t,m,g),y.length>0&&d.jsxs(d.Fragment,{children:[" ","Instead:"," ",y.map((j,T)=>d.jsxs("span",{children:[T>0&&" · ",d.jsx(Pe,{variant:"inline",onClick:()=>f(j),children:j==="send"&&t.to?`send to ${t.to.title}`:s6(t,j)})]},j))]})]}):d.jsx(QK,{item:e,piece:t})}),_=d.jsxs("div",{className:"md md-preview editor-piece-head",children:[d.jsx("div",{dangerouslySetInnerHTML:{__html:N}}),x,d.jsx(GK,{refs:t.attachments,worktreeId:r})]});return d.jsx(aC,{text:v,path:o,worktreeId:r,version:s,openSeq:a,focus:c,onChat:u,lead:_})}function eq(e){return`/${e.replace(/(^|\/)index\.html?$/i,"$1").split("/").map(encodeURIComponent).join("/")}`}const vE=6e4,tq=3e3,nq=e=>e.kind==="worktree"?`w:${e.worktreeId}:${e.path}`:e.kind==="loose"?`g:${e.grantId}`:`t:${e.text}`;function rq({source:e,path:t,version:n,openSeq:r,focus:o}){const s=S.useRef(null);it([r],()=>{var y;o&&((y=s.current)==null||y.focus())});const a=Pr(),[c,u]=S.useState(null),[h,f]=S.useState(null),m=S.useRef(e);m.current=e;const g=nq(e);return S.useEffect(()=>{let y=!1,w;const v=()=>{XD(a,m.current).then(N=>{if(!y){if(N===null){w=setTimeout(v,tq);return}if(typeof N=="string"){f(N),u(null);return}f(null),u(N.url),w=setTimeout(v,Math.max(N.ms-vE,vE))}})};return v(),()=>{y=!0,clearTimeout(w)}},[a,g,n]),d.jsx("div",{ref:s,className:"editor-viewer",tabIndex:-1,children:h!==null?d.jsx("p",{className:"hint",children:h}):c!==null&&d.jsx("iframe",{className:"editor-frame",title:t,sandbox:"allow-scripts",referrerPolicy:"no-referrer",src:c})})}function oq({worktreeId:e,openSeq:t,focus:n}){const r=Qe(),o=L(m=>{var g;return(g=qt(m,e))==null?void 0:g.worktree.pr}),s=L(m=>{var g;return(g=qt(m,e))==null?void 0:g.worktree.prComments}),a=L(m=>Zr(m,e).prComments),c=s==null?void 0:s.version;it([r,e,c],()=>{r==null||r.send({t:"pr-comments",worktreeId:e})});const u=S.useMemo(()=>mW(a??[]),[a]),h=R$((a==null?void 0:a.length)??0,(s==null?void 0:s.authors)??[]),f=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:[h.count,h.rest]}),o&&d.jsxs(d.Fragment,{children:[" · ",d.jsx(Pe,{variant:"inline",tone:"quiet",onClick:()=>window.open(o.url,"_blank"),children:"on GitHub"})]})]}),u.reviews.map(m=>d.jsx(bE,{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(bE,{thread:g,worktreeId:e},g.root.id))]},m.path))]});return d.jsx(ev,{html:"",openSeq:t,focus:n,lead:f})}function bE({thread:e,worktreeId:t}){const n=zn();Qe();const{root:r,replies:o}=e,s=L(u=>u.activeId===t&&Oa(qt(u,t))!==null),a=Zy(r),c=r.review?d.jsx("span",{className:"pr-page-verb","data-review":r.review,children:I$(r.review)}):r.path&&a?d.jsxs(Pe,{variant:"inline","data-tip":"Open the diff at this line",onClick:()=>r.path&&Dn({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(xE,{url:r.url}),s&&d.jsx(Pe,{variant:"outline",tone:"quiet","data-tip":"Put this in the message box for the agent",onClick:()=>Hf(n,{worktreeId:t,text:gW(e),name:kW(e)}),children:"add to chat"})]}),r.body&&d.jsx(EE,{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(xE,{url:u.url})]}),d.jsx(EE,{text:u.body})]},u.id))]})}function xE({url:e}){return d.jsx(Pe,{variant:"inline",tone:"quiet",onClick:()=>window.open(e,"_blank"),children:"GitHub"})}function EE({text:e}){const t=S.useMemo(()=>Sa(e),[e]);return d.jsx("div",{className:"pr-page-body",dangerouslySetInnerHTML:{__html:t}})}const sq=900;function iq(){return hs(tt.editorSplit,!1,e=>e===null?void 0:e==="1")}function aq({split:e,onSplit:t}){return d.jsxs(Pe,{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(mt,{name:e?"split":"columns",className:"icon-inline"})," ",e?"inline":"split"]})}function lq({text:e,path:t,openSeq:n,focus:r,full:o,onFull:s}){const a=S.useRef(null);it([n],()=>{var u;r&&((u=a.current)==null||u.focus())});const c=S.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 cq(){return hs(tt.editorWrap,!1,e=>e===null?void 0:e==="1")}function uq({wrap:e,onWrap:t}){return d.jsxs(Pe,{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(mt,{name:"wrap",className:"icon-inline"})," ",e?"unwrap":"wrap"]})}const dq=S.lazy(async()=>{const[e]=await Promise.all([Yk(()=>import("./Editor-1fCgxkUp.js").then(t=>t.E),__vite__mapDeps([0,1,2])),Yk(()=>import("./grammar-DVeERVO3.js"),[]).then(t=>t.grammarsReady)]);return e});function SE({what:e}){return nN(!0,3e3)?d.jsx("div",{className:"empty",children:d.jsxs("span",{className:"live-text",children:["loading ",e]})}):null}const fq=()=>{},hq=[],pq={diff:"diff",file:"text",preview:"book"};function mq({path:e,note:t,title:n,worktreeId:r}){const o=zn(),s=cp(),a=w_(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?h=>Tu(h,{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 gq(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 lC({editor:e,height:t,full:n=!1,onToggleFull:r,onDragStart:o,placement:s="stack"}){const a=s==="screen",c=ut(),u=zn(),h=Qe(),f=Pr(),m=Zw(),g=ep(),{worktreeId:y,path:w,ref:v,since:N}=e,x=e.loose,_=(x==null?void 0:x.source.kind)==="pr-comments",j=L(De=>{var nt;return((nt=Bo(De))==null?void 0:nt.id)===y}),T=L(De=>{var at,Xt;const nt=(at=qt(De,y))==null?void 0:at.worktree;return nt?nt.path:(Xt=Bo(De))==null?void 0:Xt.path}),I=v!==void 0,R=L(De=>{var nt;return(nt=qt(De,y))==null?void 0:nt.worktree.plan}),C=!x&&!I&&R===w,O=Wy(C?y:void 0,C?w:void 0),A=L(De=>AN(Zr(De,y).chat??hq)),D=S.useMemo(()=>{if(I||x||e.view!=="preview"||!A)return null;const De=A.plan??R;return De&&w===De?A:null},[I,x,e.view,R,w,A]),[B,W]=S.useState(null);it([D==null?void 0:D.id,w],()=>W(null)),it([e.seq],()=>{e.piece&&W(e.piece)});const U=!!D&&!n6(D),Q=D?B!==null&&(B==="plan"?U:D.pieces.some(De=>De.id===B))?B:d6(D,U):"plan",Y=D&&Q!=="plan"?D.pieces.find(De=>De.id===Q)??null:null,se=YK(D,U?"Plan":null,Q,W),H=S.useMemo(()=>x?PK(x.source,w,De=>c({a:"editor-refused",file:{worktreeId:y,path:w},message:De}),MK(h?De=>h.send(De):null)):(m==null?void 0:m.bind({worktreeId:y,path:w,...v?{ref:v}:{},...N?{since:N}:{}}))??iC,[m,y,w,v,N,x,c,h]),$=L(De=>Zr(De,y).changedRanges[w]);S.useEffect(()=>{!$&&!I&&!j&&!x&&(h==null||h.send({t:"changed-ranges",worktreeId:y,path:w}))},[y,w,$,I,j,x,h]);const Z=($==null?void 0:$.offset)??0,q=e.disk,K=e.view??"diff",ne=!!q&&(q.before===""||q.before===q.after),de=_?[]:bN(w,ne).filter(De=>De!==K&&!(x&&De==="diff")),pe=(x==null?void 0:x.source.kind)==="grant"?x.source:null,je=I||j||x&&!pe?null:AD(w),_e=qh(w),[fe,te]=S.useState(!1),re=je==="image"||K==="preview"&&_e==="svg"&&!!q&&!q.binary&&!q.tooLarge,[we,ue]=cq(),le=!!q&&!_&&!je&&!q.binary&&!q.tooLarge&&K!=="preview",be=le&&K==="diff"&&!ne&&!a,[Ce,Ne]=iq(),Ie=S.useRef(null),Be=S.useRef(!1),Je=L(De=>De.layout.chat);it([Je],()=>{Je&&(Be.current=!1)});const zt=S.useCallback(()=>{if(!Be.current)return;Be.current=!1;const De=u.getState();!De.layout.chat&&!No(De)&&c({a:"toggle-chat"})},[u,c]),Yt=De=>{var Xt;if(Ne(De),!De){zt();return}const nt=u.getState(),at=((Xt=Ie.current)==null?void 0:Xt.clientWidth)??Number.POSITIVE_INFINITY;nt.layout.chat&&!No(nt)&&at<sq&&(Be.current=!0,c({a:"toggle-chat"}))};S.useEffect(()=>zt,[zt]);const _t=e.line&&!e.line.fiber?e.line.n:void 0,xt=L(De=>{var nt;return((nt=bu(De))==null?void 0:nt.worktreeId)===y})&&!a&&!I&&!j&&!x&&_e==="html",ht=()=>{cn.post(y,{type:"navigate",path:eq(w)}),n&&(r==null||r())};return d.jsxs(Jy,{kind:"editor",className:Ke("editor-pane",n&&"full"),height:n||a?void 0:t,resizable:!n&&!a,onDragStart:o??fq,title:d.jsx(mq,{path:w,note:I?` at ${v==null?void 0:v.slice(0,7)}`:N?", last turn":void 0,title:C&&O?O:void 0,worktreeId:x?void 0:y}),menu:()=>T&&!x?Ls({id:y,dir:T},w,{discard:!I&&!j,kept:j,ref:v,showing:e.view??void 0,noDiff:ne},{sock:h,dispatch:c}):[],onClose:()=>c({a:"close-editor"}),full:n,onToggleFull:a?void 0:r,actions:d.jsxs(d.Fragment,{children:[!je&&de.length>0&&d.jsx("span",{className:"editor-views",children:de.map(De=>d.jsxs(Pe,{variant:"outline",tone:"quiet",mono:!0,className:"deep-link",onClick:()=>c({a:"editor-view",v:De}),"data-tip":gq(De,K),children:[d.jsx(mt,{name:pq[De],className:"icon-inline"})," ",De]},De))}),re&&d.jsxs(Pe,{variant:"outline",tone:"quiet",mono:!0,className:"deep-link",onClick:()=>te(!0),"data-tip":"Full size: see the picture over the window",children:[d.jsx(mt,{name:"zen",className:"icon-inline"})," full size"]}),be&&d.jsx(aq,{split:Ce,onSplit:Yt}),le&&d.jsx(uq,{wrap:we,onWrap:ue}),xt&&d.jsxs(Pe,{variant:"outline",tone:"quiet",mono:!0,className:"deep-link",onClick:ht,"data-tip":"Run: open the page in the preview, with its scripts on",children:[d.jsx(mt,{name:"run",className:"icon-inline"})," run"]})]}),children:[q&&d.jsx(kq,{editor:e,disk:q,files:m}),se&&d.jsx(XK,{tabs:se}),d.jsx("div",{className:"editor-body",ref:Ie,children:_?d.jsx(oq,{worktreeId:y,openSeq:e.seq,focus:e.focus}):q?je?d.jsx(UK,{kind:je,src:pe?f.loose(pe.id,pe.version):f.worktreeFile(y,w,q.version),path:w,openSeq:e.seq,focus:e.focus,full:fe,onFull:te}):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"}):K==="preview"&&D&&Y?d.jsx(JK,{item:D,piece:Y,alone:!se,worktreeId:y,path:w,version:I||j||x?void 0:q.version,openSeq:e.seq,focus:e.focus,onChat:De=>Hf(u,{worktreeId:y,text:De,name:w})}):K==="preview"&&_e==="svg"?d.jsx(lq,{text:q.after,path:w,openSeq:e.seq,focus:e.focus,full:fe,onFull:te}):K==="preview"&&_e==="html"?d.jsx(rq,{source:pe?{kind:"loose",grantId:pe.id}:I||j||x?{kind:"text",text:q.after}:{kind:"worktree",worktreeId:y,path:w},path:w,version:q.version,openSeq:e.seq,focus:e.focus}):K==="preview"?d.jsx(aC,{text:q.after,path:w,worktreeId:y,version:I||j||x?void 0:q.version,openSeq:e.seq,focus:e.focus,onChat:De=>Hf(u,{worktreeId:y,text:De,name:w})}):d.jsx(uy,{pane:!0,children:d.jsx(S.Suspense,{fallback:d.jsx(SE,{what:K}),children:d.jsx(dq,{file:{worktreeId:y,path:w,...v?{ref:v}:{},...N?{since:N}:{}},disk:q,blame:e.blame,view:K,openSeq:e.seq,line:_t,focus:e.focus,readOnly:I||!q.writable||a,numbers:!a,wrap:we,split:Ce,theme:g,sync:H,onCopy:x?void 0:(De,nt,at)=>T3(at,{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:I||x?void 0:De=>{De==null?cn.post(y,{type:"highlight-clear"}):cn.post(y,{type:"highlight-file",path:w,ranges:[[De+Z,De+Z]]})}},`${y}
270
- ${x?"loose":v??N??""}
271
- ${w}`)})}):d.jsx(SE,{what:w},w)})]})}function kq({editor:e,disk:t,files:n}){var h,f;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(Pe,{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(Pe,{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})}):((h=e.loose)==null?void 0:h.source.kind)==="pr-comments"?null:((f=e.loose)==null?void 0:f.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 cC(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 wq=(e,t)=>{const n=ek(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"}},yq="https://toyon.dev",_h="https://github.com/toyon-dev/toyon",vq=e=>`${_h}/releases/tag/v${e}`,bq=`${_h}/releases/latest`,xq=4e3;function Eq(e,t,n,r){if(r==="asking")return{value:`${e} checking`,text:`Asking ${ek(n)} for the newest version`,act:"check",busy:!0};const o=ek(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(t_(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 Sq(e,t,n,r,o,s=!1,a=null,c=null){if(n){if(n.restarting){const h=n.installed??n.running,f=n.restarting.length>0?iT(n.restarting):"Toyon is restarting; this page reloads when it is back";return{value:`${h} restarting`,text:f,act:"restart",busy:!0}}if(n.installing){const h=n.latest??n.installed??n.running;return{value:`${h} installing`,text:`Installing Toyon ${h}`,act:"update",busy:!0}}if(n.failed){const h=n.failed.line.replace(/\.$/,"");return{value:`${n.running} update failed`,text:`Installing Toyon ${n.failed.version} stopped: ${h}. 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=cC(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?Eq(e,t,a,c):{value:e,text:`Toyon ${e}, ${wq(t,a)}`,act:"check",busy:!1}}function _q(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(vq(e))},{id:"latest-release",label:"latest release",onClick:r(bq)},{id:"site",label:"toyon.dev",onClick:r(yq)},{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 Nq=gI.map(e=>({title:e,rows:yI(e).map(t=>[Dt(t),cu[t].label])}));function Tq(){const e=ut(),t=Qe(),n=xn("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),h=nc(),f=L(g=>g.rows),m=g=>{e({a:"palette-return",v:{mode:"keys",q:""}}),e(g)};return d.jsxs(Lu,{bare:!0,boxClass:"keys-stack",id:"keys-help",onClose:()=>e({a:"close"}),children:[d.jsxs("div",{className:"keys-card",children:[d.jsxs("div",{children:[h&&d.jsxs(d.Fragment,{children:[d.jsx("div",{className:"section-title keys-h",children:h.name}),d.jsxs("div",{className:"keys-setting",children:[d.jsx("span",{className:"keys-d",children:"processes"}),d.jsx(Pe,{variant:"field",mono:!0,className:"keys-chip","data-tip":`edit the install + start commands in ${h.configFile}`,onClick:()=>e({a:"open",overlay:{kind:"setup",repoId:h.id}}),...n.contextMenu(()=>hp(h,h.id,{sock:t,dispatch:e},f)),children:d.jsx("span",{className:"keys-v",children:Object.keys(h.config.run).join(" + ")||"not set up"})})]})]}),d.jsx("div",{className:"section-title keys-h",children:"Agents"}),u.map(g=>d.jsx(Cq,{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(Pe,{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(Pe,{variant:"field",mono:!0,onClick:()=>m({a:"open",overlay:{kind:"theme",slot:"theme"}}),children:Kh(r,o,c).name})]}),d.jsxs("div",{className:"keys-setting",children:[d.jsx("span",{className:"keys-d",children:"chat side"}),d.jsx(Pe,{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(Pe,{variant:"field",mono:!0,onClick:()=>m({a:"open",overlay:{kind:"keep-awake"}}),children:mh[a]})]}),d.jsx(jq,{}),d.jsx($q,{})]})]}),d.jsx("div",{className:"keys-card",children:Nq.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(ts,{k:y}),d.jsx("span",{className:"keys-d",children:w})]},y))]},g.title))})]})}function jq(){const e=Qe(),t=ut(),n=xn("keys"),r=L(j=>j.version),o=L(j=>j.install),s=L(j=>j.registry),a=L(j=>j.update),c=L(j=>j.self),u=L(j=>j.rebuilt),h=L(j=>j.repos),f=L(j=>j.managed.updates),m=L(j=>j.updateCheck),g=L(j=>j.frame),y=L(j=>j.newProject!==null),w=Sq(r,o,a,c,h,u,s,m),v=!f&&(w.act==="update"||w.act==="check"),N=w.settles&&m&&m!=="asking"?m:null;S.useEffect(()=>{if(!N)return;const j=()=>t({a:"update-check-settle",check:N}),T=setTimeout(j,xq);return()=>{clearTimeout(T),j()}},[N,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"}))},_=()=>_q(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(_),children:[d.jsx("span",{className:"keys-d",children:"version"}),d.jsx(Pe,{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 $q(){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: ${fP(e).join(", ")||"nothing turned off"}`;return d.jsx("div",{className:"hint",children:t})}function uC(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 dC(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":jp(e)}function Cq({agent:e}){const t=ut(),n=Qe(),r=xn("keys");return d.jsxs("div",{className:"keys-setting",children:[d.jsx("span",{className:"keys-d",children:e.name}),d.jsx(Pe,{variant:"field",mono:!0,"data-tip":dC(e),...r.contextMenu(()=>Ky(e,{sock:n})),onClick:()=>{t({a:"palette-return",v:{mode:"keys",q:""}}),t({a:"open",overlay:{kind:"agent-page",agent:e.id}})},children:uC(e)})]})}function Aq({agentId:e}){const t=ut(),n=Qe(),r=nc(),o=L(g=>g.home),s=L(g=>g.agents.find(y=>y.id===e)??null),a=L(g=>g.agentConfigs[e]??null),c=xn("keys");if(S.useEffect(()=>{n==null||n.send({t:"agent-config",agent:e,...r?{repoId:r.id}:{}})},[n,e,r]),oC(n,e,s??void 0),!s)return null;const u=Ky(s,{sock:n}),h=()=>t({a:"close",back:!0}),f=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(Lu,{bare:!0,boxClass:"keys-stack",onClose:h,children:d.jsxs("div",{className:"keys-card keys-settings",children:[d.jsx("div",{className:"agent-page-back",children:d.jsx(It,{icon:"back",label:"back to settings",hint:"esc",onClick:h})}),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(Pe,{variant:"field",mono:!0,"data-tip":dC(s),disabled:u.length===0,...c.dropdown(()=>u,"right"),children:uC(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(Iq,{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(Pe,{variant:"field",mono:!0,"data-tip":`reveal ${f(g.path)} in Finder`,onClick:()=>m(g),children:f(g.path)}):d.jsxs("span",{className:"keys-d",children:["not present: ",f(g.path)]})]},g.id))]})]})})}function Iq({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 Rq(){const e=ut(),t=Qe(),n=L(o=>o.agents),r=L(o=>o.defaultAgent);return d.jsx(Gr,{items:n,filter:(o,s)=>o.filter(a=>es(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=>Ky(o,{sock:t}),placeholder:"default agent for new worktrees",row:o=>d.jsx(Mn,{label:o.name,current:o.id===r,hint:o.available?o.checkFailed??(o.sandboxed?void 0:"unsandboxed"):jp(o)})})}const Oq=["dark","light","system","daylight"],Mq=new Intl.DateTimeFormat(void 0,{hour:"numeric",minute:"2-digit"});function Lq(){const e=ut(),t=Qe(),n=L(u=>u.themePrefs),r=L(u=>u.themes),o=qw(),s=L(u=>u.daylight),a=u=>{var h;return((h=r.find(f=>f.id===n[_w({...n,mode:u},o)]))==null?void 0:h.name)??""},c=u=>{if(u==="system")return`${o.system?"dark":"light"} now · ${a(u)}`;if(u!=="daylight")return a(u);const h=s&&s.until>Date.now()?` · ${o.daylight?"light":"dark"} at ${Mq.format(s.until)}`:"";return`${o.daylight?"dark":"light"} now${h} · ${a(u)}`};return d.jsx(Gr,{items:Oq,filter:(u,h)=>u.filter(f=>es(h,ph[f])),rowClass:()=>"picker-row",keyOf:u=>u,initialIndex:u=>u.indexOf(n.mode),onActive:u=>e({a:"preview-theme",theme:u?Kh({...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(Mn,{label:ph[u],current:u===n.mode,hint:c(u)})})}const Pq=2,Qk=e=>XS(e).join(" ").length<Pq,Dq=e=>({kind:"chat",id:e.id,name:e.name,hint:e.branch??"",fields:[e.name,e.branch??""]}),zq=e=>({kind:"chat",id:e.id,name:e.title,hint:MT(e),fields:[e.title,e.branch],prompt:e.prompt,archived:e});function Fq(e,t,n){const r=XS(t),o=n==="all"&&!Qk(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 Bq=e=>e.flatMap(([t,n])=>Array.from({length:n},(r,o)=>t+o));function Uq({repoId:e,scope:t}){const n=ut(),r=Qe(),o=L(T=>T.clientId),s=L(T=>T.frame),a=L(T=>T.chats[e]),c=Xw(),u=L(T=>T.archived[e]),[h,f]=S.useState(t),m=S.useCallback(()=>f(T=>T==="all"?"names":"all"),[]);S.useEffect(()=>{r==null||r.send({t:"list-archived",repoId:e})},[r,e]);const g=S.useMemo(()=>[...c.filter(T=>!jr(T.worktree)).map(Dq),...(u??[]).map(zq)],[c,u]),y=S.useMemo(()=>new Map(g.map(T=>[T.id,T])),[g]),w=S.useMemo(()=>[...g,...((a==null?void 0:a.hits)??[]).map(T=>({kind:"hit",hit:T}))],[g,a]),v=S.useMemo(()=>{const T=new Map;for(const I of(a==null?void 0:a.hits)??[])T.set(I.worktreeId,Math.max(T.get(I.worktreeId)??0,I.ts));return T},[a]),N=S.useCallback((T,I)=>Fq(T,I,h),[h]),x=S.useCallback(T=>{h==="all"&&!Qk(T)&&(r==null||r.send({t:"search-chats",repoId:e,query:T.trim()}))},[r,e,h]),_=T=>!a||a.query!==T.trim(),j=T=>h==="all"&&!Qk(T);return d.jsx(Gr,{items:w,filter:N,onQuery:x,onTab:m,trailing:d.jsx(Pe,{tone:"chrome",on:h==="names","aria-pressed":h==="names",onClick:m,children:"names only"}),keyOf:T=>T.kind==="hit"?`h:${T.hit.worktreeId}:${T.hit.seq}`:`w:${T.id}`,rowClass:T=>T.kind==="hit"?"chats-hit":Ke("picker-row",T.archived&&!T.archived.restorable&&"dim"),rowTitle:T=>{var I;return T.kind==="hit"?T.hit.text:((I=T.archived)==null?void 0:I.prompt)??T.name},groupOf:T=>T.kind==="hit"?`h:${T.hit.worktreeId}`:T.archived?"archived":"open",groupHead:(T,I)=>{if(!T.startsWith("h:"))return`${T} · ${I}`;const R=T.slice(2),C=y.get(R),O=a==null?void 0:a.asks[R],A=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"})]})]}),A>0&&d.jsx("span",{className:"picker-group-tail",children:fr(A)}),O&&d.jsx("span",{className:"picker-group-line",children:dp(O,vT*2)})]})},headAlone:!0,onPick:T=>{const I=T.kind==="hit"?T.hit.worktreeId:T.id,R=T.kind==="hit"?T.hit.archived:!!T.archived;n(R?{a:"open-archived",id:I}:{a:"activate",id:I}),T.kind==="hit"&&n({a:"reveal",id:I,seq:T.hit.seq}),n({a:"close"})},onBack:()=>n({a:"close"}),rowMenu:T=>T.kind==="chat"&&T.archived?Kf(T.archived,{clientId:o,frame:s},{sock:r,dispatch:n}):[],placeholder:h==="names"?"find a chat by name…":"search in chats…",keys:T=>({nav:"moves",tab:h==="names"?"searches messages too":"searches names only",pick:T?T.kind==="hit"?"opens the chat there":"opens its chat":void 0,back:"closes"}),empty:T=>T.trim()?j(T)?_(T)?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:(T,I)=>{const R=I.filter(C=>C.kind==="hit").length;return a!=null&&a.truncated&&!_(T)&&R>0?d.jsxs("div",{className:"empty",children:["showing the first ",R,"; narrow the search"]}):null},row:T=>T.kind==="chat"?d.jsx(Mn,{label:T.name,hint:T.hint}):d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"chats-text",children:Ql(T.hit.text,Bq(T.hit.match),0)}),d.jsxs("span",{className:"chats-said row-dim",children:[T.hit.role==="user"?"you":"the agent",T.hit.ts>0&&fr(T.hit.ts)!==fr(v.get(T.hit.worktreeId)??0)?` · ${fr(T.hit.ts)}`:""]})]})})}const oc=function(e,t){let o=e;const s=au[t];let a=null,c=0,u=null;const h=[],f={},m=function(C,O){c=o*4+17,a=(function(A){const D=new Array(A);for(let B=0;B<A;B+=1){D[B]=new Array(A);for(let W=0;W<A;W+=1)D[B][W]=null}return D})(c),g(0,0),g(c-7,0),g(0,c-7),v(),w(),x(C,O),o>=7&&N(C),u==null&&(u=T(o,s,h)),_(u,O)},g=function(C,O){for(let A=-1;A<=7;A+=1)if(!(C+A<=-1||c<=C+A))for(let D=-1;D<=7;D+=1)O+D<=-1||c<=O+D||(0<=A&&A<=6&&(D==0||D==6)||0<=D&&D<=6&&(A==0||A==6)||2<=A&&A<=4&&2<=D&&D<=4?a[C+A][O+D]=!0:a[C+A][O+D]=!1)},y=function(){let C=0,O=0;for(let A=0;A<8;A+=1){m(!0,A);const D=bi.getLostPoint(f);(A==0||C>D)&&(C=D,O=A)}return O},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=bi.getPatternPosition(o);for(let O=0;O<C.length;O+=1)for(let A=0;A<C.length;A+=1){const D=C[O],B=C[A];if(a[D][B]==null)for(let W=-2;W<=2;W+=1)for(let U=-2;U<=2;U+=1)W==-2||W==2||U==-2||U==2||W==0&&U==0?a[D+W][B+U]=!0:a[D+W][B+U]=!1}},N=function(C){const O=bi.getBCHTypeNumber(o);for(let A=0;A<18;A+=1){const D=!C&&(O>>A&1)==1;a[Math.floor(A/3)][A%3+c-8-3]=D}for(let A=0;A<18;A+=1){const D=!C&&(O>>A&1)==1;a[A%3+c-8-3][Math.floor(A/3)]=D}},x=function(C,O){const A=s<<3|O,D=bi.getBCHTypeInfo(A);for(let B=0;B<15;B+=1){const W=!C&&(D>>B&1)==1;B<6?a[B][8]=W:B<8?a[B+1][8]=W:a[c-15+B][8]=W}for(let B=0;B<15;B+=1){const W=!C&&(D>>B&1)==1;B<8?a[8][c-B-1]=W:B<9?a[8][15-B-1+1]=W:a[8][15-B-1]=W}a[c-8][8]=!C},_=function(C,O){let A=-1,D=c-1,B=7,W=0;const U=bi.getMaskFunction(O);for(let Q=c-1;Q>0;Q-=2)for(Q==6&&(Q-=1);;){for(let Y=0;Y<2;Y+=1)if(a[D][Q-Y]==null){let se=!1;W<C.length&&(se=(C[W]>>>B&1)==1),U(D,Q-Y)&&(se=!se),a[D][Q-Y]=se,B-=1,B==-1&&(W+=1,B=7)}if(D+=A,D<0||c<=D){D-=A,A=-A;break}}},j=function(C,O){let A=0,D=0,B=0;const W=new Array(O.length),U=new Array(O.length);for(let H=0;H<O.length;H+=1){const $=O[H].dataCount,Z=O[H].totalCount-$;D=Math.max(D,$),B=Math.max(B,Z),W[H]=new Array($);for(let de=0;de<W[H].length;de+=1)W[H][de]=255&C.getBuffer()[de+A];A+=$;const q=bi.getErrorCorrectPolynomial(Z),ne=zu(W[H],q.getLength()-1).mod(q);U[H]=new Array(q.getLength()-1);for(let de=0;de<U[H].length;de+=1){const pe=de+ne.getLength()-U[H].length;U[H][de]=pe>=0?ne.getAt(pe):0}}let Q=0;for(let H=0;H<O.length;H+=1)Q+=O[H].totalCount;const Y=new Array(Q);let se=0;for(let H=0;H<D;H+=1)for(let $=0;$<O.length;$+=1)H<W[$].length&&(Y[se]=W[$][H],se+=1);for(let H=0;H<B;H+=1)for(let $=0;$<O.length;$+=1)H<U[$].length&&(Y[se]=U[$][H],se+=1);return Y},T=function(C,O,A){const D=_E.getRSBlocks(C,O),B=NE();for(let U=0;U<A.length;U+=1){const Q=A[U];B.put(Q.getMode(),4),B.put(Q.getLength(),bi.getLengthInBits(Q.getMode(),C)),Q.write(B)}let W=0;for(let U=0;U<D.length;U+=1)W+=D[U].dataCount;if(B.getLengthInBits()>W*8)throw"code length overflow. ("+B.getLengthInBits()+">"+W*8+")";for(B.getLengthInBits()+4<=W*8&&B.put(0,4);B.getLengthInBits()%8!=0;)B.putBit(!1);for(;!(B.getLengthInBits()>=W*8||(B.put(236,8),B.getLengthInBits()>=W*8));)B.put(17,8);return j(B,D)};f.addData=function(C,O){O=O||"Byte";let A=null;switch(O){case"Numeric":A=Hq(C);break;case"Alphanumeric":A=Wq(C);break;case"Byte":A=Kq(C);break;case"Kanji":A=qq(C);break;default:throw"mode:"+O}h.push(A),u=null},f.isDark=function(C,O){if(C<0||c<=C||O<0||c<=O)throw C+","+O;return a[C][O]},f.getModuleCount=function(){return c},f.make=function(){if(o<1){let C=1;for(;C<40;C++){const O=_E.getRSBlocks(C,s),A=NE();for(let B=0;B<h.length;B++){const W=h[B];A.put(W.getMode(),4),A.put(W.getLength(),bi.getLengthInBits(W.getMode(),C)),W.write(A)}let D=0;for(let B=0;B<O.length;B++)D+=O[B].dataCount;if(A.getLengthInBits()<=D*8)break}o=C}m(!1,y())},f.createTableTag=function(C,O){C=C||2,O=typeof O>"u"?C*4:O;let A="";A+='<table style="',A+=" border-width: 0px; border-style: none;",A+=" border-collapse: collapse;",A+=" padding: 0px; margin: "+O+"px;",A+='">',A+="<tbody>";for(let D=0;D<f.getModuleCount();D+=1){A+="<tr>";for(let B=0;B<f.getModuleCount();B+=1)A+='<td style="',A+=" border-width: 0px; border-style: none;",A+=" border-collapse: collapse;",A+=" padding: 0px; margin: 0px;",A+=" width: "+C+"px;",A+=" height: "+C+"px;",A+=" background-color: ",A+=f.isDark(D,B)?"#000000":"#ffffff",A+=";",A+='"/>';A+="</tr>"}return A+="</tbody>",A+="</table>",A},f.createSvgTag=function(C,O,A,D){let B={};typeof arguments[0]=="object"&&(B=arguments[0],C=B.cellSize,O=B.margin,A=B.alt,D=B.title),C=C||2,O=typeof O>"u"?C*4:O,A=typeof A=="string"?{text:A}:A||{},A.text=A.text||null,A.id=A.text?A.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 W=f.getModuleCount()*C+O*2;let U,Q,Y,se,H="",$;for($="l"+C+",0 0,"+C+" -"+C+",0 0,-"+C+"z ",H+='<svg version="1.1" xmlns="http://www.w3.org/2000/svg"',H+=B.scalable?"":' width="'+W+'px" height="'+W+'px"',H+=' viewBox="0 0 '+W+" "+W+'" ',H+=' preserveAspectRatio="xMinYMin meet"',H+=D.text||A.text?' role="img" aria-labelledby="'+I([D.id,A.id].join(" ").trim())+'"':"",H+=">",H+=D.text?'<title id="'+I(D.id)+'">'+I(D.text)+"</title>":"",H+=A.text?'<description id="'+I(A.id)+'">'+I(A.text)+"</description>":"",H+='<rect width="100%" height="100%" fill="white" cx="0" cy="0"/>',H+='<path d="',Y=0;Y<f.getModuleCount();Y+=1)for(se=Y*C+O,U=0;U<f.getModuleCount();U+=1)f.isDark(Y,U)&&(Q=U*C+O,H+="M"+Q+","+se+$);return H+='" stroke="transparent" fill="black"/>',H+="</svg>",H},f.createDataURL=function(C,O){C=C||2,O=typeof O>"u"?C*4:O;const A=f.getModuleCount()*C+O*2,D=O,B=A-O;return Yq(A,A,function(W,U){if(D<=W&&W<B&&D<=U&&U<B){const Q=Math.floor((W-D)/C),Y=Math.floor((U-D)/C);return f.isDark(Y,Q)?0:1}else return 1})},f.createImgTag=function(C,O,A){C=C||2,O=typeof O>"u"?C*4:O;const D=f.getModuleCount()*C+O*2;let B="";return B+="<img",B+=' src="',B+=f.createDataURL(C,O),B+='"',B+=' width="',B+=D,B+='"',B+=' height="',B+=D,B+='"',A&&(B+=' alt="',B+=I(A),B+='"'),B+="/>",B};const I=function(C){let O="";for(let A=0;A<C.length;A+=1){const D=C.charAt(A);switch(D){case"<":O+="&lt;";break;case">":O+="&gt;";break;case"&":O+="&amp;";break;case'"':O+="&quot;";break;default:O+=D;break}}return O},R=function(C){C=typeof C>"u"?2:C;const A=f.getModuleCount()*1+C*2,D=C,B=A-C;let W,U,Q,Y,se;const H={"██":"█","█ ":"▀"," █":"▄"," ":" "},$={"██":"▀","█ ":"▀"," █":" "," ":" "};let Z="";for(W=0;W<A;W+=2){for(Q=Math.floor((W-D)/1),Y=Math.floor((W+1-D)/1),U=0;U<A;U+=1)se="█",D<=U&&U<B&&D<=W&&W<B&&f.isDark(Q,Math.floor((U-D)/1))&&(se=" "),D<=U&&U<B&&D<=W+1&&W+1<B&&f.isDark(Y,Math.floor((U-D)/1))?se+=" ":se+="█",Z+=C<1&&W+1>=B?$[se]:H[se];Z+=`
272
- `}return A%2&&C>0?Z.substring(0,Z.length-A-1)+Array(A+1).join("▀"):Z.substring(0,Z.length-1)};return f.createASCII=function(C,O){if(C=C||1,C<2)return R(O);C-=1,O=typeof O>"u"?C*2:O;const A=f.getModuleCount()*C+O*2,D=O,B=A-O;let W,U,Q,Y;const se=Array(C+1).join("██"),H=Array(C+1).join(" ");let $="",Z="";for(W=0;W<A;W+=1){for(Q=Math.floor((W-D)/C),Z="",U=0;U<A;U+=1)Y=1,D<=U&&U<B&&D<=W&&W<B&&f.isDark(Q,Math.floor((U-D)/C))&&(Y=0),Z+=Y?se:H;for(Q=0;Q<C;Q+=1)$+=Z+`
273
- `}return $.substring(0,$.length-1)},f.renderTo2dContext=function(C,O){O=O||2;const A=f.getModuleCount();for(let D=0;D<A;D++)for(let B=0;B<A;B++)C.fillStyle=f.isDark(D,B)?"black":"white",C.fillRect(B*O,D*O,O,O)},f};oc.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};oc.createStringToBytes=function(e,t){const n=(function(){const o=Gq(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 h=s(),f=s(),m=s(),g=String.fromCharCode(u<<8|h),y=f<<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 Kr={MODE_NUMBER:1,MODE_ALPHA_NUM:2,MODE_8BIT_BYTE:4,MODE_KANJI:8},au={L:1,M:0,Q:3,H:2},vi={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7},bi=(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 vi.PATTERN000:return function(c,u){return(c+u)%2==0};case vi.PATTERN001:return function(c,u){return c%2==0};case vi.PATTERN010:return function(c,u){return u%3==0};case vi.PATTERN011:return function(c,u){return(c+u)%3==0};case vi.PATTERN100:return function(c,u){return(Math.floor(c/2)+Math.floor(u/3))%2==0};case vi.PATTERN101:return function(c,u){return c*u%2+c*u%3==0};case vi.PATTERN110:return function(c,u){return(c*u%2+c*u%3)%2==0};case vi.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=zu([1],0);for(let u=0;u<a;u+=1)c=c.multiply(zu([1,Si.gexp(u)],0));return c},o.getLengthInBits=function(a,c){if(1<=c&&c<10)switch(a){case Kr.MODE_NUMBER:return 10;case Kr.MODE_ALPHA_NUM:return 9;case Kr.MODE_8BIT_BYTE:return 8;case Kr.MODE_KANJI:return 8;default:throw"mode:"+a}else if(c<27)switch(a){case Kr.MODE_NUMBER:return 12;case Kr.MODE_ALPHA_NUM:return 11;case Kr.MODE_8BIT_BYTE:return 16;case Kr.MODE_KANJI:return 10;default:throw"mode:"+a}else if(c<41)switch(a){case Kr.MODE_NUMBER:return 14;case Kr.MODE_ALPHA_NUM:return 13;case Kr.MODE_8BIT_BYTE:return 16;case Kr.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 N=-1;N<=1;N+=1)g+N<0||c<=g+N||v==0&&N==0||w==a.isDark(m+v,g+N)&&(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 h=0;for(let m=0;m<c;m+=1)for(let g=0;g<c;g+=1)a.isDark(g,m)&&(h+=1);const f=Math.abs(100*h/c/c-50)/5;return u+=f*10,u},o})(),Si=(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})(),zu=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]^=Si.gexp(Si.glog(r.getAt(a))+Si.glog(o.getAt(c)));return zu(s,0)},r.mod=function(o){if(r.getLength()-o.getLength()<0)return r;const s=Si.glog(r.getAt(0))-Si.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]^=Si.gexp(Si.glog(o.getAt(c))+s);return zu(a,0).mod(o)},r},_E=(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 au.L:return e[(o-1)*4+0];case au.M:return e[(o-1)*4+1];case au.Q:return e[(o-1)*4+2];case au.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 h=0;h<c;h+=1){const f=a[h*3+0],m=a[h*3+1],g=a[h*3+2];for(let y=0;y<f;y+=1)u.push(t(m,g))}return u},n})(),NE=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},Hq=function(e){const t=Kr.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},Wq=function(e){const t=Kr.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},Kq=function(e){const t=Kr.MODE_8BIT_BYTE,n=oc.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},qq=function(e){const t=Kr.MODE_KANJI,n=oc.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},fC=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},Zq=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},Gq=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},Vq=function(e,t){const n=e,r=t,o=new Array(e*t),s={};s.setPixel=function(h,f,m){o[f*n+h]=m},s.write=function(h){h.writeString("GIF87a"),h.writeShort(n),h.writeShort(r),h.writeByte(128),h.writeByte(0),h.writeByte(0),h.writeByte(0),h.writeByte(0),h.writeByte(0),h.writeByte(255),h.writeByte(255),h.writeByte(255),h.writeString(","),h.writeShort(0),h.writeShort(0),h.writeShort(n),h.writeShort(r),h.writeByte(0);const f=2,m=c(f);h.writeByte(f);let g=0;for(;m.length-g>255;)h.writeByte(255),h.writeBytes(m,g,255),g+=255;h.writeByte(m.length-g),h.writeBytes(m,g,m.length-g),h.writeByte(0),h.writeString(";")};const a=function(h){const f=h;let m=0,g=0;const y={};return y.write=function(w,v){if(w>>>v)throw"length over";for(;m+v>=8;)f.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&&f.writeByte(g)},y},c=function(h){const f=1<<h,m=(1<<h)+1;let g=h+1;const y=u();for(let _=0;_<f;_+=1)y.add(String.fromCharCode(_));y.add(String.fromCharCode(f)),y.add(String.fromCharCode(m));const w=fC(),v=a(w);v.write(f,g);let N=0,x=String.fromCharCode(o[N]);for(N+=1;N<o.length;){const _=String.fromCharCode(o[N]);N+=1,y.contains(x+_)?x=x+_:(v.write(y.indexOf(x),g),y.size()<4095&&(y.size()==1<<g&&(g+=1),y.add(x+_)),x=_)}return v.write(y.indexOf(x),g),v.write(m,g),v.flush(),w.toByteArray()},u=function(){const h={};let f=0;const m={};return m.add=function(g){if(m.contains(g))throw"dup key:"+g;h[g]=f,f+=1},m.size=function(){return f},m.indexOf=function(g){return h[g]},m.contains=function(g){return typeof h[g]<"u"},m};return s},Yq=function(e,t,n){const r=Vq(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=fC();r.write(o);const s=Zq(),a=o.toByteArray();for(let c=0;c<a.length;c+=1)s.writeByte(a[c]);return s.flush(),"data:image/gif;base64,"+s};oc.stringToBytes;function Xq(e){const t=oc(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 dr={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 Qq(e,t){return e.reached?e.toyon&&!e.toyon.answering?dr.notAnswering:t?dr.listed:e.toyon?null:dr.noToyon:dr.offline}function TE(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 hC(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 Jq(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",dr.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 eZ=e=>e==="phone"?"phone":"laptop";function jE({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(mt,{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 $E=(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:eZ(e.kind),right:t}},Rg=4;function tZ({text:e}){const{size:t,d:n}=S.useMemo(()=>{const r=Xq(e);let o="";return r.forEach((s,a)=>{s.forEach((c,u)=>{c&&(o+=`M${u+Rg} ${a+Rg}h1v1h-1z`)})}),{size:r.length+Rg*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 nZ=5e3;function rZ(e){return e.from===null?"A device that opened this address":`A Toyon page at ${Nh(e.from)}`}function oZ({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?`${rZ(e)} wants in.`:t?"is in.":"was turned away."})]}),t===null&&d.jsxs("div",{className:"devices-actions",children:[d.jsx(Pe,{tone:"primary",onClick:()=>n(!0),children:"let in"}),d.jsx(Pe,{variant:"outline",onClick:()=>n(!1),children:"not now"})]})]})}function sZ({host:e,noPhone:t}){return d.jsxs("div",{className:"devices-address",children:[d.jsx("div",{className:"devices-frame",children:d.jsx(tZ,{text:TI(e)})}),d.jsxs("div",{className:"devices-about",children:[d.jsx("p",{className:"devices-line",children:dr.scan}),t&&d.jsx("p",{className:"devices-note",children:dr.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)=>TE(r.d)-TE(o.d)||r.i-o.i).map(({d:r})=>r);return[...t,...n]}function aZ(){const e=ut(),t=ks(),n=Pr(),r=L(ue=>ue.frame==="desk"),o=L(ue=>{var le;return((le=ue.remote)==null?void 0:le.host)??null}),s=L(ue=>ue.machine),a=L(ue=>ue.tailscale),c=L(ue=>ue.knocks),[u,h]=S.useState(""),[f,m]=S.useState({kind:"idle"}),[g,y]=S.useState([]),w=()=>e({a:"close"}),v=f.kind==="asking"||f.kind==="waiting",N=o3(()=>WD(n),nZ,!v),x=S.useRef(new AbortController);S.useEffect(()=>()=>x.current.abort(),[]);const _=async ue=>{if(v)return;const le=x.current.signal;m({kind:"asking",origin:ue});const be=await l_(ue,le,Ie=>m({kind:"waiting",origin:ue,word:Ie}));if(le.aborted)return;if(typeof be=="string"){m({kind:"failed",line:hC(be,ue,"this page")});return}const Ce=t.serving(),Ne=await VD(Tw(Ce.origin,Ce.token),ue,be.token);m(Ne?{kind:"failed",line:dr.notKept(Ne)}:{kind:"added",name:t.displayName(ue)})},j=()=>{const ue=jI(u);ue?_(ue):m({kind:"failed",line:dr.notAnAddress})},T=()=>{x.current.abort(),x.current=new AbortController,m({kind:"idle"})},I=(ue,le)=>{y(be=>be.some(Ce=>Ce.knock.id===ue.id)?be:[...be,{knock:ue,letIn:le}]),YD(n,ue.id,le)},R=c.filter(ue=>!g.some(le=>le.knock.id===ue.id)),C=[...g,...R.map(ue=>({knock:ue,letIn:null}))],[O,A]=S.useState(!1),[D,B]=S.useState(null),W=async ue=>{A(!0),B(null);const le=await(ue?KD(n):qD(n));A(!1),le&&B(le)},U=(N==null?void 0:N.here)===!0,Q=Jq(N,a,o),Y=o!==null,se=r&&(U||N===void 0)?d.jsx(Pe,{variant:"outline",size:"sm",on:Y,"aria-pressed":Y,busy:O,disabled:!Y&&(a==null?void 0:a.state)!=="ready",onClick:()=>void W(!Y),...Lt(Y?"Take this machine's name off your tailnet":"Give this machine a name on your tailnet"),children:Y?"on":"off"}):null,[H,$]=S.useState(!1),[Z,q]=S.useState(null),K=ue=>{window.open(ue,"_blank","noopener")===null?q(ue):q(null)},ne=async ue=>{if($(!0),B(null),ue==="connect"){const le=await ZD(n);le&&B(le)}else{const le=await GD(n);"url"in le?K(le.url):B(le.why)}$(!1)},de=r&&Q.offer!==null?Z!==null?d.jsx(Pe,{variant:"outline",size:"sm",onClick:()=>K(Z),children:"open the sign-in page"}):d.jsx(Pe,{variant:"outline",size:"sm",busy:H,onClick:()=>void ne(Q.offer??"connect"),...Q.note?Lt(Q.note):{},children:Q.offer==="connect"?"connect":"sign in"}):null,pe=Q.word===null&&se===null&&de===null?"this machine":d.jsxs(d.Fragment,{children:[Q.word&&d.jsx("span",{className:"hint",children:Q.word}),se??de]}),je=[{key:"self",name:s??"This machine",host:o??void 0,reached:N===void 0?null:U,icon:"laptop",right:pe}],_e=N?iZ(N).map(ue=>{if(ue.kind==="phone"||ue.host==="")return $E(ue,ue.reached?void 0:"not answering");const le=`https://${ue.host}`,be=Qq(ue,t.get(le)!==null);return $E(ue,be??d.jsx(Pe,{variant:"outline",size:"sm",disabled:v,onClick:()=>void _(le),children:dr.request}))}):[],fe=r&&o!==null&&N!==null&&(N===void 0||N.here),te=N==null?void 0:N.devices.some(ue=>ue.kind==="machine"&&ue.host!==""&&ue.reached&&ue.toyon===null),re=fe&&N!==void 0&&!N.devices.some(ue=>ue.kind==="phone"),we=(()=>{switch(f.kind){case"asking":return dr.asking(f.origin);case"waiting":return dr.waiting(f.origin,f.word);case"added":return dr.added(f.name);case"failed":return f.line;case"idle":return null}})();return d.jsxs(Lu,{boxClass:"devices-card",onClose:w,children:[d.jsx("div",{className:"devices-title",children:dr.title}),d.jsx(jE,{rows:je}),Q.note&&Q.offer===null&&d.jsx("p",{className:"devices-note",children:Q.note}),D&&d.jsx("p",{className:"devices-note",children:D}),r&&!Y&&(a==null?void 0:a.state)==="ready"&&d.jsx("p",{className:"devices-note",children:dr.turnOn}),fe&&o!==null&&d.jsx(sZ,{host:o,noPhone:re}),f.kind==="waiting"&&d.jsx("div",{className:"knock-word devices-word",children:f.word}),we&&d.jsx("p",{className:Ke("devices-line",f.kind==="failed"&&"devices-failed"),children:we}),N!==void 0&&d.jsxs(d.Fragment,{children:[_e.length>0&&d.jsx("div",{className:"devices-others",children:d.jsx(jE,{rows:_e})}),(N==null?void 0:N.devices.length)===0&&d.jsx("p",{className:"devices-note",children:dr.noneOnTailnet}),te&&d.jsx("p",{className:"devices-note",children:dr.missing})]}),!v&&d.jsxs("form",{className:"devices-form",onSubmit:ue=>{ue.preventDefault(),j()},children:[d.jsx(Fo,{size:"md",font:"ui",value:u,placeholder:dr.placeholder,"aria-label":"Address of the other machine",onChange:ue=>h(ue.target.value),className:"devices-field"}),d.jsx(Pe,{type:"submit",variant:"outline",disabled:!u.trim(),children:dr.add})]}),v&&d.jsx("div",{className:"devices-actions",children:d.jsx(Pe,{tone:"quiet",onClick:T,children:"cancel"})}),R.length>0&&d.jsx("p",{className:"devices-line devices-centred",children:dr.knocking}),C.map(ue=>d.jsx(oZ,{knock:ue.knock,letIn:ue.letIn,onAnswer:le=>I(ue.knock,le)},ue.knock.id))]})}function lZ({worktreeId:e,hits:t}){const n=ut(),r=Qe(),o=L(c=>c.layout.changes),s=L(c=>{var h;const u=(h=qt(c,e))==null?void 0:h.worktree;return u?u.path:null}),a=S.useCallback((c,u)=>{const h=u.trim().toLowerCase();return h?c.filter(f=>`${f.path}:${f.line} ${f.text}`.toLowerCase().includes(h)):c},[]);return d.jsx(Gr,{items:t,filter:a,keyOf:c=>`${c.path}:${c.line}`,rowClass:()=>"search-hit",rowTitle:c=>`${c.path}:${c.line}`,onPick:c=>{Dn({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 cZ({project:e}){const t=ut(),n=Qe(),r=L(h=>h.paths),o=L(h=>h.home),s=S.useCallback(h=>{Au(h)&&(n==null||n.send({t:"browse-path",path:h}))},[n]),a=S.useCallback((h,f)=>u8({query:f,entries:r.entries,target:r.target,answered:r.query,home:o}),[r,o]),c=vu(e.name)?null:e.name.trim(),u=h=>`${h.replace(/\/+$/,"")}/`;return d.jsx(Gr,{initialQuery:u(e.parent),lead:d.jsx("span",{className:"picker-chip",children:c??"new project"}),items:[],filter:a,keyOf:h=>h.kind==="dir"?`d:${h.entry.path}`:`${h.kind}:${h.path}`,rowClass:()=>"picker-row folder-row",onQuery:s,completionOf:h=>h.kind==="dir"?u(h.entry.path):null,narrowTo:h=>h.kind==="dir"?u(h.entry.path):h.kind==="up"?u(h.path):null,onPick:h=>{h.kind==="here"&&(t({a:"new-project-set",v:{mode:e.mode==="init"?"create":e.mode,parent:h.path}}),t({a:"close"}))},onBack:()=>t({a:"close"}),placeholder:"type a folder path",keys:h=>({complete:"completes the path",pick:(h==null?void 0:h.kind)==="here"?"chooses it":(h==null?void 0:h.kind)==="up"?"goes up":"opens it",back:"goes back"}),empty:"no such folder",row:h=>h.kind==="here"?d.jsx(Mn,{label:`put ${c??"it"} in ${$k(h.path,o)}`,hint:d.jsx("bdi",{children:c?ej(h.path,c):h.path})}):h.kind==="up"?d.jsx(Mn,{label:`up to ${$k(h.path,o)}`,hint:d.jsx("bdi",{children:h.path})}):d.jsx(Mn,{label:h.entry.name})})}function uZ({worktreeId:e}){const t=ut(),n=Qe(),r=L(g=>g.clientId),o=L(g=>qt(g,e)),s=L(g=>g.repos),c=At(e,"draft").trim(),u=o==null?void 0:o.worktree.repoId,h=S.useMemo(()=>[...s.filter(g=>g.id===u),...s.filter(g=>g.id!==u)],[s,u]),f=()=>t({a:"close"}),m=g=>{if(!o)return f();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:""})),f()};return d.jsx(Gr,{lead:d.jsx("span",{className:"picker-chip",children:(o==null?void 0:o.worktree.title)??"worktree"}),items:h,filter:(g,y)=>g.filter(w=>w.id===u&&es(y,"here")||es(y,w.name,w.path)),keyOf:g=>g.id,row:g=>d.jsx(Mn,{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(`
274
- `)[0]]}):void 0})}const dZ={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 fZ(){const e=ut(),t=Qe(),n=L(r=>r.keepAwake);return d.jsx(Gr,{items:[...YA],filter:(r,o)=>r.filter(s=>es(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(Mn,{label:mh[r],current:r===n,hint:dZ[r]})})}function hZ(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=Nk(t.rows,null);return n?`${n.n} ${n.tier==="waiting"?"waiting":"unread"}`:"all quiet"}function Jk(e){try{return $I(new URL(e).hostname)}catch{return!1}}function pZ(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 N;if(w.serving)return;(((N=w.store.getState().remote)==null?void 0:N.front)==="edge"||Jk(w.origin))&&w!==o?w.sock.suspend():w.sock.resume()},h=w=>{var N;let v=(N=w.store.getState().remote)==null?void 0:N.front;c.set(w.origin,w.store.subscribe(()=>{var _;const x=(_=w.store.getState().remote)==null?void 0:_.front;x!==v&&(v=x,u(w))}))},f=()=>s,m={list:f,active:()=>o,serving:()=>n,get:w=>f().find(v=>v.origin===w)??null,displayName(w){const v=f().find(x=>x.origin===w);return v?f().filter(x=>x.name===v.name).length>1?`${v.name} (${new URL(v.origin).host})`:v.name:w},activate(w){const v=f().find(x=>x.origin===w);if(!v||v===o)return;const N=o;o=v,u(N),u(v),a()},add(w){var x;const v=r.find(_=>_.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 N=e.build({...w,serving:!1});return r.push(N),h(N),Jk(N.origin)&&N.sock.suspend(),a(),N},remove(w){var N;const v=r.find(x=>x.origin===w);v&&((N=c.get(w))==null||N(),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 f())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(N=>N.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 tv({form:e,anchored:t}){var H;const n=ut(),r=Qe(),o=ks(),s=Bs(),a=o.displayName(s.origin),c=L($=>$.repos),u=L($=>$.newProject?null:$.activeRepoId),h=L($=>$.rows),f=L($=>$.paths),m=L($=>$.home),g=L($=>$.pending),y=L($=>$.folderDialog),w=e==="url",v=S.useRef(""),N=S.useMemo(()=>J0(c,h),[c,h]),x=eN(),_=tN(),j=S.useMemo(()=>x.map($=>{var Z;return{...$,repos:J0($.repos,((Z=_.find(q=>q.origin===$.origin))==null?void 0:Z.rows)??[])}}),[x,_]),T=S.useCallback($=>{v.current=$,Au($)&&(r==null||r.send({t:"browse-path",path:$}))},[r]),I=S.useCallback(($,Z)=>c8({query:Z,repos:N,pending:g,entries:[...f.entries].sort((q,K)=>Number(K.isRepo)-Number(q.isRepo)),target:f.target,answered:f.query,home:m,others:j,current:u,urlOnly:w}),[N,f,g,m,j,u,w]),R=()=>n({a:"close"}),C=()=>n({a:"close",back:!0}),O={sock:r,dispatch:n},A=$=>Cu(O,{t:"register-repo",path:$}),D=($,Z)=>Cu(O,{t:"create-repo",mode:"create",parent:$,name:Z}),B=($,Z,q)=>n({a:"new-project",v:Yh({mode:$,name:Z,parent:l8(c,u,m),...q})}),W=()=>n({a:"open",overlay:{kind:"projects",form:"disk"}}),U=()=>n({a:"open",overlay:{kind:"projects",form:"url"}}),Q=()=>{const $=v.current.trim(),Z=$.lastIndexOf("/"),q=Au($)&&Z>=0?$.slice(0,Z)||"/":"~";r==null||r.send({t:"choose-file",start:q}),R()},Y=()=>n({a:"open",overlay:{kind:"devices"}}),se=($,Z)=>{const q=o.get($);q&&(q.store.dispatch({a:"activate-repo",id:Z}),o.activate($))};return d.jsx(Gr,{anchored:e==="pill"&&(t??!0),initialQuery:e==="disk"?"~/":"",lead:e==="disk"||w?void 0:d.jsx("span",{className:"picker-chip",children:((H=c.find($=>$.id===u))==null?void 0:H.name)??"no project"}),trailing:w?void 0:e==="disk"?y?d.jsx(It,{icon:"file",label:"Open a file from Finder",onClick:Q}):void 0:d.jsx(It,{icon:"folder",label:"Find a project or file on disk",onClick:W}),items:[],filter:I,initialIndex:$=>$.findIndex(Z=>Z.kind==="repo"&&!Z.machine&&Z.repo.id===u),groupOf:$=>$.kind==="machine"||$.kind==="repo"&&$.machine?$.machine.origin:s.origin,groupHead:$=>$===s.origin?a:d.jsx(mZ,{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:T,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 B("clone",$.name,{url:$.url,...$.branch?{branch:$.branch}:{}});if($.kind==="create"&&!$.parent)return B("create",$.name);if($.kind==="new")return B("create","");if($.kind==="disk")return W();if($.kind==="from-url")return U();if($.kind==="add-machine")return Y();$.kind==="machine"?o.activate($.machine.origin):$.kind==="pending"?n({a:"watch-import",id:$.pending.id}):$.kind==="repo"&&$.machine?se($.machine.origin,$.repo.id):$.kind==="repo"?n({a:"activate-repo",id:$.repo.id}):$.kind==="open"?A($.path):$.kind==="file"?h8(r,$.entry.path):$.kind==="init"?VT(O,$.path):$.kind==="dir"?A($.entry.path):$.parent&&D($.parent,$.name),R()},onBack:C,rowMenu:$=>$.kind==="machine"||$.kind==="repo"&&$.machine?Tk(o,$.machine.origin):$.kind==="repo"?hp($.repo,u,O,h):$.kind==="pending"?o8($.pending,O):[],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(Mn,{label:$.repo.name,current:!$.machine&&$.repo.id===u}):$.kind==="pending"?d.jsx(Mn,{label:$.pending.name,hint:$.pending.error?"import failed":d.jsx("span",{className:"live-text",children:"importing"})}):$.kind==="dir"?d.jsx(Mn,{label:$.entry.name,hint:$.entry.isRepo?"git repo":void 0}):$.kind==="file"?d.jsx(Mn,{label:$.entry.name,hint:"file"}):$.kind==="open"?d.jsx(Mn,{label:`open ${$.path}`,hint:"register with this daemon"}):$.kind==="init"?d.jsx(Mn,{label:`open ${$.path}`,hint:"no git yet; starts it here with the files in it"}):$.kind==="clone"?d.jsx(Mn,{label:`clone ${$.name}`,hint:$.branch?`${CE($.url)} · ${$.branch}`:CE($.url)}):$.kind==="new"?d.jsx(Mn,{label:d.jsxs(d.Fragment,{children:[d.jsx(mt,{name:"plus",className:"icon-inline"}),"new project"]})}):$.kind==="disk"?d.jsx(Mn,{label:d.jsxs(d.Fragment,{children:[d.jsx(mt,{name:"folder",className:"icon-inline"}),"open folder or file"]})}):$.kind==="from-url"?d.jsx(Mn,{label:d.jsxs(d.Fragment,{children:[d.jsx(mt,{name:"globe",className:"icon-inline"}),"clone from a URL"]})}):$.kind==="add-machine"?d.jsx(Mn,{label:d.jsxs(d.Fragment,{children:[d.jsx(mt,{name:"devices",className:"icon-inline"}),"add a machine"]})}):$.kind==="machine"?d.jsx(Mn,{label:`switch to ${o.displayName($.machine.origin)}`}):d.jsx(Mn,{label:`create ${$.name}`,hint:$.parent?`in ${$.parent}`:"new project"})})}function mZ({origin:e}){const t=ks(),n=t.get(e)??t.active(),r=Gc(n,m=>m.rows),o=Gc(n,m=>m.connected),s=Gc(n,m=>m.connectFailure),a=Gc(n,m=>m.incompatible),c=Gc(n,m=>{var g;return(g=m.remote)==null?void 0:g.front}),u=t.displayName(e),h=hZ(u,{rows:r.filter(jn),connected:o,connectFailure:s,incompatible:a,suspended:(c==="edge"||Jk(e))&&!o}),f=/^\d+ /.test(h);return d.jsxs(d.Fragment,{children:[u,d.jsx("span",{className:Ke("picker-group-tail",f&&"picker-group-owed"),children:h})]})}function CE(e){const t=e.match(/^[a-z+]+:\/\/(?:[^@/]*@)?([^/:]+)/i)??e.match(/^[^@]+@([^:]+):/);return(t==null?void 0:t[1])??"git remote"}function gZ(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 kZ=[],wZ={branch:"branch",remote:"globe",pr:"pr"},AE={pr:0,branch:1,remote:2},yZ={pr:"pull requests",branch:"branches",remote:"remote branches"};function vZ({repoId:e}){const t=ut(),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=S.useCallback(m=>[...m].sort((g,y)=>AE[g.kind]-AE[y.kind]),[]),u=S.useCallback(m=>n==null?void 0:n.send({t:"search-refs",repoId:e,query:m.trim()}),[n,e]),h=m=>!o||o.query!==m.trim(),f=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(Gr,{items:(o==null?void 0:o.refs)??kZ,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:gZ,groupOf:m=>m.kind,groupHead:(m,g)=>`${yZ[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=>h(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(Mn,{label:d.jsxs(d.Fragment,{children:[d.jsx(mt,{name:wZ[m.kind],className:"icon-inline"}),d.jsx("span",{className:"ref-name",children:m.name})]}),hint:f(m)})})}const IE=[],Og=2;function bZ(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 xZ({worktreeId:e}){const t=ut(),n=Qe(),r=dN(e).search,o=L(h=>h.layout.changes),s=L(h=>{var m;const f=(m=qt(h,e))==null?void 0:m.worktree;return f?f.path:null}),a=S.useCallback((h,f)=>f.trim().length>=Og?h:IE,[]),c=S.useCallback(h=>{const f=h.trim();f.length>=Og&&(n==null||n.send({t:"search",worktreeId:e,query:f}))},[n,e]),u=h=>!r||r.query.trim()!==h.trim();return S.useEffect(()=>()=>n==null?void 0:n.send({t:"search-stop"}),[n]),d.jsx(Gr,{items:(r==null?void 0:r.hits)??IE,filter:a,onQuery:c,keyOf:h=>`${h.path}:${h.line}`,rowClass:()=>"search-hit",rowTitle:h=>`${h.path}:${h.line}`,onPick:h=>{Dn({dispatch:t},{worktreeId:e,path:h.path,view:"file",line:{n:h.line}}),o||t({a:"toggle-changes"}),t({a:"close"})},onBack:()=>t({a:"close"}),rowMenu:h=>s?Ls({id:e,dir:s},h.path,{},{sock:n,dispatch:t}):[],placeholder:"search in files…",empty:h=>h.trim().length<Og?"type at least two characters":u(h)?d.jsx("span",{className:"live-text",children:"searching"}):"no matches",footer:(h,f)=>r!=null&&r.truncated&&!u(h)&&f.length>0?d.jsx("div",{className:"empty",children:"not every match is shown; narrow the search"}):null,row:(h,f,m)=>d.jsxs(d.Fragment,{children:[d.jsxs("span",{className:"search-loc",children:[h.path,":",h.line]}),d.jsx("span",{className:"search-text",children:Ql(h.text,bZ(h.text,m),0)})]})})}const RE=e=>e.source==="file"?"~/.toyon/themes":e.source==="vscode"?"VS Code":"";function EZ({slot:e}){const t=ut(),n=Qe(),r=L(_=>_.themePrefs),o=L(_=>_.themes),s=qw(),a=_w(r,s),c=r[e==="theme"?a:e],u=()=>t({a:"close"}),h=()=>t({a:"close",back:!0}),f=_=>t({a:"preview-theme",theme:_}),[m,g]=S.useState(null),[y,w]=S.useState(null),v=(_,j)=>_[j??a]??_.dark??_.light??null,N=S.useMemo(()=>SD(o),[o]),x=S.useMemo(()=>o.filter(_=>_.kind===e),[o,e]);return it([m,y],()=>{e==="theme"&&f(m?v(m,y):null)}),e!=="theme"?d.jsx(Gr,{items:x,filter:(_,j)=>_.filter(T=>es(j,T.name,T.id)),rowClass:()=>"picker-row",keyOf:_=>_.id,initialIndex:_=>_.findIndex(j=>j.id===c),onActive:f,onPick:_=>{n==null||n.send({t:"set-theme",prefs:{...r,[e]:_.id}}),u()},onBack:h,placeholder:`${e} slot override`,keys:{nav:"preview",pick:"keeps",back:"reverts"},empty:"no matching theme",row:_=>d.jsx(Mn,{label:_.name,current:_.id===c,hint:RE(_)})}):d.jsx(Gr,{items:N,filter:(_,j)=>_.filter(T=>{var I,R;return es(j,T.name,(I=T.dark)==null?void 0:I.name,(R=T.light)==null?void 0:R.name)}),rowClass:()=>"picker-row",keyOf:_=>{var j,T;return _.name+(((j=_.dark)==null?void 0:j.id)??((T=_.light)==null?void 0:T.id))},initialIndex:_=>_.findIndex(j=>{var T,I;return((T=j.dark)==null?void 0:T.id)===c||((I=j.light)==null?void 0:I.id)===c}),onActive:g,onSide:_=>{var j;_.dark&&_.light&&w((((j=v(_,y))==null?void 0:j.kind)??a)==="dark"?"light":"dark")},onPick:_=>{n==null||n.send({t:"set-theme",prefs:_D(r,_)}),u()},onBack:h,placeholder:"theme",keys:{nav:"preview",side:"dark/light",pick:"keeps",back:"reverts"},empty:"no matching theme",row:(_,j)=>{var C,O;const T=v(_,j?y:null),I=RE(_.dark??_.light),R=((C=_.dark)==null?void 0:C.id)===c||((O=_.light)==null?void 0:O.id)===c;return d.jsx(Mn,{label:_.name,current:R,hint:d.jsxs("span",{className:"theme-kinds",children:[I&&d.jsx("span",{children:I}),d.jsx("span",{className:"kind","data-state":hr({current:j&&(T==null?void 0:T.kind)==="dark"}),children:_.dark?"dark":""}),d.jsx("span",{className:"kind","data-state":hr({current:j&&(T==null?void 0:T.kind)==="light"}),children:_.light?"light":""})]})})}})}function pC(){const e=h3(),t=L(s=>s.frame==="phone"),n=tc(),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(VW,{worktreeId:n}),(e==null?void 0:e.kind)==="search"&&n&&d.jsx(xZ,{worktreeId:n}),(e==null?void 0:e.kind)==="element-sources"&&d.jsx(lZ,{worktreeId:e.worktreeId,hits:e.hits}),(e==null?void 0:e.kind)==="refs"&&r&&d.jsx(vZ,{repoId:r}),(e==null?void 0:e.kind)==="chats"&&r&&d.jsx(Uq,{repoId:r,scope:e.names?"names":"all"}),(e==null?void 0:e.kind)==="keys"&&d.jsx(Tq,{}),(e==null?void 0:e.kind)==="devices"&&d.jsx(aZ,{}),(e==null?void 0:e.kind)==="theme"&&d.jsx(EZ,{slot:e.slot}),(e==null?void 0:e.kind)==="appearance"&&d.jsx(Lq,{}),(e==null?void 0:e.kind)==="keep-awake"&&d.jsx(fZ,{}),(e==null?void 0:e.kind)==="agent"&&d.jsx(Rq,{}),(e==null?void 0:e.kind)==="agent-page"&&d.jsx(Aq,{agentId:e.agent}),(e==null?void 0:e.kind)==="handoff"&&d.jsx(uZ,{worktreeId:e.worktreeId}),(e==null?void 0:e.kind)==="commands"&&!t&&d.jsx(q$,{}),(e==null?void 0:e.kind)==="projects"&&e.form!=="pill"&&d.jsx(tv,{form:e.form},e.form),(e==null?void 0:e.kind)==="choose-folder"&&o&&d.jsx(cZ,{project:o})]})}const Vf="Lost the daemon; retrying",OE="Not answering";function SZ(e,t){return e!=="down"&&e!=="blocked"?Vf:t===null?OE:`${OE}; as of ${So(fr(t))}`}const _Z="Not run by Toyon",mC="new worktree",gC=e=>`started from ${e}`,NZ=(e,t)=>`in ${e}, ${gC(t)}`,TZ=e=>`in ${e}, here while it needs you`,jZ=new Set(["waiting","stopping","working","background","starting","failed","crashed"]);function ew(e,t){if(!jn(e))return e.locked?`Held by ${e.lockReason??"another tool"}`:t.path;if(t.op)return Iw(t.op);if(jr(e.worktree))return mC;const n=Aw(e,t.needsSetup),r=e.worktree.lastTurn;return!jZ.has(Fs(e))&&r?my(r):t.at&&t.at!=="now"?`${n} · ${t.at}`:n}function $Z(e,t){if(!jn(e)||t)return!1;const n=Fs(e);return(n==="idle"||n==="asleep")&&!e.unseen}function CZ(e){const t=e.worktree.lastTurn,n=e.worktree.landed?fy(e.worktree.lands):[],r=t?(ns(e.agent)?nF:my)(t):void 0,o=Mh(e.worktree),s=o&&!e.worktree.landed?Rs(o):void 0;return[...n,r,s].filter(a=>!!a)}function AZ(e,t,n,r){let o;const s=(f,m)=>{const g=m==null?void 0:m[m.length-1];g&&(!o||g.at>o.mark.at)&&(o={title:f,mark:g})};for(const f of e)f.worktree&&s(f.worktree.title,f.worktree.lands);for(const f of t)s(f.title,f.lands);const a=o&&bT(o.mark),c=o?`Landed ${o.title} ${So(fr(o.mark.at))}${a?`: ${eo(a)}`:"."}`:void 0,u=n?f_(r,n):null,h=u?eo(`${u.charAt(0).toUpperCase()}${u.slice(1)}`):n!=null&&n.fetchedAt?`Level with origin, fetched ${So(fr(n.fetchedAt))}.`:void 0;return[c,h].filter(f=>!!f)}function IZ(e){const t=e.prompt?dp(e.prompt):"";return[...t?[t]:[],...fy(e.lands)]}function RZ(e){const n=[e.auto&&OZ(e.auto,!!e.landed),e.cost!==void 0?Xu(e.cost):void 0].filter(r=>!!r);return n.length?n:void 0}function OZ(e,t){const{what:n,idle:r}=nI(e);return r?`${t?"":`${n}, `}${r} idle`:n}const ME=25;function MZ(e,t){if(e.length<=ME+1)return{shown:e,rest:0};const n=e.slice(0,ME),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 LZ(e,t,n){const r=e.indexOf(t);return r<0?null:e[r+(n?1:-1)]??null}const PZ=.5;function DZ(e){const t=e.usage,n=t&&t.size>0?t.used/t.size:0,r=[n>=PZ?`${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 zZ(e){const t=e.filter(ms).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 kC(e){return e.altKey?"Alt":e.ctrlKey?"Control":e.metaKey?"Meta":null}function tw(e,t){return t==="Alt"?e.altKey:t==="Control"?e.ctrlKey:e.metaKey}const FZ=200,wC={set:(e,t)=>setTimeout(e,t),clear:e=>clearTimeout(e)};function BZ(){let e=null;return{press(t){e=kC(t)},holds(t){return e!==null&&tw(t,e)},keyup(t){e&&t===e&&(e=null)},mods(t){e&&!tw(t,e)&&(e=null)}}}function UZ(e,t=wC){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 h=n!==null;n=kC(u),a(),n&&(h?s():o=t.set(()=>{o=null,s()},FZ))},keyup(u){n&&u===n&&c()},mods(u){n&&!tw(u,n)&&c()},end:c}}const HZ=350,WZ=80,KZ=2e3;function qZ(e,t=wC){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},h=()=>{c(),u(),o=null,n&&(n=!1,e(!1))};return{over(f){u(),a=t.set(h,KZ),n||(n=!0,e(!0)),(r==null?void 0:r.id)!==(f==null?void 0:f.id)&&(c(),!(!f||f.id===o)&&(o=null,r={id:f.id,pending:t.set(()=>{r=null,o=f.id,f.land()},HZ)}))},leave(){n&&(s!==null&&t.clear(s),s=t.set(h,WZ))},end:h}}const Of=e=>e>999?"1k+":String(e);function yC({width:e,placement:t="strip"}){const n=t==="screen",r=Di(),o=cp(),s=qu("chat"),a=ut(),c=Qe(),{host:u}=Pr(),h=Xw(),f=h[0]&&jr(h[0].worktree)?h[0]:null,m=f?h.slice(1):h,g=L(J=>ql(J,J.activeRepoId)),y=J=>f&&J.id===f.id&&g?{behind:g.behind,dirty:g.dirty}:J,[,w]=S.useState(0);S.useEffect(()=>{const J=setInterval(()=>w(ye=>ye+1),6e4);return()=>clearInterval(J)},[]);const v=i3(),N=a3(),x=l3(),_=c3(),j=(J,ye,We)=>{J.key!=="ArrowLeft"&&J.key!=="ArrowRight"||J.shiftKey||J.altKey||J.metaKey||J.ctrlKey||(J.preventDefault(),lp([{depth:0,open:ye}],0,J.key)&&a({a:We}))},T=La(),I=L(J=>J.notesPage),R=L(J=>J.clientId),C=L(J=>J.frame),O=L(J=>J.activeRepoId),A=L(J=>J.connected);S.useEffect(()=>{c&&A&&O&&c.send({t:"list-archived",repoId:O})},[c,A,O]);const D=tc(),B=lN(),W=L(J=>J.layout),U=L(J=>J.railOpen),Q=L(J=>J.railPeek),Y=S.useRef(null),[se,H]=S.useState(!1);it([Q],()=>{var J;Q&&!n&&!r&&!((J=Y.current)!=null&&J.matches(":hover"))&&H(!0)}),S.useEffect(()=>{if(!se)return;let J=null;const ye=We=>{if(!J){J={x:We.clientX,y:We.clientY};return}Math.abs(We.clientX-J.x)+Math.abs(We.clientY-J.y)<3||H(!1)};return window.addEventListener("pointermove",ye),()=>window.removeEventListener("pointermove",ye)},[se]);const[$,Z]=S.useState(!1),q=S.useMemo(()=>qZ(Z),[]);S.useEffect(()=>()=>q.end(),[q]);const K=L(J=>{var ye;return((ye=J.dragFiles)==null?void 0:ye.at)==="rail"?J.dragFiles.worktreeId:null}),ne=L(J=>J.focusRail),de=S.useRef(ne),pe=S.useRef(null);it([ne],()=>{if(ne===de.current)return;de.current=ne;const J=requestAnimationFrame(()=>{var ye,We;return(We=(ye=pe.current)==null?void 0:ye.querySelector('[data-state~="current"]'))==null?void 0:We.focus()});return()=>cancelAnimationFrame(J)});const je=(J,ye,We,rt,jt)=>{var P,oe;if(J.key!=="ArrowUp"&&J.key!=="ArrowDown"||J.altKey||J.ctrlKey||J.metaKey)return;J.preventDefault();const Ft=LZ(ye,We,J.key==="ArrowDown");Ft!==null&&(jt(Ft),(oe=(P=pe.current)==null?void 0:P.querySelector(`[${rt}="${Ft}"]`))==null||oe.focus())},_e=L(J=>J.repos),fe=L(J=>J.shipping),te=L(J=>J.rows),re=J=>_e.find(ye=>ye.id===J.repoId)??null,we=J=>O?Uw(J,O,te):null,ue=J=>O&&J.repoId!==O?re(J):null,le=xn("rail"),be=zn(),Ce=ey(),Ne=L(J=>J.home),Ie=J=>{const ye=J.worktree?J.worktree.path:J.path;return Ne&&ye.startsWith(`${Ne}/`)?`~${ye.slice(Ne.length)}`:ye},[Be,Je]=S.useState(!1),[zt,Yt]=S.useState([]),_t=J=>{!Df(J.worktree)||ue(J)||(Je(!0),Yt(ye=>ye.includes(J.worktree.id)?ye.filter(We=>We!==J.worktree.id):[...ye,J.worktree.id]))},qe=()=>{Je(!1),Yt([])};it([Be],()=>{const J=ye=>ye.key==="Escape"&&qe();return Be&&window.addEventListener("keydown",J),()=>window.removeEventListener("keydown",J)});const xt={sock:c,dispatch:a},ht=J=>Fw(be.getState(),J),De=J=>{Je(!0),Yt(ye=>J===D||ye.includes(J)?ye:[...ye,J])},nt=J=>jn(J)?wT(J,re(J),{layout:W,shipping:fe,frame:C,drafted:ht},xt,{...ue(J)?{}:{graft:De},hostname:u}):W5(J,{clientId:R,frame:C},xt,u),[at,Xt]=S.useState(null),Nt=J=>jn(J)?zZ(nt(J)):[],Zt=L(J=>J.left);oT(pe,{rowOf:J=>{if(!n||Be||P_({left:Zt},Date.now()))return null;const ye=J.closest(".slide"),We=ye==null?void 0:ye.dataset.row,rt=We?h.find(jt=>jt.id===We):void 0;return ye&&We&&rt?{el:ye,key:We,rungs:Nt(rt).length}:null},onSlide:Xt,onPick:(J,ye)=>{var jt;const We=h.find(Ft=>Ft.id===J),rt=We?Nt(We)[ye-1]:void 0;if(!(!We||!rt)){if(rt.id==="more"){const Ft=(jt=pe.current)==null?void 0:jt.querySelector(`.slide[data-row="${J}"]`);Ft&&le.openUnder(Ft,()=>nt(We),J)}else if(rt.item&&!rt.item.disabled){const Ft=rt.item.onClick;window.setTimeout(Ft,nT)}}}});const gt=MZ(x,(T==null?void 0:T.id)??null),nr=gt.shown.some(J=>(J.dirty??0)>0),Jt=J=>d.jsxs("button",{type:"button",className:Ke("row row-edge row-quiet rail-disc-item rail-arch-item",(Ce==null?void 0:Ce.owner)==="rail"&&Ce.key===J.id&&"menu-open"),"data-state":hr({current:!n&&(T==null?void 0:T.id)===J.id}),"data-arch":J.id,...Lt(OF(J),void 0,{placement:s,card:!0,detail:IZ(J),aside:RZ(J)}),onClick:()=>a({a:"open-archived",id:J.id}),onKeyDown:ye=>je(ye,gt.shown.map(We=>We.id),J.id,"data-arch",We=>a({a:"open-archived",id:We})),...le.contextMenu(()=>Kf(J,{clientId:R,frame:C},xt),J.id),children:[d.jsxs("span",{className:"rail-gut",onClick:r?ye=>{ye.stopPropagation(),le.openUnder(ye.currentTarget,()=>Kf(J,{clientId:R,frame:C},xt),J.id)}:void 0,children:[d.jsx("span",{className:"rail-at row-dim",children:fr(J.archivedAt)}),d.jsx("span",{className:"rail-more",...Lt("Actions"),onClick:ye=>{ye.stopPropagation(),le.openUnder(ye.currentTarget,()=>Kf(J,{clientId:R,frame:C},xt),J.id)},children:d.jsx(mt,{name:"more"})})]}),d.jsx("span",{className:"branch",children:J.title}),nr&&d.jsx("span",{className:"rail-counts",children:d.jsx("span",{className:"rail-count row-dim","data-tip":J.dirty?`${J.dirty} uncommitted, kept`:void 0,children:J.dirty?`~${Of(J.dirty)}`:""})}),J.auto?d.jsx("span",{className:"rail-glyph rail-auto row-dim",children:d.jsx(mt,{name:"clock",className:"icon-inline"})}):d.jsx("span",{className:"dot"}),n&&d.jsx("span",{className:"rail-at rail-at-end row-dim",children:fr(J.archivedAt)})]},J.id),Rn=[...h,...v].map(y),Kn=["ahead","dirty","behind"].filter(J=>Rn.some(ye=>(ye[J]??0)>0)),un=J=>{const ye=Kn.findIndex(We=>(J[We]??0)>0);return new Set(ye<0?[]:Kn.slice(ye))},vn=J=>{var sr;const ye=jn(J)?J:null,We=!!ye&&jr(ye.worktree),rt=y(J),jt=_e.find(Pt=>Pt.id===J.repoId)??null,Ft=jt?Oh(jt):"main",P=jt&&HI(jt)&&(g!=null&&g.fetchedAt)?` as of ${Gh(g.fetchedAt)}`:"",oe=un(rt),$e=!!rt.ahead&&!rt.dirty,Fe=J.id,Rt=(Ce==null?void 0:Ce.owner)==="rail"&&Ce.key===Fe,Gt=ye?we(ye):null,Re=ye?ue(ye):null,He=ye&&!Re?sz(ye,te,x):null,Ze=ye&&!Re&&Be&&Df(ye.worktree)&&Fe!==D,Qt=ye&&ye.worktree.kind==="worktree"&&!Re?{title:ye.worktree.title,branch:ye.worktree.branch}:null,Wt=Vh(J,(sr=fe[Fe])==null?void 0:sr.op),En=d.jsxs("button",{type:"button",className:Ke("row row-edge",ye?"rail-item":"row-quiet rail-disc-item",n&&$Z(J,Wt)&&"row-quiet",Rt&&"menu-open",K===Fe&&"drop-over"),"data-state":hr({current:!n&&Fe===D&&!T&&!I,checked:zt.includes(Fe)}),...ye?Lt(B?Vf:g_(J,Wt,lh(re(ye))),void 0,{placement:s,card:!0,aside:DZ(J),detail:jr(ye.worktree)?AZ(h,x,g,Ft):[...Re?[Gt?NZ(Re.name,Gt.worktree.title):TZ(Re.name)]:He?[gC(He)]:[],...CZ(ye)],dot:B?void 0:m_(J,Wt)}):Lt(B?Vf:J.locked?`Held by ${J.lockReason??"another tool"}`:_Z,void 0,{placement:s,card:!0,detail:Ie(J),dot:B||J.locked?void 0:"discovered"}),"data-wt":Fe,draggable:o&&Qt!==null,onDragStart:Qt!==null?Pt=>Tu(Pt,{kind:"worktree",worktreeId:Fe,...Qt}):void 0,onDragEnd:()=>Yu(be),onKeyDown:Pt=>{if(Be)return;const bn=(ye?h:v).map(fn=>fn.id);je(Pt,bn,Fe,"data-wt",fn=>a({a:"activate",id:fn}))},onClick:Pt=>{ye&&!Re&&(Be||Pt.shiftKey)?Fe===D?Je(!0):_t(ye):We&&!n?a({a:"open-draft"}):(a({a:"activate",id:Fe}),ye&&!r&&a({a:"walked"}))},...le.contextMenu(()=>nt(J),Fe),children:[d.jsx("span",{className:"rail-gut",onClick:r&&!Be?Pt=>{Pt.stopPropagation(),le.openUnder(Pt.currentTarget,()=>nt(J),Fe)}:void 0,children:Ze?d.jsx("input",{type:"checkbox",className:"rail-graft-check",checked:zt.includes(Fe),readOnly:!0,tabIndex:-1}):!Be&&d.jsxs(d.Fragment,{children:[ye&&!We&&d.jsx("span",{className:"rail-at row-dim",children:fr(Ta(ye.worktree))}),d.jsx("span",{className:"rail-more",...Lt("Actions"),onClick:Pt=>{Pt.stopPropagation(),le.openUnder(Pt.currentTarget,()=>nt(J),Fe)},children:d.jsx(mt,{name:"more"})})]})}),We?d.jsxs("span",{className:"branch rail-main-label",children:[d.jsx(mt,{name:"plus",className:"icon-inline"}),"new worktree"]}):d.jsx("span",{className:Ke("branch",(ye==null?void 0:ye.worktree.unnamed)&&"row-dim"),children:rk(J,ye?re(ye):null)}),(ye==null?void 0:ye.worktree.mode)&&ye.worktree.mode!=="auto"&&d.jsx("span",{className:"rail-badge badge-mode","data-tip":`${ye.worktree.mode} mode: the agent waits for you`,children:ye.worktree.mode}),ye&&(()=>{const Pt=re(ye),bn=pT(ye.worktree,Pt);return bn&&bn!==(Pt==null?void 0:Pt.config.defaultProfile)?d.jsx("span",{className:"rail-badge badge-profile","data-tip":`runs the ${bn} profile`,children:bn}):null})(),Re&&d.jsx("span",{className:"rail-guest row-dim",children:Re.name}),d.jsxs("span",{className:"rail-counts",children:[oe.has("ahead")&&d.jsx("span",{className:"rail-count badge-ahead","data-tip":rt.ahead?`${rt.ahead} ahead of ${Ft}`:void 0,children:rt.ahead?`+${Of(rt.ahead)}`:""}),oe.has("dirty")&&!$e&&d.jsx("span",{className:"rail-count badge-dirty","data-tip":rt.dirty?`${rt.dirty} uncommitted${We?" on main":""}`:void 0,children:rt.dirty?`~${Of(rt.dirty)}`:""}),oe.has("behind")&&d.jsx("span",{className:"rail-count rail-behind row-dim","data-tip":rt.behind?`${rt.behind} behind ${We?"origin":Ft}${We?"":P}`:void 0,children:rt.behind?Of(rt.behind):""}),n&&ye&&d.jsx("span",{className:"rail-at row-dim",children:We?"":fr(Ta(ye.worktree))})]}),(()=>{if(Wt)return d.jsx("span",{className:"dot background"});if(J.locked)return d.jsx("span",{className:"rail-glyph rail-lock row-dim",children:d.jsx(mt,{name:"lock",className:"icon-inline"})});if(!ye)return d.jsx("span",{className:"dot discovered"});const Pt=Be||B?null:k_(J.procs),bn=J.unseen?" unseen":"",fn=Fs(J);return We&&!Pt&&fn!=="crashed"&&!B?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(mt,{name:"plus"})})]}):!Pt||fn!=="crashed"?d.jsx("span",{className:`dot ${fn}${bn}`}):d.jsx("span",{className:`dot crashed clickable${bn}`,...Lt(Pt.tip),onClick:ie=>{ie.stopPropagation(),a({a:"activate",id:Fe}),a({a:"term-stream",id:Fe,stream:Pt.stream})}})})(),n&&d.jsx("span",{className:"rail-say row-dim",children:ew(J,{needsSetup:lh(ye?re(ye):null),path:Ie(J),op:Wt})})]},Fe);if(!n||!ye)return En;const Sn=(at==null?void 0:at.key)===Fe?at.step:null,Ct=Sn===null?null:Nt(J)[Math.max(0,Sn-1)],nn=!!Ct&&Sn!==null&&Sn>0&&(Ct.id==="more"||!!Ct.item&&!Ct.item.disabled);return d.jsxs("div",{className:"slide","data-row":Fe,children:[En,Ct&&d.jsxs("span",{className:"slide-verb","data-rung":nn?Ct.id:void 0,"aria-hidden":"true",children:[d.jsx("span",{className:"slide-word",children:Ct.label}),d.jsx(mt,{name:Ct.icon})]})]},Fe)};return d.jsx("div",{ref:Y,className:Ke("rail",n&&"rail-screen",!n&&(Be||(Ce==null?void 0:Ce.owner)==="rail"||Q||$)&&"hold",se&&"quiet",(n||U)&&"pinned",B&&"offline"),style:e!==void 0&&!n?{"--rail-width":`${e}px`}:void 0,onClick:r&&!n&&!U?J=>{J.target instanceof Element&&J.target.closest("button, .rail-gut")||a({a:"toggle-rail"})}:void 0,onDragOver:J=>{var jt;if(!kk(J.dataTransfer))return;const ye=J.target instanceof Element?(jt=J.target.closest("[data-wt]"))==null?void 0:jt.dataset.wt:void 0,We=ye?[...h,...v].find(Ft=>Ft.id===ye):void 0;if(!We||Be||We.id===D)return q.over(null);const rt=!n&&jn(We)&&jr(We.worktree);q.over({id:We.id,land:()=>a(rt?{a:"open-draft"}:{a:"activate",id:We.id})})},onDragLeave:q.leave,onDrop:q.end,children:d.jsx("div",{className:"rail-panel","data-tip":B?Vf:void 0,"data-tip-placement":"follow",children:d.jsxs("div",{className:"rail-list",ref:pe,children:[f&&!n&&vn(f),m.map(vn),Be&&d.jsxs("div",{className:"rail-graft",children:[(()=>{const J=h.find(rt=>rt.worktree.id===D&&Df(rt.worktree)&&!ue(rt)),ye=zt.filter(rt=>rt!==(J==null?void 0:J.worktree.id)),We=ye.map(rt=>{var jt;return((jt=h.find(Ft=>Ft.worktree.id===rt))==null?void 0:jt.worktree.title)??rt}).join(", ");return d.jsxs(Pe,{size:"md",tone:"primary",disabled:!J||ye.length===0,"data-tip":J?`Merge the checked worktrees into ${J.worktree.title} and remove them`:"Select a worktree to graft onto",onClick:()=>{J&&window.confirm(`Graft ${We} onto ${J.worktree.title}?
275
-
276
- Their branches are merged in, then their directories and branches are removed.`)&&(c==null||c.send({t:"graft",targetId:J.worktree.id,sourceIds:ye}),qe())},children:["graft ",ye.length]})})(),d.jsxs(Pe,{size:"md",disabled:!zt.some(J=>{var ye;return(((ye=h.find(We=>We.worktree.id===J))==null?void 0:ye.behind)??0)>0}),"data-tip":"Pull main into every selected worktree that's behind",onClick:()=>{for(const J of zt){const ye=h.find(We=>We.worktree.id===J);((ye==null?void 0:ye.behind)??0)>0&&$i(c,a,{t:"sync-main",worktreeId:J})}qe()},children:[d.jsx(mt,{name:"pull",className:"icon-inline"})," sync"]}),d.jsx(Pe,{size:"md",tone:"danger",disabled:zt.length===0,"data-tip":"Archive all selected worktrees; their chats and work are kept",onClick:()=>{window.confirm(`Archive ${zt.length} worktree(s)?
277
-
278
- Their directories and branches go. The chats, commits and any uncommitted changes are kept, and each can be restored.`)&&(Fl(c,a,zt),qe())},children:"archive…"}),d.jsx(It,{icon:"close",label:"Cancel",hint:"esc",onClick:qe})]}),!Be&&v.length>0&&d.jsxs(d.Fragment,{children:[d.jsxs("button",{className:"section-title section-row section-fold rail-disc-head","aria-expanded":N,...Lt(`${v.length} worktree${v.length===1?"":"s"} here that Toyon did not make`,void 0,{placement:s}),onClick:()=>a({a:"toggle-discovered"}),onKeyDown:J=>j(J,N,"toggle-discovered"),children:[d.jsx("span",{className:"rail-gut",children:d.jsx(mt,{name:"caret",className:Ke("icon-inline disc-caret",!N&&"shut")})}),d.jsx("span",{className:"rail-label",children:"discovered"})]}),N&&v.map(vn)]}),!Be&&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":_,...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:J=>j(J,_,"toggle-archived"),children:[d.jsx("span",{className:"rail-gut",children:d.jsx(mt,{name:"caret",className:Ke("icon-inline disc-caret",!_&&"shut")})}),d.jsx("span",{className:"rail-label",children:"archived"})]}),_&&gt.shown.map(Jt),_&&gt.rest>0&&O&&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:[gt.rest," more"]}),d.jsx("span",{className:"dot"})]})]})]})})})}const Th=["home","chat","preview","changes"],ZZ=(e,t)=>Th.indexOf(t)<Th.indexOf(e)?"left":"right";function GZ(e,t,n,r=null){if(e==="home")return t!=="left"||!r||r==="home"?null:r==="preview"&&!n?"chat":r;const o=Th.filter(a=>a!=="preview"||n),s=o.indexOf(e);return s<0?null:o[s+(t==="right"?-1:1)]??null}function VZ({screen:e,tabs:t,fold:n,beside:r=!1,away:o=!1}){const s=ut(),a=ks(),c=Bs(),u=L(pe=>pe.reading),h=L(pe=>pe.typing),f=f3(),m=nc(),g=L(pe=>pe.repos),y=Us(),w=tc(),v=La(),N=Qw(),x=Xw(),_=lN(),j=L(pe=>pe.connectFailure),T=L(pe=>pe.recalledAt??pe.heardAt);ji(_&&T!==null?T:void 0);const I=SZ(j,T),R=tN(),C=t8(x,w,R),O=x.find(pe=>jr(pe.worktree)),A=e==="home",D=!A&&!v&&!!y&&jr(y.worktree),B=L(pe=>{var je;return D&&y?Vh(y,(je=pe.shipping[y.id])==null?void 0:je.op):null}),W=Kw().length,U=a.displayName(c.origin),Q=A?(f==null?void 0:f.name)??U:D?mC:(v==null?void 0:v.title)??(y==null?void 0:y.worktree.title)??(N==null?void 0:N.name)??null,Y=x.filter(pe=>!jr(pe.worktree)).length,se=Y===0?"no worktrees yet":`${Y} ${Y===1?"worktree":"worktrees"}`,H=L(pe=>pe.sharing),$=A?_?I:H||(f&&W>1?`${U} · ${se}`:se):v?MT(v):_?I:D?B?Iw(B):(f==null?void 0:f.name)??null:y?ew(y,{needsSetup:lh(m),path:y.worktree.path,at:fr(Ta(y.worktree))}):N?ew(N,{needsSetup:!1,path:N.path}):null,Z=!A&&!v&&!!y&&Fs(y)==="waiting",q=L(pe=>{var je;return((je=pe.overlay)==null?void 0:je.kind)==="projects"&&pe.overlay.form==="pill"})&&!r,K=L(pe=>{var je;return((je=pe.overlay)==null?void 0:je.kind)==="commands"})&&!r,ne=d.jsxs("div",{className:"phone-title",children:[A&&(g.length>1||W>1)?d.jsxs("span",{className:"phone-drop phone-switch",children:[d.jsxs(Pe,{tone:"chrome",on:q,onClick:()=>s({a:"toggle",overlay:{kind:"projects",form:"pill"}}),children:[d.jsx("span",{className:"phone-name",children:Q}),d.jsx(mt,{name:"caret",className:"icon-inline"})]}),q&&d.jsx(tv,{form:"pill",anchored:{margin:6}})]}):d.jsx("span",{className:"phone-name",children:Q}),$&&d.jsx("span",{className:Ke("phone-sub",Z&&"phone-sub-asks"),children:$})]}),de=C&&d.jsxs(Pe,{size:"md",tone:"primary",onClick:()=>{const pe=n8(x,w,R);if(!pe)return;if(pe.origin===null)return s({a:"activate",id:pe.activate});const je=a.get(pe.origin);je&&(je.store.dispatch({a:"activate",id:pe.activate}),a.activate(pe.origin))},children:[C.n," ",C.tier]});return d.jsxs("div",{className:"phone-bar",children:[d.jsxs("div",{className:"phone-bar-row",children:[!A&&d.jsx(It,{icon:"back",label:"Worktrees",tone:"chrome",onClick:()=>s({a:"screen",to:"home"})}),t?d.jsx("div",{className:"phone-tabs",children:t}):ne,!t&&de,A&&O&&d.jsx(It,{icon:"plus",label:"New worktree",tone:"chrome",onClick:()=>s({a:"activate",id:O.id})}),d.jsxs("span",{className:"phone-drop",children:[d.jsx(It,{icon:"more",label:"Menu",tone:"chrome",on:K,onClick:()=>s({a:"toggle",overlay:{kind:"commands"}})}),K&&d.jsx(q$,{anchored:{flip:"align",margin:6},trailing:d.jsx(It,{icon:"close",label:"Close",tone:"chrome",onClick:()=>s({a:"close"})})})]})]}),t&&!n&&d.jsx("div",{className:"phone-title-seat","data-away":u||h||o||void 0,children:d.jsxs("div",{className:"phone-title-strip",children:[ne,de]})})]})}const Yf="toyonDepth",vC="toyonOver",Mg=-1;function Lg(e){return e.frame!=="phone"||!e.heard&&e.recalledAt===null?null:e.screen!=="home"&&($o(e,e.activeId)!==null||Bo(e)!==null)?1+(e.editor?1:0):0}const bC=(()=>{const e=new Set;return{watch(t){return e.add(t),()=>e.delete(t)},tell(t){for(const n of e)n(t)}}})(),Pg=e=>{const t=e&&typeof e=="object"?e[Yf]:void 0;return typeof t=="number"?t:null},YZ=e=>!!e&&typeof e=="object"&&e[vC]===!0;function XZ(e,t=window,n=Vl,r=bC){const o=t.history;let s=Pg(o.state)??Mg,a=Pg(o.state)!==null,c=null;const u=()=>{const j=n.open();c&&!j.includes(c)&&(c=null);for(let T=j.length-1;T>=0;T--){const I=j[T];if(I!=null&&I.dismiss&&I!==c)return I}return null};let h=!1;const f=()=>{const j=Lg(e.getState());if(j===null||h)return;a||(o.replaceState({[Yf]:Mg},""),a=!0);const T=j+(u()?1:0);if(T!==s)if(T>s){for(let I=s+1;I<=T;I++)o.pushState({[Yf]:I,[vC]:I>j},"");s=T}else o.go(-1),h=!0};let m=!1;const g=()=>{m||(m=!0,queueMicrotask(()=>{m=!1,f()}))},y=(j,T)=>{const I=u();if(I){c=I,n.shut(I);return}const R=T===0?"home":j.screen;e.dispatch({a:"screen",to:R})},w=j=>{const T=h;h=!1,s=Pg(j.state)??Mg;const I=e.getState(),R=Lg(I);if(R===null)return;if(s<0){o.pushState({[Yf]:0},""),s=0,f();return}if(T){f();return}const C=R+(u()?1:0);C!==s&&(C>s?y(I,s):C===0&&I.activeId&&!YZ(j.state)&&e.dispatch({a:"screen",to:"chat"}),f())},v=j=>{if(h){h=!1,f();return}const T=e.getState(),I=Lg(T);I===null||I===0||T.screen==="preview"&&!T.editor&&I===1||j.dir==="forward"||y(T,I+(u()?1:0)-1)};t.addEventListener("popstate",w);const N=e.subscribe(f),x=n.watch(g),_=r.watch(v);return f(),()=>{t.removeEventListener("popstate",w),N(),x(),_()}}function QZ({gated:e,active:t,url:n,onTouch:r}){const o=Qh(t),s=H6(Bs(),o?n:null,e),a=S.useRef(null),c=S.useRef(r);return c.current=r,S.useEffect(()=>{if(!s)return;const u=new URL(s,location.href).origin,h=f=>{var y,w;const m=(y=a.current)==null?void 0:y.contentWindow;if(!m||f.source!==m||f.origin!==u||!((w=f.data)!=null&&w.__toyon))return;const g=YS(f.data);(g==null?void 0:g.type)==="traversed"?bC.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",h),()=>window.removeEventListener("message",h)},[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(ws,{wide:!0,children:d.jsx("p",{className:"status-line",children:Aw(t)})})})}function JZ(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 eG=sh(),tG=!ZN(),nG={current:null};function rG(){const e=S.useRef(null),t=S.useRef(null),n=S.useRef(null);t3(e),n3(e);const r=ut(),o=L(de=>de.screen),s=Us(),a=La(),c=Qw(),u=L(de=>de.editor),h=L(de=>de.left),f=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),N=Di(),x=Bs(),_=ks(),[j,T]=S.useState(null),[I,R]=S.useState(null),C=L(de=>de.incompatible),O=lT({connected:g,heard:y,standing:w,connectFailure:v,hasToken:x.serving?eG:!0,projectChord:Dt("project"),title:(s==null?void 0:s.worktree.title)??null,machine:x.serving?null:_.displayName(x.origin)}),A=o!=="home"&&(s!==null||a!==null||c!==null),D=!A&&j!==null&&j!=="home",B=!m&&!a?s:null,W=A||D?B:null,{host:U}=Pr(),Q=W?h_(W.worktree.id,W.worktree.proxyPort,f,U):null,Y=o==="preview"&&!W?"chat":o,se=JZ({incompatible:C,serving:x.serving,machine:_.displayName(x.origin),said:O!==null,onWorktree:A,editor:u!==null,tab:Y}),H=se.kind==="home"?"home":se.kind==="tab"?se.tab:null,$=W!==null&&Q!==null,Z=N5(tG?e:nG,{take:(de,pe)=>{if(j!==null)return null;const je=se.kind==="tab"?se.tab:se.kind==="home"?"home":null;if(!je)return null;const _e=je==="home"?P_({left:h},Date.now()):null;if(pe==="left"&&!_e&&de.closest(".slide"))return null;const fe=GZ(je,pe,B!==null,_e);return fe?(T(fe),(fe==="home"||je==="home"?t:n).current):null},onSettle:de=>{de&&j&&R(j)},onEnd:de=>{de&&j&&r({a:"screen",to:j}),T(null),R(null)}}),q=(de,pe)=>d.jsx(VZ,{screen:de==="home"?"home":"chat",beside:pe,fold:de!=="chat"||u!==null,away:!pe&&j!==null&&j!=="home",tabs:de!=="home"&&O===null&&d.jsx(Vu,{fill:!0,segmented:!0,owner:"phone-tabs",label:"worktree",items:ne,current:I&&I!=="home"?I:de,onPick:je=>r({a:"screen",to:je})})}),K=se.kind==="updated"?d.jsx(aT,{foreign:se.foreign??void 0}):se.kind==="say"&&O?d.jsx(ws,{wide:!0,children:d.jsx("p",{className:Ke("status-line",O.live&&"live-text"),children:O.text})}):se.kind==="editor"&&u?d.jsx(lC,{editor:u,placement:"screen"}):null,ne=[{id:"chat",label:"chat"},...W&&Q?[{id:"preview",label:"preview",trail:d.jsx(It,{icon:"external",label:"Open in browser",tone:"chrome",onClick:()=>W6(x,Q,wk(x,f))})}]:[],{id:"changes",label:"code"}];return d.jsxs("div",{ref:e,className:"app phone","data-chat-side":"left","data-touch":N||void 0,"data-hover":!N||void 0,children:[d.jsx(XN,{}),d.jsx(tT,{}),d.jsx("div",{className:"phone-screen",children:d.jsxs("div",{className:"center-root",children:[d.jsxs("div",{className:"phone-track",ref:t,children:[(!A||j==="home")&&d.jsxs("div",{className:"phone-face","data-side":A?"left":void 0,children:[q("home",A),!A&&H===null?K:d.jsx(yC,{placement:"screen"})]},"home"),(A||D)&&d.jsxs("div",{className:"phone-face","data-side":D?"right":void 0,children:[q(D&&j?j:Y,D),d.jsxs("div",{className:"phone-track",ref:n,children:[H===null&&d.jsx("div",{className:"phone-face",children:K},"cover"),Th.map(de=>{if(de==="home")return null;const pe=D?de===j:de===H,je=de===j&&!pe;return!pe&&!je&&!(de==="preview"&&$)?null:d.jsx("div",{className:"phone-face",hidden:!pe&&!je,"data-side":je&&H?ZZ(H,de):void 0,children:de==="chat"?d.jsx(mu,{placement:"screen",archived:a,found:c}):de==="changes"?d.jsx(IT,{placement:"screen"}):W&&Q?d.jsx(QZ,{gated:wk(x,f),active:W,url:Q,onTouch:Z},W.worktree.id):null},de)})]})]},"worktree")]}),d.jsx(pC,{})]})})]})}function oG(){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 sG(){if(cy()!=="phone")return"surface0";try{const e=sessionStorage.getItem(tt.ground);if(e==="surface0"||e==="surface1")return e}catch{}return"surface1"}function xC(e,t={}){var s,a;const n=document.documentElement;for(const[c,u]of Object.entries(yD(e)))n.style.setProperty(c,u);n.style.colorScheme=e.kind,n.dataset.theme=e.kind;const r=t.ground??sG();n.dataset.ground=r;const o=cy()==="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 EC(e){const t=Sw(e);return{type:"theme",accent:t,accentFg:$D(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 lG(){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 cG(e){try{localStorage.setItem(tt.daylight,JSON.stringify(e))}catch{}}function uG(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 dG(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 LE(e,t){return t==="reading"?"Reading the release notes":`No release notes could be read from Toyon ${e}.`}function fG(){const e=Pr(),t=L(s=>s.version),[n,r]=S.useState(void 0);S.useEffect(()=>{let s=!0;return UD(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(ev,{html:o})}):d.jsx(ws,{wide:!0,children:d.jsx("p",{className:"status-line",children:n===void 0?d.jsx("span",{className:"live-text",children:LE(t,"reading")}):LE(t,"missing")})})}function nw(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 rw(e){return[{id:"copy-value",label:"copy value",detail:e,onClick:()=>tn(e)}]}function hG(e,t,{sock:n},r){return t?Wn([[{id:"source",label:"open source",onClick:r}],Uo(()=>n==null?void 0:n.send({t:"reveal",worktreeId:e.id,path:t}),mo(n)),[{id:"copy-path",label:"copy path",onClick:()=>tn(t)}]]):[]}function Fu(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 pG(e){const t=/^#([0-9a-f]{3,8})$/i.exec(e.trim());return t?t[1].length===4||t[1].length===8:!1}function PE([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 SC(e,t){if(pG(e))return null;const n=Fu(e);if(!n)return null;const r=Fu(t);if(!r)return null;const[o,s]=[PE(n),PE(r)];return`${((Math.max(o,s)+.05)/(Math.min(o,s)+.05)).toFixed(2)}:1`}function mG({worktreeId:e,height:t,full:n,onToggleFull:r,onDragStart:o}){const s=ut(),a=Qe(),c=L(h=>Zr(h,e).design);S.useEffect(()=>{c||a==null||a.send({t:"design-scan",worktreeId:e})},[c,e,a]),S.useEffect(()=>()=>cn.post(e,{type:"highlight-clear"}),[e]);const u={outline:h=>cn.post(e,h),clear:()=>cn.post(e,{type:"highlight-clear"}),open:h=>Dn({dispatch:s},{worktreeId:e,path:h})};return d.jsx(Jy,{kind:"design",className:Ke("design-pane",n&&"full"),height:n?void 0:t,resizable:!n,onDragStart:o,title:c?d.jsx("span",{children:yG(c)}):void 0,onClose:()=>s({a:"toggle-design"}),closeHint:Dt("design"),full:n,onToggleFull:r,actions:d.jsxs(Pe,{variant:"outline",onClick:()=>a==null?void 0:a.send({t:"design-scan",worktreeId:e}),"data-tip":"Scan this worktree again",children:[d.jsx(mt,{name:"reload",className:"icon-inline"})," rescan"]}),children:c?d.jsxs("div",{className:"design-body",style:wG,onMouseLeave:u.clear,children:[c.tokens.length===0&&c.literals.length>0?d.jsx(_G,{literals:c.literals,outline:u.outline,clear:u.clear}):d.jsx(EG,{tokens:c.tokens,coverage:c.coverage,outline:u.outline,clear:u.clear}),d.jsx(OG,{index:c,outline:u.outline,clear:u.clear,onOpen:u.open}),d.jsx(MG,{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 gG=720,kG=132,wG={"--design-column":`${gG}px`,"--design-cell":`${kG}px`};function yG(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 Ml=e=>`${e} use${e===1?"":"s"}`;function $p({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 jh({children:e}){return d.jsx("p",{className:"design-gap",children:e})}const vG=[{kind:"font",label:"type"},{kind:"color",label:"color"},{kind:"length",label:"size & radius"},{kind:"shadow",label:"shadow"},{kind:"other",label:"computed"}];function bG(e){return e.find(t=>t.kind==="color"&&Fu(t.resolved??t.value)!==null)}function xG(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 EG({tokens:e,coverage:t,outline:n,clear:r}){const o=bG(e),s=o&&(o.resolved??o.value),a=new Map;for(const u of e){const h=(u.resolved??u.value).trim().toLowerCase();a.set(h,[...a.get(h)??[],u.name])}const c=u=>(a.get((u.resolved??u.value).trim().toLowerCase())??[]).filter(h=>h!==u.name);return d.jsx($p,{title:"Tokens",children:e.length===0?d.jsx(jh,{children:xG(t)}):vG.map(({kind:u,label:h})=>{const f=e.filter(g=>g.kind===u);if(f.length===0)return null;const m=NC(f.map(g=>g.value));return d.jsxs("div",{className:"design-group",children:[u!=="font"&&d.jsx("span",{className:"design-group-name",children:h}),u==="font"?d.jsx(TC,{groups:CG(f),outline:n,clear:r}):d.jsx("div",{className:"design-breakout",style:_C(f.length),children:d.jsx("div",{className:"design-grid",children:f.map(g=>{const y=g.resolved??g.value,w=g.kind==="color"&&s?SC(y,s):null;return d.jsx(jC,{kind:g.kind,name:g.name,lines:g.resolved?[g.value,g.resolved]:[g.value],actual:y,ratio:w,largest:m,tipText:IG(g,w,o,c(g)),menu:()=>nw(g.name,y),outline:n,clear:r},g.name)})})})]},u)})})}const SG=[{role:"color",kind:"color",label:"color"},{role:"radius",kind:"length",label:"radius"},{role:"shadow",kind:"shadow",label:"shadow"}];function _G({literals:e,outline:t,clear:n}){const r=e.find(s=>s.ground&&Fu(s.value)!==null),o=AG(e);return d.jsxs($p,{title:"Values",note:"written out in the rules; no custom properties",children:[o.length>0&&d.jsx("div",{className:"design-group",children:d.jsx(TC,{groups:o,outline:t,clear:n})}),SG.map(({role:s,kind:a,label:c})=>{const u=e.filter(f=>f.role===s);if(u.length===0)return null;const h=NC(u.map(f=>f.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:_C(u.length),children:d.jsx("div",{className:"design-grid",children:u.map(f=>{const m=a==="color"&&r?SC(f.value,r.value):null;return d.jsx(jC,{kind:a,name:f.value,lines:[Ml(f.uses)],actual:f.value,ratio:m,largest:h,tipText:RG(f,m,r),menu:()=>rw(f.value),outline:t,clear:n},f.value)})})})]},s)})]})}function _C(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 NC(e){return e.reduce((t,n)=>Math.max(t,Math.abs(Number.parseFloat(n))||0),0)}const NG=["color","background-color","border-top-color","border-right-color","border-bottom-color","border-left-color","outline-color"];function TG(e,t){if(!e)return[];const n=getComputedStyle(e);return t.map(r=>[r,n.getPropertyValue(r)])}const ow=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:ow(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:ow(t[4]??""),size:n,lead:o}}function Dg(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 $G(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 CG(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}
279
- ${o.actual}`:void 0,menu:()=>o?nw(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}
280
- ${s.actual}`,menu:()=>nw(s.token.name,s.actual)}))}})}function AG(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":ow(o);return{family:a,stack:o,name:s?Ml(s.uses):void 0,label:a,tipText:s?`${s.value}
281
- ${Ml(s.uses)}: ${s.selectors.join(", ")}`:void 0,menu:()=>s?rw(s.value):[],rows:n.filter(c=>(c.family??"initial")===o).sort((c,u)=>Dg(u.value)-Dg(c.value)).map(c=>{const u=Dg(c.value),h=$G(c.lead,u),f=c.value.endsWith("px")?`${u}`:c.value;return{key:`${c.value}/${c.lead??""}`,sample:`${a} ${f}${h===null?"":`/${h}`}`,style:{fontFamily:o,fontSize:c.value,lineHeight:c.lead},name:Ml(c.uses),label:c.value,tipText:`${c.value}${c.lead?` / ${c.lead}`:""}
282
- ${Ml(c.uses)}: ${c.selectors.join(", ")}`,menu:()=>rw(c.value)}})}})}function TC({groups:e,outline:t,clear:n}){const r=(s,a,c)=>t({type:"highlight-computed",props:TG(s.currentTarget.querySelector(".design-face-sample"),a?["font-family","font-size","line-height"]:["font-family"]),match:"all",label:c}),o=xn("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 jC({kind:e,name:t,lines:n,actual:r,ratio:o,largest:s,tipText:a,menu:c,outline:u,clear:h}){const f=e==="color"&&Fu(r)!==null,m=e==="length"?Number.parseFloat(r):Number.NaN,g=xn("design");return d.jsxs("div",{className:"design-cell","data-kind":e,...g.contextMenu(c),onMouseEnter:f?y=>{const w=y.currentTarget.querySelector(".design-fill"),v=w?getComputedStyle(w).backgroundColor:"";u({type:"highlight-computed",props:NG.map(N=>[N,v]),match:"any",label:t})}:void 0,onMouseLeave:f?h:void 0,...Lt(a),children:[e==="color"&&d.jsx("div",{className:"design-sample",children:f&&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 IG(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(`
283
- `)}function RG(e,t,n){const r=[e.value,`${Ml(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(`
284
- `)}function $C({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 OG({index:e,outline:t,clear:n,onOpen:r}){const{components:o,typed:s}=e;if(o.length===0)return null;const a=o.filter(h=>h.imports>=2),c=o.filter(h=>h.imports<2),u=h=>d.jsx(CC,{count:h.imports,name:h.name,path:h.path,onEnter:()=>t({type:"highlight-file",path:h.path,ranges:null}),onLeave:n,onOpen:()=>r(h.path),children:h.variants.length>0&&d.jsx("span",{className:"design-variants",children:h.variants.map(f=>d.jsxs("span",{className:"design-variant",children:[f.prop,": ",f.values.join(" · ")]},f.prop))})},`${h.path}:${h.name}`);return d.jsxs($p,{title:"Components",note:`${a.length} reused of ${o.length}`,children:[!s&&d.jsx(jh,{children:"No TypeScript in this project, so the values each prop allows are not listed."}),d.jsx($C,{shared:a.map(u),rest:c.map(u)})]})}function MG({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),h=c.filter(g=>g.unwrapped).length,f=o.length?`${c.length} reused of ${o.length}`+(h?`, ${h} with no component of their name`:""):void 0,m=g=>d.jsx(LG,{cls:g,outline:t,clear:n,onOpen:r},g.name);return d.jsx($p,{title:"Classes",note:f,children:o.length===0?d.jsx(jh,{children:"No stylesheet in this project defines a class. Utility-first CSS generates its own."}):a.length===0?d.jsx(jh,{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($C,{shared:c.map(m),rest:u.map(m)})})}function LG({cls:e,outline:t,clear:n,onOpen:r}){return d.jsx(CC,{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 CC({count:e,name:t,path:n,onEnter:r,onLeave:o,onOpen:s,children:a}){const c=Us(),u=Qe();ut();const h=xn("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,...h.contextMenu(()=>c?hG({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 PG({worktreeId:e,procs:t,borrowed:n,login:r,current:o,onRestart:s}){const a=Qe();ut();const c={sock:a},u=(f,m)=>d.jsx(It,{icon:"reload",label:m,onClick:()=>s(f)}),h={id:Ds,label:"login",tip:Lt("The agent's login; it closes once you are in",void 0,{placement:"top"}),trail:u(Ds,"Run the login again")};return r&&o===Ds?[h]:[{id:Do,label:"shell",tip:Lt("A shell in this worktree",void 0,{placement:"top"}),menu:()=>GT(e,c),trail:u(Do,"Restart the shell")},...r?[h]:[],...t.map(f=>({id:f.name,label:f.name,lead:d.jsx("span",{className:`dot ${f.status}`}),tip:Lt(T4(f.status),void 0,{placement:"top",dot:f.status,name:f.name,detail:f.command,aside:[`:${f.port}`]}),menu:()=>yy(f,e,c),trail:u(f.name,`Restart ${f.name}`)})),...n.map(f=>({id:f,label:f,lead:d.jsx("span",{className:"dot borrowed"}),tip:Lt(`${f} runs on main for every worktree; this one reaches it at its usual address`,void 0,{placement:"top"})}))]}const DG=S.lazy(()=>Yk(()=>import("./XTerm-B_hkTWne.js"),__vite__mapDeps([3,4]))),zG=[];function FG({worktreeId:e,opened:t,height:n,onDragStart:r}){const o=ut(),s=Qe(),a=ep(),c=L(B=>B.connected),u=L(B=>B.focusTerm),h=Us(),f=(h==null?void 0:h.procs)??[],m=(h==null?void 0:h.borrowed)??zG,g=(h==null?void 0:h.login)??!1,y=At(e,"termStream"),w=L(B=>{var W;return((W=B.termRun)==null?void 0:W.id)===e&&y===Do?B.termRun.command:null}),[v,N]=S.useState(null),x=m.includes(y);S.useEffect(()=>{y===Do||(y===Ds?g:f.some(W=>W.name===y)||m.includes(y))||o({a:"term-stream",id:e,stream:Do})},[f,m,g,y,e,o]);const _=B=>{B!==y&&(N(null),o({a:"term-stream",id:e,stream:B}))},j=S.useRef(!1),[T,I]=S.useState(0),R=B=>{B===Do&&B===y&&(j.current=!0),s==null||s.send({t:"term-restart",worktreeId:e,stream:B}),B===Ds&&B===y&&(N(null),I(W=>W+1))},C=(B,W)=>{if(B)return N(null);if(j.current){j.current=!1,I(U=>U+1);return}N({code:W})},O=PG({worktreeId:e,procs:f,borrowed:m,login:g,current:y,onRestart:R}),A=S.useRef(!t),D=!A.current;return S.useEffect(()=>{A.current=!1},[]),d.jsxs(Jy,{kind:"terminal",className:"term-pane",height:n,onDragStart:r,tabs:{items:O,current:y,onPick:_,font:"mono",owner:"terminal",label:"terminal streams"},onClose:()=>o({a:"toggle-terminal"}),closeHint:Dt("terminal"),children:[d.jsxs("div",{className:"term-body",children:[x&&d.jsx(_u,{pane:!0,title:`${y} runs on main`,body:"Every worktree reaches main's copy until its own changes touch it, or until asked.",action:d.jsx(Pe,{variant:"outline",onClick:()=>s==null?void 0:s.send({t:"own-procs",worktreeId:e,names:[y]}),children:"run it here"})}),d.jsx(uy,{pane:!0,children:d.jsx(S.Suspense,{fallback:d.jsx("div",{className:"empty",children:d.jsx("span",{className:"live-text",children:"loading terminal"})}),children:d.jsx(DG,{worktreeId:e,stream:y,theme:a,sock:s,connected:c,focusOnMount:D,focusReq:u,onAlive:C,run:w,onRan:()=>o({a:"term-ran"}),onEscape:()=>o({a:"toggle-terminal"})},`${y}:${T}`)})})]}),v!==null&&!x&&d.jsx(_u,{pane:!0,title:y===Do?"the shell exited":y===Ds?"the login did not finish":`${y} exited`,body:v.code===void 0?void 0:`exit code ${v.code}`,action:d.jsx(Pe,{variant:"outline",onClick:()=>R(y),children:"restart"})})]})}function BG(e){return e==="reserved"?"checking out a fresh worktree":e==="warming"?"copying dependencies and running setup":"starting dev servers"}const UG="preview off; it starts when the agent writes a file";function HG({worktree:e,log:t}){const n=Qe(),r=ut(),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=$u(e,"setup"),h=u&&u.status!=="terminated"?u:null,f=ji(gy(h??void 0)?h==null?void 0:h.since:void 0),m=!!e.worktree.parked&&o.length===0,g=()=>n==null?void 0:n.send({t:"preview-start",worktreeId:e.id}),y=h&&(h.status==="running"||h.status==="detached"),w=()=>n==null?void 0:n.send({t:"fix-preview",worktreeId:e.id,clientId:c});return d.jsxs(ws,{wide:!0,children:[o.length===0?d.jsx("div",{className:"status-line",children:h?d.jsx("span",{className:"live-text","data-tip":xk[h.status],children:fh("setup",h,f)}):m?UG:d.jsx("span",{className:"live-text",children:BG(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:WG(v)}),(v.status==="crashed"||v.status==="unreachable")&&d.jsx(Pe,{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(Pe,{variant:"outline",size:"lg",onClick:g,children:"start preview"})}),y&&d.jsx("div",{className:"status-actions",children:d.jsx(Pe,{variant:"outline","data-tip":$T("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(Pe,{variant:"outline",size:"lg",onClick:w,children:"ask the agent to fix it"}),d.jsx(Pe,{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(`
285
- `)})]})}function WG(e){switch(e.status){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 KG(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 DE(e){if(!e)return"/";try{const t=new URL(e);return`${t.pathname}${t.search}${t.hash}`}catch{return"/"}}function qG(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 ZG({active:e}){const t=ut(),n=Qe(),r=nc(),o=L(c=>c.home),s=e.worktree.title,a=()=>{r!=null&&r.made&&(t({a:"new-project",v:{...Yh({mode:r.made==="git"?"init":"create",name:r.name,parent:tj(r.path,o)??r.path}),phase:"unmaking",repoId:r.id}}),t({a:"move-box",from:e.worktree.id,to:Kl}),n==null||n.send({t:"unmake-repo",repoId:r.id}))};return d.jsx(ws,{anchor:"line",foot:d.jsx("div",{className:"composer view-foot",children:d.jsx(pu,{active:e,greenfield:!0})}),children:d.jsx("p",{className:"form-title",children:r!=null&&r.made?d.jsx(Pe,{variant:"inline",onClick:a,...Lt("Rename or move this project"),children:s}):s})})}function GG({pending:e}){const t=ut(),n=Qe(),r=!!e.error,o=()=>{n==null||n.send({t:"cancel-import",id:e.id}),t({a:"watch-import",id:null})},s=S.useRef(null);return S.useEffect(()=>{var a;return(a=s.current)==null?void 0:a.scrollTo({top:s.current.scrollHeight})},[e.lines.length]),d.jsxs(ws,{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(Pe,{variant:"outline",size:"lg",onClick:o,children:r?"dismiss":"stop"})})]})}const VG=150,YG=/^[^\s@]+@[^\s@]+$/,XG=14;function QG({project:e}){var Z;const t=ut(),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),h=L(q=>q.paths),[f,m]=S.useState({name:"",email:""}),[g,y]=S.useState(null),w=S.useRef(null),{mode:v,name:N,parent:x}=e,_=v==="clone",j=v==="init",T=e.phase==="editing",I=N.trim(),R=j||!I?null:vu(N),C=!j&&I&&!R?ej(x,I):null,O=$k(x,o),A=C!==null&&h.query===C&&((Z=h.target)==null?void 0:Z.exists)===!0,D=!a&&!_,B=!D||f.name.trim()!==""&&YG.test(f.email.trim()),W=T?g?"the folder you chose is already a project: open it, or choose another":!j&&!I?"name the project first":R??(A?`${O} already has a folder called ${I}`:B?null:"git needs your name and email first"):null;S.useEffect(()=>{if(!C)return;const q=setTimeout(()=>n==null?void 0:n.send({t:"browse-path",path:C}),VG);return()=>clearTimeout(q)},[C,n]),it([e.phase],()=>{var q;e.phase==="editing"&&((q=w.current)==null||q.focus())}),it([e.error],()=>{e.error&&t({a:"notice",id:Kl,text:e.error})});const U={sock:n,dispatch:t},Q=()=>{W||!T||(t({a:"new-project-set",v:{phase:"creating"}}),Cu(U,{t:"create-repo",mode:v,parent:x.trim(),name:I,..._&&e.url?{url:e.url,...e.branch?{branch:e.branch}:{}}:{},...D?{identity:{name:f.name.trim(),email:f.email.trim()}}:{}}))},Y=q=>{const K=r.find(ne=>ne.path===Yl(q,o));K?t({a:"activate-repo",id:K.id}):Cu(U,{t:"register-repo",path:q})},se=q=>{const K=by(q);t({a:"new-project-set",v:{mode:"init",parent:K.parent,name:K.name}})},H=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"}})};it([u==null?void 0:u.seq],()=>{var K,ne;if(!c||!u)return;t({a:"choosing-folder",v:!1});const q=u.folder;if(!q){(K=w.current)==null||K.focus();return}if(c==="open"){q.kind==="project"?Y(q.path):D?se(q.path):VT(U,q.path);return}if(y(q.kind==="project"?q.path:null),q.kind!=="project"){if(q.kind==="empty"&&!_){se(q.path);return}t({a:"new-project-set",v:{mode:_?"clone":"create",parent:q.path}}),(ne=w.current)==null||ne.focus()}});const $=j?"the folder you chose becomes the project":g?null:A?`${O} already has a folder called ${I}`:R;return d.jsxs(ws,{anchor:"line",foot:d.jsx("div",{className:"composer view-foot",children:d.jsx(pu,{active:null,project:{name:I,why:W,busy:!T,create:Q}})}),children:[_&&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:[j?d.jsx("p",{className:"form-title",children:N}):d.jsx(Fo,{ref:w,bare:!0,font:"lead",className:"new-project-field",autoFocus:!0,spellCheck:!1,autoComplete:"off",value:N,placeholder:"Project name",disabled:!T,style:{width:`${Math.max(N.length+1,XG)}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:O}),d.jsx(It,{icon:"folder",label:s?"Choose in Finder":"Choose a folder",className:"new-project-folder",on:c==="location",disabled:!T,onClick:()=>H("location")})]})]}),$&&d.jsx("p",{className:"hint",children:$}),g&&d.jsxs("p",{className:"hint",children:["the folder you chose is already a project:"," ",d.jsx(Pe,{variant:"inline",autoFocus:!0,onClick:()=>Y(g),children:"open it"}),", or choose another"]}),D&&d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"new-project-identity",children:[d.jsx(Fo,{size:"md",font:"ui",rule:!0,value:f.name,placeholder:"Your name",autoComplete:"name",disabled:!T,onChange:q=>m({...f,name:q.target.value})}),d.jsx(Fo,{size:"md",font:"ui",rule:!0,type:"email",value:f.email,placeholder:"Email",autoComplete:"email",disabled:!T,onChange:q=>m({...f,email:q.target.value})})]}),d.jsx("p",{className:"hint",children:"git labels the work you save with these, and asks only once"})]}),!_&&T&&d.jsx(Pe,{tone:"quiet",className:"new-project-open",onClick:()=>H("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 JG(e,t,n){const r=[n.envUrl?`\`${n.envUrl.name}\` in \`${n.envUrl.file}\``:null,n.compose?`the compose stack in \`${n.compose}\``:null].filter(Boolean).join(" and ");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 ${r}: 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, which never runs setup) and \`TOYON_ROOT\` (the main checkout). Edit \`${t}\` so that:`,'- `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 running commands point at it, with the base database in the main checkout: put the URL in front of the command in `run`, or in a profile's `env`, named `<db>${TOYON_WORKTREE:+_$TOYON_WORKTREE}`. `setup` does not see what `run` sets, so a migration step in `setup` needs the URL in front of it too.",'- a database container the worktrees share (each with its own database inside it) is marked `{ "cmd": ..., "from": "trunk", "paths": [] }` in `run`, so the main checkout runs it once for everyone.',"","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(`
286
- `)}function eV(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(`
287
- `)}let tV=1;const zg=(e,t,n=!1)=>({id:tV++,name:e,cmd:t,shared:n}),nV=[{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 rV({repo:e,onClose:t}){const n=Qe(),r=zn(),o=L(fe=>fe.clientId),s=L(fe=>fe.rows.find(te=>{var re;return jn(te)&&te.id===((re=ql(fe,e.id))==null?void 0:re.id)})??null),a=L(fe=>{var te;return((te=ql(fe,e.id))==null?void 0:te.id)??null});S.useEffect(()=>{if(!t)return;const fe=te=>te.key==="Escape"&&t();return window.addEventListener("keydown",fe),()=>window.removeEventListener("keydown",fe)},[t]);const[c]=S.useState(()=>Object.keys(e.config.run).length>0),[u,h]=S.useState(()=>{const fe=Object.entries(e.config.run).map(([te,re])=>zg(te,oS(re),xI(re)));return fe.length>0?fe:[zg("web","")]}),[f,m]=S.useState(()=>(e.config.setup??[]).join(`
288
- `)),[g,y]=S.useState(()=>(e.config.teardown??[]).join(`
289
- `)),[w,v]=S.useState(()=>e.config.check??""),[N,x]=S.useState(()=>Ni(e.config).land),[_,j]=S.useState(()=>Ni(e.config).automerge),[T,I]=S.useState(()=>Ni(e.config).merge??"default"),[R,C]=S.useState(()=>_I(e.configFile)),O=NI(e.configFile,R),A=!!e.remote&&N==="pr",D=u.length>1,B=u.some(fe=>fe.name.trim()&&fe.cmd.trim()),U=!!s&&!t&&!c&&!B,Q=(fe,te)=>h(u.map((re,we)=>we===fe?{...re,...te}:re)),Y=fe=>fe.split(`
290
- `).map(te=>te.trim()).filter(Boolean),se=()=>Y(f),H=()=>Y(g),$=()=>{const{check:fe,land:te,teardown:re,...we}=e.config,ue=e.remote?N:Wg,le=T==="default"||ue!=="pr"&&T===Kg?void 0:T,be={...ue!==Wg?{route:ue}:{},...ue==="pr"&&_?{automerge:!0}:{},...le?{method:le}:{}};return{...we,setup:se(),...H().length>0?{teardown:H()}:{},...w.trim()?{check:w.trim()}:{},...Object.keys(be).length>0?{land:be}:{}}},Z=()=>{n==null||n.send({t:"confirm-config",repoId:e.id,config:{...$(),run:Object.fromEntries(u.filter(fe=>fe.name.trim()&&fe.cmd.trim()).map((fe,te)=>[fe.name.trim(),fe.shared&&te>0?{cmd:fe.cmd.trim(),from:"trunk"}:fe.cmd.trim()]))},kind:R}),t==null||t()},q=()=>{n==null||n.send({t:"confirm-config",repoId:e.id,config:{...$(),run:{}},kind:R}),t==null||t()},K=()=>n==null?void 0:n.send({t:"create-worktree",clientId:o,repoId:e.id,prompt:eV(e,O)}),ne=e.services,de=[f,g,...u.map(fe=>fe.cmd)].some(fe=>fe.includes("TOYON_WORKTREE"))||EI(e.config),pe=ne?[ne.envUrl?`the database at ${ne.envUrl.name} in ${ne.envUrl.file}`:null,ne.compose?`the stack in ${ne.compose}`:null].filter(Boolean).join(" and "):"",je=()=>ne&&(n==null?void 0:n.send({t:"create-worktree",clientId:o,repoId:e.id,prompt:JG(e,O,ne)})),_e=(fe,te)=>d.jsxs("div",{className:"setup-proc",children:[D&&d.jsx(Fo,{size:"md",rule:!0,className:"setup-name",value:fe.name,placeholder:"name",...Lt("Process name, shown in the status bar"),onChange:re=>Q(te,{name:re.target.value})}),d.jsx(Fo,{size:"md",rule:!0,className:"setup-cmd",value:fe.cmd,placeholder:"npm run dev",onChange:re=>Q(te,{cmd:re.target.value})}),D&&d.jsx(It,{icon:"close",label:"Remove",onClick:()=>h(u.filter((re,we)=>we!==te))}),D&&te>0&&d.jsx(sC,{className:"setup-shared",checked:fe.shared,onChange:re=>Q(te,{shared:re.target.checked}),tip:"Main runs it once for every worktree; a worktree whose changes touch it runs its own",children:"shared from main"})]},fe.id);return d.jsxs(ws,{children:[d.jsxs("p",{className:"form-title",children:["how does ",e.name," start?"]}),ne&&!de&&d.jsxs("p",{className:"hint setup-shared-note",children:["Worktrees will share ",pe,", migrations included."," ",d.jsx(Pe,{tone:"quiet",disabled:!s,onClick:je,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(ju,{size:"md",rule:!0,rows:Math.max(1,f.split(`
291
- `).length),value:f,placeholder:"bun install",onChange:fe=>m(fe.target.value)})}),d.jsx(_l,{label:"remove",hint:"once when a worktree goes, before its directory does; one command per line",children:d.jsx(ju,{size:"md",rule:!0,rows:Math.max(1,g.split(`
292
- `).length),value:g,placeholder:'dropdb --if-exists "app_$TOYON_WORKTREE"',onChange:fe=>y(fe.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(Fo,{size:"md",rule:!0,value:w,placeholder:"bun run check",onChange:fe=>v(fe.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(_i,{value:N,options:FI.map(fe=>({id:fe.id,label:fe.name,description:fe.description})),onChange:x,hint:"where the work goes",placeholder:"where work lands"}),A&&d.jsx(_i,{value:_?"github":"you",options:UI.map(fe=>({id:fe.id,label:fe.name,description:fe.description})),onChange:fe=>j(fe==="github"),hint:"who merges the pull request",placeholder:"who merges it"})]})}),d.jsx(_l,{label:"merge",hint:A?"how GitHub merges the pull request; only what the repo allows":"how the commits arrive on main",children:d.jsx(_i,{value:T==="default"&&!A?Kg:T,options:[...A?[{id:"default",label:"what the repo allows",description:"the repo's allowed methods on GitHub: squash, else a merge commit, else rebase"}]:[],...BI.map(fe=>({id:fe.id,label:fe.name,description:fe.description}))],onChange:I,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(Pe,{mono:!0,tone:"quiet",...Lt(`open ${e.guess} in the editor pane`),onClick:()=>Ea(r,n,a,e.guess??"",1),children:e.guess})]})]}),children:u[0]&&_e(u[0],0)}),u.slice(1).map((fe,te)=>d.jsxs("div",{className:"form-row",children:[d.jsx("span",{className:"form-label"}),d.jsx("div",{className:"form-control",children:_e(fe,te+1)})]},fe.id)),d.jsxs("div",{className:"form-row",children:[d.jsx("span",{className:"form-label"}),d.jsxs(Pe,{tone:"quiet",onClick:()=>h([...u,zg("","")]),children:[d.jsx(mt,{name:"plus",className:"icon-inline"})," another process"]})]}),d.jsxs("div",{className:"form-knobs",children:[d.jsx(_i,{value:R,options:nV,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:O}),t&&d.jsx(Pe,{onClick:t,children:"cancel"}),(!c||t)&&d.jsx(Pe,{...Lt("This project has no dev server: chat, changes and the terminal work, the preview stays empty"),onClick:q,children:"no dev server"}),U&&s?d.jsx(Pe,{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:K,children:"let the agent work it out"}):d.jsxs(Pe,{variant:"outline",size:"lg",disabled:!B,...t?Lt("Restarts every worktree of this repo. Profiles and other keys in the file are kept."):{},onClick:Z,children:[t?"save + restart":"start"," ",d.jsx(mt,{name:"forward",className:"icon-inline"})]})]})]})}function oV(e){return`${Math.round(e.w)} × ${Math.round(e.h)}`}function sV(e){return e.w>0&&e.h>0}function iV(e,t,n){S.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(sV(a)?oV(a):null)});return r.observe(e),()=>{r.disconnect(),n(null)}},[e,t,n])}const aV=1500,lV={set:(e,t)=>setTimeout(e,t),clear:e=>clearTimeout(e)};class cV{constructor(t,n,r=lV){Tt(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=Wb(r));const s=Hh(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)},aV)}title(t,n){const r=this.frame(t);r.title=Wb(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 uV=sh(),dV=2*6e4;function zE(e){e==null||e.setAttribute("src",e.src)}const fV=8e3;function hV(e,t){try{const n=new URL(e,t);return n.origin===new URL(t).origin?n.href:null}catch{return null}}function pV({onRoot:e}){const t=S.useRef(null),n=S.useCallback(ie=>{t.current=ie,e(ie)},[e]),r=ut(),o=zn(),s=Qe(),a=S.useRef(s);a.current=s;const[c]=S.useState(()=>new cV((ie,Te,dt)=>{var lt,Bt;(lt=a.current)==null||lt.send({t:"visit",worktreeId:ie,path:Te,title:dt}),b_((Bt=o.getState().local[ie])==null?void 0:Bt.pages)&&cn.post(ie,{type:"links"})},(ie,Te,dt)=>{var lt;return(lt=a.current)==null?void 0:lt.send({t:"page-title",worktreeId:ie,path:Te,title:dt})}));S.useEffect(()=>()=>c.dispose(),[c]);const u=uN(),h=tc(),f=Us(),m=L(ie=>ie.connected),g=L(ie=>ie.heard),y=L(ie=>ie.recalledAt!==null),w=L(ie=>ie.connectFailure),v=L(ie=>ie.remote),{host:N}=Pr(),x=Bs(),_=ks(),j=L(ie=>ie.editor),T=fN(),I=p3(),R=L(ie=>ie.notesPage),C=Wu(),O=L(ie=>ie.layout.term)&&!C,A=L(ie=>ie.focusTerm),D=S.useRef(!1),B=S.useRef(A),W=!D.current||A!==B.current;S.useEffect(()=>{D.current=O&&!!h,B.current=A});const U=Ku(),Q=L(ie=>ie.layout.design)&&!C&&!U,Y=L(ie=>ie.reloadReq),se=ep(),H=S.useRef(se);H.current=se;const $=L(ie=>ie.zen),Z=L(ie=>{var Te;return((Te=ie.dragFiles)==null?void 0:Te.at)==="centre"}),q=S.useRef($);q.current=$;const K=At(h,"log"),ne=L(ie=>ie.incompatible),de=g3(),pe=L(ie=>{var Te;return((Te=ie.overlay)==null?void 0:Te.kind)==="setup"?ie.repos.find(dt=>dt.id===ie.overlay.repoId)??null:null}),je=(f==null?void 0:f.worktree.empty)===!0,_e=ns(f==null?void 0:f.agent),fe=de&&!je&&!_e?de:null,te=fe??pe,re=L(ie=>ie.pending.find(Te=>Te.id===ie.activeImportId)??null),[we,ue]=S.useState([]),le=S.useMemo(()=>we.map(ie=>ie.id),[we]),be=S.useRef(new Map),Ce=S.useRef(new Map),[Ne,Ie]=S.useState([]),Be=S.useRef(new Set),Je=S.useRef(new Set),zt=S.useRef(ie=>zE(be.current.get(ie)));S.useEffect(()=>{cn.post=(ie,Te)=>{var dt,lt;if(Te.type==="reload"&&Be.current.has(ie))return zt.current(ie);(lt=(dt=be.current.get(ie))==null?void 0:dt.contentWindow)==null||lt.postMessage({__toyon:!0,...Te},Ce.current.get(ie)??"*")},cn.broadcast=ie=>{var Te;for(const[dt,lt]of be.current)(Te=lt.contentWindow)==null||Te.postMessage({__toyon:!0,...ie},Ce.current.get(dt)??"*")}},[]),S.useEffect(()=>{let ie=null;const Te=Bt=>{Bt.target instanceof HTMLElement&&Bt.target.tagName!=="IFRAME"&&(ie=Bt.target)},dt=Bt=>{Bt.relatedTarget===null&&setTimeout(()=>{document.activeElement===document.body&&(ie=null)},0)},lt=Bt=>{var kn,Dr,lr,ln,cr;if((kn=Bt.data)!=null&&kn.__toyon)for(const[rn,Ht]of be.current){if(Ht.contentWindow!==Bt.source)continue;if(Bt.origin!==Ce.current.get(rn))return;const Ut=YS(Bt.data);if(!Ut)return;switch(Ut.type){case"key":window.dispatchEvent(new KeyboardEvent(Ut.up?"keyup":"keydown",{key:Ut.key,code:Ut.code,metaKey:Ut.meta,ctrlKey:!!Ut.ctrl,shiftKey:!!Ut.shift,altKey:!!Ut.alt}));break;case"hmr":r({a:"hmr",id:rn}),(Dr=a.current)==null||Dr.send({t:"page-loaded",worktreeId:rn});break;case"loaded":Be.current.delete(rn),Je.current.add(rn),Ie(xe=>xe.includes(rn)?xe:[...xe,rn]),cn.post(rn,EC(H.current)),cn.post(rn,{type:"zen",on:q.current}),r({a:"hmr",id:rn}),r({a:"page",id:rn,url:Ut.url,title:Ut.title}),(lr=a.current)==null||lr.send({t:"page-loaded",worktreeId:rn}),c.note(rn,Ut.url,Ut.title);break;case"navigated":r({a:"page",id:rn,url:Ut.url,...Ut.title!==void 0?{title:Ut.title}:{}}),c.note(rn,Ut.url,Ut.title);break;case"title":r({a:"page",id:rn,title:Ut.title}),c.title(rn,Ut.title);break;case"links":r({a:"links",id:rn,links:Ut.links});break;case"page-error":{const xe=E4(Ut);xe&&((ln=a.current)==null||ln.send({t:"page-error",worktreeId:rn,message:xe}));break}case"picked":{const{type:xe,verb:Ge,site:kt,...wt}=Ut,on=kt==="call"?{file:wt.callFile,line:wt.callLine}:{file:wt.file,line:wt.line};if(Ge==="code"){r({a:"set-picking",v:!1});const dn=(cr=qt(o.getState(),rn))==null?void 0:cr.worktree;on.file?Ea(o,s,rn,p_(on.file,dn==null?void 0:dn.path),on.line??1):s==null||s.send({t:"find-element",worktreeId:rn,seq:_o(),element:wt.element})}else X3(o,rn,wt);break}case"pick-cancel":r({a:"set-picking",v:!1});break;case"drag-files":Ut.over?ay(o,o.getState().activeId?{at:"centre"}:null):zN(o);break;case"drop-files":HN(o,s,o.getState().activeId?{at:"centre"}:null,A6(Ut.files));break;case"focus":Ut.gesture?ie=null:document.activeElement===Ht&&(ie!=null&&ie.isConnected)&&ie!==document.body&&ie.focus();break;case"highlight-miss":console.warn(`[toyon] highlight miss on ${Ut.path}: ${Ut.fileMatched} elements from this file, ${Ut.withSource} elements with source info on page, ranges=${JSON.stringify(Ut.ranges)}`);break}return}};return window.addEventListener("message",lt),document.addEventListener("focusin",Te),document.addEventListener("focusout",dt),()=>{window.removeEventListener("message",lt),document.removeEventListener("focusin",Te),document.removeEventListener("focusout",dt)}},[r,o,s,c]),S.useEffect(()=>{cn.broadcast({type:"zen",on:$})},[$]);const Yt=S.useRef(new Map);it([Y==null?void 0:Y.id,Y==null?void 0:Y.n],()=>{if(!Y)return;const{id:ie}=Y;clearTimeout(Yt.current.get(ie)),Yt.current.set(ie,setTimeout(()=>{Yt.current.delete(ie),cn.post(ie,{type:"reload"})},1200))});const _t=Yw(),qe=_t&&!jn(_t)?_t:null,xt=La(),ht=!!f&&f.procs.some(ie=>ie.status==="running"),De=Jw(),nt=De!==null&&De===h&&ht;S.useEffect(()=>{var ie;if(De&&nt&&!le.includes(De)){const Te=DE((ie=o.getState().local[De])==null?void 0:ie.page.url);ue(dt=>[...dt,{id:De,path:Te}])}},[De,nt,le,o]);const at=u.filter(ie=>jn(ie)&&ie.procs.some(Te=>Te.status==="asleep")).map(ie=>ie.id).join(" ");S.useEffect(()=>{const ie=new Set(at.split(" ").filter(Boolean));le.some(Te=>ie.has(Te))&&ue(Te=>Te.filter(dt=>!ie.has(dt.id)))},[at,le]);const Xt=le.join(" ");S.useEffect(()=>{const ie=Xt.split(" ").filter(Te=>Te&&Te!==De).map(Te=>setTimeout(()=>ue(dt=>dt.filter(lt=>lt.id!==Te)),dV));return()=>{for(const Te of ie)clearTimeout(Te)}},[Xt,De]),S.useEffect(()=>{Ie(ie=>ie.every(Te=>le.includes(Te))?ie:ie.filter(Te=>le.includes(Te)))},[le]);const Nt=S.useMemo(()=>u.filter(jn).flatMap(ie=>{const Te=we.find(lt=>lt.id===ie.id);if(!Te)return[];const dt=h_(ie.worktree.id,ie.worktree.proxyPort,v,N);return[{id:ie.worktree.id,port:ie.worktree.proxyPort,title:ie.worktree.title,url:hV(Te.path,dt)??dt}]}),[u,we,v,N]),Zt=wk(x,v),gt=VN(x,Nt,Zt);zt.current=ie=>{var dt;const Te=DE((dt=o.getState().local[ie])==null?void 0:dt.page.url);if(we.some(lt=>lt.id===ie&&lt.path!==Te)){ue(lt=>lt.map(Bt=>Bt.id===ie?{...Bt,path:Te}:Bt));return}Zt?gt.renew(ie):zE(be.current.get(ie))};const nr=Nt.filter(ie=>{var Te;return(Te=u.find(dt=>dt.id===ie.id))==null?void 0:Te.procs.some(dt=>dt.status==="running")}).map(ie=>ie.id).join(" ");it([nr],()=>{for(const ie of nr.split(" "))Be.current.has(ie)&&zt.current(ie)});const Jt=L(ie=>ie.carryTo),[Rn,Kn]=S.useState(null),[un,vn]=S.useState(De),J=S.useRef(null);un!==De&&(vn(De),Kn(KG({leaving:J.current,arriving:De,carryTo:Jt,repoOf:ie=>{var Te;return((Te=u.find(dt=>dt.id===ie))==null?void 0:Te.repoId)??null}}))),S.useEffect(()=>{if(!Rn)return;const ie=setTimeout(()=>Kn(null),fV);return()=>clearTimeout(ie)},[Rn]);const ye=De!==null&&Ne.includes(De),We=qG({previewId:De,painted:ye,ready:nt,carry:Rn,mounted:le}),rt=We!==null&&We!==De;S.useEffect(()=>{J.current=We});const jt=We!==null&&!te&&!re&&!R&&!C&&!U,[Ft,P]=S.useState(null),oe=S.useCallback(ie=>r({a:"preview-size",text:ie}),[r]);iV(Ft,jt,oe);const[$e,Fe]=hs(tt.editorHeight,0,ie=>{const Te=Number(ie);return Number.isFinite(Te)&&Te>=120?Te:0}),[Rt,Gt]=hs(tt.designHeight,0,ie=>{const Te=Number(ie);return Number.isFinite(Te)&&Te>0?Te:0}),[Re,He]=hs(tt.designFull,!1,ie=>ie===null?void 0:ie==="1"),[Ze,Qt]=hs(tt.editorFull,!1,ie=>ie===null?void 0:ie==="1"),[Wt,En]=hs(tt.termHeight,240,ie=>{const Te=Number(ie);return Number.isFinite(Te)&&Te>=140?Te:void 0}),Sn=L(ie=>ie.termTall);it([Sn],()=>{const ie=t.current;Sn&&ie&&En(Math.max(Wt,Math.round(ie.clientHeight/2)))});const Ct=ie=>(Te,dt)=>{const lt=dt.parentElement,Bt=t.current;if(!lt||!Bt)return null;let kn=0;for(const lr of Array.from(Bt.querySelectorAll(":scope > .pane")))lr!==lt&&!lr.classList.contains("full")&&(kn+=lr.offsetHeight);const Dr=Math.max(Bt.clientHeight-kn-80,ie);return Math.min(Math.max(lt.getBoundingClientRect().bottom-Te.clientY,ie),Dr)},nn=zl(Ct(120),ie=>Fe(Math.round(ie))),sr=zl(Ct(160),ie=>Gt(Math.round(ie))),Pt=zl(Ct(140),ie=>En(Math.round(ie))),bn=L(ie=>{var Te,dt;return f&&jr(f.worktree)?((dt=(Te=ie.rows.find(lt=>{var Bt;return lt.repoId===f.worktree.repoId&&((Bt=lt.worktree)==null?void 0:Bt.kind)==="worktree"}))==null?void 0:Te.worktree)==null?void 0:dt.title)??null:null}),fn=D5({connected:m,heard:g,standing:y,connectFailure:w,hasToken:x.serving?uV:!0,projectChord:Dt("project"),title:(f==null?void 0:f.worktree.title)??null,machine:x.serving?null:_.displayName(x.origin),needsSetup:!!de,busy:_e,treeEmpty:je,landsFrom:bn});return d.jsxs("div",{className:"center-root",ref:n,children:[d.jsx("div",{className:Ke("center-area",Z&&"drop-over"),style:{display:!($&&!U)&&!xt&&!R&&(j&&Ze||Q&&Re)?"none":void 0},children:d.jsxs("div",{className:"frames-wrap",ref:P,children:[Nt.map(ie=>d.jsx("iframe",{ref:Te=>{Te?(be.current.set(ie.id,Te),Ce.current.set(ie.id,new URL(ie.url).origin)):(be.current.delete(ie.id),Ce.current.delete(ie.id),Be.current.delete(ie.id),Je.current.delete(ie.id))},onLoad:()=>{Je.current.delete(ie.id)?Be.current.delete(ie.id):Be.current.add(ie.id)},src:gt.urlOf(ie.id)??void 0,title:ie.title,style:{display:jt&&ie.id===We?"block":"none"}},ie.id)),I?d.jsx(QG,{project:I}):R?d.jsx(fG,{}):d.jsxs(d.Fragment,{children:[re&&d.jsx(GG,{pending:re},re.id),T&&f&&!re&&d.jsx(ZG,{active:f},f.worktree.id),te&&!re&&!T&&d.jsx(rV,{repo:te,onClose:fe?void 0:()=>r({a:"close"})},`${te.id}:${JSON.stringify(te.config)}`),qe&&!te&&!re&&!xt&&d.jsx(mu,{placement:"centre",found:qe},qe.id),xt&&!te&&!re&&d.jsx(mu,{placement:"centre",archived:xt},xt.id),!ht&&!qe&&!xt&&!te&&!re&&!T&&ne&&d.jsx(aT,{foreign:x.serving?void 0:_.displayName(x.origin)}),!ht&&!qe&&!xt&&!te&&!re&&!T&&!ne&&(fn!==null?d.jsx(ws,{wide:!0,children:d.jsx("p",{className:Ke("status-line",fn.live&&"live-text"),children:fn.text})}):U?d.jsx(mu,{placement:"centre"}):rt?null:f&&d.jsx(HG,{worktree:f,log:K}))]})]})}),j&&d.jsx(lC,{editor:j,height:Ze?"100%":$e>0?$e:"45%",full:Ze,onToggleFull:()=>Qt(!Ze),onDragStart:nn}),Q&&h&&!xt&&!R&&d.jsx(mG,{worktreeId:h,height:Re?"100%":Rt>0?Rt:"55%",full:Re,onToggleFull:()=>He(!Re),onDragStart:sr},`design:${h}`),O&&h&&!xt&&!R&&d.jsx(FG,{worktreeId:h,opened:W,height:Wt,onDragStart:Pt},`term:${h}`),d.jsx(pC,{})]})}function mV({width:e}){const t=L(r=>r.layout.chat),n=Wu();return d.jsx(mu,{placement:"dock",className:!t||n?"collapsed":void 0,width:e})}function gV(e,t){const n=[];return e&&(n.push(wN(e)),n.push({id:"copy-url",label:"copy URL",onClick:()=>tn(e)})),Wn([n,[{id:"reload",label:"reload preview",key:Dt("reload"),onClick:t.reload}]])}const kV=520,Fg=8;function wV({winW:e,centre:t,leadRight:n,toolsLeft:r}){const o=t.right-t.left,s=Math.max(0,Math.min(kV,Math.floor(e*.4),o-2*Fg)),a=t.left+(o-s)/2,c=n+Fg,u=r-Fg-s,h=Math.max(Math.min(a,u),c);return{left:Math.round(h),width:s}}function yV({center:e}){const t=qz(),n=sN(e),r=S.useRef(null);r3(r);const o=J6(),[s,a]=fx(),[c,u]=fx(),h=wV({winW:t,centre:n,leadRight:a.right,toolsLeft:u.left}),f=ut(),m=Qe(),g=zn(),y=xn("bar"),w=Us(),v=Ku(),N=L(H=>H.zen)&&!v,x=L(H=>H.layout.changes),_=L(H=>H.layout.chat),j=Wu(),T=L(H=>H.layout.design),I=L(H=>{var $;return(($=H.overlay)==null?void 0:$.kind)==="keys"}),R=_$(),C=(w==null?void 0:w.worktree.id)??null,O=L(H=>H.archivedPage!==null||H.notesPage),A=!!w&&Qh(w)&&!O,D=L(H=>H.chatSide)==="left",B={tipAlign:"start"},W={tipAlign:"end"},U=!j&&d.jsx(It,{icon:"branch",label:"Changes panel",hint:Dt("changes"),tone:"chrome",on:x,...D?W:B,onClick:()=>f({a:"toggle-changes"})}),Q=!j&&!v&&d.jsx(It,{icon:"chat",label:"Chat panel",hint:Dt("composer"),tone:"chrome",on:_,...D?B:W,onClick:()=>f({a:"toggle-chat"})}),Y=L(H=>H.railOpen),se=!j&&d.jsx(It,{icon:"worktrees",label:"Worktree panel",hint:Dt("rail"),tone:"chrome",on:Y,...D?B:W,onClick:()=>f({a:"toggle-rail"})});return d.jsxs("div",{className:"top-bar",ref:r,"data-float-up":o||void 0,children:[N&&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?se:U,D&&Q,d.jsx(vV,{}),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(xV,{}),d.jsx(EV,{}),d.jsx(SV,{})]}),!v&&d.jsx(bV,{worktreeId:C,repoId:(w==null?void 0:w.repoId)??null,ready:A,left:h.left,width:h.width}),d.jsx("span",{className:"bar-grow"}),d.jsxs("span",{className:"bar-tools",ref:c,children:[d.jsx(_V,{}),d.jsx(It,{icon:"settings",label:"Settings & shortcuts",hint:Dt("keys"),tone:"chrome",on:I,...W,"aria-controls":"keys-help","aria-expanded":I,onClick:()=>f({a:"toggle",overlay:{kind:"keys"}}),...y.contextMenu(()=>YT(g.getState(),{sock:m,dispatch:f}))}),!j&&!v&&d.jsx(It,{icon:"palette",label:"Design system",hint:Dt("design"),tone:"chrome",on:T,...W,onClick:()=>f({a:"toggle-design"})}),D?U:Q,!D&&se,!v&&d.jsx(It,{icon:"zen",className:"bar-zen",label:"Full-bleed preview",hint:Dt("zen"),tone:"chrome",on:N,...W,onClick:()=>f({a:"toggle-zen"})})]})]})}function vV(){const e=ut(),t=Qe(),n=nc(),r=L(m=>m.activeRepoId),o=L(m=>m.rows),s=L(m=>m.repos),a=xn("bar"),c=()=>Wn([[{id:"project",label:s.length>1?"switch project…":"open project…",key:Dt("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?hp(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"}),h=L(m=>m.heard),f=L(m=>m.newProject!==null);return d.jsxs("span",{className:"bar-project",children:[d.jsx(Pe,{tone:"chrome",className:"bar-pill",on:u,...Lt(s.length>1?"Switch project":"Open a project",Dt("project")),onClick:()=>e({a:"toggle",overlay:{kind:"projects",form:"pill"}}),...a.contextMenu(c),children:d.jsx("span",{className:"bar-project-name",children:f?"new project":(n==null?void 0:n.name)??(h?"open project":"")})}),u&&d.jsx(tv,{form:"pill"})]})}function bV({worktreeId:e,repoId:t,ready:n,left:r,width:o}){const s=At(e,"page").url,a=ut(),c=L(y=>{var w;return((w=y.overlay)==null?void 0:w.kind)==="routes"}),u=L(y=>y.previewSize);it([e,n],()=>{c&&a({a:"close"})});const f=xn("bar").contextMenu(()=>n?gV(s,{reload:()=>e&&cn.post(e,{type:"reload"})}):[]),m=L(y=>y.picking),g=Jw();return d.jsxs("div",{className:"bar-center",style:{left:r,width:o},children:[d.jsx(It,{icon:"back",label:"Back",hint:Dt("back"),disabled:!n,onClick:()=>e&&cn.post(e,{type:"back"}),...f}),d.jsx(It,{icon:"forward",label:"Forward",hint:Dt("forward"),disabled:!n,onClick:()=>e&&cn.post(e,{type:"forward"}),...f}),d.jsx(It,{icon:"reload",label:"Reload preview",hint:Dt("reload"),disabled:!n,onClick:()=>e&&cn.post(e,{type:"reload"}),...f}),d.jsxs("span",{className:"bar-route",children:[n&&e&&t?d.jsx(HW,{worktreeId:e,repoId:t,url:s,open:c},e):d.jsx(Fo,{className:"bar-path",value:"",readOnly:!0,disabled:!0}),u&&d.jsx("span",{className:"bar-size",children:u})]}),d.jsx(It,{icon:"inspect",label:"Pick an element to open its code",hint:Dt("inspect"),also:{text:"Add an element to chat",key:Dt("pick")},on:m==="code",disabled:!n||!g,onClick:()=>g&&Nu(g,m,a,"code")})]})}function nd({icon:e,busy:t,children:n,...r}){return d.jsxs(Pe,{disabled:t,...r,children:[!t&&d.jsx(mt,{name:e,className:"icon-inline"}),d.jsx("span",{className:Ke(t&&"live-text"),children:n})]})}function xV(){const e=L(u=>u.self),t=L(u=>u.rebuilt),n=L(u=>u.repos),r=Qe(),o=L(u=>{var h;return((h=u.update)==null?void 0:h.restarting)!=null}),s=cC(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 EV(){const e=L(o=>o.update),t=L(o=>o.managed.updates),n=Qe(),r=C5(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 SV(){const e=ut(),t=L(uz),n=L(a=>a.ranBefore),r=L(a=>a.newProject!==null);if(!t||!n||r)return null;const{word:o,text:s}=dG(n,t);return d.jsx(nd,{icon:"book",onClick:()=>e({a:"open-release-notes"}),...Lt(s),children:o})}function _V(){const e=ut(),t=L(_z),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(It,{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 NV(e,t,n){return t==="left"?n-e.left:e.right-n}const TV="input, textarea, [contenteditable], .monaco-editor, .xterm, iframe";function jV(){const e=zn(),t=ut(),n=Qe(),r=Wu(),o=Di(),s=Ku(),a=L(Z=>Z.zen)&&!s,c=La(),u=L(Z=>Z.notesPage),h=!!Qw()||!!c||u,f=L(Z=>Z.layout.changes)&&!r,m=L(Z=>Z.layout.chat)&&!r&&!s&&!h,g=L(Z=>Z.chatSide),y=L(Z=>Z.railOpen),[w,v]=hs(tt.changesWidth,220,Z=>Z?bf(Number(Z),220):void 0),[N,x]=hs(tt.chatWidth,380,Z=>Z?bf(Number(Z),380):void 0),[_,j]=hs(tt.railWidth,280,Z=>Z?bf(Number(Z),280):void 0),T=(Z,q,K)=>{const ne=q.classList.contains("left")?"left":"right",de=ne==="left"?q.previousElementSibling:q.nextElementSibling;return de?bf(NV(de.getBoundingClientRect(),ne,Z.clientX),K):null},I=zl((Z,q)=>T(Z,q,220),v),R=zl((Z,q)=>T(Z,q,380),x),C=zl((Z,q)=>T(Z,q,280),j),[O,A]=S.useState(null),B=xn("app").contextMenu(()=>ZT(e.getState(),{sock:n,dispatch:t})),W=d.jsx(IT,{width:w}),U=!s&&!h&&d.jsx(mV,{width:N}),Q=!r&&d.jsx(yC,{width:_}),Y=Z=>!r&&y&&d.jsx("div",{className:`dock-resize ${Z}`,onPointerDown:C}),se=g==="left",H=se?{dock:U,open:m,drag:R}:{dock:W,open:f,drag:I},$=se?{dock:W,open:f,drag:I}:{dock:U,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:Z=>{Z.defaultPrevented||Z.target instanceof Element&&Z.target.closest(TV)||B.onContextMenu(Z)},children:[d.jsx(XN,{}),d.jsx(tT,{}),d.jsx(yV,{center:O}),d.jsxs("div",{className:"docks",children:[se&&Q,se&&Y("left"),H.dock,H.open&&d.jsx("div",{className:"dock-resize left",onPointerDown:H.drag}),d.jsx(pV,{onRoot:A}),$.open&&d.jsx("div",{className:"dock-resize right",onPointerDown:$.drag}),$.dock,!se&&Y("right"),!se&&Q]})]})}function $V(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 CV=new Set(["design","chats"]),AV=new Set(["back","forward"]),IV=new Set(["wt-back","wt-forward"]),RV=new Set(["project","commands","keys","zen"]);function OV(){const e=zn(),t=Qe();S.useEffect(()=>{const n=UZ(m=>e.dispatch({a:"rail-peek",on:m})),r=n.end,o=m=>{e.getState().railOpen||n.press(m)},s=BZ(),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"})},h=m=>{m.key!=="Escape"||!e.getState().choosingFolder||(m.stopImmediatePropagation(),t==null||t.send({t:"cancel-folder"}),e.dispatch({a:"choosing-folder",v:!1}))},f=m=>{var T,I,R,C;c(m),uI(m)&&!m.defaultPrevented&&m.preventDefault();const g=e.getState(),{dispatch:y}=e,w=(O,A={a:"activate",id:O})=>{const D=document.activeElement,B=!D||D===document.body||!!D.closest(".rail, .chat-input");y(A),B&&y({a:"walked"})},v=nS(m,{guest:!!((T=document.activeElement)!=null&&T.closest(".xterm"))}),N=g.zen&&!No(g),x=N?cI(v):v;if(N&&!g.overlay&&!g.picking&&!(x&&aI.has(x.id))||(x==null?void 0:x.id)==="close"&&!Mw()||!!((I=document.activeElement)!=null&&I.closest(".monaco-editor"))&&x&&CV.has(x.id))return;const j=x&&IV.has(x.id)&&s.holds(m);if(!(x&&!j&&mI(x.id,document.activeElement))&&!(x&&AV.has(x.id)&&!(Il(g)&&bu(g)))&&!((x==null?void 0:x.id)==="reload"&&!ik(g))){if(x){const O=m.defaultPrevented;if(m.preventDefault(),g.newProject&&!RV.has(x.id))return;switch(x.id){case"worktree":{const A=fI(x.digit,g.visible.length),D=A===null?void 0:g.visible[A];D&&w(D.id);break}case"wt-prev":case"wt-next":{const A=$V(g.visible,g.visibleDiscovered,g.activeId,x.id==="wt-next"?1:-1);A&&w(A.activate),o(m);break}case"wt-unseen-prev":case"wt-unseen-next":{const A=wy(g.visible,g.activeId,x.id==="wt-unseen-next"?1:-1);A&&w(A.activate),o(m);break}case"wt-back":case"wt-forward":{const A=new Set(g.rows.map(B=>B.id)),D=Y4(g.viewed,A,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(A=>A.id===g.activeId)&&gT(t,y,g.activeId);break;case"wt-archive":{if(m.repeat||O)break;const A=g.draft||g.archivedPage?void 0:g.visible.find(D=>D.id===g.activeId);A&&kT(t,y,D=>Fw(g,D)).archive(A);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"}):bu(g)&&y({a:"open",overlay:{kind:"routes"}});break;case"reload":{const A=ik(g);if(!A)break;A.act==="frame"?cn.post(A.id,{type:"reload"}):t==null||t.send({t:"preview-start",worktreeId:A.id});break}case"back":case"forward":{const A=Il(g);A&&cn.post(A,{type:x.id});break}case"pick":case"inspect":{const A=Il(g);A&&Nu(A,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&&(Gl(g)==="changes"||Bo(g)!==null)?{a:"toggle-changes"}:{a:"focus-changes",tab:"changes"});break;case"files":y(g.layout.changes&&Gl(g)==="files"?{a:"toggle-changes"}:{a:"focus-changes",tab:"files"});break;case"panel-tab-prev":case"panel-tab-next":if(Xh(g))break;y(g.layout.changes?{a:"focus-changes",tab:cz(g,x.id==="panel-tab-next"?1:-1)}:{a:"focus-changes"});break;case"composer":y(C_(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 A=g.rows.find(U=>U.id===g.activeId);if(!A)break;const D=Zr(g,g.activeId).termStream;if(A.login&&D===Ds)break;const B=[Do,...A.login?[Ds]:[],...A.procs.map(U=>U.name)],W=B.indexOf(D);y({a:"term-stream",id:A.id,stream:B[(W+1)%B.length]??Do});break}}}else if(m.key==="Escape")if(g.newProject)g.newProject.phase==="editing"&&y({a:"close-new-project"});else if(g.picking){const O=Il(g);O&&cn.post(O,{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",h,!0),window.addEventListener("keydown",f),window.addEventListener("keyup",a),window.addEventListener("pointermove",c),window.addEventListener("pointerdown",c),window.addEventListener("blur",r),()=>{window.removeEventListener("keydown",h,!0),window.removeEventListener("keydown",f),window.removeEventListener("keyup",a),window.removeEventListener("pointermove",c),window.removeEventListener("pointerdown",c),window.removeEventListener("blur",r),r()}},[e,t]),S.useEffect(()=>{const n=r=>{if(r.key!=="Alt"&&r.key!=="Shift")return;const o=e.getState();o.picking&&o.activeId&&cn.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 MV=3,LV=2e3,PV=200,DV=5e3;function zV(){const e=ut(),t=Qe(),n=Bs(),{storage:r}=n,o=tc(),s=L(te=>te.activeRepoId),a=Us(),c=Yw(),u=L(te=>te.connected),h=L(te=>te.daylight),f=L(te=>{var re;return((re=te.daylight)==null?void 0:re.until)??0}),m=La(),g=L(te=>te.notesPage),y=L(te=>te.version),w=L(te=>te.railOpen),v=L(te=>te.chatSide),N=L(te=>te.layouts),x=L(te=>te.lastActive),_=L(te=>te.discoveredOpen),j=L(te=>te.archivedOpen),T=L(te=>te.committedShut),I=L(te=>te.turnOpen),R=L(te=>te.treeOpen),C=ep(),O=L(te=>te.previewTheme!==null),A=L(te=>te.openUrl),D=uN();S.useEffect(()=>Vl.install(window),[]);const B=S.useRef([]),W=S.useCallback(te=>t==null?void 0:t.send({t:"subscribe",worktreeId:te,since:n.since(te)}),[t,n]);S.useEffect(()=>{if(!t||!u||!o)return;const te=[o,...B.current.filter(re=>re!==o)];for(const re of te.splice(MV))t.send({t:"unsubscribe",worktreeId:re});B.current.includes(o)||W(o),B.current=te},[o,u,t,W]),S.useEffect(()=>{if(!(!t||!u))for(const te of B.current)W(te)},[u,t,W]);const U=S.useRef(void 0);S.useEffect(()=>{if(!t||!u)return;let te;const re=()=>{const le=document.visibilityState==="visible"?o:null;t.send({t:"view",worktreeId:le}),U.current=le},we=()=>{clearTimeout(te),te=setTimeout(re,PV)};U.current===void 0||U.current===o||document.visibilityState!=="visible"?re():we();const ue=()=>document.visibilityState==="visible"?we():re();return document.addEventListener("visibilitychange",ue),()=>{clearTimeout(te),document.removeEventListener("visibilitychange",ue)}},[o,u,t]);const Q=(m==null?void 0:m.id)??null;S.useEffect(()=>{if(!(!t||!u||!Q))return W(Q),()=>t.send({t:"unsubscribe",worktreeId:Q})},[Q,u,t,W]),S.useEffect(()=>{const te=new Set(D.map(we=>we.id)),re=B.current.filter(we=>!te.has(we));if(re.length!==0&&(B.current=B.current.filter(we=>te.has(we)),!(!t||!u)))for(const we of re)t.send({t:"unsubscribe",worktreeId:we})},[D,u,t]);const Y=g?"Release notes":(m==null?void 0:m.title)??(c==null?void 0:c.name)??null;S.useEffect(()=>{document.title=Y?`${Y} · Toyon`:"Toyon"},[Y]);const se=!!(a!=null&&a.unseen),H=L(te=>te.unreadHold!==null&&te.unreadHold===te.activeId);S.useEffect(()=>{if(!t||!o||!se||H)return;let te;const re=()=>document.visibilityState==="visible"&&document.hasFocus(),we=()=>{clearTimeout(te),re()&&(te=setTimeout(()=>{re()&&t.send({t:"seen",worktreeId:o})},LV))},ue=()=>clearTimeout(te);return we(),window.addEventListener("focus",we),window.addEventListener("blur",ue),()=>{ue(),window.removeEventListener("focus",we),window.removeEventListener("blur",ue)}},[t,o,se,H]);const $=S.useRef(0),Z=L(te=>Bw(te));S.useEffect(()=>{if(!t||!u||!s)return;const te=()=>{Date.now()-$.current<DV||($.current=Date.now(),t.send({t:"refresh-git",repoId:s}),Z&&Z!==s&&t.send({t:"refresh-git",repoId:Z}))};return window.addEventListener("focus",te),()=>window.removeEventListener("focus",te)},[t,u,s,Z]);const q=L(te=>te.frame==="phone"&&te.screen==="home"?"surface1":"surface0");S.useEffect(()=>{try{sessionStorage.setItem(tt.ground,q)}catch{}},[q]);const K=L(te=>te.frame==="phone"),ne=L(te=>te.blackGround),de=S.useMemo(()=>K&&ne?kD(C):C,[K,ne,C]);S.useEffect(()=>{try{localStorage.setItem(tt.blackGround,ne?"1":"0")}catch{}},[ne]),S.useEffect(()=>{xC(de,{remember:!O,ground:q,black:de!==C}),cn.broadcast(EC(de))},[de,C,O,q]);const pe=S.useCallback(()=>{t==null||t.send({t:"zone",tz:Intl.DateTimeFormat().resolvedOptions().timeZone})},[t]);S.useEffect(()=>{if(!u)return;pe();const te=()=>{document.visibilityState==="visible"&&pe()};return document.addEventListener("visibilitychange",te),()=>document.removeEventListener("visibilitychange",te)},[u,pe]),S.useEffect(()=>{if(!u||f<=Date.now())return;const te=setTimeout(pe,f-Date.now()+1e3);return()=>clearTimeout(te)},[u,f,pe]),S.useEffect(()=>{h&&h.until>0&&cG(h)},[h]),S.useEffect(()=>{o&&r.set(tt.active,o)},[o,r]),S.useEffect(()=>{y&&r.set(tt.version,y)},[y,r]);const je=L(te=>te.frame==="phone"?te.screen!=="home":null);S.useEffect(()=>{je!==null&&r.session.set(tt.phoneRow,je?"1":"0")},[je,r]),S.useEffect(()=>{s&&r.set(tt.repo,s)},[s,r]),S.useEffect(()=>{try{localStorage.setItem(tt.rail,w?"1":"0")}catch{}},[w]),S.useEffect(()=>{try{localStorage.setItem(tt.chatSide,v)}catch{}},[v]),S.useEffect(()=>{try{localStorage.setItem(tt.layouts,JSON.stringify(N))}catch{}},[N]),S.useEffect(()=>{r.set(tt.lastActive,JSON.stringify(x))},[x,r]),S.useEffect(()=>{r.set(tt.discoveredOpen,JSON.stringify(_))},[_,r]),S.useEffect(()=>{r.set(tt.archivedOpen,JSON.stringify(j))},[j,r]),S.useEffect(()=>{r.set(tt.committedShut,JSON.stringify(T))},[T,r]),S.useEffect(()=>{r.set(tt.turnOpen,JSON.stringify(I))},[I,r]),S.useEffect(()=>{r.set(tt.treeOpen,JSON.stringify(R))},[R,r]),OV(),L6();const _e=S.useRef(null);return S.useEffect(()=>{!A||_e.current===A||(_e.current=A,window.open(A,"_blank"),e({a:"opened-url"}))},[A,e]),L(te=>te.frame)==="phone"?d.jsx(rG,{}):d.jsx(jV,{})}function FV({origin:e,machine:t,onToken:n}){const[r,o]=S.useState({kind:"asking"}),[s,a]=S.useState(0),c=URL.canParse(e)&&Rh(new URL(e).hostname);return it([s],()=>{const u=new AbortController;return o({kind:"asking"}),l_(e,u.signal,h=>o({kind:"waiting",word:h})).then(h=>{if(!u.signal.aborted){if(typeof h=="string"){o({kind:"failed",failure:h});return}o({kind:"in"}),n(h.token)}}),()=>u.abort()}),d.jsxs(ws,{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.":hC(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(Pe,{variant:"outline",onClick:()=>a(u=>u+1),children:"ask again"})})]})}const Bg="toyon-shared",BV="x-toyon-name";async function UV(e=globalThis.caches){var t;try{if(!e||!await e.has(Bg))return[];const n=await e.open(Bg),r=[];for(const o of await n.keys()){const s=await n.match(o);if(!s)continue;const a=decodeURIComponent(s.headers.get(BV)??"")||"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(Bg),r}catch{return[]}}function FE(e,t=()=>!0){const n=()=>t()?Pa(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 HV(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 WV(e,t){const n=await UV(t);if(n.length===0)return;if(e.getState().frame!=="phone"){ch(e,await FE(e),n);return}e.dispatch({a:"screen",to:"home"}),e.dispatch({a:"sharing",v:HV(n)});const r=await FE(e,()=>e.getState().screen!=="home");e.dispatch({a:"sharing",v:null}),ch(e,r,n)}function KV(){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(GA(t.worktreeId,t.stream))??[])n(t)}}}const qV=2e3,ZV=1500;function GV(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 G4,c.set(R,C)),C},h=new Map,f=new Map,m=R=>{var D;o.clear(f.get(R)),f.delete(R);const C=e.getState();if(R===""){if(!C.heard)return;const B=B4(C,s());if(!B)return;const W=Z4(Object.fromEntries([...h].map(([U,Q])=>[U,{at:Q}])),C.rows);for(const U of W)h.delete(U),c.delete(U);t.putHello(n,B).then(()=>W.length?t.dropChats(n,W):void 0);return}const O=c.get(R);if(!O||!C.rows.some(B=>B.id===R))return;const A=s();h.set(R,A),t.putChat(n,R,O.snapshot((D=C.local[R])==null?void 0:D.draft,A))},g=R=>{f.has(R)||f.set(R,o.set(()=>m(R),qV))},y=()=>{for(const R of[...f.keys()])m(R)};let w=e.getState();const v=new Map,N=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 O of c.keys()){const A=((C=R.local[O])==null?void 0:C.draft)??"";(v.get(O)??"")!==A&&(v.set(O,A),g(O))}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 _=Promise.all([t.hello(n),t.chats(n)]);let j;const T=new Promise(R=>{j=o.set(()=>R(null),ZV)});return{recalled:Promise.race([_,T]).then(R=>{if(o.clear(j),!R)return;const[C,O]=R;for(const[D,B]of Object.entries(O))h.set(D,B.at);if(!C||!tx(C)||e.getState().heard)return;const A={};for(const[D,B]of Object.entries(O))tx(B)&&(A[D]=B);try{e.dispatch({a:"recall",hello:C,chats:A})}catch(D){console.error("the last-known machine could not be recalled; dropping it",D),h.clear(),t.clear(n);return}for(const[D,B]of Object.entries(A))u(D).reset(B.events,B.seq,!1),v.set(D,B.draft??"")}).catch(R=>{console.error("the last-known machine could not be read",R)}),hear(R){var C;if(R.t==="backfill"){const O=u(R.worktreeId);g(R.worktreeId);const A=(((C=e.getState().local[R.worktreeId])==null?void 0:C.chat.length)??0)>0;if(R.after!==void 0&&R.after===O.since()&&A)return O.extend(R.events,R.last),R;if(O.reset(R.events,R.last,R.after===void 0),R.after===void 0)return R;const{after:D,...B}=R;return B}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[...f.keys()])o.clear(f.get(R)),f.delete(R);c.clear(),h.clear(),t.clear(n)},dispose(){N(),a==null||a.removeEventListener("visibilitychange",x),a==null||a.removeEventListener("pagehide",y),y()}}}function VV(){const e=new Map,t=n=>{const r=uo.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(uo.hello(n))??null,putHello:async(n,r)=>void e.set(uo.hello(n),r),chats:async n=>t(n),putChat:async(n,r,o)=>void e.set(uo.chat(n,r),o),dropChats:async(n,r)=>{for(const o of r)e.delete(uo.chat(n,o))},clear:async n=>{e.delete(uo.hello(n));for(const r of[...e.keys()])r.startsWith(uo.chats(n))&&e.delete(r)}}}function AC(){if(typeof indexedDB>"u")return VV();let e=null;const t=()=>(e??(e=new Promise((s,a)=>{const c=indexedDB.open(OD,1);c.onupgradeneeded=()=>c.result.createObjectStore(qc),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(qc,s).objectStore(qc);return new Promise((u,h)=>{const f=a(c);f.onsuccess=()=>u(f.result),f.onerror=()=>h(f.error)})},r=s=>{const a=uo.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(uo.hello(s))),void 0).then(a=>a??null),putHello:(s,a)=>o(n("readwrite",c=>c.put(a,uo.hello(s))),void 0).then(()=>{}),chats:async s=>{const a=uo.chats(s),[c,u]=await o((async()=>{const f=(await t()).transaction(qc,"readonly").objectStore(qc),m=g=>new Promise((y,w)=>{g.onsuccess=()=>y(g.result),g.onerror=()=>w(g.error)});return Promise.all([m(f.getAllKeys(r(s))),m(f.getAll(r(s)))])})(),[[],[]]),h={};return c.forEach((f,m)=>{const g=u[m];typeof f=="string"&&g&&(h[f.slice(a.length)]=g)}),h},putChat:(s,a,c)=>o(n("readwrite",u=>u.put(c,uo.chat(s,a))),void 0).then(()=>{}),dropChats:async(s,a)=>{for(const c of a)await o(n("readwrite",u=>u.delete(uo.chat(s,c))),void 0)},clear:async s=>{await o(n("readwrite",a=>a.delete(uo.hello(s))),void 0),await o(n("readwrite",a=>a.delete(r(s))),void 0)}}}function YV(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 XV(e){const t={};try{const n=JSON.parse(e??"{}");if(!n||typeof n!="object")return t;for(const[r,o]of Object.entries(n))J4(o)&&(t[r]=o)}catch{}return t}function QV(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 JV(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 eY=400,tY=2e3;function IC(){const e=new Map;return{another(t,n=0){return(e.get(t)??0)===n?!1:(e.set(t,n),!0)}}}function RC(e,t,n){const r=e.getState(),o=[];for(const[s,a]of t){if(a===n||r.local[s])continue;const c=ps(s);c&&c.clientId!==r.clientId||o.push(s)}return o}function nY(e,t){const n=new Map,r=new Map,o=IC(),s=u=>{var f,m;clearTimeout((f=r.get(u))==null?void 0:f.timer),r.delete(u);const h=e.getState().local[u];!h||((m=h.mark)==null?void 0:m.by)==="walk"||(n.get(u)??"")!==h.draft&&(n.set(u,h.draft),t.send({t:"set-draft",boxId:u,text:h.draft,clientId:e.getState().clientId}))},a=()=>{for(const u of[...r.keys()])s(u)},c=e.subscribe(()=>{var u,h,f;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,"")),((h=g.mark)==null?void 0:h.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(eY,w+tY-Date.now()));r.set(m,{text:g.draft,timer:setTimeout(s,v,m),since:w})}for(const m of RC(e,n,""))clearTimeout((f=r.get(m))==null?void 0:f.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[h,f]of Object.entries(u))n.set(h,f)},heard(u,h){return r.has(u)?!1:(n.set(u,h),!0)},dispose(){c();for(const u of r.values())clearTimeout(u.timer);r.clear(),window.removeEventListener("focusout",a),window.removeEventListener("pagehide",a)}}}function rY(e,t){const n=new Map,r=new Map,o=IC(),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 h=Dw(u.attachments),f=JSON.stringify(h),m=r.get(c)??"[]";m!==f&&(r.set(c,f),a.push({id:c,items:h,before:x_(JSON.parse(m))}))}for(const c of RC(e,r,"[]"))r.set(c,"[]"),a.push({id:c,items:[],before:[]});for(const c of D4(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 oY(e,t){return e.subscribe(()=>{for(const n of P4(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(nu(o.outgoing.frame,n,o.draft,o.attachments)),e.dispatch({a:"sent-out",id:n}))}})}const BE="not sent: the page reloaded while an upload was on its way; attach it again and send";function UE(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=ps(c);if((u==null?void 0:u.clientId)!==r.clientId||(a=r.local[c])!=null&&a.outgoing)continue;const h=n.drafts[c]??"",f=n.attachments[c]??[],m=n.drafts[u.source]??"",g=[...f,...n.attachments[u.source]??[]],y=m||h,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 sY(e,t){const n=(t.storage??MD)(e.origin),r=Bz(tz({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:XV(Lf(tt.layouts)),storedLastActive:QV(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:JV(n.get(tt.treeOpen)),clientId:t.clientId,frame:t.frame,touch:t.touch})),o=KV(),s={version:null,protocol:null},a=bB(v=>r.dispatch({a:"server",msg:v}));let c,u,h;const f=GV(r,t.snapshots??AC(),e.origin);let m=[];const g=new o4(e,v=>{if(v.t==="hello"){if(s.protocol=v.protocol,e.serving){const{rebuilt:x,update:_}=r.getState(),j=x&&(_==null?void 0:_.restarting)!=null;if(s.version!==null&&(j||v.version!==s.version||v.protocol!==ga)){g.dispose(),t.reload();return}if(v.protocol!==ga){r.dispatch({a:"incompatible"}),g.dispose();return}}else if(v.protocol!==ga){r.dispatch({a:"incompatible"}),g.suspend();return}else r.getState().incompatible&&r.dispatch({a:"incompatible",v:!1});s.version=v.version;const N=new Set(g.sentWhileDown());if(N.size){const x=_=>Object.fromEntries(Object.entries(_).filter(([j])=>!N.has(j)));v.drafts=x(v.drafts),v.attachments=x(v.attachments)}m=UE(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(vP(v)){o.deliver(v);return}if(bP(v)){if(v.t==="file-written"&&U3(v))return;h.receive(v);return}if(v.t==="loose-written"){LK(v);return}if(d8(v)){m8(r,g,v);return}if(v.t==="open-refused"){p8(r,v);return}a(f.hear(v));for(const N of m.splice(0))r.dispatch({a:"notice",id:N,text:BE})}},(v,N)=>r.dispatch({a:"connected",v,failure:N}),{},{known:()=>Mz(r.getState()),held:e.serving});q3(r,g.urls),h=new OK({store:r,send:v=>g.send(v),timers:{set:(v,N)=>setTimeout(v,N),clear:v=>clearTimeout(v)},win:window});const y=h.start();c=nY(r,g),u=rY(r,g);const w=oY(r,g);return{origin:e.origin,serving:e.serving,token:e.token,get name(){return r.getState().machine??YV(e.origin)},store:r,sock:g,files:h,terminals:o,storage:n,heard:s,recalled:f.recalled,forget:()=>f.forget(),boot(v){try{if((v==null?void 0:v.t)==="hello"&&v.protocol===ga){s.version??(s.version=v.version);const N=UE(r,g,v);u.hello(v.attachments),r.dispatch({a:"server",msg:v});for(const x of N)r.dispatch({a:"notice",id:x,text:BE})}}finally{g.resume()}},since:v=>{var N;return(N=r.getState().local[v])!=null&&N.chat.length?f.since(v):void 0},dispose(){g.dispose(),y(),c.dispose(),u.dispose(),w(),f.dispose()}}}function Lf(e){try{return localStorage.getItem(e)}catch{return null}}window.__toyonShell=!0;const OC=ZN();OC&&(document.documentElement.dataset.framed="");PD(location.origin);const MC=oG();xC(MC);function iY(e,t){try{return e.getItem(t)}catch{return null}}function aY(){const e=iY(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 lY={cached:MC,systemDark:iG(),daylight:lG(),clientId:aY(),frame:cy(),touch:F6(),reload:()=>window.location.reload(),snapshots:AC()},gs=pZ({serving:{origin:location.origin,token:n_()},build:e=>sY(e,lY)});B6({dispatch:e=>gs.broadcast(e)});uG(e=>gs.broadcast({a:"system-dark",v:e}));const LC=e=>OC?()=>{}:XZ(e);let HE=LC(gs.active().store),WE=gs.active();gs.subscribe(()=>{const e=gs.active();e!==WE&&(WE=e,HE(),e.store.getState().frame==="phone"&&e.store.dispatch({a:"screen",to:"home"}),HE=LC(e.store))});window.addEventListener("vite:preloadError",A5);const cY=Promise.all([(window.toyonBoot??Promise.resolve(null)).then(e=>{const t=e;gs.active().boot(t&&typeof t=="object"&&t.t==="hello"?t:null)}),gs.active().recalled]).catch(e=>{console.error("boot",e)});function uY(e){r_(e),window.location.reload()}const dY=DA.createRoot(document.getElementById("root"));cY.then(()=>{var e;ZE.flushSync(()=>dY.render(d.jsx(RA.StrictMode,{children:d.jsx(uy,{children:sh()?d.jsx(Hz,{machines:gs,children:d.jsx(zV,{})}):d.jsx(FV,{origin:location.origin,machine:location.host,onToken:uY})})}))),document.documentElement.style.removeProperty("background"),document.documentElement.style.removeProperty("--boot-ink"),(e=document.getElementById("boot"))==null||e.remove(),sh()&&WV(gs.active().store)});"serviceWorker"in navigator&&navigator.serviceWorker.register("/sw.js").catch(()=>{});export{Hs as F,sq as S,Yk as _,fr as a,Sw as b,gY as c,it as d,wY as e,pY as f,rS as g,ND as h,GA as i,d as j,BF as k,ky as l,nS as m,hY as n,mY as p,S as r,wD as s,Uu as t,kY as u,Zb as w};