toyon 0.19.0 → 0.20.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 (102) hide show
  1. package/dist/CHANGELOG.md +33 -0
  2. package/dist/cli.js +1 -1
  3. package/dist/daemon.js +604 -91
  4. package/dist/shell/assets/{Editor-B-1lrUVF.js → Editor--Z8ktewC.js} +3 -3
  5. package/dist/shell/assets/Editor--Z8ktewC.js.br +0 -0
  6. package/dist/shell/assets/Editor--Z8ktewC.js.gz +0 -0
  7. package/dist/shell/assets/{XTerm-CZl-vWEO.js → XTerm-DsUQ0Xew.js} +1 -1
  8. package/dist/shell/assets/XTerm-DsUQ0Xew.js.br +0 -0
  9. package/dist/shell/assets/XTerm-DsUQ0Xew.js.gz +0 -0
  10. package/dist/shell/assets/{cssMode-BpigOakf.js → cssMode-BjAkCPrp.js} +1 -1
  11. package/dist/shell/assets/cssMode-BjAkCPrp.js.br +0 -0
  12. package/dist/shell/assets/cssMode-BjAkCPrp.js.gz +0 -0
  13. package/dist/shell/assets/{freemarker2-vvh2KLdJ.js → freemarker2-BZCFxXwq.js} +1 -1
  14. package/dist/shell/assets/freemarker2-BZCFxXwq.js.br +0 -0
  15. package/dist/shell/assets/freemarker2-BZCFxXwq.js.gz +0 -0
  16. package/dist/shell/assets/{grammar-DBMSnNcB.js → grammar-CQ1uaD6_.js} +1 -1
  17. package/dist/shell/assets/{grammar-DBMSnNcB.js.br → grammar-CQ1uaD6_.js.br} +0 -0
  18. package/dist/shell/assets/grammar-CQ1uaD6_.js.gz +0 -0
  19. package/dist/shell/assets/{handlebars-ExFAR1bz.js → handlebars-G1zJeDLP.js} +1 -1
  20. package/dist/shell/assets/handlebars-G1zJeDLP.js.br +0 -0
  21. package/dist/shell/assets/handlebars-G1zJeDLP.js.gz +0 -0
  22. package/dist/shell/assets/{html-DpIWoe_L.js → html-CUHSCFMy.js} +1 -1
  23. package/dist/shell/assets/html-CUHSCFMy.js.br +0 -0
  24. package/dist/shell/assets/html-CUHSCFMy.js.gz +0 -0
  25. package/dist/shell/assets/{htmlMode-vCEOKCM-.js → htmlMode-gpMedtd9.js} +1 -1
  26. package/dist/shell/assets/htmlMode-gpMedtd9.js.br +0 -0
  27. package/dist/shell/assets/htmlMode-gpMedtd9.js.gz +0 -0
  28. package/dist/shell/assets/index-B3Alj0WH.css +1 -0
  29. package/dist/shell/assets/index-B3Alj0WH.css.br +0 -0
  30. package/dist/shell/assets/index-B3Alj0WH.css.gz +0 -0
  31. package/dist/shell/assets/index-VVd_p5tJ.js +278 -0
  32. package/dist/shell/assets/index-VVd_p5tJ.js.br +0 -0
  33. package/dist/shell/assets/index-VVd_p5tJ.js.gz +0 -0
  34. package/dist/shell/assets/{javascript-CF6f9y1O.js → javascript-BHWH8gQN.js} +1 -1
  35. package/dist/shell/assets/{jsonMode-CZzpDv9U.js → jsonMode-DyV5nvVT.js} +1 -1
  36. package/dist/shell/assets/jsonMode-DyV5nvVT.js.br +0 -0
  37. package/dist/shell/assets/jsonMode-DyV5nvVT.js.gz +0 -0
  38. package/dist/shell/assets/{liquid-5T0ZgJhW.js → liquid-Dy3tUgRC.js} +1 -1
  39. package/dist/shell/assets/liquid-Dy3tUgRC.js.br +0 -0
  40. package/dist/shell/assets/liquid-Dy3tUgRC.js.gz +0 -0
  41. package/dist/shell/assets/{lspLanguageFeatures-DrkNrp6u.js → lspLanguageFeatures-CB_Ow-w5.js} +1 -1
  42. package/dist/shell/assets/lspLanguageFeatures-CB_Ow-w5.js.br +0 -0
  43. package/dist/shell/assets/lspLanguageFeatures-CB_Ow-w5.js.gz +0 -0
  44. package/dist/shell/assets/{mdx-DnLcCYKb.js → mdx-DD5jgco_.js} +1 -1
  45. package/dist/shell/assets/mdx-DD5jgco_.js.br +0 -0
  46. package/dist/shell/assets/mdx-DD5jgco_.js.gz +0 -0
  47. package/dist/shell/assets/{python-Di4WuyJe.js → python-BvLKUXll.js} +1 -1
  48. package/dist/shell/assets/python-BvLKUXll.js.br +0 -0
  49. package/dist/shell/assets/python-BvLKUXll.js.gz +0 -0
  50. package/dist/shell/assets/{razor-NpEB1IHs.js → razor-B2tUlbzR.js} +1 -1
  51. package/dist/shell/assets/razor-B2tUlbzR.js.br +0 -0
  52. package/dist/shell/assets/razor-B2tUlbzR.js.gz +0 -0
  53. package/dist/shell/assets/{tsMode-BylSuxTF.js → tsMode-DMuNnqM7.js} +1 -1
  54. package/dist/shell/assets/tsMode-DMuNnqM7.js.br +0 -0
  55. package/dist/shell/assets/tsMode-DMuNnqM7.js.gz +0 -0
  56. package/dist/shell/assets/{xml-BYRl5HAh.js → xml-DdYgb5a2.js} +1 -1
  57. package/dist/shell/assets/xml-DdYgb5a2.js.br +0 -0
  58. package/dist/shell/assets/xml-DdYgb5a2.js.gz +0 -0
  59. package/dist/shell/assets/{yaml-DeSD0TUR.js → yaml-BDujJdoL.js} +1 -1
  60. package/dist/shell/assets/yaml-BDujJdoL.js.br +0 -0
  61. package/dist/shell/assets/yaml-BDujJdoL.js.gz +0 -0
  62. package/dist/shell/index.html +2 -2
  63. package/package.json +1 -1
  64. package/dist/shell/assets/Editor-B-1lrUVF.js.br +0 -0
  65. package/dist/shell/assets/Editor-B-1lrUVF.js.gz +0 -0
  66. package/dist/shell/assets/XTerm-CZl-vWEO.js.br +0 -0
  67. package/dist/shell/assets/XTerm-CZl-vWEO.js.gz +0 -0
  68. package/dist/shell/assets/cssMode-BpigOakf.js.br +0 -0
  69. package/dist/shell/assets/cssMode-BpigOakf.js.gz +0 -0
  70. package/dist/shell/assets/freemarker2-vvh2KLdJ.js.br +0 -0
  71. package/dist/shell/assets/freemarker2-vvh2KLdJ.js.gz +0 -0
  72. package/dist/shell/assets/grammar-DBMSnNcB.js.gz +0 -0
  73. package/dist/shell/assets/handlebars-ExFAR1bz.js.br +0 -0
  74. package/dist/shell/assets/handlebars-ExFAR1bz.js.gz +0 -0
  75. package/dist/shell/assets/html-DpIWoe_L.js.br +0 -0
  76. package/dist/shell/assets/html-DpIWoe_L.js.gz +0 -0
  77. package/dist/shell/assets/htmlMode-vCEOKCM-.js.br +0 -0
  78. package/dist/shell/assets/htmlMode-vCEOKCM-.js.gz +0 -0
  79. package/dist/shell/assets/index-CHbNBHbD.css +0 -1
  80. package/dist/shell/assets/index-CHbNBHbD.css.br +0 -0
  81. package/dist/shell/assets/index-CHbNBHbD.css.gz +0 -0
  82. package/dist/shell/assets/index-D5GN5OOv.js +0 -276
  83. package/dist/shell/assets/index-D5GN5OOv.js.br +0 -0
  84. package/dist/shell/assets/index-D5GN5OOv.js.gz +0 -0
  85. package/dist/shell/assets/jsonMode-CZzpDv9U.js.br +0 -0
  86. package/dist/shell/assets/jsonMode-CZzpDv9U.js.gz +0 -0
  87. package/dist/shell/assets/liquid-5T0ZgJhW.js.br +0 -0
  88. package/dist/shell/assets/liquid-5T0ZgJhW.js.gz +0 -0
  89. package/dist/shell/assets/lspLanguageFeatures-DrkNrp6u.js.br +0 -0
  90. package/dist/shell/assets/lspLanguageFeatures-DrkNrp6u.js.gz +0 -0
  91. package/dist/shell/assets/mdx-DnLcCYKb.js.br +0 -0
  92. package/dist/shell/assets/mdx-DnLcCYKb.js.gz +0 -0
  93. package/dist/shell/assets/python-Di4WuyJe.js.br +0 -0
  94. package/dist/shell/assets/python-Di4WuyJe.js.gz +0 -0
  95. package/dist/shell/assets/razor-NpEB1IHs.js.br +0 -0
  96. package/dist/shell/assets/razor-NpEB1IHs.js.gz +0 -0
  97. package/dist/shell/assets/tsMode-BylSuxTF.js.br +0 -0
  98. package/dist/shell/assets/tsMode-BylSuxTF.js.gz +0 -0
  99. package/dist/shell/assets/xml-BYRl5HAh.js.br +0 -0
  100. package/dist/shell/assets/xml-BYRl5HAh.js.gz +0 -0
  101. package/dist/shell/assets/yaml-DeSD0TUR.js.br +0 -0
  102. package/dist/shell/assets/yaml-DeSD0TUR.js.gz +0 -0
@@ -1,276 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/Editor-B-1lrUVF.js","assets/grammar-DBMSnNcB.js","assets/Editor-CB2SckMT.css","assets/XTerm-CZl-vWEO.js","assets/XTerm-6GBZ9nXN.css"])))=>i.map(i=>d[i]);
2
- var uC=Object.defineProperty;var dC=(e,t,n)=>t in e?uC(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var St=(e,t,n)=>dC(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 i of o)if(i.type==="childList")for(const l of i.addedNodes)l.tagName==="LINK"&&l.rel==="modulepreload"&&r(l)}).observe(document,{childList:!0,subtree:!0});function n(o){const i={};return o.integrity&&(i.integrity=o.integrity),o.referrerPolicy&&(i.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?i.credentials="include":o.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function r(o){if(o.ep)return;o.ep=!0;const i=n(o);fetch(o.href,i)}})();function W1(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var pm={exports:{}},Ec={},mm={exports:{}},Jt={};/**
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 fC(){if(u0)return Jt;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"),i=Symbol.for("react.provider"),l=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(Z){return Z===null||typeof Z!="object"?null:(Z=m&&Z[m]||Z["@@iterator"],typeof Z=="function"?Z:null)}var w={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},y=Object.assign,v={};function _(Z,ie,be){this.props=Z,this.context=ie,this.refs=v,this.updater=be||w}_.prototype.isReactComponent={},_.prototype.setState=function(Z,ie){if(typeof Z!="object"&&typeof Z!="function"&&Z!=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,Z,ie,"setState")},_.prototype.forceUpdate=function(Z){this.updater.enqueueForceUpdate(this,Z,"forceUpdate")};function x(){}x.prototype=_.prototype;function T(Z,ie,be){this.props=Z,this.context=ie,this.refs=v,this.updater=be||w}var N=T.prototype=new x;N.constructor=T,y(N,_.prototype),N.isPureReactComponent=!0;var j=Array.isArray,$=Object.prototype.hasOwnProperty,O={current:null},I={key:!0,ref:!0,__self:!0,__source:!0};function P(Z,ie,be){var ge,we={},pe=null,Q=null;if(ie!=null)for(ge in ie.ref!==void 0&&(Q=ie.ref),ie.key!==void 0&&(pe=""+ie.key),ie)$.call(ie,ge)&&!I.hasOwnProperty(ge)&&(we[ge]=ie[ge]);var W=arguments.length-2;if(W===1)we.children=be;else if(1<W){for(var ye=Array(W),_e=0;_e<W;_e++)ye[_e]=arguments[_e+2];we.children=ye}if(Z&&Z.defaultProps)for(ge in W=Z.defaultProps,W)we[ge]===void 0&&(we[ge]=W[ge]);return{$$typeof:e,type:Z,key:pe,ref:Q,props:we,_owner:O.current}}function R(Z,ie){return{$$typeof:e,type:Z.type,key:ie,ref:Z.ref,props:Z.props,_owner:Z._owner}}function U(Z){return typeof Z=="object"&&Z!==null&&Z.$$typeof===e}function F(Z){var ie={"=":"=0",":":"=2"};return"$"+Z.replace(/[=:]/g,function(be){return ie[be]})}var B=/\/+/g;function X(Z,ie){return typeof Z=="object"&&Z!==null&&Z.key!=null?F(""+Z.key):ie.toString(36)}function ae(Z,ie,be,ge,we){var pe=typeof Z;(pe==="undefined"||pe==="boolean")&&(Z=null);var Q=!1;if(Z===null)Q=!0;else switch(pe){case"string":case"number":Q=!0;break;case"object":switch(Z.$$typeof){case e:case t:Q=!0}}if(Q)return Q=Z,we=we(Q),Z=ge===""?"."+X(Q,0):ge,j(we)?(be="",Z!=null&&(be=Z.replace(B,"$&/")+"/"),ae(we,ie,be,"",function(_e){return _e})):we!=null&&(U(we)&&(we=R(we,be+(!we.key||Q&&Q.key===we.key?"":(""+we.key).replace(B,"$&/")+"/")+Z)),ie.push(we)),1;if(Q=0,ge=ge===""?".":ge+":",j(Z))for(var W=0;W<Z.length;W++){pe=Z[W];var ye=ge+X(pe,W);Q+=ae(pe,ie,be,ye,we)}else if(ye=g(Z),typeof ye=="function")for(Z=ye.call(Z),W=0;!(pe=Z.next()).done;)pe=pe.value,ye=ge+X(pe,W++),Q+=ae(pe,ie,be,ye,we);else if(pe==="object")throw ie=String(Z),Error("Objects are not valid as a React child (found: "+(ie==="[object Object]"?"object with keys {"+Object.keys(Z).join(", ")+"}":ie)+"). If you meant to render a collection of children, use an array instead.");return Q}function Y(Z,ie,be){if(Z==null)return Z;var ge=[],we=0;return ae(Z,ge,"","",function(pe){return ie.call(be,pe,we++)}),ge}function ne(Z){if(Z._status===-1){var ie=Z._result;ie=ie(),ie.then(function(be){(Z._status===0||Z._status===-1)&&(Z._status=1,Z._result=be)},function(be){(Z._status===0||Z._status===-1)&&(Z._status=2,Z._result=be)}),Z._status===-1&&(Z._status=0,Z._result=ie)}if(Z._status===1)return Z._result.default;throw Z._result}var C={current:null},H={transition:null},V={ReactCurrentDispatcher:C,ReactCurrentBatchConfig:H,ReactCurrentOwner:O};function J(){throw Error("act(...) is not supported in production builds of React.")}return Jt.Children={map:Y,forEach:function(Z,ie,be){Y(Z,function(){ie.apply(this,arguments)},be)},count:function(Z){var ie=0;return Y(Z,function(){ie++}),ie},toArray:function(Z){return Y(Z,function(ie){return ie})||[]},only:function(Z){if(!U(Z))throw Error("React.Children.only expected to receive a single React element child.");return Z}},Jt.Component=_,Jt.Fragment=n,Jt.Profiler=o,Jt.PureComponent=T,Jt.StrictMode=r,Jt.Suspense=u,Jt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=V,Jt.act=J,Jt.cloneElement=function(Z,ie,be){if(Z==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+Z+".");var ge=y({},Z.props),we=Z.key,pe=Z.ref,Q=Z._owner;if(ie!=null){if(ie.ref!==void 0&&(pe=ie.ref,Q=O.current),ie.key!==void 0&&(we=""+ie.key),Z.type&&Z.type.defaultProps)var W=Z.type.defaultProps;for(ye in ie)$.call(ie,ye)&&!I.hasOwnProperty(ye)&&(ge[ye]=ie[ye]===void 0&&W!==void 0?W[ye]:ie[ye])}var ye=arguments.length-2;if(ye===1)ge.children=be;else if(1<ye){W=Array(ye);for(var _e=0;_e<ye;_e++)W[_e]=arguments[_e+2];ge.children=W}return{$$typeof:e,type:Z.type,key:we,ref:pe,props:ge,_owner:Q}},Jt.createContext=function(Z){return Z={$$typeof:l,_currentValue:Z,_currentValue2:Z,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},Z.Provider={$$typeof:i,_context:Z},Z.Consumer=Z},Jt.createElement=P,Jt.createFactory=function(Z){var ie=P.bind(null,Z);return ie.type=Z,ie},Jt.createRef=function(){return{current:null}},Jt.forwardRef=function(Z){return{$$typeof:c,render:Z}},Jt.isValidElement=U,Jt.lazy=function(Z){return{$$typeof:f,_payload:{_status:-1,_result:Z},_init:ne}},Jt.memo=function(Z,ie){return{$$typeof:h,type:Z,compare:ie===void 0?null:ie}},Jt.startTransition=function(Z){var ie=H.transition;H.transition={};try{Z()}finally{H.transition=ie}},Jt.unstable_act=J,Jt.useCallback=function(Z,ie){return C.current.useCallback(Z,ie)},Jt.useContext=function(Z){return C.current.useContext(Z)},Jt.useDebugValue=function(){},Jt.useDeferredValue=function(Z){return C.current.useDeferredValue(Z)},Jt.useEffect=function(Z,ie){return C.current.useEffect(Z,ie)},Jt.useId=function(){return C.current.useId()},Jt.useImperativeHandle=function(Z,ie,be){return C.current.useImperativeHandle(Z,ie,be)},Jt.useInsertionEffect=function(Z,ie){return C.current.useInsertionEffect(Z,ie)},Jt.useLayoutEffect=function(Z,ie){return C.current.useLayoutEffect(Z,ie)},Jt.useMemo=function(Z,ie){return C.current.useMemo(Z,ie)},Jt.useReducer=function(Z,ie,be){return C.current.useReducer(Z,ie,be)},Jt.useRef=function(Z){return C.current.useRef(Z)},Jt.useState=function(Z){return C.current.useState(Z)},Jt.useSyncExternalStore=function(Z,ie,be){return C.current.useSyncExternalStore(Z,ie,be)},Jt.useTransition=function(){return C.current.useTransition()},Jt.version="18.3.1",Jt}var d0;function yk(){return d0||(d0=1,mm.exports=fC()),mm.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 f0;function hC(){if(f0)return Ec;f0=1;var e=yk(),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,i={key:!0,ref:!0,__self:!0,__source:!0};function l(c,u,h){var f,m={},g=null,w=null;h!==void 0&&(g=""+h),u.key!==void 0&&(g=""+u.key),u.ref!==void 0&&(w=u.ref);for(f in u)r.call(u,f)&&!i.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:w,props:m,_owner:o.current}}return Ec.Fragment=n,Ec.jsx=l,Ec.jsxs=l,Ec}var h0;function pC(){return h0||(h0=1,pm.exports=hC()),pm.exports}var d=pC(),S=yk();const mC=W1(S);var gm={exports:{}},oo={},km={exports:{}},wm={};/**
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 p0;function gC(){return p0||(p0=1,(function(e){function t(H,V){var J=H.length;H.push(V);e:for(;0<J;){var Z=J-1>>>1,ie=H[Z];if(0<o(ie,V))H[Z]=V,H[J]=ie,J=Z;else break e}}function n(H){return H.length===0?null:H[0]}function r(H){if(H.length===0)return null;var V=H[0],J=H.pop();if(J!==V){H[0]=J;e:for(var Z=0,ie=H.length,be=ie>>>1;Z<be;){var ge=2*(Z+1)-1,we=H[ge],pe=ge+1,Q=H[pe];if(0>o(we,J))pe<ie&&0>o(Q,we)?(H[Z]=Q,H[pe]=J,Z=pe):(H[Z]=we,H[ge]=J,Z=ge);else if(pe<ie&&0>o(Q,J))H[Z]=Q,H[pe]=J,Z=pe;else break e}}return V}function o(H,V){var J=H.sortIndex-V.sortIndex;return J!==0?J:H.id-V.id}if(typeof performance=="object"&&typeof performance.now=="function"){var i=performance;e.unstable_now=function(){return i.now()}}else{var l=Date,c=l.now();e.unstable_now=function(){return l.now()-c}}var u=[],h=[],f=1,m=null,g=3,w=!1,y=!1,v=!1,_=typeof setTimeout=="function"?setTimeout:null,x=typeof clearTimeout=="function"?clearTimeout:null,T=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function N(H){for(var V=n(h);V!==null;){if(V.callback===null)r(h);else if(V.startTime<=H)r(h),V.sortIndex=V.expirationTime,t(u,V);else break;V=n(h)}}function j(H){if(v=!1,N(H),!y)if(n(u)!==null)y=!0,ne($);else{var V=n(h);V!==null&&C(j,V.startTime-H)}}function $(H,V){y=!1,v&&(v=!1,x(P),P=-1),w=!0;var J=g;try{for(N(V),m=n(u);m!==null&&(!(m.expirationTime>V)||H&&!F());){var Z=m.callback;if(typeof Z=="function"){m.callback=null,g=m.priorityLevel;var ie=Z(m.expirationTime<=V);V=e.unstable_now(),typeof ie=="function"?m.callback=ie:m===n(u)&&r(u),N(V)}else r(u);m=n(u)}if(m!==null)var be=!0;else{var ge=n(h);ge!==null&&C(j,ge.startTime-V),be=!1}return be}finally{m=null,g=J,w=!1}}var O=!1,I=null,P=-1,R=5,U=-1;function F(){return!(e.unstable_now()-U<R)}function B(){if(I!==null){var H=e.unstable_now();U=H;var V=!0;try{V=I(!0,H)}finally{V?X():(O=!1,I=null)}}else O=!1}var X;if(typeof T=="function")X=function(){T(B)};else if(typeof MessageChannel<"u"){var ae=new MessageChannel,Y=ae.port2;ae.port1.onmessage=B,X=function(){Y.postMessage(null)}}else X=function(){_(B,0)};function ne(H){I=H,O||(O=!0,X())}function C(H,V){P=_(function(){H(e.unstable_now())},V)}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(H){H.callback=null},e.unstable_continueExecution=function(){y||w||(y=!0,ne($))},e.unstable_forceFrameRate=function(H){0>H||125<H?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):R=0<H?Math.floor(1e3/H):5},e.unstable_getCurrentPriorityLevel=function(){return g},e.unstable_getFirstCallbackNode=function(){return n(u)},e.unstable_next=function(H){switch(g){case 1:case 2:case 3:var V=3;break;default:V=g}var J=g;g=V;try{return H()}finally{g=J}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(H,V){switch(H){case 1:case 2:case 3:case 4:case 5:break;default:H=3}var J=g;g=H;try{return V()}finally{g=J}},e.unstable_scheduleCallback=function(H,V,J){var Z=e.unstable_now();switch(typeof J=="object"&&J!==null?(J=J.delay,J=typeof J=="number"&&0<J?Z+J:Z):J=Z,H){case 1:var ie=-1;break;case 2:ie=250;break;case 5:ie=1073741823;break;case 4:ie=1e4;break;default:ie=5e3}return ie=J+ie,H={id:f++,callback:V,priorityLevel:H,startTime:J,expirationTime:ie,sortIndex:-1},J>Z?(H.sortIndex=J,t(h,H),n(u)===null&&H===n(h)&&(v?(x(P),P=-1):v=!0,C(j,J-Z))):(H.sortIndex=ie,t(u,H),y||w||(y=!0,ne($))),H},e.unstable_shouldYield=F,e.unstable_wrapCallback=function(H){var V=g;return function(){var J=g;g=V;try{return H.apply(this,arguments)}finally{g=J}}}})(wm)),wm}var m0;function kC(){return m0||(m0=1,km.exports=gC()),km.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 wC(){if(g0)return oo;g0=1;var e=yk(),t=kC();function n(s){for(var a="https://reactjs.org/docs/error-decoder.html?invariant="+s,p=1;p<arguments.length;p++)a+="&args[]="+encodeURIComponent(arguments[p]);return"Minified React error #"+s+"; visit "+a+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var r=new Set,o={};function i(s,a){l(s,a),l(s+"Capture",a)}function l(s,a){for(o[s]=a,s=0;s<a.length;s++)r.add(a[s])}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(s){return u.call(m,s)?!0:u.call(f,s)?!1:h.test(s)?m[s]=!0:(f[s]=!0,!1)}function w(s,a,p,k){if(p!==null&&p.type===0)return!1;switch(typeof a){case"function":case"symbol":return!0;case"boolean":return k?!1:p!==null?!p.acceptsBooleans:(s=s.toLowerCase().slice(0,5),s!=="data-"&&s!=="aria-");default:return!1}}function y(s,a,p,k){if(a===null||typeof a>"u"||w(s,a,p,k))return!0;if(k)return!1;if(p!==null)switch(p.type){case 3:return!a;case 4:return a===!1;case 5:return isNaN(a);case 6:return isNaN(a)||1>a}return!1}function v(s,a,p,k,b,E,A){this.acceptsBooleans=a===2||a===3||a===4,this.attributeName=k,this.attributeNamespace=b,this.mustUseProperty=p,this.propertyName=s,this.type=a,this.sanitizeURL=E,this.removeEmptyString=A}var _={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(s){_[s]=new v(s,0,!1,s,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(s){var a=s[0];_[a]=new v(a,1,!1,s[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(s){_[s]=new v(s,2,!1,s.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(s){_[s]=new v(s,2,!1,s,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(s){_[s]=new v(s,3,!1,s.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(s){_[s]=new v(s,3,!0,s,null,!1,!1)}),["capture","download"].forEach(function(s){_[s]=new v(s,4,!1,s,null,!1,!1)}),["cols","rows","size","span"].forEach(function(s){_[s]=new v(s,6,!1,s,null,!1,!1)}),["rowSpan","start"].forEach(function(s){_[s]=new v(s,5,!1,s.toLowerCase(),null,!1,!1)});var x=/[\-:]([a-z])/g;function T(s){return s[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(s){var a=s.replace(x,T);_[a]=new v(a,1,!1,s,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(s){var a=s.replace(x,T);_[a]=new v(a,1,!1,s,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(s){var a=s.replace(x,T);_[a]=new v(a,1,!1,s,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(s){_[s]=new v(s,1,!1,s.toLowerCase(),null,!1,!1)}),_.xlinkHref=new v("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(s){_[s]=new v(s,1,!1,s.toLowerCase(),null,!0,!0)});function N(s,a,p,k){var b=_.hasOwnProperty(a)?_[a]:null;(b!==null?b.type!==0:k||!(2<a.length)||a[0]!=="o"&&a[0]!=="O"||a[1]!=="n"&&a[1]!=="N")&&(y(a,p,b,k)&&(p=null),k||b===null?g(a)&&(p===null?s.removeAttribute(a):s.setAttribute(a,""+p)):b.mustUseProperty?s[b.propertyName]=p===null?b.type===3?!1:"":p:(a=b.attributeName,k=b.attributeNamespace,p===null?s.removeAttribute(a):(b=b.type,p=b===3||b===4&&p===!0?"":""+p,k?s.setAttributeNS(k,a,p):s.setAttribute(a,p))))}var j=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,$=Symbol.for("react.element"),O=Symbol.for("react.portal"),I=Symbol.for("react.fragment"),P=Symbol.for("react.strict_mode"),R=Symbol.for("react.profiler"),U=Symbol.for("react.provider"),F=Symbol.for("react.context"),B=Symbol.for("react.forward_ref"),X=Symbol.for("react.suspense"),ae=Symbol.for("react.suspense_list"),Y=Symbol.for("react.memo"),ne=Symbol.for("react.lazy"),C=Symbol.for("react.offscreen"),H=Symbol.iterator;function V(s){return s===null||typeof s!="object"?null:(s=H&&s[H]||s["@@iterator"],typeof s=="function"?s:null)}var J=Object.assign,Z;function ie(s){if(Z===void 0)try{throw Error()}catch(p){var a=p.stack.trim().match(/\n( *(at )?)/);Z=a&&a[1]||""}return`
35
- `+Z+s}var be=!1;function ge(s,a){if(!s||be)return"";be=!0;var p=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(a)if(a=function(){throw Error()},Object.defineProperty(a.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(a,[])}catch(he){var k=he}Reflect.construct(s,[],a)}else{try{a.call()}catch(he){k=he}s.call(a.prototype)}else{try{throw Error()}catch(he){k=he}s()}}catch(he){if(he&&k&&typeof he.stack=="string"){for(var b=he.stack.split(`
36
- `),E=k.stack.split(`
37
- `),A=b.length-1,q=E.length-1;1<=A&&0<=q&&b[A]!==E[q];)q--;for(;1<=A&&0<=q;A--,q--)if(b[A]!==E[q]){if(A!==1||q!==1)do if(A--,q--,0>q||b[A]!==E[q]){var te=`
38
- `+b[A].replace(" at new "," at ");return s.displayName&&te.includes("<anonymous>")&&(te=te.replace("<anonymous>",s.displayName)),te}while(1<=A&&0<=q);break}}}finally{be=!1,Error.prepareStackTrace=p}return(s=s?s.displayName||s.name:"")?ie(s):""}function we(s){switch(s.tag){case 5:return ie(s.type);case 16:return ie("Lazy");case 13:return ie("Suspense");case 19:return ie("SuspenseList");case 0:case 2:case 15:return s=ge(s.type,!1),s;case 11:return s=ge(s.type.render,!1),s;case 1:return s=ge(s.type,!0),s;default:return""}}function pe(s){if(s==null)return null;if(typeof s=="function")return s.displayName||s.name||null;if(typeof s=="string")return s;switch(s){case I:return"Fragment";case O:return"Portal";case R:return"Profiler";case P:return"StrictMode";case X:return"Suspense";case ae:return"SuspenseList"}if(typeof s=="object")switch(s.$$typeof){case F:return(s.displayName||"Context")+".Consumer";case U:return(s._context.displayName||"Context")+".Provider";case B:var a=s.render;return s=s.displayName,s||(s=a.displayName||a.name||"",s=s!==""?"ForwardRef("+s+")":"ForwardRef"),s;case Y:return a=s.displayName||null,a!==null?a:pe(s.type)||"Memo";case ne:a=s._payload,s=s._init;try{return pe(s(a))}catch{}}return null}function Q(s){var a=s.type;switch(s.tag){case 24:return"Cache";case 9:return(a.displayName||"Context")+".Consumer";case 10:return(a._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return s=a.render,s=s.displayName||s.name||"",a.displayName||(s!==""?"ForwardRef("+s+")":"ForwardRef");case 7:return"Fragment";case 5:return a;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return pe(a);case 8:return a===P?"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 a=="function")return a.displayName||a.name||null;if(typeof a=="string")return a}return null}function W(s){switch(typeof s){case"boolean":case"number":case"string":case"undefined":return s;case"object":return s;default:return""}}function ye(s){var a=s.type;return(s=s.nodeName)&&s.toLowerCase()==="input"&&(a==="checkbox"||a==="radio")}function _e(s){var a=ye(s)?"checked":"value",p=Object.getOwnPropertyDescriptor(s.constructor.prototype,a),k=""+s[a];if(!s.hasOwnProperty(a)&&typeof p<"u"&&typeof p.get=="function"&&typeof p.set=="function"){var b=p.get,E=p.set;return Object.defineProperty(s,a,{configurable:!0,get:function(){return b.call(this)},set:function(A){k=""+A,E.call(this,A)}}),Object.defineProperty(s,a,{enumerable:p.enumerable}),{getValue:function(){return k},setValue:function(A){k=""+A},stopTracking:function(){s._valueTracker=null,delete s[a]}}}}function ve(s){s._valueTracker||(s._valueTracker=_e(s))}function ce(s){if(!s)return!1;var a=s._valueTracker;if(!a)return!0;var p=a.getValue(),k="";return s&&(k=ye(s)?s.checked?"true":"false":s.value),s=k,s!==p?(a.setValue(s),!0):!1}function Se(s){if(s=s||(typeof document<"u"?document:void 0),typeof s>"u")return null;try{return s.activeElement||s.body}catch{return s.body}}function me(s,a){var p=a.checked;return J({},a,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:p??s._wrapperState.initialChecked})}function Ue(s,a){var p=a.defaultValue==null?"":a.defaultValue,k=a.checked!=null?a.checked:a.defaultChecked;p=W(a.value!=null?a.value:p),s._wrapperState={initialChecked:k,initialValue:p,controlled:a.type==="checkbox"||a.type==="radio"?a.checked!=null:a.value!=null}}function Ie(s,a){a=a.checked,a!=null&&N(s,"checked",a,!1)}function We(s,a){Ie(s,a);var p=W(a.value),k=a.type;if(p!=null)k==="number"?(p===0&&s.value===""||s.value!=p)&&(s.value=""+p):s.value!==""+p&&(s.value=""+p);else if(k==="submit"||k==="reset"){s.removeAttribute("value");return}a.hasOwnProperty("value")?en(s,a.type,p):a.hasOwnProperty("defaultValue")&&en(s,a.type,W(a.defaultValue)),a.checked==null&&a.defaultChecked!=null&&(s.defaultChecked=!!a.defaultChecked)}function mt(s,a,p){if(a.hasOwnProperty("value")||a.hasOwnProperty("defaultValue")){var k=a.type;if(!(k!=="submit"&&k!=="reset"||a.value!==void 0&&a.value!==null))return;a=""+s._wrapperState.initialValue,p||a===s.value||(s.value=a),s.defaultValue=a}p=s.name,p!==""&&(s.name=""),s.defaultChecked=!!s._wrapperState.initialChecked,p!==""&&(s.name=p)}function en(s,a,p){(a!=="number"||Se(s.ownerDocument)!==s)&&(p==null?s.defaultValue=""+s._wrapperState.initialValue:s.defaultValue!==""+p&&(s.defaultValue=""+p))}var Kt=Array.isArray;function Be(s,a,p,k){if(s=s.options,a){a={};for(var b=0;b<p.length;b++)a["$"+p[b]]=!0;for(p=0;p<s.length;p++)b=a.hasOwnProperty("$"+s[p].value),s[p].selected!==b&&(s[p].selected=b),b&&k&&(s[p].defaultSelected=!0)}else{for(p=""+W(p),a=null,b=0;b<s.length;b++){if(s[b].value===p){s[b].selected=!0,k&&(s[b].defaultSelected=!0);return}a!==null||s[b].disabled||(a=s[b])}a!==null&&(a.selected=!0)}}function Xt(s,a){if(a.dangerouslySetInnerHTML!=null)throw Error(n(91));return J({},a,{value:void 0,defaultValue:void 0,children:""+s._wrapperState.initialValue})}function ln(s,a){var p=a.value;if(p==null){if(p=a.children,a=a.defaultValue,p!=null){if(a!=null)throw Error(n(92));if(Kt(p)){if(1<p.length)throw Error(n(93));p=p[0]}a=p}a==null&&(a=""),p=a}s._wrapperState={initialValue:W(p)}}function It(s,a){var p=W(a.value),k=W(a.defaultValue);p!=null&&(p=""+p,p!==s.value&&(s.value=p),a.defaultValue==null&&s.defaultValue!==p&&(s.defaultValue=p)),k!=null&&(s.defaultValue=""+k)}function Je(s){var a=s.textContent;a===s._wrapperState.initialValue&&a!==""&&a!==null&&(s.value=a)}function Vt(s){switch(s){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 tn(s,a){return s==null||s==="http://www.w3.org/1999/xhtml"?Vt(a):s==="http://www.w3.org/2000/svg"&&a==="foreignObject"?"http://www.w3.org/1999/xhtml":s}var ht,gt=(function(s){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(a,p,k,b){MSApp.execUnsafeLocalFunction(function(){return s(a,p,k,b)})}:s})(function(s,a){if(s.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in s)s.innerHTML=a;else{for(ht=ht||document.createElement("div"),ht.innerHTML="<svg>"+a.valueOf().toString()+"</svg>",a=ht.firstChild;s.firstChild;)s.removeChild(s.firstChild);for(;a.firstChild;)s.appendChild(a.firstChild)}});function sn(s,a){if(a){var p=s.firstChild;if(p&&p===s.lastChild&&p.nodeType===3){p.nodeValue=a;return}}s.textContent=a}var kn={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},Pt=["Webkit","ms","Moz","O"];Object.keys(kn).forEach(function(s){Pt.forEach(function(a){a=a+s.charAt(0).toUpperCase()+s.substring(1),kn[a]=kn[s]})});function Rn(s,a,p){return a==null||typeof a=="boolean"||a===""?"":p||typeof a!="number"||a===0||kn.hasOwnProperty(s)&&kn[s]?(""+a).trim():a+"px"}function bt(s,a){s=s.style;for(var p in a)if(a.hasOwnProperty(p)){var k=p.indexOf("--")===0,b=Rn(p,a[p],k);p==="float"&&(p="cssFloat"),k?s.setProperty(p,b):s[p]=b}}var ee=J({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 ke(s,a){if(a){if(ee[s]&&(a.children!=null||a.dangerouslySetInnerHTML!=null))throw Error(n(137,s));if(a.dangerouslySetInnerHTML!=null){if(a.children!=null)throw Error(n(60));if(typeof a.dangerouslySetInnerHTML!="object"||!("__html"in a.dangerouslySetInnerHTML))throw Error(n(61))}if(a.style!=null&&typeof a.style!="object")throw Error(n(62))}}function Xe(s,a){if(s.indexOf("-")===-1)return typeof a.is=="string";switch(s){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 Ge=null;function Zt(s){return s=s.target||s.srcElement||window,s.correspondingUseElement&&(s=s.correspondingUseElement),s.nodeType===3?s.parentNode:s}var Bt=null,mn=null,an=null;function xn(s){if(s=lc(s)){if(typeof Bt!="function")throw Error(n(280));var a=s.stateNode;a&&(a=od(a),Bt(s.stateNode,s.type,a))}}function M(s){mn?an?an.push(s):an=[s]:mn=s}function re(){if(mn){var s=mn,a=an;if(an=mn=null,xn(s),a)for(s=0;s<a.length;s++)xn(a[s])}}function Ne(s,a){return s(a)}function Ze(){}var jt=!1;function Ut(s,a,p){if(jt)return s(a,p);jt=!0;try{return Ne(s,a,p)}finally{jt=!1,(mn!==null||an!==null)&&(Ze(),re())}}function Me(s,a){var p=s.stateNode;if(p===null)return null;var k=od(p);if(k===null)return null;p=k[a];e:switch(a){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)||(s=s.type,k=!(s==="button"||s==="input"||s==="select"||s==="textarea")),s=!k;break e;default:s=!1}if(s)return null;if(p&&typeof p!="function")throw Error(n(231,a,typeof p));return p}var Pe=!1;if(c)try{var Ve={};Object.defineProperty(Ve,"passive",{get:function(){Pe=!0}}),window.addEventListener("test",Ve,Ve),window.removeEventListener("test",Ve,Ve)}catch{Pe=!1}function Lt(s,a,p,k,b,E,A,q,te){var he=Array.prototype.slice.call(arguments,3);try{a.apply(p,he)}catch(Ae){this.onError(Ae)}}var qt=!1,zn=null,et=!1,Ht=null,On={onError:function(s){qt=!0,zn=s}};function dn(s,a,p,k,b,E,A,q,te){qt=!1,zn=null,Lt.apply(On,arguments)}function sr(s,a,p,k,b,E,A,q,te){if(dn.apply(this,arguments),qt){if(qt){var he=zn;qt=!1,zn=null}else throw Error(n(198));et||(et=!0,Ht=he)}}function Fn(s){var a=s,p=s;if(s.alternate)for(;a.return;)a=a.return;else{s=a;do a=s,(a.flags&4098)!==0&&(p=a.return),s=a.return;while(s)}return a.tag===3?p:null}function hr(s){if(s.tag===13){var a=s.memoizedState;if(a===null&&(s=s.alternate,s!==null&&(a=s.memoizedState)),a!==null)return a.dehydrated}return null}function oe(s){if(Fn(s)!==s)throw Error(n(188))}function Le(s){var a=s.alternate;if(!a){if(a=Fn(s),a===null)throw Error(n(188));return a!==s?null:s}for(var p=s,k=a;;){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 oe(b),s;if(E===k)return oe(b),a;E=E.sibling}throw Error(n(188))}if(p.return!==k.return)p=b,k=E;else{for(var A=!1,q=b.child;q;){if(q===p){A=!0,p=b,k=E;break}if(q===k){A=!0,k=b,p=E;break}q=q.sibling}if(!A){for(q=E.child;q;){if(q===p){A=!0,p=E,k=b;break}if(q===k){A=!0,k=E,p=b;break}q=q.sibling}if(!A)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?s:a}function Ye(s){return s=Le(s),s!==null?$t(s):null}function $t(s){if(s.tag===5||s.tag===6)return s;for(s=s.child;s!==null;){var a=$t(s);if(a!==null)return a;s=s.sibling}return null}var pt=t.unstable_scheduleCallback,yn=t.unstable_cancelCallback,Tr=t.unstable_shouldYield,ir=t.unstable_requestPaint,Wt=t.unstable_now,Yr=t.unstable_getCurrentPriorityLevel,dt=t.unstable_ImmediatePriority,Bn=t.unstable_UserBlockingPriority,st=t.unstable_NormalPriority,Te=t.unstable_LowPriority,qe=t.unstable_IdlePriority,xt=null,at=null;function fn(s){if(at&&typeof at.onCommitFiberRoot=="function")try{at.onCommitFiberRoot(xt,s,void 0,(s.current.flags&128)===128)}catch{}}var Ft=Math.clz32?Math.clz32:$n,cn=Math.log,Hr=Math.LN2;function $n(s){return s>>>=0,s===0?32:31-(cn(s)/Hr|0)|0}var Un=64,yr=4194304;function Hn(s){switch(s&-s){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 s&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return s&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return s}}function G(s,a){var p=s.pendingLanes;if(p===0)return 0;var k=0,b=s.suspendedLanes,E=s.pingedLanes,A=p&268435455;if(A!==0){var q=A&~b;q!==0?k=Hn(q):(E&=A,E!==0&&(k=Hn(E)))}else A=p&~b,A!==0?k=Hn(A):E!==0&&(k=Hn(E));if(k===0)return 0;if(a!==0&&a!==k&&(a&b)===0&&(b=k&-k,E=a&-a,b>=E||b===16&&(E&4194240)!==0))return a;if((k&4)!==0&&(k|=p&16),a=s.entangledLanes,a!==0)for(s=s.entanglements,a&=k;0<a;)p=31-Ft(a),b=1<<p,k|=s[p],a&=~b;return k}function fe(s,a){switch(s){case 1:case 2:case 4:return a+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 a+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 tt(s,a){for(var p=s.suspendedLanes,k=s.pingedLanes,b=s.expirationTimes,E=s.pendingLanes;0<E;){var A=31-Ft(E),q=1<<A,te=b[A];te===-1?((q&p)===0||(q&k)!==0)&&(b[A]=fe(q,a)):te<=a&&(s.expiredLanes|=q),E&=~q}}function kt(s){return s=s.pendingLanes&-1073741825,s!==0?s:s&1073741824?1073741824:0}function Nt(){var s=Un;return Un<<=1,(Un&4194240)===0&&(Un=64),s}function vn(s){for(var a=[],p=0;31>p;p++)a.push(s);return a}function Wn(s,a,p){s.pendingLanes|=a,a!==536870912&&(s.suspendedLanes=0,s.pingedLanes=0),s=s.eventTimes,a=31-Ft(a),s[a]=p}function ar(s,a){var p=s.pendingLanes&~a;s.pendingLanes=a,s.suspendedLanes=0,s.pingedLanes=0,s.expiredLanes&=a,s.mutableReadLanes&=a,s.entangledLanes&=a,a=s.entanglements;var k=s.eventTimes;for(s=s.expirationTimes;0<p;){var b=31-Ft(p),E=1<<b;a[b]=0,k[b]=-1,s[b]=-1,p&=~E}}function jr(s,a){var p=s.entangledLanes|=a;for(s=s.entanglements;p;){var k=31-Ft(p),b=1<<k;b&a|s[k]&a&&(s[k]|=a),p&=~b}}var Gt=0;function Et(s){return s&=-s,1<s?4<s?(s&268435455)!==0?16:536870912:4:1}var To,Nn,Qt,Wr,Rr,je=!1,z=[],K=null,le=null,xe=null,Re=new Map,$e=new Map,Ct=[],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 er(s,a){switch(s){case"focusin":case"focusout":K=null;break;case"dragenter":case"dragleave":le=null;break;case"mouseover":case"mouseout":xe=null;break;case"pointerover":case"pointerout":Re.delete(a.pointerId);break;case"gotpointercapture":case"lostpointercapture":$e.delete(a.pointerId)}}function Cn(s,a,p,k,b,E){return s===null||s.nativeEvent!==E?(s={blockedOn:a,domEventName:p,eventSystemFlags:k,nativeEvent:E,targetContainers:[b]},a!==null&&(a=lc(a),a!==null&&Nn(a)),s):(s.eventSystemFlags|=k,a=s.targetContainers,b!==null&&a.indexOf(b)===-1&&a.push(b),s)}function zs(s,a,p,k,b){switch(a){case"focusin":return K=Cn(K,s,a,p,k,b),!0;case"dragenter":return le=Cn(le,s,a,p,k,b),!0;case"mouseover":return xe=Cn(xe,s,a,p,k,b),!0;case"pointerover":var E=b.pointerId;return Re.set(E,Cn(Re.get(E)||null,s,a,p,k,b)),!0;case"gotpointercapture":return E=b.pointerId,$e.set(E,Cn($e.get(E)||null,s,a,p,k,b)),!0}return!1}function bn(s){var a=Ki(s.target);if(a!==null){var p=Fn(a);if(p!==null){if(a=p.tag,a===13){if(a=hr(p),a!==null){s.blockedOn=a,Rr(s.priority,function(){Qt(p)});return}}else if(a===3&&p.stateNode.current.memoizedState.isDehydrated){s.blockedOn=p.tag===3?p.stateNode.containerInfo:null;return}}}s.blockedOn=null}function Ri(s){if(s.blockedOn!==null)return!1;for(var a=s.targetContainers;0<a.length;){var p=Hs(s.domEventName,s.eventSystemFlags,a[0],s.nativeEvent);if(p===null){p=s.nativeEvent;var k=new p.constructor(p.type,p);Ge=k,p.target.dispatchEvent(k),Ge=null}else return a=lc(p),a!==null&&Nn(a),s.blockedOn=p,!1;a.shift()}return!0}function $a(s,a,p){Ri(s)&&p.delete(a)}function ju(){je=!1,K!==null&&Ri(K)&&(K=null),le!==null&&Ri(le)&&(le=null),xe!==null&&Ri(xe)&&(xe=null),Re.forEach($a),$e.forEach($a)}function Fs(s,a){s.blockedOn===a&&(s.blockedOn=null,je||(je=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,ju)))}function Oi(s){function a(b){return Fs(b,s)}if(0<z.length){Fs(z[0],s);for(var p=1;p<z.length;p++){var k=z[p];k.blockedOn===s&&(k.blockedOn=null)}}for(K!==null&&Fs(K,s),le!==null&&Fs(le,s),xe!==null&&Fs(xe,s),Re.forEach(a),$e.forEach(a),p=0;p<Ct.length;p++)k=Ct[p],k.blockedOn===s&&(k.blockedOn=null);for(;0<Ct.length&&(p=Ct[0],p.blockedOn===null);)bn(p),p.blockedOn===null&&Ct.shift()}var Bs=j.ReactCurrentBatchConfig,Ca=!0;function Aa(s,a,p,k){var b=Gt,E=Bs.transition;Bs.transition=null;try{Gt=1,Us(s,a,p,k)}finally{Gt=b,Bs.transition=E}}function ys(s,a,p,k){var b=Gt,E=Bs.transition;Bs.transition=null;try{Gt=4,Us(s,a,p,k)}finally{Gt=b,Bs.transition=E}}function Us(s,a,p,k){if(Ca){var b=Hs(s,a,p,k);if(b===null)op(s,a,k,Mi,p),er(s,k);else if(zs(b,s,a,p,k))k.stopPropagation();else if(er(s,k),a&4&&-1<nn.indexOf(s)){for(;b!==null;){var E=lc(b);if(E!==null&&To(E),E=Hs(s,a,p,k),E===null&&op(s,a,k,Mi,p),E===b)break;b=E}b!==null&&k.stopPropagation()}else op(s,a,k,null,p)}}var Mi=null;function Hs(s,a,p,k){if(Mi=null,s=Zt(k),s=Ki(s),s!==null)if(a=Fn(s),a===null)s=null;else if(p=a.tag,p===13){if(s=hr(a),s!==null)return s;s=null}else if(p===3){if(a.stateNode.current.memoizedState.isDehydrated)return a.tag===3?a.stateNode.containerInfo:null;s=null}else a!==s&&(s=null);return Mi=s,null}function Pi(s){switch(s){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(Yr()){case dt:return 1;case Bn:return 4;case st:case Te:return 16;case qe:return 536870912;default:return 16}default:return 16}}var Uo=null,Ws=null,Li=null;function Ia(){if(Li)return Li;var s,a=Ws,p=a.length,k,b="value"in Uo?Uo.value:Uo.textContent,E=b.length;for(s=0;s<p&&a[s]===b[s];s++);var A=p-s;for(k=1;k<=A&&a[p-k]===b[E-k];k++);return Li=b.slice(s,1<k?1-k:void 0)}function pr(s){var a=s.keyCode;return"charCode"in s?(s=s.charCode,s===0&&a===13&&(s=13)):s=a,s===10&&(s=13),32<=s||s===13?s:0}function Ra(){return!0}function $u(){return!1}function $r(s){function a(p,k,b,E,A){this._reactName=p,this._targetInst=b,this.type=k,this.nativeEvent=E,this.target=A,this.currentTarget=null;for(var q in s)s.hasOwnProperty(q)&&(p=s[q],this[q]=p?p(E):E[q]);return this.isDefaultPrevented=(E.defaultPrevented!=null?E.defaultPrevented:E.returnValue===!1)?Ra:$u,this.isPropagationStopped=$u,this}return J(a.prototype,{preventDefault:function(){this.defaultPrevented=!0;var p=this.nativeEvent;p&&(p.preventDefault?p.preventDefault():typeof p.returnValue!="unknown"&&(p.returnValue=!1),this.isDefaultPrevented=Ra)},stopPropagation:function(){var p=this.nativeEvent;p&&(p.stopPropagation?p.stopPropagation():typeof p.cancelBubble!="unknown"&&(p.cancelBubble=!0),this.isPropagationStopped=Ra)},persist:function(){},isPersistent:Ra}),a}var is={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(s){return s.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},as=$r(is),vs=J({},is,{view:0,detail:0}),Cu=$r(vs),ql,Di,zi,Fi=J({},vs,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Ks,button:0,buttons:0,relatedTarget:function(s){return s.relatedTarget===void 0?s.fromElement===s.srcElement?s.toElement:s.fromElement:s.relatedTarget},movementX:function(s){return"movementX"in s?s.movementX:(s!==zi&&(zi&&s.type==="mousemove"?(ql=s.screenX-zi.screenX,Di=s.screenY-zi.screenY):Di=ql=0,zi=s),ql)},movementY:function(s){return"movementY"in s?s.movementY:Di}}),Au=$r(Fi),Iu=J({},Fi,{dataTransfer:0}),Yh=$r(Iu),Ru=J({},vs,{relatedTarget:0}),vr=$r(Ru),Ou=J({},is,{animationName:0,elapsedTime:0,pseudoElement:0}),Mu=$r(Ou),Gl=J({},is,{clipboardData:function(s){return"clipboardData"in s?s.clipboardData:window.clipboardData}}),Vl=$r(Gl),Oa=J({},is,{data:0}),An=$r(Oa),Pu={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Ma={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"},Yl={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function Pa(s){var a=this.nativeEvent;return a.getModifierState?a.getModifierState(s):(s=Yl[s])?!!a[s]:!1}function Ks(){return Pa}var Zs=J({},vs,{key:function(s){if(s.key){var a=Pu[s.key]||s.key;if(a!=="Unidentified")return a}return s.type==="keypress"?(s=pr(s),s===13?"Enter":String.fromCharCode(s)):s.type==="keydown"||s.type==="keyup"?Ma[s.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Ks,charCode:function(s){return s.type==="keypress"?pr(s):0},keyCode:function(s){return s.type==="keydown"||s.type==="keyup"?s.keyCode:0},which:function(s){return s.type==="keypress"?pr(s):s.type==="keydown"||s.type==="keyup"?s.keyCode:0}}),Lu=$r(Zs),Xl=J({},Fi,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),La=$r(Xl),Du=J({},vs,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Ks}),gy=$r(Du),zu=J({},is,{propertyName:0,elapsedTime:0,pseudoElement:0}),Da=$r(zu),Fu=J({},Fi,{deltaX:function(s){return"deltaX"in s?s.deltaX:"wheelDeltaX"in s?-s.wheelDeltaX:0},deltaY:function(s){return"deltaY"in s?s.deltaY:"wheelDeltaY"in s?-s.wheelDeltaY:"wheelDelta"in s?-s.wheelDelta:0},deltaZ:0,deltaMode:0}),Bu=$r(Fu),Uu=[9,13,27,32],tr=c&&"CompositionEvent"in window,ls=null;c&&"documentMode"in document&&(ls=document.documentMode);var Xh=c&&"TextEvent"in window&&!ls,Bi=c&&(!tr||ls&&8<ls&&11>=ls),Ql=" ",qs=!1;function Gs(s,a){switch(s){case"keyup":return Uu.indexOf(a.keyCode)!==-1;case"keydown":return a.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function za(s){return s=s.detail,typeof s=="object"&&"data"in s?s.data:null}var Vs=!1;function Jl(s,a){switch(s){case"compositionend":return za(a);case"keypress":return a.which!==32?null:(qs=!0,Ql);case"textInput":return s=a.data,s===Ql&&qs?null:s;default:return null}}function Qh(s,a){if(Vs)return s==="compositionend"||!tr&&Gs(s,a)?(s=Ia(),Li=Ws=Uo=null,Vs=!1,s):null;switch(s){case"paste":return null;case"keypress":if(!(a.ctrlKey||a.altKey||a.metaKey)||a.ctrlKey&&a.altKey){if(a.char&&1<a.char.length)return a.char;if(a.which)return String.fromCharCode(a.which)}return null;case"compositionend":return Bi&&a.locale!=="ko"?null:a.data;default:return null}}var Hu={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 ec(s){var a=s&&s.nodeName&&s.nodeName.toLowerCase();return a==="input"?!!Hu[s.type]:a==="textarea"}function tc(s,a,p,k){M(k),a=td(a,"onChange"),0<a.length&&(p=new as("onChange","change",null,p,k),s.push({event:p,listeners:a}))}var Ys=null,jo=null;function Jh(s){Ny(s,0)}function Xs(s){var a=Ka(s);if(ce(a))return s}function Wu(s,a){if(s==="change")return a}var Ku=!1;if(c){var Ui;if(c){var Fa="oninput"in document;if(!Fa){var nc=document.createElement("div");nc.setAttribute("oninput","return;"),Fa=typeof nc.oninput=="function"}Ui=Fa}else Ui=!1;Ku=Ui&&(!document.documentMode||9<document.documentMode)}function rc(){Ys&&(Ys.detachEvent("onpropertychange",Zu),jo=Ys=null)}function Zu(s){if(s.propertyName==="value"&&Xs(jo)){var a=[];tc(a,jo,s,Zt(s)),Ut(Jh,a)}}function qu(s,a,p){s==="focusin"?(rc(),Ys=a,jo=p,Ys.attachEvent("onpropertychange",Zu)):s==="focusout"&&rc()}function Gu(s){if(s==="selectionchange"||s==="keyup"||s==="keydown")return Xs(jo)}function Vu(s,a){if(s==="click")return Xs(a)}function Yu(s,a){if(s==="input"||s==="change")return Xs(a)}function Xu(s,a){return s===a&&(s!==0||1/s===1/a)||s!==s&&a!==a}var Xr=typeof Object.is=="function"?Object.is:Xu;function Qs(s,a){if(Xr(s,a))return!0;if(typeof s!="object"||s===null||typeof a!="object"||a===null)return!1;var p=Object.keys(s),k=Object.keys(a);if(p.length!==k.length)return!1;for(k=0;k<p.length;k++){var b=p[k];if(!u.call(a,b)||!Xr(s[b],a[b]))return!1}return!0}function D(s){for(;s&&s.firstChild;)s=s.firstChild;return s}function ze(s,a){var p=D(s);s=0;for(var k;p;){if(p.nodeType===3){if(k=s+p.textContent.length,s<=a&&k>=a)return{node:p,offset:a-s};s=k}e:{for(;p;){if(p.nextSibling){p=p.nextSibling;break e}p=p.parentNode}p=void 0}p=D(p)}}function Tt(s,a){return s&&a?s===a?!0:s&&s.nodeType===3?!1:a&&a.nodeType===3?Tt(s,a.parentNode):"contains"in s?s.contains(a):s.compareDocumentPosition?!!(s.compareDocumentPosition(a)&16):!1:!1}function At(){for(var s=window,a=Se();a instanceof s.HTMLIFrameElement;){try{var p=typeof a.contentWindow.location.href=="string"}catch{p=!1}if(p)s=a.contentWindow;else break;a=Se(s.document)}return a}function Vn(s){var a=s&&s.nodeName&&s.nodeName.toLowerCase();return a&&(a==="input"&&(s.type==="text"||s.type==="search"||s.type==="tel"||s.type==="url"||s.type==="password")||a==="textarea"||s.contentEditable==="true")}function rr(s){var a=At(),p=s.focusedElem,k=s.selectionRange;if(a!==p&&p&&p.ownerDocument&&Tt(p.ownerDocument.documentElement,p)){if(k!==null&&Vn(p)){if(a=k.start,s=k.end,s===void 0&&(s=a),"selectionStart"in p)p.selectionStart=a,p.selectionEnd=Math.min(s,p.value.length);else if(s=(a=p.ownerDocument||document)&&a.defaultView||window,s.getSelection){s=s.getSelection();var b=p.textContent.length,E=Math.min(k.start,b);k=k.end===void 0?E:Math.min(k.end,b),!s.extend&&E>k&&(b=k,k=E,E=b),b=ze(p,E);var A=ze(p,k);b&&A&&(s.rangeCount!==1||s.anchorNode!==b.node||s.anchorOffset!==b.offset||s.focusNode!==A.node||s.focusOffset!==A.offset)&&(a=a.createRange(),a.setStart(b.node,b.offset),s.removeAllRanges(),E>k?(s.addRange(a),s.extend(A.node,A.offset)):(a.setEnd(A.node,A.offset),s.addRange(a)))}}for(a=[],s=p;s=s.parentNode;)s.nodeType===1&&a.push({element:s,left:s.scrollLeft,top:s.scrollTop});for(typeof p.focus=="function"&&p.focus(),p=0;p<a.length;p++)s=a[p],s.element.scrollLeft=s.left,s.element.scrollTop=s.top}}var Hi=c&&"documentMode"in document&&11>=document.documentMode,bs=null,Qr=null,Wi=null,Ba=!1;function ky(s,a,p){var k=p.window===p?p.document:p.nodeType===9?p:p.ownerDocument;Ba||bs==null||bs!==Se(k)||(k=bs,"selectionStart"in k&&Vn(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}),Wi&&Qs(Wi,k)||(Wi=k,k=td(Qr,"onSelect"),0<k.length&&(a=new as("onSelect","select",null,a,p),s.push({event:a,listeners:k}),a.target=bs)))}function Qu(s,a){var p={};return p[s.toLowerCase()]=a.toLowerCase(),p["Webkit"+s]="webkit"+a,p["Moz"+s]="moz"+a,p}var Ua={animationend:Qu("Animation","AnimationEnd"),animationiteration:Qu("Animation","AnimationIteration"),animationstart:Qu("Animation","AnimationStart"),transitionend:Qu("Transition","TransitionEnd")},ep={},wy={};c&&(wy=document.createElement("div").style,"AnimationEvent"in window||(delete Ua.animationend.animation,delete Ua.animationiteration.animation,delete Ua.animationstart.animation),"TransitionEvent"in window||delete Ua.transitionend.transition);function Ju(s){if(ep[s])return ep[s];if(!Ua[s])return s;var a=Ua[s],p;for(p in a)if(a.hasOwnProperty(p)&&p in wy)return ep[s]=a[p];return s}var yy=Ju("animationend"),vy=Ju("animationiteration"),by=Ju("animationstart"),xy=Ju("transitionend"),Ey=new Map,Sy="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 Js(s,a){Ey.set(s,a),i(a,[s])}for(var tp=0;tp<Sy.length;tp++){var np=Sy[tp],y$=np.toLowerCase(),v$=np[0].toUpperCase()+np.slice(1);Js(y$,"on"+v$)}Js(yy,"onAnimationEnd"),Js(vy,"onAnimationIteration"),Js(by,"onAnimationStart"),Js("dblclick","onDoubleClick"),Js("focusin","onFocus"),Js("focusout","onBlur"),Js(xy,"onTransitionEnd"),l("onMouseEnter",["mouseout","mouseover"]),l("onMouseLeave",["mouseout","mouseover"]),l("onPointerEnter",["pointerout","pointerover"]),l("onPointerLeave",["pointerout","pointerover"]),i("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),i("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),i("onBeforeInput",["compositionend","keypress","textInput","paste"]),i("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),i("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),i("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var oc="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(" "),b$=new Set("cancel close invalid load scroll toggle".split(" ").concat(oc));function _y(s,a,p){var k=s.type||"unknown-event";s.currentTarget=p,sr(k,a,void 0,s),s.currentTarget=null}function Ny(s,a){a=(a&4)!==0;for(var p=0;p<s.length;p++){var k=s[p],b=k.event;k=k.listeners;e:{var E=void 0;if(a)for(var A=k.length-1;0<=A;A--){var q=k[A],te=q.instance,he=q.currentTarget;if(q=q.listener,te!==E&&b.isPropagationStopped())break e;_y(b,q,he),E=te}else for(A=0;A<k.length;A++){if(q=k[A],te=q.instance,he=q.currentTarget,q=q.listener,te!==E&&b.isPropagationStopped())break e;_y(b,q,he),E=te}}}if(et)throw s=Ht,et=!1,Ht=null,s}function Mn(s,a){var p=a[up];p===void 0&&(p=a[up]=new Set);var k=s+"__bubble";p.has(k)||(Ty(a,s,2,!1),p.add(k))}function rp(s,a,p){var k=0;a&&(k|=4),Ty(p,s,k,a)}var ed="_reactListening"+Math.random().toString(36).slice(2);function sc(s){if(!s[ed]){s[ed]=!0,r.forEach(function(p){p!=="selectionchange"&&(b$.has(p)||rp(p,!1,s),rp(p,!0,s))});var a=s.nodeType===9?s:s.ownerDocument;a===null||a[ed]||(a[ed]=!0,rp("selectionchange",!1,a))}}function Ty(s,a,p,k){switch(Pi(a)){case 1:var b=Aa;break;case 4:b=ys;break;default:b=Us}p=b.bind(null,a,p,s),b=void 0,!Pe||a!=="touchstart"&&a!=="touchmove"&&a!=="wheel"||(b=!0),k?b!==void 0?s.addEventListener(a,p,{capture:!0,passive:b}):s.addEventListener(a,p,!0):b!==void 0?s.addEventListener(a,p,{passive:b}):s.addEventListener(a,p,!1)}function op(s,a,p,k,b){var E=k;if((a&1)===0&&(a&2)===0&&k!==null)e:for(;;){if(k===null)return;var A=k.tag;if(A===3||A===4){var q=k.stateNode.containerInfo;if(q===b||q.nodeType===8&&q.parentNode===b)break;if(A===4)for(A=k.return;A!==null;){var te=A.tag;if((te===3||te===4)&&(te=A.stateNode.containerInfo,te===b||te.nodeType===8&&te.parentNode===b))return;A=A.return}for(;q!==null;){if(A=Ki(q),A===null)return;if(te=A.tag,te===5||te===6){k=E=A;continue e}q=q.parentNode}}k=k.return}Ut(function(){var he=E,Ae=Zt(p),Oe=[];e:{var Ce=Ey.get(s);if(Ce!==void 0){var Qe=as,ot=s;switch(s){case"keypress":if(pr(p)===0)break e;case"keydown":case"keyup":Qe=Lu;break;case"focusin":ot="focus",Qe=vr;break;case"focusout":ot="blur",Qe=vr;break;case"beforeblur":case"afterblur":Qe=vr;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":Qe=Au;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":Qe=Yh;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":Qe=gy;break;case yy:case vy:case by:Qe=Mu;break;case xy:Qe=Da;break;case"scroll":Qe=Cu;break;case"wheel":Qe=Bu;break;case"copy":case"cut":case"paste":Qe=Vl;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":Qe=La}var it=(a&4)!==0,or=!it&&s==="scroll",ue=it?Ce!==null?Ce+"Capture":null:Ce;it=[];for(var se=he,de;se!==null;){de=se;var Fe=de.stateNode;if(de.tag===5&&Fe!==null&&(de=Fe,ue!==null&&(Fe=Me(se,ue),Fe!=null&&it.push(ic(se,Fe,de)))),or)break;se=se.return}0<it.length&&(Ce=new Qe(Ce,ot,null,p,Ae),Oe.push({event:Ce,listeners:it}))}}if((a&7)===0){e:{if(Ce=s==="mouseover"||s==="pointerover",Qe=s==="mouseout"||s==="pointerout",Ce&&p!==Ge&&(ot=p.relatedTarget||p.fromElement)&&(Ki(ot)||ot[xs]))break e;if((Qe||Ce)&&(Ce=Ae.window===Ae?Ae:(Ce=Ae.ownerDocument)?Ce.defaultView||Ce.parentWindow:window,Qe?(ot=p.relatedTarget||p.toElement,Qe=he,ot=ot?Ki(ot):null,ot!==null&&(or=Fn(ot),ot!==or||ot.tag!==5&&ot.tag!==6)&&(ot=null)):(Qe=null,ot=he),Qe!==ot)){if(it=Au,Fe="onMouseLeave",ue="onMouseEnter",se="mouse",(s==="pointerout"||s==="pointerover")&&(it=La,Fe="onPointerLeave",ue="onPointerEnter",se="pointer"),or=Qe==null?Ce:Ka(Qe),de=ot==null?Ce:Ka(ot),Ce=new it(Fe,se+"leave",Qe,p,Ae),Ce.target=or,Ce.relatedTarget=de,Fe=null,Ki(Ae)===he&&(it=new it(ue,se+"enter",ot,p,Ae),it.target=de,it.relatedTarget=or,Fe=it),or=Fe,Qe&&ot)t:{for(it=Qe,ue=ot,se=0,de=it;de;de=Ha(de))se++;for(de=0,Fe=ue;Fe;Fe=Ha(Fe))de++;for(;0<se-de;)it=Ha(it),se--;for(;0<de-se;)ue=Ha(ue),de--;for(;se--;){if(it===ue||ue!==null&&it===ue.alternate)break t;it=Ha(it),ue=Ha(ue)}it=null}else it=null;Qe!==null&&jy(Oe,Ce,Qe,it,!1),ot!==null&&or!==null&&jy(Oe,or,ot,it,!0)}}e:{if(Ce=he?Ka(he):window,Qe=Ce.nodeName&&Ce.nodeName.toLowerCase(),Qe==="select"||Qe==="input"&&Ce.type==="file")var lt=Wu;else if(ec(Ce))if(Ku)lt=Yu;else{lt=Gu;var yt=qu}else(Qe=Ce.nodeName)&&Qe.toLowerCase()==="input"&&(Ce.type==="checkbox"||Ce.type==="radio")&&(lt=Vu);if(lt&&(lt=lt(s,he))){tc(Oe,lt,p,Ae);break e}yt&&yt(s,Ce,he),s==="focusout"&&(yt=Ce._wrapperState)&&yt.controlled&&Ce.type==="number"&&en(Ce,"number",Ce.value)}switch(yt=he?Ka(he):window,s){case"focusin":(ec(yt)||yt.contentEditable==="true")&&(bs=yt,Qr=he,Wi=null);break;case"focusout":Wi=Qr=bs=null;break;case"mousedown":Ba=!0;break;case"contextmenu":case"mouseup":case"dragend":Ba=!1,ky(Oe,p,Ae);break;case"selectionchange":if(Hi)break;case"keydown":case"keyup":ky(Oe,p,Ae)}var vt;if(tr)e:{switch(s){case"compositionstart":var Mt="onCompositionStart";break e;case"compositionend":Mt="onCompositionEnd";break e;case"compositionupdate":Mt="onCompositionUpdate";break e}Mt=void 0}else Vs?Gs(s,p)&&(Mt="onCompositionEnd"):s==="keydown"&&p.keyCode===229&&(Mt="onCompositionStart");Mt&&(Bi&&p.locale!=="ko"&&(Vs||Mt!=="onCompositionStart"?Mt==="onCompositionEnd"&&Vs&&(vt=Ia()):(Uo=Ae,Ws="value"in Uo?Uo.value:Uo.textContent,Vs=!0)),yt=td(he,Mt),0<yt.length&&(Mt=new An(Mt,s,null,p,Ae),Oe.push({event:Mt,listeners:yt}),vt?Mt.data=vt:(vt=za(p),vt!==null&&(Mt.data=vt)))),(vt=Xh?Jl(s,p):Qh(s,p))&&(he=td(he,"onBeforeInput"),0<he.length&&(Ae=new An("onBeforeInput","beforeinput",null,p,Ae),Oe.push({event:Ae,listeners:he}),Ae.data=vt))}Ny(Oe,a)})}function ic(s,a,p){return{instance:s,listener:a,currentTarget:p}}function td(s,a){for(var p=a+"Capture",k=[];s!==null;){var b=s,E=b.stateNode;b.tag===5&&E!==null&&(b=E,E=Me(s,p),E!=null&&k.unshift(ic(s,E,b)),E=Me(s,a),E!=null&&k.push(ic(s,E,b))),s=s.return}return k}function Ha(s){if(s===null)return null;do s=s.return;while(s&&s.tag!==5);return s||null}function jy(s,a,p,k,b){for(var E=a._reactName,A=[];p!==null&&p!==k;){var q=p,te=q.alternate,he=q.stateNode;if(te!==null&&te===k)break;q.tag===5&&he!==null&&(q=he,b?(te=Me(p,E),te!=null&&A.unshift(ic(p,te,q))):b||(te=Me(p,E),te!=null&&A.push(ic(p,te,q)))),p=p.return}A.length!==0&&s.push({event:a,listeners:A})}var x$=/\r\n?/g,E$=/\u0000|\uFFFD/g;function $y(s){return(typeof s=="string"?s:""+s).replace(x$,`
39
- `).replace(E$,"")}function nd(s,a,p){if(a=$y(a),$y(s)!==a&&p)throw Error(n(425))}function rd(){}var sp=null,ip=null;function ap(s,a){return s==="textarea"||s==="noscript"||typeof a.children=="string"||typeof a.children=="number"||typeof a.dangerouslySetInnerHTML=="object"&&a.dangerouslySetInnerHTML!==null&&a.dangerouslySetInnerHTML.__html!=null}var lp=typeof setTimeout=="function"?setTimeout:void 0,S$=typeof clearTimeout=="function"?clearTimeout:void 0,Cy=typeof Promise=="function"?Promise:void 0,_$=typeof queueMicrotask=="function"?queueMicrotask:typeof Cy<"u"?function(s){return Cy.resolve(null).then(s).catch(N$)}:lp;function N$(s){setTimeout(function(){throw s})}function cp(s,a){var p=a,k=0;do{var b=p.nextSibling;if(s.removeChild(p),b&&b.nodeType===8)if(p=b.data,p==="/$"){if(k===0){s.removeChild(b),Oi(a);return}k--}else p!=="$"&&p!=="$?"&&p!=="$!"||k++;p=b}while(p);Oi(a)}function ei(s){for(;s!=null;s=s.nextSibling){var a=s.nodeType;if(a===1||a===3)break;if(a===8){if(a=s.data,a==="$"||a==="$!"||a==="$?")break;if(a==="/$")return null}}return s}function Ay(s){s=s.previousSibling;for(var a=0;s;){if(s.nodeType===8){var p=s.data;if(p==="$"||p==="$!"||p==="$?"){if(a===0)return s;a--}else p==="/$"&&a++}s=s.previousSibling}return null}var Wa=Math.random().toString(36).slice(2),cs="__reactFiber$"+Wa,ac="__reactProps$"+Wa,xs="__reactContainer$"+Wa,up="__reactEvents$"+Wa,T$="__reactListeners$"+Wa,j$="__reactHandles$"+Wa;function Ki(s){var a=s[cs];if(a)return a;for(var p=s.parentNode;p;){if(a=p[xs]||p[cs]){if(p=a.alternate,a.child!==null||p!==null&&p.child!==null)for(s=Ay(s);s!==null;){if(p=s[cs])return p;s=Ay(s)}return a}s=p,p=s.parentNode}return null}function lc(s){return s=s[cs]||s[xs],!s||s.tag!==5&&s.tag!==6&&s.tag!==13&&s.tag!==3?null:s}function Ka(s){if(s.tag===5||s.tag===6)return s.stateNode;throw Error(n(33))}function od(s){return s[ac]||null}var dp=[],Za=-1;function ti(s){return{current:s}}function Pn(s){0>Za||(s.current=dp[Za],dp[Za]=null,Za--)}function In(s,a){Za++,dp[Za]=s.current,s.current=a}var ni={},Or=ti(ni),Jr=ti(!1),Zi=ni;function qa(s,a){var p=s.type.contextTypes;if(!p)return ni;var k=s.stateNode;if(k&&k.__reactInternalMemoizedUnmaskedChildContext===a)return k.__reactInternalMemoizedMaskedChildContext;var b={},E;for(E in p)b[E]=a[E];return k&&(s=s.stateNode,s.__reactInternalMemoizedUnmaskedChildContext=a,s.__reactInternalMemoizedMaskedChildContext=b),b}function eo(s){return s=s.childContextTypes,s!=null}function sd(){Pn(Jr),Pn(Or)}function Iy(s,a,p){if(Or.current!==ni)throw Error(n(168));In(Or,a),In(Jr,p)}function Ry(s,a,p){var k=s.stateNode;if(a=a.childContextTypes,typeof k.getChildContext!="function")return p;k=k.getChildContext();for(var b in k)if(!(b in a))throw Error(n(108,Q(s)||"Unknown",b));return J({},p,k)}function id(s){return s=(s=s.stateNode)&&s.__reactInternalMemoizedMergedChildContext||ni,Zi=Or.current,In(Or,s),In(Jr,Jr.current),!0}function Oy(s,a,p){var k=s.stateNode;if(!k)throw Error(n(169));p?(s=Ry(s,a,Zi),k.__reactInternalMemoizedMergedChildContext=s,Pn(Jr),Pn(Or),In(Or,s)):Pn(Jr),In(Jr,p)}var Es=null,ad=!1,fp=!1;function My(s){Es===null?Es=[s]:Es.push(s)}function $$(s){ad=!0,My(s)}function ri(){if(!fp&&Es!==null){fp=!0;var s=0,a=Gt;try{var p=Es;for(Gt=1;s<p.length;s++){var k=p[s];do k=k(!0);while(k!==null)}Es=null,ad=!1}catch(b){throw Es!==null&&(Es=Es.slice(s+1)),pt(dt,ri),b}finally{Gt=a,fp=!1}}return null}var Ga=[],Va=0,ld=null,cd=0,$o=[],Co=0,qi=null,Ss=1,_s="";function Gi(s,a){Ga[Va++]=cd,Ga[Va++]=ld,ld=s,cd=a}function Py(s,a,p){$o[Co++]=Ss,$o[Co++]=_s,$o[Co++]=qi,qi=s;var k=Ss;s=_s;var b=32-Ft(k)-1;k&=~(1<<b),p+=1;var E=32-Ft(a)+b;if(30<E){var A=b-b%5;E=(k&(1<<A)-1).toString(32),k>>=A,b-=A,Ss=1<<32-Ft(a)+b|p<<b|k,_s=E+s}else Ss=1<<E|p<<b|k,_s=s}function hp(s){s.return!==null&&(Gi(s,1),Py(s,1,0))}function pp(s){for(;s===ld;)ld=Ga[--Va],Ga[Va]=null,cd=Ga[--Va],Ga[Va]=null;for(;s===qi;)qi=$o[--Co],$o[Co]=null,_s=$o[--Co],$o[Co]=null,Ss=$o[--Co],$o[Co]=null}var go=null,ko=null,Kn=!1,Ho=null;function Ly(s,a){var p=Oo(5,null,null,0);p.elementType="DELETED",p.stateNode=a,p.return=s,a=s.deletions,a===null?(s.deletions=[p],s.flags|=16):a.push(p)}function Dy(s,a){switch(s.tag){case 5:var p=s.type;return a=a.nodeType!==1||p.toLowerCase()!==a.nodeName.toLowerCase()?null:a,a!==null?(s.stateNode=a,go=s,ko=ei(a.firstChild),!0):!1;case 6:return a=s.pendingProps===""||a.nodeType!==3?null:a,a!==null?(s.stateNode=a,go=s,ko=null,!0):!1;case 13:return a=a.nodeType!==8?null:a,a!==null?(p=qi!==null?{id:Ss,overflow:_s}:null,s.memoizedState={dehydrated:a,treeContext:p,retryLane:1073741824},p=Oo(18,null,null,0),p.stateNode=a,p.return=s,s.child=p,go=s,ko=null,!0):!1;default:return!1}}function mp(s){return(s.mode&1)!==0&&(s.flags&128)===0}function gp(s){if(Kn){var a=ko;if(a){var p=a;if(!Dy(s,a)){if(mp(s))throw Error(n(418));a=ei(p.nextSibling);var k=go;a&&Dy(s,a)?Ly(k,p):(s.flags=s.flags&-4097|2,Kn=!1,go=s)}}else{if(mp(s))throw Error(n(418));s.flags=s.flags&-4097|2,Kn=!1,go=s}}}function zy(s){for(s=s.return;s!==null&&s.tag!==5&&s.tag!==3&&s.tag!==13;)s=s.return;go=s}function ud(s){if(s!==go)return!1;if(!Kn)return zy(s),Kn=!0,!1;var a;if((a=s.tag!==3)&&!(a=s.tag!==5)&&(a=s.type,a=a!=="head"&&a!=="body"&&!ap(s.type,s.memoizedProps)),a&&(a=ko)){if(mp(s))throw Fy(),Error(n(418));for(;a;)Ly(s,a),a=ei(a.nextSibling)}if(zy(s),s.tag===13){if(s=s.memoizedState,s=s!==null?s.dehydrated:null,!s)throw Error(n(317));e:{for(s=s.nextSibling,a=0;s;){if(s.nodeType===8){var p=s.data;if(p==="/$"){if(a===0){ko=ei(s.nextSibling);break e}a--}else p!=="$"&&p!=="$!"&&p!=="$?"||a++}s=s.nextSibling}ko=null}}else ko=go?ei(s.stateNode.nextSibling):null;return!0}function Fy(){for(var s=ko;s;)s=ei(s.nextSibling)}function Ya(){ko=go=null,Kn=!1}function kp(s){Ho===null?Ho=[s]:Ho.push(s)}var C$=j.ReactCurrentBatchConfig;function cc(s,a,p){if(s=p.ref,s!==null&&typeof s!="function"&&typeof s!="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,s));var b=k,E=""+s;return a!==null&&a.ref!==null&&typeof a.ref=="function"&&a.ref._stringRef===E?a.ref:(a=function(A){var q=b.refs;A===null?delete q[E]:q[E]=A},a._stringRef=E,a)}if(typeof s!="string")throw Error(n(284));if(!p._owner)throw Error(n(290,s))}return s}function dd(s,a){throw s=Object.prototype.toString.call(a),Error(n(31,s==="[object Object]"?"object with keys {"+Object.keys(a).join(", ")+"}":s))}function By(s){var a=s._init;return a(s._payload)}function Uy(s){function a(ue,se){if(s){var de=ue.deletions;de===null?(ue.deletions=[se],ue.flags|=16):de.push(se)}}function p(ue,se){if(!s)return null;for(;se!==null;)a(ue,se),se=se.sibling;return null}function k(ue,se){for(ue=new Map;se!==null;)se.key!==null?ue.set(se.key,se):ue.set(se.index,se),se=se.sibling;return ue}function b(ue,se){return ue=di(ue,se),ue.index=0,ue.sibling=null,ue}function E(ue,se,de){return ue.index=de,s?(de=ue.alternate,de!==null?(de=de.index,de<se?(ue.flags|=2,se):de):(ue.flags|=2,se)):(ue.flags|=1048576,se)}function A(ue){return s&&ue.alternate===null&&(ue.flags|=2),ue}function q(ue,se,de,Fe){return se===null||se.tag!==6?(se=lm(de,ue.mode,Fe),se.return=ue,se):(se=b(se,de),se.return=ue,se)}function te(ue,se,de,Fe){var lt=de.type;return lt===I?Ae(ue,se,de.props.children,Fe,de.key):se!==null&&(se.elementType===lt||typeof lt=="object"&&lt!==null&&lt.$$typeof===ne&&By(lt)===se.type)?(Fe=b(se,de.props),Fe.ref=cc(ue,se,de),Fe.return=ue,Fe):(Fe=Md(de.type,de.key,de.props,null,ue.mode,Fe),Fe.ref=cc(ue,se,de),Fe.return=ue,Fe)}function he(ue,se,de,Fe){return se===null||se.tag!==4||se.stateNode.containerInfo!==de.containerInfo||se.stateNode.implementation!==de.implementation?(se=cm(de,ue.mode,Fe),se.return=ue,se):(se=b(se,de.children||[]),se.return=ue,se)}function Ae(ue,se,de,Fe,lt){return se===null||se.tag!==7?(se=na(de,ue.mode,Fe,lt),se.return=ue,se):(se=b(se,de),se.return=ue,se)}function Oe(ue,se,de){if(typeof se=="string"&&se!==""||typeof se=="number")return se=lm(""+se,ue.mode,de),se.return=ue,se;if(typeof se=="object"&&se!==null){switch(se.$$typeof){case $:return de=Md(se.type,se.key,se.props,null,ue.mode,de),de.ref=cc(ue,null,se),de.return=ue,de;case O:return se=cm(se,ue.mode,de),se.return=ue,se;case ne:var Fe=se._init;return Oe(ue,Fe(se._payload),de)}if(Kt(se)||V(se))return se=na(se,ue.mode,de,null),se.return=ue,se;dd(ue,se)}return null}function Ce(ue,se,de,Fe){var lt=se!==null?se.key:null;if(typeof de=="string"&&de!==""||typeof de=="number")return lt!==null?null:q(ue,se,""+de,Fe);if(typeof de=="object"&&de!==null){switch(de.$$typeof){case $:return de.key===lt?te(ue,se,de,Fe):null;case O:return de.key===lt?he(ue,se,de,Fe):null;case ne:return lt=de._init,Ce(ue,se,lt(de._payload),Fe)}if(Kt(de)||V(de))return lt!==null?null:Ae(ue,se,de,Fe,null);dd(ue,de)}return null}function Qe(ue,se,de,Fe,lt){if(typeof Fe=="string"&&Fe!==""||typeof Fe=="number")return ue=ue.get(de)||null,q(se,ue,""+Fe,lt);if(typeof Fe=="object"&&Fe!==null){switch(Fe.$$typeof){case $:return ue=ue.get(Fe.key===null?de:Fe.key)||null,te(se,ue,Fe,lt);case O:return ue=ue.get(Fe.key===null?de:Fe.key)||null,he(se,ue,Fe,lt);case ne:var yt=Fe._init;return Qe(ue,se,de,yt(Fe._payload),lt)}if(Kt(Fe)||V(Fe))return ue=ue.get(de)||null,Ae(se,ue,Fe,lt,null);dd(se,Fe)}return null}function ot(ue,se,de,Fe){for(var lt=null,yt=null,vt=se,Mt=se=0,Er=null;vt!==null&&Mt<de.length;Mt++){vt.index>Mt?(Er=vt,vt=null):Er=vt.sibling;var gn=Ce(ue,vt,de[Mt],Fe);if(gn===null){vt===null&&(vt=Er);break}s&&vt&&gn.alternate===null&&a(ue,vt),se=E(gn,se,Mt),yt===null?lt=gn:yt.sibling=gn,yt=gn,vt=Er}if(Mt===de.length)return p(ue,vt),Kn&&Gi(ue,Mt),lt;if(vt===null){for(;Mt<de.length;Mt++)vt=Oe(ue,de[Mt],Fe),vt!==null&&(se=E(vt,se,Mt),yt===null?lt=vt:yt.sibling=vt,yt=vt);return Kn&&Gi(ue,Mt),lt}for(vt=k(ue,vt);Mt<de.length;Mt++)Er=Qe(vt,ue,Mt,de[Mt],Fe),Er!==null&&(s&&Er.alternate!==null&&vt.delete(Er.key===null?Mt:Er.key),se=E(Er,se,Mt),yt===null?lt=Er:yt.sibling=Er,yt=Er);return s&&vt.forEach(function(fi){return a(ue,fi)}),Kn&&Gi(ue,Mt),lt}function it(ue,se,de,Fe){var lt=V(de);if(typeof lt!="function")throw Error(n(150));if(de=lt.call(de),de==null)throw Error(n(151));for(var yt=lt=null,vt=se,Mt=se=0,Er=null,gn=de.next();vt!==null&&!gn.done;Mt++,gn=de.next()){vt.index>Mt?(Er=vt,vt=null):Er=vt.sibling;var fi=Ce(ue,vt,gn.value,Fe);if(fi===null){vt===null&&(vt=Er);break}s&&vt&&fi.alternate===null&&a(ue,vt),se=E(fi,se,Mt),yt===null?lt=fi:yt.sibling=fi,yt=fi,vt=Er}if(gn.done)return p(ue,vt),Kn&&Gi(ue,Mt),lt;if(vt===null){for(;!gn.done;Mt++,gn=de.next())gn=Oe(ue,gn.value,Fe),gn!==null&&(se=E(gn,se,Mt),yt===null?lt=gn:yt.sibling=gn,yt=gn);return Kn&&Gi(ue,Mt),lt}for(vt=k(ue,vt);!gn.done;Mt++,gn=de.next())gn=Qe(vt,ue,Mt,gn.value,Fe),gn!==null&&(s&&gn.alternate!==null&&vt.delete(gn.key===null?Mt:gn.key),se=E(gn,se,Mt),yt===null?lt=gn:yt.sibling=gn,yt=gn);return s&&vt.forEach(function(cC){return a(ue,cC)}),Kn&&Gi(ue,Mt),lt}function or(ue,se,de,Fe){if(typeof de=="object"&&de!==null&&de.type===I&&de.key===null&&(de=de.props.children),typeof de=="object"&&de!==null){switch(de.$$typeof){case $:e:{for(var lt=de.key,yt=se;yt!==null;){if(yt.key===lt){if(lt=de.type,lt===I){if(yt.tag===7){p(ue,yt.sibling),se=b(yt,de.props.children),se.return=ue,ue=se;break e}}else if(yt.elementType===lt||typeof lt=="object"&&lt!==null&&lt.$$typeof===ne&&By(lt)===yt.type){p(ue,yt.sibling),se=b(yt,de.props),se.ref=cc(ue,yt,de),se.return=ue,ue=se;break e}p(ue,yt);break}else a(ue,yt);yt=yt.sibling}de.type===I?(se=na(de.props.children,ue.mode,Fe,de.key),se.return=ue,ue=se):(Fe=Md(de.type,de.key,de.props,null,ue.mode,Fe),Fe.ref=cc(ue,se,de),Fe.return=ue,ue=Fe)}return A(ue);case O:e:{for(yt=de.key;se!==null;){if(se.key===yt)if(se.tag===4&&se.stateNode.containerInfo===de.containerInfo&&se.stateNode.implementation===de.implementation){p(ue,se.sibling),se=b(se,de.children||[]),se.return=ue,ue=se;break e}else{p(ue,se);break}else a(ue,se);se=se.sibling}se=cm(de,ue.mode,Fe),se.return=ue,ue=se}return A(ue);case ne:return yt=de._init,or(ue,se,yt(de._payload),Fe)}if(Kt(de))return ot(ue,se,de,Fe);if(V(de))return it(ue,se,de,Fe);dd(ue,de)}return typeof de=="string"&&de!==""||typeof de=="number"?(de=""+de,se!==null&&se.tag===6?(p(ue,se.sibling),se=b(se,de),se.return=ue,ue=se):(p(ue,se),se=lm(de,ue.mode,Fe),se.return=ue,ue=se),A(ue)):p(ue,se)}return or}var Xa=Uy(!0),Hy=Uy(!1),fd=ti(null),hd=null,Qa=null,wp=null;function yp(){wp=Qa=hd=null}function vp(s){var a=fd.current;Pn(fd),s._currentValue=a}function bp(s,a,p){for(;s!==null;){var k=s.alternate;if((s.childLanes&a)!==a?(s.childLanes|=a,k!==null&&(k.childLanes|=a)):k!==null&&(k.childLanes&a)!==a&&(k.childLanes|=a),s===p)break;s=s.return}}function Ja(s,a){hd=s,wp=Qa=null,s=s.dependencies,s!==null&&s.firstContext!==null&&((s.lanes&a)!==0&&(to=!0),s.firstContext=null)}function Ao(s){var a=s._currentValue;if(wp!==s)if(s={context:s,memoizedValue:a,next:null},Qa===null){if(hd===null)throw Error(n(308));Qa=s,hd.dependencies={lanes:0,firstContext:s}}else Qa=Qa.next=s;return a}var Vi=null;function xp(s){Vi===null?Vi=[s]:Vi.push(s)}function Wy(s,a,p,k){var b=a.interleaved;return b===null?(p.next=p,xp(a)):(p.next=b.next,b.next=p),a.interleaved=p,Ns(s,k)}function Ns(s,a){s.lanes|=a;var p=s.alternate;for(p!==null&&(p.lanes|=a),p=s,s=s.return;s!==null;)s.childLanes|=a,p=s.alternate,p!==null&&(p.childLanes|=a),p=s,s=s.return;return p.tag===3?p.stateNode:null}var oi=!1;function Ep(s){s.updateQueue={baseState:s.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Ky(s,a){s=s.updateQueue,a.updateQueue===s&&(a.updateQueue={baseState:s.baseState,firstBaseUpdate:s.firstBaseUpdate,lastBaseUpdate:s.lastBaseUpdate,shared:s.shared,effects:s.effects})}function Ts(s,a){return{eventTime:s,lane:a,tag:0,payload:null,callback:null,next:null}}function si(s,a,p){var k=s.updateQueue;if(k===null)return null;if(k=k.shared,(hn&2)!==0){var b=k.pending;return b===null?a.next=a:(a.next=b.next,b.next=a),k.pending=a,Ns(s,p)}return b=k.interleaved,b===null?(a.next=a,xp(k)):(a.next=b.next,b.next=a),k.interleaved=a,Ns(s,p)}function pd(s,a,p){if(a=a.updateQueue,a!==null&&(a=a.shared,(p&4194240)!==0)){var k=a.lanes;k&=s.pendingLanes,p|=k,a.lanes=p,jr(s,p)}}function Zy(s,a){var p=s.updateQueue,k=s.alternate;if(k!==null&&(k=k.updateQueue,p===k)){var b=null,E=null;if(p=p.firstBaseUpdate,p!==null){do{var A={eventTime:p.eventTime,lane:p.lane,tag:p.tag,payload:p.payload,callback:p.callback,next:null};E===null?b=E=A:E=E.next=A,p=p.next}while(p!==null);E===null?b=E=a:E=E.next=a}else b=E=a;p={baseState:k.baseState,firstBaseUpdate:b,lastBaseUpdate:E,shared:k.shared,effects:k.effects},s.updateQueue=p;return}s=p.lastBaseUpdate,s===null?p.firstBaseUpdate=a:s.next=a,p.lastBaseUpdate=a}function md(s,a,p,k){var b=s.updateQueue;oi=!1;var E=b.firstBaseUpdate,A=b.lastBaseUpdate,q=b.shared.pending;if(q!==null){b.shared.pending=null;var te=q,he=te.next;te.next=null,A===null?E=he:A.next=he,A=te;var Ae=s.alternate;Ae!==null&&(Ae=Ae.updateQueue,q=Ae.lastBaseUpdate,q!==A&&(q===null?Ae.firstBaseUpdate=he:q.next=he,Ae.lastBaseUpdate=te))}if(E!==null){var Oe=b.baseState;A=0,Ae=he=te=null,q=E;do{var Ce=q.lane,Qe=q.eventTime;if((k&Ce)===Ce){Ae!==null&&(Ae=Ae.next={eventTime:Qe,lane:0,tag:q.tag,payload:q.payload,callback:q.callback,next:null});e:{var ot=s,it=q;switch(Ce=a,Qe=p,it.tag){case 1:if(ot=it.payload,typeof ot=="function"){Oe=ot.call(Qe,Oe,Ce);break e}Oe=ot;break e;case 3:ot.flags=ot.flags&-65537|128;case 0:if(ot=it.payload,Ce=typeof ot=="function"?ot.call(Qe,Oe,Ce):ot,Ce==null)break e;Oe=J({},Oe,Ce);break e;case 2:oi=!0}}q.callback!==null&&q.lane!==0&&(s.flags|=64,Ce=b.effects,Ce===null?b.effects=[q]:Ce.push(q))}else Qe={eventTime:Qe,lane:Ce,tag:q.tag,payload:q.payload,callback:q.callback,next:null},Ae===null?(he=Ae=Qe,te=Oe):Ae=Ae.next=Qe,A|=Ce;if(q=q.next,q===null){if(q=b.shared.pending,q===null)break;Ce=q,q=Ce.next,Ce.next=null,b.lastBaseUpdate=Ce,b.shared.pending=null}}while(!0);if(Ae===null&&(te=Oe),b.baseState=te,b.firstBaseUpdate=he,b.lastBaseUpdate=Ae,a=b.shared.interleaved,a!==null){b=a;do A|=b.lane,b=b.next;while(b!==a)}else E===null&&(b.shared.lanes=0);Qi|=A,s.lanes=A,s.memoizedState=Oe}}function qy(s,a,p){if(s=a.effects,a.effects=null,s!==null)for(a=0;a<s.length;a++){var k=s[a],b=k.callback;if(b!==null){if(k.callback=null,k=p,typeof b!="function")throw Error(n(191,b));b.call(k)}}}var uc={},us=ti(uc),dc=ti(uc),fc=ti(uc);function Yi(s){if(s===uc)throw Error(n(174));return s}function Sp(s,a){switch(In(fc,a),In(dc,s),In(us,uc),s=a.nodeType,s){case 9:case 11:a=(a=a.documentElement)?a.namespaceURI:tn(null,"");break;default:s=s===8?a.parentNode:a,a=s.namespaceURI||null,s=s.tagName,a=tn(a,s)}Pn(us),In(us,a)}function el(){Pn(us),Pn(dc),Pn(fc)}function Gy(s){Yi(fc.current);var a=Yi(us.current),p=tn(a,s.type);a!==p&&(In(dc,s),In(us,p))}function _p(s){dc.current===s&&(Pn(us),Pn(dc))}var Yn=ti(0);function gd(s){for(var a=s;a!==null;){if(a.tag===13){var p=a.memoizedState;if(p!==null&&(p=p.dehydrated,p===null||p.data==="$?"||p.data==="$!"))return a}else if(a.tag===19&&a.memoizedProps.revealOrder!==void 0){if((a.flags&128)!==0)return a}else if(a.child!==null){a.child.return=a,a=a.child;continue}if(a===s)break;for(;a.sibling===null;){if(a.return===null||a.return===s)return null;a=a.return}a.sibling.return=a.return,a=a.sibling}return null}var Np=[];function Tp(){for(var s=0;s<Np.length;s++)Np[s]._workInProgressVersionPrimary=null;Np.length=0}var kd=j.ReactCurrentDispatcher,jp=j.ReactCurrentBatchConfig,Xi=0,Xn=null,mr=null,br=null,wd=!1,hc=!1,pc=0,A$=0;function Mr(){throw Error(n(321))}function $p(s,a){if(a===null)return!1;for(var p=0;p<a.length&&p<s.length;p++)if(!Xr(s[p],a[p]))return!1;return!0}function Cp(s,a,p,k,b,E){if(Xi=E,Xn=a,a.memoizedState=null,a.updateQueue=null,a.lanes=0,kd.current=s===null||s.memoizedState===null?M$:P$,s=p(k,b),hc){E=0;do{if(hc=!1,pc=0,25<=E)throw Error(n(301));E+=1,br=mr=null,a.updateQueue=null,kd.current=L$,s=p(k,b)}while(hc)}if(kd.current=bd,a=mr!==null&&mr.next!==null,Xi=0,br=mr=Xn=null,wd=!1,a)throw Error(n(300));return s}function Ap(){var s=pc!==0;return pc=0,s}function ds(){var s={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return br===null?Xn.memoizedState=br=s:br=br.next=s,br}function Io(){if(mr===null){var s=Xn.alternate;s=s!==null?s.memoizedState:null}else s=mr.next;var a=br===null?Xn.memoizedState:br.next;if(a!==null)br=a,mr=s;else{if(s===null)throw Error(n(310));mr=s,s={memoizedState:mr.memoizedState,baseState:mr.baseState,baseQueue:mr.baseQueue,queue:mr.queue,next:null},br===null?Xn.memoizedState=br=s:br=br.next=s}return br}function mc(s,a){return typeof a=="function"?a(s):a}function Ip(s){var a=Io(),p=a.queue;if(p===null)throw Error(n(311));p.lastRenderedReducer=s;var k=mr,b=k.baseQueue,E=p.pending;if(E!==null){if(b!==null){var A=b.next;b.next=E.next,E.next=A}k.baseQueue=b=E,p.pending=null}if(b!==null){E=b.next,k=k.baseState;var q=A=null,te=null,he=E;do{var Ae=he.lane;if((Xi&Ae)===Ae)te!==null&&(te=te.next={lane:0,action:he.action,hasEagerState:he.hasEagerState,eagerState:he.eagerState,next:null}),k=he.hasEagerState?he.eagerState:s(k,he.action);else{var Oe={lane:Ae,action:he.action,hasEagerState:he.hasEagerState,eagerState:he.eagerState,next:null};te===null?(q=te=Oe,A=k):te=te.next=Oe,Xn.lanes|=Ae,Qi|=Ae}he=he.next}while(he!==null&&he!==E);te===null?A=k:te.next=q,Xr(k,a.memoizedState)||(to=!0),a.memoizedState=k,a.baseState=A,a.baseQueue=te,p.lastRenderedState=k}if(s=p.interleaved,s!==null){b=s;do E=b.lane,Xn.lanes|=E,Qi|=E,b=b.next;while(b!==s)}else b===null&&(p.lanes=0);return[a.memoizedState,p.dispatch]}function Rp(s){var a=Io(),p=a.queue;if(p===null)throw Error(n(311));p.lastRenderedReducer=s;var k=p.dispatch,b=p.pending,E=a.memoizedState;if(b!==null){p.pending=null;var A=b=b.next;do E=s(E,A.action),A=A.next;while(A!==b);Xr(E,a.memoizedState)||(to=!0),a.memoizedState=E,a.baseQueue===null&&(a.baseState=E),p.lastRenderedState=E}return[E,k]}function Vy(){}function Yy(s,a){var p=Xn,k=Io(),b=a(),E=!Xr(k.memoizedState,b);if(E&&(k.memoizedState=b,to=!0),k=k.queue,Op(Jy.bind(null,p,k,s),[s]),k.getSnapshot!==a||E||br!==null&&br.memoizedState.tag&1){if(p.flags|=2048,gc(9,Qy.bind(null,p,k,b,a),void 0,null),xr===null)throw Error(n(349));(Xi&30)!==0||Xy(p,a,b)}return b}function Xy(s,a,p){s.flags|=16384,s={getSnapshot:a,value:p},a=Xn.updateQueue,a===null?(a={lastEffect:null,stores:null},Xn.updateQueue=a,a.stores=[s]):(p=a.stores,p===null?a.stores=[s]:p.push(s))}function Qy(s,a,p,k){a.value=p,a.getSnapshot=k,ev(a)&&tv(s)}function Jy(s,a,p){return p(function(){ev(a)&&tv(s)})}function ev(s){var a=s.getSnapshot;s=s.value;try{var p=a();return!Xr(s,p)}catch{return!0}}function tv(s){var a=Ns(s,1);a!==null&&qo(a,s,1,-1)}function nv(s){var a=ds();return typeof s=="function"&&(s=s()),a.memoizedState=a.baseState=s,s={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:mc,lastRenderedState:s},a.queue=s,s=s.dispatch=O$.bind(null,Xn,s),[a.memoizedState,s]}function gc(s,a,p,k){return s={tag:s,create:a,destroy:p,deps:k,next:null},a=Xn.updateQueue,a===null?(a={lastEffect:null,stores:null},Xn.updateQueue=a,a.lastEffect=s.next=s):(p=a.lastEffect,p===null?a.lastEffect=s.next=s:(k=p.next,p.next=s,s.next=k,a.lastEffect=s)),s}function rv(){return Io().memoizedState}function yd(s,a,p,k){var b=ds();Xn.flags|=s,b.memoizedState=gc(1|a,p,void 0,k===void 0?null:k)}function vd(s,a,p,k){var b=Io();k=k===void 0?null:k;var E=void 0;if(mr!==null){var A=mr.memoizedState;if(E=A.destroy,k!==null&&$p(k,A.deps)){b.memoizedState=gc(a,p,E,k);return}}Xn.flags|=s,b.memoizedState=gc(1|a,p,E,k)}function ov(s,a){return yd(8390656,8,s,a)}function Op(s,a){return vd(2048,8,s,a)}function sv(s,a){return vd(4,2,s,a)}function iv(s,a){return vd(4,4,s,a)}function av(s,a){if(typeof a=="function")return s=s(),a(s),function(){a(null)};if(a!=null)return s=s(),a.current=s,function(){a.current=null}}function lv(s,a,p){return p=p!=null?p.concat([s]):null,vd(4,4,av.bind(null,a,s),p)}function Mp(){}function cv(s,a){var p=Io();a=a===void 0?null:a;var k=p.memoizedState;return k!==null&&a!==null&&$p(a,k[1])?k[0]:(p.memoizedState=[s,a],s)}function uv(s,a){var p=Io();a=a===void 0?null:a;var k=p.memoizedState;return k!==null&&a!==null&&$p(a,k[1])?k[0]:(s=s(),p.memoizedState=[s,a],s)}function dv(s,a,p){return(Xi&21)===0?(s.baseState&&(s.baseState=!1,to=!0),s.memoizedState=p):(Xr(p,a)||(p=Nt(),Xn.lanes|=p,Qi|=p,s.baseState=!0),a)}function I$(s,a){var p=Gt;Gt=p!==0&&4>p?p:4,s(!0);var k=jp.transition;jp.transition={};try{s(!1),a()}finally{Gt=p,jp.transition=k}}function fv(){return Io().memoizedState}function R$(s,a,p){var k=ci(s);if(p={lane:k,action:p,hasEagerState:!1,eagerState:null,next:null},hv(s))pv(a,p);else if(p=Wy(s,a,p,k),p!==null){var b=Zr();qo(p,s,k,b),mv(p,a,k)}}function O$(s,a,p){var k=ci(s),b={lane:k,action:p,hasEagerState:!1,eagerState:null,next:null};if(hv(s))pv(a,b);else{var E=s.alternate;if(s.lanes===0&&(E===null||E.lanes===0)&&(E=a.lastRenderedReducer,E!==null))try{var A=a.lastRenderedState,q=E(A,p);if(b.hasEagerState=!0,b.eagerState=q,Xr(q,A)){var te=a.interleaved;te===null?(b.next=b,xp(a)):(b.next=te.next,te.next=b),a.interleaved=b;return}}catch{}finally{}p=Wy(s,a,b,k),p!==null&&(b=Zr(),qo(p,s,k,b),mv(p,a,k))}}function hv(s){var a=s.alternate;return s===Xn||a!==null&&a===Xn}function pv(s,a){hc=wd=!0;var p=s.pending;p===null?a.next=a:(a.next=p.next,p.next=a),s.pending=a}function mv(s,a,p){if((p&4194240)!==0){var k=a.lanes;k&=s.pendingLanes,p|=k,a.lanes=p,jr(s,p)}}var bd={readContext:Ao,useCallback:Mr,useContext:Mr,useEffect:Mr,useImperativeHandle:Mr,useInsertionEffect:Mr,useLayoutEffect:Mr,useMemo:Mr,useReducer:Mr,useRef:Mr,useState:Mr,useDebugValue:Mr,useDeferredValue:Mr,useTransition:Mr,useMutableSource:Mr,useSyncExternalStore:Mr,useId:Mr,unstable_isNewReconciler:!1},M$={readContext:Ao,useCallback:function(s,a){return ds().memoizedState=[s,a===void 0?null:a],s},useContext:Ao,useEffect:ov,useImperativeHandle:function(s,a,p){return p=p!=null?p.concat([s]):null,yd(4194308,4,av.bind(null,a,s),p)},useLayoutEffect:function(s,a){return yd(4194308,4,s,a)},useInsertionEffect:function(s,a){return yd(4,2,s,a)},useMemo:function(s,a){var p=ds();return a=a===void 0?null:a,s=s(),p.memoizedState=[s,a],s},useReducer:function(s,a,p){var k=ds();return a=p!==void 0?p(a):a,k.memoizedState=k.baseState=a,s={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:s,lastRenderedState:a},k.queue=s,s=s.dispatch=R$.bind(null,Xn,s),[k.memoizedState,s]},useRef:function(s){var a=ds();return s={current:s},a.memoizedState=s},useState:nv,useDebugValue:Mp,useDeferredValue:function(s){return ds().memoizedState=s},useTransition:function(){var s=nv(!1),a=s[0];return s=I$.bind(null,s[1]),ds().memoizedState=s,[a,s]},useMutableSource:function(){},useSyncExternalStore:function(s,a,p){var k=Xn,b=ds();if(Kn){if(p===void 0)throw Error(n(407));p=p()}else{if(p=a(),xr===null)throw Error(n(349));(Xi&30)!==0||Xy(k,a,p)}b.memoizedState=p;var E={value:p,getSnapshot:a};return b.queue=E,ov(Jy.bind(null,k,E,s),[s]),k.flags|=2048,gc(9,Qy.bind(null,k,E,p,a),void 0,null),p},useId:function(){var s=ds(),a=xr.identifierPrefix;if(Kn){var p=_s,k=Ss;p=(k&~(1<<32-Ft(k)-1)).toString(32)+p,a=":"+a+"R"+p,p=pc++,0<p&&(a+="H"+p.toString(32)),a+=":"}else p=A$++,a=":"+a+"r"+p.toString(32)+":";return s.memoizedState=a},unstable_isNewReconciler:!1},P$={readContext:Ao,useCallback:cv,useContext:Ao,useEffect:Op,useImperativeHandle:lv,useInsertionEffect:sv,useLayoutEffect:iv,useMemo:uv,useReducer:Ip,useRef:rv,useState:function(){return Ip(mc)},useDebugValue:Mp,useDeferredValue:function(s){var a=Io();return dv(a,mr.memoizedState,s)},useTransition:function(){var s=Ip(mc)[0],a=Io().memoizedState;return[s,a]},useMutableSource:Vy,useSyncExternalStore:Yy,useId:fv,unstable_isNewReconciler:!1},L$={readContext:Ao,useCallback:cv,useContext:Ao,useEffect:Op,useImperativeHandle:lv,useInsertionEffect:sv,useLayoutEffect:iv,useMemo:uv,useReducer:Rp,useRef:rv,useState:function(){return Rp(mc)},useDebugValue:Mp,useDeferredValue:function(s){var a=Io();return mr===null?a.memoizedState=s:dv(a,mr.memoizedState,s)},useTransition:function(){var s=Rp(mc)[0],a=Io().memoizedState;return[s,a]},useMutableSource:Vy,useSyncExternalStore:Yy,useId:fv,unstable_isNewReconciler:!1};function Wo(s,a){if(s&&s.defaultProps){a=J({},a),s=s.defaultProps;for(var p in s)a[p]===void 0&&(a[p]=s[p]);return a}return a}function Pp(s,a,p,k){a=s.memoizedState,p=p(k,a),p=p==null?a:J({},a,p),s.memoizedState=p,s.lanes===0&&(s.updateQueue.baseState=p)}var xd={isMounted:function(s){return(s=s._reactInternals)?Fn(s)===s:!1},enqueueSetState:function(s,a,p){s=s._reactInternals;var k=Zr(),b=ci(s),E=Ts(k,b);E.payload=a,p!=null&&(E.callback=p),a=si(s,E,b),a!==null&&(qo(a,s,b,k),pd(a,s,b))},enqueueReplaceState:function(s,a,p){s=s._reactInternals;var k=Zr(),b=ci(s),E=Ts(k,b);E.tag=1,E.payload=a,p!=null&&(E.callback=p),a=si(s,E,b),a!==null&&(qo(a,s,b,k),pd(a,s,b))},enqueueForceUpdate:function(s,a){s=s._reactInternals;var p=Zr(),k=ci(s),b=Ts(p,k);b.tag=2,a!=null&&(b.callback=a),a=si(s,b,k),a!==null&&(qo(a,s,k,p),pd(a,s,k))}};function gv(s,a,p,k,b,E,A){return s=s.stateNode,typeof s.shouldComponentUpdate=="function"?s.shouldComponentUpdate(k,E,A):a.prototype&&a.prototype.isPureReactComponent?!Qs(p,k)||!Qs(b,E):!0}function kv(s,a,p){var k=!1,b=ni,E=a.contextType;return typeof E=="object"&&E!==null?E=Ao(E):(b=eo(a)?Zi:Or.current,k=a.contextTypes,E=(k=k!=null)?qa(s,b):ni),a=new a(p,E),s.memoizedState=a.state!==null&&a.state!==void 0?a.state:null,a.updater=xd,s.stateNode=a,a._reactInternals=s,k&&(s=s.stateNode,s.__reactInternalMemoizedUnmaskedChildContext=b,s.__reactInternalMemoizedMaskedChildContext=E),a}function wv(s,a,p,k){s=a.state,typeof a.componentWillReceiveProps=="function"&&a.componentWillReceiveProps(p,k),typeof a.UNSAFE_componentWillReceiveProps=="function"&&a.UNSAFE_componentWillReceiveProps(p,k),a.state!==s&&xd.enqueueReplaceState(a,a.state,null)}function Lp(s,a,p,k){var b=s.stateNode;b.props=p,b.state=s.memoizedState,b.refs={},Ep(s);var E=a.contextType;typeof E=="object"&&E!==null?b.context=Ao(E):(E=eo(a)?Zi:Or.current,b.context=qa(s,E)),b.state=s.memoizedState,E=a.getDerivedStateFromProps,typeof E=="function"&&(Pp(s,a,E,p),b.state=s.memoizedState),typeof a.getDerivedStateFromProps=="function"||typeof b.getSnapshotBeforeUpdate=="function"||typeof b.UNSAFE_componentWillMount!="function"&&typeof b.componentWillMount!="function"||(a=b.state,typeof b.componentWillMount=="function"&&b.componentWillMount(),typeof b.UNSAFE_componentWillMount=="function"&&b.UNSAFE_componentWillMount(),a!==b.state&&xd.enqueueReplaceState(b,b.state,null),md(s,p,b,k),b.state=s.memoizedState),typeof b.componentDidMount=="function"&&(s.flags|=4194308)}function tl(s,a){try{var p="",k=a;do p+=we(k),k=k.return;while(k);var b=p}catch(E){b=`
40
- Error generating stack: `+E.message+`
41
- `+E.stack}return{value:s,source:a,stack:b,digest:null}}function Dp(s,a,p){return{value:s,source:null,stack:p??null,digest:a??null}}function zp(s,a){try{console.error(a.value)}catch(p){setTimeout(function(){throw p})}}var D$=typeof WeakMap=="function"?WeakMap:Map;function yv(s,a,p){p=Ts(-1,p),p.tag=3,p.payload={element:null};var k=a.value;return p.callback=function(){$d||($d=!0,em=k),zp(s,a)},p}function vv(s,a,p){p=Ts(-1,p),p.tag=3;var k=s.type.getDerivedStateFromError;if(typeof k=="function"){var b=a.value;p.payload=function(){return k(b)},p.callback=function(){zp(s,a)}}var E=s.stateNode;return E!==null&&typeof E.componentDidCatch=="function"&&(p.callback=function(){zp(s,a),typeof k!="function"&&(ai===null?ai=new Set([this]):ai.add(this));var A=a.stack;this.componentDidCatch(a.value,{componentStack:A!==null?A:""})}),p}function bv(s,a,p){var k=s.pingCache;if(k===null){k=s.pingCache=new D$;var b=new Set;k.set(a,b)}else b=k.get(a),b===void 0&&(b=new Set,k.set(a,b));b.has(p)||(b.add(p),s=Q$.bind(null,s,a,p),a.then(s,s))}function xv(s){do{var a;if((a=s.tag===13)&&(a=s.memoizedState,a=a!==null?a.dehydrated!==null:!0),a)return s;s=s.return}while(s!==null);return null}function Ev(s,a,p,k,b){return(s.mode&1)===0?(s===a?s.flags|=65536:(s.flags|=128,p.flags|=131072,p.flags&=-52805,p.tag===1&&(p.alternate===null?p.tag=17:(a=Ts(-1,1),a.tag=2,si(p,a,1))),p.lanes|=1),s):(s.flags|=65536,s.lanes=b,s)}var z$=j.ReactCurrentOwner,to=!1;function Kr(s,a,p,k){a.child=s===null?Hy(a,null,p,k):Xa(a,s.child,p,k)}function Sv(s,a,p,k,b){p=p.render;var E=a.ref;return Ja(a,b),k=Cp(s,a,p,k,E,b),p=Ap(),s!==null&&!to?(a.updateQueue=s.updateQueue,a.flags&=-2053,s.lanes&=~b,js(s,a,b)):(Kn&&p&&hp(a),a.flags|=1,Kr(s,a,k,b),a.child)}function _v(s,a,p,k,b){if(s===null){var E=p.type;return typeof E=="function"&&!am(E)&&E.defaultProps===void 0&&p.compare===null&&p.defaultProps===void 0?(a.tag=15,a.type=E,Nv(s,a,E,k,b)):(s=Md(p.type,null,k,a,a.mode,b),s.ref=a.ref,s.return=a,a.child=s)}if(E=s.child,(s.lanes&b)===0){var A=E.memoizedProps;if(p=p.compare,p=p!==null?p:Qs,p(A,k)&&s.ref===a.ref)return js(s,a,b)}return a.flags|=1,s=di(E,k),s.ref=a.ref,s.return=a,a.child=s}function Nv(s,a,p,k,b){if(s!==null){var E=s.memoizedProps;if(Qs(E,k)&&s.ref===a.ref)if(to=!1,a.pendingProps=k=E,(s.lanes&b)!==0)(s.flags&131072)!==0&&(to=!0);else return a.lanes=s.lanes,js(s,a,b)}return Fp(s,a,p,k,b)}function Tv(s,a,p){var k=a.pendingProps,b=k.children,E=s!==null?s.memoizedState:null;if(k.mode==="hidden")if((a.mode&1)===0)a.memoizedState={baseLanes:0,cachePool:null,transitions:null},In(rl,wo),wo|=p;else{if((p&1073741824)===0)return s=E!==null?E.baseLanes|p:p,a.lanes=a.childLanes=1073741824,a.memoizedState={baseLanes:s,cachePool:null,transitions:null},a.updateQueue=null,In(rl,wo),wo|=s,null;a.memoizedState={baseLanes:0,cachePool:null,transitions:null},k=E!==null?E.baseLanes:p,In(rl,wo),wo|=k}else E!==null?(k=E.baseLanes|p,a.memoizedState=null):k=p,In(rl,wo),wo|=k;return Kr(s,a,b,p),a.child}function jv(s,a){var p=a.ref;(s===null&&p!==null||s!==null&&s.ref!==p)&&(a.flags|=512,a.flags|=2097152)}function Fp(s,a,p,k,b){var E=eo(p)?Zi:Or.current;return E=qa(a,E),Ja(a,b),p=Cp(s,a,p,k,E,b),k=Ap(),s!==null&&!to?(a.updateQueue=s.updateQueue,a.flags&=-2053,s.lanes&=~b,js(s,a,b)):(Kn&&k&&hp(a),a.flags|=1,Kr(s,a,p,b),a.child)}function $v(s,a,p,k,b){if(eo(p)){var E=!0;id(a)}else E=!1;if(Ja(a,b),a.stateNode===null)Sd(s,a),kv(a,p,k),Lp(a,p,k,b),k=!0;else if(s===null){var A=a.stateNode,q=a.memoizedProps;A.props=q;var te=A.context,he=p.contextType;typeof he=="object"&&he!==null?he=Ao(he):(he=eo(p)?Zi:Or.current,he=qa(a,he));var Ae=p.getDerivedStateFromProps,Oe=typeof Ae=="function"||typeof A.getSnapshotBeforeUpdate=="function";Oe||typeof A.UNSAFE_componentWillReceiveProps!="function"&&typeof A.componentWillReceiveProps!="function"||(q!==k||te!==he)&&wv(a,A,k,he),oi=!1;var Ce=a.memoizedState;A.state=Ce,md(a,k,A,b),te=a.memoizedState,q!==k||Ce!==te||Jr.current||oi?(typeof Ae=="function"&&(Pp(a,p,Ae,k),te=a.memoizedState),(q=oi||gv(a,p,q,k,Ce,te,he))?(Oe||typeof A.UNSAFE_componentWillMount!="function"&&typeof A.componentWillMount!="function"||(typeof A.componentWillMount=="function"&&A.componentWillMount(),typeof A.UNSAFE_componentWillMount=="function"&&A.UNSAFE_componentWillMount()),typeof A.componentDidMount=="function"&&(a.flags|=4194308)):(typeof A.componentDidMount=="function"&&(a.flags|=4194308),a.memoizedProps=k,a.memoizedState=te),A.props=k,A.state=te,A.context=he,k=q):(typeof A.componentDidMount=="function"&&(a.flags|=4194308),k=!1)}else{A=a.stateNode,Ky(s,a),q=a.memoizedProps,he=a.type===a.elementType?q:Wo(a.type,q),A.props=he,Oe=a.pendingProps,Ce=A.context,te=p.contextType,typeof te=="object"&&te!==null?te=Ao(te):(te=eo(p)?Zi:Or.current,te=qa(a,te));var Qe=p.getDerivedStateFromProps;(Ae=typeof Qe=="function"||typeof A.getSnapshotBeforeUpdate=="function")||typeof A.UNSAFE_componentWillReceiveProps!="function"&&typeof A.componentWillReceiveProps!="function"||(q!==Oe||Ce!==te)&&wv(a,A,k,te),oi=!1,Ce=a.memoizedState,A.state=Ce,md(a,k,A,b);var ot=a.memoizedState;q!==Oe||Ce!==ot||Jr.current||oi?(typeof Qe=="function"&&(Pp(a,p,Qe,k),ot=a.memoizedState),(he=oi||gv(a,p,he,k,Ce,ot,te)||!1)?(Ae||typeof A.UNSAFE_componentWillUpdate!="function"&&typeof A.componentWillUpdate!="function"||(typeof A.componentWillUpdate=="function"&&A.componentWillUpdate(k,ot,te),typeof A.UNSAFE_componentWillUpdate=="function"&&A.UNSAFE_componentWillUpdate(k,ot,te)),typeof A.componentDidUpdate=="function"&&(a.flags|=4),typeof A.getSnapshotBeforeUpdate=="function"&&(a.flags|=1024)):(typeof A.componentDidUpdate!="function"||q===s.memoizedProps&&Ce===s.memoizedState||(a.flags|=4),typeof A.getSnapshotBeforeUpdate!="function"||q===s.memoizedProps&&Ce===s.memoizedState||(a.flags|=1024),a.memoizedProps=k,a.memoizedState=ot),A.props=k,A.state=ot,A.context=te,k=he):(typeof A.componentDidUpdate!="function"||q===s.memoizedProps&&Ce===s.memoizedState||(a.flags|=4),typeof A.getSnapshotBeforeUpdate!="function"||q===s.memoizedProps&&Ce===s.memoizedState||(a.flags|=1024),k=!1)}return Bp(s,a,p,k,E,b)}function Bp(s,a,p,k,b,E){jv(s,a);var A=(a.flags&128)!==0;if(!k&&!A)return b&&Oy(a,p,!1),js(s,a,E);k=a.stateNode,z$.current=a;var q=A&&typeof p.getDerivedStateFromError!="function"?null:k.render();return a.flags|=1,s!==null&&A?(a.child=Xa(a,s.child,null,E),a.child=Xa(a,null,q,E)):Kr(s,a,q,E),a.memoizedState=k.state,b&&Oy(a,p,!0),a.child}function Cv(s){var a=s.stateNode;a.pendingContext?Iy(s,a.pendingContext,a.pendingContext!==a.context):a.context&&Iy(s,a.context,!1),Sp(s,a.containerInfo)}function Av(s,a,p,k,b){return Ya(),kp(b),a.flags|=256,Kr(s,a,p,k),a.child}var Up={dehydrated:null,treeContext:null,retryLane:0};function Hp(s){return{baseLanes:s,cachePool:null,transitions:null}}function Iv(s,a,p){var k=a.pendingProps,b=Yn.current,E=!1,A=(a.flags&128)!==0,q;if((q=A)||(q=s!==null&&s.memoizedState===null?!1:(b&2)!==0),q?(E=!0,a.flags&=-129):(s===null||s.memoizedState!==null)&&(b|=1),In(Yn,b&1),s===null)return gp(a),s=a.memoizedState,s!==null&&(s=s.dehydrated,s!==null)?((a.mode&1)===0?a.lanes=1:s.data==="$!"?a.lanes=8:a.lanes=1073741824,null):(A=k.children,s=k.fallback,E?(k=a.mode,E=a.child,A={mode:"hidden",children:A},(k&1)===0&&E!==null?(E.childLanes=0,E.pendingProps=A):E=Pd(A,k,0,null),s=na(s,k,p,null),E.return=a,s.return=a,E.sibling=s,a.child=E,a.child.memoizedState=Hp(p),a.memoizedState=Up,s):Wp(a,A));if(b=s.memoizedState,b!==null&&(q=b.dehydrated,q!==null))return F$(s,a,A,k,q,b,p);if(E){E=k.fallback,A=a.mode,b=s.child,q=b.sibling;var te={mode:"hidden",children:k.children};return(A&1)===0&&a.child!==b?(k=a.child,k.childLanes=0,k.pendingProps=te,a.deletions=null):(k=di(b,te),k.subtreeFlags=b.subtreeFlags&14680064),q!==null?E=di(q,E):(E=na(E,A,p,null),E.flags|=2),E.return=a,k.return=a,k.sibling=E,a.child=k,k=E,E=a.child,A=s.child.memoizedState,A=A===null?Hp(p):{baseLanes:A.baseLanes|p,cachePool:null,transitions:A.transitions},E.memoizedState=A,E.childLanes=s.childLanes&~p,a.memoizedState=Up,k}return E=s.child,s=E.sibling,k=di(E,{mode:"visible",children:k.children}),(a.mode&1)===0&&(k.lanes=p),k.return=a,k.sibling=null,s!==null&&(p=a.deletions,p===null?(a.deletions=[s],a.flags|=16):p.push(s)),a.child=k,a.memoizedState=null,k}function Wp(s,a){return a=Pd({mode:"visible",children:a},s.mode,0,null),a.return=s,s.child=a}function Ed(s,a,p,k){return k!==null&&kp(k),Xa(a,s.child,null,p),s=Wp(a,a.pendingProps.children),s.flags|=2,a.memoizedState=null,s}function F$(s,a,p,k,b,E,A){if(p)return a.flags&256?(a.flags&=-257,k=Dp(Error(n(422))),Ed(s,a,A,k)):a.memoizedState!==null?(a.child=s.child,a.flags|=128,null):(E=k.fallback,b=a.mode,k=Pd({mode:"visible",children:k.children},b,0,null),E=na(E,b,A,null),E.flags|=2,k.return=a,E.return=a,k.sibling=E,a.child=k,(a.mode&1)!==0&&Xa(a,s.child,null,A),a.child.memoizedState=Hp(A),a.memoizedState=Up,E);if((a.mode&1)===0)return Ed(s,a,A,null);if(b.data==="$!"){if(k=b.nextSibling&&b.nextSibling.dataset,k)var q=k.dgst;return k=q,E=Error(n(419)),k=Dp(E,k,void 0),Ed(s,a,A,k)}if(q=(A&s.childLanes)!==0,to||q){if(k=xr,k!==null){switch(A&-A){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|A))!==0?0:b,b!==0&&b!==E.retryLane&&(E.retryLane=b,Ns(s,b),qo(k,s,b,-1))}return im(),k=Dp(Error(n(421))),Ed(s,a,A,k)}return b.data==="$?"?(a.flags|=128,a.child=s.child,a=J$.bind(null,s),b._reactRetry=a,null):(s=E.treeContext,ko=ei(b.nextSibling),go=a,Kn=!0,Ho=null,s!==null&&($o[Co++]=Ss,$o[Co++]=_s,$o[Co++]=qi,Ss=s.id,_s=s.overflow,qi=a),a=Wp(a,k.children),a.flags|=4096,a)}function Rv(s,a,p){s.lanes|=a;var k=s.alternate;k!==null&&(k.lanes|=a),bp(s.return,a,p)}function Kp(s,a,p,k,b){var E=s.memoizedState;E===null?s.memoizedState={isBackwards:a,rendering:null,renderingStartTime:0,last:k,tail:p,tailMode:b}:(E.isBackwards=a,E.rendering=null,E.renderingStartTime=0,E.last=k,E.tail=p,E.tailMode=b)}function Ov(s,a,p){var k=a.pendingProps,b=k.revealOrder,E=k.tail;if(Kr(s,a,k.children,p),k=Yn.current,(k&2)!==0)k=k&1|2,a.flags|=128;else{if(s!==null&&(s.flags&128)!==0)e:for(s=a.child;s!==null;){if(s.tag===13)s.memoizedState!==null&&Rv(s,p,a);else if(s.tag===19)Rv(s,p,a);else if(s.child!==null){s.child.return=s,s=s.child;continue}if(s===a)break e;for(;s.sibling===null;){if(s.return===null||s.return===a)break e;s=s.return}s.sibling.return=s.return,s=s.sibling}k&=1}if(In(Yn,k),(a.mode&1)===0)a.memoizedState=null;else switch(b){case"forwards":for(p=a.child,b=null;p!==null;)s=p.alternate,s!==null&&gd(s)===null&&(b=p),p=p.sibling;p=b,p===null?(b=a.child,a.child=null):(b=p.sibling,p.sibling=null),Kp(a,!1,b,p,E);break;case"backwards":for(p=null,b=a.child,a.child=null;b!==null;){if(s=b.alternate,s!==null&&gd(s)===null){a.child=b;break}s=b.sibling,b.sibling=p,p=b,b=s}Kp(a,!0,p,null,E);break;case"together":Kp(a,!1,null,null,void 0);break;default:a.memoizedState=null}return a.child}function Sd(s,a){(a.mode&1)===0&&s!==null&&(s.alternate=null,a.alternate=null,a.flags|=2)}function js(s,a,p){if(s!==null&&(a.dependencies=s.dependencies),Qi|=a.lanes,(p&a.childLanes)===0)return null;if(s!==null&&a.child!==s.child)throw Error(n(153));if(a.child!==null){for(s=a.child,p=di(s,s.pendingProps),a.child=p,p.return=a;s.sibling!==null;)s=s.sibling,p=p.sibling=di(s,s.pendingProps),p.return=a;p.sibling=null}return a.child}function B$(s,a,p){switch(a.tag){case 3:Cv(a),Ya();break;case 5:Gy(a);break;case 1:eo(a.type)&&id(a);break;case 4:Sp(a,a.stateNode.containerInfo);break;case 10:var k=a.type._context,b=a.memoizedProps.value;In(fd,k._currentValue),k._currentValue=b;break;case 13:if(k=a.memoizedState,k!==null)return k.dehydrated!==null?(In(Yn,Yn.current&1),a.flags|=128,null):(p&a.child.childLanes)!==0?Iv(s,a,p):(In(Yn,Yn.current&1),s=js(s,a,p),s!==null?s.sibling:null);In(Yn,Yn.current&1);break;case 19:if(k=(p&a.childLanes)!==0,(s.flags&128)!==0){if(k)return Ov(s,a,p);a.flags|=128}if(b=a.memoizedState,b!==null&&(b.rendering=null,b.tail=null,b.lastEffect=null),In(Yn,Yn.current),k)break;return null;case 22:case 23:return a.lanes=0,Tv(s,a,p)}return js(s,a,p)}var Mv,Zp,Pv,Lv;Mv=function(s,a){for(var p=a.child;p!==null;){if(p.tag===5||p.tag===6)s.appendChild(p.stateNode);else if(p.tag!==4&&p.child!==null){p.child.return=p,p=p.child;continue}if(p===a)break;for(;p.sibling===null;){if(p.return===null||p.return===a)return;p=p.return}p.sibling.return=p.return,p=p.sibling}},Zp=function(){},Pv=function(s,a,p,k){var b=s.memoizedProps;if(b!==k){s=a.stateNode,Yi(us.current);var E=null;switch(p){case"input":b=me(s,b),k=me(s,k),E=[];break;case"select":b=J({},b,{value:void 0}),k=J({},k,{value:void 0}),E=[];break;case"textarea":b=Xt(s,b),k=Xt(s,k),E=[];break;default:typeof b.onClick!="function"&&typeof k.onClick=="function"&&(s.onclick=rd)}ke(p,k);var A;p=null;for(he in b)if(!k.hasOwnProperty(he)&&b.hasOwnProperty(he)&&b[he]!=null)if(he==="style"){var q=b[he];for(A in q)q.hasOwnProperty(A)&&(p||(p={}),p[A]="")}else he!=="dangerouslySetInnerHTML"&&he!=="children"&&he!=="suppressContentEditableWarning"&&he!=="suppressHydrationWarning"&&he!=="autoFocus"&&(o.hasOwnProperty(he)?E||(E=[]):(E=E||[]).push(he,null));for(he in k){var te=k[he];if(q=b!=null?b[he]:void 0,k.hasOwnProperty(he)&&te!==q&&(te!=null||q!=null))if(he==="style")if(q){for(A in q)!q.hasOwnProperty(A)||te&&te.hasOwnProperty(A)||(p||(p={}),p[A]="");for(A in te)te.hasOwnProperty(A)&&q[A]!==te[A]&&(p||(p={}),p[A]=te[A])}else p||(E||(E=[]),E.push(he,p)),p=te;else he==="dangerouslySetInnerHTML"?(te=te?te.__html:void 0,q=q?q.__html:void 0,te!=null&&q!==te&&(E=E||[]).push(he,te)):he==="children"?typeof te!="string"&&typeof te!="number"||(E=E||[]).push(he,""+te):he!=="suppressContentEditableWarning"&&he!=="suppressHydrationWarning"&&(o.hasOwnProperty(he)?(te!=null&&he==="onScroll"&&Mn("scroll",s),E||q===te||(E=[])):(E=E||[]).push(he,te))}p&&(E=E||[]).push("style",p);var he=E;(a.updateQueue=he)&&(a.flags|=4)}},Lv=function(s,a,p,k){p!==k&&(a.flags|=4)};function kc(s,a){if(!Kn)switch(s.tailMode){case"hidden":a=s.tail;for(var p=null;a!==null;)a.alternate!==null&&(p=a),a=a.sibling;p===null?s.tail=null:p.sibling=null;break;case"collapsed":p=s.tail;for(var k=null;p!==null;)p.alternate!==null&&(k=p),p=p.sibling;k===null?a||s.tail===null?s.tail=null:s.tail.sibling=null:k.sibling=null}}function Pr(s){var a=s.alternate!==null&&s.alternate.child===s.child,p=0,k=0;if(a)for(var b=s.child;b!==null;)p|=b.lanes|b.childLanes,k|=b.subtreeFlags&14680064,k|=b.flags&14680064,b.return=s,b=b.sibling;else for(b=s.child;b!==null;)p|=b.lanes|b.childLanes,k|=b.subtreeFlags,k|=b.flags,b.return=s,b=b.sibling;return s.subtreeFlags|=k,s.childLanes=p,a}function U$(s,a,p){var k=a.pendingProps;switch(pp(a),a.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Pr(a),null;case 1:return eo(a.type)&&sd(),Pr(a),null;case 3:return k=a.stateNode,el(),Pn(Jr),Pn(Or),Tp(),k.pendingContext&&(k.context=k.pendingContext,k.pendingContext=null),(s===null||s.child===null)&&(ud(a)?a.flags|=4:s===null||s.memoizedState.isDehydrated&&(a.flags&256)===0||(a.flags|=1024,Ho!==null&&(rm(Ho),Ho=null))),Zp(s,a),Pr(a),null;case 5:_p(a);var b=Yi(fc.current);if(p=a.type,s!==null&&a.stateNode!=null)Pv(s,a,p,k,b),s.ref!==a.ref&&(a.flags|=512,a.flags|=2097152);else{if(!k){if(a.stateNode===null)throw Error(n(166));return Pr(a),null}if(s=Yi(us.current),ud(a)){k=a.stateNode,p=a.type;var E=a.memoizedProps;switch(k[cs]=a,k[ac]=E,s=(a.mode&1)!==0,p){case"dialog":Mn("cancel",k),Mn("close",k);break;case"iframe":case"object":case"embed":Mn("load",k);break;case"video":case"audio":for(b=0;b<oc.length;b++)Mn(oc[b],k);break;case"source":Mn("error",k);break;case"img":case"image":case"link":Mn("error",k),Mn("load",k);break;case"details":Mn("toggle",k);break;case"input":Ue(k,E),Mn("invalid",k);break;case"select":k._wrapperState={wasMultiple:!!E.multiple},Mn("invalid",k);break;case"textarea":ln(k,E),Mn("invalid",k)}ke(p,E),b=null;for(var A in E)if(E.hasOwnProperty(A)){var q=E[A];A==="children"?typeof q=="string"?k.textContent!==q&&(E.suppressHydrationWarning!==!0&&nd(k.textContent,q,s),b=["children",q]):typeof q=="number"&&k.textContent!==""+q&&(E.suppressHydrationWarning!==!0&&nd(k.textContent,q,s),b=["children",""+q]):o.hasOwnProperty(A)&&q!=null&&A==="onScroll"&&Mn("scroll",k)}switch(p){case"input":ve(k),mt(k,E,!0);break;case"textarea":ve(k),Je(k);break;case"select":case"option":break;default:typeof E.onClick=="function"&&(k.onclick=rd)}k=b,a.updateQueue=k,k!==null&&(a.flags|=4)}else{A=b.nodeType===9?b:b.ownerDocument,s==="http://www.w3.org/1999/xhtml"&&(s=Vt(p)),s==="http://www.w3.org/1999/xhtml"?p==="script"?(s=A.createElement("div"),s.innerHTML="<script><\/script>",s=s.removeChild(s.firstChild)):typeof k.is=="string"?s=A.createElement(p,{is:k.is}):(s=A.createElement(p),p==="select"&&(A=s,k.multiple?A.multiple=!0:k.size&&(A.size=k.size))):s=A.createElementNS(s,p),s[cs]=a,s[ac]=k,Mv(s,a,!1,!1),a.stateNode=s;e:{switch(A=Xe(p,k),p){case"dialog":Mn("cancel",s),Mn("close",s),b=k;break;case"iframe":case"object":case"embed":Mn("load",s),b=k;break;case"video":case"audio":for(b=0;b<oc.length;b++)Mn(oc[b],s);b=k;break;case"source":Mn("error",s),b=k;break;case"img":case"image":case"link":Mn("error",s),Mn("load",s),b=k;break;case"details":Mn("toggle",s),b=k;break;case"input":Ue(s,k),b=me(s,k),Mn("invalid",s);break;case"option":b=k;break;case"select":s._wrapperState={wasMultiple:!!k.multiple},b=J({},k,{value:void 0}),Mn("invalid",s);break;case"textarea":ln(s,k),b=Xt(s,k),Mn("invalid",s);break;default:b=k}ke(p,b),q=b;for(E in q)if(q.hasOwnProperty(E)){var te=q[E];E==="style"?bt(s,te):E==="dangerouslySetInnerHTML"?(te=te?te.__html:void 0,te!=null&&gt(s,te)):E==="children"?typeof te=="string"?(p!=="textarea"||te!=="")&&sn(s,te):typeof te=="number"&&sn(s,""+te):E!=="suppressContentEditableWarning"&&E!=="suppressHydrationWarning"&&E!=="autoFocus"&&(o.hasOwnProperty(E)?te!=null&&E==="onScroll"&&Mn("scroll",s):te!=null&&N(s,E,te,A))}switch(p){case"input":ve(s),mt(s,k,!1);break;case"textarea":ve(s),Je(s);break;case"option":k.value!=null&&s.setAttribute("value",""+W(k.value));break;case"select":s.multiple=!!k.multiple,E=k.value,E!=null?Be(s,!!k.multiple,E,!1):k.defaultValue!=null&&Be(s,!!k.multiple,k.defaultValue,!0);break;default:typeof b.onClick=="function"&&(s.onclick=rd)}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&&(a.flags|=4)}a.ref!==null&&(a.flags|=512,a.flags|=2097152)}return Pr(a),null;case 6:if(s&&a.stateNode!=null)Lv(s,a,s.memoizedProps,k);else{if(typeof k!="string"&&a.stateNode===null)throw Error(n(166));if(p=Yi(fc.current),Yi(us.current),ud(a)){if(k=a.stateNode,p=a.memoizedProps,k[cs]=a,(E=k.nodeValue!==p)&&(s=go,s!==null))switch(s.tag){case 3:nd(k.nodeValue,p,(s.mode&1)!==0);break;case 5:s.memoizedProps.suppressHydrationWarning!==!0&&nd(k.nodeValue,p,(s.mode&1)!==0)}E&&(a.flags|=4)}else k=(p.nodeType===9?p:p.ownerDocument).createTextNode(k),k[cs]=a,a.stateNode=k}return Pr(a),null;case 13:if(Pn(Yn),k=a.memoizedState,s===null||s.memoizedState!==null&&s.memoizedState.dehydrated!==null){if(Kn&&ko!==null&&(a.mode&1)!==0&&(a.flags&128)===0)Fy(),Ya(),a.flags|=98560,E=!1;else if(E=ud(a),k!==null&&k.dehydrated!==null){if(s===null){if(!E)throw Error(n(318));if(E=a.memoizedState,E=E!==null?E.dehydrated:null,!E)throw Error(n(317));E[cs]=a}else Ya(),(a.flags&128)===0&&(a.memoizedState=null),a.flags|=4;Pr(a),E=!1}else Ho!==null&&(rm(Ho),Ho=null),E=!0;if(!E)return a.flags&65536?a:null}return(a.flags&128)!==0?(a.lanes=p,a):(k=k!==null,k!==(s!==null&&s.memoizedState!==null)&&k&&(a.child.flags|=8192,(a.mode&1)!==0&&(s===null||(Yn.current&1)!==0?gr===0&&(gr=3):im())),a.updateQueue!==null&&(a.flags|=4),Pr(a),null);case 4:return el(),Zp(s,a),s===null&&sc(a.stateNode.containerInfo),Pr(a),null;case 10:return vp(a.type._context),Pr(a),null;case 17:return eo(a.type)&&sd(),Pr(a),null;case 19:if(Pn(Yn),E=a.memoizedState,E===null)return Pr(a),null;if(k=(a.flags&128)!==0,A=E.rendering,A===null)if(k)kc(E,!1);else{if(gr!==0||s!==null&&(s.flags&128)!==0)for(s=a.child;s!==null;){if(A=gd(s),A!==null){for(a.flags|=128,kc(E,!1),k=A.updateQueue,k!==null&&(a.updateQueue=k,a.flags|=4),a.subtreeFlags=0,k=p,p=a.child;p!==null;)E=p,s=k,E.flags&=14680066,A=E.alternate,A===null?(E.childLanes=0,E.lanes=s,E.child=null,E.subtreeFlags=0,E.memoizedProps=null,E.memoizedState=null,E.updateQueue=null,E.dependencies=null,E.stateNode=null):(E.childLanes=A.childLanes,E.lanes=A.lanes,E.child=A.child,E.subtreeFlags=0,E.deletions=null,E.memoizedProps=A.memoizedProps,E.memoizedState=A.memoizedState,E.updateQueue=A.updateQueue,E.type=A.type,s=A.dependencies,E.dependencies=s===null?null:{lanes:s.lanes,firstContext:s.firstContext}),p=p.sibling;return In(Yn,Yn.current&1|2),a.child}s=s.sibling}E.tail!==null&&Wt()>ol&&(a.flags|=128,k=!0,kc(E,!1),a.lanes=4194304)}else{if(!k)if(s=gd(A),s!==null){if(a.flags|=128,k=!0,p=s.updateQueue,p!==null&&(a.updateQueue=p,a.flags|=4),kc(E,!0),E.tail===null&&E.tailMode==="hidden"&&!A.alternate&&!Kn)return Pr(a),null}else 2*Wt()-E.renderingStartTime>ol&&p!==1073741824&&(a.flags|=128,k=!0,kc(E,!1),a.lanes=4194304);E.isBackwards?(A.sibling=a.child,a.child=A):(p=E.last,p!==null?p.sibling=A:a.child=A,E.last=A)}return E.tail!==null?(a=E.tail,E.rendering=a,E.tail=a.sibling,E.renderingStartTime=Wt(),a.sibling=null,p=Yn.current,In(Yn,k?p&1|2:p&1),a):(Pr(a),null);case 22:case 23:return sm(),k=a.memoizedState!==null,s!==null&&s.memoizedState!==null!==k&&(a.flags|=8192),k&&(a.mode&1)!==0?(wo&1073741824)!==0&&(Pr(a),a.subtreeFlags&6&&(a.flags|=8192)):Pr(a),null;case 24:return null;case 25:return null}throw Error(n(156,a.tag))}function H$(s,a){switch(pp(a),a.tag){case 1:return eo(a.type)&&sd(),s=a.flags,s&65536?(a.flags=s&-65537|128,a):null;case 3:return el(),Pn(Jr),Pn(Or),Tp(),s=a.flags,(s&65536)!==0&&(s&128)===0?(a.flags=s&-65537|128,a):null;case 5:return _p(a),null;case 13:if(Pn(Yn),s=a.memoizedState,s!==null&&s.dehydrated!==null){if(a.alternate===null)throw Error(n(340));Ya()}return s=a.flags,s&65536?(a.flags=s&-65537|128,a):null;case 19:return Pn(Yn),null;case 4:return el(),null;case 10:return vp(a.type._context),null;case 22:case 23:return sm(),null;case 24:return null;default:return null}}var _d=!1,Lr=!1,W$=typeof WeakSet=="function"?WeakSet:Set,nt=null;function nl(s,a){var p=s.ref;if(p!==null)if(typeof p=="function")try{p(null)}catch(k){nr(s,a,k)}else p.current=null}function qp(s,a,p){try{p()}catch(k){nr(s,a,k)}}var Dv=!1;function K$(s,a){if(sp=Ca,s=At(),Vn(s)){if("selectionStart"in s)var p={start:s.selectionStart,end:s.selectionEnd};else e:{p=(p=s.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 A=0,q=-1,te=-1,he=0,Ae=0,Oe=s,Ce=null;t:for(;;){for(var Qe;Oe!==p||b!==0&&Oe.nodeType!==3||(q=A+b),Oe!==E||k!==0&&Oe.nodeType!==3||(te=A+k),Oe.nodeType===3&&(A+=Oe.nodeValue.length),(Qe=Oe.firstChild)!==null;)Ce=Oe,Oe=Qe;for(;;){if(Oe===s)break t;if(Ce===p&&++he===b&&(q=A),Ce===E&&++Ae===k&&(te=A),(Qe=Oe.nextSibling)!==null)break;Oe=Ce,Ce=Oe.parentNode}Oe=Qe}p=q===-1||te===-1?null:{start:q,end:te}}else p=null}p=p||{start:0,end:0}}else p=null;for(ip={focusedElem:s,selectionRange:p},Ca=!1,nt=a;nt!==null;)if(a=nt,s=a.child,(a.subtreeFlags&1028)!==0&&s!==null)s.return=a,nt=s;else for(;nt!==null;){a=nt;try{var ot=a.alternate;if((a.flags&1024)!==0)switch(a.tag){case 0:case 11:case 15:break;case 1:if(ot!==null){var it=ot.memoizedProps,or=ot.memoizedState,ue=a.stateNode,se=ue.getSnapshotBeforeUpdate(a.elementType===a.type?it:Wo(a.type,it),or);ue.__reactInternalSnapshotBeforeUpdate=se}break;case 3:var de=a.stateNode.containerInfo;de.nodeType===1?de.textContent="":de.nodeType===9&&de.documentElement&&de.removeChild(de.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(n(163))}}catch(Fe){nr(a,a.return,Fe)}if(s=a.sibling,s!==null){s.return=a.return,nt=s;break}nt=a.return}return ot=Dv,Dv=!1,ot}function wc(s,a,p){var k=a.updateQueue;if(k=k!==null?k.lastEffect:null,k!==null){var b=k=k.next;do{if((b.tag&s)===s){var E=b.destroy;b.destroy=void 0,E!==void 0&&qp(a,p,E)}b=b.next}while(b!==k)}}function Nd(s,a){if(a=a.updateQueue,a=a!==null?a.lastEffect:null,a!==null){var p=a=a.next;do{if((p.tag&s)===s){var k=p.create;p.destroy=k()}p=p.next}while(p!==a)}}function Gp(s){var a=s.ref;if(a!==null){var p=s.stateNode;switch(s.tag){case 5:s=p;break;default:s=p}typeof a=="function"?a(s):a.current=s}}function zv(s){var a=s.alternate;a!==null&&(s.alternate=null,zv(a)),s.child=null,s.deletions=null,s.sibling=null,s.tag===5&&(a=s.stateNode,a!==null&&(delete a[cs],delete a[ac],delete a[up],delete a[T$],delete a[j$])),s.stateNode=null,s.return=null,s.dependencies=null,s.memoizedProps=null,s.memoizedState=null,s.pendingProps=null,s.stateNode=null,s.updateQueue=null}function Fv(s){return s.tag===5||s.tag===3||s.tag===4}function Bv(s){e:for(;;){for(;s.sibling===null;){if(s.return===null||Fv(s.return))return null;s=s.return}for(s.sibling.return=s.return,s=s.sibling;s.tag!==5&&s.tag!==6&&s.tag!==18;){if(s.flags&2||s.child===null||s.tag===4)continue e;s.child.return=s,s=s.child}if(!(s.flags&2))return s.stateNode}}function Vp(s,a,p){var k=s.tag;if(k===5||k===6)s=s.stateNode,a?p.nodeType===8?p.parentNode.insertBefore(s,a):p.insertBefore(s,a):(p.nodeType===8?(a=p.parentNode,a.insertBefore(s,p)):(a=p,a.appendChild(s)),p=p._reactRootContainer,p!=null||a.onclick!==null||(a.onclick=rd));else if(k!==4&&(s=s.child,s!==null))for(Vp(s,a,p),s=s.sibling;s!==null;)Vp(s,a,p),s=s.sibling}function Yp(s,a,p){var k=s.tag;if(k===5||k===6)s=s.stateNode,a?p.insertBefore(s,a):p.appendChild(s);else if(k!==4&&(s=s.child,s!==null))for(Yp(s,a,p),s=s.sibling;s!==null;)Yp(s,a,p),s=s.sibling}var Cr=null,Ko=!1;function ii(s,a,p){for(p=p.child;p!==null;)Uv(s,a,p),p=p.sibling}function Uv(s,a,p){if(at&&typeof at.onCommitFiberUnmount=="function")try{at.onCommitFiberUnmount(xt,p)}catch{}switch(p.tag){case 5:Lr||nl(p,a);case 6:var k=Cr,b=Ko;Cr=null,ii(s,a,p),Cr=k,Ko=b,Cr!==null&&(Ko?(s=Cr,p=p.stateNode,s.nodeType===8?s.parentNode.removeChild(p):s.removeChild(p)):Cr.removeChild(p.stateNode));break;case 18:Cr!==null&&(Ko?(s=Cr,p=p.stateNode,s.nodeType===8?cp(s.parentNode,p):s.nodeType===1&&cp(s,p),Oi(s)):cp(Cr,p.stateNode));break;case 4:k=Cr,b=Ko,Cr=p.stateNode.containerInfo,Ko=!0,ii(s,a,p),Cr=k,Ko=b;break;case 0:case 11:case 14:case 15:if(!Lr&&(k=p.updateQueue,k!==null&&(k=k.lastEffect,k!==null))){b=k=k.next;do{var E=b,A=E.destroy;E=E.tag,A!==void 0&&((E&2)!==0||(E&4)!==0)&&qp(p,a,A),b=b.next}while(b!==k)}ii(s,a,p);break;case 1:if(!Lr&&(nl(p,a),k=p.stateNode,typeof k.componentWillUnmount=="function"))try{k.props=p.memoizedProps,k.state=p.memoizedState,k.componentWillUnmount()}catch(q){nr(p,a,q)}ii(s,a,p);break;case 21:ii(s,a,p);break;case 22:p.mode&1?(Lr=(k=Lr)||p.memoizedState!==null,ii(s,a,p),Lr=k):ii(s,a,p);break;default:ii(s,a,p)}}function Hv(s){var a=s.updateQueue;if(a!==null){s.updateQueue=null;var p=s.stateNode;p===null&&(p=s.stateNode=new W$),a.forEach(function(k){var b=eC.bind(null,s,k);p.has(k)||(p.add(k),k.then(b,b))})}}function Zo(s,a){var p=a.deletions;if(p!==null)for(var k=0;k<p.length;k++){var b=p[k];try{var E=s,A=a,q=A;e:for(;q!==null;){switch(q.tag){case 5:Cr=q.stateNode,Ko=!1;break e;case 3:Cr=q.stateNode.containerInfo,Ko=!0;break e;case 4:Cr=q.stateNode.containerInfo,Ko=!0;break e}q=q.return}if(Cr===null)throw Error(n(160));Uv(E,A,b),Cr=null,Ko=!1;var te=b.alternate;te!==null&&(te.return=null),b.return=null}catch(he){nr(b,a,he)}}if(a.subtreeFlags&12854)for(a=a.child;a!==null;)Wv(a,s),a=a.sibling}function Wv(s,a){var p=s.alternate,k=s.flags;switch(s.tag){case 0:case 11:case 14:case 15:if(Zo(a,s),fs(s),k&4){try{wc(3,s,s.return),Nd(3,s)}catch(it){nr(s,s.return,it)}try{wc(5,s,s.return)}catch(it){nr(s,s.return,it)}}break;case 1:Zo(a,s),fs(s),k&512&&p!==null&&nl(p,p.return);break;case 5:if(Zo(a,s),fs(s),k&512&&p!==null&&nl(p,p.return),s.flags&32){var b=s.stateNode;try{sn(b,"")}catch(it){nr(s,s.return,it)}}if(k&4&&(b=s.stateNode,b!=null)){var E=s.memoizedProps,A=p!==null?p.memoizedProps:E,q=s.type,te=s.updateQueue;if(s.updateQueue=null,te!==null)try{q==="input"&&E.type==="radio"&&E.name!=null&&Ie(b,E),Xe(q,A);var he=Xe(q,E);for(A=0;A<te.length;A+=2){var Ae=te[A],Oe=te[A+1];Ae==="style"?bt(b,Oe):Ae==="dangerouslySetInnerHTML"?gt(b,Oe):Ae==="children"?sn(b,Oe):N(b,Ae,Oe,he)}switch(q){case"input":We(b,E);break;case"textarea":It(b,E);break;case"select":var Ce=b._wrapperState.wasMultiple;b._wrapperState.wasMultiple=!!E.multiple;var Qe=E.value;Qe!=null?Be(b,!!E.multiple,Qe,!1):Ce!==!!E.multiple&&(E.defaultValue!=null?Be(b,!!E.multiple,E.defaultValue,!0):Be(b,!!E.multiple,E.multiple?[]:"",!1))}b[ac]=E}catch(it){nr(s,s.return,it)}}break;case 6:if(Zo(a,s),fs(s),k&4){if(s.stateNode===null)throw Error(n(162));b=s.stateNode,E=s.memoizedProps;try{b.nodeValue=E}catch(it){nr(s,s.return,it)}}break;case 3:if(Zo(a,s),fs(s),k&4&&p!==null&&p.memoizedState.isDehydrated)try{Oi(a.containerInfo)}catch(it){nr(s,s.return,it)}break;case 4:Zo(a,s),fs(s);break;case 13:Zo(a,s),fs(s),b=s.child,b.flags&8192&&(E=b.memoizedState!==null,b.stateNode.isHidden=E,!E||b.alternate!==null&&b.alternate.memoizedState!==null||(Jp=Wt())),k&4&&Hv(s);break;case 22:if(Ae=p!==null&&p.memoizedState!==null,s.mode&1?(Lr=(he=Lr)||Ae,Zo(a,s),Lr=he):Zo(a,s),fs(s),k&8192){if(he=s.memoizedState!==null,(s.stateNode.isHidden=he)&&!Ae&&(s.mode&1)!==0)for(nt=s,Ae=s.child;Ae!==null;){for(Oe=nt=Ae;nt!==null;){switch(Ce=nt,Qe=Ce.child,Ce.tag){case 0:case 11:case 14:case 15:wc(4,Ce,Ce.return);break;case 1:nl(Ce,Ce.return);var ot=Ce.stateNode;if(typeof ot.componentWillUnmount=="function"){k=Ce,p=Ce.return;try{a=k,ot.props=a.memoizedProps,ot.state=a.memoizedState,ot.componentWillUnmount()}catch(it){nr(k,p,it)}}break;case 5:nl(Ce,Ce.return);break;case 22:if(Ce.memoizedState!==null){qv(Oe);continue}}Qe!==null?(Qe.return=Ce,nt=Qe):qv(Oe)}Ae=Ae.sibling}e:for(Ae=null,Oe=s;;){if(Oe.tag===5){if(Ae===null){Ae=Oe;try{b=Oe.stateNode,he?(E=b.style,typeof E.setProperty=="function"?E.setProperty("display","none","important"):E.display="none"):(q=Oe.stateNode,te=Oe.memoizedProps.style,A=te!=null&&te.hasOwnProperty("display")?te.display:null,q.style.display=Rn("display",A))}catch(it){nr(s,s.return,it)}}}else if(Oe.tag===6){if(Ae===null)try{Oe.stateNode.nodeValue=he?"":Oe.memoizedProps}catch(it){nr(s,s.return,it)}}else if((Oe.tag!==22&&Oe.tag!==23||Oe.memoizedState===null||Oe===s)&&Oe.child!==null){Oe.child.return=Oe,Oe=Oe.child;continue}if(Oe===s)break e;for(;Oe.sibling===null;){if(Oe.return===null||Oe.return===s)break e;Ae===Oe&&(Ae=null),Oe=Oe.return}Ae===Oe&&(Ae=null),Oe.sibling.return=Oe.return,Oe=Oe.sibling}}break;case 19:Zo(a,s),fs(s),k&4&&Hv(s);break;case 21:break;default:Zo(a,s),fs(s)}}function fs(s){var a=s.flags;if(a&2){try{e:{for(var p=s.return;p!==null;){if(Fv(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&&(sn(b,""),k.flags&=-33);var E=Bv(s);Yp(s,E,b);break;case 3:case 4:var A=k.stateNode.containerInfo,q=Bv(s);Vp(s,q,A);break;default:throw Error(n(161))}}catch(te){nr(s,s.return,te)}s.flags&=-3}a&4096&&(s.flags&=-4097)}function Z$(s,a,p){nt=s,Kv(s)}function Kv(s,a,p){for(var k=(s.mode&1)!==0;nt!==null;){var b=nt,E=b.child;if(b.tag===22&&k){var A=b.memoizedState!==null||_d;if(!A){var q=b.alternate,te=q!==null&&q.memoizedState!==null||Lr;q=_d;var he=Lr;if(_d=A,(Lr=te)&&!he)for(nt=b;nt!==null;)A=nt,te=A.child,A.tag===22&&A.memoizedState!==null?Gv(b):te!==null?(te.return=A,nt=te):Gv(b);for(;E!==null;)nt=E,Kv(E),E=E.sibling;nt=b,_d=q,Lr=he}Zv(s)}else(b.subtreeFlags&8772)!==0&&E!==null?(E.return=b,nt=E):Zv(s)}}function Zv(s){for(;nt!==null;){var a=nt;if((a.flags&8772)!==0){var p=a.alternate;try{if((a.flags&8772)!==0)switch(a.tag){case 0:case 11:case 15:Lr||Nd(5,a);break;case 1:var k=a.stateNode;if(a.flags&4&&!Lr)if(p===null)k.componentDidMount();else{var b=a.elementType===a.type?p.memoizedProps:Wo(a.type,p.memoizedProps);k.componentDidUpdate(b,p.memoizedState,k.__reactInternalSnapshotBeforeUpdate)}var E=a.updateQueue;E!==null&&qy(a,E,k);break;case 3:var A=a.updateQueue;if(A!==null){if(p=null,a.child!==null)switch(a.child.tag){case 5:p=a.child.stateNode;break;case 1:p=a.child.stateNode}qy(a,A,p)}break;case 5:var q=a.stateNode;if(p===null&&a.flags&4){p=q;var te=a.memoizedProps;switch(a.type){case"button":case"input":case"select":case"textarea":te.autoFocus&&p.focus();break;case"img":te.src&&(p.src=te.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(a.memoizedState===null){var he=a.alternate;if(he!==null){var Ae=he.memoizedState;if(Ae!==null){var Oe=Ae.dehydrated;Oe!==null&&Oi(Oe)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(n(163))}Lr||a.flags&512&&Gp(a)}catch(Ce){nr(a,a.return,Ce)}}if(a===s){nt=null;break}if(p=a.sibling,p!==null){p.return=a.return,nt=p;break}nt=a.return}}function qv(s){for(;nt!==null;){var a=nt;if(a===s){nt=null;break}var p=a.sibling;if(p!==null){p.return=a.return,nt=p;break}nt=a.return}}function Gv(s){for(;nt!==null;){var a=nt;try{switch(a.tag){case 0:case 11:case 15:var p=a.return;try{Nd(4,a)}catch(te){nr(a,p,te)}break;case 1:var k=a.stateNode;if(typeof k.componentDidMount=="function"){var b=a.return;try{k.componentDidMount()}catch(te){nr(a,b,te)}}var E=a.return;try{Gp(a)}catch(te){nr(a,E,te)}break;case 5:var A=a.return;try{Gp(a)}catch(te){nr(a,A,te)}}}catch(te){nr(a,a.return,te)}if(a===s){nt=null;break}var q=a.sibling;if(q!==null){q.return=a.return,nt=q;break}nt=a.return}}var q$=Math.ceil,Td=j.ReactCurrentDispatcher,Xp=j.ReactCurrentOwner,Ro=j.ReactCurrentBatchConfig,hn=0,xr=null,lr=null,Ar=0,wo=0,rl=ti(0),gr=0,yc=null,Qi=0,jd=0,Qp=0,vc=null,no=null,Jp=0,ol=1/0,$s=null,$d=!1,em=null,ai=null,Cd=!1,li=null,Ad=0,bc=0,tm=null,Id=-1,Rd=0;function Zr(){return(hn&6)!==0?Wt():Id!==-1?Id:Id=Wt()}function ci(s){return(s.mode&1)===0?1:(hn&2)!==0&&Ar!==0?Ar&-Ar:C$.transition!==null?(Rd===0&&(Rd=Nt()),Rd):(s=Gt,s!==0||(s=window.event,s=s===void 0?16:Pi(s.type)),s)}function qo(s,a,p,k){if(50<bc)throw bc=0,tm=null,Error(n(185));Wn(s,p,k),((hn&2)===0||s!==xr)&&(s===xr&&((hn&2)===0&&(jd|=p),gr===4&&ui(s,Ar)),ro(s,k),p===1&&hn===0&&(a.mode&1)===0&&(ol=Wt()+500,ad&&ri()))}function ro(s,a){var p=s.callbackNode;tt(s,a);var k=G(s,s===xr?Ar:0);if(k===0)p!==null&&yn(p),s.callbackNode=null,s.callbackPriority=0;else if(a=k&-k,s.callbackPriority!==a){if(p!=null&&yn(p),a===1)s.tag===0?$$(Yv.bind(null,s)):My(Yv.bind(null,s)),_$(function(){(hn&6)===0&&ri()}),p=null;else{switch(Et(k)){case 1:p=dt;break;case 4:p=Bn;break;case 16:p=st;break;case 536870912:p=qe;break;default:p=st}p=o0(p,Vv.bind(null,s))}s.callbackPriority=a,s.callbackNode=p}}function Vv(s,a){if(Id=-1,Rd=0,(hn&6)!==0)throw Error(n(327));var p=s.callbackNode;if(sl()&&s.callbackNode!==p)return null;var k=G(s,s===xr?Ar:0);if(k===0)return null;if((k&30)!==0||(k&s.expiredLanes)!==0||a)a=Od(s,k);else{a=k;var b=hn;hn|=2;var E=Qv();(xr!==s||Ar!==a)&&($s=null,ol=Wt()+500,ea(s,a));do try{Y$();break}catch(q){Xv(s,q)}while(!0);yp(),Td.current=E,hn=b,lr!==null?a=0:(xr=null,Ar=0,a=gr)}if(a!==0){if(a===2&&(b=kt(s),b!==0&&(k=b,a=nm(s,b))),a===1)throw p=yc,ea(s,0),ui(s,k),ro(s,Wt()),p;if(a===6)ui(s,k);else{if(b=s.current.alternate,(k&30)===0&&!G$(b)&&(a=Od(s,k),a===2&&(E=kt(s),E!==0&&(k=E,a=nm(s,E))),a===1))throw p=yc,ea(s,0),ui(s,k),ro(s,Wt()),p;switch(s.finishedWork=b,s.finishedLanes=k,a){case 0:case 1:throw Error(n(345));case 2:ta(s,no,$s);break;case 3:if(ui(s,k),(k&130023424)===k&&(a=Jp+500-Wt(),10<a)){if(G(s,0)!==0)break;if(b=s.suspendedLanes,(b&k)!==k){Zr(),s.pingedLanes|=s.suspendedLanes&b;break}s.timeoutHandle=lp(ta.bind(null,s,no,$s),a);break}ta(s,no,$s);break;case 4:if(ui(s,k),(k&4194240)===k)break;for(a=s.eventTimes,b=-1;0<k;){var A=31-Ft(k);E=1<<A,A=a[A],A>b&&(b=A),k&=~E}if(k=b,k=Wt()-k,k=(120>k?120:480>k?480:1080>k?1080:1920>k?1920:3e3>k?3e3:4320>k?4320:1960*q$(k/1960))-k,10<k){s.timeoutHandle=lp(ta.bind(null,s,no,$s),k);break}ta(s,no,$s);break;case 5:ta(s,no,$s);break;default:throw Error(n(329))}}}return ro(s,Wt()),s.callbackNode===p?Vv.bind(null,s):null}function nm(s,a){var p=vc;return s.current.memoizedState.isDehydrated&&(ea(s,a).flags|=256),s=Od(s,a),s!==2&&(a=no,no=p,a!==null&&rm(a)),s}function rm(s){no===null?no=s:no.push.apply(no,s)}function G$(s){for(var a=s;;){if(a.flags&16384){var p=a.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(!Xr(E(),b))return!1}catch{return!1}}}if(p=a.child,a.subtreeFlags&16384&&p!==null)p.return=a,a=p;else{if(a===s)break;for(;a.sibling===null;){if(a.return===null||a.return===s)return!0;a=a.return}a.sibling.return=a.return,a=a.sibling}}return!0}function ui(s,a){for(a&=~Qp,a&=~jd,s.suspendedLanes|=a,s.pingedLanes&=~a,s=s.expirationTimes;0<a;){var p=31-Ft(a),k=1<<p;s[p]=-1,a&=~k}}function Yv(s){if((hn&6)!==0)throw Error(n(327));sl();var a=G(s,0);if((a&1)===0)return ro(s,Wt()),null;var p=Od(s,a);if(s.tag!==0&&p===2){var k=kt(s);k!==0&&(a=k,p=nm(s,k))}if(p===1)throw p=yc,ea(s,0),ui(s,a),ro(s,Wt()),p;if(p===6)throw Error(n(345));return s.finishedWork=s.current.alternate,s.finishedLanes=a,ta(s,no,$s),ro(s,Wt()),null}function om(s,a){var p=hn;hn|=1;try{return s(a)}finally{hn=p,hn===0&&(ol=Wt()+500,ad&&ri())}}function Ji(s){li!==null&&li.tag===0&&(hn&6)===0&&sl();var a=hn;hn|=1;var p=Ro.transition,k=Gt;try{if(Ro.transition=null,Gt=1,s)return s()}finally{Gt=k,Ro.transition=p,hn=a,(hn&6)===0&&ri()}}function sm(){wo=rl.current,Pn(rl)}function ea(s,a){s.finishedWork=null,s.finishedLanes=0;var p=s.timeoutHandle;if(p!==-1&&(s.timeoutHandle=-1,S$(p)),lr!==null)for(p=lr.return;p!==null;){var k=p;switch(pp(k),k.tag){case 1:k=k.type.childContextTypes,k!=null&&sd();break;case 3:el(),Pn(Jr),Pn(Or),Tp();break;case 5:_p(k);break;case 4:el();break;case 13:Pn(Yn);break;case 19:Pn(Yn);break;case 10:vp(k.type._context);break;case 22:case 23:sm()}p=p.return}if(xr=s,lr=s=di(s.current,null),Ar=wo=a,gr=0,yc=null,Qp=jd=Qi=0,no=vc=null,Vi!==null){for(a=0;a<Vi.length;a++)if(p=Vi[a],k=p.interleaved,k!==null){p.interleaved=null;var b=k.next,E=p.pending;if(E!==null){var A=E.next;E.next=b,k.next=A}p.pending=k}Vi=null}return s}function Xv(s,a){do{var p=lr;try{if(yp(),kd.current=bd,wd){for(var k=Xn.memoizedState;k!==null;){var b=k.queue;b!==null&&(b.pending=null),k=k.next}wd=!1}if(Xi=0,br=mr=Xn=null,hc=!1,pc=0,Xp.current=null,p===null||p.return===null){gr=1,yc=a,lr=null;break}e:{var E=s,A=p.return,q=p,te=a;if(a=Ar,q.flags|=32768,te!==null&&typeof te=="object"&&typeof te.then=="function"){var he=te,Ae=q,Oe=Ae.tag;if((Ae.mode&1)===0&&(Oe===0||Oe===11||Oe===15)){var Ce=Ae.alternate;Ce?(Ae.updateQueue=Ce.updateQueue,Ae.memoizedState=Ce.memoizedState,Ae.lanes=Ce.lanes):(Ae.updateQueue=null,Ae.memoizedState=null)}var Qe=xv(A);if(Qe!==null){Qe.flags&=-257,Ev(Qe,A,q,E,a),Qe.mode&1&&bv(E,he,a),a=Qe,te=he;var ot=a.updateQueue;if(ot===null){var it=new Set;it.add(te),a.updateQueue=it}else ot.add(te);break e}else{if((a&1)===0){bv(E,he,a),im();break e}te=Error(n(426))}}else if(Kn&&q.mode&1){var or=xv(A);if(or!==null){(or.flags&65536)===0&&(or.flags|=256),Ev(or,A,q,E,a),kp(tl(te,q));break e}}E=te=tl(te,q),gr!==4&&(gr=2),vc===null?vc=[E]:vc.push(E),E=A;do{switch(E.tag){case 3:E.flags|=65536,a&=-a,E.lanes|=a;var ue=yv(E,te,a);Zy(E,ue);break e;case 1:q=te;var se=E.type,de=E.stateNode;if((E.flags&128)===0&&(typeof se.getDerivedStateFromError=="function"||de!==null&&typeof de.componentDidCatch=="function"&&(ai===null||!ai.has(de)))){E.flags|=65536,a&=-a,E.lanes|=a;var Fe=vv(E,q,a);Zy(E,Fe);break e}}E=E.return}while(E!==null)}e0(p)}catch(lt){a=lt,lr===p&&p!==null&&(lr=p=p.return);continue}break}while(!0)}function Qv(){var s=Td.current;return Td.current=bd,s===null?bd:s}function im(){(gr===0||gr===3||gr===2)&&(gr=4),xr===null||(Qi&268435455)===0&&(jd&268435455)===0||ui(xr,Ar)}function Od(s,a){var p=hn;hn|=2;var k=Qv();(xr!==s||Ar!==a)&&($s=null,ea(s,a));do try{V$();break}catch(b){Xv(s,b)}while(!0);if(yp(),hn=p,Td.current=k,lr!==null)throw Error(n(261));return xr=null,Ar=0,gr}function V$(){for(;lr!==null;)Jv(lr)}function Y$(){for(;lr!==null&&!Tr();)Jv(lr)}function Jv(s){var a=r0(s.alternate,s,wo);s.memoizedProps=s.pendingProps,a===null?e0(s):lr=a,Xp.current=null}function e0(s){var a=s;do{var p=a.alternate;if(s=a.return,(a.flags&32768)===0){if(p=U$(p,a,wo),p!==null){lr=p;return}}else{if(p=H$(p,a),p!==null){p.flags&=32767,lr=p;return}if(s!==null)s.flags|=32768,s.subtreeFlags=0,s.deletions=null;else{gr=6,lr=null;return}}if(a=a.sibling,a!==null){lr=a;return}lr=a=s}while(a!==null);gr===0&&(gr=5)}function ta(s,a,p){var k=Gt,b=Ro.transition;try{Ro.transition=null,Gt=1,X$(s,a,p,k)}finally{Ro.transition=b,Gt=k}return null}function X$(s,a,p,k){do sl();while(li!==null);if((hn&6)!==0)throw Error(n(327));p=s.finishedWork;var b=s.finishedLanes;if(p===null)return null;if(s.finishedWork=null,s.finishedLanes=0,p===s.current)throw Error(n(177));s.callbackNode=null,s.callbackPriority=0;var E=p.lanes|p.childLanes;if(ar(s,E),s===xr&&(lr=xr=null,Ar=0),(p.subtreeFlags&2064)===0&&(p.flags&2064)===0||Cd||(Cd=!0,o0(st,function(){return sl(),null})),E=(p.flags&15990)!==0,(p.subtreeFlags&15990)!==0||E){E=Ro.transition,Ro.transition=null;var A=Gt;Gt=1;var q=hn;hn|=4,Xp.current=null,K$(s,p),Wv(p,s),rr(ip),Ca=!!sp,ip=sp=null,s.current=p,Z$(p),ir(),hn=q,Gt=A,Ro.transition=E}else s.current=p;if(Cd&&(Cd=!1,li=s,Ad=b),E=s.pendingLanes,E===0&&(ai=null),fn(p.stateNode),ro(s,Wt()),a!==null)for(k=s.onRecoverableError,p=0;p<a.length;p++)b=a[p],k(b.value,{componentStack:b.stack,digest:b.digest});if($d)throw $d=!1,s=em,em=null,s;return(Ad&1)!==0&&s.tag!==0&&sl(),E=s.pendingLanes,(E&1)!==0?s===tm?bc++:(bc=0,tm=s):bc=0,ri(),null}function sl(){if(li!==null){var s=Et(Ad),a=Ro.transition,p=Gt;try{if(Ro.transition=null,Gt=16>s?16:s,li===null)var k=!1;else{if(s=li,li=null,Ad=0,(hn&6)!==0)throw Error(n(331));var b=hn;for(hn|=4,nt=s.current;nt!==null;){var E=nt,A=E.child;if((nt.flags&16)!==0){var q=E.deletions;if(q!==null){for(var te=0;te<q.length;te++){var he=q[te];for(nt=he;nt!==null;){var Ae=nt;switch(Ae.tag){case 0:case 11:case 15:wc(8,Ae,E)}var Oe=Ae.child;if(Oe!==null)Oe.return=Ae,nt=Oe;else for(;nt!==null;){Ae=nt;var Ce=Ae.sibling,Qe=Ae.return;if(zv(Ae),Ae===he){nt=null;break}if(Ce!==null){Ce.return=Qe,nt=Ce;break}nt=Qe}}}var ot=E.alternate;if(ot!==null){var it=ot.child;if(it!==null){ot.child=null;do{var or=it.sibling;it.sibling=null,it=or}while(it!==null)}}nt=E}}if((E.subtreeFlags&2064)!==0&&A!==null)A.return=E,nt=A;else e:for(;nt!==null;){if(E=nt,(E.flags&2048)!==0)switch(E.tag){case 0:case 11:case 15:wc(9,E,E.return)}var ue=E.sibling;if(ue!==null){ue.return=E.return,nt=ue;break e}nt=E.return}}var se=s.current;for(nt=se;nt!==null;){A=nt;var de=A.child;if((A.subtreeFlags&2064)!==0&&de!==null)de.return=A,nt=de;else e:for(A=se;nt!==null;){if(q=nt,(q.flags&2048)!==0)try{switch(q.tag){case 0:case 11:case 15:Nd(9,q)}}catch(lt){nr(q,q.return,lt)}if(q===A){nt=null;break e}var Fe=q.sibling;if(Fe!==null){Fe.return=q.return,nt=Fe;break e}nt=q.return}}if(hn=b,ri(),at&&typeof at.onPostCommitFiberRoot=="function")try{at.onPostCommitFiberRoot(xt,s)}catch{}k=!0}return k}finally{Gt=p,Ro.transition=a}}return!1}function t0(s,a,p){a=tl(p,a),a=yv(s,a,1),s=si(s,a,1),a=Zr(),s!==null&&(Wn(s,1,a),ro(s,a))}function nr(s,a,p){if(s.tag===3)t0(s,s,p);else for(;a!==null;){if(a.tag===3){t0(a,s,p);break}else if(a.tag===1){var k=a.stateNode;if(typeof a.type.getDerivedStateFromError=="function"||typeof k.componentDidCatch=="function"&&(ai===null||!ai.has(k))){s=tl(p,s),s=vv(a,s,1),a=si(a,s,1),s=Zr(),a!==null&&(Wn(a,1,s),ro(a,s));break}}a=a.return}}function Q$(s,a,p){var k=s.pingCache;k!==null&&k.delete(a),a=Zr(),s.pingedLanes|=s.suspendedLanes&p,xr===s&&(Ar&p)===p&&(gr===4||gr===3&&(Ar&130023424)===Ar&&500>Wt()-Jp?ea(s,0):Qp|=p),ro(s,a)}function n0(s,a){a===0&&((s.mode&1)===0?a=1:(a=yr,yr<<=1,(yr&130023424)===0&&(yr=4194304)));var p=Zr();s=Ns(s,a),s!==null&&(Wn(s,a,p),ro(s,p))}function J$(s){var a=s.memoizedState,p=0;a!==null&&(p=a.retryLane),n0(s,p)}function eC(s,a){var p=0;switch(s.tag){case 13:var k=s.stateNode,b=s.memoizedState;b!==null&&(p=b.retryLane);break;case 19:k=s.stateNode;break;default:throw Error(n(314))}k!==null&&k.delete(a),n0(s,p)}var r0;r0=function(s,a,p){if(s!==null)if(s.memoizedProps!==a.pendingProps||Jr.current)to=!0;else{if((s.lanes&p)===0&&(a.flags&128)===0)return to=!1,B$(s,a,p);to=(s.flags&131072)!==0}else to=!1,Kn&&(a.flags&1048576)!==0&&Py(a,cd,a.index);switch(a.lanes=0,a.tag){case 2:var k=a.type;Sd(s,a),s=a.pendingProps;var b=qa(a,Or.current);Ja(a,p),b=Cp(null,a,k,s,b,p);var E=Ap();return a.flags|=1,typeof b=="object"&&b!==null&&typeof b.render=="function"&&b.$$typeof===void 0?(a.tag=1,a.memoizedState=null,a.updateQueue=null,eo(k)?(E=!0,id(a)):E=!1,a.memoizedState=b.state!==null&&b.state!==void 0?b.state:null,Ep(a),b.updater=xd,a.stateNode=b,b._reactInternals=a,Lp(a,k,s,p),a=Bp(null,a,k,!0,E,p)):(a.tag=0,Kn&&E&&hp(a),Kr(null,a,b,p),a=a.child),a;case 16:k=a.elementType;e:{switch(Sd(s,a),s=a.pendingProps,b=k._init,k=b(k._payload),a.type=k,b=a.tag=nC(k),s=Wo(k,s),b){case 0:a=Fp(null,a,k,s,p);break e;case 1:a=$v(null,a,k,s,p);break e;case 11:a=Sv(null,a,k,s,p);break e;case 14:a=_v(null,a,k,Wo(k.type,s),p);break e}throw Error(n(306,k,""))}return a;case 0:return k=a.type,b=a.pendingProps,b=a.elementType===k?b:Wo(k,b),Fp(s,a,k,b,p);case 1:return k=a.type,b=a.pendingProps,b=a.elementType===k?b:Wo(k,b),$v(s,a,k,b,p);case 3:e:{if(Cv(a),s===null)throw Error(n(387));k=a.pendingProps,E=a.memoizedState,b=E.element,Ky(s,a),md(a,k,null,p);var A=a.memoizedState;if(k=A.element,E.isDehydrated)if(E={element:k,isDehydrated:!1,cache:A.cache,pendingSuspenseBoundaries:A.pendingSuspenseBoundaries,transitions:A.transitions},a.updateQueue.baseState=E,a.memoizedState=E,a.flags&256){b=tl(Error(n(423)),a),a=Av(s,a,k,p,b);break e}else if(k!==b){b=tl(Error(n(424)),a),a=Av(s,a,k,p,b);break e}else for(ko=ei(a.stateNode.containerInfo.firstChild),go=a,Kn=!0,Ho=null,p=Hy(a,null,k,p),a.child=p;p;)p.flags=p.flags&-3|4096,p=p.sibling;else{if(Ya(),k===b){a=js(s,a,p);break e}Kr(s,a,k,p)}a=a.child}return a;case 5:return Gy(a),s===null&&gp(a),k=a.type,b=a.pendingProps,E=s!==null?s.memoizedProps:null,A=b.children,ap(k,b)?A=null:E!==null&&ap(k,E)&&(a.flags|=32),jv(s,a),Kr(s,a,A,p),a.child;case 6:return s===null&&gp(a),null;case 13:return Iv(s,a,p);case 4:return Sp(a,a.stateNode.containerInfo),k=a.pendingProps,s===null?a.child=Xa(a,null,k,p):Kr(s,a,k,p),a.child;case 11:return k=a.type,b=a.pendingProps,b=a.elementType===k?b:Wo(k,b),Sv(s,a,k,b,p);case 7:return Kr(s,a,a.pendingProps,p),a.child;case 8:return Kr(s,a,a.pendingProps.children,p),a.child;case 12:return Kr(s,a,a.pendingProps.children,p),a.child;case 10:e:{if(k=a.type._context,b=a.pendingProps,E=a.memoizedProps,A=b.value,In(fd,k._currentValue),k._currentValue=A,E!==null)if(Xr(E.value,A)){if(E.children===b.children&&!Jr.current){a=js(s,a,p);break e}}else for(E=a.child,E!==null&&(E.return=a);E!==null;){var q=E.dependencies;if(q!==null){A=E.child;for(var te=q.firstContext;te!==null;){if(te.context===k){if(E.tag===1){te=Ts(-1,p&-p),te.tag=2;var he=E.updateQueue;if(he!==null){he=he.shared;var Ae=he.pending;Ae===null?te.next=te:(te.next=Ae.next,Ae.next=te),he.pending=te}}E.lanes|=p,te=E.alternate,te!==null&&(te.lanes|=p),bp(E.return,p,a),q.lanes|=p;break}te=te.next}}else if(E.tag===10)A=E.type===a.type?null:E.child;else if(E.tag===18){if(A=E.return,A===null)throw Error(n(341));A.lanes|=p,q=A.alternate,q!==null&&(q.lanes|=p),bp(A,p,a),A=E.sibling}else A=E.child;if(A!==null)A.return=E;else for(A=E;A!==null;){if(A===a){A=null;break}if(E=A.sibling,E!==null){E.return=A.return,A=E;break}A=A.return}E=A}Kr(s,a,b.children,p),a=a.child}return a;case 9:return b=a.type,k=a.pendingProps.children,Ja(a,p),b=Ao(b),k=k(b),a.flags|=1,Kr(s,a,k,p),a.child;case 14:return k=a.type,b=Wo(k,a.pendingProps),b=Wo(k.type,b),_v(s,a,k,b,p);case 15:return Nv(s,a,a.type,a.pendingProps,p);case 17:return k=a.type,b=a.pendingProps,b=a.elementType===k?b:Wo(k,b),Sd(s,a),a.tag=1,eo(k)?(s=!0,id(a)):s=!1,Ja(a,p),kv(a,k,b),Lp(a,k,b,p),Bp(null,a,k,!0,s,p);case 19:return Ov(s,a,p);case 22:return Tv(s,a,p)}throw Error(n(156,a.tag))};function o0(s,a){return pt(s,a)}function tC(s,a,p,k){this.tag=s,this.key=p,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=a,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 Oo(s,a,p,k){return new tC(s,a,p,k)}function am(s){return s=s.prototype,!(!s||!s.isReactComponent)}function nC(s){if(typeof s=="function")return am(s)?1:0;if(s!=null){if(s=s.$$typeof,s===B)return 11;if(s===Y)return 14}return 2}function di(s,a){var p=s.alternate;return p===null?(p=Oo(s.tag,a,s.key,s.mode),p.elementType=s.elementType,p.type=s.type,p.stateNode=s.stateNode,p.alternate=s,s.alternate=p):(p.pendingProps=a,p.type=s.type,p.flags=0,p.subtreeFlags=0,p.deletions=null),p.flags=s.flags&14680064,p.childLanes=s.childLanes,p.lanes=s.lanes,p.child=s.child,p.memoizedProps=s.memoizedProps,p.memoizedState=s.memoizedState,p.updateQueue=s.updateQueue,a=s.dependencies,p.dependencies=a===null?null:{lanes:a.lanes,firstContext:a.firstContext},p.sibling=s.sibling,p.index=s.index,p.ref=s.ref,p}function Md(s,a,p,k,b,E){var A=2;if(k=s,typeof s=="function")am(s)&&(A=1);else if(typeof s=="string")A=5;else e:switch(s){case I:return na(p.children,b,E,a);case P:A=8,b|=8;break;case R:return s=Oo(12,p,a,b|2),s.elementType=R,s.lanes=E,s;case X:return s=Oo(13,p,a,b),s.elementType=X,s.lanes=E,s;case ae:return s=Oo(19,p,a,b),s.elementType=ae,s.lanes=E,s;case C:return Pd(p,b,E,a);default:if(typeof s=="object"&&s!==null)switch(s.$$typeof){case U:A=10;break e;case F:A=9;break e;case B:A=11;break e;case Y:A=14;break e;case ne:A=16,k=null;break e}throw Error(n(130,s==null?s:typeof s,""))}return a=Oo(A,p,a,b),a.elementType=s,a.type=k,a.lanes=E,a}function na(s,a,p,k){return s=Oo(7,s,k,a),s.lanes=p,s}function Pd(s,a,p,k){return s=Oo(22,s,k,a),s.elementType=C,s.lanes=p,s.stateNode={isHidden:!1},s}function lm(s,a,p){return s=Oo(6,s,null,a),s.lanes=p,s}function cm(s,a,p){return a=Oo(4,s.children!==null?s.children:[],s.key,a),a.lanes=p,a.stateNode={containerInfo:s.containerInfo,pendingChildren:null,implementation:s.implementation},a}function rC(s,a,p,k,b){this.tag=a,this.containerInfo=s,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=vn(0),this.expirationTimes=vn(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=vn(0),this.identifierPrefix=k,this.onRecoverableError=b,this.mutableSourceEagerHydrationData=null}function um(s,a,p,k,b,E,A,q,te){return s=new rC(s,a,p,q,te),a===1?(a=1,E===!0&&(a|=8)):a=0,E=Oo(3,null,null,a),s.current=E,E.stateNode=s,E.memoizedState={element:k,isDehydrated:p,cache:null,transitions:null,pendingSuspenseBoundaries:null},Ep(E),s}function oC(s,a,p){var k=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:O,key:k==null?null:""+k,children:s,containerInfo:a,implementation:p}}function s0(s){if(!s)return ni;s=s._reactInternals;e:{if(Fn(s)!==s||s.tag!==1)throw Error(n(170));var a=s;do{switch(a.tag){case 3:a=a.stateNode.context;break e;case 1:if(eo(a.type)){a=a.stateNode.__reactInternalMemoizedMergedChildContext;break e}}a=a.return}while(a!==null);throw Error(n(171))}if(s.tag===1){var p=s.type;if(eo(p))return Ry(s,p,a)}return a}function i0(s,a,p,k,b,E,A,q,te){return s=um(p,k,!0,s,b,E,A,q,te),s.context=s0(null),p=s.current,k=Zr(),b=ci(p),E=Ts(k,b),E.callback=a??null,si(p,E,b),s.current.lanes=b,Wn(s,b,k),ro(s,k),s}function Ld(s,a,p,k){var b=a.current,E=Zr(),A=ci(b);return p=s0(p),a.context===null?a.context=p:a.pendingContext=p,a=Ts(E,A),a.payload={element:s},k=k===void 0?null:k,k!==null&&(a.callback=k),s=si(b,a,A),s!==null&&(qo(s,b,A,E),pd(s,b,A)),A}function Dd(s){if(s=s.current,!s.child)return null;switch(s.child.tag){case 5:return s.child.stateNode;default:return s.child.stateNode}}function a0(s,a){if(s=s.memoizedState,s!==null&&s.dehydrated!==null){var p=s.retryLane;s.retryLane=p!==0&&p<a?p:a}}function dm(s,a){a0(s,a),(s=s.alternate)&&a0(s,a)}function sC(){return null}var l0=typeof reportError=="function"?reportError:function(s){console.error(s)};function fm(s){this._internalRoot=s}zd.prototype.render=fm.prototype.render=function(s){var a=this._internalRoot;if(a===null)throw Error(n(409));Ld(s,a,null,null)},zd.prototype.unmount=fm.prototype.unmount=function(){var s=this._internalRoot;if(s!==null){this._internalRoot=null;var a=s.containerInfo;Ji(function(){Ld(null,s,null,null)}),a[xs]=null}};function zd(s){this._internalRoot=s}zd.prototype.unstable_scheduleHydration=function(s){if(s){var a=Wr();s={blockedOn:null,target:s,priority:a};for(var p=0;p<Ct.length&&a!==0&&a<Ct[p].priority;p++);Ct.splice(p,0,s),p===0&&bn(s)}};function hm(s){return!(!s||s.nodeType!==1&&s.nodeType!==9&&s.nodeType!==11)}function Fd(s){return!(!s||s.nodeType!==1&&s.nodeType!==9&&s.nodeType!==11&&(s.nodeType!==8||s.nodeValue!==" react-mount-point-unstable "))}function c0(){}function iC(s,a,p,k,b){if(b){if(typeof k=="function"){var E=k;k=function(){var he=Dd(A);E.call(he)}}var A=i0(a,k,s,0,null,!1,!1,"",c0);return s._reactRootContainer=A,s[xs]=A.current,sc(s.nodeType===8?s.parentNode:s),Ji(),A}for(;b=s.lastChild;)s.removeChild(b);if(typeof k=="function"){var q=k;k=function(){var he=Dd(te);q.call(he)}}var te=um(s,0,!1,null,null,!1,!1,"",c0);return s._reactRootContainer=te,s[xs]=te.current,sc(s.nodeType===8?s.parentNode:s),Ji(function(){Ld(a,te,p,k)}),te}function Bd(s,a,p,k,b){var E=p._reactRootContainer;if(E){var A=E;if(typeof b=="function"){var q=b;b=function(){var te=Dd(A);q.call(te)}}Ld(a,A,s,b)}else A=iC(p,a,s,b,k);return Dd(A)}To=function(s){switch(s.tag){case 3:var a=s.stateNode;if(a.current.memoizedState.isDehydrated){var p=Hn(a.pendingLanes);p!==0&&(jr(a,p|1),ro(a,Wt()),(hn&6)===0&&(ol=Wt()+500,ri()))}break;case 13:Ji(function(){var k=Ns(s,1);if(k!==null){var b=Zr();qo(k,s,1,b)}}),dm(s,1)}},Nn=function(s){if(s.tag===13){var a=Ns(s,134217728);if(a!==null){var p=Zr();qo(a,s,134217728,p)}dm(s,134217728)}},Qt=function(s){if(s.tag===13){var a=ci(s),p=Ns(s,a);if(p!==null){var k=Zr();qo(p,s,a,k)}dm(s,a)}},Wr=function(){return Gt},Rr=function(s,a){var p=Gt;try{return Gt=s,a()}finally{Gt=p}},Bt=function(s,a,p){switch(a){case"input":if(We(s,p),a=p.name,p.type==="radio"&&a!=null){for(p=s;p.parentNode;)p=p.parentNode;for(p=p.querySelectorAll("input[name="+JSON.stringify(""+a)+'][type="radio"]'),a=0;a<p.length;a++){var k=p[a];if(k!==s&&k.form===s.form){var b=od(k);if(!b)throw Error(n(90));ce(k),We(k,b)}}}break;case"textarea":It(s,p);break;case"select":a=p.value,a!=null&&Be(s,!!p.multiple,a,!1)}},Ne=om,Ze=Ji;var aC={usingClientEntryPoint:!1,Events:[lc,Ka,od,M,re,om]},xc={findFiberByHostInstance:Ki,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},lC={bundleType:xc.bundleType,version:xc.version,rendererPackageName:xc.rendererPackageName,rendererConfig:xc.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:j.ReactCurrentDispatcher,findHostInstanceByFiber:function(s){return s=Ye(s),s===null?null:s.stateNode},findFiberByHostInstance:xc.findFiberByHostInstance||sC,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 Ud=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Ud.isDisabled&&Ud.supportsFiber)try{xt=Ud.inject(lC),at=Ud}catch{}}return oo.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=aC,oo.createPortal=function(s,a){var p=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!hm(a))throw Error(n(200));return oC(s,a,null,p)},oo.createRoot=function(s,a){if(!hm(s))throw Error(n(299));var p=!1,k="",b=l0;return a!=null&&(a.unstable_strictMode===!0&&(p=!0),a.identifierPrefix!==void 0&&(k=a.identifierPrefix),a.onRecoverableError!==void 0&&(b=a.onRecoverableError)),a=um(s,1,!1,null,null,p,!1,k,b),s[xs]=a.current,sc(s.nodeType===8?s.parentNode:s),new fm(a)},oo.findDOMNode=function(s){if(s==null)return null;if(s.nodeType===1)return s;var a=s._reactInternals;if(a===void 0)throw typeof s.render=="function"?Error(n(188)):(s=Object.keys(s).join(","),Error(n(268,s)));return s=Ye(a),s=s===null?null:s.stateNode,s},oo.flushSync=function(s){return Ji(s)},oo.hydrate=function(s,a,p){if(!Fd(a))throw Error(n(200));return Bd(null,s,a,!0,p)},oo.hydrateRoot=function(s,a,p){if(!hm(s))throw Error(n(405));var k=p!=null&&p.hydratedSources||null,b=!1,E="",A=l0;if(p!=null&&(p.unstable_strictMode===!0&&(b=!0),p.identifierPrefix!==void 0&&(E=p.identifierPrefix),p.onRecoverableError!==void 0&&(A=p.onRecoverableError)),a=i0(a,null,s,1,p??null,b,!1,E,A),s[xs]=a.current,sc(s),k)for(s=0;s<k.length;s++)p=k[s],b=p._getVersion,b=b(p._source),a.mutableSourceEagerHydrationData==null?a.mutableSourceEagerHydrationData=[p,b]:a.mutableSourceEagerHydrationData.push(p,b);return new zd(a)},oo.render=function(s,a,p){if(!Fd(a))throw Error(n(200));return Bd(null,s,a,!1,p)},oo.unmountComponentAtNode=function(s){if(!Fd(s))throw Error(n(40));return s._reactRootContainer?(Ji(function(){Bd(null,null,s,!1,function(){s._reactRootContainer=null,s[xs]=null})}),!0):!1},oo.unstable_batchedUpdates=om,oo.unstable_renderSubtreeIntoContainer=function(s,a,p,k){if(!Fd(p))throw Error(n(200));if(s==null||s._reactInternals===void 0)throw Error(n(38));return Bd(s,a,p,!1,k)},oo.version="18.3.1-next-f1338f8080-20240426",oo}var k0;function K1(){if(k0)return gm.exports;k0=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(),gm.exports=wC(),gm.exports}var Z1=K1(),Hd={},w0;function yC(){if(w0)return Hd;w0=1;var e=K1();return Hd.createRoot=e.createRoot,Hd.hydrateRoot=e.hydrateRoot,Hd}var vC=yC();const _i="shell",q1="check",Sf="ToolSearch",vk="AskUserQuestion";function Wd(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 bC=new Set(["edit","delete","move","execute"]),xC=new Set(["Edit","Write","MultiEdit","NotebookEdit","Bash"]);function G1(e){return e.kind?bC.has(e.kind):xC.has(e.name)}const EC=["read","edit","delete","move","search","execute","fetch"];function bk(e){return EC.includes(e??"")}function V1(e,t){return(bk(e.kind)||e.name===vk||e.name===Sf)&&rh(t)}function rh(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 gu=[{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"}],_f="auto";function SC(e){return e.branch.startsWith("toyon/")}const Po="shell",Rs="login";function _C(e,t){return`${e}/${t}`}function NC(e,t,n,r=0){var i;let o=e;for(let l=r;l>0;l--){let c=o.length-1;for(;c>=0&&((i=o[c])==null?void 0:i.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 Fo=e=>e==="working"||e==="waiting",TC=["use","always","off"];function Y1(e){return e.find(t=>t.id==="default")}function jC(e,t){const n=Y1(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 Sn(e){return e.worktree!==void 0}function wa(e){return e.kind==="main"}function ku(e){return e.kind==="spare"}function _r(e){return ku(e)||wa(e)}function xk(e){return e.kind==="worktree"}function X1(e){return e.kind==="worktree"&&SC(e)}function ca(e){var t;return e.kind==="worktree"&&((t=e.from)==null?void 0:t.kind)!=="pr"}function hf(e){return e.kind==="worktree"}function oh(e){return!!e.branch&&!e.locked&&!(e.worktree&&_r(e.worktree))}const ya=e=>{var t;return e.promptedAt??((t=e.lastTurn)==null?void 0:t.at)??e.createdAt},y0=e=>_r(e)?0:1;function $C(e){return[...e].sort((t,n)=>y0(t.worktree)-y0(n.worktree)||ya(n.worktree)-ya(t.worktree))}function v0(e,t){const n=new Map;for(const r of e)n.set(r.id,r.promptedAt??0);for(const r of t){if(!Sn(r)||r.worktree.kind==="spare")continue;const o=r.worktree.repoId;n.set(o,Math.max(n.get(o)??0,ya(r.worktree)))}return[...e].sort((r,o)=>(n.get(o.id)??0)-(n.get(r.id)??0))}const b0="not opened in ";function CC(e){const t=e.lastIndexOf(b0);return t<0?{what:e}:{what:e.slice(0,t).replace(/,\s*$/,""),idle:e.slice(t+b0.length)}}const Q1={image:6,paste:4,file:8,pick:8},AC={image:"image",paste:"paste",file:"file",pick:"element"},IC={image:"Image",paste:"Pasted text"},J1=(e,t)=>`${IC[e]} ${t}`,Ek=e=>`at most ${Q1[e]} ${AC[e]}s per message`,RC=(e,t)=>e.filter(n=>n.kind===t).length,OC=(e,t)=>Math.max(0,Q1[t]-RC(e,t));function sg(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 Sk(e,t){const n={...t};return e.map(r=>[r,n[r.kind]++])}function Fc(e,t){const n={...e};for(const r of t)n[r.kind]++;return n}function _k(e){return e>=1024*1024?`${(e/1024/1024).toFixed(1)} MB`:`${Math.max(1,Math.round(e/1024))} KB`}const bl=e=>`card:${e}`,pf=[{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-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:"ArrowLeft",textKeeps:!0},{id:"forward",key:"ArrowRight",textKeeps:!0},{id:"close",key:"w"}],MC=new Set(["zen","close","back","forward"]);function eE(e,{guest:t=!1}={}){var r,o;if(e.altKey){if(e.metaKey||e.ctrlKey)return null;const i=pf.find(l=>l.alt&&!!l.shift===e.shiftKey&&(l.key===e.key||l.key.length===1&&e.code===`Key${l.key.toUpperCase()}`));return i&&i.id!=="worktree"?{id:i.id}:null}if(!e.metaKey&&!e.ctrlKey){if(e.shiftKey||t)return null;const i=pf.find(l=>l.bareAlias===e.key);return i&&i.id!=="worktree"?{id:i.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 i of pf){if(i.id==="worktree")continue;const l=i.ctrlAlias;if(l&&e.ctrlKey&&l.key===n&&!!l.shift===e.shiftKey&&!(t&&l.hostOnly))return{id:i.id};if(e.metaKey&&e.shiftKey&&((r=i.cmdShiftAlias)!=null&&r.includes(n)))return{id:i.id};if(!i.alt&&!(e.ctrlKey&&!i.ctrl||!!i.shift!==e.shiftKey)&&(i.key===n||(o=i.aliases)!=null&&o.includes(n)))return{id:i.id}}return null}function PC(e){return e.altKey||e.key.toLowerCase()!=="s"?!1:!!e.ctrlKey!==e.metaKey}function tE(e){const t=pf.find(n=>n.id===e);if(!t)throw new Error(`unknown chord ${e}`);return t}function LC(e,t){return e===t-1?"⌘9":e<8?`⌘${e+1}`:void 0}function DC(e,t){return t===0?null:e===9?t-1:e-1<t?e-1:null}function zC(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 FC(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 BC(e,t){const n=tE(e);return!!n.textKeeps&&zC(t)&&!(n.emptyGives&&FC(t))}const UC=["Find","Preview","Panels","Worktrees"],Bc={"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-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"}},HC={ArrowUp:"↑",ArrowDown:"↓",ArrowLeft:"←",ArrowRight:"→",Backspace:"⌫",Tab:"Tab"};function WC(e,t={}){var c;const n=tE(e),r=Bc[e],o=r.advertise&&t[r.advertise.when]?r.advertise.key:n.key;if(o===n.bareAlias)return o;const i=o==="1-9"?"1-9":HC[o]??o.toUpperCase(),l=o!==n.key&&o===((c=n.ctrlAlias)==null?void 0:c.key)?n.ctrlAlias:void 0;return l?`⌃${l.shift?"⇧":""}${i}`:`${n.alt?"⌥":n.ctrl?"⌃":"⌘"}${n.shift?"⇧":""}${i}`}function KC(e){return Object.keys(Bc).filter(t=>Bc[t].section===e&&!Bc[t].hidden)}const x0={m:6e4,h:60*6e4};function ZC(e){const[t,n]=qC(e);return`${t}${n.charAt(0)}`}function qC(e){const t=e/x0.h;if(t>=1&&Number.isInteger(t))return[t,"hour"];const n=e/x0.m;return n>=1&&Number.isInteger(n)?[n,"minute"]:n>=60?[Math.round(n),"minute"]:[Math.max(1,Math.round(e/1e3)),"second"]}const qc={folder:{shared:".toyon/settings.json",local:".toyon/settings.local.json"},root:{shared:"toyon.json",local:"toyon.local.json"}};function nE(e){return typeof e=="string"?e:e.cmd}function GC(e){return typeof e!="string"&&e.from==="trunk"}function VC(e){return[...e.setup??[],...e.teardown??[],...Object.values(e.run).map(nE),...Object.values(e.profiles??{}).flatMap(n=>Object.values(n.env??{}))].some(n=>n.includes("TOYON_WORKTREE"))}function YC(e){return e===qc.folder.local||e===qc.root.local}function XC(e){return YC(e)?"local":"shared"}function QC(e,t){return(Object.values(qc).find(r=>r.shared===e||r.local===e)??qc.folder)[t]}const JC=e=>`https://${e}/`;function eA(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 nA(n.origin)?n.origin:null}function tA(e){return e.toLowerCase().endsWith(".fly.dev")}function nA(e){let t;try{t=new URL(e)}catch{return!1}return t.origin!==e?!1:t.protocol==="https:"||t.protocol==="http:"&&Nk(t.hostname)}const rA="toyon_grant";function Nk(e){return e==="127.0.0.1"||e==="::1"||e==="[::1]"||e==="localhost"||e.endsWith(".localhost")}function oA(e,t,n){return e.replace("{id}",t).replace("{port}",String(n))}const sA=4401,iA=25e4;function aA(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(i=>({mark:" ",value:i}));return o.push(...lA(e.slice(n,e.length-r),t.slice(n,t.length-r))),o.push(...e.slice(e.length-r).map(i=>({mark:" ",value:i}))),o}function lA(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)>iA)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 i=0,l=0;for(;i<e.length&&l<t.length;)e[i]===t[l]?(o.push({mark:" ",value:e[i]}),i++,l++):(r[(i+1)*n+l]??0)>=(r[i*n+l+1]??0)?(o.push({mark:"-",value:e[i]}),i++):(o.push({mark:"+",value:t[l]}),l++);for(;i<e.length;)o.push({mark:"-",value:e[i++]});for(;l<t.length;)o.push({mark:"+",value:t[l++]});return o}const cA=/[\p{L}\p{N}_$]+|\s+|[^\s\p{L}\p{N}_$]/gu;function E0(e){return e.match(cA)??[]}const uA=.4;function dA(e,t){if(e===t)return null;const n=aA(E0(e),E0(t));let r=0;for(const o of n)o.mark===" "&&(r+=o.value.length);return r<uA*Math.max(e.length,t.length)?null:{before:S0(n,"-"),after:S0(n,"+")}}function S0(e,t){const n=[];for(const r of e){if(r.mark!==" "&&r.mark!==t)continue;const o=r.mark===t,i=n[n.length-1];i&&i.changed===o?i.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 rE(n)}function _0(e){const t=[[]];for(const n of e){const r=n.text.split(`
42
- `);for(const[o,i]of r.entries())o>0&&t.push([]),i&&t[t.length-1].push({text:i,changed:n.changed})}return t.map(rE)}function rE(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 fA=[{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"}],hA=[{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"}],pA=[{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)"}],ig="merge",ag="merge";function bi(e){var n,r,o;const t=((n=e.land)==null?void 0:n.route)??ig;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 sh(e){return e.base??e.defaultBranch}function mA(e){return e.base!==void 0&&e.base!==e.defaultBranch}function gA(e){return!!e.pr&&(e.lands??[]).some(t=>{var n;return t.pr===((n=e.pr)==null?void 0:n.number)})}function kA(e){return{land:"a land",commit:"a commit","sync-main":"a sync","pull-main":"a pull"}[e]}function ih(e){return gA(e)&&!e.landed?void 0:e.pr}function Tk(e,t){const n=ih(t);return e.land==="pr"&&(!n||n.state==="closed")?"create pr":"land"}function Nf(e,t="main"){const n={merge:"merge into",squash:"squash onto",rebase:"rebase onto"}[e.merge??ag];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 oE(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 N0(e,t="|"){return e.map(n=>aE(n)).join(t)}function lg(e,t){return typeof t=="bigint"?t.toString():t}function ah(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function wA(e){return e==null}function jk(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function yA(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 uo(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function $i(...e){const t={};for(const n of e){const r=Object.getOwnPropertyDescriptors(n);Object.assign(t,r)}return Object.defineProperties({},t)}function vA(e){return JSON.stringify(e)}function bA(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const sE="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Gc(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const xA=ah(()=>{var e;if(ns.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 Vc(e){if(Gc(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!(Gc(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function iE(e){return Vc(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}const EA=new Set(["string","number","symbol"]);function jl(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Ci(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 ut(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 aE(e){return typeof e=="bigint"?e.toString()+"n":typeof e=="string"?`"${e}"`:`${e}`}function SA(e){return Object.keys(e).filter(t=>e[t]._zod.optin!==void 0&&e[t]._zod.optout==="optional")}const _A={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 NA(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 i=$i(e._zod.def,{get shape(){const l={};for(const c of Reflect.ownKeys(t)){if(!Object.prototype.hasOwnProperty.call(n.shape,c))throw new Error(`Unrecognized key: "${String(c)}"`);t[c]&&uo(l,c,n.shape[c])}return uo(this,"shape",l),l},checks:[]});return Ci(e,i)}function TA(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 i=$i(e._zod.def,{get shape(){const l={...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 l[c]}return uo(this,"shape",l),l},checks:[]});return Ci(e,i)}function jA(e,t){if(!Vc(t))throw new Error("Invalid input to extend: expected a plain object");const n=e._zod.def.checks;if(n&&n.length>0){const i=e._zod.def.shape;for(const l of Reflect.ownKeys(t))if(Object.getOwnPropertyDescriptor(i,l)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}const o=$i(e._zod.def,{get shape(){const i={...e._zod.def.shape,...t};return uo(this,"shape",i),i}});return Ci(e,o)}function $A(e,t){if(!Vc(t))throw new Error("Invalid input to safeExtend: expected a plain object");const n=$i(e._zod.def,{get shape(){const r={...e._zod.def.shape,...t};return uo(this,"shape",r),r}});return Ci(e,n)}function CA(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=$i(e._zod.def,{get shape(){const i={...e._zod.def.shape,...t._zod.def.shape};return uo(this,"shape",i),i},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return Ci(e,n)}function T0(e,t,n,r="partial"){const i=t._zod.def.checks;if(i&&i.length>0)throw new Error(`.${r}() cannot be used on object schemas containing refinements`);const c=$i(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 uo(this,"shape",h),h},checks:[]});return Ci(t,c)}function AA(e,t,n){const r=$i(t._zod.def,{get shape(){const o=t._zod.def.shape,i={...o};if(n)for(const l of Reflect.ownKeys(n)){if(!Object.prototype.hasOwnProperty.call(i,l))throw new Error(`Unrecognized key: "${String(l)}"`);n[l]&&(i[l]=new e({type:"nonoptional",innerType:o[l]}))}else for(const l of Reflect.ownKeys(o))i[l]=new e({type:"nonoptional",innerType:o[l]});return uo(this,"shape",i),i}});return Ci(t,r)}function hl(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 IA(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 lh(e,t){return t.map(n=>{var r;return(r=n).path??(r.path=[]),n.path.unshift(e),n})}function Sc(e){return typeof e=="string"?e:e==null?void 0:e.message}function j0(e,t,n){var r;for(let o=t;o<e.length;o++)(r=e[o]).schema??(r.schema=n)}function zl(e,t,n){var g,w,y,v,_,x,T,N,j,$;var r;const o=(w=(g=e.inst)==null?void 0:g._zod)==null?void 0:w.traits;o!=null&&o.has("$ZodType")&&(o.has("$ZodCheck")?(r=e).schema??(r.schema=e.inst):e.schema=e.inst);const i=e.schema!==e.inst?(v=(y=e.schema)==null?void 0:y._zod.def)==null?void 0:v.error:void 0,l=e.message?e.message:Sc((T=(x=(_=e.inst)==null?void 0:_._zod.def)==null?void 0:x.error)==null?void 0:T.call(x,e))??Sc(i==null?void 0:i(e))??Sc((N=t==null?void 0:t.error)==null?void 0:N.call(t,e))??Sc((j=n.customError)==null?void 0:j.call(n,e))??Sc(($=n.localeError)==null?void 0:$.call(n,e))??"Invalid input",{inst:c,schema:u,continue:h,input:f,...m}=e;return m.path??(m.path=[]),m.message=l,t!=null&&t.reportInput&&(m.input=f),m}const RA=/[\uD800-\uDBFF]/;function $k(e){const t=e.length;if(!RA.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 Ck(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function OA(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 Yc(...e){const[t,n,r]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:r}:{...t}}function MA(e,t){for(const n in t){const r=Object.getOwnPropertyDescriptor(t,n);r.get?Object.defineProperty(e,n,{...r,enumerable:!1}):PA(e,n,r.value)}}function $l(e,t,n,r=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:r,value:n}),n}function lE(e,t,n){return $l(e,t,n,!1)}function PA(e,t,n){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?n:$l(this,t,n.bind(this))},set(r){$l(this,t,r)}})}function LA(e,t){const n=Object.getPrototypeOf(e);return t in n?void 0:n}let ym,ki=!1;const DA={configurable:!0,get(){ki=!0}};function _n(e,t,n){const r=Object.getPrototypeOf(e._zod);if(t in r&&ym!==e._zod){ym=void 0;return}ym=e._zod,Object.defineProperty(r,t,{configurable:!0,get(){Object.defineProperty(this,t,DA);const o=ki;ki=!1;try{const i=n(this);return ki?delete this[t]:Object.defineProperty(this,t,{configurable:!0,writable:!0,value:i}),ki=ki||o,i}catch(i){throw delete this[t],ki=ki||o,i}},set(o){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:o})}})}function zA(e,t,n,r){const o=LA(e,t);o&&Object.defineProperty(o,t,{configurable:!0,get(){const i={configurable:!0,writable:!0,enumerable:r,value:void 0};return Object.defineProperty(this,t,i),i.value=n(this),Object.defineProperty(this,t,i),i.value},set(i){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:r,value:i})}})}const FA="~constantCatch";function BA(e){const t=()=>e;return t[FA]=!0,t}var $0;const vm={value:void 0,enumerable:!1};let C0="captureStackTrace"in Error?Error:null;function UA(e){const t=C0;if(t){const n=t.stackTraceLimit;if(typeof n=="number"){try{t.stackTraceLimit=0}catch{return C0=null,new e}try{return new e}finally{t.stackTraceLimit=n}}}return new e}function Ee(e,t,n,r){const o={};function i(g){this.def=g,this.constr=m,this.traits=new Set}i.prototype=o;const l=n,c=l&&new WeakSet;function u(g,w){if(!g._zod){vm.value=new i(w);try{Object.defineProperty(g,"_zod",vm)}finally{vm.value=void 0}}if(g._zod.traits.has(e))return;if(g._zod.traits.add(e),t(g,w),c){const v=Object.getPrototypeOf(g),_=g._zod.constr.prototype;let x=v;for(;x&&x!==_;)x=Object.getPrototypeOf(x);const T=x??v;c.has(T)||(c.add(T),MA(T,l))}const y=m.prototype;for(const v in y)Object.prototype.hasOwnProperty.call(y,v)&&(v in g||(g[v]=y[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 _;const w=r!=null&&r.Parent?UA(f):this;u(w,g);const y=w._zod.deferred;if(y){for(const x of y)x();w._zod.deferred=void 0}const v=(_=globalThis.__zod_globalConfig)==null?void 0:_.postProcessor;return v&&v(w),w}return Object.defineProperty(m,"init",{value:u}),Object.defineProperty(m,Symbol.hasInstance,{value:g=>{var w,y;return r!=null&&r.Parent&&g instanceof r.Parent?!0:(y=(w=g==null?void 0:g._zod)==null?void 0:w.traits)==null?void 0:y.has(e)}}),Object.defineProperty(m,"name",{value:e}),m}class xl extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class cE extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}($0=globalThis).__zod_globalConfig??($0.__zod_globalConfig={});const ns=globalThis.__zod_globalConfig;function Ai(e){return e&&Object.assign(ns,e),ns}function HA(){const e=this._zod;return e.message??(e.message=JSON.stringify(e.def,lg,2)),e.message}function WA(e){this._zod.message=e}const KA={get:HA,set:WA,enumerable:!0,configurable:!0},bm={value:void 0,enumerable:!1},xm={value:void 0,enumerable:!1},A0=new WeakSet([Object.prototype,Error.prototype]),uE=(e,t)=>{e.name="$ZodError",bm.value=e._zod,Object.defineProperty(e,"_zod",bm),xm.value=t,Object.defineProperty(e,"issues",xm),bm.value=void 0,xm.value=void 0,Object.defineProperty(e,"message",KA);const n=Object.getPrototypeOf(e);A0.has(n)||(A0.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})}}))},dE=Ee("$ZodError",uE),fE=Ee("$ZodError",uE,void 0,{Parent:Error});function ZA(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 qA(e,t=n=>n.message){const n={},r=[];for(const o of e.issues)o.path.length>0?ZA(n,o.path[0],()=>[]).push(t(o)):r.push(t(o));return{formErrors:r,fieldErrors:n}}function GA(e,t=n=>n.message){const n={_errors:[]},r=(o,i=[])=>{for(const l of o.issues)if(l.code==="invalid_union"&&l.errors.length)l.errors.map(c=>r({issues:c},[...i,...l.path]));else if(l.code==="invalid_key")r({issues:l.issues},[...i,...l.path]);else if(l.code==="invalid_element")r({issues:l.issues},[...i,...l.path]);else{const c=[...i,...l.path];if(c.length===0)n._errors.push(t(l));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(l)),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(l)),u=g,h++}}}};return r(e),n}function ch(e,t){return{callee:(t==null?void 0:t.callee)??e,Err:t==null?void 0:t.Err}}const Ak=e=>{const t=(n,r,o,i)=>{const l=o?{...o,async:!1}:{async:!1},c=n._zod.run({value:r,issues:[]},l);if(c instanceof Promise)throw new xl;if(c.issues.length){const u=new((i==null?void 0:i.Err)??e)(c.issues.map(h=>zl(h,l,Ai())));throw sE(u,(i==null?void 0:i.callee)??t),u}return c.value};return t},Ik=e=>{const t=async(n,r,o,i)=>{const l=o?{...o,async:!0}:{async:!0};let c=n._zod.run({value:r,issues:[]},l);if(c instanceof Promise&&(c=await c),c.issues.length){const u=new((i==null?void 0:i.Err)??e)(c.issues.map(h=>zl(h,l,Ai())));throw sE(u,(i==null?void 0:i.callee)??t),u}return c.value};return t},uh=e=>(t,n,r)=>{const o=r?{...r,async:!1}:{async:!1},i=t._zod.run({value:n,issues:[]},o);if(i instanceof Promise)throw new xl;return i.issues.length?{success:!1,error:new(e??dE)(i.issues.map(l=>zl(l,o,Ai())))}:{success:!0,data:i.value}},VA=uh(fE),dh=e=>async(t,n,r)=>{const o=r?{...r,async:!0}:{async:!0};let i=t._zod.run({value:n,issues:[]},o);return i instanceof Promise&&(i=await i),i.issues.length?{success:!1,error:new e(i.issues.map(l=>zl(l,o,Ai())))}:{success:!0,data:i.value}},YA=dh(fE),XA=e=>{const t=Ak(e),n=(r,o,i,l)=>{const c=i?{...i,direction:"backward"}:{direction:"backward"};return t(r,o,c,ch(n,l))};return n},QA=e=>{const t=Ak(e),n=(r,o,i,l)=>t(r,o,i,ch(n,l));return n},JA=e=>{const t=Ik(e),n=async(r,o,i,l)=>{const c=i?{...i,direction:"backward"}:{direction:"backward"};return await t(r,o,c,ch(n,l))};return n},eI=e=>{const t=Ik(e),n=async(r,o,i,l)=>await t(r,o,i,ch(n,l));return n},tI=e=>(t,n,r)=>{const o=r?{...r,direction:"backward"}:{direction:"backward"};return uh(e)(t,n,o)},nI=e=>(t,n,r)=>uh(e)(t,n,r),rI=e=>async(t,n,r)=>{const o=r?{...r,direction:"backward"}:{direction:"backward"};return dh(e)(t,n,o)},oI=e=>async(t,n,r)=>dh(e)(t,n,r),sI=/^[cC][0-9a-z]{6,}$/,iI=/^[0-9a-z]+$/,aI=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,lI=/^[0-9a-vA-V]{20}$/,cI=/^[A-Za-z0-9]{27}$/,uI=/^[a-zA-Z0-9_-]{21}$/;function dI(e){return new RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}const fI=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,hI=/^([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})$/,I0=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)$/,pI=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,mI="^[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$";function gI(){return new RegExp(mI,"u")}const kI=/^(?:(?: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])$/,wI=/^(([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}|:))$/,yI=/^((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])$/,vI=/^(([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])$/,bI=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,hE=/^[A-Za-z0-9_-]*$/,xI=/^https?$/,EI=/^\+[1-9]\d{6,14}$/,pE="(?:(?:\\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 SI(e){return new RegExp(`^${e}$`)}const _I=SI(pE);function cg(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 NI(e){return new RegExp(`^${cg(e)}$`)}function TI(e){const t=["Z"];e.offset&&t.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const n=`${cg({precision:e.precision,seconds:!0})}(?:${t.join("|")})`,r=e.local?`${n}|${cg({precision:e.precision})}`:n;return new RegExp(`^${pE}T(?:${r})$`)}const jI=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}$`)},$I=/^-?\d+$/,CI=/^-?\d+(?:\.\d+)?$/,AI=/^(?:true|false)$/i,II=/^[^A-Z]*$/,RI=/^[^a-z]*$/,po=Ee("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),Rk=e=>{const t=e.value;return!wA(t)&&t.length!==void 0},Tf={number:"number",bigint:"bigint",object:"date"},mE=Ee("$ZodCheckLessThan",(e,t)=>{po.init(e,t);const n=Tf[typeof t.value];e._zod.onattach.push(r=>{const o=r._zod.bag,i=(t.inclusive?o.maximum:o.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<i&&(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:Tf[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})}}),gE=Ee("$ZodCheckGreaterThan",(e,t)=>{po.init(e,t);const n=Tf[typeof t.value];e._zod.onattach.push(r=>{const o=r._zod.bag,i=(t.inclusive?o.minimum:o.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>i&&(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:Tf[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})}}),OI=Ee("$ZodCheckMultipleOf",(e,t)=>{po.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):yA(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})}}),MI=Ee("$ZodCheckNumberFormat",(e,t)=>{var l;po.init(e,t),t.format=t.format||"float64";const n=(l=t.format)==null?void 0:l.includes("int"),r=n?"int":"number",[o,i]=_A[t.format];e._zod.onattach.push(c=>{const u=c._zod.bag;u.format=t.format,u.minimum=o,u.maximum=i,n&&(u.pattern=$I)}),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>i&&c.issues.push({origin:"number",input:u,code:"too_big",maximum:i,inclusive:!0,inst:e,continue:!t.abort})}}),PI=Ee("$ZodCheckMaxLength",(e,t)=>{var n;po.init(e,t),(n=e._zod.def).when??(n.when=Rk),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,i=o.length;if((typeof o=="string"&&i>t.maximum?$k(o):i)<=t.maximum)return;const c=Ck(o);r.issues.push({origin:c,code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),LI=Ee("$ZodCheckMinLength",(e,t)=>{var n;po.init(e,t),(n=e._zod.def).when??(n.when=Rk),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,i=o.length;if((typeof o=="string"&&i>=t.minimum&&i<t.minimum*2?$k(o):i)>=t.minimum)return;const c=Ck(o);r.issues.push({origin:c,code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),DI=Ee("$ZodCheckLengthEquals",(e,t)=>{var n;po.init(e,t),(n=e._zod.def).when??(n.when=Rk),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,i=o.length,l=typeof o=="string"&&i>=t.length&&i<=t.length*2?$k(o):i;if(l===t.length)return;const c=Ck(o),u=l>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})}}),fh=Ee("$ZodCheckStringFormat",(e,t)=>{var n,r;po.init(e,t),e._zod.onattach.push(o=>{const i=o._zod.bag;i.format=t.format,t.pattern&&(i.patterns??(i.patterns=new Set),i.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=()=>{})}),zI=Ee("$ZodCheckRegex",(e,t)=>{fh.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})}}),FI=Ee("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=II),fh.init(e,t)}),BI=Ee("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=RI),fh.init(e,t)}),UI=Ee("$ZodCheckIncludes",(e,t)=>{po.init(e,t);const n=jl(t.includes),r=new RegExp(typeof t.position=="number"?`^.{${t.position},}${n}`:n);t.pattern=r,e._zod.onattach.push(o=>{const i=o._zod.bag;i.patterns??(i.patterns=new Set),i.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})}}),HI=Ee("$ZodCheckStartsWith",(e,t)=>{po.init(e,t);const n=new RegExp(`^${jl(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})}}),WI=Ee("$ZodCheckEndsWith",(e,t)=>{po.init(e,t);const n=new RegExp(`.*${jl(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})}}),KI=Ee("$ZodCheckOverwrite",(e,t)=>{po.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});class ZI{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(l=>l),o=Math.min(...r.map(l=>l.length-l.trimStart().length)),i=r.map(l=>l.slice(o)).map(l=>" ".repeat(this.indent*2)+l);for(const l of i)this.content.push(l)}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 qI={major:4,minor:5,patch:4},Zn=Ee("$ZodType",(e,t)=>{var i;var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=qI;const r=e._zod.def.checks,o=e._zod.traits.has("$ZodCheck")?[e,...r??[]]:r!=null&&r.length?[...r]:[];for(const l of o)for(const c of l._zod.onattach)c(e);if(o.length===0)(n=e._zod).deferred??(n.deferred=[]),(i=e._zod.deferred)==null||i.push(()=>{e._zod.run=e._zod.parse});else{const l=(u,h,f)=>{if(u.memo)return u;let m=hl(u),g;for(const w of h){if(w._zod.def.when){if(IA(u)||!w._zod.def.when(u))continue}else if(m)continue;const y=u.issues.length,v=w._zod.check(u);if(v instanceof Promise&&(f==null?void 0:f.async)===!1)throw new xl;if(g||v instanceof Promise)g=(g??Promise.resolve()).then(async()=>{await v,u.issues.length!==y&&(j0(u.issues,y,e),m||(m=hl(u,y)))});else{if(u.issues.length===y)continue;j0(u.issues,y,e),m||(m=hl(u,y))}}return g?g.then(()=>u):u},c=(u,h,f)=>{if(hl(u))return u.aborted=!0,u;const m=l(h,o,f);if(m instanceof Promise){if(f.async===!1)throw new xl;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 xl;return f.then(m=>l(m,o,h))}return l(f,o,h)}}},{get"~standard"(){return lE(this,"~standard",kE(this))},set"~standard"(e){$l(this,"~standard",e)}}),R0=e=>{var t;return e.success?{value:e.data}:{issues:(t=e.error)==null?void 0:t.issues}};function kE(e){return{validate:t=>{try{return R0(VA(e,t))}catch{return YA(e,t).then(R0)}},vendor:"zod",version:1}}const Ok=Ee("$ZodString",(e,t)=>{var n;Zn.init(e,t),e._zod.pattern=[...((n=e==null?void 0:e._zod.bag)==null?void 0:n.patterns)??[]].pop()??jI(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}}),qn=Ee("$ZodStringFormat",(e,t)=>{fh.init(e,t),Ok.init(e,t)}),GI=Ee("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=hI),qn.init(e,t)}),VI=Ee("$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=I0(r))}else t.pattern??(t.pattern=I0());qn.init(e,t)}),YI=Ee("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=pI),qn.init(e,t)}),wE=1,yE=2;function XI(e,t){var n;if(!t.normalize&&((n=t.protocol)==null?void 0:n.source)===xI.source&&!/^https?:\/\//i.test(e))return wE;try{return new URL(e)}catch{return yE}}const QI=/[\t\n\r]/g;function JI(e){return e.replace(QI,"")}function eR(e,t){return t.lastIndex=0,t.test(e.hostname)}function tR(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(":")?e.protocol.slice(0,-1):e.protocol)}const nR=Ee("$ZodURL",(e,t)=>{qn.init(e,t),e._zod.check=n=>{try{const r=n.value.trim(),o=XI(r,t);if(o===wE){n.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:n.value,inst:e,continue:!t.abort});return}if(o===yE){n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort});return}t.hostname&&!eR(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&&!tR(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:JI(r);return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),rR=Ee("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=gI()),qn.init(e,t)}),oR=Ee("$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?uI:dI(t.length)),qn.init(e,t)}),sR=Ee("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=sI),qn.init(e,t)}),iR=Ee("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=iI),qn.init(e,t)}),aR=Ee("$ZodULID",(e,t)=>{t.pattern??(t.pattern=aI),qn.init(e,t)}),lR=Ee("$ZodXID",(e,t)=>{t.pattern??(t.pattern=lI),qn.init(e,t)}),cR=Ee("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=cI),qn.init(e,t)}),uR=Ee("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=TI(t)),qn.init(e,t),(t.local||t.precision===-1)&&(e._zod.bag.laxFormat=!0,e._zod.onattach.push(n=>{n._zod.bag.laxFormat=!0}))}),dR=Ee("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=_I),qn.init(e,t)}),fR=Ee("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=NI(t)),qn.init(e,t)}),hR=Ee("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=fI),qn.init(e,t)}),pR=Ee("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=kI),qn.init(e,t),e._zod.bag.format="ipv4"}),mR=/^[0-9a-fA-F:.]+$/;function vE(e){if(!mR.test(e))return!1;try{return new URL(`http://[${e}]`),!0}catch{return!1}}const gR=Ee("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=wI),qn.init(e,t),e._zod.bag.format="ipv6",e._zod.check=n=>{vE(n.value)||n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}}),kR=Ee("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=yI),qn.init(e,t)});function wR(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:vE(n)}const yR=Ee("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=vI),qn.init(e,t),e._zod.check=n=>{wR(n.value)||n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}});function bE(e){if(e==="")return!0;if(/\s/.test(e)||e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const vR=Ee("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=bI),qn.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{bE(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});function bR(e){if(!hE.test(e))return!1;const t=e.replace(/[-_]/g,r=>r==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return bE(n)}const xR=Ee("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=hE),qn.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{bR(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),ER=Ee("$ZodE164",(e,t)=>{t.pattern??(t.pattern=EI),qn.init(e,t)});function SR(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 _R=Ee("$ZodJWT",(e,t)=>{qn.init(e,t),e._zod.check=n=>{SR(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),xE=Ee("$ZodNumber",(e,t)=>{Zn.init(e,t),e._zod.pattern=e._zod.bag.pattern??CI,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 i=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,...i?{received:i}:{}}),n}}),NR=Ee("$ZodNumberFormat",(e,t)=>{MI.init(e,t),xE.init(e,t)}),TR=Ee("$ZodBoolean",(e,t)=>{Zn.init(e,t),e._zod.pattern=AI,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}}),jR=Ee("$ZodUnknown",(e,t)=>{Zn.init(e,t),e._zod.parse=n=>n}),$R=Ee("$ZodNever",(e,t)=>{Zn.init(e,t),e._zod.parse=(n,r)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)});function O0(e,t,n){e.issues.length&&t.issues.push(...lh(n,e.issues)),t.value[n]=e.value}const CR=Ee("$ZodArray",(e,t)=>{Zn.init(e,t);const n=ns.memoizer;n==null||n.attach(e),e._zod.parse=(r,o)=>{const i=r.value;if(!Array.isArray(i))return r.issues.push({expected:"array",code:"invalid_type",input:i,inst:e}),r;r.value=n?n.alloc(e,r,Array(i.length),o):Array(i.length);const l=[];for(let c=0;c<i.length;c++){const u=i[c],h=t.element._zod.run({value:u,issues:[]},o);h instanceof Promise?l.push(h.then(f=>O0(f,r,c))):O0(h,r,c)}return l.length?Promise.all(l).then(()=>r):r}});function jf(e,t,n,r,o,i){const l=n in r,c=i==="optional";if(!(!l&&c&&o==="optional")){if(e.issues.length){if(o!==void 0&&c&&!l)return;t.issues.push(...lh(n,e.issues))}if(!l&&o===void 0){e.issues.length||t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[n]});return}e.value===void 0?l&&(t.value[n]=void 0):t.value[n]=e.value}}const AR=[];function EE(e){var l,c,u,h;const t=Object.keys(e.shape),n=Object.getOwnPropertySymbols(e.shape),r=n.length?n:AR,o=r.length?[...t,...r]:t;for(const f of o)if(!((h=(u=(c=(l=e.shape)==null?void 0:l[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 i=SA(e.shape);return{...e,allKeys:o,symbolKeys:r,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(i)}}function SE(e,t,n,r,o,i){const l=[],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"&&l.push(g);continue}if(h==="never"){l.push(g);continue}const w=u.run({value:t[g],issues:[]},r);w instanceof Promise?e.push(w.then(y=>jf(y,n,g,t,f,m))):jf(w,n,g,t,f,m)}return l.length&&n.issues.push({code:"unrecognized_keys",keys:l,input:t,inst:i,continue:!0}),e.length?Promise.all(e).then(()=>n):n}const ug=new WeakMap,IR=Ee("$ZodObject",(e,t)=>{Zn.init(e,t);const n=Object.getOwnPropertyDescriptor(t,"shape");if(!(n!=null&&n.get)){const u=t.shape;ug.set(t,u),Object.defineProperty(t,"shape",{get:()=>{const h={...u};return Object.defineProperty(t,"shape",{value:h}),ug.set(t,h),h}})}const r=ah(()=>EE(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)||uo(f,m,new Set);for(const w of g.values)f[m].add(w);g.optin!==void 0&&f[m].add(void 0)}}return f});const o=Gc,i=t.catchall;let l;const c=ns.memoizer;c==null||c.attach(e),e._zod.parse=(u,h)=>{l??(l=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=l.shape;for(const w of l.allKeys){if(w==="__proto__")continue;const y=g[w],v=y._zod.optin,_=y._zod.optout,x=y._zod.run({value:f[w],issues:[]},h);x instanceof Promise?m.push(x.then(T=>jf(T,u,w,f,v,_))):jf(x,u,w,f,v,_)}return i?SE(m,f,u,h,r.value,e):m.length?Promise.all(m).then(()=>u):u}}),RR=Ee("$ZodObjectJIT",(e,t)=>{IR.init(e,t);const n=e._zod.parse,r=ah(()=>EE(t)),o=ns.memoizer,i=w=>{var $,O;const y=r.value,v=y.symbolKeys,_=new ZI(["payload","ctx"],{shape:w,inst:e,memo:o,syms:v}),x=I=>`shape[${I}]._zod.run({ value: input[${I}], issues: [] }, ctx)`,T=(I,P)=>`
47
- for (let i = 0; i < ${I}.issues.length; i++) {
48
- const iss = ${I}.issues[i];
49
- iss.path = iss.path ? [${P}, ...iss.path] : [${P}];
50
- payload.issues.push(iss);
51
- }`;_.write("const input = payload.value;");const N=Object.create(null);let j=0;for(const I of y.allKeys)N[I]=`key_${j++}`;_.write(o?"const newResult = memo.alloc(inst, payload, {}, ctx);":"const newResult = {};");for(const I of y.allKeys){if(I==="__proto__")continue;const P=N[I],R=typeof I=="symbol"?`syms[${v.indexOf(I)}]`:vA(I),U=`${R} in input`,F=w[I],B=($=F==null?void 0:F._zod)==null?void 0:$.optin,X=B!==void 0,ae=((O=F==null?void 0:F._zod)==null?void 0:O.optout)==="optional";if(_.write(`const ${P} = ${x(R)};`),X&&ae){const Y=B==="optional"?`${P}_present`:`${P}.value !== undefined || ${P}_present`;_.write(`
52
- const ${P}_present = ${U};
53
- if (!${P}.issues.length || ${P}_present) {
54
- if (${P}.issues.length) {${T(P,R)}
55
- }
56
-
57
- if (${Y}) {
58
- newResult[${R}] = ${P}.value;
59
- }
60
- }
61
-
62
- `)}else X?_.write(`
63
- if (${P}.issues.length) {${T(P,R)}
64
- }
65
-
66
- if (${P}.value === undefined) {
67
- if (${U}) {
68
- newResult[${R}] = undefined;
69
- }
70
- } else {
71
- newResult[${R}] = ${P}.value;
72
- }
73
-
74
- `):_.write(`
75
- const ${P}_present = ${U};
76
- if (${P}.issues.length) {${T(P,R)}
77
- }
78
- if (!${P}_present && !${P}.issues.length) {
79
- payload.issues.push({
80
- code: "invalid_type",
81
- expected: "nonoptional",
82
- input: undefined,
83
- path: [${R}]
84
- });
85
- }
86
-
87
- if (${P}_present) {
88
- newResult[${R}] = ${P}.value;
89
- }
90
-
91
- `)}return _.write("payload.value = newResult;"),_.write("return payload;"),_.compile()};let l;const c=Gc,u=!ns.jitless,f=u&&xA.value,m=t.catchall;let g;e._zod.parse=(w,y)=>{g??(g=r.value);const v=w.value;return c(v)?u&&f&&(y==null?void 0:y.async)===!1&&y.jitless!==!0?(l||(l=i(t.shape)),w=l(w,y),m?SE([],v,w,y,g,e):w):n(w,y):(w.issues.push({expected:"object",code:"invalid_type",input:v,inst:e}),w)}});function M0(e,t,n,r){for(const i of e)if(i.issues.length===0)return t.value=i.value,t;const o=e.filter(i=>!hl(i));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(i=>i.issues.map(l=>zl(l,r,Ai())))}),t)}const _E=Ee("$ZodUnion",(e,t)=>{Zn.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(i=>i._zod.pattern);return new RegExp(`^(${o.map(i=>jk(i.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 i=!1;const l=[];for(const c of t.options){const u=c._zod.run({value:r.value,issues:[]},o);if(u instanceof Promise)l.push(u),i=!0;else{if(u.issues.length===0)return u;l.push(u)}}return i?Promise.all(l).then(c=>M0(c,r,e,o)):M0(l,r,e,o)}}),OR=Ee("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,_E.init(e,t);const n=e._zod.parse;_n(e,"propValues",o=>{const i={};for(const l of o.def.options){const c=l._zod.propValues;if(!c||Object.keys(c).length===0)throw new Error(`Invalid discriminated union option at index "${o.def.options.indexOf(l)}"`);for(const[u,h]of Object.entries(c)){Object.prototype.hasOwnProperty.call(i,u)||uo(i,u,new Set);for(const f of h)i[u].add(f)}}return i}),t.options.forEach((o,i)=>{const l=ug.get(o._zod.def);if(l&&!Object.prototype.hasOwnProperty.call(l,t.discriminator))throw new Error(`Invalid discriminated union option at index "${i}"`)});const r=ah(()=>{var l;const o=t.options,i=new Map;for(const c of o){const u=(l=c._zod.propValues)==null?void 0:l[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(i.has(h))throw new Error(`Duplicate discriminator value "${String(h)}"`);i.set(h,c)}}return i});e._zod.parse=(o,i)=>{const l=o.value;if(!Gc(l))return o.issues.push({code:"invalid_type",expected:"object",input:l,inst:e}),o;const c=r.value.get(l==null?void 0:l[t.discriminator]);return c?c._zod.run(o,i):t.unionFallback||i.direction==="backward"?n(o,i):(o.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,options:Array.from(r.value.keys()),input:l,path:[t.discriminator],inst:e}),o)}}),MR=Ee("$ZodIntersection",(e,t)=>{Zn.init(e,t),e._zod.parse=(n,r)=>{const o=n.value,i=t.left._zod.run({value:o,issues:[]},r),l=t.right._zod.run({value:o,issues:[]},r);return i instanceof Promise||l instanceof Promise?Promise.all([i,l]).then(([u,h])=>P0(n,u,h)):P0(n,i,l)}});function dg(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(Vc(e)&&Vc(t)){const n=Object.keys(t),r=Object.keys(e).filter(i=>n.indexOf(i)!==-1),o={...e,...t};Object.prototype.hasOwnProperty.call(o,"__proto__")&&delete o.__proto__;for(const i of r){if(i==="__proto__")continue;const l=dg(e[i],t[i]);if(!l.valid)return{valid:!1,mergeErrorPath:[i,...l.mergeErrorPath]};o[i]=l.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],i=t[r],l=dg(o,i);if(!l.valid)return{valid:!1,mergeErrorPath:[r,...l.mergeErrorPath]};n.push(l.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function P0(e,t,n){const r=new Map;let o;const i=new Map,l=(h,f)=>{var g,w;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"&&((w=h.path)==null?void 0:w.length)===1){const y=String(h.path[0]);i.has(y)||i.set(y,h),m=[y]}else return!1;for(const y of m)r.has(y)||r.set(y,{}),r.get(y)[f]=!0;return!0};for(const h of t.issues)l(h,"l")||e.issues.push(h);for(const h of n.issues)l(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)&&i.has(f)&&e.issues.push(i.get(f))}const u=dg(t.value,n.value);if(!u.valid){if(hl(e))return e;throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(u.mergeErrorPath)}`)}return e.value=u.data,e}const PR=Ee("$ZodTuple",(e,t)=>{Zn.init(e,t);const n=t.items,r=ns.memoizer;r==null||r.attach(e),e._zod.parse=(o,i)=>{const l=o.value;if(!Array.isArray(l))return o.issues.push({input:l,inst:e,expected:"tuple",code:"invalid_type"}),o;o.value=r?r.alloc(e,o,[],i):[];const c=[],u=L0(n,"optin"),h=L0(n,"optout");if(!t.rest){if(l.length<u)return o.issues.push({code:"too_small",minimum:u,inclusive:!0,input:l,inst:e,origin:"array"}),o;l.length>n.length&&o.issues.push({code:"too_big",maximum:n.length,inclusive:!0,input:l,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:l[m],issues:[]},i);g instanceof Promise?c.push(g.then(w=>{f[m]=w})):f[m]=g}if(t.rest){let m=n.length-1;const g=l.slice(n.length);for(const w of g){m++;const y=t.rest._zod.run({value:w,issues:[]},i);y instanceof Promise?c.push(y.then(v=>D0(v,o,m))):D0(y,o,m)}}return c.length?Promise.all(c).then(()=>z0(f,o,n,l,h)):z0(f,o,n,l,h)}});function L0(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 D0(e,t,n){e.issues.length&&t.issues.push(...lh(n,e.issues)),t.value[n]=e.value}function z0(e,t,n,r,o){for(let i=0;i<n.length;i++){const l=e[i],c=i<r.length;if(!c&&i>=o&&n[i]._zod.optin==="optional"){t.value.length=i;break}if(l.issues.length){if(!c&&i>=o){t.value.length=i;break}t.issues.push(...lh(i,l.issues))}t.value[i]=l.value}for(let i=t.value.length-1;i>=r.length&&(n[i]._zod.optout==="optional"&&t.value[i]===void 0);i--)t.value.length=i;return t}const LR=Ee("$ZodEnum",(e,t)=>{Zn.init(e,t);const n=oE(t.entries),r=new Set(n);e._zod.values=r;const o=n.filter(i=>EA.has(typeof i));e._zod.pattern=new RegExp(o.length?`^(${o.map(i=>jl(i.toString())).join("|")})$`:"^[^\\s\\S]$"),e._zod.parse=(i,l)=>{const c=i.value;return r.has(c)||i.issues.push({code:"invalid_value",values:n,input:c,inst:e}),i}}),DR=Ee("$ZodLiteral",(e,t)=>{Zn.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"?jl(r):r?jl(r.toString()):String(r)).join("|")})$`:"^[^\\s\\S]$"),e._zod.parse=(r,o)=>{const i=r.value;return n.has(i)||r.issues.push({code:"invalid_value",values:t.values,input:i,inst:e}),r}}),zR=Ee("$ZodTransform",(e,t)=>{var n;Zn.init(e,t),e._zod.optin="optional",(n=ns.memoizer)==null||n.guard(e),e._zod.parse=(r,o)=>{if(o.direction==="backward")throw new cE(e.constructor.name);const i=t.transform(r.value,r);if(o.async)return(i instanceof Promise?i:Promise.resolve(i)).then(c=>(r.value=c,r));if(i instanceof Promise)throw new xl;return r.value=i,r}});function F0(e,t){return e.value=t.issues.length?void 0:t.value,e}const NE=Ee("$ZodOptional",(e,t)=>{Zn.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(`^(${jk(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(i=>F0(n,i)):F0(n,o)}return t.innerType._zod.run(n,r)}}),FR=Ee("$ZodExactOptional",(e,t)=>{NE.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)}),BR=Ee("$ZodNullable",(e,t)=>{Zn.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(`^(${jk(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)}),UR=Ee("$ZodDefault",(e,t)=>{Zn.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(i=>B0(i,t)):B0(o,t)}});function B0(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const HR=Ee("$ZodPrefault",(e,t)=>{Zn.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))}),WR=Ee("$ZodNonOptional",(e,t)=>{Zn.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(i=>U0(i,e)):U0(o,e)}});function U0(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 H0(e,t,n,r){return t.issues.length?(e.value=n.catchValue({...t,value:e.value,error:{issues:t.issues.map(o=>zl(o,r,Ai()))},input:e.value}),e):(e.value=t.value,t.memo&&(e.memo=!0),e)}const KR=Ee("$ZodCatch",(e,t)=>{Zn.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(i=>H0(n,i,t,r)):H0(n,o,t,r)}}),ZR=Ee("$ZodPipe",(e,t)=>{Zn.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 i=t.out._zod.run(n,r);return i instanceof Promise?i.then(l=>Kd(l,t.in,r)):Kd(i,t.in,r)}const o=t.in._zod.run(n,r);return o instanceof Promise?o.then(i=>Kd(i,t.out,r)):Kd(o,t.out,r)}});function Kd(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 qR=Ee("$ZodReadonly",(e,t)=>{Zn.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(W0):W0(o)}});function W0(e){return e.memo||(e.value=Object.freeze(e.value)),e}const GR=Ee("$ZodCustom",(e,t)=>{po.init(e,t),Zn.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(i=>K0(i,n,r,e));K0(o,n,r,e)}});function K0(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(Yc(o))}}class VR extends Error{constructor(){super("Cannot parse a reference cycle that closes through a transform"),this.name="ZodCyclicError"}}const fg="~memo",Z0=[];function Em(e){return e.map(t=>t.path?{...t,path:t.path.slice()}:{...t})}const q0=new WeakMap;function TE(e,t){const n=q0.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)&&TE(c,t)&&(r=!0)},i=e._zod.def;switch(i.type){case"object":{for(const c of Reflect.ownKeys(i.shape))o(i.shape[c]);o(i.catchall);break}case"array":o(i.element);break;case"tuple":for(const c of i.items)o(c);o(i.rest);break;case"record":case"map":o(i.keyType),o(i.valueType);break;case"set":o(i.valueType);break;case"union":for(const c of i.options)o(c);break;case"intersection":o(i.left),o(i.right);break;case"optional":case"nullable":case"default":case"prefault":case"catch":case"readonly":case"nonoptional":case"promise":case"success":o(i.innerType);break;case"pipe":o(i.in),o(i.out);break;case"function":o(i.input),o(i.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 i){const u=Object.getOwnPropertyDescriptor(i,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),q0.set(e,r),r}function YR(e,t){let n=e.buckets.get(t);return n||(n=new Map,e.buckets.set(t,n)),n}let Zd;const qd=[],XR={alloc(e,t,n){const r=Zd;if(!r)return n;Zd=void 0;const o={value:n,issues:null};return r.set(t.value,o),qd.push(o),n},guard(e){var t;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{const n=e._zod.parse,r=(o,i)=>{if(i.direction!=="backward"&&JR(i,o.value))throw new VR;return n(o,i)};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 i=e._zod.parse,l=(c,u)=>{if(n===void 0&&(n=TE(e,new Set),!n))return e._zod.parse=i,e._zod.run===l&&(e._zod.run=i),i(c,u);const h=c.value;if(h===null||typeof h!="object")return i(c,u);let f=u[fg];f||(f={buckets:new Map,backEdges:void 0},u[fg]=f);let m;r===u?m=o:(m=YR(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(...Em(g.issues)):(c.memo=!0,f.backEdges??(f.backEdges=new Set),f.backEdges.add(g.value)),c;Zd=m;const w=qd.length,y=i(c,u);Zd=void 0;const v=qd.length>w?qd.pop():void 0;return y instanceof Promise?y.then(_=>(v&&(v.issues=_.issues.length?Em(_.issues):Z0),_)):(v&&(v.issues=y.issues.length?Em(y.issues):Z0),y)};e._zod.parse=l,e._zod.run===i&&(e._zod.run=l)})}};function QR(){return XR}function JR(e,t){var r;const n=(r=e[fg])==null?void 0:r.backEdges;return n!==void 0&&t!==null&&typeof t=="object"&&n.has(t)}const eO=()=>{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(i){return e[i]??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(i,l){return i==="number"&&typeof l=="number"&&!Number.isFinite(l)?String(l):r[i]??i}return i=>{switch(i.code){case"invalid_type":{const l=o(i.expected),c=OA(i.input),u=o(c,i.input);return`Invalid input: expected ${l}, received ${u}`}case"invalid_value":return i.values.length===1?`Invalid input: expected ${aE(i.values[0])}`:`Invalid option: expected one of ${N0(i.values,"|")}`;case"too_big":{const l=i.exact?"exactly ":i.inclusive?"<=":"<",c=t(i.origin);return c?`Too big: expected ${i.origin??"value"} to have ${l}${i.maximum.toString()} ${c.unit??"elements"}`:`Too big: expected ${i.origin??"value"} to be ${l}${i.maximum.toString()}`}case"too_small":{const l=i.exact?"exactly ":i.inclusive?">=":">",c=t(i.origin);return c?`Too small: expected ${i.origin} to have ${l}${i.minimum.toString()} ${c.unit}`:`Too small: expected ${i.origin} to be ${l}${i.minimum.toString()}`}case"invalid_format":{const l=i;return l.format==="starts_with"?`Invalid string: must start with "${l.prefix}"`:l.format==="ends_with"?`Invalid string: must end with "${l.suffix}"`:l.format==="includes"?`Invalid string: must include "${l.includes}"`:l.format==="regex"?`Invalid string: must match pattern ${l.pattern}`:`Invalid ${n[l.format]??i.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${i.divisor}`;case"unrecognized_keys":return`Unrecognized key${i.keys.length>1?"s":""}: ${N0(i.keys,", ")}`;case"invalid_key":return`Invalid key in ${i.origin}`;case"invalid_union":return i.options&&Array.isArray(i.options)&&i.options.length>0?`Invalid discriminator value. Expected ${i.options.map(c=>`'${c}'`).join(" | ")}`:i.inclusive===!1?"Invalid input: more than one option matched":"Invalid input";case"invalid_element":return`Invalid value in ${i.origin}`;default:return"Invalid input"}}};function tO(){return{localeError:eO()}}var G0;class nO{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 rO(){return new nO}(G0=globalThis).__zod_globalRegistry??(G0.__zod_globalRegistry=rO());const Oc=globalThis.__zod_globalRegistry;function oO(e,t){return new e({type:"string",...ut(t)})}function sO(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...ut(t)})}function iO(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...ut(t)})}function aO(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...ut(t)})}function lO(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...ut(t)})}function cO(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...ut(t)})}function uO(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...ut(t)})}function dO(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...ut(t)})}function fO(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...ut(t)})}function hO(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...ut(t)})}function pO(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...ut(t)})}function mO(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...ut(t)})}function gO(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...ut(t)})}function kO(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...ut(t)})}function wO(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...ut(t)})}function yO(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...ut(t)})}function vO(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...ut(t)})}function bO(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...ut(t)})}function xO(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...ut(t)})}function EO(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...ut(t)})}function SO(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...ut(t)})}function _O(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...ut(t)})}function NO(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...ut(t)})}function TO(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...ut(t)})}function jO(e,t){return new e({type:"string",format:"date",check:"string_format",...ut(t)})}function $O(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...ut(t)})}function CO(e,t){return new e({type:"string",format:"duration",check:"string_format",...ut(t)})}function AO(e,t){return new e({type:"number",checks:[],...ut(t)})}function IO(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...ut(t)})}function RO(e,t){return new e({type:"boolean",...ut(t)})}function OO(e){return new e({type:"unknown"})}function MO(e,t){return new e({type:"never",...ut(t)})}function V0(e,t){return new mE({check:"less_than",...ut(t),value:e,inclusive:!1})}function Sm(e,t){return new mE({check:"less_than",...ut(t),value:e,inclusive:!0})}function Y0(e,t){return new gE({check:"greater_than",...ut(t),value:e,inclusive:!1})}function _m(e,t){return new gE({check:"greater_than",...ut(t),value:e,inclusive:!0})}function X0(e,t){return new OI({check:"multiple_of",...ut(t),value:e})}function jE(e,t){return new PI({check:"max_length",...ut(t),maximum:e})}function $f(e,t){return new LI({check:"min_length",...ut(t),minimum:e})}function $E(e,t){return new DI({check:"length_equals",...ut(t),length:e})}function PO(e,t){return new zI({check:"string_format",format:"regex",...ut(t),pattern:e})}function LO(e){return new FI({check:"string_format",format:"lowercase",...ut(e)})}function DO(e){return new BI({check:"string_format",format:"uppercase",...ut(e)})}function zO(e,t){return new UI({check:"string_format",format:"includes",...ut(t),includes:e})}function FO(e,t){return new HI({check:"string_format",format:"starts_with",...ut(t),prefix:e})}function BO(e,t){return new WI({check:"string_format",format:"ends_with",...ut(t),suffix:e})}function Fl(e){return new KI({check:"overwrite",tx:e})}function UO(e){return Fl(t=>t.normalize(e))}function HO(){return Fl(e=>e.trim())}function WO(){return Fl(e=>e.toLowerCase())}function KO(){return Fl(e=>e.toUpperCase())}function ZO(){return Fl(e=>bA(e))}function qO(e,t,n){return new e({type:"array",element:t,...ut(n)})}function GO(e,t,n){return new e({type:"custom",check:"custom",fn:t,...ut(n)})}function VO(e,t){const n=YO(r=>(r.addIssue=o=>{if(typeof o=="string")r.issues.push(Yc(o,r.value,n._zod.def));else{const i=o;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),"input"in i||(i.input=r.value),i.inst??(i.inst=n),i.continue??(i.continue=!n._zod.def.abort),r.issues.push(Yc(i))}},e(r.value,r)),t);return n}function YO(e,t){const n=new po({check:"custom",...ut(t)});return n._zod.check=e,n}function Uc(e,...t){for(const n of t)for(const r of Reflect.ownKeys(n))Object.prototype.propertyIsEnumerable.call(n,r)&&uo(e,r,n[r]);return e}function CE(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)??Oc,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 Ni(e,t,n,r,o){const i=typeof t.unrepresentable=="function"?t.unrepresentable({zodSchema:e,path:r.path,message:o}):t.unrepresentable;if(i==="any")return!1;if(i===void 0||i==="throw")throw new Error(o);return Object.assign(n,i),!0}function wr(e,t,n={path:[],schemaPath:[]}){var f,m;var r;const o=e._zod.def,i=t.seen.get(e);if(i)return i.count++,n.schemaPath.includes(e)&&(i.cycle=n.path),i.schema;const l={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,l),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;const c=(m=(f=e._zod).toJSONSchema)==null?void 0:m.call(f);if(c)l.schema=c;else{const g={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,l.schema,g);else{const y=l.schema,v=t.processors[o.type];if(!v)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${o.type}`);v(e,t,y,g)}const w=e._zod.parent;w&&(l.ref||(l.ref=w),wr(w,t,g),t.seen.get(w).isParent=!0)}const u=t.metadataRegistry.get(e);return u&&Uc(l.schema,u),t.io==="input"&&Gr(e)&&(delete l.schema.examples,delete l.schema.default),t.io==="input"&&"_prefault"in l.schema&&((r=l.schema).default??(r.default=l.schema._prefault)),delete l.schema._prefault,t.seen.get(e).schema}function Q0(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function AE(e,t){var l,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=(l=e.metadataRegistry.get(f[0]))==null?void 0:l.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 _=(v=e.external.registry.get(f[0]))==null?void 0:v.id,x=e.external.uri??(N=>N);if(_)return{ref:x(_)};const T=f[1].defId??f[1].schema.id??`schema${e.counter++}`;return f[1].defId=T,{defId:T,ref:`${x("__shared")}#/${m}/${Q0(T)}`}}const g="#",w=`${g}/${m}/`;if(f[1]===n&&!f[1].schema.id)return{ref:g};const y=f[1].schema.id??`__schema${e.counter++}`;return{defId:y,ref:w+Q0(y)}},i=f=>{if(f[1].schema.$ref)return;const m=f[1],{ref:g,defId:w}=o(f);m.def={...m.schema},w&&(m.defId=w);const y=m.schema;for(const v in y)delete y[v];y.$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]){i(f);continue}if(e.external){const w=(u=e.external.registry.get(f[0]))==null?void 0:u.id;if(t!==f[0]&&w){i(f);continue}}if((h=e.metadataRegistry.get(f[0]))==null?void 0:h.id){i(f);continue}if(m.cycle){i(f);continue}if(m.count>1&&e.reused==="ref"){i(f);continue}}e.external&&(e.sharedDefsExtractedFor=e.external)}function IE(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;IE(r);const o=Object.keys(r);if(o.length!==1||o[0]!=="type")return;const i=r.type;for(const l of Array.isArray(i)?i:[i]){if(typeof l!="string")return;n.includes(l)||n.push(l)}}delete e.anyOf,e.type=n.length===1?n[0]:n}const RE=new Set(["type","properties","required","additionalProperties"]),J0=["oneOf","anyOf"];function eb(e){const t=e.additionalProperties;return t===void 0||t===!1||typeof t!="object"||t===null?null:Object.keys(t).length?t:null}function hg(e){var i;const t=[];for(const l of e){if(typeof l!="object"||l.type!=="object")return null;for(const c in l)if(!RE.has(c))return null;t.push(l)}const n={},r=new Set;for(const l of t){for(const c in l.properties){if(Object.prototype.hasOwnProperty.call(n,c))continue;const u=[];for(const f of t){const m=((i=f.properties)==null?void 0:i[c])??eb(f);m!=null&&(u.some(g=>JSON.stringify(g)===JSON.stringify(m))||u.push(m))}const h=u.length===1?u[0]:hg(u)??{allOf:u};uo(n,c,h)}for(const c of l.required??[])r.add(c)}const o={type:"object",properties:n};if(r.size&&(o.required=[...r]),t.every(l=>l.additionalProperties===!1))o.additionalProperties=!1;else{const l=[];for(const c of t){const u=eb(c);u&&!l.some(h=>JSON.stringify(h)===JSON.stringify(u))&&l.push(u)}l.length===1?o.additionalProperties=l[0]:l.length>1&&(o.additionalProperties={allOf:l})}return o}function XO(e){const t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(const o of RE)if(o in e)return;const n=t.filter(o=>J0.some(i=>Array.isArray(o[i])));let r=null;if(!n.length)r=hg(t);else{const o=n[0],i=J0.find(u=>Array.isArray(o[u]));if(Object.keys(o).length!==1)return;const l=t.filter(u=>u!==o),c=o[i].map(u=>hg([...l,u]));if(c.some(u=>!u))return;r={[i]:c}}r&&(delete e.allOf,Uc(e,r))}function OE(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 w=g.def??g.schema,y={...w},v=g.ref;if(g.ref=null,v){r(v);const x=e.seen.get(v),T=x.schema;if(T.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(w.allOf=w.allOf??[],w.allOf.push(T)):Uc(w,T),Uc(w,y),m._zod.parent===v)for(const j in w)j==="$ref"||j==="allOf"||j in y||delete w[j];if(T.$ref&&x.def)for(const j in w)j==="$ref"||j==="allOf"||j in x.def&&JSON.stringify(w[j])===JSON.stringify(x.def[j])&&delete w[j]}const _=m._zod.parent;if(_&&_!==v){r(_);const x=e.seen.get(_);if(x!=null&&x.schema.$ref&&(w.$ref=x.schema.$ref,x.def))for(const T in w)T==="$ref"||T==="allOf"||T in x.def&&JSON.stringify(w[T])===JSON.stringify(x.def[T])&&delete w[T]}e.override({zodSchema:m,jsonSchema:w,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())IE(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 w of[g.schema,g.def]){const y=w==null?void 0:w.allOf;if(!Array.isArray(y))continue;const v=m.get(y);v?v.push(w):m.set(y,[w])}for(const g of e.intersections)for(const w of m.get(g)??[])XO(w)}}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)}Uc(o,n.defId?n.schema:n.def??n.schema);const i=(h=e.metadataRegistry.get(t))==null?void 0:h.id;i!==void 0&&o.id===i&&delete o.id;const l=((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,uo(l,g.defId,g.def))}e.external&&(e.sharedEmitDoneFor=e.external),e.external||Object.keys(l).length>0&&(e.target==="draft-2020-12"?o.$defs=l:o.definitions=l);try{const m=JSON.parse(JSON.stringify(o));return Object.defineProperty(m,"~standard",{value:{...t["~standard"],jsonSchema:{input:Cf(t,"input",e.processors),output:Cf(t,"output",e.processors)}},enumerable:!1,writable:!1}),m}catch{throw new Error("Error converting schema to JSON.")}}function Gr(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 Gr(r.element,n);if(r.type==="set")return Gr(r.valueType,n);if(r.type==="lazy")return Gr(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 Gr(r.innerType,n);if(r.type==="intersection")return Gr(r.left,n)||Gr(r.right,n);if(r.type==="record"||r.type==="map")return Gr(r.keyType,n)||Gr(r.valueType,n);if(r.type==="pipe")return e._zod.traits.has("$ZodCodec")?!0:Gr(r.in,n)||Gr(r.out,n);if(r.type==="object"){for(const o in r.shape)if(Gr(r.shape[o],n))return!0;return!1}if(r.type==="union"){for(const o of r.options)if(Gr(o,n))return!0;return!1}if(r.type==="tuple"){for(const o of r.items)if(Gr(o,n))return!0;return!!(r.rest&&Gr(r.rest,n))}return!1}const QO=(e,t={})=>n=>{const r=CE({...n,processors:t});return wr(e,r),AE(r,e),OE(r,e)},Cf=(e,t,n={})=>r=>{const{libraryOptions:o,target:i}=r??{},l=CE({...o??{},target:i,io:t,processors:n});return wr(e,l),AE(l,e),OE(l,e)},JO={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},e2=(e,t,n,r)=>{const o=n;o.type="string";const{minimum:i,maximum:l,format:c,patterns:u,contentEncoding:h,laxFormat:f}=e._zod.bag;if(typeof i=="number"&&(o.minLength=i),typeof l=="number"&&(o.maxLength=l),c&&(o.format=JO[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}))])}},t2=(e,t,n,r)=>{const o=n,{minimum:i,maximum:l,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>=(i??Number.NEGATIVE_INFINITY),g=typeof h=="number"&&h<=(l??Number.POSITIVE_INFINITY),w=t.target==="draft-04"||t.target==="openapi-3.0";m?w?(o.minimum=f,o.exclusiveMinimum=!0):o.exclusiveMinimum=f:typeof i=="number"&&(o.minimum=i),g?w?(o.maximum=h,o.exclusiveMaximum=!0):o.exclusiveMaximum=h:typeof l=="number"&&(o.maximum=l),typeof u=="number"&&(Number.isFinite(u)&&u!==0?o.multipleOf=Math.abs(u):Ni(e,t,o,r,`A multipleOf divisor of ${u} cannot be represented in JSON Schema`))},n2=(e,t,n,r)=>{n.type="boolean"},r2=(e,t,n,r)=>{n.not={}},o2=(e,t,n,r)=>{},s2=(e,t,n,r)=>{const o=e._zod.def,i=oE(o.entries);if(i.length===0){n.not={};return}i.every(l=>typeof l=="number")&&(n.type="number"),i.every(l=>typeof l=="string")&&(n.type="string"),n.enum=i},i2=(e,t,n,r)=>{const o=e._zod.def;if(o.values.length===0){n.not={};return}const i=[];for(const l of o.values)if(l===void 0){if(Ni(e,t,n,r,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof l=="bigint"){if(Ni(e,t,n,r,"BigInt literals cannot be represented in JSON Schema"))return;i.push(Number(l))}else i.push(l);if(i.length!==0)if(i.length===1){const l=i[0];n.type=l===null?"null":typeof l,t.target==="draft-04"||t.target==="openapi-3.0"?n.enum=[l]:n.const=l}else i.every(l=>typeof l=="number")&&(n.type="number"),i.every(l=>typeof l=="string")&&(n.type="string"),i.every(l=>typeof l=="boolean")&&(n.type="boolean"),i.every(l=>l===null)&&(n.type="null"),n.enum=i},a2=(e,t,n,r)=>{Ni(e,t,n,r,"Custom types cannot be represented in JSON Schema")},l2=(e,t,n,r)=>{Ni(e,t,n,r,"Transforms cannot be represented in JSON Schema")},c2=(e,t,n,r)=>{const o=n,i=e._zod.def,{minimum:l,maximum:c}=e._zod.bag;typeof l=="number"&&(o.minItems=l),typeof c=="number"&&(o.maxItems=c),o.type="array",o.items=wr(i.element,t,{...r,path:[...r.path,"items"]})};function Af(e){const t=e._zod.def;return t.type==="pipe"&&t.in._zod.traits.has("$ZodTransform")?Af(t.out):t.type==="catch"?Af(t.innerType):e._zod.optin}const u2=(e,t,n,r)=>{var f;const o=n,i=e._zod.def,l=i.shape;if(Object.getOwnPropertySymbols(l).length&&Ni(e,t,o,r,"Symbol keys cannot be represented in JSON Schema"))return;o.type="object",o.properties={};for(const m in l)uo(o.properties,m,wr(l[m],t,{...r,path:[...r.path,"properties",m]}));const u=new Set(Object.keys(l)),h=new Set([...u].filter(m=>{const g=i.shape[m];return t.io==="input"?Af(g)===void 0:g._zod.optout===void 0}));h.size>0&&(o.required=Array.from(h)),((f=i.catchall)==null?void 0:f._zod.def.type)==="never"?o.additionalProperties=!1:i.catchall?i.catchall&&(o.additionalProperties=wr(i.catchall,t,{...r,path:[...r.path,"additionalProperties"]})):t.io==="output"&&(o.additionalProperties=!1)},d2=(e,t,n,r)=>{const o=e._zod.def,i=o.inclusive===!1,l=o.options.map((c,u)=>wr(c,t,{...r,path:[...r.path,i?"oneOf":"anyOf",u]}));i?n.oneOf=l:n.anyOf=l},f2=(e,t,n,r)=>{const o=e._zod.def,i=wr(o.left,t,{...r,path:[...r.path,"allOf",0]}),l=wr(o.right,t,{...r,path:[...r.path,"allOf",1]}),c=h=>"allOf"in h&&Object.keys(h).length===1,u=[...c(i)?i.allOf:[i],...c(l)?l.allOf:[l]];n.allOf=u,t.intersections.push(u)},h2=(e,t,n,r)=>{const o=n,i=e._zod.def;o.type="array";const l=t.target==="draft-2020-12"?"prefixItems":"items",c=t.target==="draft-2020-12"||t.target==="openapi-3.0"?"items":"additionalItems",u=i.items.map((v,_)=>wr(v,t,{...r,path:[...r.path,l,_]})),h=i.rest?wr(i.rest,t,{...r,path:[...r.path,c,...t.target==="openapi-3.0"?[i.items.length]:[]]}):null;let f=i.items.length;for(;f>0;){const v=i.items[f-1];if(!(t.io==="input"?Af(v)!==void 0:v._zod.optout==="optional"))break;f--}const m=i.items.length,g=!i.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:w,maximum:y}=e._zod.bag;typeof w=="number"&&(o.minItems=w),typeof y=="number"&&(o.maxItems=y)},p2=(e,t,n,r)=>{const o=e._zod.def,i=wr(o.innerType,t,r),l=t.seen.get(e);t.target==="openapi-3.0"?(l.ref=o.innerType,n.nullable=!0):n.anyOf=[i,{type:"null"}]},m2=(e,t,n,r)=>{const o=e._zod.def;wr(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType},Mk=Symbol();function ME(e,t,n,r,o){let i=!1;const l=JSON.stringify(e,(c,u)=>typeof u!="bigint"?u:(i=!0,null));return i?(Ni(t,n,r,o,"BigInt defaults cannot be represented in JSON Schema"),Mk):JSON.parse(l)}const g2=(e,t,n,r)=>{const o=e._zod.def;wr(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType;const l=ME(o.defaultValue,e,t,n,r);l!==Mk&&(n.default=l)},k2=(e,t,n,r)=>{const o=e._zod.def;wr(o.innerType,t,r);const i=t.seen.get(e);if(i.ref=o.innerType,t.io!=="input")return;const l=ME(o.defaultValue,e,t,n,r);l!==Mk&&(n._prefault=l)},w2=(e,t,n,r)=>{const o=e._zod.def;wr(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType;let l;try{l=o.catchValue(void 0)}catch{Ni(e,t,n,r,"Dynamic catch values are not supported in JSON Schema");return}n.default=l},y2=(e,t,n,r)=>{const o=e._zod.def,i=o.in._zod.traits.has("$ZodTransform"),l=t.io==="input"?i?o.out:o.in:o.out;wr(l,t,r);const c=t.seen.get(e);c.ref=l},v2=(e,t,n,r)=>{const o=e._zod.def;wr(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType,n.readOnly=!0},PE=(e,t,n,r)=>{const o=e._zod.def;wr(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType},tb=new WeakSet([Object.prototype,Error.prototype]);function Gd(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 b2=(e,t)=>{dE.init(e,t),e.name="ZodError";const n=Object.getPrototypeOf(e);tb.has(n)||(tb.add(n),Gd(n,"format",r=>o=>GA(r,o)),Gd(n,"flatten",r=>o=>qA(r,o)),Gd(n,"addIssue",r=>o=>{r.issues.push(o),r.message=JSON.stringify(r.issues,lg,2)}),Gd(n,"addIssues",r=>o=>{r.issues.push(...o),r.message=JSON.stringify(r.issues,lg,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},Bo=Ee("ZodError",b2,void 0,{Parent:Error}),x2=Ak(Bo),E2=Ik(Bo),S2=uh(Bo),_2=dh(Bo),N2=XA(Bo),T2=QA(Bo),j2=JA(Bo),$2=eI(Bo),C2=tI(Bo),A2=nI(Bo),I2=rI(Bo),R2=oI(Bo);function O2(){ns.localeError||Ai(tO())}function hh(){ns.memoizer||Ai({memoizer:QR()})}const Qn=Ee("ZodType",(e,t)=>(O2(),Zn.init(e,t),e.def=t,e.type=t.type,e),{check(...e){const t=this.def;return this.clone($i(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 Ci(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(IM(e,t))},superRefine(e,t){return this.check(RM(e,t))},overwrite(e){return this.check(Fl(e))},optional(){return ob(this)},exactOptional(){return vM(this)},nullable(){return sb(this)},nullish(){return ob(sb(this))},nonoptional(e){return NM(this,e)},array(){return pa(this)},or(e){return dM([this,e])},and(e){return mM(this,e)},transform(e){return ib(this,yM(e))},default(e){return EM(this,e)},prefault(e){return _M(this,e)},catch(e){return jM(this,e)},pipe(e){return ib(this,e)},readonly(){return AM(this)},describe(e){const t=this.clone();return Oc.add(t,{description:e}),t},meta(...e){if(e.length===0)return Oc.get(this);const t=this.clone();return Oc.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 lE(this,"~standard",{...kE(this),jsonSchema:{input:Cf(this,"input"),output:Cf(this,"output")}})},set"~standard"(e){$l(this,"~standard",e)},parse:function e(t,n){return x2(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await E2(this,t,n,{callee:e})},safeParse(e,t){return S2(this,e,t)},async safeParseAsync(e,t){return _2(this,e,t)},get spa(){return this==null?void 0:this.safeParseAsync},set spa(e){$l(this,"spa",e)},encode:function e(t,n){return N2(this,t,n,{callee:e})},decode:function e(t,n){return T2(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await j2(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await $2(this,t,n,{callee:e})},safeEncode(e,t){return C2(this,e,t)},safeDecode(e,t){return A2(this,e,t)},async safeEncodeAsync(e,t){return I2(this,e,t)},async safeDecodeAsync(e,t){return R2(this,e,t)},toJSONSchema(e){return QO(this,{})(e)},get description(){var e;return(e=Oc.get(this))==null?void 0:e.description},get _def(){return this._zod.def}}),LE=Ee("_ZodString",(e,t)=>{Ok.init(e,t),Qn.init(e,t),e._zod.processJSONSchema=(r,o,i)=>e2(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(PO(...e))},includes(...e){return this.check(zO(...e))},startsWith(...e){return this.check(FO(...e))},endsWith(...e){return this.check(BO(...e))},min(...e){return this.check($f(...e))},max(...e){return this.check(jE(...e))},length(...e){return this.check($E(...e))},nonempty(...e){return this.check($f(1,...e))},lowercase(e){return this.check(LO(e))},uppercase(e){return this.check(DO(e))},trim(){return this.check(HO())},normalize(...e){return this.check(UO(...e))},toLowerCase(){return this.check(WO())},toUpperCase(){return this.check(KO())},slugify(){return this.check(ZO())}}),M2=Ee("ZodString",(e,t)=>{Ok.init(e,t),LE.init(e,t)},{email(e){return this.check(sO(F2,e))},url(e){return this.check(dO(U2,e))},jwt(e){return this.check(NO(rM,e))},emoji(e){return this.check(fO(H2,e))},guid(e){return this.check(iO(B2,e))},uuid(e){return this.check(aO(Vd,e))},uuidv4(e){return this.check(lO(Vd,e))},uuidv6(e){return this.check(cO(Vd,e))},uuidv7(e){return this.check(uO(Vd,e))},nanoid(e){return this.check(hO(W2,e))},cuid(e){return this.check(pO(K2,e))},cuid2(e){return this.check(mO(Z2,e))},ulid(e){return this.check(gO(q2,e))},base64(e){return this.check(EO(eM,e))},base64url(e){return this.check(SO(tM,e))},xid(e){return this.check(kO(G2,e))},ksuid(e){return this.check(wO(V2,e))},ipv4(e){return this.check(yO(Y2,e))},ipv6(e){return this.check(vO(X2,e))},cidrv4(e){return this.check(bO(Q2,e))},cidrv6(e){return this.check(xO(J2,e))},e164(e){return this.check(_O(nM,e))},datetime(e){return this.check(TO(P2,e))},date(e){return this.check(jO(L2,e))},time(e){return this.check($O(D2,e))},duration(e){return this.check(CO(z2,e))}});function Tn(e){return oO(M2,e)}const Jn=Ee("ZodStringFormat",(e,t)=>{qn.init(e,t),LE.init(e,t)}),P2=Ee("ZodISODateTime",(e,t)=>{uR.init(e,t),Jn.init(e,t)}),L2=Ee("ZodISODate",(e,t)=>{dR.init(e,t),Jn.init(e,t)}),D2=Ee("ZodISOTime",(e,t)=>{fR.init(e,t),Jn.init(e,t)}),z2=Ee("ZodISODuration",(e,t)=>{hR.init(e,t),Jn.init(e,t)}),F2=Ee("ZodEmail",(e,t)=>{YI.init(e,t),Jn.init(e,t)}),B2=Ee("ZodGUID",(e,t)=>{GI.init(e,t),Jn.init(e,t)}),Vd=Ee("ZodUUID",(e,t)=>{VI.init(e,t),Jn.init(e,t)}),U2=Ee("ZodURL",(e,t)=>{nR.init(e,t),Jn.init(e,t)}),H2=Ee("ZodEmoji",(e,t)=>{rR.init(e,t),Jn.init(e,t)}),W2=Ee("ZodNanoID",(e,t)=>{oR.init(e,t),Jn.init(e,t)}),K2=Ee("ZodCUID",(e,t)=>{sR.init(e,t),Jn.init(e,t)}),Z2=Ee("ZodCUID2",(e,t)=>{iR.init(e,t),Jn.init(e,t)}),q2=Ee("ZodULID",(e,t)=>{aR.init(e,t),Jn.init(e,t)}),G2=Ee("ZodXID",(e,t)=>{lR.init(e,t),Jn.init(e,t)}),V2=Ee("ZodKSUID",(e,t)=>{cR.init(e,t),Jn.init(e,t)}),Y2=Ee("ZodIPv4",(e,t)=>{pR.init(e,t),Jn.init(e,t)}),X2=Ee("ZodIPv6",(e,t)=>{gR.init(e,t),Jn.init(e,t)}),Q2=Ee("ZodCIDRv4",(e,t)=>{kR.init(e,t),Jn.init(e,t)}),J2=Ee("ZodCIDRv6",(e,t)=>{yR.init(e,t),Jn.init(e,t)}),eM=Ee("ZodBase64",(e,t)=>{vR.init(e,t),Jn.init(e,t)}),tM=Ee("ZodBase64URL",(e,t)=>{xR.init(e,t),Jn.init(e,t)}),nM=Ee("ZodE164",(e,t)=>{ER.init(e,t),Jn.init(e,t)}),rM=Ee("ZodJWT",(e,t)=>{_R.init(e,t),Jn.init(e,t)}),DE=Ee("ZodNumber",(e,t)=>{xE.init(e,t),Qn.init(e,t),e._zod.processJSONSchema=(r,o,i)=>t2(e,r,o,i);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(Y0(e,t))},gte(e,t){return this.check(_m(e,t))},min(e,t){return this.check(_m(e,t))},lt(e,t){return this.check(V0(e,t))},lte(e,t){return this.check(Sm(e,t))},max(e,t){return this.check(Sm(e,t))},int(e){return this.check(nb(e))},safe(e){return this.check(nb(e))},positive(e){return this.check(Y0(0,e))},nonnegative(e){return this.check(_m(0,e))},negative(e){return this.check(V0(0,e))},nonpositive(e){return this.check(Sm(0,e))},multipleOf(e,t){return this.check(X0(e,t))},step(e,t){return this.check(X0(e,t))},finite(){return this}});function As(e){return AO(DE,e)}const oM=Ee("ZodNumberFormat",(e,t)=>{NR.init(e,t),DE.init(e,t)});function nb(e){return IO(oM,e)}const sM=Ee("ZodBoolean",(e,t)=>{TR.init(e,t),Qn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>n2(e,n,r)});function Mo(e){return RO(sM,e)}const iM=Ee("ZodUnknown",(e,t)=>{jR.init(e,t),Qn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>o2()});function rb(){return OO(iM)}const aM=Ee("ZodNever",(e,t)=>{$R.init(e,t),Qn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>r2(e,n,r)});function lM(e){return MO(aM,e)}const cM=Ee("ZodArray",(e,t)=>{hh(),CR.init(e,t),Qn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>c2(e,n,r,o),e.element=t.element},{min(e,t){return this.check($f(e,t))},nonempty(e){return this.check($f(1,e))},max(e,t){return this.check(jE(e,t))},length(e,t){return this.check($E(e,t))},unwrap(){return this.element}});function pa(e,t){return qO(cM,e,t)}const uM=Ee("ZodObject",(e,t)=>{hh(),RR.init(e,t),Qn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>u2(e,n,r,o),zA(e,"shape",n=>n._zod.def.shape,!1)},{keyof(){return pl(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:rb()})},loose(){return this.clone({...this._zod.def,catchall:rb()})},strict(){return this.clone({...this._zod.def,catchall:lM()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return jA(this,e)},safeExtend(e){return $A(this,e)},merge(e){return CA(this,e)},pick(e){return NA(this,e)},omit(e){return TA(this,e)},partial(...e){return T0(Pk,this,e[0])},exactPartial(...e){return T0(BE,this,e[0],"exactPartial")},required(...e){return AA(UE,this,e[0])}});function Sr(e,t){const n={type:"object",shape:e??{},...ut(t)};return new uM(n)}const zE=Ee("ZodUnion",(e,t)=>{_E.init(e,t),Qn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>d2(e,n,r,o),e.options=t.options});function dM(e,t){return new zE({type:"union",options:e,...ut(t)})}const fM=Ee("ZodDiscriminatedUnion",(e,t)=>{zE.init(e,t),OR.init(e,t)});function hM(e,t,n){return new fM({type:"union",options:t,discriminator:e,...ut(n)})}const pM=Ee("ZodIntersection",(e,t)=>{MR.init(e,t),Qn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>f2(e,n,r,o)});function mM(e,t){return new pM({type:"intersection",left:e,right:t})}const gM=Ee("ZodTuple",(e,t)=>{hh(),PR.init(e,t),Qn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>h2(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 Pk({type:"optional",innerType:n}))})}});function FE(e,t,n){const r=t instanceof Zn,o=r?n:t,i=r?t:null;return new gM({type:"tuple",items:e,rest:i,...ut(o)})}const pg=Ee("ZodEnum",(e,t)=>{LR.init(e,t),Qn.init(e,t),e._zod.processJSONSchema=(r,o,i)=>s2(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 i={};for(const l of r)if(n.has(l))i[l]=t.entries[l];else throw new Error(`Key ${l} not found in enum`);return new pg({...t,checks:[],...ut(o),entries:i})},e.exclude=(r,o)=>{const i={...t.entries};for(const l of r)if(n.has(l))delete i[l];else throw new Error(`Key ${l} not found in enum`);return new pg({...t,checks:[],...ut(o),entries:i})}});function pl(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(r=>[r,r])):e;return new pg({type:"enum",entries:n,...ut(t)})}const kM=Ee("ZodLiteral",(e,t)=>{DR.init(e,t),Qn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>i2(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 kM({type:"literal",values:Array.isArray(e)?e:[e],...ut(t)})}const wM=Ee("ZodTransform",(e,t)=>{hh(),zR.init(e,t),Qn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>l2(e,n,r,o),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new cE(e.constructor.name);n.addIssue=i=>{if(typeof i=="string")n.issues.push(Yc(i,n.value,t));else{const l=i;l.fatal&&(l.continue=!1),l.code??(l.code="custom"),"input"in l||(l.input=n.value),l.inst??(l.inst=e),n.issues.push(Yc(l))}};const o=t.transform(n.value,n);return o instanceof Promise?o.then(i=>(n.value=i,n)):(n.value=o,n)}});function yM(e){return new wM({type:"transform",transform:e})}const Pk=Ee("ZodOptional",(e,t)=>{NE.init(e,t),Qn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>PE(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function ob(e){return new Pk({type:"optional",innerType:e})}const BE=Ee("ZodExactOptional",(e,t)=>{FR.init(e,t),Qn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>PE(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function vM(e){return new BE({type:"optional",innerType:e})}const bM=Ee("ZodNullable",(e,t)=>{BR.init(e,t),Qn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>p2(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function sb(e){return new bM({type:"nullable",innerType:e})}const xM=Ee("ZodDefault",(e,t)=>{UR.init(e,t),Qn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>g2(e,n,r,o),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function EM(e,t){return new xM({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():iE(t)}})}const SM=Ee("ZodPrefault",(e,t)=>{HR.init(e,t),Qn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>k2(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function _M(e,t){return new SM({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():iE(t)}})}const UE=Ee("ZodNonOptional",(e,t)=>{WR.init(e,t),Qn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>m2(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function NM(e,t){return new UE({type:"nonoptional",innerType:e,...ut(t)})}const TM=Ee("ZodCatch",(e,t)=>{KR.init(e,t),Qn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>w2(e,n,r,o),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function jM(e,t){return new TM({type:"catch",innerType:e,catchValue:typeof t=="function"?t:BA(t)})}const $M=Ee("ZodPipe",(e,t)=>{ZR.init(e,t),Qn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>y2(e,n,r,o),e.in=t.in,e.out=t.out});function ib(e,t){return new $M({type:"pipe",in:e,out:t})}const CM=Ee("ZodReadonly",(e,t)=>{qR.init(e,t),Qn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>v2(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function AM(e){return new CM({type:"readonly",innerType:e})}const HE=Ee("ZodCustom",(e,t)=>{GR.init(e,t),Qn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>a2(e,n,r,o)});function IM(e,t={}){return GO(HE,e,t)}function RM(e,t){return VO(e,t)}function OM(e,t={}){const n=new HE({type:"custom",check:"custom",fn:r=>r instanceof e,abort:!0,...ut(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 MM=["off","tailscale","any"],PM={updates:!0,deploy:!0,remote:"any",agents:null,customAgents:!0,brandedListener:!0,planSignIn:!0};Sr({updates:Mo().optional(),deploy:Mo().optional(),remote:pl(MM).optional(),agents:pa(Tn()).optional(),customAgents:Mo().optional(),brandedListener:Mo().optional(),planSignIn:Mo().optional()});const LM={...PM,source:null,problem:null};function DM(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 Nm=6e3,ab=1500;function zM(e){if(e.length<=Nm)return e;const t=e.length-Nm;return`${e.slice(0,ab)}
94
- [${t} characters cut here]
95
- ${e.slice(e.length-(Nm-ab))}`}const ua=129,FM=2e3,If=5e6,BM=["image/png","image/jpeg","image/gif","image/webp"],lb=2576,Tm=5*1024*1024,UM=1200,HM=10,WM=1e5,cb=100*1024*1024,KM="pasted-text.txt";function ZM(e){return e.t==="term-data"||e.t==="term-snapshot"||e.t==="term-exit"}function qM(e){return e.t==="file-read"||e.t==="file-written"||e.t==="file-blame"}const GM=80;function Lk(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,GM)}}function WE(e){return e.length>=UM||e.split(`
97
- `).length>=HM}function VM({startLine:e,endLine:t}){return e===t?`${e}`:`${e}-${t}`}function YM(e){return`${e.path.slice(e.path.lastIndexOf("/")+1)} (${VM(e)})`}const XM=/\u001B(?:\[[0-?]*[ -/]*[@-~]|\][^\u0007]*(?:\u0007|\u001B\\))/g;function QM(e){return e.replace(XM,"")}const KE="Projects";function JM(e){for(const t of e){const n=t.codePointAt(0)??0;if(n<32||n===127)return!0}return!1}function Xc(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":JM(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 eP=/^(?:https?|ssh|git|file):\/\/\S+$/i,ZE=/^[\w.-]+@[\w.-]+:\S+$/;function tP(e){const t=e.trim();if(!eP.test(t)&&!ZE.test(t))return null;const n=nP(t);return n&&!Xc(n)?{url:t,name:n}:null}function nP(e){var o;const t=((o=e.split(/[?#]/)[0])==null?void 0:o.replace(/\/+$/,""))??"";return((ZE.test(t)?t.split(":")[1]??"":t).split("/").pop()??"").replace(/\.git$/i,"")}const rP=Sr({component:Tn().nullable(),file:Tn().nullable(),line:As().nullable(),callFile:Tn().nullable().default(null),callLine:As().nullable().default(null),tag:Tn(),selector:Tn()}),oP=Sr({tag:Tn().max(40),id:Tn().max(200),classes:pa(Tn().max(120)).max(16),text:Tn().max(200),attrs:pa(FE([Tn().max(40),Tn().max(200)])).max(12)}),sP=FE([As(),As()]),iP=rP.extend({classes:Tn(),text:Tn(),html:Tn(),route:Tn(),element:oP}),aP=hM("type",[Sr({type:qr("loaded"),url:Tn(),title:Tn()}),Sr({type:qr("navigated"),url:Tn(),title:Tn().optional()}),Sr({type:qr("traversed"),dir:pl(["back","forward"]).optional()}),Sr({type:qr("title"),title:Tn()}),Sr({type:qr("links"),links:pa(Sr({path:Tn().max(2048),text:Tn().max(120)})).max(200)}),Sr({type:qr("hmr")}),Sr({type:qr("touch"),phase:pl(["start","move","end","cancel"]),x:As(),y:As()}),Sr({type:qr("page-error"),message:Tn(),source:Tn().optional(),line:As().optional()}),iP.extend({type:qr("picked"),verb:pl(["chat","code"]).default("chat"),site:pl(["call","source"]).default("source")}),Sr({type:qr("pick-cancel")}),Sr({type:qr("highlight-miss"),path:Tn(),fileMatched:As(),withSource:As(),ranges:pa(sP).nullable()}),Sr({type:qr("drag-files"),over:Mo().default(!0)}),Sr({type:qr("drop-files"),files:pa(OM(File))}),Sr({type:qr("focus"),gesture:Mo()}),Sr({type:qr("key"),key:Tn(),code:Tn().optional(),meta:Mo(),ctrl:Mo().optional(),shift:Mo().optional(),alt:Mo().optional(),up:Mo().optional()})]);function qE(e){const t=aP.safeParse(e);return t.success?t.data:null}const lP=["rows","repos","visits","themes"];function cP(e){return lP.map(t=>e[t]??"").join(".")}const uP=/["“”]([^"“”]*)["“”]?|(\S+)/g;function GE(e){const t=new Set;for(const n of e.matchAll(uP)){const r=(n[1]??n[2]??"").replace(/\s+/g," ").trim().toLowerCase();r&&t.add(r)}return[...t]}const dP="now",fP="http://preview.invalid",hP=200;function ub(e){const t=e==null?void 0:e.replace(/\s+/g," ").trim().slice(0,hP).trim();return t||void 0}function ph(e){let t;try{t=new URL(e,fP)}catch{return null}if(t.pathname.startsWith("/__toyon"))return null;const n=db(t.pathname)||"/",r=t.hash.startsWith("#/")?db(t.hash.split("?")[0]??""):"";return r.length>1?`${n}${r}`:n}const db=e=>e.replace(/\/+$/,""),pP={static:4,mixed:3.5,param:3,optional:2,"optional-static":2,splat:1},Rf=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");function VE(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 i=[];let l="",c=0;for(const h of e.matchAll(/\[([^\]=]+)(?:=[^\]]*)?\]|\{\$([\w-]+)\}/g)){const f=e.slice(c,h.index);f&&(i.push({text:f}),l+=Rf(f)),i.push({name:h[1]??h[2]??"param"}),l+="[^/]+?",c=(h.index??0)+h[0].length}const u=e.slice(c);if(u&&(i.push({text:u}),l+=Rf(u)),i.some(h=>"name"in h))return{kind:"mixed",pattern:l,parts:i}}return{kind:"static",text:e}}function mP(e){const t=e.split("/").filter(Boolean).map(VE);if(t.every(r=>r.kind==="static"))return null;let n="";for(const r of t)r.kind==="static"?n+=`/${Rf(r.text)}`:r.kind==="optional-static"?n+=`(?:/${Rf(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+pP[o.kind],0),statics:t.filter(r=>r.kind==="static").length}}function gP(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 mh(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(VE))if(t+="/",o.kind==="static"||o.kind==="optional-static")t+=o.text;else if(o.kind==="mixed")for(const i of o.parts)"name"in i?r(i.name):t+=i.text;else r(o.name);return t||(t="/"),{text:t,params:n,literal:n.length>0?t.slice(0,n[0][0]):t}}const wu={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"}},YE={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"}},kP={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"}},wP={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"}},vP={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"}},bP={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"}},xP={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"}},EP={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"}},SP={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"}},_P={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"}},NP={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"}},TP={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"}},jP={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"}},$P={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"}},CP={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"}},AP={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"}},IP={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"}},RP={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"}},OP=[EP,SP,_P,NP,TP,jP,$P,CP,AP,IP,RP],mf=[wu,YE,kP,wP,yP,vP,bP,xP,...OP],MP={mode:"dark",light:YE.id,dark:wu.id},PP=["surface0","surface1","surface2","element0","element1","border0","border1","text0","text1","text2","red","orange","yellow","green","aqua","blue","purple","diffAdd","diffDel"];function LP(e){return`--${e.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`)}`}function mg(e){return XE(ma(e))}function XE(e){return e>.008856?116*e**(1/3)-16:903.3*e}function Dk(e,t){const n=mg(e)+t,r=va(e);if(!r)return e;let o=0,i=2;for(let l=0;l<24;l++){const c=(o+i)/2,u=Cl(Math.min(255,r[0]*c),Math.min(255,r[1]*c),Math.min(255,r[2]*c));mg(u)<n?o=c:i=c}return Cl(Math.min(255,r[0]*o),Math.min(255,r[1]*o),Math.min(255,r[2]*o))}function DP(e){return Dk(e.colors.surface1,-4)}function zP(e){return Dk(e.colors.surface0,-4)}const fb=["surface0","surface1","surface2","element0","element1","border0","border1"];function FP(e){if(e.kind!=="dark")return e;const t=fb.reduce((o,i)=>ma(e.colors[i])<ma(e.colors[o])?i:o),n=e.colors[t];if(ma(n)<=0)return e;const r={...e.colors};for(const o of[...fb,"text1","text2"]){const i=YP(e.colors[o],n)*.05-.05;r[o]=Dk(r[o],XE(i)-mg(r[o]))}return r.surface0="#000000",r.surface1="#000000",{...e,colors:r}}function hb(e){return VP(e,.55)}function BP(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 UP(e){const t={};for(const n of PP)t[LP(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(BP(e)))t[`--syntax-${n}`]=r;return t["--accent"]=zk(e),t["--fault"]=HP(e),t["--sunken"]=DP(e),t["--sunken-floor"]=zP(e),t["--scrim"]=GP(e.colors.surface0,.7),t["--shadow"]=e.kind==="dark"?"#00000066":"#0000002e",t["--diff-add-word"]=hb(e.colors.diffAdd),t["--diff-del-word"]=hb(e.colors.diffDel),t}function zk(e){return QE(e.accent??"")??e.colors.orange}function HP(e){return zk(e)===QE(e.colors.orange)?e.colors.red:e.colors.orange}function WP(e){return e==="system"||e==="daylight"}function Fk(e,t){return e.mode==="system"?t.system?"dark":"light":e.mode==="daylight"?t.daylight?"dark":"light":e.mode}function gh(e,t,n){const r=Fk(e,n);return t.find(o=>o.id===e[r])??mf.find(o=>o.kind===r)??wu}function KP(e,t){if(e.pair){const l=t.find(c=>c.id===e.pair);if(l&&l.kind!==e.kind)return l}const n=e.kind==="dark"?"light":"dark",r=l=>l.toLowerCase().replace(/\b(dark|light)\b/g,"*").replace(/\s+/g," ").trim(),o=r(e.name);if(!o.includes("*"))return null;const i=e.id.startsWith("vscode:")?e.id.slice(0,e.id.lastIndexOf(":")+1):null;return t.find(l=>l.kind===n&&l.source===e.source&&(!i||l.id.startsWith(i))&&r(l.name)===o)??null}function ZP(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 i=KP(o,e),l={name:r(o)};l[o.kind]=o,n.add(o.id),i&&(l[i.kind]=i,n.add(i.id)),t.push(l)}return t}function qP(e,t){const n={...e};return t.dark&&(n.dark=t.dark.id),t.light&&(n.light=t.light.id),!WP(n.mode)&&!t[n.mode]&&(n.mode=t.dark?"dark":"light"),n}function va(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 QE(e){const t=va(e);return t?Cl(t[0],t[1],t[2],t[3]):null}function Cl(e,t,n,r=1){const o=i=>Math.round(Math.max(0,Math.min(255,i))).toString(16).padStart(2,"0");return`#${o(e)}${o(t)}${o(n)}${r>=1?"":o(r*255)}`}function GP(e,t){const n=va(e);return n?Cl(n[0],n[1],n[2],t):e}function VP(e,t){const n=va(e);return n?Cl(n[0],n[1],n[2],Math.min(1,n[3]*t)):e}function Mq(e,t){const n=va(e),r=va(t);if(!n||!r)return e;const o=n[3];return Cl(n[0]*o+r[0]*(1-o),n[1]*o+r[1]*(1-o),n[2]*o+r[2]*(1-o))}function ma(e){const t=va(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 YP(e,t){const n=ma(e),r=ma(t);return(Math.max(n,r)+.05)/(Math.min(n,r)+.05)}function XP(e){return ma(e)>.179?"#1d2021":"#fbf1c7"}function gg(e){if(e===null||e==="")return"the npm registry";try{return new URL(e).host}catch{return e}}function JE(e,t){const n=pb(e),r=pb(t);if(!n||!r)return!1;for(let o=0;o<3;o++){const i=n.nums[o]??0,l=r.nums[o]??0;if(i!==l)return i>l}return n.pre===r.pre?!1:n.pre===null?!0:r.pre===null?!1:n.pre>r.pre}function pb(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 QP=[[/\.(png|jpe?g|gif|webp|avif|bmp|ico)$/i,"image"]];function JP(e){var t;return((t=QP.find(([n])=>n.test(e)))==null?void 0:t[1])??null}const eL=[[/\.(md|markdown)$/i,"markdown"],[/\.html?$/i,"html"]];function kh(e){var t;return((t=eL.find(([n])=>n.test(e)))==null?void 0:t[1])??null}const Ke={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",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",profilePrefix:"toyon-profile-",modePrefix:"toyon-mode-",modelPrefix:"toyon-model-",effortPrefix:"toyon-effort-",version:"toyon-version"},tL=[Ke.active,Ke.repo,Ke.lastActive,Ke.discoveredOpen,Ke.archivedOpen,Ke.committedShut,Ke.turnOpen,Ke.treeOpen,Ke.profilePrefix,Ke.modePrefix,Ke.modelPrefix,Ke.effortPrefix,Ke.phoneRow,Ke.version],nL=[Ke.profilePrefix,Ke.modePrefix,Ke.modelPrefix,Ke.effortPrefix],gf=(e,t)=>`${e}@${t}`,rL="toyon",_c="snapshots",ao={hello:e=>`hello@${e}`,chat:(e,t)=>`chat@${e}/${t}`,chats:e=>`chat@${e}/`};function oL(e,t=typeof localStorage>"u"?null:localStorage,n=typeof sessionStorage>"u"?null:sessionStorage){const r=l=>({get(c){try{return(l==null?void 0:l.getItem(gf(c,e)))??null}catch{return null}},set(c,u){try{l==null||l.setItem(gf(c,e),u)}catch{}},remove(c){try{l==null||l.removeItem(gf(c,e))}catch{}}}),o=r(t),i=r(n);return{...o,session:{get:i.get,set:i.set},clear(){for(const l of[t,n])for(const c of eS(l).filter(u=>u.endsWith(`@${e}`)))try{l==null||l.removeItem(c)}catch{}}}}function eS(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 sL="orch-";function iL(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 i of o){const l=Ke[i],c=sL+l.slice(6);mb(r,c,l)}for(const[r,o]of[[t,tL.filter(i=>i!==Ke.phoneRow)],[n,[Ke.phoneRow]]]){const i=eS(r).filter(l=>!l.includes("@"));for(const l of o){const c=nL.includes(l)?i.filter(u=>u.startsWith(l)):i.filter(u=>u===l);for(const u of c)mb(r,u,gf(u,e))}}}function mb(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 tS(){const e=location.hash.match(/token=([a-f0-9]+)/);if(e!=null&&e[1])return nS(e[1]),e[1];try{return localStorage.getItem(Ke.token)??sessionStorage.getItem(Ke.token)??""}catch{return""}}function nS(e){try{localStorage.setItem(Ke.token,e)}catch{}}function Of(){return tS()!==""}function Bk(e,t){const n=new URL(e),r=`token=${t}`,o=i=>`&v=${encodeURIComponent(i??"")}`;return{origin:n.origin,host:n.hostname,token:t,ws:`${n.protocol==="https:"?"wss":"ws"}://${n.host}/ws?${r}`,attachment:(i,l)=>`${n.origin}/attachments/${i}/${l}?${r}`,attachmentWhere:(i,l)=>`${n.origin}/attachments/${i}/${l}?${r}&where`,upload:i=>`${n.origin}/uploads/${i}?${r}`,worktreeFile:(i,l,c)=>`${n.origin}/files/${i}/${l.split("/").map(encodeURIComponent).join("/")}?${r}${o(c)}`,loose:(i,l)=>`${n.origin}/loose/${encodeURIComponent(i)}?${r}${o(l)}`,health:`${n.origin}/health`,restart:i=>`${n.origin}/restart?${r}${i?`&${dP}`:""}`,uploads:i=>`${n.origin}/uploads?kind=${i}`,tailnet:`${n.origin}/tailnet`,remote:`${n.origin}/remote`,tailscale:`${n.origin}/tailscale`,machines:`${n.origin}/machines`,knockAnswer:i=>`${n.origin}/knock/${i}/answer`,previewGrant:`${n.origin}/preview-grant`,changelog:`${n.origin}/changelog`}}const Bl=e=>({authorization:`Bearer ${e.token}`});async function aL(e,t,n,r){try{await n.slice(0,1).arrayBuffer()}catch{return"could not be read"}return new Promise(o=>{const i=new XMLHttpRequest;i.open("POST",e.uploads(t)),i.setRequestHeader("authorization",Bl(e).authorization),i.setRequestHeader("content-type",n.type||"application/octet-stream"),r&&(i.upload.onprogress=l=>l.lengthComputable&&r(l.loaded/l.total)),i.onload=()=>{if(i.status>=502&&i.status<=504)return o(null);if(i.status<200||i.status>=300)return o(i.responseText||"could not be attached");try{o(JSON.parse(i.responseText))}catch{o("could not be attached")}},i.onerror=()=>o(null),i.onabort=()=>o(null),i.send(n)})}async function lL(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 rS(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 cL(e){var t;try{const n=await fetch(e.changelog,{headers:Bl(e)});return!n.ok||!((t=n.headers.get("content-type"))!=null&&t.startsWith("text/markdown"))?null:await n.text()}catch{return null}}async function uL(e,t){try{const n=await fetch(t,{headers:Bl(e)});return n.ok?await n.json():null}catch{return null}}async function wh(e,t,n,r){try{const o=await fetch(t,{method:"POST",headers:{...Bl(e),"content-type":"application/json"},body:JSON.stringify(n)});return o.ok?null:await o.text()||`refused (${o.status})`}catch{return r}}const dL=e=>uL(e,e.tailnet),fL=e=>wh(e,e.remote,{tailscale:!0},"Toyon is not answering; try again once it is back."),hL=e=>wh(e,e.remote,{off:!0},"Toyon is not answering; try again once it is back.");async function oS(e,t,n){try{const r=await fetch(t,{method:"POST",headers:{...Bl(e),"content-type":"application/json"},body:JSON.stringify(n)});return r.ok?await r.json():null}catch{return null}}const sS="Toyon is not answering; try again once it is back.",pL=async e=>{const t=await oS(e,e.tailscale,{up:!0});return t===null?sS:t.refused},mL=async e=>await oS(e,e.tailscale,{login:!0})??{why:sS},gL=(e,t,n)=>wh(e,e.machines,{origin:t,token:n},"Toyon here is not answering; the machine is not listed yet."),kL=(e,t,n)=>wh(e,e.knockAnswer(t),{letIn:n},"Toyon is not answering");async function iS(e){try{const t=await fetch(e.previewGrant,{method:"POST",headers:Bl(e)});return t.ok?await t.json():null}catch{return null}}const wL=2e3;async function aS(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 i=await o.json();if(i.state==="let-in"&&typeof i.token=="string"&&i.token)return{token:i.token};if(i.state==="refused")return"refused"}}catch{}await new Promise(o=>setTimeout(o,wL))}return"gone"}async function kg(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 yL=1e3,vL=3e4,bL=1500,xL=5e3,gb=50,EL=e=>e.t==="chat"||e.t==="create-worktree"||e.t==="restore-worktree";class SL{constructor(t,n,r,o={},i={}){St(this,"ws",null);St(this,"queue",[]);St(this,"closed",!1);St(this,"attempt",0);St(this,"timer",null);St(this,"downAt",null);St(this,"downCode",0);St(this,"sayTimer",null);St(this,"sentDown",new Set);St(this,"drops",0);St(this,"urls");St(this,"suspended",!1);St(this,"connectDeadline");St(this,"settle");St(this,"backoffMin");St(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=i,this.connectDeadline=o.connectDeadline??xL,this.settle=o.settle??bL,this.backoffMin=o.backoffMin??yL,this.urls=Bk(t.origin,t.token),this.suspended=i.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===sA)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 i,l;if(this.closed||this.suspended)return;const t=((l=(i=this.hooks).known)==null?void 0:l.call(i))??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(vL,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)),EL(t)&&t.boxId&&this.sentDown.add(t.boxId),this.queue.push({key:r,raw:n}),this.queue.length>gb&&this.queue.splice(0,this.queue.length-gb)}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 Uk(e){return e==="cancelled"||e==="expired"}function lS(e){const t=e.findLast(n=>n.kind==="ask"||yu(n));return(t==null?void 0:t.kind)!=="ask"||t.ask.kind!=="question"?null:Uk(t.outcome)?t:null}function _L(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 NL(e){return e.map(()=>({selected:[]}))}function kb(e,t,n,r){return e.map((o,i)=>{if(i!==t)return o;const l=o.selected.includes(n);return r?{...o,selected:l?o.selected.filter(c=>c!==n):[...o.selected,n]}:{...o,selected:[n]}})}function Mf(e,t,n){return e.map((r,o)=>{if(o!==t)return r;const{note:i,...l}=r;return n===void 0?l:{...l,note:n}})}function wb(e,t,n,r){return e.map((o,i)=>i!==t?o:{selected:n&&!r?[]:o.selected,note:o.note??""})}function kf(e,t){const n=e[t];return n&&n.note!==void 0&&!n.note.trim()?Mf(e,t,void 0):e}function TL(e){return e?e.options.length+(e.note?1:0):0}function jL(e,t){return!!(e!=null&&e.note)&&t===e.options.length}function cS(e,t){return!!e&&e.note!==void 0&&(t||e.selected.length===0)}function El(e){var t;return!!e&&(e.selected.length>0||!!((t=e.note)!=null&&t.trim()))}function Yd(e,t){return e.every((n,r)=>!n.required||El(t[r]))}function $L(e,t){var o;const n=((t==null?void 0:t.selected)??[]).map(i=>{var l;return Wk(((l=e.options.find(c=>c.value===i))==null?void 0:l.label)??i)}),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 CL(e,t){var o;const n=((t==null?void 0:t.selected)??[]).map(i=>{var l;return Wk(((l=e.options.find(c=>c.value===i))==null?void 0:l.label)??i)}),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 Hk(e,t){return e.map((n,r)=>{const o=$L(n,t==null?void 0:t[r]);return e.length>1&&n.header?`${n.header} · ${o}`:o})}function AL(e){return e.outcome!=="answered"||e.ask.kind!=="question"?null:{message:e.ask.message,questions:e.ask.questions,answers:e.answers}}function IL(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(`
98
- `):null}function RL(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 ml(e,t){if(!e)return 0;if(cS(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 OL(e,t,n){return Math.max(0,Math.min(n-1,e+t))}function ML(e,t,n){const r=e.length;for(let o=1;o<=r;o++){const i=(n+o)%r;if(!El(t[i]))return i}return-1}function gl(e){return e.length>1?e.length:-1}function PL(e){return e.length+(gl(e)===-1?0:1)}function yb(e,t,n){const r=ML(e,t,n);if(r!==-1)return{current:r,cursor:ml(e[r],t[r]),send:!1};const o=gl(e);return o!==-1?{current:o,cursor:0,send:!1}:{current:n,cursor:ml(e[n],t[n]),send:!0}}const uS=/\s*\(recommended\)\s*$/i;function LL(e){return uS.test(e)}function Wk(e){return e.replace(uS,"")}const DL={skipped:"you skipped this",cancelled:"the turn was stopped before you answered",expired:"Toyon restarted before you answered"};function dS(e,t,n,r){return n!==null&&r===n.host?`${oA(n.previews,e,t)}/`:r.endsWith(".localhost")?`http://w${e}.${r}:${t}/`:Nk(r)?`http://${r==="localhost"?"127.0.0.1":r}:${t}/`:`https://${r}:${t}/`}function vb(e){return e.ranges.map(([t,n])=>[t+e.offset,n+e.offset])}function fS(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 zL(e){var r;const t=(r=e.source)==null?void 0:r.replace(/[?#].*$/,""),n=t?` (${fS(t)}:${e.line??"?"})`:"";return`${e.message}${n}`.slice(0,FM)}function Xd(e,t){return!Number.isFinite(e)||e<=0?t:Math.min(Math.max(e,170),Math.floor(window.innerWidth*.5))}function Ms(e){var t,n,r;return e.agent==="waiting"?"waiting":e.agent==="working"&&e.stopping?"stopping":e.agent==="working"?"working":e.agent==="error"||((n=(t=e.worktree)==null?void 0:t.lastTurn)==null?void 0:n.end)==="failed"?"failed":(r=e.worktree)!=null&&r.landed?"landed":e.procs.some(o=>o.status==="crashed"||o.status==="unreachable")?"crashed":e.procs.some(o=>o.status==="running")?"running":e.procs.some(o=>o.status==="starting")?"starting":e.procs.some(o=>o.status==="asleep")?"asleep":"idle"}const FL={waiting:"Waiting for you",stopping:"Agent stopping",working:"Agent working",failed:"Agent failed",landed:"Landed",crashed:"Crashed",running:"Running",starting:"Starting",asleep:"Asleep",idle:"Idle"};function yh(e,t=!1){const n=Ms(e);return n==="idle"&&t?"Not set up":FL[n]}const BL={starting:"Starting",running:"Running",unreachable:"Not answering",crashed:"Crashed",stopped:"Stopped",asleep:"Asleep"};function UL(e){return BL[e]}function hS(e,t){return t&&Ms(e)!=="waiting"?t:null}const HL={land:"Landing",commit:"Committing","sync-main":"Syncing with main","pull-main":"Pulling"};function Kk(e){return HL[e]}function pS(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 mS(e){const t=e.lastIndexOf("/");return t<0?{name:e,dir:""}:{name:e.slice(t+1),dir:e.slice(0,t)}}const gS=new Intl.Collator(void 0,{numeric:!0,sensitivity:"base"}).compare;function Pf(e){const t=[];for(let n=e.indexOf("/");n!==-1;n=e.indexOf("/",n+1))t.push(e.slice(0,n));return t}function kS(e){const t=new Set;for(const n of e)for(const r of Pf(n))t.add(r);return[...t].sort(gS)}function Zk(e){return e.includes("A")||e==="??"?"added":e.includes("D")?"deleted":""}function qk(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 WL=/Firefox\//.test(navigator.userAgent);function Gk(){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 KL=/Chrome\//.test(navigator.userAgent)&&Gk(),Dt=e=>WC(e,{firefox:WL,pwa:KL});function Vk(e){return e.component?`<${e.component} />`:`<${e.tag}>`}function wg(e,t){return e.worktree&&_r(e.worktree)&&t?t.defaultBranch:e.name}function Yk(e){const t=Math.max(0,e/1e3),n=(l,c)=>`${l} ${c}${l===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 i=o/24;return i<7?n(Math.floor(i),"day"):i<365?n(Math.floor(i/7),"week"):n(Math.floor(i/365),"year")}function ur(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 da(e){const t=Math.max(0,Math.floor(e));return t<100?`${t}s`:`${Math.floor(t/60)}m ${t%60}s`}function ZL(e,t,n,r){var l;if(!t)return null;const o=e.filter(Sn).filter(c=>c.repoId===t&&(c.worktree.agent??r)===n);return((l=o.find(c=>_r(c.worktree))??o[0])==null?void 0:l.id)??null}const qL=200;function GL(e,t){const n=new Map(e.map(r=>[r.path,r]));for(const r of t){if(n.size>=qL)break;const o=ph(r.path);o&&!n.has(o)&&n.set(o,{path:o,text:r.text})}return n.size===e.length?e:[...n.values()]}function wS(e){return e!==void 0&&!e.routes.some(t=>!t.endpoint)}const Ti=e=>"uploading"in e&&e.uploading===!0;function Sl(e){switch(e.kind){case"image":case"file":{const{key:t,local:n,uploading:r,progress:o,...i}=e;return i}case"paste":{const{key:t,chars:n,lines:r,preview:o,...i}=e;return i}case"pick":{const{key:t,...n}=e;return n}}}const Xk=e=>e.filter(t=>!Ti(t)).map(Sl);let VL=0;function yg(e,t){const n=new Map(t.filter(o=>!Ti(o)).map(o=>[JSON.stringify(Sl(o)),o]));return[...e.map(o=>{const i=JSON.stringify(o),l=n.get(i);if(l)return n.delete(i),l;const c=`d${++VL}`;return o.kind==="paste"?{...o,key:c,...Lk(o.text)}:{...o,key:c}}),...t.filter(Ti)]}const vg="out:",YL=(e,t,n)=>`${vg}${e}:${t}:${n}`;function ms(e){if(!e.startsWith(vg))return null;const t=e.slice(vg.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 Mc(e,t,n,r){const o=r.length?Xk(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 XL(e,t){const n=new Set,r=[];for(const o of e){if(n.has(o.log))continue;const i=t[o.id];if(!i||i.attachments.some(Ti)){n.add(o.log);continue}r.push(o.id)}return r}const yS=e=>e.flatMap(t=>"upload"in t&&t.upload?[t.upload]:[]);function QL(e){const t=n=>yS(n.items).some(r=>!n.before.includes(r));return[...e.filter(t),...e.filter(n=>!t(n))]}const il=300,JL=20;function e4(e,t){return e.rows.length===0&&e.repos.length===0?null:{protocol:ua,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 bb=e=>(e==null?void 0:e.protocol)===ua,t4={rows:"",repos:"",visits:"",themes:""};function n4(e){const{at:t,...n}=e;return{t:"hello",...n,rows:e.rows.map(r4),trunks:Object.fromEntries(Object.entries(e.trunks).map(([r,o])=>[r,o4(o)])),stamps:t4,themes:[],drafts:{},attachments:{},knocks:[],letIn:!1,self:null,update:null,pending:[]}}function r4(e){const{stopping:t,shipping:n,queued:r,syncQueued:o,...i}=e;return{...i,agent:e.agent==="working"?"idle":e.agent,procs:[],login:!1}}function o4(e){const{shipping:t,...n}=e;return n}function s4(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 Qd(e,t){return e.length>t?e.slice(e.length-t):[...e]}function i4(e,t,n=JL){const r=new Set(t.map(l=>l.id)),o=Object.keys(e).filter(l=>!r.has(l)),i=Object.entries(e).filter(([l])=>r.has(l)).sort((l,c)=>c[1].at-l[1].at);return[...o,...i.slice(n).map(([l])=>l)]}class a4{constructor(){St(this,"events",[]);St(this,"seq",-1);St(this,"whole",!1)}reset(t,n,r){this.events=Qd(Wd(t),il),this.seq=n,this.whole=r}extend(t,n){this.events.push(...t),n>this.seq&&(this.seq=n),this.events.length>il*2&&(this.events=Qd(Wd(this.events),il))}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>il*2&&(this.events=Qd(Wd(this.events),il))}snapshot(t,n){return this.events=Qd(Wd(this.events),il),{protocol:ua,at:n,events:[...this.events],seq:this.seq,...t?{draft:t}:{}}}}function yu(e){return e.kind==="user"||e.kind==="handed"}function vS(e){return e.map(t=>yu(t)?t.attachments:void 0)}const wf=["files","changes","history"],l4=e=>wf.includes(e),Ul=e=>(e==null?void 0:e.worktree.id)??null,Al="new-project",Sa=Object.freeze({chat:[],log:[],queue:[],page:{},turn:{edits:!1,hmr:!1},changedRanges:{},commitFiles:{},search:null,design:null,draft:"",attachments:[],commands:[],termStream:Po}),Qk=e=>({...e,phase:"editing",repoId:null}),bS=()=>Qk({mode:"create",name:"",parent:`~/${KE}`}),c4=Object.freeze({changes:!1,changesTab:"files",chat:!0,term:!1,design:!1});function u4(e){if(!e||typeof e!="object")return!1;const t=e;return typeof t.changes=="boolean"&&l4(t.changesTab)&&typeof t.chat=="boolean"&&typeof t.term=="boolean"&&typeof t.design=="boolean"}function so(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 Jk(e,t){return{...e,layout:t,changesAuto:!1}}const ji=e=>kh(e)?"preview":"file",d4=(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),Nc=(e,t)=>e.worktreeId===t.worktreeId&&e.path===t.path&&e.ref===t.ref&&e.since===t.since;function xS(e,t,n,r){var i;if(!r.fiber)return r;const o=(i=fo(e,t).changedRanges[n])==null?void 0:i.offset;return o===void 0?r:{n:r.n-o}}function f4(e){const t=e.cached??wu,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,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:c4,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",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:mf.some(o=>o.id===t.id)?mf:[...mf,t],themePrefs:{...MP,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:LM,letIn:!1,knocks:[],tailscale:null,handed:[],gitIdentity:!0,self:null,rebuilt:!1,update: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?Jk(n,r):n}function ES(e){var t;return{system:e.systemDark,daylight:((t=e.daylight)==null?void 0:t.dark)??e.systemDark}}function h4(e){return e.previewTheme??gh(e.themePrefs,e.themes,ES(e))}function fo(e,t){return t&&e.local[t]||Sa}function _o(e,t){return t&&e.rows.find(n=>n.id===t)||null}function SS(e,t){const n=_o(e,t);return n?Fo(n.agent)||!!e.shipping[n.id]||(n.queued??0)>0:!1}function rn(e,t){const n=_o(e,t);return n&&Sn(n)?n:null}function _S(e){var o;const t=rn(e,e.activeId);if(!t||!wa(t.worktree)||t.agent!=="idle"||!((o=Il(e,t.repoId))!=null&&o.empty))return!1;const n=Ii(e,t.repoId),r=e.rows.some(i=>{var l;return i.repoId===t.repoId&&((l=i.worktree)==null?void 0:l.kind)==="worktree"});return!!(n!=null&&n.needsSetup)&&!r&&fo(e,t.id).chat.length===0}function vh(e){return e.newProject!==null||_S(e)}function p4(e){return e.incompatible||vh(e)}function m4(e){return(!e.needsSetup||!!e.assumed)&&Object.keys(e.config.run).length===0}function Lf(e){return!!(e!=null&&e.needsSetup)&&!e.assumed}function ew(e){const t=e.archivedPage?null:_o(e,e.activeId);return(t==null?void 0:t.repoId)??e.activeRepoId}function Do(e){const t=Ii(e,ew(e));return!!t&&m4(t)}function NS(e){return e.layout.chat&&!Do(e)&&!e.archivedPage&&!nw(e)?{a:"toggle-chat"}:{a:"focus-chat"}}function TS(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 Yo(e){return Do(e)?e:so(e,{chat:!0})}function Ii(e,t){return t&&e.repos.find(n=>n.id===t)||null}function jS(e,t){if(!t)return null;const n=e.rows.filter(Sn).filter(r=>r.repoId===t);return n.find(r=>ku(r.worktree))??n.find(r=>wa(r.worktree))??null}function Il(e,t){return t&&e.trunks[t]||null}function kl(e){return Do(e)||e.archivedPage||e.notesPage?null:e.activeId}function bh(e){return e.procs.some(t=>t.status==="running"||t.status==="starting")}function Df(e){if(e.archivedPage||e.notesPage)return null;const t=rn(e,e.activeId);return t&&bh(t)?{worktreeId:t.worktree.id,repoId:t.repoId}:null}function bg(e){const t=kl(e),n=rn(e,t);return n?{id:n.worktree.id,act:bh(n)?"frame":"start"}:null}function tw(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(i=>i.id===r.origin.id);return o&&Sn(o)&&o.repoId===t?o:null}function $S(e,t){return e.repoId!==t&&(e.agent==="waiting"||!!e.unseen)}function xh(e,t,n,r){return e.repoId===t||tw(e,t,n)!==null||$S(e,t)||e.id===r}function CS(e,t,n){return!e||!t||!Sn(e)||e.repoId===t||tw(e,t,n)?null:$S(e,t)?e.id:null}function AS(e,t){return t.length?e.filter(n=>!t.includes(n.id)):e}function g4(e,t,n,r){const o=AS(e,n).filter(Sn);return $C(t?o.filter(i=>xh(i,t,o,r)):o)}function k4(e,t){const n=e.filter(r=>!Sn(r));return t?n.filter(r=>r.repoId===t):n}function Rl(e,t,n=e.rows){var c;const r=n.filter(Sn),o=e.archiving.length?r.filter(u=>!e.archiving.includes(u.id)):r,i=t?e.lastActive[t]:void 0;if(i&&o.some(u=>u.id===i))return i;const l=t?o.filter(u=>u.repoId===t):o;return((c=l.find(u=>ku(u.worktree))??l.find(u=>wa(u.worktree))??l[0])==null?void 0:c.id)??null}function xb(e,t){const n=Object.entries(e),r=n.filter(([o])=>!t(o));return r.length===n.length?e:Object.fromEntries(r)}function IS(e,t,n){const r={};for(const l of t)l.shipping&&(r[l.id]=l.shipping);for(const l of Object.values(n))l.shipping&&(r[l.id]=l.shipping);for(const[l,c]of Object.entries(e))!c.sent||r[l]||(t.some(u=>u.id===l)||FS({trunks:n},l))&&(r[l]=c);const o=Object.keys(r);return o.length===Object.keys(e).length&&o.every(l=>w4(e[l],r[l]))?e:r}const w4=(e,t)=>!!e&&!!t&&e.op===t.op&&e.step===t.step&&e.sent===t.sent;function wl(e,t){var m;const n=_o(e,t),r=!!n&&Sn(n)&&!!e.activeRepoId&&xh(n,e.activeRepoId,e.rows,e.lent),o=r&&e.lent!==t?CS(n,e.activeRepoId,e.rows):r?e.lent:null,i=r?e.activeRepoId:(n==null?void 0:n.repoId)??e.activeRepoId,l=n&&Sn(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"?yl(u,"reveal"):null,f=c&&h?{...e.local,[c]:h}:e.local;return{...e,activeId:t,activeRepoId:i,lent:o,lastActive:l,editor:null,archivedPage:null,notesPage:!1,local:f}}function Ol(e){return No(e)?"history":e.layout.changesTab}function y4(e,t){const n=Ol(e);if(No(e))return n;const r=wf.length;return wf[(wf.indexOf(n)+t+r)%r]??"changes"}function nw(e){if(e.archivedPage)return null;const t=_o(e,e.activeId);return t&&!Sn(t)?t:null}function v4(e){return e.notesSeen||e.ranBefore===null||!JE(e.version,e.ranBefore)?null:e.version}function No(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 yl(e,t){var o;if(((o=e.mark)==null?void 0:o.by)!==t)return e;const{mark:n,...r}=e;return r}const RS=e=>e.kind==="theme"||e.kind==="appearance"||e.kind==="keep-awake"||e.kind==="agent"||e.kind==="agent-page"||e.kind==="choose-folder"||e.kind==="split";let b4=0;function Qc(e){if(!e.sending)return e;const{sending:t,...n}=e;return n}function x4(e,t){const n=Object.keys(e.local).filter(o=>{var i;return((i=e.local[o])==null?void 0:i.sending)&&(!t||o===t)});if(n.length===0)return e;const r={...e.local};for(const o of n)r[o]=Qc(r[o]);return{...e,local:r}}function E4(e,t,n,r){var l;let o=e;const i=n?(l=o[n])==null?void 0:l.sending:void 0;if(i&&n&&r&&r!==n){const c=o[r]??Sa,u=c.chat.some(h=>h.kind==="user")?{at:i.at}:i;o={...o,[n]:Qc(o[n]),[r]:{...c,sending:u}}}for(const c of t){const u=o[c.id];u!=null&&u.sending&&!u.sending.message&&Fo(c.agent)&&(o={...o,[c.id]:Qc(u)})}return o}function wt(e,t,n){return{...e,local:{...e.local,[t]:n(e.local[t]??Sa)}}}function Eb(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 S4(e,t){const n=t.type==="agent-question"||t.type==="agent-permission"||t.type==="pieces-proposed"&&!t.held||t.type==="pieces-shown",r=t.type==="agent-ask-end"||t.type==="pieces-go"||t.type==="pieces-declined"?t.id:null;if(!n&&!r)return e;const o=t.type==="agent-ask-end"&&Uk(t.outcome),i=t.type==="agent-ask-end"&&t.outcome==="expired"?t.id:null,{card:l,cardParked:c,askRevived:u,...h}=e;return{...h,...l&&!n&&(l.id!==r||o)?{card:l}:{},...c&&!n&&c!==r?{cardParked:c}:{},...i?{askRevived:i}:u&&!n?{askRevived:u}:{}}}function _4(e,t,n){return wt(e,t,r=>({...r,chat:[...r.chat,n],chatAt:Date.now()}))}function OS(e,t,n){return _4(Yo(e),t,{kind:"error",text:n})}function xg(e,t){const n=Ul(rn(e,e.activeId));return n?wt(Yo(e),n,r=>({...r,notice:t})):e}function Sb(e,t,n){return rn(e,t)?OS(e,t,n):xg(e,n)}function N4(e,t){const n=e.paletteReturn;return!t||!n?{overlay:null,paletteReturn:null}:{overlay:{kind:n.mode},paletteReturn:n}}function T4(e){const t=e.activeRepoId;if(!t)return e;const n=e.layouts[t];return n?Jk(e,n):e.frame==="desk"?{...e,layouts:{...e.layouts,[t]:e.layout}}:e}function j4(e){return e.a==="server"&&e.msg.t==="git-status"}function $4(e){return{agent:e.defaultAgent}}function C4(e){const t=rn(e,e.activeId);return!!t&&_r(t.worktree)&&!e.archivedPage&&!vh(e)?e.draft?e:{...e,draft:$4(e)}:e.draft?{...e,draft:null}:e}function MS(e){var r;const t=e.archivedPage,n=t!==null&&((r=e.editor)==null?void 0:r.worktreeId)===t&&rn(e,t)===null;return{...e,archivedPage:null,...n?{editor:null}:{}}}function A4(e){const t=e.activeRepoId;if(!t)return e;const n=rn(e,e.activeId);return!n||n.repoId===t||xh(n,t,AS(e.rows,e.archiving),e.lent)?e:wl(e,Rl(e,t))}function PS(e,t,n){const r=t.some(i=>!e.knocks.some(l=>l.id===i.id)),o={...e,knocks:t,letIn:n};return r&&o.overlay===null?xi(o,{a:"open",overlay:{kind:"devices"}}):o}const I4=e=>{var t;return e.frame==="desk"&&(e.remote!==null||((t=e.tailscale)==null?void 0:t.state)==="ready")};function xi(e,t){let n=C4(A4(R4(e,t)));return n.unreadHold!==null&&n.activeId!==n.unreadHold&&(n={...n,unreadHold:null}),n.archivedPage!==null&&(No(n)===null||rn(n,n.archivedPage)!==null)&&(n=MS(n)),n.activeRepoId!==e.activeRepoId?n=T4(n):n.frame==="desk"&&n.activeRepoId&&!j4(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:g4(n.rows,n.activeRepoId,n.archiving,n.lent),visibleDiscovered:k4(n.rows,n.activeRepoId)}}function R4(e,t){var n,r,o,i,l,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:D4(e.local)};case"activate":return{...wl(e,t.id),carryTo:null,screen:t.id?"chat":"home"};case"open-draft":{if(vh(e))return e;const f=((n=jS(e,e.activeRepoId))==null?void 0:n.id)??null;return f?Yo({...wl(e,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 TS(e,t.id);case"close-archived":return e.archivedPage?MS(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 wt(e,t.id,f=>({...f,sending:{message:t.message,at:Date.now()}}));case"sent-box":return wt(e,t.id,({notice:f,...m})=>({...yl(m,"walk"),draft:"",attachments:[],sent:(m.sent??0)+1}));case"answered":return wt(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=YL(e.clientId,++b4,t.id),g={...Sa,draft:t.text,attachments:f.attachments,outgoing:{frame:t.frame,log:t.log}},w=wt(e,t.id,({notice:y,...v})=>({...yl(v,"walk"),draft:"",attachments:[]}));return{...w,local:{...w.local,[m]:g},outbox:[...e.outbox,{id:m,log:t.log,kinds:f.attachments.map(y=>y.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,...w}=e.local,y={...e,local:w,outbox:e.outbox.filter(N=>N.id!==t.id)},v=f.draft,_=f.attachments.length?Xk(f.attachments):void 0,x=N=>({...N,sent:(N.sent??0)+1});if(m.frame.t==="restore-worktree"||m.frame.t==="adopt-worktree")return wt(y,m.log,N=>({...x(N),sending:{message:{text:v,attachments:_},at:Date.now()}}));if(m.frame.t==="agent-answer")return wt(y,m.log,x);const T=m.frame.t==="chat"&&SS(e,m.log);return wt(y,m.log,N=>T?x(N):{...x(N),sending:{message:{text:v,attachments:_},at:Date.now()}})}case"unsend":{const f=e.local[t.id],m=(r=ms(t.id))==null?void 0:r.source;if(!(f!=null&&f.outgoing)||!m)return e;const{[t.id]:g,...w}=e.local,y={...e,local:w,outbox:e.outbox.filter(v=>v.id!==t.id)};return wt(Yo(y),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(N=>!e.archiving.includes(N)&&rn(e,N));if(f.length===0)return e;const m={...e,archiving:[...e.archiving,...f]};if(!e.activeId||!f.includes(e.activeId))return m;const g=e.visible.filter(N=>N.id===e.activeId||!m.archiving.includes(N.id)),w=g.findIndex(N=>N.id===e.activeId),y=[N=>N.agent==="waiting",N=>xk(N.worktree)&&!!N.worktree.landed&&N.agent==="idle",N=>!!N.unseen,N=>N.agent==="working",N=>!_r(N.worktree)&&Ms(N)==="running"],v=N=>{for(const j of y){const $=N(j);if($)return $.id}},_=v(N=>g.findLast((j,$)=>$<w&&N(j))),T=wl(m,_??v(N=>g.find((j,$)=>$>w&&N(j)))??Rl(m,e.activeRepoId));return e.frame==="phone"?{...T,screen:"home"}:T}case"shipping":return e.shipping[t.id]||!(_o(e,t.id)||FS(e,t.id))?e:{...e,shipping:{...e.shipping,[t.id]:{op:t.op,sent:!0}}};case"activate-repo":{if(!Ii(e,t.id))return e;const f=e.newProject?{...e,newProject:null}:e;if(t.id===e.activeRepoId)return f;const m=Rl(f,t.id);return{...wl(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&&Nc(m,f)?m:null,w=f.line&&xS(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,...w?{line:w}:{},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!=="bytes"&&f.source.kind!=="text"&&!f.tooLarge&&!f.binary,binary:f.binary,tooLarge:f.tooLarge};return{...e,editor:{worktreeId:f.worktreeId,path:f.name,view:ji(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||!Nc(f,t.file))return e;const m=t.disk;if(!m){const y=OS(e,f.worktreeId,t.error??`could not read ${f.path}`);return f.disk?y:{...y,editor:null}}const g=ji(f.path),w=m.before===""?f.view&&f.view!=="diff"?f.view:g:f.view??(m.before===m.after?g:"diff");return{...e,editor:{...f,view:w,disk:m}}}case"editor-conflict":{const f=e.editor;return f&&!f.loose&&Nc(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||!Nc(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&&Nc(f,t.file)?{...e,editor:{...f,blame:t.blame}}:e}case"notice":return wt(Yo(e),((i=ms(t.id))==null?void 0:i.source)??t.id,f=>({...f,notice:t.text}));case"link-refused":return wt(e,t.id,({refusedLink:f,...m})=>t.v?{...m,refusedLink:t.v}:m);case"card-draft":return wt(e,t.id,f=>({...f,card:t.card}));case"card-park":return wt(e,t.id,f=>({...f,cardParked:t.cardId}));case"card-unpark":return wt(e,t.id,({cardParked:f,...m})=>m);case"ask-revive":return wt(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 wt(e,t.id,f=>{const{notice:m,...g}=yl(f,"walk");return{...g,draft:t.text,...m!==void 0&&t.text===""?{notice:m}:{}}});case"move-box":return zS(e,t.from,t.to);case"walk":return wt(e,t.id,f=>({...yl(f,"walk"),draft:t.text,...t.walk?{mark:{by:"walk",at:t.walk.at,from:t.walk.from}}:{}}));case"reveal":return wt(Yo(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 wt(Yo(e),t.id,({notice:f,...m})=>({...m,attachments:[...m.attachments,...t.items]}));case"upload-progress":return(l=e.local[t.id])!=null&&l.attachments.some(f=>f.key===t.key&&Ti(f))?wt(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)?wt(e,t.id,f=>({...f,attachments:f.attachments.map(m=>m.key===t.key?t.item:m)})):e;case"detach":{const f=wt(e,t.id,({notice:m,...g})=>({...g,attachments:g.attachments.filter(w=>w.key!==t.key)}));return(u=e.local[t.id])!=null&&u.outgoing?xi(f,{a:"unsend",id:t.id}):f}case"clear-attachments":return wt(e,t.id,({notice:f,...m})=>m.attachments.length?{...m,attachments:[]}:m);case"hmr":return wt(e,t.id,f=>({...f,turn:{...f.turn,hmr:!0}}));case"page":return wt(e,t.id,f=>({...f,page:{url:t.url??f.page.url,title:t.title??f.page.title}}));case"links":return wt(e,t.id,f=>{const m=GL(f.links??[],t.links);return m===f.links?f:{...f,links:m}});case"drag-files":return d4(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:RS(t.overlay)?e.paletteReturn:null};case"choosing-folder":return{...e,choosingFolder:t.v};case"close":return{...e,previewTheme:null,...N4(e,t.back)};case"toggle":return((h=e.overlay)==null?void 0:h.kind)===t.overlay.kind?xi(e,{a:"close"}):xi(e,{a:"open",overlay:t.overlay});case"palette-return":return{...e,paletteReturn:t.v};case"toggle-changes":return{...so(e,{changes:!e.layout.changes}),changesAuto:!1};case"focus-changes":return{...so(e,{changes:!0,changesTab:t.tab&&!No(e)?t.tab:e.layout.changesTab}),changesAuto:!1,focusChanges:e.focusChanges+1};case"changes-tab":return so(e,{changesTab:t.v});case"edit-commit":return{...so(e,{changes:!0}),changesAuto:!1,editCommit:e.editCommit+1};case"toggle-chat":return Do(e)?e:so(e,{chat:!e.layout.chat});case"focus-chat":return{...Yo(e),focusChat:e.focusChat+1};case"walked":return{...e,walked:e.walked+1};case"show-chat":return Yo(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"?so(e,{changesTab:"changes"}):e,screen:t.to,editor:null};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?Jk(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(w=>w!==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 y=t.path.indexOf("/");y!==-1;y=t.path.indexOf("/",y+1))m.push(t.path.slice(0,y));m.push(t.path);const g=m.filter(y=>!f.includes(y)),w=g.length?{...e.treeOpen,[t.worktreeId]:[...f,...g]}:e.treeOpen;return{...so(e,{changes:!0,changesTab:"files"}),changesAuto:!1,focusChanges:e.focusChanges+1,treeOpen:w,treeReveal:{worktreeId:t.worktreeId,path:t.path}}}case"files-asked":return wt(e,t.worktreeId,f=>({...f,filesFor:t.key}));case"toggle-zen":return Do(e)?e:{...e,zen:!e.zen};case"toggle-terminal":return so(e,{term:!e.layout.term});case"focus-terminal":return{...so(e,{term:!0}),focusTerm:e.focusTerm+1};case"toggle-design":return Do(e)?e:so(e,{design:!e.layout.design});case"term-stream":return wt({...so(e,{term:!0}),termTall:t.tall?e.termTall+1:e.termTall},t.id,f=>({...f,termStream:t.stream}));case"term-run":return wt({...so(e,{term:!0}),focusTerm:e.focusTerm+1,termRun:{id:t.id,command:t.command}},t.id,f=>({...f,termStream:Po}));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 W4(e,t.msg);case"recall":return H4(e,t.hello,t.chats)}}function LS(e,t){const n=Object.entries(e),r=n.filter(([o])=>t.some(i=>i.id===o));return r.length===n.length?e:Object.fromEntries(r)}function DS(e,t,n){const r=new Set(t.map(l=>l.id));n&&r.add(n);const o=([l,c])=>r.has(l)||!!c.draft||c.attachments.length>0,i=Object.entries(e);return i.every(o)?e:Object.fromEntries(i.filter(o))}function O4(e,t,n){var o;let r=e;for(const i of n){if(!((o=i.worktree)!=null&&o.landed)||t.some(h=>{var f;return h.id===i.id&&((f=h.worktree)==null?void 0:f.landed)}))continue;const l=r[i.id];if(!(l!=null&&l.git)||l.git.files.length===0)continue;r===e&&(r={...e});const{extras:c,...u}=l.git;r[i.id]={...l,git:{...u,files:[]}}}return r}function M4(e,t){const{version:n,files:r,ahead:o,behind:i,unpushed:l,head:c}=t,u={version:n,files:r,...o===void 0?{}:{ahead:o},...i===void 0?{}:{behind:i},...l===void 0?{}:{unpushed:l},...c===void 0?{}:{head:c}};if(t.extras)return{...u,extras:t.extras};const h=new Map(e==null?void 0:e.files.map(w=>[w.path,w])),f=r.map(w=>{const y=h.get(w.path);return y&&y.xy===w.xy&&y.add!==void 0?{...w,add:y.add,del:y.del}:w}),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 P4(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(i=>i.path));let o=n;for(const i of Object.keys(n))r.has(i)&&(o===n&&(o={...n}),delete o[i]);return o}function L4(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 D4(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,...i}=r;t[n]=i}return t}function z4(e,t){let n=e;for(const[r,o]of Object.entries(t)){const i=n[r];i!=null&&i.draft||ms(r)||(n===e&&(n={...e}),n[r]={...i??Sa,draft:o})}return n}function F4(e,t){let n=e;for(const[r,o]of Object.entries(t)){const i=n[r];i!=null&&i.attachments.length||ms(r)||(n===e&&(n={...e}),n[r]={...i??Sa,attachments:yg(o,[])})}return n}function B4(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 wi(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 _b(e){const t=e.newProject;if((t==null?void 0:t.phase)!=="creating"||!t.repoId)return e;const n=jS(e,t.repoId);if(!n)return e;const r=fo(e,Al);return!r.draft.trim()&&r.attachments.length===0?{...e,newProject:null}:{...zS(e,Al,n.id),newProject:null,autoSend:n.id}}function zS(e,t,n){const r=e.local[t];if(!r)return e;const o=wt(e,n,i=>({...i,draft:r.draft,attachments:r.attachments}));return wt(o,t,i=>({...i,draft:"",attachments:[]}))}function Tc(e,t,n){return e.stamps?{...e.stamps,[t]:n}:null}function U4(e){return e.stamps?cP(e.stamps):null}function FS(e,t){return Object.values(e.trunks).some(n=>n.id===t)}function BS(e,t,n){var y;const{rows:r,repos:o,trunks:i,visits:l}=t.same?e:t,c=v=>!!v&&r.some(_=>_.id===v),u=v=>!!v&&o.some(_=>_.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:Rl(e,h,r),m=r.find(v=>v.id===f),g=!!h&&!!m&&Sn(m)&&xh(m,h,r,e.lent),w={...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:CS(m??null,h,r):null,activeRepoId:g?h:(m==null?void 0:m.repoId)??h??((y=o[0])==null?void 0:y.id)??null,trunks:i,archiving:e.archiving.length?[]:e.archiving,shipping:IS({},r,i),local:L4(DS(F4(z4(e.local,t.drafts),t.attachments),r,e.archivedPage)),lastActive:B4(e.lastActive,r),treeOpen:LS(e.treeOpen,r),discoveredOpen:wi(e.discoveredOpen,o),archivedOpen:wi(e.archivedOpen,o),committedShut:wi(e.committedShut,o),turnOpen:wi(e.turnOpen,o),refs:wi(e.refs,o),chats:wi(e.chats,o),archived:wi(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?bS():null),pending:n?e.pending:t.pending,visits:l,self:n?e.self:t.self,update:n?e.update:t.update,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?w:PS(w,t.knocks,t.letIn)}function Eg(e,t=[]){let n=t,r;for(const{seq:o,event:i}of e)n=HS(n,i,o),i.type==="usage"&&(r=US(i));return r?{chat:n,usage:r}:{chat:n}}function H4(e,t,n){var i;let r=BS(e,n4(t),!0);r={...r,recalledAt:t.at};for(const[l,c]of Object.entries(n))if(r.rows.some(u=>u.id===l))try{const{chat:u,usage:h}=Eg(c.events);r=wt(r,l,f=>({...f,chat:WS(u),chatAt:s4(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"&&!(((i=r.local[o])==null?void 0:i.chat.length)??0)&&(r={...r,screen:"home"}),r}function W4(e,t){var n,r,o,i,l,c,u,h,f,m,g,w,y,v,_;switch(t.t){case"hello":return BS(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 PS(e,t.knocks,t.letIn);case"update":return{...e,update:t.update};case"update-checked":return{...e,updateCheck:t.check};case"visits":return{...e,visits:{...e.visits,[t.repoId]:t.pages},stamps:Tc(e,"visits",t.stamp)};case"themes":return{...e,themes:t.themes,themePrefs:t.prefs,stamps:Tc(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}=t;return{...e,agentConfigs:{...e.agentConfigs,[T.agent]:T}}}case"pending-repos":{const x=new Set(e.pending.map(O=>O.id)),T=t.pending.find(O=>!x.has(O.id)),N=T&&e.pendingOpen?T.id:e.activeImportId,j=t.pending.some(O=>O.id===N),$=t.pending.some(O=>O.id===N&&O.error);return{...e,pending:t.pending,activeImportId:j?N:null,pendingOpen:$?!1:e.pendingOpen,newProject:T&&e.pendingOpen&&((i=e.newProject)==null?void 0:i.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:(((l=e.chosenFolder)==null?void 0:l.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":return{...e,archived:{...e.archived,[t.repoId]:t.items}};case"draft":return t.clientId===e.clientId||ms(t.boxId)?e:wt(e,t.boxId,x=>{var T;return x.draft===t.text||((T=x.mark)==null?void 0:T.by)==="walk"?x:{...x,draft:t.text}});case"attachments":return t.clientId===e.clientId||ms(t.boxId)?e:wt(e,t.boxId,x=>({...x,attachments:yg(t.items,x.attachments)}));case"repos":{const x=new Set(e.repos.map(R=>R.id)),T=t.repos.find(R=>!x.has(R.id));let N=e.activeRepoId,j=e.pendingOpen,$=e.newProject;T&&(j||!N)?(N=T.id,j=!1,$&&$.phase!=="unmaking"&&($={...$,phase:"creating",repoId:T.id})):t.repos.some(R=>R.id===N)||(N=((c=t.repos[0])==null?void 0:c.id)??null),($==null?void 0:$.phase)==="unmaking"&&!t.repos.some(R=>R.id===($==null?void 0:$.repoId))&&($={...$,phase:"editing",repoId:null}),t.repos.length===0&&!$&&($=bS());const O=e.gitIdentity||t.repos.some(R=>R.made&&!x.has(R.id)),I=Tc(e,"repos",t.stamp),P=wi(e.visits,t.repos);return N===e.activeRepoId?{...e,repos:t.repos,stamps:I,visits:P,pendingOpen:j,newProject:$,gitIdentity:O}:_b({...e,repos:t.repos,stamps:I,visits:P,pendingOpen:j,newProject:$,gitIdentity:O,activeRepoId:N,activeId:Rl(e,N),editor:null})}case"worktrees":{let x=e.activeId;(!x||!t.rows.some(O=>O.id===x))&&(x=Rl(e,e.activeRepoId,t.rows));const T=new Set(e.rows.map(O=>O.id)),N=O=>{var I;return((I=O.worktree)==null?void 0:I.kind)==="worktree"&&O.worktree.createdBy===e.clientId},j=t.rows.find(O=>!T.has(O.id)&&N(O));j&&e.rows.length>0&&(x=j.id);const $=e.archiving.filter(O=>t.rows.some(I=>I.id===O));return _b({...wl({...e,rows:t.rows,trunks:t.trunks,stamps:Tc(e,"rows",t.stamp),archiving:$.length===e.archiving.length?e.archiving:$,shipping:IS(e.shipping,t.rows,t.trunks),local:DS(E4(O4(e.local,e.rows,t.rows),t.rows,e.activeId,x===(j==null?void 0:j.id)?j.id:void 0),t.rows,e.archivedPage),treeOpen:LS(e.treeOpen,t.rows)},x),editor:x===e.activeId?e.editor:null,...j&&x===j.id?{carryTo:j.id}:{},...x===e.activeId?{activeRepoId:e.activeRepoId}:{},archivedPage:j?null:e.archivedPage,notesPage:j?!1:e.notesPage})}case"proc":{const x=e.rows.map(T=>T.id===t.worktreeId?{...T,procs:K4(T.procs,t.proc)}:T);return{...e,rows:x,stamps:Tc(e,"rows","")}}case"log":return wt(e,t.worktreeId,x=>({...x,log:NC(x.log.slice(-400),t.proc,t.line,t.retract)}));case"agent":{const x=t.event,T=t.worktreeId;let N=wt(e,T,j=>{const $=HS(j.chat,x,t.seq),O=x.type==="turn-end",I=O||x.type==="agent-error"||x.type==="agent-auth-required",R=x.type==="tool-start"||x.type==="tool-end"||O||x.type==="tool-update"&&x.background?Eb($,j.running):j.running;let U=j.turn;x.type==="turn-start"?U={edits:!1,hmr:!1}:x.type==="tool-start"&&G1(x)&&(U={...U,edits:!0});const F=x.type==="session-info"&&x.model?x.model:j.model,B=x.type==="session-info"&&x.effort?x.effort:j.effort,X=x.type==="usage"?{...US(x),heard:Date.now()}:j.usage,ae=e.rows.find(H=>H.id===T),Y=Fo(ae==null?void 0:ae.agent),ne=j.sending?Y?Qc(j):{...j,sending:{at:j.sending.at}}:j,C=S4(x.type==="user-message"?ne:I?Qc(j):j,x);return{...x.type==="user-message"?yl(C,"reveal"):C,chat:$,...$!==j.chat?{chatAt:Date.now()}:{},...R!==j.running?{running:R}:{},turn:U,...F!==j.model?{model:F}:{},...B!==j.effort?{effort:B}:{},...X!==j.usage?{usage:X}:{}}});if(x.type==="agent-ask-end"&&!Uk(x.outcome)&&((u=N.local[bl(x.id)])!=null&&u.attachments.length)&&(N=wt(N,bl(x.id),j=>({...j,attachments:[]}))),x.type==="user-message"){const j=lS(((h=e.local[T])==null?void 0:h.chat)??[]),$=j?bl(j.id):null,O=$?((f=N.local[$])==null?void 0:f.attachments)??[]:[];$&&O.length&&(N=wt(N,$,I=>({...I,attachments:[]})),N=wt(N,T,I=>({...I,attachments:[...I.attachments,...O]})))}if(x.type==="turn-end"){const j=N.local[T].turn;j.edits&&!j.hmr&&(N={...N,reloadReq:{id:T,n:(((m=N.reloadReq)==null?void 0:m.n)??0)+1}})}return(x.type==="agent-question"||x.type==="agent-permission"||x.type==="pieces-proposed"&&!x.held||x.type==="pieces-shown")&&T===e.activeId&&(N=Yo(N)),N}case"backfill":{const x=T=>t.events.some(({event:N})=>N.type==="user-message"&&N.text===T);return wt(e,t.worktreeId,({sending:T,...N})=>{const{chat:j,usage:$}=t.after!==void 0?Eg(t.events,N.chat):Eg(t.events);return{...N,...T&&!(T.message&&x(T.message.text))?{sending:T}:{},chat:j,chatAt:Date.now(),running:Eb(j,N.running),log:t.log??N.log,...$?{usage:$}:{}}})}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 T=e.layout.changes,N=e.changesAuto;const j=((w=t.extras)==null?void 0:w.committed.length)??0;e.changesAuto&&t.worktreeId===e.activeId&&!T&&(t.files.length>0||j>0)&&(T=!0,N=!1);const $=t.worktreeId===e.archivedPage?No(e):null;$&&(t.files.length>0||j>0||$.landed)&&(T=!0);const O=wt(e,t.worktreeId,I=>{const P=M4(I.git,t);return{...I,git:P,changedRanges:P4(I.git,P,I.changedRanges)}});return{...so(O,{changes:T}),changesAuto:N}}case"changed-ranges":{const x=wt(e,t.worktreeId,N=>({...N,changedRanges:{...N.changedRanges,[t.path]:{ranges:t.ranges,offset:t.lineOffset}}})),T=x.editor;return!((y=T==null?void 0:T.line)!=null&&y.fiber)||T.worktreeId!==t.worktreeId||T.path!==t.path?x:{...x,editor:{...T,line:xS(x,T.worktreeId,T.path,T.line)}}}case"shipped":{const x=t.worktreeId,T={...e,shipping:xb(e.shipping,N=>{var j;return N===x&&((j=e.shipping[N])==null?void 0:j.sent)===!0}),openUrl:t.ok&&t.url?t.url:e.openUrl};return!t.ok&&!t.asked?x?Sb(T,x,t.message):xg(T,t.message):T}case"files":return wt(e,t.worktreeId,x=>({...x,files:t.paths,submodules:t.submodules,ignored:t.ignored}));case"search-results":return wt(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 wt(e,t.worktreeId,N=>({...N,notice:"nothing in the source matches this element"}));if(!t.sure)return xi(e,{a:"open",overlay:{kind:"element-sources",worktreeId:t.worktreeId,hits:t.hits}});const T=xi(e,{a:"open-file",v:{worktreeId:t.worktreeId,path:x.path,view:"file",line:{n:x.line},focus:!0,seq:t.seq}});return T.layout.changes?T:xi(T,{a:"toggle-changes"})}case"design-index":return wt(e,t.worktreeId,x=>({...x,design:t.index}));case"routes":return wt(e,t.worktreeId,x=>({...x,pages:{routes:t.routes,unseen:t.unseen}}));case"queue":return wt(e,t.worktreeId,x=>({...x,queue:t.items}));case"agent-commands":return wt(e,t.worktreeId,x=>({...x,commands:t.commands}));case"git-log":return wt(e,t.worktreeId,x=>({...x,commits:t.commits}));case"git-commit":return wt(e,t.worktreeId,x=>({...x,commitFiles:{...x.commitFiles,[t.sha]:t.files}}));case"error":{const x=t.worktreeId,T=e.newProject,N=(T==null?void 0:T.phase)==="creating"&&!T.repoId,j={...x4(e,x),archiving:x?e.archiving.includes(x)?e.archiving.filter($=>$!==x):e.archiving:e.archiving.length?[]:e.archiving,shipping:xb(e.shipping,$=>!x||$===x),newProject:N?{...T,phase:"editing",error:t.message}:(T==null?void 0:T.phase)==="unmaking"?null:T,pendingOpen:N?!1:e.pendingOpen,updateCheck:!x&&e.updateCheck==="asking"?null:e.updateCheck};return N?j:x?Sb(j,x,t.message):xg(j,t.message)}case"unsent":{const x=((v=ms(t.boxId))==null?void 0:v.source)??t.boxId,T=!_o(e,x)&&!!e.activeRepoId&&((_=e.archived[e.activeRepoId])==null?void 0:_.some(N=>N.id===x));return wt(Yo(T?TS(e,x):e),x,({sending:N,...j})=>({...j,draft:j.draft||t.text,attachments:[...yg(t.items,[]),...j.attachments],notice:t.message}))}default:return e}}function K4(e,t){const n=e.findIndex(o=>o.name===t.name);if(n===-1)return[...e,t];const r=e.slice();return r[n]=t,r}function US(e){return{used:e.used,size:e.size,...e.cost!==void 0?{cost:e.cost}:{}}}function Z4(e,t){const n=t.trim();return n!==""&&(e.trim()===n||e.trim().endsWith(`: ${n}`))}function HS(e,t,n){var i,l,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,...(i=t.attachments)!=null&&i.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,...(l=t.attachments)!=null&&l.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:q4(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"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}:{}},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"&&Z4(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"landed":return[...e,{kind:"landed",text:t.message,...t.mark?{mark:t.mark}:{},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}:{},ts:t.ts}];case"pieces-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:"pieces",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"pieces-stale":{const h=al(e,t.id,["held","proposed"]);return h===-1?e:e.with(h,{...e[h],stale:!0})}case"pieces-shown":{const h=al(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"pieces-fate":{const h=al(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"pieces-go":{const h=al(e,t.id,["held","proposed"]);return h===-1?e:e.with(h,{...e[h],state:"going"})}case"pieces":{const h=al(e,t.id,["held","proposed","going"]);return h===-1?[...e,{kind:"pieces",id:t.id,pieces:[],fates:{},mode:_f,state:"done",outcomes:t.outcomes,later:[],ts:t.ts}]:e.with(h,{...e[h],state:"done",outcomes:t.outcomes})}case"pieces-declined":{const h=al(e,t.id,["held","proposed","going"]);if(h===-1)return e;const f=e[h];return e.with(h,{...f,state:"declined",...t.reason?{reason:t.reason}:{}})}case"piece-made":case"piece-dropped":{const h=e.findLastIndex(v=>v.kind==="pieces"&&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,w={kind:"piece-later",id:t.id,...g?{title:g}:{},...m,ts:t.ts};return[...f?e.with(h,{...f,later:[...f.later,m]}):e,w]}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 Nb(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.pieces?{pieces:t.pieces}:{},choices:t.choices}},f=t.pieces?e.findLastIndex(w=>w.kind==="pieces"&&w.id===t.pieces):-1,m=f===-1?e:e.with(f,{...e[f],companion:t.id,...t.plan&&!e[f].plan?{plan:t.plan}:{}}),g=m.findLast(w=>w.kind==="tool"&&w.id===t.toolId);return(g==null?void 0:g.kind)!=="tool"||t.plan||g.toolKind==="switch_mode"?Nb(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&&G4(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=WS(e);return t.stopReason==="interrupted"?[...h,{kind:"stopped",...o}]:h}default:return e}}function WS(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 q4(e,t){let n=e.length-1;for(;n>=0&&yu(e[n]);)n--;const r=e[n];return(r==null?void 0:r.kind)==="assistant"&&r.messageId===t?n:-1}function al(e,t,n){return e.findLastIndex(r=>r.kind==="pieces"&&r.id===t&&n.includes(r.state))}function G4(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 Nb(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 V4(e){let t=e;const n=new Set;return{getState:()=>t,dispatch(r){const o=xi(t,r);if(o!==t){t=o;for(const i of n)i()}},subscribe(r){return n.add(r),()=>n.delete(r)}}}const KS=S.createContext(null),rw=S.createContext(null),ZS=S.createContext(null);function Y4({store:e,sock:t,files:n,children:r}){return d.jsx(KS.Provider,{value:e,children:d.jsx(rw.Provider,{value:t,children:d.jsx(ZS.Provider,{value:n,children:r})})})}const qS=S.createContext(null),GS=S.createContext(null);function X4({machines:e,children:t}){const n=S.useSyncExternalStore(e.subscribe,e.active);return d.jsx(qS.Provider,{value:e,children:d.jsx(GS.Provider,{value:n,children:d.jsx(Y4,{store:n.store,sock:n.sock,files:n.files,children:d.jsx(S.Fragment,{children:t},n.origin)})})})}function ss(){const e=S.useContext(qS);if(!e)throw new Error("useMachines outside <MachinesProvider>");return e}function mo(){const e=S.useContext(GS);if(!e)throw new Error("useMachine outside <MachinesProvider>");return e}function ow(){const e=ss();return S.useSyncExternalStore(e.subscribe,e.list)}function dl(e,t){return S.useSyncExternalStore(e.store.subscribe,()=>t(e.store.getState()))}const Sg=(e,t)=>e.length===t.length&&e.every((n,r)=>n===t[r]);function VS(){const e=ss(),t=mo(),n=ow(),r=S.useMemo(()=>n.filter(c=>c!==t),[n,t]),o=S.useRef(null),i=S.useCallback(c=>{const u=r.map(h=>h.store.subscribe(c));return()=>{for(const h of u)h()}},[r]),l=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&&Sg(h.names,c)&&Sg(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(i,l)}function YS(){const e=mo(),t=ow(),n=S.useMemo(()=>t.filter(l=>l!==e),[t,e]),r=S.useRef(null),o=S.useCallback(l=>{const c=n.map(u=>u.store.subscribe(l));return()=>{for(const u of c)u()}},[n]),i=S.useCallback(()=>{const l=n.map(h=>{const f=h.store.getState();return f.connected&&!f.incompatible?f.rows:Tb}),c=r.current;if(c&&c.others===n&&Sg(c.rows,l))return c.value;const u=n.map((h,f)=>({origin:h.origin,rows:(l[f]??Tb).filter(Sn)}));return r.current={others:n,rows:l,value:u},u},[n]);return S.useSyncExternalStore(o,i)}const Tb=[];function Pq(){return mo().terminals}function Gn(){const e=S.useContext(KS);if(!e)throw new Error("useStore outside <StoreProvider>");return e}function L(e){const t=Gn();return S.useSyncExternalStore(t.subscribe,()=>e(t.getState()))}function sw(){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 ct(){return Gn().dispatch}function rt(){return S.useContext(rw)}function Ur(){const e=S.useContext(rw);return(e==null?void 0:e.urls)??Bk(location.origin,"")}function iw(){return S.useContext(ZS)}function Q4(e=!1,t=!0){const n=S.useRef(null);return S.useEffect(()=>{if(!t)return;const r=()=>{const i=n.current;!i||document.activeElement===i||(i.focus(),e&&i instanceof HTMLInputElement&&i.select())};r();const o=requestAnimationFrame(r);return()=>cancelAnimationFrame(o)},[e,t]),n}function xo(e,t,n,r=J4){const o=()=>{try{return n(r.get(e))??t}catch{return t}},[i,l]=S.useState(()=>({key:e,value:o()}));return i.key!==e&&l({key:e,value:o()}),[i.key===e?i.value:o(),h=>{l({key:e,value:h});try{r.set(e,typeof h=="boolean"?h?"1":"0":String(h))}catch{}}]}const J4={get:e=>localStorage.getItem(e),set:(e,t)=>localStorage.setItem(e,t)};function _l(e,t){return n=>{n.preventDefault(),document.body.classList.add("resizing");const r=n.currentTarget;r.classList.add("active");const o=l=>{const c=e(l,r);c!==null&&t(c)},i=()=>{document.body.classList.remove("resizing"),r.classList.remove("active"),window.removeEventListener("pointermove",o),window.removeEventListener("pointerup",i)};window.addEventListener("pointermove",o),window.addEventListener("pointerup",i)}}function XS(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 aw(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 lw=1500;function Ei(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 eD(){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 tD(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(),i=n.getBoundingClientRect(),l=parseFloat(getComputedStyle(r).getPropertyValue("--scroll-foot"))||0,c=i.bottom-(o.bottom-l);if(c<=0)return;const u=parseFloat(getComputedStyle(r).paddingTop)||0;r.scrollTop+=Math.min(c,Math.max(0,i.top-o.top-u))}),n=>{t.current=n}}const jm=40,nD=1200,rD=150,oD=new Set(["ArrowUp","ArrowDown","PageUp","PageDown","Home","End"," "]);function QS(e,t){const n=S.useRef(!0),r=S.useRef(Number.NEGATIVE_INFINITY),o=S.useRef(!1),[i,l]=S.useState(!1),[c,u]=S.useState(!1),[h,f]=S.useState(!1),[m,g]=S.useState(null),w=S.useCallback($=>{n.current=$,e.current&&(e.current.style.overflowAnchor=$?"none":"")},[e]),y=S.useRef(null),v=S.useRef(null);ft([t],()=>{n.current||f(!0)});const _=S.useCallback(()=>n.current,[]),x=S.useCallback(()=>{const $=e.current;$&&(w($.scrollHeight-$.scrollTop-$.clientHeight<jm),l(!n.current),u($.scrollTop>=jm),n.current&&f(!1))},[e,w]),T=S.useCallback($=>{Math.abs($)<4||(g($<0?"up":"down"),v.current&&clearTimeout(v.current),v.current=setTimeout(()=>g(null),nD))},[]),N=S.useCallback(()=>{const $=e.current;$&&($.scrollTop=$.scrollHeight,w(!0),l(!1),f(!1))},[e,w]),j=S.useCallback(()=>{const $=e.current;$&&(r.current=performance.now(),$.scrollTop=0)},[e]);return S.useEffect(()=>{const $=e.current;if(!$)return;w(n.current);const O=()=>o.current||performance.now()-r.current<rD,I=()=>{n.current&&!O()?u($.scrollTop>=jm):x()};$.addEventListener("scroll",I,{passive:!0});const P=()=>{r.current=performance.now()},R=H=>{P(),T(H.deltaY)},U=H=>{var V;P(),y.current=((V=H.touches[0])==null?void 0:V.clientY)??null},F=H=>{var J;P();const V=(J=H.touches[0])==null?void 0:J.clientY;V===void 0||y.current===null||(T(y.current-V),y.current=V)},B=()=>{o.current=!0},X=()=>{o.current=!1},ae=H=>{if(!oD.has(H.key))return;const V=H.target;(V===document.body||V instanceof Node&&$.contains(V))&&P()};$.addEventListener("wheel",R,{passive:!0}),$.addEventListener("touchstart",U,{passive:!0}),$.addEventListener("touchmove",F,{passive:!0}),$.addEventListener("pointerdown",B,{passive:!0}),window.addEventListener("pointerup",X,{passive:!0}),window.addEventListener("pointercancel",X,{passive:!0}),document.addEventListener("keydown",ae);const Y=()=>{$.scrollTop=$.scrollHeight},ne=new ResizeObserver(()=>{n.current&&Y()});ne.observe($);for(const H of $.children)ne.observe(H);const C=new MutationObserver(H=>{for(const V of H){for(const J of V.addedNodes)J instanceof Element&&ne.observe(J);for(const J of V.removedNodes)J instanceof Element&&ne.unobserve(J)}n.current&&Y()});return C.observe($,{childList:!0}),()=>{$.removeEventListener("scroll",I),$.removeEventListener("wheel",R),$.removeEventListener("touchstart",U),$.removeEventListener("touchmove",F),$.removeEventListener("pointerdown",B),window.removeEventListener("pointerup",X),window.removeEventListener("pointercancel",X),document.removeEventListener("keydown",ae),C.disconnect(),ne.disconnect(),v.current&&clearTimeout(v.current)}},[e,x,T,w]),{offEnd:i,offStart:c,away:h,moving:m,pinned:_,jump:N,start:j,read:x}}function jb(e,t,n){const r=document.createRange();return r.selectNodeContents(e),r.setEnd(t,n),r.toString().length}function $b(e,t){const n=document.createTreeWalker(e,NodeFilter.SHOW_TEXT);let r=0,o=null;for(let i=n.nextNode();i;i=n.nextNode()){if(r+i.data.length>=t)return[i,t-r];r+=i.data.length,o=i}return o?[o,o.data.length]:[e,0]}function JS(e,t){S.useLayoutEffect(()=>{const n=e.current;if(!n)return;const r=window.getSelection(),o=g=>!!g&&n.contains(g),i=r&&r.rangeCount>0&&o(r.anchorNode)?jb(n,r.anchorNode,r.anchorOffset):null,l=r&&r.rangeCount>0&&o(r.focusNode)?jb(n,r.focusNode,r.focusOffset):null,c=r&&(i!==null||l!==null)?[r.anchorNode,r.anchorOffset,r.focusNode,r.focusOffset]:null;if(n.innerHTML=t,!r||!c)return;const[u,h]=i===null?[c[0],c[1]]:$b(n,i),[f,m]=l===null?[c[2],c[3]]:$b(n,l);u&&f&&r.setBaseAndExtent(u,h,f,m)},[e,t])}function ft(e,t){const n=S.useRef(t);n.current=t,S.useEffect(()=>n.current(),e)}function e_(e){const[t,n]=S.useState({left:0,right:0});return S.useLayoutEffect(()=>{if(!e)return;const r=()=>{const i=e.getBoundingClientRect();let{left:l,right:c}=i;const u=e.closest("[data-pinned]");if(u){const f=u.getBoundingClientRect(),m=u.offsetWidth/f.width;l=u.offsetLeft+(l-f.left)*m,c=u.offsetLeft+(c-f.left)*m}const h={left:Math.round(l),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 Cb(){const[e,t]=S.useState(null);return[t,e_(e)]}function Lq(e){e.ctrlKey&&e.stopPropagation()}function t_(e,t){return e.defaultPrevented||e.ctrlKey?!1:t<1.01}function Dq(e){S.useEffect(()=>{const t=e.current;if(!t)return;const n=r=>{var o;t_(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 n_={axis:null,dx:0,dy:0,at:Number.NEGATIVE_INFINITY},sD=2,iD=4,aD=300;function lD(e,t,n){const r=Math.abs(t.deltaX),o=Math.abs(t.deltaY),i=r>o?"x":"y",l=n-e.at<=aD?e:n_;if(l.axis===null){const u=l.dx+r,h=l.dy+o,f=Math.max(u,h)>=sD?u>h?"x":"y":null;return{scrolls:f!==null&&f===i,next:{axis:f,dx:u,dy:h,at:n}}}return i===l.axis?{scrolls:!0,next:{...l,at:n}}:(i==="x"?r:o)>=iD?{scrolls:!0,next:{...l,axis:i,at:n}}:{scrolls:!1,next:{...l,at:n}}}function zq(e){S.useEffect(()=>{const t=e.current;if(!t)return;let n=n_;const r=o=>{var c;if(o.ctrlKey)return;const{scrolls:i,next:l}=lD(n,o,o.timeStamp);n=l,!i&&(o.stopPropagation(),t_(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 cD(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 uD(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 dD(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 fD(e,t,n){const[r,o]=S.useState(),i=S.useRef(e);return i.current=e,S.useEffect(()=>{if(!n)return;let l=!0,c;const u=()=>void i.current().then(h=>{l&&(o(h),c=setTimeout(u,t))});return u(),()=>{l=!1,clearTimeout(c)}},[t,n]),r}const Hl=()=>L(e=>e.activeId),r_=()=>XS(!L(e=>e.connected),900),hD=e=>!e.connected&&(e.connectFailure==="down"||e.connectFailure==="blocked"),o_=()=>L(hD),Ps=()=>L(e=>rn(e,e.activeId)),cw=()=>L(e=>_o(e,e.activeId)),s_=()=>L(e=>e.rows),uw=()=>L(e=>e.visible),pD=()=>L(e=>e.visibleDiscovered),mD=()=>L(e=>e.activeRepoId?e.discoveredOpen[e.activeRepoId]??!1:!1),Ab=[],gD=()=>L(e=>e.activeRepoId?e.archived[e.activeRepoId]??Ab:Ab),kD=()=>L(e=>e.activeRepoId?e.archivedOpen[e.activeRepoId]??!1:!1),wD=()=>L(e=>!(e.activeRepoId&&e.committedShut[e.activeRepoId])),yD=()=>L(e=>!!(e.activeRepoId&&e.turnOpen[e.activeRepoId])),_a=()=>L(No),dw=()=>L(nw),vD=()=>L(e=>Ii(e,e.activeRepoId)),Wl=()=>L(e=>Ii(e,ew(e))),i_=e=>L(t=>fo(t,e)),Rt=(e,t)=>L(n=>fo(n,e)[t]),bD=()=>L(e=>e.overlay),Eh=()=>L(h4),a_=()=>L(_S),vu=()=>L(p4),bu=()=>L(Do),xD=()=>L(e=>e.newProject),Na=()=>L(e=>e.touch),ED=()=>L(e=>e.draft),fw=()=>L(kl),SD=()=>L(e=>{const t=_o(e,e.activeId),n=t?e.repos.find(r=>r.id===t.repoId):null;return Lf(n)?n:null});function _D(e){return e.image?{kind:"image",blob:e.image,sig:`image:${e.image.type}:${e.image.size}`}:e.text&&WE(e.text)?{kind:"text",text:e.text,sig:`text:${e.text}`}:null}function ND(){try{return localStorage.getItem(Ke.clipboardOffer)==="1"}catch{return!1}}let Os={access:"none",on:typeof localStorage<"u"&&ND(),offer:null},_g="";const Ng=new Set;function Sh(e){Os={...Os,...e};for(const t of Ng)t()}async function TD(){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 _D({image:e,text:t})}async function _h({taken:e=!1,asking:t=!1}={}){if(!Os.on||!(Os.access==="granted"||t&&Os.access==="prompt"))return;let n;try{n=await TD()}catch{return}e&&(_g=(n==null?void 0:n.sig)??""),Sh({offer:n&&n.sig!==_g?n:null})}const jD=()=>void _h();let Ib=!1;function $D(){var e,t;Ib||(Ib=!0,!(!((e=navigator.clipboard)!=null&&e.read)||!((t=navigator.permissions)!=null&&t.query))&&navigator.permissions.query({name:"clipboard-read"}).then(n=>{const r=()=>{Sh({access:n.state,...n.state==="denied"?{offer:null}:{}})};n.onchange=r,r(),window.addEventListener("focus",jD),document.hasFocus()&&_h()},()=>{}))}function CD(e){return Ng.add(e),$D(),()=>{Ng.delete(e)}}const AD=()=>Os;function ID(e){try{localStorage.setItem(Ke.clipboardOffer,e?"1":"0")}catch{}Sh({on:e,offer:null}),e&&_h({asking:!0})}function l_(){Os.offer&&(_g=Os.offer.sig),Sh({offer:null})}const RD=()=>void _h({taken:!0});function OD(){return S.useSyncExternalStore(CD,()=>Os.offer)}const c_="application/x-toyon-source";function Fq(e){const t=e.endColumn===1&&e.endLineNumber>e.startLineNumber?e.endLineNumber-1:e.endLineNumber;return{startLine:e.startLineNumber,endLine:t}}function MD(e,t){e.setData(c_,JSON.stringify(t))}const Rb=e=>typeof e=="number"&&Number.isInteger(e)&&e>=1;function PD(e,t){const n=e.getData(c_);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:i,ref:l}=r;return!Rb(o)||!Rb(i)||i<o?null:{path:r.path,startLine:o,endLine:i,...typeof l=="string"?{ref:l}:{}}}const u_=e=>({left:e.x,top:e.y,right:e.x,bottom:e.y});function LD(e,t){return t.matchWidth===void 0?void 0:Math.max(0,e.right-e.left+t.matchWidth)}const DD=new Set(["top","bottom"]),$m={top:"bottom",bottom:"top",left:"right",right:"left"};function Cm(e,t,n,r,o){const i=n==="top"||n==="left";return o?i?e.end+r-t:e.start-r:i?e.start-r-t:e.end+r}function Ob(e,t,n,r,o){return n==="top"||n==="left"?e>=o:e+t<=r-o}function Am(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 Mb(e,t,n,r,o){return n==="start"?e+t<=r-o:e>=o}const Pb=(e,t,n,r)=>n||!r?e:t,Lb=(e,t,n,r)=>Math.max(r,Math.min(e,n-r-t));function zD(e,t,n,r){const{offset:o=0,alignOffset:i=0,cover:l=!1,flip:c="none",margin:u=8}=r,h=DD.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 _=Cm(f.a,f.size,g,o,l),x=Cm(f.a,f.size,$m[g],o,l);g=Pb(g,$m[g],Ob(_,f.size,g,f.limit,u),Ob(x,f.size,$m[g],f.limit,u))}let w=r.align??"center";if((c==="align"||c==="both")&&w!=="center"){const _=w==="start"?"end":"start",x=Am(m.a,m.size,w,i),T=Am(m.a,m.size,_,i);w=Pb(w,_,Mb(x,m.size,w,m.limit,u),Mb(T,m.size,_,m.limit,u))}const y=Lb(Cm(f.a,f.size,g,o,l),f.size,f.limit,u),v=Lb(Am(m.a,m.size,w,i),m.size,m.limit,u);return h?{x:v,y,side:g,align:w}:{x:y,y:v,side:g,align:w}}function FD(e,t,n){var i,l;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&&((i=e[o])!=null&&i.disabled);c++)o=(o+n+r)%r;return(l=e[o])!=null&&l.disabled?-1:o}const d_={sep:!0},gs=e=>!("sep"in e);function Nh(e){const t=[];for(const n of e)(gs(n)||t.length>0&&gs(t[t.length-1]))&&t.push(n);for(;t.length>0&&!gs(t[t.length-1]);)t.pop();return t}const Dn=e=>Nh(e.flatMap((t,n)=>n?[d_,...t]:t));let ll=null,BD=0;const Tg=new Set,Db=()=>{for(const e of Tg)e()},co={get:()=>ll,subscribe(e){return Tg.add(e),()=>{Tg.delete(e)}},open(e){const t=Nh(e.items);if(t.length===0)return co.close();ll={...e,items:t,id:++BD},Db()},close(){ll&&(ll=null,Db())},toggle(e){ll&&ll.target===e.target?co.close():co.open(e)}};function hw(){return S.useSyncExternalStore(co.subscribe,co.get)}function f_(e){const t=e.nativeEvent;return t&&"pointerType"in t?t.pointerType==="":e.clientX===0&&e.clientY===0}function UD(e,t){return f_(e)?{anchor:(t.querySelector('[data-state~="cursor"]')??t).getBoundingClientRect()}:{at:{x:e.clientX,y:e.clientY}}}function HD(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:u_(e.at??{x:0,y:0}),placement:{side:"bottom",align:"start",margin:4}}}function wn(e){return S.useMemo(()=>({contextMenu(t,n){return{onContextMenu:r=>{const o=Nh(t(f_(r)?"keyboard":"pointer",r.target));if(o.length===0)return;r.preventDefault(),r.stopPropagation();const i=r.currentTarget;co.open({items:o,owner:e,key:n,target:i,...UD(r,i)})}}},dropdown(t,n="left",r,o){return{"aria-haspopup":"menu",onClick:i=>{i.stopPropagation();const l=i.currentTarget;co.toggle({items:t(),...o?{head:o()}:{},owner:e,key:r,target:l,toggles:!0,anchor:l.getBoundingClientRect(),align:n})}}},openUnder(t,n,r){co.open({items:n(),owner:e,key:r,target:t,toggles:!0,anchor:t.getBoundingClientRect(),align:"left"})}}),[e])}const h_=e=>({id:"open-out",label:Gk()?"open in the browser":"open in a new tab",onClick:()=>window.open(e,"_blank")}),Yt=e=>{var t;return void((t=navigator.clipboard)==null?void 0:t.writeText(e).catch(()=>{}))};function p_(e,t){const n=navigator.clipboard;if(n){if(typeof ClipboardItem>"u"||!n.write){e==="text/plain"&&t.then(r=>r.text()).then(Yt,()=>{});return}n.write([new ClipboardItem({[e]:t})]).catch(()=>{})}}const m_=e=>p_("text/plain",fetch(e).then(t=>t.blob())),WD=e=>p_("image/png",KD(e));async function KD(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,i)=>r.toBlob(l=>l?o(l):i(new Error("could not encode image")),"image/png"))}finally{n.close()}}function ZD(e){return Nk(e)}function rs(e){return(e==null?void 0:e.urls.host)??(typeof location=="object"?location.hostname:"127.0.0.1")}function os(e,t,n="reveal in Finder"){return!e||!ZD(t)?[]:[{id:"reveal",label:n,onClick:e}]}function qD(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??""}
99
- ${n.sort().join(`
100
- `)}`}function Th(e,t,{sock:n,dispatch:r}){var l,c;if(!n)return;const o=t.local[e]??Sa,i=qD((l=o.git)==null?void 0:l.head,((c=o.git)==null?void 0:c.files)??[]);o.filesFor!==i&&(r({a:"files-asked",worktreeId:e,key:i}),n.send({t:"list-files",worktreeId:e}))}const GD=["diff","file","preview"],g_=(e,t)=>GD.filter(n=>!(n==="preview"&&!kh(e))&&!(n==="diff"&&t));let VD=0;const Lo=()=>++VD;function Ln({dispatch:e},{focus:t=!0,...n}){e({a:"open-file",v:{...n,focus:t,seq:Lo()}})}const jg=new Map;function k_(e,t,n=""){const{sock:r}=e;if(!r)return Promise.resolve("not connected to the daemon");const o=Lo();return new Promise(i=>{jg.set(o,l=>{l.ok?(Ln(e,{...t,view:ji(t.path)}),i(null)):i(l.reason==="changed"?"a file is already there":l.message??"the file was not made")}),r.send({t:"write-file",...t,content:n,base:null,seq:o})})}function YD(e){const t=jg.get(e.seq);return t?(jg.delete(e.seq),t(e),!0):!1}function XD({dispatch:e},t){e({a:"tree-reveal",...t})}function Is(e,t,{discard:n=!1,ref:r,since:o,showing:i,noDiff:l=!1,kept:c=!1,select:u},h){const{sock:f,dispatch:m}=h,g=g_(t,l).filter(T=>T!==i).map(T=>({id:`view:${T}`,label:`view ${T}`,onClick:()=>i?m({a:"editor-view",v:T}):Ln(h,{worktreeId:e.id,path:t,view:T,ref:r,since:o})})),w=`${e.dir}/${t}`,y=c?[]:os(()=>f==null?void 0:f.send({t:"reveal",worktreeId:e.id,path:t}),rs(f));return Dn([g,[{id:"copy-path",label:"copy path",onClick:()=>Yt(w)}],y,u?[{id:"select",label:"select…",onClick:()=>u(t)}]:[],n?[{id:"discard",label:"discard changes…",danger:!0,onClick:()=>{window.confirm(w_([t]))&&(f==null||f.send({t:"discard-files",worktreeId:e.id,paths:[t]}))}}]:[]])}function w_(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(`
101
- `);return`Discard uncommitted changes to ${e.length} files?
102
-
103
- ${r}`}const Eo=(e,t,n)=>e.dispatch({a:"notice",id:t,text:n});function jh(e,t,n){var o;const r=OC(((o=e.getState().local[t])==null?void 0:o.attachments)??[],n);return r===0&&Eo(e,t,Ek(n)),r}const QD=1e3,JD=1e4,y_=new WeakMap;function ez(e,t){y_.set(e,t)}async function v_(e,t,n,r){var y,v;const{local:o,...i}=n;e.dispatch({a:"attach",id:t,items:[{...n,upload:"",uploading:!0}]});const l=()=>{var _;return(_=Object.entries(e.getState().local).find(([,x])=>x.attachments.some(T=>T.key===n.key)))==null?void 0:_[0]},c=y_.get(e);let u=-1;const h=_=>{const x=Math.min(99,Math.floor(_*100)),T=l();x===u||T===void 0||(u=x,e.dispatch({a:"upload-progress",id:T,key:n.key,progress:x}))},f=()=>(u=-1,c?aL(c,n.kind,r,h):Promise.resolve(null));let m=await f();const g=m===null;g&&Eo(e,l()??t,`${n.name}: Toyon is not answering; it attaches once it is back`);for(let _=QD;m===null&&l()!==void 0;_=Math.min(_*2,JD))await new Promise(x=>setTimeout(x,_)),l()!==void 0&&(m=await f());const w=l();if(!(m===null||w===void 0))if(typeof m=="string")e.dispatch({a:"detach",id:w,key:n.key}),Eo(e,w,`${n.name}: ${m}`);else{const _=i.kind==="file"?{...i,...m}:{...i,upload:m.upload,bytes:m.bytes};e.dispatch({a:"attached",id:w,key:n.key,item:_});const x=(v=e.getState().local[((y=ms(w))==null?void 0:y.source)??w])==null?void 0:v.notice;g&&(x!=null&&x.startsWith(`${n.name}: Toyon is not answering`))&&Eo(e,w,"")}o&&URL.revokeObjectURL(o)}function pw(e,t,n){if(!t||n.length===0)return;const r=jh(e,t,"file");if(r!==0){for(const o of n.slice(0,r)){const i=o.name||"file";if(o.size>cb){Eo(e,t,`${i}: larger than ${_k(cb)}`);continue}const l={kind:"file",key:crypto.randomUUID(),upload:"",name:i,bytes:o.size,text:!1};v_(e,t,l,o)}n.length>r&&Eo(e,t,`kept ${r} of ${n.length}: ${Ek("file")}`)}}function mw(e,t,n,r={}){if(!t)return;const o=QM(r.source?n.replace(/\r?\n$/,""):n);if(o.length>WM)return r.source?Eo(e,t,"that paste is too large; save it in the worktree and reference it with @path"):pw(e,t,[new File([o],KM,{type:"text/plain"})]);jh(e,t,"paste")!==0&&e.dispatch({a:"attach",id:t,items:[{kind:"paste",key:crypto.randomUUID(),text:o,...r,...Lk(o)}]})}function b_(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 zb(e,t){var i;const n=e.getState(),r=rn(n,n.activeId),o=Ul(r);if(t&&o&&t.worktreeId===(r==null?void 0:r.worktree.id)&&t.text.trim()){const l="source"in t?{source:t.source}:{name:t.name};(((i=n.local[o])==null?void 0:i.attachments)??[]).some(u=>{var w;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((w=u.source)==null?void 0:w.path)===h&&u.source.startLine===f&&u.source.endLine===m&&u.source.ref===g})||mw(e,o,t.text,l)}e.dispatch(t?{a:"focus-chat"}:NS(n))}function gw(e,t){return t!==e.activeId?null:Ul(rn(e,t))}const x_=(e,t)=>`@${e}${t?"/":""}`,kw=e=>`${e.map(t=>x_(t.path,t.folder)).join(" ")} `;function E_(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 S_(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:E_(r,r.length,n).text}),e.dispatch({a:"focus-chat"})}function ww(e,t,n){const r=gw(e.getState(),t);r&&S_(e,r,n)}function tz(e,t,n,r){ww(e,t,kw([{path:n,folder:r}]))}function nz(e,t,n){n.length!==0&&ww(e,t,kw(n.map(r=>({path:r,folder:!1}))))}function Fb(e,t,n){ww(e,t,n)}function rz(e,t){return rn(e,t)?t:null}function oz(e,t){var r;const n=(r=rn(e,t))==null?void 0:r.worktree;return n?[n.path]:[]}function Bb(e,t){if(!e)return e;const n=t.find(r=>e.startsWith(`${r}/`));return n?e.slice(n.length+1):e}function sz(e,t,n){var g;e.dispatch({a:"set-picking",v:!1});const r=e.getState(),o=rz(r,t);if(!o)return;const{classes:i,route:l,element:c,...u}=n,h=oz(r,t),f={...u,file:Bb(u.file,h),callFile:Bb(u.callFile,h)};!(((g=r.local[o])==null?void 0:g.attachments)??[]).some(w=>w.kind==="pick"&&w.selector===f.selector)&&jh(e,o,"pick")>0&&e.dispatch({a:"attach",id:o,items:[{kind:"pick",key:crypto.randomUUID(),...f}]}),e.dispatch({a:"focus-chat"})}function iz(e,t=[],n=[]){const r={path:"",name:"",kind:"folder",children:[],ignored:!1},o=new Map([["",r]]),i=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 i(f===-1?"":u.slice(0,f)).children.push(m),o.set(u,m),m},l=(u,h,f=!1)=>{const m=u.lastIndexOf("/");i(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)l(u,"file");for(const u of t)l(u,"submodule");for(const u of n)u.endsWith("/")?l(u.slice(0,-1),"ignored",!0):l(u,"file",!0);const c=u=>{const h=f=>f.kind==="file"?1:0;u.children.sort((f,m)=>h(f)-h(m)||gS(f.name,m.name));for(const f of u.children)f.kind==="folder"&&c(f)};return c(r),r.children}function az(e,t){const n=[],r=(o,i)=>{for(const l of o){const c=l.kind==="folder"&&t(l.path);n.push({path:l.path,name:l.name,depth:i,kind:l.kind,open:c,ignored:l.ignored}),c&&r(l.children,i+1)}};return r(e,0),n}const __=e=>{const t=e.lastIndexOf("/");return t===-1?"":e.slice(0,t)};function lz(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 cz(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 i of Pf(o))n.add(i)}return{files:t,folders:n}}function uz(e){const t=e.findLast(n=>n.kind==="pieces"&&n.state!=="declined");return(t==null?void 0:t.kind)==="pieces"?t:null}function dz(e){return!!e.plan&&!e.companion}function $h(e,t){return e.fates[t.id]??t.fate}function yw(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 N_(e){const t={worktrees:0,queued:0,sent:0,here:0,skipped:0};for(const n of e.pieces){const r=$h(e,n);r==="worktree"?n.after?t.queued++:t.worktrees++:r==="send"?t.sent++:r==="here"?t.here++:t.skipped++}return t}const T_=(e,t,n=`${t}s`)=>`${e} ${e===1?t:n}`,fz=e=>e.length<=1?e[0]??"":`${e.slice(0,-1).join(", ")} and ${e.at(-1)}`;function hz(e,t){const n=N_(e),r=[];if(n.here&&r.push("this plan here"),n.worktrees&&r.push(`${T_(n.worktrees,"worktree")} now`),n.queued){const i=e.pieces.filter(u=>$h(e,u)==="worktree"&&u.after),l=i.every(u=>u.after&&"id"in u.after&&u.after.id===t),c=i.length===1?yw(e,i[0]):null;r.push(l?`${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 ${fz(r)}${o}.`}function $g(e){var i;const t=e.pieces.length===1?e.pieces[0]:void 0;if(t)return t.fate==="send"?`Send ${t.title} to ${((i=t.to)==null?void 0:i.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=N_(e),o=[n.worktrees?`start ${T_(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 pz(e,t){var c;const n=yw(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}`,notes:!0}:{fate:"worktree",label:n?"queue a worktree":"start a worktree",description:`a copy of this project, with this text as its plan${r}`,notes:!0},i={fate:"here",label:"do it here",description:"this worktree's agent, after its turn",notes:!1},l={fate:null,label:"not now",notes:!1};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",notes:!0},l]:t.fate==="here"?[i,o,l]:t.project?[o,l]:[o,i,l]}function j_(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 mz(e,t,n){var r;if(t==="worktree"){const o=e.project?` in ${e.project.name}`:"",i=n?`, once ${n.kind==="branch"?n.branch:n.title} lands`:"";return`Starts as a new worktree${o}${i}, 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 this piece."}function Ub(e,t,n,r){const o=n?r==null?void 0:r.trim():void 0;return{t:"pieces-answer",worktreeId:t,id:e.id,go:n,...o?{note:o}:{}}}function $_(e,t,n,r){return{t:"pieces-fate",worktreeId:t,id:e.id,pieceId:n,fate:r}}function gz(e){return e.fate==="send"?["send","skip"]:e.project?["worktree","skip"]:["here","worktree","skip"]}function vw(e){const t=e.findLast(n=>n.kind==="ask"&&!n.outcome||n.kind==="pieces"&&n.state==="proposed");return(t==null?void 0:t.kind)==="ask"||(t==null?void 0:t.kind)==="pieces"?t:null}function kz(e){const t=e?vw(e.chat):null;return(t==null?void 0:t.kind)!=="ask"||t.ask.kind!=="question"||(e==null?void 0:e.cardParked)===t.id?null:bl(t.id)}function wz(e){return e.kind==="ask"?_L(e):$g(e)}const C_=new Set(BM),yz=/^image\.[a-z0-9]+$/i,vz=e=>yz.test(e.name),bz=(e,t)=>e===t||e.name===t.name&&e.size===t.size&&e.type===t.type&&e.lastModified===t.lastModified;function xz(e){if(!e)return[];const t=[];for(const i of Array.from(e.items??[])){if(i.kind!=="file"||!i.type.startsWith("image/"))continue;const l=i.getAsFile();l&&t.push(l)}if(t.length===0)for(const i of Array.from(e.files??[]))i.type.startsWith("image/")&&t.push(i);const n=[];for(const i of t)n.some(l=>bz(l,i))||n.push(i);const r=n.filter(i=>!vz(i));if(r.length>0)return r;const o=n.find(i=>C_.has(i.type))??n[0];return o?[o]:[]}function Ez(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 Sz(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 _z(e){try{return await createImageBitmap(e)}catch{throw new Error(`${e.name||"image"}: not a readable image`)}}function Hb(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,i)=>r.toBlob(l=>l?o(l):i(new Error("could not encode image")),n,.9))}async function Nz(e){const t=await _z(e);try{const n=Math.max(t.width,t.height);let r=e,o=e.type,i=t.width,l=t.height;if(!C_.has(o)||n>lb||e.size>Tm){const c=o==="image/jpeg"?"image/jpeg":"image/png";let u=Math.min(1,lb/n);for(r=await Hb(t,u,c);r.size>Tm&&u>.1;)u*=.7,r=await Hb(t,u,c);if(r.size>Tm)throw new Error(`${e.name||"image"}: too large even after downscaling`);o=c,i=Math.max(1,Math.round(t.width*u)),l=Math.max(1,Math.round(t.height*u))}return{blob:r,name:e.name||`pasted.${o==="image/jpeg"?"jpg":"png"}`,mimeType:o,width:i,height:l}}finally{t.close()}}const Hc={el:null},Tz=80,jz=2e3;let So=null,Cg;const A_=(e,t)=>{clearTimeout(Cg),Cg=setTimeout(()=>xw(e),t)};function bw(e,t){So??(So={refused:!1}),e.dispatch({a:"drag-files",v:So.refused?null:t}),A_(e,jz)}function I_(e){So&&A_(e,Tz)}const $z=()=>(So==null?void 0:So.refused)??!1;function xw(e){So&&(clearTimeout(Cg),So=null,e.dispatch({a:"drag-files",v:null}))}function Cz(e){So&&(So.refused=!0,e.dispatch({a:"drag-files",v:null}))}let Az=0;function Iz(e){const{blob:t,...n}=e;return{kind:"image",key:`img${++Az}`,...n,upload:"",bytes:t.size,local:URL.createObjectURL(t)}}async function Ch(e,t,n){var l;if(!t||n.length===0)return;const r=jh(e,t,"image");if(r===0)return;const o=await Promise.allSettled(n.slice(0,r).map(Nz));for(const c of o)c.status==="fulfilled"&&v_(e,t,Iz(c.value),c.value.blob);const i=o.find(c=>c.status==="rejected");i?Eo(e,t,String(((l=i.reason)==null?void 0:l.message)??i.reason)):n.length>r&&Eo(e,t,`kept ${r} of ${n.length}: ${Ek("image")}`)}function Rz(e,t,n){n.kind==="image"?Ch(e,t,[new File([n.blob],"image.png",{type:n.blob.type})]):mw(e,t,n.text),l_()}function zf(e,t,n){const r=o=>o.type.startsWith("image/");Ch(e,t,n.filter(r)),pw(e,t,n.filter(o=>!r(o)))}function R_(e,t){const n=document.createElement("input");n.type="file",n.multiple=!0,n.onchange=()=>zf(e,t,Array.from(n.files??[])),n.click()}function Ta(e){const t=e.getState();if(t.newProject)return Al;const n=No(t)??nw(t);if(n)return n.id;const r=rn(t,t.activeId);return kz(r?t.local[r.worktree.id]:void 0)??Ul(r)}function O_(e,t,n=Ta(e)){zf(e,n,t.filter(o=>!o.folder).map(o=>o.file));const r=t.find(o=>o.folder);n&&r&&Eo(e,n,`${r.file.name}: a folder cannot be attached; drop its files`)}const Ag=Promise.resolve(null);function Oz(e){var n,r,o;if(!e)return[];const t=[];for(const i of Array.from(e.items)){if(i.kind!=="file")continue;const l=i.getAsFile();if(!l)continue;const c=((n=i.getAsFileSystemHandle)==null?void 0:n.call(i).then(u=>(u==null?void 0:u.kind)==="file"?u:null,()=>null))??Ag;t.push({file:l,handle:c,folder:((o=(r=i.webkitGetAsEntry)==null?void 0:r.call(i))==null?void 0:o.isDirectory)===!0})}if(t.length===0)for(const i of Array.from(e.files))t.push({file:i,handle:Ag});return t}const Mz=e=>e.map(t=>({file:t,handle:Ag}));async function M_(e){const t=If*4;if(e.size>t)return{text:"",tooLarge:!0};const n=await Sz(e,t);return n===null?null:n.length>If?{text:"",tooLarge:!0}:{text:n,tooLarge:!1}}async function Pz(e,t){const n=Ta(e),r=e.getState().activeId,o=f=>n&&Eo(e,n,f),i=t.filter(f=>f.file.type.startsWith("image/")).map(f=>f.file);i.length&&Ch(e,n,i);const l=t.filter(f=>!f.file.type.startsWith("image/")),c=l[0];if(!c||!r)return;const u=await M_(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:Lo()}}),l.length>1&&o(`opened ${c.file.name}; one file opens at a time`)}async function Lz(e,t,n,r){const o=gw(e.getState(),n.worktreeId)??Ta(e),i=c=>o&&Eo(e,o,c),l={sock:t,dispatch:c=>e.dispatch(c)};for(const{file:c}of r){const u=await M_(c);if(!u){i(`${c.name}: not a text file`);continue}if(u.tooLarge){i(`${c.name}: too large to add here`);continue}const h=n.dir?`${n.dir}/${c.name}`:c.name,f=await k_(l,{worktreeId:n.worktreeId,path:h},u.text);f&&i(`${c.name}: ${f}`)}}function Dz(e){const t=Ta(e);t&&Eo(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 P_(e,t,n,r){const o=(So==null?void 0:So.refused)??!1;xw(e),!(o||r.length===0)&&(n?n.at==="chat"||n.at==="centre"&&e.getState().newProject?O_(e,r):n.at==="centre"?Pz(e,r):n.at==="rail"?zz(e,n,r):Lz(e,t,n,r):Dz(e))}function zz(e,t,n){const r=rn(e.getState(),t.worktreeId);r&&(e.dispatch(_r(r.worktree)?{a:"open-draft"}:{a:"activate",id:r.worktree.id}),O_(e,n,Ul(r)))}const Ig=e=>!!e&&Array.from(e.types).includes("Files");function Wb(e,t){var c,u;const n=t instanceof Element?t:t instanceof Node?t.parentElement:null;if(!n)return null;if((c=Hc.el)!=null&&c.contains(n))return Ta(e)?{at:"chat"}:null;const r=(u=n.closest(".rail [data-wt]"))==null?void 0:u.dataset.wt;if(r)return rn(e.getState(),r)?{at:"rail",worktreeId:r}:null;const o=n.closest(".tree"),i=o==null?void 0:o.dataset.worktree;if(o&&i){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:i,dir:f==="file"?__(m):m}}if(!n.closest(".center-root")||n.closest('[data-pane="terminal"], [data-pane="design"]'))return null;const l=e.getState();return l.activeId||l.newProject?{at:"centre"}:null}function Fz(){const e=Gn(),t=rt();S.useEffect(()=>{const n=l=>{l.defaultPrevented||!Ig(l.dataTransfer)||(l.preventDefault(),bw(e,Wb(e,l.target)),l.dataTransfer&&(l.dataTransfer.dropEffect=e.getState().dragFiles?"copy":"none"))},r=l=>{l.defaultPrevented||!Ig(l.dataTransfer)||(l.preventDefault(),P_(e,t,Wb(e,l.target),Oz(l.dataTransfer)))},o=()=>I_(e),i=l=>{l.key==="Escape"&&Cz(e)};return window.addEventListener("dragover",n),window.addEventListener("drop",r),window.addEventListener("dragleave",o),window.addEventListener("keydown",i,!0),()=>{window.removeEventListener("dragover",n),window.removeEventListener("drop",r),window.removeEventListener("dragleave",o),window.removeEventListener("keydown",i,!0)}},[e,t])}function L_(e,t,n){const r=Gn(),o=S.useRef(!1);return{onPaste:u=>{RD();const h=xz(u.clipboardData);if(h.length>0)return u.preventDefault(),void Ch(r,e,h);const f=Ez(u.clipboardData);if(f.length>0)return u.preventDefault(),pw(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()?PD(u.clipboardData,t):null;!(g&&m.includes(`
104
- `))&&!WE(m)||(u.preventDefault(),mw(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 Bz(e,t,n){const r=S.useRef(n);r.current=n,S.useEffect(()=>{const o=e.current;if(!o)return;const i=l=>{const{inputType:c,data:u,isComposing:h}=l;l.target!==t.current||h||!u||c!=="insertText"&&c!=="insertFromPaste"||r.current(u)&&l.preventDefault()};return o.addEventListener("beforeinput",i),()=>o.removeEventListener("beforeinput",i)},[e,t])}const Uz=640,Hz=1e3,D_=`(max-width: ${Uz}px), ((hover: none) and (max-width: ${Hz}px))`,z_="(hover: none)",Ew=()=>{var e;return(e=window.matchMedia)!=null&&e.call(window,D_).matches?"phone":"desk"},Wz=()=>{var e;return((e=window.matchMedia)==null?void 0:e.call(window,z_).matches)??!1},F_=()=>window.top!==window;function Kz(e){const t=(o,i)=>{var u;const l=(u=window.matchMedia)==null?void 0:u.call(window,o);if(!l)return()=>{};const c=h=>i(h.matches);return l.addEventListener("change",c),()=>l.removeEventListener("change",c)},n=t(D_,o=>e.dispatch({a:"frame",v:o?"phone":"desk"})),r=t(z_,o=>e.dispatch({a:"touch",v:o}));return()=>{n(),r()}}const B_=(e,t)=>{const n=e.indexOf("#"),[r,o]=n===-1?[e,""]:[e.slice(0,n),e.slice(n)];return`${r}${r.includes("?")?"&":"?"}${rA}=${encodeURIComponent(t)}${o}`},Rg=(e,t)=>!e.serving&&t!==null,Zz=3e3;function U_(e,t,n){const[r,o]=S.useState(()=>new Map),i=S.useRef(new Set),l=S.useRef(t);l.current=t;const c=S.useRef(new Map),u=S.useCallback((h,f)=>{i.current.has(h)||(i.current.add(h),iS(e.sock.urls).then(m=>{if(i.current.delete(h),!!l.current.some(w=>w.id===h&&w.url===f)){if(!m){c.current.set(h,setTimeout(()=>{c.current.delete(h),l.current.some(w=>w.id===h&&w.url===f)&&u(h,f)},Zz));return}o(w=>new Map(w).set(h,{url:f,src:B_(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 qz(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}]),U_(e,r.current,n).urlOf("one")}function Gz(e,t,n){if(!n){window.open(t,"_blank");return}const r=window.open("","_blank");iS(e.sock.urls).then(o=>{const i=o?B_(t,o.code):t;r?r.location.href=i:window.open(i,"_blank")})}function He(...e){return e.filter(Boolean).join(" ")}const Vz={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",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.5 8h3.3 M5.8 8c2.2 0 2.2-3.6 4.4-3.6h1.5 M5.8 8c2.2 0 2.2 3.6 4.4 3.6h1.5 M12.05 4.4a.45 .45 0 1 0 .9 0a.45 .45 0 1 0-.9 0z M12.05 11.6a.45 .45 0 1 0 .9 0a.45 .45 0 1 0-.9 0z",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.8 2.95a1.05 1.05 0 1 0 0 2.1 1.05 1.05 0 1 0 0-2.1z M7.4 4h5.4 M3.8 6.95a1.05 1.05 0 1 0 0 2.1 1.05 1.05 0 1 0 0-2.1z M7.4 8h5.4 M3.8 10.95a1.05 1.05 0 1 0 0 2.1 1.05 1.05 0 1 0 0-2.1z 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",dot:"M8 4.6a3.4 3.4 0 1 0 0 6.8 3.4 3.4 0 1 0 0-6.8z"};function _t({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:Vz[e]})})}function Ml({size:e="inline",className:t}){return d.jsxs("span",{className:He("spinner",e==="dot"&&"spinner-dot",t),"aria-hidden":"true",children:[d.jsx("span",{}),d.jsx("span",{}),d.jsx("span",{}),d.jsx("span",{})]})}const Yz='button, a[href], input, textarea, select, summary, label, [role="button"], [role="menuitem"]';function Kb(e){var n;const t=e;return((n=t==null?void 0:t.closest)==null?void 0:n.call(t,Yz))??t??null}function Xz(e,t){var r,o,i;if(e.box.contains(t)||(r=e.trigger)!=null&&r.contains(t))return!0;const n=(i=(o=t.closest)==null?void 0:o.call(t,"[aria-controls]"))==null?void 0:i.getAttribute("aria-controls");return!!n&&n===e.box.id}function Qz(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 Jz(e,t){const n=new Set;for(const r of e)if(Xz(r,t))for(let o=r;o;o=o.parent)n.add(o);return e.filter(r=>!n.has(r)&&r.dismiss).reverse()}const e3=e=>{setTimeout(e,0)};function t3({schedule:e=e3}={}){let t=[],n=null,r=!1;const o=new Set,i=()=>{for(const c of[...o])c()},l=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:Qz(t,c.from??u),dismiss:c.dismiss,onKey:c.onKey,back:c.back};return t=[...t,h],i(),h},unregister(c){t=t.filter(u=>u!==c),i()},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 T;const _=v.target,x=_?Jz(t,_):[];for(const N of x)(T=N.dismiss)==null||T.call(N,"outside");r=x.length>0&&v.pointerType==="touch",r&&v.preventDefault(),n=Kb(v.target)},f=()=>e(()=>n=null),m=()=>{r=!1,f()},g=v=>{if(r){r=!1,v.preventDefault(),v.stopPropagation();return}n||(n=Kb(v.target),f())},w=v=>{var x;const _=t[t.length-1];(x=_==null?void 0:_.onKey)==null||x.call(_,v)},y=()=>e(()=>{var v;((v=u.activeElement)==null?void 0:v.tagName)==="IFRAME"&&l("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",w,!0),c.addEventListener("blur",y),()=>{u.removeEventListener("pointerdown",h,!0),u.removeEventListener("pointerup",f,!0),u.removeEventListener("pointercancel",m,!0),u.removeEventListener("click",g,!0),c.removeEventListener("keydown",w,!0),c.removeEventListener("blur",y)}}}}const Pl=t3(),n3=()=>Pl.open().some(e=>!!e.dismiss);function r3(){return S.useSyncExternalStore(Pl.watch,n3,()=>!1)}const Im=typeof HTMLElement<"u"&&"showPopover"in HTMLElement.prototype,Zb=e=>(e==null?void 0:e.getBoundingClientRect())??null;function o3(e,t,n,r){const o=e.querySelector(t);if(!o)return null;const i=e.getBoundingClientRect(),l=o.getBoundingClientRect();return{offset:n==="top"?i.bottom-l.bottom:l.top-i.top,alignOffset:r==="end"?i.right-l.right:l.left-i.left}}function Ls({className:e,anchor:t,placement:n,coverBy:r,track:o=t==="parent",raiseKey:i,onDismiss:l,onKey:c,onBack:u,trigger:h,from:f,boxRef:m,handle:g,children:w,...y}){const v=S.useRef(null),_=S.useRef({anchor:t,placement:n,coverBy:r,onDismiss:l,onKey:c,onBack:u,trigger:h,from:f});_.current={anchor:t,placement:n,coverBy:r,onDismiss:l,onKey:c,onBack:u,trigger:h,from:f};const x=S.useCallback(()=>{const N=v.current,{anchor:j,placement:$,coverBy:O}=_.current;if(!N||!j||!$)return;const I=j==="parent"?Zb(N.parentElement):j();if(!I)return;const P=LD(I,$);P!==void 0&&(N.style.width=`${P}px`);for(let R=0;R<2;R++){const U=O?o3(N,O,N.dataset.side??"",N.dataset.align??""):null,F=zD(I,{w:N.offsetWidth,h:N.offsetHeight},{w:window.innerWidth,h:window.innerHeight},U?{...$,...U}:$);N.style.left=`${F.x}px`,N.style.top=`${F.y}px`;const B=N.dataset.side!==F.side||N.dataset.align!==F.align;if(N.dataset.side=F.side,N.dataset.align=F.align,!B)break}},[]);S.useImperativeHandle(g,()=>({update:x}),[x]),S.useLayoutEffect(()=>{const N=v.current;if(!N)return;m&&(m.current=N),Im&&(N.popover="manual",N.matches(":popover-open")||N.showPopover());const{onDismiss:j,onKey:$,onBack:O,trigger:I,from:P}=_.current,R=j||$?Pl.register({box:N,trigger:I,from:P,dismiss:j?U=>{var F,B;return(B=(F=_.current).onDismiss)==null?void 0:B.call(F,U)}:void 0,onKey:$?U=>{var F,B;return(B=(F=_.current).onKey)==null?void 0:B.call(F,U)}:void 0,back:O?()=>{var U,F;return(F=(U=_.current).onBack)==null?void 0:F.call(U)}:void 0}):null;return()=>{R&&Pl.unregister(R),m&&(m.current=null),Im&&N.isConnected&&N.matches(":popover-open")&&N.hidePopover()}},[m]),S.useLayoutEffect(x),S.useLayoutEffect(()=>{if(!o)return;let N=0,j="";const $=()=>{const O=v.current,{anchor:I}=_.current,P=O&&I?I==="parent"?Zb(O.parentElement):I():null;if(O&&P){const R=`${P.left},${P.top},${P.right},${P.bottom},${O.offsetWidth},${O.offsetHeight},${window.innerWidth},${window.innerHeight}`;R!==j&&(j=R,x())}N=requestAnimationFrame($)};return N=requestAnimationFrame($),()=>cancelAnimationFrame(N)},[o,x]);const T=S.useRef(!0);return ft([i],()=>{if(T.current){T.current=!1;return}const N=v.current;!Im||!(N!=null&&N.matches(":popover-open"))||(N.hidePopover(),N.showPopover(),x())}),d.jsx("div",{ref:v,className:He("float",e),...y,children:w})}const s3=/^[⌘⇧⌥⌃]+/;function es({k:e,chip:t=!1,className:n}){var l;const r=(l=e.match(s3))==null?void 0:l[0],o=r?e.slice(r.length):e,i=["kbd",t?"kbd-chip":"",n??""].filter(Boolean).join(" ");return d.jsxs("kbd",{className:i,children:[r&&d.jsx("span",{className:"kbd-mod",children:r}),o]})}function zt(e,t,{placement:n,detail:r,card:o,dot:i,name:l,aside:c,also:u}={}){const h=l?`${e}: ${l}`:e,f=(Array.isArray(r)?r:[r]).filter(g=>!!g),m=[h,...f,...c??[]].join(", ");return{"data-tip":e,"data-tip-key":t,"data-tip-placement":n,"data-tip-detail":f.length?f.join(`
105
- `):void 0,"data-tip-card":o||l||c!=null&&c.length?"":void 0,"data-tip-dot":i,"data-tip-name":l,"data-tip-aside":c!=null&&c.length?c.join(`
106
- `):void 0,"data-tip-also":u==null?void 0:u.text,"data-tip-also-key":u==null?void 0:u.key,"aria-label":t?`${m} (${t})`:m}}const i3=120,a3=600,l3=150,qb=6,c3=18,Rm=8;function Gb(e){const t=e.dataset.tipPlacement;return t==="follow"||t==="top"||t==="bottom"||t==="left"||t==="right"?t:"bottom"}function H_(e){return e==="follow"?{side:"bottom",align:"start",offset:c3,alignOffset:-12,flip:"both",margin:Rm}:e==="left"||e==="right"?{side:e,align:"start",offset:qb,flip:"both",margin:Rm}:{side:e,align:"center",offset:qb,flip:"side",margin:Rm}}function u3(e,t){return e.placement==="follow"?u_(t):e.el.getBoundingClientRect()}function W_(){var u;const[e,t]=S.useState(null),n=S.useRef(null),r=S.useRef(null),o=S.useRef({x:0,y:0}),i=Na();if(S.useEffect(()=>{if(i)return;let h=0,f=0,m=null,g=!1,w=0;const y=()=>{window.clearTimeout(h),window.clearTimeout(f)},v=()=>{y(),g&&(w=Date.now()),g=!1,m=null,t(null)},_=(P,R)=>{var F,B;const U=P.dataset.tip;if(!U)return v();y(),g=!0,t({el:P,text:U,key:P.dataset.tipKey,detail:(F=P.dataset.tipDetail)==null?void 0:F.split(`
107
- `),card:P.dataset.tipCard!==void 0,dot:P.dataset.tipDot,name:P.dataset.tipName,aside:(B=P.dataset.tipAside)==null?void 0:B.split(`
108
- `),also:P.dataset.tipAlso&&P.dataset.tipAlsoKey?{text:P.dataset.tipAlso,key:P.dataset.tipAlsoKey}:void 0,placement:R})},x=P=>{const R=P.target;if(!(R instanceof Element))return null;const U=R.closest("[data-tip], .float");return(U==null?void 0:U.dataset.tip)!==void 0?U:null},T=P=>{o.current={x:P.clientX,y:P.clientY};const R=x(P);if(R===m)return;if(y(),m=R,!R){g&&(f=window.setTimeout(v,l3));return}const U=Gb(R);if(g||Date.now()-w<a3)return _(R,U);h=window.setTimeout(()=>_(R,U),i3)},N=P=>{P.relatedTarget||v()},j=P=>{const R=x(P);if(R!=null&&R.matches(":focus-visible")){y(),m=R;const U=Gb(R);_(R,U==="follow"?"bottom":U)}},$=()=>v(),O=P=>{P.key!=="Shift"&&P.key!=="Control"&&P.key!=="Alt"&&P.key!=="Meta"&&v()},I=P=>{m&&P.target instanceof Node&&P.target.contains(m)&&v()};return document.addEventListener("mouseover",T),document.addEventListener("mouseout",N),document.addEventListener("mousedown",v),document.addEventListener("keydown",O),document.addEventListener("scroll",I,!0),document.addEventListener("focusin",j),document.addEventListener("focusout",$),window.addEventListener("blur",v),()=>{y(),document.removeEventListener("mouseover",T),document.removeEventListener("mouseout",N),document.removeEventListener("mousedown",v),document.removeEventListener("keydown",O),document.removeEventListener("scroll",I,!0),document.removeEventListener("focusin",j),document.removeEventListener("focusout",$),window.removeEventListener("blur",v)}},[i]),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 l=d.jsxs(d.Fragment,{children:[e.dot==="spinner"?d.jsx(Ml,{size:"dot",className:"tooltip-dot"}):e.dot&&d.jsx("span",{className:`dot ${e.dot} tooltip-dot`}),e.text]}),c=d.jsxs(d.Fragment,{children:[l,e.key&&d.jsx(es,{k:e.key,className:"tooltip-key"})]});return d.jsxs(Ls,{className:He("tooltip",e.card&&"tooltip-card"),role:"tooltip",boxRef:n,handle:r,anchor:()=>u3(e,o.current),placement:H_(e.placement),track:!1,raiseKey:e,children:[e.also?d.jsxs("div",{className:"tooltip-pair",children:[d.jsx("span",{children:l}),e.key?d.jsx(es,{k:e.key,className:"tooltip-key"}):d.jsx("span",{}),d.jsx("span",{className:"tooltip-also",children:e.also.text}),d.jsx(es,{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 d3={sm:"",md:"btn-md",lg:"btn-lg"},f3={ghost:"",outline:"btn-outline",field:"btn-outline btn-field",inline:"btn-inline"},K_={primary:"tone-primary",quiet:"tone-quiet",danger:"tone-danger",strong:"tone-strong",chrome:"tone-chrome"};function De({variant:e="ghost",size:t="sm",tone:n,on:r,mono:o,busy:i,className:l,type:c="button",disabled:u,children:h,...f}){const m=He("btn",f3[e],d3[t],n&&K_[n],r&&"on",o&&"btn-mono",i&&"btn-busy",l);return d.jsxs("button",{className:m,type:c,disabled:i||u,"aria-busy":i||void 0,...f,children:[i&&d.jsx(Ml,{}),h]})}function Ot({icon:e,label:t,hint:n,detail:r,also:o,silent:i,badge:l,tone:c,on:u,className:h,type:f="button",...m}){const g=He("btn-icon",c&&K_[c],u&&"on",h),w=zt(t,n,{detail:r,also:o});return d.jsxs("button",{className:g,type:f,...i?{"aria-label":w["aria-label"]}:w,...m,children:[typeof e=="string"?d.jsx(_t,{name:e}):e,l]})}function xu(e,t,n){return n===0?0:(e+t+n)%n}function Vb(e,t,n){return e>=0?xu(e,t,n):n===0?-1:t>0?0:n-1}function Z_(e,t,n){var i;const r=e.length,o=n.toLowerCase();for(let l=1;l<=r;l++){const c=(Math.max(t,-1)+l)%r;if((i=e[c])!=null&&i.trim().toLowerCase().startsWith(o))return c}return-1}function Om(e,t){return e&&e.length>t.length&&e.toLowerCase().startsWith(t.toLowerCase())?e.slice(t.length):null}function h3(e,t){if(e==null)return null;if(typeof e=="string"){const o=Om(e,t);return o?{text:o,accept:o,params:[]}:null}const n=Om(e.show,t);if(!n)return null;const r=(e.params??[]).map(([o,i])=>[Math.max(o,t.length)-t.length,i-t.length]).filter(([o,i])=>i>o);return{text:n,accept:Om(e.accept,t),params:r}}function q_(e){const{results:t,keyOf:n,q:r,onPick:o,listRef:i,onActive:l,onSide:c,completionOf:u,narrowTo:h,setQ:f,tabPicks:m,onIdlePick:g}=e,[w,y]=S.useState(()=>{var O;return e.idle?-1:Math.max(0,((O=e.initialIndex)==null?void 0:O.call(e,t))??0)}),v=w>=0&&t[w]?n(t[w]):null,_=S.useRef(l);_.current=l,ft([v],()=>{var O,I,P;(I=(O=i.current)==null?void 0:O.querySelector('.picker-item[data-state~="cursor"]'))==null||I.scrollIntoView({block:"nearest"}),(P=_.current)==null||P.call(_,w>=0?t[w]??null:null)});const x=w<0?-1:Math.min(w,Math.max(0,t.length-1)),T=x>=0?t[x]??null:null,N=T?h3(u==null?void 0:u(T,r),r):null,j=O=>{const I=h==null?void 0:h(O,r);if(I==null)return o(O,r);f==null||f(I),y(0)};return{index:x,active:T,ghost:N,setIndex:y,pick:j,onKeyDown:O=>{if(O.key==="ArrowDown")O.preventDefault(),y(Vb(x,1,t.length));else if(O.key==="ArrowUp")O.preventDefault(),y(Vb(x,-1,t.length));else if((O.key==="ArrowLeft"||O.key==="ArrowRight")&&c&&T)O.preventDefault(),c(T,O.key==="ArrowLeft"?-1:1);else if(O.key==="Tab"&&(N!=null&&N.accept))O.preventDefault(),f==null||f(r+N.accept),y(0);else if(O.key==="Tab"&&m&&T)O.preventDefault(),j(T);else if(O.key==="Enter"&&T)O.preventDefault(),j(T);else if(O.key==="Enter"&&x<0&&g)O.preventDefault(),g(r);else return!1;return!0}}}function dr(e){const t=Object.keys(e).filter(n=>e[n]);return t.length>0?t.join(" "):void 0}const p3=new Set(["Shift","Meta","Control","Alt","CapsLock","Fn"]);function G_(){const e=hw(),t=Gn();return S.useEffect(()=>{if(!e)return;const n=()=>{e.target.isConnected||co.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(m3,{spec:e},e.id):null}function m3({spec:e}){const t=e.items,n=t.filter(gs),[r,o]=S.useState(-1),i=S.useRef({idx:r,items:n});i.current={idx:r,items:n};const l=S.useRef(null),c=m=>{var g,w;{const y=()=>co.close(),{idx:v,items:_}=i.current;if(p3.has(m.key))return;if(m.key==="ArrowDown"||m.key==="ArrowUp"){m.preventDefault(),m.stopPropagation();const x=m.key==="ArrowDown"?1:-1;o(FD(_,v,x));return}if((m.key==="Enter"||m.key===" ")&&v>=0&&_[v]&&!_[v].disabled){m.preventDefault(),m.stopPropagation(),_[v].onClick(),y();return}if(m.key==="Escape"){m.stopPropagation(),y();return}if(m.key.length===1&&!m.metaKey&&!m.ctrlKey&&!m.altKey){m.preventDefault(),m.stopPropagation();const x=Array.from(((g=l.current)==null?void 0:g.querySelectorAll(".menu-label"))??[],N=>N.textContent??""),T=Z_(x,v,m.key);T>=0&&!((w=_[T])!=null&&w.disabled)&&o(T);return}y()}};S.useEffect(()=>{const m=()=>co.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}=HD(e),f=n.some(m=>m.checked);return d.jsxs(Ls,{className:He("menu",e.head!==void 0&&"menu-headed"),role:"menu",boxRef:l,anchor:()=>u,placement:h,track:!1,from:e.target,trigger:e.toggles?e.target:null,onDismiss:()=>co.close(),onKey:c,onContextMenu:m=>m.preventDefault(),children:[e.head!==void 0&&d.jsx("div",{className:"menu-head",children:e.head}),t.map((m,g)=>{if(!gs(m))return d.jsx("hr",{className:"menu-sep"},`sep-${g}`);const w=n.indexOf(m);return d.jsx(g3,{item:m,gutter:f,cursor:w===r,onEnter:()=>o(w)},m.id)})]})}function g3({item:e,gutter:t,cursor:n,onEnter:r}){const o=e.disabled!==void 0,i=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:He("row row-keyed",e.danger&&"danger",i!==void 0&&"row-tall",o&&"disabled"),"data-state":dr({cursor:n,checked:e.checked}),onMouseMove:o||n?void 0:r,onClick:()=>{o||(e.onClick(),co.close())},children:[t&&d.jsx("span",{className:"menu-check",children:e.checked&&d.jsx(_t,{name:"check",className:"icon-inline"})}),d.jsxs("span",{className:"menu-text",children:[d.jsx("span",{className:"menu-label",children:e.label}),i!==void 0&&d.jsx("span",{className:"menu-detail row-dim",children:i})]}),e.key&&d.jsx(es,{k:e.key,className:"menu-key row-dim"})]})}const Ff=8,k3=104,w3=.25,V_=220,Og=.5,y3=100;function v3(e,t){return Math.max(0,-Y_(e,t))}function Y_(e,t){const n=e.filter(l=>t-l.t<=y3);if(n.length<2)return 0;const r=n[0],o=n[n.length-1],i=o.t-r.t;return i>0?(o.x-r.x)/i:0}function b3(e,t,n){return e>0?e:n>0&&t>=Og?1:0}function x3({dx:e,dy:t}){return Math.abs(e)<Ff&&Math.abs(t)<Ff?null:Math.abs(e)>Math.abs(t)&&e<0?"slide":"other"}function E3(e,t,n=k3){const r=Math.max(0,-e),o=t*n,i=Math.min(t,Math.floor(r/n)),l=r<=o?r:o+(r-o)*w3,c=Math.min(1,r/(n/2));return{step:i,x:-l,well:c}}function X_(e,t){const n=S.useRef(t);n.current=t,S.useEffect(()=>{const r=e.current;if(!r)return;let o=null,i=null,l=!1,c=0,u=[],h=0,f=0;const m=(N,j,$,O)=>{N.el.dataset.slide!==O&&(N.el.dataset.slide=O,N.el.offsetWidth),N.el.style.setProperty("--slide-x",`${j}px`),N.el.style.setProperty("--slide-well",`${Math.round($*100)}%`)},g=N=>{N.el.style.removeProperty("--slide-x"),N.el.style.removeProperty("--slide-well"),delete N.el.dataset.slide},w=(N=0)=>{var P;const j=o,$=l,O=j?b3(c,N,j.rungs):0,I=O!==c;o=null,i=null,l=!1,c=0,u=[],!(!j||!$)&&(I&&(n.current.onSlide({key:j.key,step:O}),(P=navigator.vibrate)==null||P.call(navigator,8)),m(j,0,0,"settle"),O>0&&n.current.onPick(j.key,O),h=window.setTimeout(()=>{g(j),n.current.onSlide(null)},V_))};let y=null;const v=N=>{if(!N.isPrimary||N.pointerType==="mouse"&&N.button!==0)return w();const j=N.target instanceof Element?n.current.rowOf(N.target):null;!j||j.el.dataset.slide||(window.clearTimeout(h),o=j,y=N.pointerId,i={x:N.clientX,y:N.clientY})},_=N=>{var P;const j=o;if(!j||!i||N.pointerId!==y)return;const $=N.clientX-i.x,O=N.clientY-i.y;if(!l){const R=x3({dx:$,dy:O});if(R==="other"&&(o=null,i=null,y=null),R!=="slide")return;l=!0;try{j.el.setPointerCapture(N.pointerId)}catch{}n.current.onSlide({key:j.key,step:0})}u.push({x:N.clientX,t:N.timeStamp}),u.length>8&&u.shift();const I=E3($,j.rungs,j.rung);m(j,I.x,I.well,"drag"),I.step!==c&&(c=I.step,n.current.onSlide({key:j.key,step:c}),c>0&&((P=navigator.vibrate)==null||P.call(navigator,8)))},x=N=>{N.pointerId===y&&(l&&(f=N.timeStamp+400),y=null,w(N.type==="pointerup"?v3(u,N.timeStamp):0))},T=N=>{N.timeStamp>=f||(N.preventDefault(),N.stopPropagation())};return r.addEventListener("pointerdown",v),r.addEventListener("pointermove",_),r.addEventListener("pointerup",x),r.addEventListener("pointercancel",x),r.addEventListener("click",T,!0),()=>{window.clearTimeout(h),r.removeEventListener("pointerdown",v),r.removeEventListener("pointermove",_),r.removeEventListener("pointerup",x),r.removeEventListener("pointercancel",x),r.removeEventListener("click",T,!0)}},[e])}const Q_=1/3,S3=220;function _3({dx:e,dy:t}){return Math.abs(e)<Ff&&Math.abs(t)<Ff?null:Math.abs(e)<=Math.abs(t)?"other":e<0?"left":"right"}function N3(e,t,n){return n==="left"?Math.min(0,Math.max(-t,e)):Math.max(0,Math.min(t,e))}function T3(e,t,n,r){const o=n==="left"?-r:r;return o>=Og?!0:o<=-Og?!1:Math.abs(e)>=t*Q_}function j3(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 Yb=-1;function $3(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 i=null,l=null,c=null,u=!1,h=0,f=null,m=null,g=0,w=null,y=[],v=0,_=0;const x=(B,X)=>{const ae=m;ae&&(ae.dataset.swipe!==X&&(ae.dataset.swipe=X,ae.offsetWidth),ae.style.translate=`${B}px`)},T=()=>{const B=m;m=null,B&&(delete B.dataset.swipe,B.offsetWidth,B.style.removeProperty("translate"))},N=()=>{i=null,l=null,c=null,u=!1,f=null,g=0,w=null,y=[]},j=B=>{try{o.setPointerCapture(B.pointerId)}catch{}},$=B=>{const X=f,ae=(m==null?void 0:m.clientWidth)??0;N(),X&&(x(B?X==="left"?-ae:ae:0,"settle"),v=window.setTimeout(()=>{Z1.flushSync(()=>n.current.onEnd(B)),T()},S3))},O=B=>{var ae;if(B.pointerType==="mouse")return;if(!B.isPrimary)return f?$(!1):N();if(m||(((ae=window.visualViewport)==null?void 0:ae.scale)??1)>1.01)return;const X=B.target instanceof Element?B.target:null;!X||X.closest("textarea, input, [contenteditable], iframe, .float")||(window.clearTimeout(v),i={x:B.clientX,y:B.clientY},l=X,c=j3(X,o),w=B.pointerId,h=B.clientX)},I=(B,X,ae,Y)=>{if(!i||!l)return;const ne=B-i.x,C=X-i.y;if(u&&c){c.scrollLeft-=B-h,h=B;return}if(!f){const H=_3({dx:ne,dy:C});if(H===null)return;if(H==="other")return N();if(c){u=!0,h=B,Y&&j(Y);return}if(H==="left"&&l.closest(".slide"))return N();const V=n.current.take(l,H);if(!V)return N();m=V,f=H,Y&&j(Y)}y.push({x:B,t:ae}),y.length>8&&y.shift(),g=N3(ne,(m==null?void 0:m.clientWidth)??0,f),x(g,"drag")},P=(B,X)=>{var C;if(!f)return N();const ae=(m==null?void 0:m.clientWidth)??0,Y=X?Y_(y,B):0,ne=X&&T3(g,ae,f,Y);ne&&Math.abs(g)<ae*Q_&&((C=navigator.vibrate)==null||C.call(navigator,8)),$(ne)},R=B=>{B.pointerId===w&&I(B.clientX,B.clientY,B.timeStamp,B)},U=B=>{B.pointerId===w&&((f||u)&&(_=B.timeStamp+400),P(B.timeStamp,B.type==="pointerup"))};r.current=B=>{const X=performance.now();if(B.phase==="start"){if(m||i)return;i={x:B.x,y:B.y},l=o,c=null,w=Yb;return}if(w===Yb){if(B.phase==="move")return I(B.x+g,B.y,X);P(X,B.phase==="end")}};const F=B=>{B.timeStamp>=_||(B.preventDefault(),B.stopPropagation())};return o.addEventListener("pointerdown",O),o.addEventListener("pointermove",R),o.addEventListener("pointerup",U),o.addEventListener("pointercancel",U),o.addEventListener("click",F,!0),()=>{r.current=()=>{},window.clearTimeout(v),o.removeEventListener("pointerdown",O),o.removeEventListener("pointermove",R),o.removeEventListener("pointerup",U),o.removeEventListener("pointercancel",U),o.removeEventListener("click",F,!0)}},[e]),S.useCallback(o=>r.current(o),[])}function Ah({items:e,current:t,onPick:n,fill:r,font:o,segmented:i,quiet:l,end:c,label:u,owner:h}){const f=wn(h),m=S.useRef(null),g=Math.max(0,e.findIndex(y=>y.id===t)),w=y=>{var x,T;if(y.key!=="ArrowLeft"&&y.key!=="ArrowRight")return;y.preventDefault();const v=e.findIndex(N=>N.id===t),_=e[xu(v,y.key==="ArrowRight"?1:-1,e.length)];_&&(n(_.id),(T=(x=m.current)==null?void 0:x.querySelectorAll('[role="tab"]')[e.indexOf(_)])==null||T.focus())};return d.jsxs("div",{className:He("tabs",r&&"tabs-fill",o==="mono"&&"tabs-mono",i&&"tabs-segmented",l&&"tabs-quiet"),children:[d.jsx("div",{className:"tabs-list",role:"tablist","aria-label":u,ref:m,onKeyDown:w,style:i?{"--tabs-at":g,"--tabs-count":e.length}:void 0,children:e.map(y=>{const v=y.id===t;return d.jsxs("div",{className:He("tab",v&&!!y.trail&&"tab-trailed",y.fit&&"tab-fit",y.far&&"tab-far"),"data-state":dr({current:v}),...y.menu?f.contextMenu(y.menu):{},children:[d.jsxs("button",{type:"button",className:"tab-btn",role:"tab","aria-selected":v,tabIndex:v?0:-1,onClick:()=>n(y.id),...y.tip,...y.ariaLabel?{"aria-label":y.ariaLabel}:{},children:[y.lead,y.label]}),v&&y.trail&&d.jsx("span",{className:"tab-trail",children:y.trail})]},y.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:He("view",e==="line"&&"view-anchored",t&&"view-wide"),children:r});return n?d.jsxs("div",{className:"view-stack",children:[o,n]}):o}const J_=e=>`Toyon restarts once ${e.join(", ")} ${e.length===1?"finishes":"finish"}`,C3=(e,t)=>[...e,...t.filter(n=>!e.includes(n))];function A3(e,t,n){const r=[...t],o=[...n],i=(c,u)=>{const h=c.indexOf(u);return h===-1?!1:(c.splice(h,1),!0)};return[...e.map(c=>i(r,c)?{name:c,dot:"working",note:null}:i(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 I3(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 R3(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:J_(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 Mg=!1;function O3(){Mg=!0}function Jc({title:e,body:t,action:n,pane:r,children:o}){return d.jsxs("div",{className:He("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 Xb={title:"Toyon was updated",body:"This page is still running the old build. Reload to pick up the new one."};class Sw extends S.Component{constructor(){super(...arguments);St(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(Jc,{pane:this.props.pane,title:Mg?Xb.title:"Toyon hit an error",body:Mg?Xb.body:n.message||String(n),action:d.jsx(De,{variant:"outline",onClick:()=>window.location.reload(),children:"reload"})}):this.props.children}}const Pg={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.`},M3=1e3,Qb={held:[],asking:[],seen:[]};async function Jb(e,t,n){for(;;){await new Promise(i=>setTimeout(i,M3));const[r,o]=await Promise.all([kg(e),rS(e)]);if(r!==null&&r!==t)break;n(o??{waiting:[],asking:[]})}window.location.reload()}function eN({foreign:e}={}){return e?d.jsx(P3,{name:e}):d.jsx(L3,{})}function P3({name:e}){const t=ss(),n=t.list()[0];return d.jsx(Jc,{title:`Toyon on ${e} was updated`,body:Pg.foreign(e),action:n&&d.jsxs(De,{variant:"outline",onClick:()=>t.activate(n.origin),children:["back to ",t.displayName(n.origin)]})})}function L3(){const e=Ur(),[t,n]=S.useState(!0),[r,o]=S.useState(null),[i,l]=S.useState(Qb),c=S.useRef(null),u=S.useCallback(y=>l(v=>({held:y.waiting,asking:y.asking,seen:C3(v.seen,y.waiting)})),[]),h=S.useCallback(async y=>{n(!0),o(null);const v=c.current??{pid:await kg(e)},_=await lL(e,y);if(_){n(c.current!==null),o(_);return}y&&l(Qb),!c.current&&(c.current=v,Jb(e,v.pid,u))},[u,e]);S.useEffect(()=>{let y=!0;return(async()=>{const[v,_]=await Promise.all([kg(e),rS(e)]);if(!(!y||c.current)){if(_===null){h(!1);return}c.current={pid:v},u(_),Jb(e,v,u)}})(),()=>{y=!1}},[u,h,e]);const f=t&&i.held.length>0,m=f?A3(i.seen,i.held,i.asking):[],g=m.filter(y=>y.dot==="working").length,w=m.filter(y=>y.dot!=="waiting").length;return d.jsx(Jc,{title:Pg.title,body:r??(f?I3(g,w):Pg.waiting),action:f?d.jsx(De,{variant:"outline",onClick:()=>void h(!0),children:"restart now"}):d.jsx(De,{variant:"outline",busy:t,onClick:()=>void h(!1),children:"restart"}),children:m.length>0&&d.jsx("ul",{className:"crash-list",children:m.map((y,v)=>d.jsxs("li",{className:He("crash-row",y.dot!=="working"&&"row-dim"),children:[d.jsx("span",{className:He("dot",y.dot)}),d.jsx("span",{className:"crash-row-name",children:y.name}),y.note&&d.jsx("span",{className:"crash-row-note",children:y.note})]},v))})})}const fa=(e,t=!1)=>({text:e,live:t}),D3={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"},z3={probing:e=>`connecting to ${e}`,down:e=>`Toyon on ${e} is not answering.
109
- 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.
110
- a proxy, VPN or browser extension is the usual cause`,unauthorized:e=>`this page's token for ${e} is not the one running there.
111
- forget ${e} here and pair it again`},F3="no access token for this address.\nrun `toyon` or `toyon open` in your repo to get a signed-in page";function tN(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?fa(z3[e.connectFailure??"probing"](e.machine),t):e.hasToken?fa(D3[e.connectFailure??"probing"],t):fa(F3)}return e.title===null?fa(e.heard?`nothing open yet.
112
- press ${e.projectChord} to open a project, or type a name there to start a new one`:""):null}function B3(e){const t=tN(e);return t!==null?t:e.needsSetup&&e.busy?fa(`building in ${e.title}; the preview appears once it starts`,!0):e.needsSetup&&e.treeEmpty?fa(`${e.title} is empty so far; say what to build`):e.treeEmpty&&e.landsFrom?fa(`nothing runs on main until ${e.landsFrom} lands`):null}const un={post:(e,t)=>{},broadcast:e=>{}};function eu(e,t,n,r){const o=t===r;un.post(e,o?{type:"pick-cancel"}:{type:"pick-start",verb:r}),n({a:"set-picking",v:o?!1:r})}function nN(e){return[{id:"copy-sha",label:`copy ${e.short}`,onClick:()=>Yt(e.sha)},{id:"copy-subject",label:"copy subject",onClick:()=>Yt(e.subject)}]}function Ih(e,t,n){var o,i;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 l=t-1;l>=0;l--)if((((i=e[l])==null?void 0:i.depth)??0)<r.depth)return{do:"to",at:l};return null}const rN="application/x-toyon-mention";let ba=null;function U3(e){return e.kind==="worktree"?`@${e.title} `:kw(e.items)}function H3(e){return e.kind==="worktree"?e.branch:e.items.map(t=>t.path).join(" ")}function tu(e,t){e.dataTransfer.setData(rN,"1"),e.dataTransfer.setData("text/plain",H3(t)),e.dataTransfer.effectAllowed="copy",ba=t}function Eu(e){ba=null,xw(e)}function oN(e,t){const n=e.getState().activeId;return(t.kind==="paths"?t.worktreeId===n:t.worktreeId!==n)?Ta(e):null}const sN=e=>ba!==null&&Array.from(e.dataTransfer.types).includes(rN);function W3(e,t){if(!sN(t)||!ba)return;t.preventDefault();const n=oN(e,ba)!==null;t.dataTransfer.dropEffect=n?"copy":"none",n&&bw(e,{at:"chat"})}function iN(e,t){if(!sN(t)||!ba)return null;t.preventDefault();const n=ba,r=$z();if(Eu(e),r)return null;const o=oN(e,n);return o?{boxId:o,words:U3(n)}:null}function K3(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 Rh(e){return e!=null&&e.config.profiles?Object.keys(e.config.profiles):[]}function aN(e,t){const n=Rh(t);if(n.length!==0)return e.profile&&n.includes(e.profile)?e.profile:t==null?void 0:t.config.defaultProfile}const Z3=e=>Nf(bi((e==null?void 0:e.config)??{}),e==null?void 0:e.defaultBranch).toLowerCase();function Si(e,t,n){t({a:"shipping",id:n.worktreeId,op:n.t}),e==null||e.send(n)}const lN=e=>e.dirty===void 0||e.ahead===void 0||e.dirty>0||e.ahead>0;function Nl(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 cN(e,t,n){t({a:"hold-unread",id:n}),e==null||e.send({t:"mark-unread",worktreeId:n})}function uN(e,t){return{rename(n){if(!X1(n.worktree))return;const r=window.prompt("Rename worktree (its branch follows as a slug):",n.worktree.title);r!=null&&r.trim()&&(e==null||e.send({t:"rename-worktree",worktreeId:n.worktree.id,title:r.trim()}))},setProfile(n,r){e==null||e.send({t:"set-worktree-profile",worktreeId:n.worktree.id,profile:r})},ownProcs(n){e==null||e.send({t:"own-procs",worktreeId:n.worktree.id})},shareProcs(n){const r=(n.worktree.owns??[]).join(", ");window.confirm(`Stop this worktree's own ${r} and use main's?
113
-
114
- 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:n.worktree.id}))},archive(n){if(!xk(n.worktree))return;if(!lN(n))return Nl(e,t,[n.worktree.id]);window.confirm(`Archive worktree "${n.worktree.title}"?
115
-
116
- Its directory and branch (${n.worktree.branch}) go. The chat, the commits and any uncommitted changes are kept, and the project menu can restore it.`)&&Nl(e,t,[n.worktree.id])}}}function dN(e,t,n,{sock:r,dispatch:o},i){var $,O;const l=e.worktree.id,c=uN(r,o),u=[],h=[],f=[],m=[],g=[],w=[];Fo(e.agent)&&u.push({id:"stop",label:"stop agent",onClick:()=>r==null?void 0:r.send({t:"stop-agent",worktreeId:l})});const y=!n.shipping[l],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:l}),v?o({a:"screen",to:"changes"}):n.layout.changes||o({a:"toggle-changes"})}}),h.push({id:"copy-branch",label:"copy branch name",onClick:()=>Yt(e.worktree.branch)}),h.push(...os(()=>r==null?void 0:r.send({t:"reveal",worktreeId:l}),i.hostname)),v||h.push({id:"copy-path",label:"copy path",onClick:()=>Yt(e.path)});const{transcript:_,sessionId:x}=e,T=!v&&!!i.palette;T&&_&&!_r(e.worktree)&&h.push({id:"copy-transcript",label:"copy transcript path",onClick:()=>Yt(_)}),T&&x&&h.push({id:"copy-session",label:"copy session id",onClick:()=>Yt(x)});const N=aN(e.worktree,t);for(const I of ku(e.worktree)?[]:Rh(t))g.push({id:`profile:${I}`,label:`run with ${I}`,checked:I===N,onClick:()=>c.setProfile(e,I)});if(!wa(e.worktree)&&(($=e.borrowed)!=null&&$.length)&&g.push({id:"own-procs",label:`run ${e.borrowed.join(", ")} here`,detail:"on main now",onClick:()=>c.ownProcs(e)}),!wa(e.worktree)&&((O=e.worktree.owns)!=null&&O.length)&&g.push({id:"share-procs",label:`use main's ${e.worktree.owns.join(", ")}…`,detail:"runs here now",danger:!0,onClick:()=>c.shareProcs(e)}),X1(e.worktree)&&f.push({id:"rename",label:"rename…",onClick:()=>c.rename(e)}),i.graft&&hf(e.worktree)){const I=i.graft;f.push({id:"graft",label:"graft with…",onClick:()=>I(l)})}f.push({id:"unread",label:"mark as unread",key:Dt("mark-unread"),disabled:e.unseen?"already unread":void 0,onClick:()=>cN(r,o,l)});const j=y?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:l})});else if(oh(e)&&(e.behind??0)>0){const I=Fo(e.agent)&&(e.dirty??0)>0;m.push({id:"sync",label:`sync from main${I?" after the turn":""} (${e.behind} behind)`,disabled:j,onClick:()=>Si(r,o,{t:"sync-main",worktreeId:l})})}return ca(e.worktree)&&!(e.worktree.landed&&e.dirty===0)&&m.push({id:"land",label:Tk(bi((t==null?void 0:t.config)??{}),e.worktree),detail:Z3(t),disabled:j,onClick:()=>Si(r,o,{t:"land",worktreeId:l})}),e.worktree.kind==="worktree"&&m.push({id:"split",label:"continue elsewhere…",sub:!0,onClick:()=>o({a:"open",overlay:{kind:"split",worktreeId:l}})}),xk(e.worktree)&&w.push({id:"archive",label:lN(e)?"archive…":"archive",key:Dt("wt-archive"),danger:!0,onClick:()=>c.archive(e)}),Dn([u,h,f,m,g,w])}function q3(e,t,{sock:n,dispatch:r},o){const i=[],l=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 oh(e)&&(e.behind??0)>0&&i.push({id:"sync",label:`sync from main (${e.behind} behind)`,onClick:()=>n==null?void 0:n.send({t:"sync-main",worktreeId:e.id})}),l||i.push({id:"shell",label:"open a shell here",onClick:()=>{r({a:"activate",id:e.id}),r({a:"focus-terminal"})}}),i.push(...os(()=>n==null?void 0:n.send({t:"reveal",worktreeId:e.id}),o)),Dn([c,i,l?[]:[{id:"copy-path",label:"copy path",onClick:()=>Yt(e.path)}]])}const G3={sm:"",md:"field-md",lg:"field-lg"};function fN({size:e="sm",font:t,bare:n,rule:r,className:o}){const i=t??(e==="lg"?"ui":"mono");return He("field",G3[e],i==="ui"&&"field-ui",i==="lead"&&"field-lead",n&&"field-bare",r&&"field-rule",o)}const zo=S.forwardRef(function({size:t,font:n,bare:r,rule:o,className:i,...l},c){return d.jsx("input",{ref:c,className:fN({size:t,font:n,bare:r,rule:o,className:i}),...l})}),nu=S.forwardRef(function({size:t,font:n,bare:r,rule:o,className:i,...l},c){return d.jsx("textarea",{ref:c,className:fN({size:t,font:n,bare:r,rule:o,className:i}),...l})});function V3(e,t){const n=t??0;return n===0?null:`${n} behind ${e}`}function hN(e){const t=new Date(e);return`${String(t.getHours()).padStart(2,"0")}:${String(t.getMinutes()).padStart(2,"0")}`}function pN(e,t){if(t.fetchFailed)return`could not reach origin${t.fetchedAt?` since ${hN(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 Y3(e){return e.stale!=="diverged"}const ho=e=>/[.!?…]$/.test(e)?e:`${e}.`,mN=160;function Oh(e,t=mN){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 _w(e){return e.subjects.length?Oh(e.subjects.join("; ")):void 0}function gN(e){const t=_w(e);if(t)return e.pr===void 0?t:Oh(`PR #${e.pr}: ${t}`)}function Nw(e,t=3){const n=[];for(const l of e??[]){const c=gN(l);c&&n.push({at:l.at,line:c})}if(n.length===0)return[];const r=n.slice(-t),o=n.length-r.length,i=r.map(({at:l,line:c})=>n.length===1?ho(c):`${Tw(bo(ur(l)))}: ${ho(c)}`);return o>0?[`${o} earlier landing${o===1?"":"s"}.`,...i]:i}const X3="checks running",Q3="checks failed",kN="preview up";function J3(e){if(e.state!=="open")return[];const t=[];return(e.checks==="pending"||e.checks==="fail")&&t.push({text:e.checks==="fail"?Q3:X3,url:`${e.url}/checks`,tip:"Open the checks on GitHub",open:"open the checks"}),e.preview&&t.push({text:kN,url:e.preview,tip:`Open the branch on ${new URL(e.preview).hostname}`,open:"open the preview"}),t}function e5(e,t){const n=[];let r=e;for(const o of t){const i=new RegExp(`(^|; |, )${o.text.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}(?=;|\\.|$)`).exec(r);if(!i)continue;const l=i.index+(i[1]??"").length;l>0&&n.push(r.slice(0,l)),n.push(o),r=r.slice(l+o.text.length)}return r&&n.push(r),n}function Cs(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?`; ${kN}.`:".";if(e.automerge){const r=e.review==="review_required"?"it is approved and checks pass":"checks pass";return`${t} open; GitHub 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 wN(e){return e.state==="open"&&!e.automerge&&e.mergeable!==!1&&e.review!=="changes_requested"&&e.review!=="review_required"&&e.checks!=="fail"&&e.checks!=="pending"}const Tw=e=>`${e.charAt(0).toUpperCase()}${e.slice(1)}`;function jw(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 yN(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 t5(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 Jd(e,t=0,n=!0,r){var o,i;if(e.check==="pending")return"Checking the work…";if(e.check==="fail"){const l=(i=(o=e.checkTail)==null?void 0:o.split(`
117
- `).find(c=>c.trim()))==null?void 0:i.trim();return`Check failed${l?`: ${ho(l)}`:"."}`}return jw(e,t,n)==="unasked"?t5(r):null}function ex(e,t){const n=n5(e,t);return n?ho(Tw(n)):""}function n5(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 vN=e=>/^[A-Z][a-z]+(\s|$)/.test(e)?`${e.charAt(0).toLowerCase()}${e.slice(1)}`:e;function r5(e,t){const n=t??0;return n>0?`${n} behind ${e}; land takes it in first.`:""}function o5(e){return e>0?ho(Tw(`${e} ${e===1?"file":"files"} changed`)):""}function s5(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: ${ho(vN(e.why))}`:null}function ef(e){return ho(e)}const bo=e=>e==="now"?"just now":`${e} ago`;function i5(e,t,n){switch(e){case"asking":return`Waiting on you${n==="now"?"":` for ${n}`}${t.ask?`: ${ho(t.ask)}`:"."}`;case"failed":return t.auth?`Stopped ${bo(n)}: not logged in.`:t.error?`Failed ${bo(n)}: ${ho(t.error)}`:`Failed ${bo(n)}.`;case"stopped":return t.planBack?`Sent the plan back ${bo(n)}. Say what to change.`:`Stopped ${bo(n)}.`;case"done":return t.cut?`Ended early ${bo(n)} (${t.cut}).`:`Finished ${bo(n)}.`}}function $w(e){var n;const t=(n=e.recap)==null?void 0:n.text;return t?ho(t):i5(e.end,e.facts,ur(e.at))}function a5(e){var n;const t=(n=e.recap)==null?void 0:n.text;return t?`Last stop, ${bo(ur(e.at))}: ${ho(vN(t))}`:void 0}function ru(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 Cw(e){return(e==null?void 0:e.status)==="running"||(e==null?void 0:e.status)==="detached"}function bN(e){const t=e&&e.status!=="terminated"?e.since:void 0,n=aw(t,lw);return t!==void 0&&n===t?e:void 0}function xN(e,t){const n=e.stage?[e.stage]:[];switch(e.status){case"queued":return[...n,"queued"];case"running":return[...n,`${da(t)} of ${ZC(e.timeoutMs)}`];case"detached":return[...n,da(t),"detached"];case"terminated":return[e.why??"stopped"]}}function Bf(e,t,n){return[e,...xN(t,n)].join(" · ")}const Lg={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 EN(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 l5({active:e,ahead:t,behind:n,unpushed:r,dirty:o}){var Vt,tn,ht;const i=rt(),l=ct(),c=wn("changes"),u=Sn(e)?e.worktree:null,h=e.id,f=L(gt=>{var sn;return(sn=gt.shipping[h])==null?void 0:sn.op}),m=L(gt=>{var sn;return(sn=gt.shipping[h])==null?void 0:sn.step}),g=aw(m,lw),w=ru(e,"commit"),y=ru(e,"check"),v=f?w:y,_=bN(v),x=Ei(Cw(_)?_==null?void 0:_.since:void 0),[T,N]=S.useState("");ft([h],()=>N("")),ft([o],()=>{o||N("")});const j=S.useRef(null),$=(Vt=u==null?void 0:u.landing)!=null&&Vt.subject?u.landing.body?`${u.landing.subject}
118
-
119
- ${u.landing.body}`:u.landing.subject:null,O=()=>{T===""&&$&&N($);const gt=j.current;gt&&(gt.focus(),requestAnimationFrame(()=>gt.setSelectionRange(gt.value.length,gt.value.length)))},I=L(gt=>gt.editCommit);ft([I],()=>{I&&O()});const P=T.trim()||void 0,R=L(gt=>{var sn;return!!((sn=gt.agents.find(kn=>kn.id===((u==null?void 0:u.agent)??gt.defaultAgent)))!=null&&sn.quick)}),U=u==null?void 0:u.landing,F=P?null:jw(U,o?1:0,R),B=(U==null?void 0:U.check)==="pending",X=!!(U!=null&&U.stale),ae=()=>{f||i==null||i.send({t:"judge",worktreeId:h})},Y=()=>{f||!P&&!$||Si(i,l,{t:"commit",worktreeId:h,message:P??$??""})},ne=()=>{f||Si(i,l,{t:"land",worktreeId:h,...P?{message:P}:{}})},C=((tn=u==null?void 0:u.landing)==null?void 0:tn.check)==="fail",H=!!(u!=null&&u.landed)&&!o,V=u?ih({...u,landed:H}):void 0,J=(V==null?void 0:V.state)==="open",Z=J&&(o||r>0),ie=B||X||!!F,be=!!u&&ca(u)&&!H&&(o||t>0)&&!C&&!J&&!ie,ge=!!u&&Z&&!C&&!ie,we=!!u&&ca(u)&&!B&&(X||F==="unwritten"||F==="unanswered")&&!Fo(e.agent),pe=L(gt=>gt.repos.find(sn=>sn.id===e.repoId)??null),Q=bi((pe==null?void 0:pe.config)??{}),W=Nf(Q,pe==null?void 0:pe.defaultBranch),ye=Tk(Q,u??{}),_e=pe?sh(pe):"main",ve=oh(e)?V3(_e,n):null,ce=Fo(e.agent),Se=o&&!u?"commit or discard the changes here first":void 0,me=!!e.syncQueued,Ue=o&&ce?`Merge ${_e} into this worktree once the turn ends, uncommitted changes kept`:`Merge ${_e} into this worktree${o?", uncommitted changes kept":""}`,Ie=J&&!Z&&wN(V),We=be?ye:ge?"update":Ie?"land":(V==null?void 0:V.state)==="merged"?"pull":"land",mt=f==="commit"?g??"commit":f==="land"?g?`${We}: ${g}`:We:null,en=mt&&_?Bf(mt,_,x):mt,Kt=S.useRef(!1);en?o&&(Kt.current=!0):Kt.current=!1;const Be=!!u&&(o||Kt.current),Xt=Be&&!!en,ln=f?null:v?_?xN(_,x).join(" · "):null:B?"writing the message":null,It=_&&(_.status==="running"||_.status==="detached")?_:null,Je=It&&d.jsx(Ot,{icon:"stop",tone:"danger",label:EN(It.kind),onClick:()=>i==null?void 0:i.send({t:"run-stop",worktreeId:h,kind:It.kind})});return d.jsxs("div",{className:"composer commit-box",children:[Be&&d.jsx("div",{className:"composer-field",children:Xt?d.jsx("div",{className:"commit-running live-text","data-tip":_?Lg[_.status]:void 0,children:en}):d.jsx(nu,{size:"lg",bare:!0,ref:j,value:T,onChange:gt=>N(gt.target.value),onKeyDown:gt=>{gt.key==="Enter"&&(gt.metaKey||gt.ctrlKey)?(gt.preventDefault(),Y()):gt.key==="Tab"&&!gt.shiftKey&&T===""&&$&&(gt.preventDefault(),O())},placeholder:$??(F==="unanswered"?"no message yet: the model did not answer. Check again, or write one here":F==="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(_t,{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 ${_e}`,children:[t," ahead"]}),(u==null?void 0:u.landed)&&d.jsxs("span",{className:"badge-landed","data-tip":`Merged into ${_e}`,children:[d.jsx(_t,{name:"check",className:"icon-inline"})," landed"]})]}),d.jsxs("span",{className:"commit-acts",children:[en?d.jsxs(d.Fragment,{children:[!Xt&&d.jsx("span",{className:"live-text",children:en}),Je]}):d.jsxs(d.Fragment,{children:[u&&o&&d.jsx(De,{disabled:!P&&!$||!!f,onClick:Y,...zt($&&!P?"Commit with the suggested message":"git add -A && git commit","⌘⏎"),children:"commit"}),u&&be&&d.jsx(De,{tone:"primary",disabled:!!f,"data-tip":W,onClick:ne,children:ye}),we&&d.jsx(De,{tone:"primary",disabled:!!f,"data-tip":yN(U,!!((ht=pe==null?void 0:pe.config.check)!=null&&ht.trim()),F),onClick:ae,children:"check"}),B&&d.jsx("span",{className:"live-text",children:"check"}),ge&&V&&d.jsx(De,{tone:"primary",disabled:!!f,"data-tip":`Commit, take ${_e} in and push the branch; PR #${V.number} takes the new commits`,onClick:ne,children:"update"}),Ie&&d.jsx(De,{tone:"primary",disabled:!!f,"data-tip":"Merge the PR now, by the method the repo allows",onClick:ne,children:"land"})]}),V&&d.jsxs(De,{"data-tip":`Open PR #${V.number} on GitHub`,onClick:()=>window.open(V.url,"_blank"),...c.contextMenu(()=>[{id:"open-pr",label:"open on GitHub",onClick:()=>window.open(V.url,"_blank")},{id:"copy-link",label:"copy link",onClick:()=>Yt(V.url)}]),children:["view ",d.jsx(_t,{name:"external",className:"icon-inline"})]}),(V==null?void 0:V.preview)&&d.jsxs(De,{"data-tip":`Open the branch on ${new URL(V.preview).hostname}`,onClick:()=>window.open(V.preview,"_blank"),...c.contextMenu(()=>[{id:"open-preview",label:"open the preview",onClick:()=>window.open(V.preview,"_blank")},{id:"copy-preview",label:"copy link",onClick:()=>Yt(V.preview??"")}]),children:["preview ",d.jsx(_t,{name:"external",className:"icon-inline"})]})]})]}),(ve||ln)&&d.jsxs("div",{className:"composer-notes",children:[ln&&d.jsxs("div",{className:"hint composer-note","data-tip":_?Lg[_.status]:void 0,children:[d.jsx("span",{children:ln}),Je]}),ve&&d.jsxs("div",{className:"hint composer-note",children:[d.jsx("span",{children:ve}),f==="sync-main"?d.jsx("span",{className:"live-text",children:g?`sync: ${g}`:"sync"}):me?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(De,{variant:"outline",disabled:!!f||!!Se,"data-tip":Se??Ue,onClick:()=>Si(i,l,{t:"sync-main",worktreeId:h}),children:"sync"})]})]})]})}function Aw(){return L(e=>e.chatSide)}const c5=S.memo(function({c:t,id:n,selected:r,onToggle:o}){const i=wn("changes"),l=Aw();return d.jsxs("button",{className:"row row-sm log-row row-edge",id:n,"data-state":dr({current:r,cursor:r}),role:"option","aria-selected":r,tabIndex:-1,onClick:()=>o(t.sha),...i.contextMenu(()=>nN(t)),"data-tip":`${t.subject}
120
- ${t.short} · ${t.author}`,"data-tip-placement":l,children:[d.jsx("span",{className:"subject",children:t.subject}),d.jsx("span",{className:"at row-dim",children:ur(t.at)})]})});function u5(e,t){const n=_o(e,t);if(!n||!Sn(n))return"take this worktree over to change files here";if(wa(n.worktree))return"start a worktree to change files"}function SN(e,t,n,r){return{id:"new-file",label:"new file…",disabled:u5(e.getState(),t),onClick:()=>r(n)}}function d5(e,t,n,r){const{worktreeId:o,dir:i,path:l,folder:c,newIn:u}=e,h=gw(t.getState(),o)?void 0:"take this worktree over to talk to an agent here",f=x_(l,c),m=[...c?[]:[{id:"open",label:"open",onClick:()=>Ln(n,{worktreeId:o,path:l,view:ji(l)})}],{id:"add-to-chat",label:"add to chat",disabled:h,onClick:()=>tz(t,o,l,c)}],g=[SN(t,o,u,r),{id:"ask-rename",label:"ask the agent to rename…",disabled:h,onClick:()=>Fb(t,o,`Rename ${f} to `)},{id:"ask-delete",label:"ask the agent to delete…",disabled:h,onClick:()=>Fb(t,o,`Delete ${f} and update whatever still uses it`)}],w=[...os(()=>{var y;return(y=n.sock)==null?void 0:y.send({t:"reveal",worktreeId:o,path:l})},rs(n.sock)),{id:"copy-path",label:"copy path",onClick:()=>Yt(`${i}/${l}`)},{id:"copy-relative-path",label:"copy relative path",onClick:()=>Yt(l)}];return Dn([m,w,g])}function f5(e,t,n,r){return Dn([[SN(t,e.worktreeId,"",r)],os(()=>{var o;return(o=n.sock)==null?void 0:o.send({t:"reveal",worktreeId:e.worktreeId})},rs(n.sock))])}const tf=[],h5=[],tx=new Set,nx=e=>`tree-row-${e}`;function p5({worktreeId:e,dir:t,openPath:n,openRef:r,rootRef:o}){const i=Gn(),l=rt(),c=ct(),u=Rt(e,"files"),h=Rt(e,"submodules"),f=Rt(e,"ignored"),m=Rt(e,"git"),g=(m==null?void 0:m.files)??h5,w=m==null?void 0:m.version,y=L(ce=>ce.connected);ft([e,w,y,l],()=>Th(e,i.getState(),{sock:l,dispatch:c}));const v=L(ce=>{var Se;return((Se=ce.dragFiles)==null?void 0:Se.at)==="tree"&&ce.dragFiles.worktreeId===e?ce.dragFiles.dir:null}),_=L(ce=>ce.treeOpen[e]??tf),x=S.useMemo(()=>new Set(_),[_]),[T,N]=S.useState(tx);ft([e,n,r],()=>N(n&&!r?new Set(Pf(n).filter(ce=>!x.has(ce))):tx));const j=S.useCallback(ce=>x.has(ce)||T.has(ce),[x,T]),$=S.useCallback(ce=>{const Se=x.has(ce)||T.has(ce);if(Se&&T.has(ce)){const me=new Set(T);me.delete(ce),N(me)}c({a:"tree-folder",worktreeId:e,path:ce,open:!Se})},[x,T,e,c]),O=S.useMemo(()=>iz(u??tf,h??tf,f??tf),[u,h,f]),I=S.useMemo(()=>az(O,j),[O,j]),P=S.useMemo(()=>cz(g),[g]),R=L(ce=>ce.treeReveal),U=R&&R.worktreeId===e?R:null,[F,B]=S.useState(()=>(U==null?void 0:U.path)??null),[X,ae]=S.useState({worktreeId:e,linked:U});(X.worktreeId!==e||X.linked!==U)&&(ae({worktreeId:e,linked:U}),B((U==null?void 0:U.path)??null));const[Y,ne]=S.useState(!1),C=S.useMemo(()=>{if(F===null)return-1;const ce=I.findIndex(Se=>Se.path===F);if(ce>=0)return ce;for(const Se of Pf(F).reverse()){const me=I.findIndex(Ue=>Ue.path===Se);if(me>=0)return me}return-1},[I,F]);ft([C,Y],()=>{var ce,Se;Y&&((Se=(ce=o.current)==null?void 0:ce.querySelector('[data-state~="cursor"]'))==null||Se.scrollIntoView({block:"nearest"}))});const H=S.useCallback((ce,Se)=>Ln({dispatch:c},{worktreeId:e,path:ce,view:ji(ce),focus:Se}),[e,l,c]),V=S.useCallback(ce=>{B(ce.path),ce.kind==="folder"?$(ce.path):ce.kind==="file"&&H(ce.path,!1)},[$,H]),J=ce=>{var Ue;if(ce.metaKey||ce.ctrlKey||ce.altKey)return;const Se=I[C],me=Ie=>{const We=I[Ie];We&&(B(We.path),We.kind==="file"&&H(We.path,!1))};switch(ce.key){case"ArrowDown":case"ArrowUp":ce.preventDefault(),me(C<0?0:xu(C,ce.key==="ArrowDown"?1:-1,I.length));return;case" ":ce.preventDefault(),(Se==null?void 0:Se.kind)==="file"?H(Se.path,!1):(Se==null?void 0:Se.kind)==="folder"&&$(Se.path);return;case"Enter":ce.preventDefault(),(Se==null?void 0:Se.kind)==="file"?H(Se.path,!0):(Se==null?void 0:Se.kind)==="folder"&&$(Se.path);return;case"ArrowRight":case"ArrowLeft":{ce.preventDefault();const Ie=I.map(mt=>mt.kind==="folder"?{depth:mt.depth,open:mt.open}:{depth:mt.depth}),We=Ih(Ie,C,ce.key);(We==null?void 0:We.do)==="to"?me(We.at):We&&Se&&$(Se.path);return}case"Escape":ce.stopPropagation(),n!==null?c({a:"close-editor"}):(Ue=document.activeElement)==null||Ue.blur();return}if(ce.key.length===1){const Ie=Z_(I.map(We=>We.name),C,ce.key);Ie>=0&&(ce.preventDefault(),me(Ie))}},[Z,ie]=S.useState(null),be=S.useRef(0),ge=S.useCallback(ce=>{ce&&!j(ce)&&$(ce),be.current++,ie({dir:ce,error:null,busy:!1})},[j,$]),we=S.useCallback(()=>{be.current++,ie(null)},[]),pe=S.useCallback(ce=>{if(!Z||Z.busy)return;const Se=lz(Z.dir,ce);if("error"in Se){ie({...Z,error:Se.error});return}const me=++be.current;ie({...Z,error:null,busy:!0}),k_({sock:l,dispatch:c},{worktreeId:e,path:Se.path}).then(Ue=>{Ue===null&&B(Se.path),me===be.current&&ie(Ue===null?null:{...Z,error:Ue,busy:!1})})},[Z,e,l,c]),Q=wn("tree"),W=S.useCallback(ce=>d5({worktreeId:e,dir:t,path:ce.path,folder:ce.kind!=="file",newIn:ce.kind==="folder"||ce.kind==="ignored"?ce.path:__(ce.path)},i,{sock:l,dispatch:c},ge),[e,t,i,l,c,ge]),ye=S.useCallback((ce,Se)=>{ce.kind==="file"&&un.post(e,Se?{type:"highlight-file",path:ce.path,ranges:null}:{type:"highlight-clear"})},[e]),_e=S.useCallback((ce,Se)=>tu(Se,{kind:"paths",worktreeId:e,items:[{path:ce.path,folder:ce.kind!=="file"}]}),[e]),ve=S.useCallback(()=>Eu(i),[i]);return d.jsx("div",{className:He("tree",v===""&&"drop-over"),role:"tree","aria-label":"files","data-worktree":e,"aria-activedescendant":Y&&C>=0?nx(C):void 0,tabIndex:0,ref:o,onKeyDown:J,onFocus:()=>{var ce;ne(!0),F===null&&B(n&&I.some(Se=>Se.path===n)?n:((ce=I[0])==null?void 0:ce.path)??null)},onBlur:ce=>!ce.currentTarget.contains(ce.relatedTarget)&&ne(!1),onMouseDown:ce=>{if(ce.button!==0)return;const Se=ce.target.closest("[data-path]");(Se==null?void 0:Se.dataset.path)!==void 0&&B(Se.dataset.path)},...Q.contextMenu(ce=>{const Se=I[C];return ce==="keyboard"&&Se?W(Se):f5({worktreeId:e},i,{sock:l},ge)}),children:u===void 0?d.jsx("div",{className:"empty",children:d.jsx("span",{className:"live-text",children:"listing files"})}):I.length===0&&!Z?d.jsx("div",{className:"empty",children:"no files"}):m5(I.map((ce,Se)=>d.jsx(k5,{row:ce,id:nx(Se),status:P.files.get(ce.path),changedInside:ce.kind!=="file"&&P.folders.has(ce.path),current:Y?Se===C:!r&&ce.path===n,cursor:Y&&Se===C,dropOver:v===ce.path,onPress:V,menu:W,onHover:ye,onDragStart:_e,onDragEnd:ve},ce.path)),Z&&(()=>{var Se;const ce=Z.dir===""?-1:I.findIndex(me=>me.path===Z.dir);return{at:ce,node:d.jsx(g5,{depth:ce>=0?(((Se=I[ce])==null?void 0:Se.depth)??0)+1:0,error:Z.error,onSubmit:pe,onCancel:we},"new-file")}})())})}function m5(e,t){return t?[...e.slice(0,t.at+1),t.node,...e.slice(t.at+1)]:e}function g5({depth:e,error:t,onSubmit:n,onCancel:r}){const[o,i]=S.useState(""),l={"--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:l,children:[d.jsx("span",{className:"tree-caret row-dim"}),d.jsx(zo,{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=>i(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:l,children:[d.jsx("span",{className:"tree-caret"}),d.jsx("span",{className:"hint",children:t})]})]})}const k5=S.memo(function({row:t,id:n,status:r,changedInside:o,current:i,cursor:l,dropOver:c,onPress:u,menu:h,onHover:f,onDragStart:m,onDragEnd:g}){const w=wn("tree"),y=Aw(),v=t.kind==="submodule",_=v?"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":l,className:He("row row-sm tree-row row-rails row-edge",c&&"drop-over"),"data-state":dr({current:i,cursor:l}),"data-kind":t.kind,"data-path":t.path,style:{"--tree-depth":t.depth},draggable:!v,onDragStart:x=>m(t,x),onDragEnd:g,onClick:()=>u(t),onMouseEnter:()=>f(t,!0),onMouseLeave:()=>f(t,!1),...w.contextMenu(()=>h(t)),..._?zt(_,void 0,{placement:y}):{},children:[d.jsx("span",{className:"tree-caret row-dim",children:t.kind==="folder"&&d.jsx(_t,{name:"caret",className:He("icon-inline disc-caret",!t.open&&"shut")})}),d.jsx("span",{className:He("tree-name",(v||t.ignored)&&"row-dim"),children:t.name}),r?d.jsx("span",{className:`xy ${Zk(r.xy)}`,children:qk(r.xy)}):o&&d.jsx("span",{className:"dot tree-changed"})]})});function _N({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 nf=S.memo(function({f:t,id:n,active:r,selected:o,checking:i=!1,checked:l=!1,onOpen:c,onCheck:u,menu:h,onHover:f,onDragStart:m,onDragEnd:g}){const w=wn("changes"),y=Aw(),{name:v,dir:_}=mS(t.path);return d.jsxs("button",{className:"row row-sm git-file row-edge",id:n,"data-state":dr({current:r,cursor:o,checked:l}),role:"option","aria-selected":o,tabIndex:-1,onClick:x=>u&&(i||x.shiftKey)?u(t.path):c(t.path),draggable:!!m,onDragStart:m&&(x=>m(t.path,x)),onDragEnd:g,...w.contextMenu(()=>h(t.path)),onMouseEnter:()=>f(t.path,!0),onMouseLeave:()=>f(t.path,!1),"data-tip":_?t.path:void 0,"data-tip-placement":y,children:[i&&d.jsx("input",{type:"checkbox",className:"changes-check",checked:l,readOnly:!0,tabIndex:-1}),d.jsx("span",{className:`xy ${Zk(t.xy)}`,children:qk(t.xy)}),d.jsxs("span",{className:"path",children:[d.jsx("span",{className:"name",children:v}),_&&d.jsx("span",{className:"dir row-dim",children:_})]}),d.jsx(_N,{f:t})]})}),w5={added:"A",changed:"M",removed:"D"},y5={added:"added",changed:"",removed:"deleted"},v5=S.memo(function({tests:t,id:n,cursor:r,onPick:o}){return t.map((i,l)=>d.jsxs("button",{className:"row row-sm changes-test row-rails row-edge",id:`${n}-t${l}`,"data-state":dr({current:r===l,cursor:r===l}),"data-sub":!0,role:"option","aria-selected":r===l,tabIndex:-1,onClick:()=>o(l),"data-tip":[...i.group,i.name].join(" · "),"data-tip-placement":"follow",children:[d.jsx("span",{className:`xy ${y5[i.change]}`,children:w5[i.change]}),d.jsx("span",{className:"name",children:i.name})]},l))}),rx=new Set(["test","tests","__tests__","spec","e2e","__snapshots__","__mocks__","fixtures","testdata"]),b5=/([._-]tests?\.[^.]+$)|([._]specs?\.[^.]+$)|(^tests?[._-])|(^conftest\.py$)|(\.snap$)|([a-z0-9](Tests?|Spec)\.[^.]+$)/;function Uf(e){const t=(e.endsWith("/")?e.slice(0,-1):e).split("/"),n=t.pop()??"";return e.endsWith("/")&&rx.has(n.toLowerCase())?!0:t.some(r=>rx.has(r.toLowerCase()))||b5.test(n)}function rf(e){const t=e.filter(n=>!Uf(n.path));return t.length===0||t.length===e.length?{files:e,source:t.length}:{files:[...t,...e.filter(n=>Uf(n.path))],source:t.length}}const Dg="(?<q>[\"'`])(?<name>(?:\\\\.|(?!\\k<q>).)*)\\k<q>",ox={tests:[new RegExp(`^\\s*(?:test|it)(?:\\.(?!each\\b)\\w+)*(?:\\.each\\(.*\\))?\\(\\s*${Dg}`)],groups:[new RegExp(`^\\s*describe(?:\\.(?!each\\b)\\w+)*(?:\\.each\\(.*\\))?\\(\\s*${Dg}`)]},x5={js:ox,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*${Dg}`),/^\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*\(/,...ox.tests]}},E5={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"},S5=3,_5=/^\s*(?:[)}\]]|end\b)/,Mm=e=>e.length-e.trimStart().length;function sx(e,t){var n,r;for(const o of t??[]){const i=(r=(n=o.exec(e))==null?void 0:n.groups)==null?void 0:r.name;if(i!==void 0)return i.replace(/^(["'`])(.*)\1$/,"$2")}return null}function ix(e,t){const n=t.split(`
121
- `),r=[],o=[];let i=Number.NEGATIVE_INFINITY;return n.forEach((l,c)=>{var g,w,y;if(l.trim()==="")return;const u=Mm(l);for(;o.length>0&&(((g=o.at(-1))==null?void 0:g.indent)??0)>=u;)o.pop();(w=e.mark)!=null&&w.test(l)&&(i=c);const f=!e.mark||c-i<=S5?sx(l,e.tests):null,m=f??sx(l,e.groups);if(m!==null){if(f!==null){i=Number.NEGATIVE_INFINITY;let v=c+1;for(;v<n.length&&(((y=n[v])==null?void 0:y.trim())===""||Mm(n[v]??"")>u);)v++;v<n.length&&Mm(n[v]??"")===u&&_5.test(n[v]??"")&&v++;const _=n.slice(c,v).map(x=>x.trim()).join(`
122
- `).trim();r.push({group:o.map(x=>x.name),name:m,line:c,end:v,body:_})}o.push({indent:u,name:m})}}),r}function ax(e){const t=new Map;for(const n of e){const r=[...n.group,n.name].join(`
123
- `);let o=0;for(;t.has(`${r}
124
- ${o}`);)o++;t.set(`${r}
125
- ${o}`,n)}return t}function N5(e,t,n){const r=x5[E5[e.slice(e.lastIndexOf(".")+1).toLowerCase()]??""];if(!r)return[];const o=ax(ix(r,t)),i=ax(ix(r,n)),l=[];for(const[f,m]of i){const g=o.get(f);(g==null?void 0:g.body)!==m.body&&l.push({name:m.name,group:m.group,change:g?"changed":"added",line:m.line+1})}const c=n.split(`
126
- `).length;let u=1;for(const[f,m]of o){const g=i.get(f);g?u=Math.min(g.end+1,c):l.push({name:m.name,group:m.group,change:"removed",line:u})}const h=f=>f.change==="removed"?0:1;return l.sort((f,m)=>f.line-m.line||h(f)-h(m))}const of=[];function T5(e,t,n,r){const o=t?n>0?"no changes of its own":`same as ${e}`:"no changes";if(!r)return o;const i=ur(r.at);return`${o}, last commit ${i==="now"?"just now":`${i} ago`}`}const lx='[role="option"]:not([data-sub])',cx=[];function NN({width:e,placement:t="dock"}){var yr,Hn;const n=t==="screen",r=rt(),o=ct(),i=Gn(),l=Hl(),c=_a(),u=(c==null?void 0:c.id)??l,h=Ps(),f=L(G=>G.layout.changes),m=vu(),g=L(G=>G.focusChanges),w=Rt(u,"git"),y=L(G=>G.editor&&G.editor.worktreeId===u?G.editor.path:null),v=L(G=>G.editor&&G.editor.worktreeId===u?G.editor.ref??null:null),_=L(G=>G.editor&&G.editor.worktreeId===u?G.editor.since??null:null),x=(w==null?void 0:w.files)??of,T=((yr=w==null?void 0:w.extras)==null?void 0:yr.committed)??of,{files:N,source:j}=S.useMemo(()=>rf(x),[x]),$=T.length>0,O=wD(),{files:I,source:P}=S.useMemo(()=>rf(O?T:of),[T,O]),R=(Hn=w==null?void 0:w.extras)==null?void 0:Hn.turn,U=R==null?void 0:R.base,F=yD(),{files:B,source:X}=S.useMemo(()=>rf(R&&F?R.files:of),[R,F]),ae=N.length,Y=N.length+B.length,ne=L(G=>G.editor&&G.editor.worktreeId===u?G.editor.disk:null),C=S.useMemo(()=>y!==null&&ne&&Uf(y)?N5(y,ne.before,ne.after):cx,[y,ne]),[H,V]=S.useState(!1);ft([y,v,_],()=>V(!1));const J=j>0?N.length-j:0,Z=P>0?I.length-P:0,ie=X>0?B.length-X:0,be=N.length===0,ge=S.useMemo(()=>{if(N.length===0)return;const G=N.reduce((Nt,vn)=>Nt+(vn.add??0),0),fe=N.reduce((Nt,vn)=>Nt+(vn.del??0),0),tt=[G>0&&`+${G}`,fe>0&&`−${fe}`].filter(Boolean).join(" "),kt=`${N.length} uncommitted ${N.length===1?"file":"files"}`;return tt?`${kt}, ${tt}`:kt},[N]),we=!!w&&be&&(w.ahead??0)===0,pe=L(Ol),Q=c!==null||pe==="changes",W=c!==null||pe==="history",ye=S.useCallback(G=>o({a:"changes-tab",v:G}),[o]),_e=S.useRef(pe);_e.current=pe;const ve=S.useRef(null),ce=cw(),Se=L(G=>{const fe=Ii(G,ce==null?void 0:ce.repoId);return fe?sh(fe):"main"}),me=Rt(u,"commits"),Ue=Rt(u,"commitFiles"),[Ie,We]=S.useState(null),mt=S.useRef(null);mt.current=Ie;const en=S.useRef(null),Kt=Rt(u,"changedRanges"),Be=S.useCallback((G,fe)=>{if(!u||c)return;if(!fe){en.current=null,un.post(u,{type:"highlight-clear"});return}en.current=G;const tt=Kt[G];tt?un.post(u,{type:"highlight-file",path:G,ranges:vb(tt)}):r==null||r.send({t:"changed-ranges",worktreeId:u,path:G})},[u,c,Kt,r]);S.useEffect(()=>{const G=en.current;if(!G||!u)return;const fe=Kt[G];fe&&un.post(u,{type:"highlight-file",path:G,ranges:vb(fe)})},[Kt,u]);const Xt=c&&N.length>0?(w==null?void 0:w.head)??null:null,ln=S.useCallback((G,fe=!1,tt)=>u&&Ln({dispatch:o},{worktreeId:u,path:G,focus:fe,ref:Xt??void 0,since:tt}),[u,Xt,r,o]),It=S.useMemo(()=>c?N:[...N,...B,...I],[c,N,B,I]),Je=S.useMemo(()=>{const G=[];for(const fe of me??[])if(G.push({commit:fe}),fe.sha===Ie)for(const tt of rf(Ue[fe.sha]??[]).files)G.push({commit:fe,file:tt});return G},[me,Ie,Ue]),Vt=S.useMemo(()=>Je.filter(G=>!G.file&&G.commit.ahead).length,[Je]),tn=S.useMemo(()=>Je.findIndex(G=>!G.file&&!G.commit.ahead),[Je]),ht=c?It.length:0,gt=(Q?It.length:0)+(W?Je.length:0),sn=S.useMemo(()=>{const G=new Map;if(!c||N.length===0&&Je.every(tt=>tt.commit.landedAt))return G;let fe;return Je.forEach((tt,kt)=>{const Nt=!!tt.commit.landedAt;Nt!==fe&&(fe=Nt,G.set(kt,Nt?"landed":"not landed"))}),G},[c,N,Je]),kn=S.useRef(null),[{row:Pt,at:Rn},bt]=S.useReducer((G,fe)=>typeof fe=="number"?{row:fe,at:-1}:fe,{row:0,at:-1}),[ee,ke]=S.useState(!1),Xe=(G,fe)=>ee?sr(G):fe,Ge=G=>`changes-row-${G}`,[Zt,Bt]=S.useState(!1),[mn,an]=S.useState([]),xn=S.useCallback(()=>{Bt(!1),an([])},[]),M=S.useCallback(G=>{Bt(!0),an(fe=>fe.includes(G)?fe.filter(tt=>tt!==G):[...fe,G])},[]),re=S.useMemo(()=>N.filter(G=>mn.includes(G.path)).map(G=>G.path),[N,mn]);ft([N],()=>an(G=>{const fe=G.filter(tt=>N.some(kt=>kt.path===tt));return fe.length===G.length?G:fe})),ft([Zt],()=>{if(!Zt)return;const G=fe=>fe.key==="Escape"&&xn();return window.addEventListener("keydown",G),()=>window.removeEventListener("keydown",G)}),ft([u,pe],()=>{bt(0),xn()});const Ne=w==null?void 0:w.head,Ze=S.useRef("");S.useEffect(()=>{if(!(W||we)||!u)return;const G=`${u}:${Ne??""}`;Ze.current!==G&&(Ze.current=G,r==null||r.send({t:"git-log",worktreeId:u}))},[W,we,u,Ne,r]);const jt=S.useCallback(G=>{We(fe=>fe===G?null:G),u&&!Ue[G]&&(r==null||r.send({t:"git-commit",worktreeId:u,sha:G}))},[u,Ue,r]);ft([Pt,Rn,ee],()=>{var G,fe;ee&&((fe=(G=kn.current)==null?void 0:G.querySelector('[data-state~="cursor"]'))==null||fe.scrollIntoView({block:"nearest"}))});const Ut=S.useRef(-1),Me=G=>G>=ae&&G<Y?U:void 0,Pe=G=>{var fe;return((fe=It[G])==null?void 0:fe.path)===y&&(_??void 0)===Me(G)&&(G<ae?v===Xt:!v)};Ut.current=Q?It.findIndex((G,fe)=>Pe(fe)):-1,S.useEffect(()=>{if(!g)return;const G=_e.current==="files";Ut.current>=0&&bt(Ut.current);const fe=requestAnimationFrame(()=>{var tt;return(tt=(G?ve:kn).current)==null?void 0:tt.focus()});return()=>cancelAnimationFrame(fe)},[g]);const Ve=S.useCallback((G,fe=!1)=>{const tt=It[G];tt&&(bt(G),ln(tt.path,fe,G>=ae&&G<Y?U:void 0),Be(tt.path,!0))},[It,ln,Be,ae,Y,U]),Lt=S.useCallback((G,fe=!1)=>{const tt=mt.current;u&&tt&&Ln({dispatch:o},{worktreeId:u,path:G,ref:tt,focus:fe})},[u,r,o]),qt=S.useCallback(G=>{const fe=Je[G-ht];fe&&(bt(G),fe.file&&Lt(fe.file.path))},[Je,ht,Lt]),zn=S.useCallback(G=>{const fe=Je[G-ht];fe&&(bt(G),fe.file?Lt(fe.file.path,!0):jt(fe.commit.sha))},[Je,ht,Lt,jt]),et=G=>W&&G>=ht,Ht=G=>{if(y===null)return!1;if(Q&&G<It.length)return Pe(G);const fe=et(G)?Je[G-ht]:void 0;return!!(fe!=null&&fe.file)&&v===fe.commit.sha&&fe.file.path===y},On=G=>Ht(G)&&!H?C:cx,dn=Rn<On(Pt).length?Rn:-1,sr=G=>ee&&Pt===G&&dn<0,Fn=()=>{var fe,tt;const G=[];for(let kt=0;kt<gt;kt++){const Nt=et(kt)?Je[kt-ht]:void 0,vn=Nt?(fe=Nt.file)==null?void 0:fe.path:(tt=It[kt])==null?void 0:tt.path,Wn=Nt!=null&&Nt.file?1:0,ar=On(kt);Nt&&!Nt.file?G.push({row:kt,at:-1,depth:Wn,open:Nt.commit.sha===Ie}):vn!==void 0&&Uf(vn)?G.push({row:kt,at:-1,depth:Wn,open:ar.length>0}):G.push({row:kt,at:-1,depth:Wn});for(let jr=0;jr<ar.length;jr++)G.push({row:kt,at:jr,depth:Wn+1})}return G},hr=(G,fe=!1)=>{const tt=C[G];!tt||!u||y===null||Ln({dispatch:o},{worktreeId:u,path:y,ref:v??void 0,since:_??void 0,line:{n:tt.line},focus:fe})},oe=G=>On(G).length>0&&d.jsx(v5,{tests:C,id:Ge(G),cursor:ee&&Pt===G?dn:-1,onPick:fe=>{bt({row:G,at:fe}),hr(fe)}}),Le=G=>{var fe;if(Zt&&G.key==="Escape")G.preventDefault(),G.stopPropagation(),xn();else if(Zt&&G.key===" "){G.preventDefault();const tt=Q&&Pt<N.length?N[Pt]:void 0;tt&&M(tt.path)}else if(G.key==="ArrowDown"&&dn+1<On(Pt).length)G.preventDefault(),bt({row:Pt,at:dn+1}),hr(dn+1);else if(G.key==="ArrowUp"&&dn>=0)G.preventDefault(),dn===0?bt(Pt):(bt({row:Pt,at:dn-1}),hr(dn-1));else if(G.key==="Enter"&&dn>=0)G.preventDefault(),hr(dn,!0);else if(G.key==="ArrowDown"||G.key==="ArrowUp"){G.preventDefault();const tt=xu(Pt,G.key==="ArrowDown"?1:-1,gt);et(tt)?qt(tt):Ve(tt)}else if(G.key==="Enter")G.preventDefault(),et(Pt)?zn(Pt):Ve(Pt,!0);else if(G.key==="ArrowRight"||G.key==="ArrowLeft"){G.preventDefault();const tt=Fn(),kt=Ih(tt,tt.findIndex(Wn=>Wn.row===Pt&&Wn.at===dn),G.key),Nt=kt&&tt[kt.at];if(!kt||!Nt)return;const vn=et(Nt.row)?Je[Nt.row-ht]:void 0;kt.do==="to"?Nt.at>=0?(bt({row:Nt.row,at:Nt.at}),hr(Nt.at)):vn!=null&&vn.file&&Nt.row>Pt?qt(Nt.row):bt(Nt.row):vn&&!vn.file?jt(vn.commit.sha):kt.do==="close"?V(!0):Ht(Nt.row)?V(!1):vn!=null&&vn.file?qt(Nt.row):Ve(Nt.row)}else G.key==="Escape"&&(G.stopPropagation(),y!==null?o({a:"close-editor"}):(fe=document.activeElement)==null||fe.blur())},Ye=c?c.id:h==null?void 0:h.worktree.id,$t=c?c.path:h?h.worktree.path:"",pt=c!==null,yn=S.useMemo(()=>Ye?(G,fe)=>tu(fe,{kind:"paths",worktreeId:Ye,items:[{path:G,folder:!1}]}):void 0,[Ye]),Tr=S.useRef(re);Tr.current=re;const ir=S.useMemo(()=>Ye?(G,fe)=>{const tt=Tr.current;if(!tt.includes(G))return yn==null?void 0:yn(G,fe);tu(fe,{kind:"paths",worktreeId:Ye,items:tt.map(kt=>({path:kt,folder:!1}))})}:void 0,[Ye,yn]),Wt=S.useCallback(()=>Eu(i),[i]),Yr=S.useCallback(G=>Ye?Is({id:Ye,dir:$t},G,{discard:!pt,kept:pt,ref:Xt??void 0,select:pt?void 0:M},{sock:r,dispatch:o}):[],[Ye,$t,pt,Xt,M,r,o]),dt=S.useCallback(G=>Ye?Is({id:Ye,dir:$t},G,{kept:pt},{sock:r,dispatch:o}):[],[Ye,$t,pt,r,o]),Bn=S.useCallback(G=>Ye?Is({id:Ye,dir:$t},G,{kept:pt,since:U},{sock:r,dispatch:o}):[],[Ye,$t,pt,U,r,o]),st=S.useCallback(G=>Ye?Is({id:Ye,dir:$t},G,{ref:mt.current??void 0,kept:pt},{sock:r,dispatch:o}):[],[Ye,$t,pt,r,o]),Te=wn("changes"),qe=()=>{if(Q&&Pt<It.length){const fe=It[Pt];return fe?(Pt<ae?Yr:Pt<Y?Bn:dt)(fe.path):[]}const G=et(Pt)?Je[Pt-ht]:void 0;return G?G.file?st(G.file.path):nN(G.commit):[]},xt=(G,fe)=>{const tt=It.findIndex((kt,Nt)=>Nt>=G&&kt.path===fe);bt(tt),Pe(tt)&&C.length>0?V(kt=>!kt):ln(fe,!1,Me(tt))},at=S.useRef(xt);at.current=xt;const fn=S.useCallback(G=>at.current(0,G),[]),Ft=S.useCallback(G=>at.current(ae,G),[ae]),cn=S.useCallback(G=>at.current(Y,G),[Y]),Hr=S.useCallback(G=>{bt(ht+Je.findIndex(fe=>!fe.file&&fe.commit.sha===G)),jt(G)},[Je,ht,jt]),$n=S.useCallback(G=>{bt(ht+Je.findIndex(fe=>{var tt;return((tt=fe.file)==null?void 0:tt.path)===G})),G===y&&v===mt.current&&C.length>0?V(fe=>!fe):Lt(G)},[Je,ht,Lt,y,v,C]),Un=S.useCallback(()=>{},[]);return d.jsxs("div",{className:He("changes-dock",n&&"changes-screen",!n&&(!f||m)&&"collapsed"),style:n?void 0:{width:e},children:[!c&&d.jsx(Ah,{fill:!n,quiet:n,owner:"changes-tabs",label:"changes panel",items:[{id:"files",label:d.jsx(_t,{name:"folder",className:"icon-inline"}),fit:!0,ariaLabel:"files",tip:zt("files",Dt("files"))},{id:"changes",label:"changes",tip:zt("changes",Dt("changes"),{detail:ge})},{id:"history",label:"history"}],current:pe,onPick:ye}),pe==="files"&&u?d.jsx(p5,{worktreeId:u,dir:h?h.worktree.path:(ce==null?void 0:ce.path)??"",openPath:y,openRef:v,rootRef:ve}):d.jsxs("div",{className:He("changes-list",W&&"history"),role:"listbox","aria-label":c?"kept work":W?"commits":"changed files","aria-activedescendant":ee&&Pt>=0&&Pt<gt?dn<0?Ge(Pt):`${Ge(Pt)}-t${dn}`:void 0,tabIndex:0,ref:kn,onKeyDown:Le,onFocus:()=>ke(!0),onMouseDown:G=>{var kt;if(G.button!==0)return;G.preventDefault();const fe=G.target.closest(lx),tt=fe?Array.from(G.currentTarget.querySelectorAll(lx)).indexOf(fe):-1;tt>=0&&bt(tt),(kt=kn.current)==null||kt.focus()},onBlur:G=>!G.currentTarget.contains(G.relatedTarget)&&ke(!1),...Te.contextMenu(G=>G==="keyboard"?qe():[]),children:[Q&&N.length>0&&d.jsxs(d.Fragment,{children:[($||((w==null?void 0:w.ahead)??0)>0||c)&&d.jsx("div",{className:"section-title section-row",children:"uncommitted"}),N.map((G,fe)=>d.jsxs(S.Fragment,{children:[J>0&&fe===j&&d.jsx("div",{className:"section-title changes-sub",children:"tests"}),d.jsx(nf,{f:G,id:Ge(fe),active:Xe(fe,Ht(fe)),selected:sr(fe),checking:Zt,checked:mn.includes(G.path),onOpen:fn,onCheck:pt?void 0:M,menu:Yr,onHover:Be,onDragStart:ir,onDragEnd:Wt}),oe(fe)]},`${G.xy}:${G.path}`))]}),Q&&!c&&R&&d.jsxs(d.Fragment,{children:[d.jsxs("button",{type:"button",className:"section-title section-row section-fold","aria-expanded":F,"data-tip":"What changed since your last message","data-tip-placement":"follow",onClick:()=>o({a:"toggle-turn"}),onKeyDown:G=>(G.key==="Enter"||G.key===" ")&&G.stopPropagation(),children:["last turn",d.jsx(_t,{name:"caret",className:He("icon-inline disc-caret",!F&&"shut")})]}),B.map((G,fe)=>d.jsxs(S.Fragment,{children:[ie>0&&fe===X&&d.jsx("div",{className:"section-title changes-sub",children:"tests"}),d.jsx(nf,{f:G,id:Ge(ae+fe),active:Xe(ae+fe,Ht(ae+fe)),selected:sr(ae+fe),onOpen:Ft,menu:Bn,onHover:Be,onDragStart:yn,onDragEnd:Wt}),oe(ae+fe)]},`t-${G.path}`))]}),Q&&!c&&$&&d.jsxs(d.Fragment,{children:[d.jsxs("button",{type:"button",className:"section-title section-row section-fold","aria-expanded":O,"data-tip":`Committed on this branch, not yet on ${Se}`,"data-tip-placement":"follow",onClick:()=>o({a:"toggle-committed"}),onKeyDown:G=>(G.key==="Enter"||G.key===" ")&&G.stopPropagation(),children:["committed",d.jsx(_t,{name:"caret",className:He("icon-inline disc-caret",!O&&"shut")})]}),I.map((G,fe)=>d.jsxs(S.Fragment,{children:[Z>0&&fe===P&&d.jsx("div",{className:"section-title changes-sub",children:"tests"}),d.jsx(nf,{f:G,id:Ge(Y+fe),active:Xe(Y+fe,Ht(Y+fe)),selected:sr(Y+fe),onOpen:cn,menu:dt,onHover:Be,onDragStart:yn,onDragEnd:Wt}),oe(Y+fe)]},`c-${G.path}`))]}),Q&&!c&&we&&d.jsx("div",{className:"empty",children:T5(Se,!!ce&&oh(ce),(w==null?void 0:w.behind)??0,me==null?void 0:me[0])}),W&&Je.map((G,fe)=>d.jsxs(S.Fragment,{children:[c&&sn.has(fe)&&d.jsx("div",{className:"section-title section-row",children:sn.get(fe)}),!c&&Vt>0&&fe===0&&d.jsx("div",{className:"section-title section-row",children:"on this branch"}),!c&&Vt>0&&fe===tn&&d.jsx("div",{className:"section-title section-row",children:Se}),G.file?d.jsxs(d.Fragment,{children:[d.jsx(nf,{f:G.file,id:Ge(ht+fe),active:Xe(ht+fe,Ht(ht+fe)),selected:sr(ht+fe),onOpen:$n,menu:st,onHover:Un,onDragStart:yn,onDragEnd:Wt}),oe(ht+fe)]}):d.jsx(c5,{c:G.commit,id:Ge(ht+fe),selected:sr(ht+fe),onToggle:Hr})]},G.file?`${G.commit.sha}:${G.file.path}`:G.commit.sha)),W&&me===void 0&&d.jsx("div",{className:"empty",children:d.jsx("span",{className:"live-text",children:"reading history"})}),W&&(me==null?void 0:me.length)===0&&N.length===0&&d.jsx("div",{className:"empty",children:"no commits yet"})]}),Zt&&d.jsxs("div",{className:"changes-pick",children:[d.jsxs(De,{size:"md",tone:"danger",disabled:re.length===0,"data-tip":"Throw away the uncommitted changes to every checked file",onClick:()=>{!Ye||re.length===0||window.confirm(w_(re))&&(r==null||r.send({t:"discard-files",worktreeId:Ye,paths:re}),xn())},children:["discard ",re.length,"…"]}),d.jsx(De,{size:"md",disabled:re.length===0,"data-tip":"Name every checked file in the chat",onClick:()=>{Ye&&nz(i,Ye,re),xn()},children:"add to chat"}),d.jsx(Ot,{icon:"close",label:"Cancel",hint:"esc",onClick:xn})]}),ce&&!c&&d.jsx(l5,{active:ce,ahead:(w==null?void 0:w.ahead)??ce.ahead??0,behind:(w==null?void 0:w.behind)??ce.behind??0,unpushed:(w==null?void 0:w.unpushed)??ce.unpushed??0,dirty:!be})]})}function j5(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 ux(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 Su(e){return e>0&&e<.005?"<$0.01":`$${e.toFixed(2)}`}function $5(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 C5(e){if(!(e<.5))return e<.8?"worth compacting between tasks":"compact before the next task"}const TN=["five_hour","seven_day","seven_day_overage_included"],A5={five_hour:"the 5-hour window",seven_day:"the week",seven_day_overage_included:"the Fable week"},I5={five_hour:"5-hour",seven_day:"this week",seven_day_overage_included:"Fable week"};function jN(e,t){return TN.flatMap(n=>{const r=e.windows[n];return r&&r.resetsAt>t?[{key:n,used:r.used,resetsAt:r.resetsAt}]:[]})}function R5(e,t){return Math.min(1,Math.max(0,...jN(e,t).map(n=>n.used)))}const O5=e=>`${Math.round(100*e)}%`;function dx(e,t){const n=jN(e,t).map(r=>`${O5(r.used)} of ${A5[r.key]}`);return n.length?n.join(", "):"plan windows reset"}function M5(e,t,n){const r=new Date(e),o=new Date(t),i=r.toDateString()===o.toDateString();return new Intl.DateTimeFormat(n,{...i?{}:{month:"short",day:"numeric"},hour:"numeric",minute:"2-digit"}).format(r)}function P5(e,t,n=r=>M5(r,t)){return TN.flatMap(r=>{const o=e.windows[r];if(!o)return[];const i=I5[r];if(o.resetsAt<=t)return[{key:r,name:i,used:0,sub:`reset ${n(o.resetsAt)}, read again on the next reply`}];const l=e.binding===r&&e.status==="rejected"?", out until then":e.binding===r&&e.status==="allowed_warning"?", nearly out":"";return[{key:r,name:i,used:o.used,sub:`resets ${n(o.resetsAt)}${l}`}]})}function L5(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 $N(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(Su(e.cost)),t.push(ur(e.archivedAt)),t.filter(Boolean).join(" · ")}function CN({sock:e},t,n){e==null||e.send({t:"restore-worktree",archiveId:t,clientId:n})}function yf(e,t,{sock:n,dispatch:r}){const o=[{id:"restore",label:"restore",disabled:e.restorable?void 0:"its commits were not kept",onClick:()=>{CN({sock:n},e.id,t.clientId),r({a:"close"})}}],i=[{id:"copy-branch",label:"copy branch name",onClick:()=>Yt(e.branch)}],{sessionId:l}=e;return t.frame!=="phone"&&(i.push({id:"copy-transcript",label:"copy transcript path",onClick:()=>Yt(e.transcript)}),l&&i.push({id:"copy-session",label:"copy session id",onClick:()=>Yt(l)})),Dn([o,i,[{id:"delete",label:"delete…",danger:!0,onClick:()=>{window.confirm(`Delete "${e.title}"?
127
-
128
- 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 D5=new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"});function AN(e){const[t,n]=S.useState(()=>Date.now());return S.useEffect(()=>{const r=setInterval(()=>n(Date.now()),6e4);return()=>clearInterval(r)},[]),`${Yk(t-e)} ago`}function Ir({icon:e,word:t,tone:n,at:r,below:o,children:i,...l}){const c=r!==void 0?{"data-tip":`${t} ${D5.format(r)}`,"data-tip-placement":"top"}:null,u=(Array.isArray(o)?o:[o]).filter(h=>h!=null&&h!==!1);return d.jsx("div",{...l,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(_t,{name:e,className:"icon-inline"}),t]}),d.jsxs("div",{className:"daemon-body",children:[d.jsx("div",{className:"daemon-line",children:i}),u.map((h,f)=>d.jsx("div",{className:"daemon-below row-dim",children:h},f))]})]})})}function z5({item:e}){const t=rt(),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 ${Su(e.cost)}`:"",i=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.`,l=AN(e.archivedAt),c=Nw(e.lands);return d.jsxs(Ir,{icon:"archive",word:"archived",tone:"quiet",at:e.archivedAt,below:[...c,i],children:[d.jsxs("span",{className:"daemon-text",children:[l,e.landed?", after it was merged into main":""]}),e.restorable&&d.jsx(De,{variant:"inline",tone:"strong",onClick:()=>CN({sock:t},e.id,n),children:"restore"})]})}function ga(e,t,n,r,o){const{layout:i}=e.getState();Ln({dispatch:e.dispatch},{worktreeId:n,path:r,view:"file",line:{n:o,fiber:!0}}),i.changes||e.dispatch({a:"toggle-changes"})}function F5(e){let t=0;return e.map(n=>{const r={start:t,len:n};return t+=n,r})}function B5(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 fx(e,t,n){let r=0,o=e.length-1;for(;r<o;){const l=r+o>>1,c=e[l];(n?t>c.start+c.len:t>=c.start+c.len)?r=l+1:o=l}const i=e[r];return{i:r,at:t-i.start}}function U5(e,t){return{from:fx(e,t.start,!1),to:fx(e,t.end,!0)}}function hx(e,t){if(e.length===0)return-1;const n=e.findIndex(r=>r.start>=t);return n===-1?0:n}function H5(e,t,n){return t===0?-1:(e+n+t)%t}function Iw(e){return e.key==="f"&&(e.metaKey||e.ctrlKey)&&!e.altKey&&!e.shiftKey}function W5({label:e,query:t,onQuery:n,seed:r,seq:o,status:i,none:l,onStep:c,onClose:u}){const h=S.useRef(null);return ft([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(zo,{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(Iw(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:i}),d.jsx(Ot,{icon:"caret",label:"Previous match",hint:"⇧↩",className:"find-prev",disabled:l,onClick:()=>c(-1)}),d.jsx(Ot,{icon:"caret",label:"Next match",hint:"↩",disabled:l,onClick:()=>c(1)}),d.jsx(Ot,{icon:"close",label:"Close",hint:"esc",onClick:u})]})}const IN="find",RN="find-current",ON=typeof CSS<"u"&&"highlights"in CSS;function K5(e){const t=e.parentElement;return t?typeof t.checkVisibility=="function"?t.checkVisibility():!0:!1}function Z5(e,t){const n=e instanceof Element?e:e.parentElement;return!!(n!=null&&n.closest(t))}function q5(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 i=o;i.data.length>0&&K5(i)&&r.push(i)}return r}const zg={matches:[],ranges:[]};function G5(e,t,n){if(!t)return zg;const r=q5(e,n),o=B5(r.map(c=>c.data).join(""),t),i=F5(r.map(c=>c.data.length)),l=o.map(c=>{const{from:u,to:h}=U5(i,c),f=document.createRange();return f.setStart(r[u.i],u.at),f.setEnd(r[h.i],h.at),f});return{matches:o,ranges:l}}function V5(e,t){ON&&(CSS.highlights.set(IN,new Highlight(...e.filter((n,r)=>r!==t))),CSS.highlights.set(RN,new Highlight(...e[t]?[e[t]]:[])))}function Y5(){ON&&(CSS.highlights.delete(IN),CSS.highlights.delete(RN))}function X5(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 px=48;function Q5(e,t){const n=t.getBoundingClientRect(),r=e.getBoundingClientRect(),o=parseFloat(getComputedStyle(e).getPropertyValue("--scroll-foot"))||0;n.top>=r.top+px&&n.bottom<=r.bottom-o-px||(e.scrollTop+=n.top-r.top-r.height/3)}function MN({root:e,body:t,seed:n,seq:r,onClose:o,onReveal:i,skip:l}){const[c,u]=S.useState(n),[h,f]=S.useState(zg),[m,g]=S.useState(-1),w=S.useRef({found:zg,at:-1}),y=S.useRef(""),v=S.useRef(!1),[_,x]=S.useState(0);S.useLayoutEffect(()=>{const $=t.current;if(!$)return;let O=0;const I=new MutationObserver(P=>{l&&P.every(R=>Z5(R.target,l))||O||(O=requestAnimationFrame(()=>{O=0,x(R=>R+1)}))});return I.observe($,{childList:!0,characterData:!0,subtree:!0,attributes:!0}),()=>{I.disconnect(),O&&cancelAnimationFrame(O)}},[t,l]),S.useLayoutEffect(()=>{const $=t.current;if(!$)return;const O=G5($,c,l),I=c!==y.current;y.current=c,I&&(v.current=!0);const{found:P,at:R}=w.current;let U;I?P.matches[R]?U=hx(O.matches,P.matches[R].start):U=e.current?X5(O.ranges,e.current):hx(O.matches,0):U=Math.min(R,O.matches.length-1),w.current={found:O,at:U},f(O),g(U)},[c,_,l]),S.useLayoutEffect(()=>{V5(h.ranges,m);const $=h.ranges[m];$&&(v.current&&e.current&&(Q5(e.current,$),i==null||i()),v.current=!1)},[h,m,e,i]),S.useLayoutEffect(()=>Y5,[]);const T=h.matches.length,N=$=>{if(T===0)return;v.current=!0;const O=H5(w.current.at,T,$);w.current={...w.current,at:O},g(O)},j=()=>o(h.ranges[m]??null);return d.jsx(W5,{label:"find in this document",query:c,onQuery:u,seed:n,seq:r,status:c?T===0?"no matches":`${m+1}/${T}`:"",none:T===0,onStep:N,onClose:j})}function PN(e){return e.key==="a"&&(e.metaKey||e.ctrlKey)&&!e.altKey&&!e.shiftKey}function LN(e,t,n,r,o){S.useEffect(()=>{let i=!1;const l=u=>{const h=u.target instanceof Element?u.target:null;i=!!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):i)&&!(r!=null&&r(f))||(u.preventDefault(),n(h,u))};return window.addEventListener("pointerdown",l,!0),window.addEventListener("keydown",c),()=>{window.removeEventListener("pointerdown",l,!0),window.removeEventListener("keydown",c)}},[e,t,n,r,o])}function J5(e,t){const n=S.useCallback(r=>{var o;return DN(r,(o=t==null?void 0:t.upTo)==null?void 0:o.call(t,r))},[t]);LN(e,PN,n,void 0,t==null?void 0:t.except)}function Fg(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 DN(e,t){const n=document.createRange();n.selectNodeContents(e),t&&n.setEndBefore(t);const r=window.getSelection();r&&(r.removeAllRanges(),r.addRange(n))}function e6(e){return e.shiftKey||e.altKey||e.metaKey||e.ctrlKey?null:e.key==="ArrowLeft"?-1:e.key==="ArrowRight"?1:null}function t6(e,t,n){const r=e+n;return r<0||r>=t?null:r}const zN=S.createContext(null),n6="input, textarea, [contenteditable]";function mx(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 Mh({children:e}){const t=S.useRef(new Map),[n,r]=S.useState(null),o=S.useRef(n);o.current=n;const i=S.useMemo(()=>{const c=u=>{const h=mx(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=mx(t.current),m=f.findIndex(y=>y.id===h.id),g=m<0?null:t6(m,f.length,u),w=g===null?void 0:f[g];w&&c(w.id)},close(){var f,m,g;const u=o.current;if(r(null),!u)return;const h=document.activeElement;h!=null&&h.matches(n6)||(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})}}},[]),l=S.useMemo(()=>({api:i,shown:n}),[i,n]);return d.jsx(zN.Provider,{value:l,children:e})}function r6(e,t){const n=S.useContext(zN),r=S.useId(),[o,i]=S.useState(!1),l=n==null?void 0:n.api;if(S.useLayoutEffect(()=>{if(!(!l||!t))return l.register({id:r,el:()=>e.current})},[l,r,t,e]),!l)return{open:o,show:()=>i(!0),close:()=>i(!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:()=>l.open(r),close:l.close,nav:u&&c?{at:c.at,of:c.of,step:l.step}:void 0}}const o6=e=>e.t==="open-path"||e.t==="open-loose",ha=new Map,s6=16;function Bg({sock:e,dispatch:t},n,r){const o=FN({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 i6(e,t){e==null||e.send({t:"open-by-path",path:t,seq:FN(null)})}function FN(e){const t=Lo();ha.set(t,e);for(const n of ha.keys()){if(ha.size<=s6)break;ha.delete(n)}return t}function a6(e,t){if(!ha.has(t.seq))return;const n=ha.get(t.seq);ha.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 l6(e,t,n){var i;const r=e.getState();if(n.t==="open-path"){const l={dispatch:u=>e.dispatch(u)};if(_o(r,n.worktreeId)){r.activeId!==n.worktreeId&&e.dispatch({a:"activate",id:n.worktreeId}),Ln(l,{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(((i=_o(r,r.activeId))==null?void 0:i.repoId)!==c){const u=r.rows.find(h=>h.repoId===c);if(!u)return;e.dispatch({a:"activate",id:u.id})}Ln(l,{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:Lo()}})}function Rw({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,i=n&&r?r.urls.attachmentWhere(n.worktreeId,n.file):void 0;return[[...e?[{id:"open",label:"open full size",onClick:e}]:[],...os(o,rs(r),"reveal the copy")],i?[{id:"copy-path",label:"copy path",onClick:()=>m_(i)}]:[],t?[{id:"remove",label:"remove",onClick:t}]:[]]}function ou(e,t={},n){return Dn([[{id:"copy-image",label:"copy image",onClick:()=>WD(e)}],...Rw(t,n)])}function BN({text:e,href:t}){return e!==void 0?[{id:"copy-text",label:"copy text",onClick:()=>Yt(e)}]:t?[{id:"copy-text",label:"copy text",onClick:()=>m_(t)}]:[]}function c6(e,t={}){return Dn([BN(e),...Rw(t)])}function u6(e,t={},n){return Dn([BN(e),...Rw(t,n)])}function d6(e){return[h_(e),{id:"copy-link",label:"copy link",onClick:()=>Yt(e)}]}function Ph(e,t,n){if(e.kind==="worktree"){const{id:o,archived:i}=e;return()=>n.dispatch(i?{a:"open-archived",id:o}:{a:"activate",id:o})}if(!t)return null;if(e.kind==="outside")return()=>Bg(n,t,e);if(e.kind==="path")return()=>Bg(n,t,{href:e.path,path:e.path});if(e.kind!=="file")return null;const r=e.file;return r.folder?()=>XD(n,{worktreeId:t,path:r.path}):()=>Ln(n,{worktreeId:t,path:r.path,...r.line?{line:{n:r.line}}:{}})}function f6(e,t,n){const r=Ph(e,t,n),{sock:o}=n,i=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}),l=e.kind==="file"?e.file.path:e.path;return[[...r?[{id:"open",label:"open",onClick:r}]:[],...os(i,rs(o))],[{id:"copy-path",label:"copy path",onClick:()=>Yt(l)}]]}function h6(e,t){const n=Ph(e,null,t);return[n?[{id:"open",label:e.archived?"open archived chat":"open chat",onClick:n}]:[],[{id:"copy-branch",label:"copy branch",onClick:()=>Yt(e.branch)}]]}function Ug(e){return e?[{id:"copy-code",label:"copy code",onClick:()=>Yt(e)}]:[]}function ra(e,t,n,r={}){const{dispatch:o,sock:i}=n,l=r.link,c=l?l.kind==="out"?[d6(l.href)]:l.kind==="worktree"?h6(l,n):f6(l,t,n):[],u=[{id:"copy",label:"copy message",onClick:()=>Yt(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||!i)return o({a:"set-draft",id:t,text:e.text});o({a:"set-draft",id:t,text:""}),i.send({t:"redraft",worktreeId:t,seq:f})}}),Dn([Ug(r.code),...c,u,h])}function UN(e,t,n){return[os(t,n),[{id:"copy-path",label:"copy path",onClick:()=>Yt(e)}]]}function Ow(e,t,n){return Dn(UN(e,t,n))}function p6(e,t){const n=e.callFile??e.file,r=n?UN(n,void 0,t.host):[],o=t.remove?[{id:"remove",label:"remove",onClick:t.remove}]:[];return Dn([...r,o])}const gx=8,m6=.7,g6=100,k6=400,w6=260,y6=80,v6=220;function kx({dx:e,dy:t}){return Math.abs(e)<gx&&Math.abs(t)<gx?null:Math.abs(t)>Math.abs(e)?"away":"other"}function b6(e,t){const n=e.filter(i=>t-i.t<=g6),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 x6=e=>Math.abs(e)>=m6;function E6(e,t){return Math.min(v6,Math.max(y6,e/Math.abs(t)))}function S6(e,t,n){const r=S.useRef(n);r.current=n,S.useEffect(()=>{const o=e.current;if(!o)return;let i=null,l=!1,c=[],u=0;const h=(v,_,x)=>{x!==void 0&&o.style.setProperty("--swipe-ms",`${x}ms`),o.dataset.swipe!==_&&(o.dataset.swipe=_,o.offsetWidth),o.style.setProperty("--swipe-y",`${v}px`),o.style.setProperty("--swipe-fade",`${Math.min(1,Math.abs(v)/(window.innerHeight/2))}`)},f=()=>{o.style.removeProperty("--swipe-y"),o.style.removeProperty("--swipe-fade"),o.style.removeProperty("--swipe-ms"),delete o.dataset.swipe},m=()=>{const v=l;i=null,l=!1,c=[],v&&(h(0,"settle"),u=window.setTimeout(f,w6))},g=v=>{var T;const _=v.touches[0],x=v.target;if(v.touches.length!==1||!_||(((T=window.visualViewport)==null?void 0:T.scale)??1)>1.01)return m();o.dataset.swipe==="leave"||!(x===o||x!=null&&x.closest(t))||(window.clearTimeout(u),i={x:_.clientX,y:_.clientY,at:v.timeStamp},c=[{y:_.clientY,t:v.timeStamp}])},w=v=>{const _=v.touches[0];if(!i||!_)return;const x=_.clientX-i.x,T=_.clientY-i.y;if(!l){const N=kx({dx:x,dy:T});if(N==="other"&&(i=null),N!=="away")return;l=!0}v.preventDefault(),c.push({y:_.clientY,t:v.timeStamp}),c.length>16&&c.shift(),h(T,"drag")},y=v=>{const _=v.changedTouches[0];if(!i||!_)return;const x=_.clientY-i.y,T=v.timeStamp-i.at;if(!l&&T<k6&&v.target!==o&&kx({dx:_.clientX-i.x,dy:x})===null){v.preventDefault(),i=null,r.current();return}const j=b6(c,v.timeStamp);if(!l||!x6(j))return m();i=null,l=!1,c=[];const $=Math.sign(j)*window.innerHeight,O=E6(Math.abs($-x),j);h($,"leave",O),u=window.setTimeout(()=>r.current(),O)};return o.addEventListener("touchstart",g,{passive:!0}),o.addEventListener("touchmove",w,{passive:!1}),o.addEventListener("touchend",y),o.addEventListener("touchcancel",m),()=>{window.clearTimeout(u),o.removeEventListener("touchstart",g),o.removeEventListener("touchmove",w),o.removeEventListener("touchend",y),o.removeEventListener("touchcancel",m)}},[e,t])}function Mw({owner:e,onClose:t,menu:n,nav:r,children:o}){const i=wn(e),l=S.useRef(null);return S6(l,"img",t),d.jsxs(Ls,{className:"attach-full scrim",boxRef:l,onDismiss:t,onKey:c=>{if(c.key==="Escape"){c.stopPropagation(),t();return}const u=r&&e6(c);u&&(c.preventDefault(),c.stopPropagation(),r.step(u))},onClick:c=>{c.target===c.currentTarget&&t()},...n&&i.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(Ot,{icon:"close",label:"Close",tone:"quiet",onClick:t})]})]})}function _6({item:e}){if(!e.outcome)return null;const t=DL[e.outcome];if(e.ask.kind==="permission"){const{title:n,choices:r}=e.ask,o=r.find(i=>i.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 Pw(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 HN=e=>e.slice(0,Math.max(0,e.lastIndexOf("/")));function WN(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 i=e.replace(/\/+$/,"");if(!i||!n.startsWith(`${i}/`))return null;const l=n.endsWith("/"),c=n.slice(i.length+1).replace(/\/+$/,"");if(!c||c.split("/").some(f=>f===".."))return null;if(l)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 KN(e){if(!e.startsWith("/")||e.startsWith("//"))return null;let t;try{t=decodeURIComponent(e)}catch{return null}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 N6(e){return e.length<2||!e.startsWith("/")||e.startsWith("//")||/\s/.test(e)?null:e}function Lw(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 i=o.getAttribute("data-path");if(i)return{kind:"path",path:i};const l=o.getAttribute("href");if(!l)return null;const c=t?WN(t,l):null;if(c)return{kind:"file",file:c};const u=KN(l);return u?{kind:"outside",href:l,...u}:{kind:"out",href:l}}function Dw(e,t,n,r){const o=Lw(e.target,t),i=o&&o.kind!=="path"?Ph(o,n,r):null;i&&(e.preventDefault(),i())}const T6=150,j6=e=>({side:e,align:"center",offset:12,flip:"side",margin:8});function ZN({chip:e,className:t,children:n}){const[r,o]=S.useState(!1),i=L(c=>c.chatSide);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),T6)};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 l=()=>{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(Ls,{className:He("chip-peek",t),anchor:l,placement:j6(i==="left"?"right":"left"),track:!0,children:n}):null}function zw({className:e,label:t,tip:n,peek:r,full:o,menu:i,removeLabel:l,onRemove:c}){const u=S.useRef(null),h=wn("chat"),f=o!==void 0,m=r6(u,f);return d.jsxs("div",{ref:u,className:He("pick-chip row row-sm",e),"data-tip":f?"Open full size":n,"data-tip-placement":"follow",...h.contextMenu(()=>i({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(Ot,{icon:"close",label:l,tone:"quiet",onClick:c}),f&&r!==void 0&&d.jsx(ZN,{chip:u,children:r}),m.open&&f&&d.jsx(Mw,{owner:"chat",onClose:m.close,menu:()=>i(),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 wx(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 $6(e){if(Array.isArray(e))return e}function C6(e,t){var n=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var r,o,i,l,c=[],u=!0,h=!1;try{if(i=(n=n.call(e)).next,t!==0)for(;!(u=(r=i.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&&(l=n.return(),Object(l)!==l))return}finally{if(h)throw o}}return c}}function A6(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
129
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function I6(e,t){return $6(e)||C6(e,t)||R6(e,t)||A6()}function R6(e,t){if(e){if(typeof e=="string")return wx(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)?wx(e,t):void 0}}const qN=Object.entries,yx=Object.setPrototypeOf,O6=Object.isFrozen,M6=Object.getPrototypeOf,P6=Object.getOwnPropertyDescriptor;let kr=Object.freeze,Nr=Object.seal,fl=Object.create,GN=typeof Reflect<"u"&&Reflect,Hg=GN.apply,Wg=GN.construct;kr||(kr=function(t){return t});Nr||(Nr=function(t){return t});Hg||(Hg=function(t,n){for(var r=arguments.length,o=new Array(r>2?r-2:0),i=2;i<r;i++)o[i-2]=arguments[i];return t.apply(n,o)});Wg||(Wg=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 ia=fr(Array.prototype.forEach),L6=fr(Array.prototype.lastIndexOf),vx=fr(Array.prototype.pop),jc=fr(Array.prototype.push),D6=fr(Array.prototype.splice),Tl=Array.isArray,Pc=fr(String.prototype.toLowerCase),Pm=fr(String.prototype.toString),bx=fr(String.prototype.match),$c=fr(String.prototype.replace),xx=fr(String.prototype.indexOf),z6=fr(String.prototype.trim),F6=fr(Number.prototype.toString),B6=fr(Boolean.prototype.toString),Ex=typeof BigInt>"u"?null:fr(BigInt.prototype.toString),Sx=typeof Symbol>"u"?null:fr(Symbol.prototype.toString),io=fr(Object.prototype.hasOwnProperty),Cc=fr(Object.prototype.toString),Dr=fr(RegExp.prototype.test),oa=U6(TypeError);function fr(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 Hg(e,t,r)}}function U6(e){return function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return Wg(e,n)}}function pn(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Pc;if(yx&&yx(e,null),!Tl(t))return e;let r=t.length;for(;r--;){let o=t[r];if(typeof o=="string"){const i=n(o);i!==o&&(O6(t)||(t[r]=i),o=i)}e[o]=!0}return e}function H6(e){for(let t=0;t<e.length;t++)io(e,t)||(e[t]=null);return e}function vo(e){const t=fl(null);for(const r of qN(e)){var n=I6(r,2);const o=n[0],i=n[1];io(e,o)&&(Tl(i)?t[o]=H6(i):i&&typeof i=="object"&&i.constructor===Object?t[o]=vo(i):t[o]=i)}return t}function W6(e){switch(typeof e){case"string":return e;case"number":return F6(e);case"boolean":return B6(e);case"bigint":return Ex?Ex(e):"0";case"symbol":return Sx?Sx(e):"Symbol()";case"undefined":return Cc(e);case"function":case"object":{if(e===null)return Cc(e);const t=e,n=Vo(t,"toString");if(typeof n=="function"){const r=n(t);return typeof r=="string"?r:Cc(r)}return Cc(e)}default:return Cc(e)}}function Vo(e,t){for(;e!==null;){const r=P6(e,t);if(r){if(r.get)return fr(r.get);if(typeof r.value=="function")return fr(r.value)}e=M6(e)}function n(){return null}return n}function K6(e){try{return Dr(e,""),!0}catch{return!1}}const _x=kr(["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"]),Lm=kr(["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"]),Dm=kr(["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"]),Z6=kr(["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"]),zm=kr(["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"]),q6=kr(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),Nx=kr(["#text"]),Tx=kr(["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"]),Fm=kr(["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"]),jx=kr(["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"]),sf=kr(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),G6=Nr(/{{[\w\W]*|^[\w\W]*}}/g),V6=Nr(/<%[\w\W]*|^[\w\W]*%>/g),Y6=Nr(/\${[\w\W]*/g),X6=Nr(/^data-[\-\w.\u00B7-\uFFFF]+$/),Q6=Nr(/^aria-[\-\w]+$/),$x=Nr(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),J6=Nr(/^(?:\w+script|data):/i),eF=Nr(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),tF=Nr(/^html$/i),nF=Nr(/^[a-z][.\w]*(-[.\w]+)+$/i),Cx=Nr(/<[/\w!]/g),Ax=Nr(/<[/\w]/g),rF=Nr(/<\/no(script|embed|frames)/i),oF=Nr(/\/>/i),yo={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},VN=["style","script","xmp","iframe","noembed","noframes","plaintext","noscript"],sF=kr(pn({},VN)),iF=(function(){const e={};return ia(VN,t=>{e[t]=Nr(new RegExp("</"+t+"(?=[\\t\\n\\f\\r />])","i"))}),kr(e)})(),aF=function(){return typeof window>"u"?null:window},lF=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 i="dompurify"+(r?"#"+r:"");try{return t.createPolicy(i,{createHTML(l){return l},createScriptURL(l){return l}})}catch{return console.warn("TrustedTypes policy "+i+" could not be created."),null}},Ix=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},hi=function(t,n,r,o){return io(t,n)&&Tl(t[n])?pn(o.base?vo(o.base):{},t[n],o.transform):r},Bm=function(t,n,r){const o=io(t,n)?t[n]:void 0;return o&&typeof o=="object"?vo(o):r()};function YN(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:aF();const t=je=>YN(je);if(t.version="3.4.14",t.removed=[],!e||!e.document||e.document.nodeType!==yo.document||!e.Element)return t.isSupported=!1,t;let n=e.document;const r=n,o=r.currentScript;e.DocumentFragment;const i=e.HTMLTemplateElement,l=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,w=Vo(g,"cloneNode"),y=Vo(g,"remove"),v=Vo(g,"nextSibling"),_=Vo(g,"childNodes"),x=Vo(g,"parentNode"),T=Vo(g,"shadowRoot"),N=Vo(g,"attributes"),j=l&&l.prototype?Vo(l.prototype,"nodeType"):null,$=l&&l.prototype?Vo(l.prototype,"nodeName"):null,O=l&&l.prototype?Vo(l.prototype,"ownerDocument"):null,I=function(z){return j?j(z):z.nodeType},P=function(z){return $?$(z):z.nodeName};if(typeof i=="function"){const je=n.createElement("template");je.content&&je.content.ownerDocument&&(n=je.content.ownerDocument)}let R,U="",F,B=!1,X=0;const ae=function(){if(X>0)throw oa('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(z){ae(),X++;try{return R.createHTML(z)}finally{X--}},ne=function(z){ae(),X++;try{return R.createScriptURL(z)}finally{X--}},C=function(){return B||(F=lF(m,o),B=!0),F},H=n,V=H.implementation,J=H.createNodeIterator,Z=H.createDocumentFragment,ie=H.getElementsByTagName,be=r.importNode;let ge=Ix();t.isSupported=typeof qN=="function"&&typeof x=="function"&&V&&V.createHTMLDocument!==void 0;const we=G6,pe=V6,Q=Y6,W=X6,ye=Q6,_e=J6,ve=eF,ce=nF;let Se=$x,me=null;const Ue=pn({},[..._x,...Lm,...Dm,...zm,...Nx]);let Ie=null;const We=pn({},[...Tx,...Fm,...jx,...sf]);let mt=Object.seal(fl(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}})),en=null,Kt=null;const Be=Object.seal(fl(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let Xt=!0,ln=!0,It=!1,Je=!0,Vt=!1,tn=!0,ht=!1,gt=!1,sn=null,kn=null,Pt=!1,Rn=!1,bt=!1,ee=!1,ke=!0,Xe=!1;const Ge="user-content-";let Zt=!0,Bt=!1,mn={},an=null;const xn=pn({},["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 M=null;const re=pn({},["audio","video","img","source","image","track"]);let Ne=null;const Ze=pn({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),jt="http://www.w3.org/1998/Math/MathML",Ut="http://www.w3.org/2000/svg",Me="http://www.w3.org/1999/xhtml";let Pe=Me,Ve=!1,Lt=null;const qt=pn({},[jt,Ut,Me],Pm),zn=kr(["mi","mo","mn","ms","mtext"]);let et=pn({},zn);const Ht=kr(["annotation-xml"]);let On=pn({},Ht);const dn=pn({},["title","style","font","a","script"]);let sr=null;const Fn=["application/xhtml+xml","text/html"],hr="text/html";let oe=null,Le=null;const Ye=n.createElement("form"),$t=function(z){return z instanceof RegExp||z instanceof Function},pt=function(){let z=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(Le&&Le===z)return;(!z||typeof z!="object")&&(z={}),z=vo(z),sr=Fn.indexOf(z.PARSER_MEDIA_TYPE)===-1?hr:z.PARSER_MEDIA_TYPE,oe=sr==="application/xhtml+xml"?Pm:Pc,me=hi(z,"ALLOWED_TAGS",Ue,{transform:oe}),Ie=hi(z,"ALLOWED_ATTR",We,{transform:oe}),Lt=hi(z,"ALLOWED_NAMESPACES",qt,{transform:Pm}),Ne=hi(z,"ADD_URI_SAFE_ATTR",Ze,{transform:oe,base:Ze}),M=hi(z,"ADD_DATA_URI_TAGS",re,{transform:oe,base:re}),an=hi(z,"FORBID_CONTENTS",xn,{transform:oe}),en=hi(z,"FORBID_TAGS",vo({}),{transform:oe}),Kt=hi(z,"FORBID_ATTR",vo({}),{transform:oe}),mn=io(z,"USE_PROFILES")?z.USE_PROFILES&&typeof z.USE_PROFILES=="object"?vo(z.USE_PROFILES):z.USE_PROFILES:!1,Xt=z.ALLOW_ARIA_ATTR!==!1,ln=z.ALLOW_DATA_ATTR!==!1,It=z.ALLOW_UNKNOWN_PROTOCOLS||!1,Je=z.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Vt=z.SAFE_FOR_TEMPLATES||!1,tn=z.SAFE_FOR_XML!==!1,ht=z.WHOLE_DOCUMENT||!1,Rn=z.RETURN_DOM||!1,bt=z.RETURN_DOM_FRAGMENT||!1,ee=z.RETURN_TRUSTED_TYPE||!1,Pt=z.FORCE_BODY||!1,ke=z.SANITIZE_DOM!==!1,Xe=z.SANITIZE_NAMED_PROPS||!1,Zt=z.KEEP_CONTENT!==!1,Bt=z.IN_PLACE||!1,Se=K6(z.ALLOWED_URI_REGEXP)?z.ALLOWED_URI_REGEXP:$x,Pe=typeof z.NAMESPACE=="string"?z.NAMESPACE:Me,et=Bm(z,"MATHML_TEXT_INTEGRATION_POINTS",()=>pn({},zn)),On=Bm(z,"HTML_INTEGRATION_POINTS",()=>pn({},Ht));const K=Bm(z,"CUSTOM_ELEMENT_HANDLING",()=>fl(null));if(mt=fl(null),io(K,"tagNameCheck")&&$t(K.tagNameCheck)&&(mt.tagNameCheck=K.tagNameCheck),io(K,"attributeNameCheck")&&$t(K.attributeNameCheck)&&(mt.attributeNameCheck=K.attributeNameCheck),io(K,"allowCustomizedBuiltInElements")&&typeof K.allowCustomizedBuiltInElements=="boolean"&&(mt.allowCustomizedBuiltInElements=K.allowCustomizedBuiltInElements),Nr(mt),Vt&&(ln=!1),bt&&(Rn=!0),mn&&(me=pn({},Nx),Ie=fl(null),mn.html===!0&&(pn(me,_x),pn(Ie,Tx)),mn.svg===!0&&(pn(me,Lm),pn(Ie,Fm),pn(Ie,sf)),mn.svgFilters===!0&&(pn(me,Dm),pn(Ie,Fm),pn(Ie,sf)),mn.mathMl===!0&&(pn(me,zm),pn(Ie,jx),pn(Ie,sf))),Be.tagCheck=null,Be.attributeCheck=null,io(z,"ADD_TAGS")&&(typeof z.ADD_TAGS=="function"?Be.tagCheck=z.ADD_TAGS:Tl(z.ADD_TAGS)&&(me===Ue&&(me=vo(me)),pn(me,z.ADD_TAGS,oe))),io(z,"ADD_ATTR")&&(typeof z.ADD_ATTR=="function"?Be.attributeCheck=z.ADD_ATTR:Tl(z.ADD_ATTR)&&(Ie===We&&(Ie=vo(Ie)),pn(Ie,z.ADD_ATTR,oe))),io(z,"ADD_FORBID_CONTENTS")&&Tl(z.ADD_FORBID_CONTENTS)&&(an===xn&&(an=vo(an)),pn(an,z.ADD_FORBID_CONTENTS,oe)),Zt&&(me["#text"]=!0),ht&&pn(me,["html","head","body"]),me.table&&(pn(me,["tbody"]),delete en.tbody),z.TRUSTED_TYPES_POLICY){if(typeof z.TRUSTED_TYPES_POLICY.createHTML!="function")throw oa('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof z.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw oa('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');const le=R;R=z.TRUSTED_TYPES_POLICY;try{U=Y("")}catch(xe){throw R=le,xe}}else z.TRUSTED_TYPES_POLICY===null?(R=void 0,U=""):(R===void 0&&(R=C()),R&&typeof U=="string"&&(U=Y("")));kr&&kr(z),Le=z},yn=pn({},[...Lm,...Dm,...Z6]),Tr=pn({},[...zm,...q6]),ir=function(z,K,le){return K.namespaceURI===Me?z==="svg":K.namespaceURI===jt?z==="svg"&&(le==="annotation-xml"||et[le]):!!yn[z]},Wt=function(z,K,le){return K.namespaceURI===Me?z==="math":K.namespaceURI===Ut?z==="math"&&On[le]:!!Tr[z]},Yr=function(z,K,le){return K.namespaceURI===Ut&&!On[le]||K.namespaceURI===jt&&!et[le]?!1:!Tr[z]&&(dn[z]||!yn[z])},dt=function(z){let K=x(z);(!K||!K.tagName)&&(K={namespaceURI:Pe,tagName:"template"});const le=Pc(z.tagName),xe=Pc(K.tagName);return Lt[z.namespaceURI]?z.namespaceURI===Ut?ir(le,K,xe):z.namespaceURI===jt?Wt(le,K,xe):z.namespaceURI===Me?Yr(le,K,xe):!!(sr==="application/xhtml+xml"&&Lt[z.namespaceURI]):!1},Bn=function(z){jc(t.removed,{element:z});try{x(z).removeChild(z)}catch{if(y(z),!x(z))throw oa("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},st=function(z,K,le){try{z.removeAttributeNode(K)}catch{try{z.removeAttribute(le)}catch{}}},Te=function(z){at(z);const K=_(z);if(K){const xe=[];ia(K,Re=>{jc(xe,Re)}),ia(xe,Re=>{try{y(Re)}catch{}})}const le=N(z);if(le)for(let xe=le.length-1;xe>=0;--xe){const Re=le[xe],$e=Re&&Re.name;typeof $e=="string"&&st(z,Re,$e)}},qe=function(z,K,le){if(!le)try{le=K.getAttributeNode(z)}catch{le=null}jc(t.removed,{attribute:le||null,from:K});try{le?K.removeAttributeNode(le):K.removeAttribute(z)}catch{try{K.removeAttribute(z)}catch{}}if(z==="is")if(Rn||bt)try{Bn(K)}catch{}else try{K.setAttribute(z,"")}catch{}},xt=function(z){const K=N(z);if(K)for(let le=K.length-1;le>=0;--le){const xe=K[le],Re=xe&&xe.name;typeof Re!="string"||Ie[oe(Re)]||st(z,xe,Re)}},at=function(z){const K=[z];for(;K.length>0;){const le=K.pop();I(le)===yo.element&&xt(le);const Re=_(le);if(Re)for(let $e=Re.length-1;$e>=0;--$e)K.push(Re[$e])}},fn=function(z,K){return tn?z==="patchsrc"?!0:z==="for"&&K!=="label"&&K!=="output":!1},Ft=function(z){if(!tn)return;const K=[z];for(;K.length>0;){const le=K.pop(),xe=I(le);if(xe===yo.processingInstruction||xe===yo.comment&&Dr(Ax,le.data)){try{y(le)}catch{}continue}if(xe===yo.element){const $e=le,Ct=oe(P(le));try{$e.hasAttribute&&$e.hasAttribute("patchsrc")&&$e.removeAttribute("patchsrc"),$e.hasAttribute&&$e.hasAttribute("for")&&fn("for",Ct)&&$e.removeAttribute("for")}catch{}}const Re=_(le);if(Re)for(let $e=Re.length-1;$e>=0;--$e)K.push(Re[$e])}},cn=function(z){let K=null,le=null;if(Pt)z="<remove></remove>"+z;else{const $e=bx(z,/^[\r\n\t ]+/);le=$e&&$e[0]}sr==="application/xhtml+xml"&&Pe===Me&&(z='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+z+"</body></html>");const xe=R?Y(z):z;if(Pe===Me)try{K=new f().parseFromString(xe,sr)}catch{}if(!K||!K.documentElement){K=V.createDocument(Pe,"template",null);try{K.documentElement.innerHTML=Ve?U:xe}catch{}}const Re=K.body||K.documentElement;return z&&le&&Re.insertBefore(n.createTextNode(le),Re.childNodes[0]||null),Pe===Me?ie.call(K,ht?"html":"body")[0]:ht?K.documentElement:Re},Hr=function(z){const K=O?O(z):z.ownerDocument;return J.call(K||z,z,u.SHOW_ELEMENT|u.SHOW_COMMENT|u.SHOW_TEXT|u.SHOW_PROCESSING_INSTRUCTION|u.SHOW_CDATA_SECTION,null)},$n=function(z){return z=$c(z,we," "),z=$c(z,pe," "),z=$c(z,Q," "),z},Un=function(z){var K;z.normalize();const le=O?O(z):z.ownerDocument,xe=J.call(le||z,z,u.SHOW_TEXT|u.SHOW_COMMENT|u.SHOW_CDATA_SECTION|u.SHOW_PROCESSING_INSTRUCTION,null);let Re=xe.nextNode();for(;Re;)Re.data=$n(Re.data),Re=xe.nextNode();const $e=(K=z.querySelectorAll)===null||K===void 0?void 0:K.call(z,"template");$e&&ia($e,Ct=>{Hn(Ct.content)&&Un(Ct.content)})},yr=function(z){const K=$?$(z):null;return typeof K!="string"||oe(K)!=="form"?!1:typeof z.nodeName!="string"||typeof z.textContent!="string"||typeof z.removeChild!="function"||z.attributes!==N(z)||typeof z.removeAttribute!="function"||typeof z.setAttribute!="function"||typeof z.namespaceURI!="string"||typeof z.insertBefore!="function"||typeof z.hasChildNodes!="function"||z.nodeType!==j(z)||z.childNodes!==_(z)},Hn=function(z){if(!j||typeof z!="object"||z===null)return!1;try{return j(z)===yo.documentFragment}catch{return!1}},G=function(z){if(!j||typeof z!="object"||z===null)return!1;try{return typeof j(z)=="number"}catch{return!1}};function fe(je,z,K){je.length!==0&&ia(je,le=>{le.call(t,z,K,Le)})}const tt=function(z,K){return!!(tn&&z.hasChildNodes()&&!G(z.firstElementChild)&&Dr(Cx,z.textContent)&&Dr(Cx,z.innerHTML)||tn&&z.namespaceURI===Me&&sF[K]&&(G(z.firstElementChild)||typeof z.textContent=="string"&&Dr(iF[K],z.textContent))||z.nodeType===yo.processingInstruction||tn&&z.nodeType===yo.comment&&Dr(Ax,z.data))},kt=function(z,K){if(z instanceof RegExp)return Dr(z,K);if(z instanceof Function){for(var le=arguments.length,xe=new Array(le>2?le-2:0),Re=2;Re<le;Re++)xe[Re-2]=arguments[Re];return!!z(K,...xe)}return!1},Nt=function(z,K,le){if(!en[K]&&Et(K)&&kt(mt.tagNameCheck,K))return!1;if(Zt&&!an[K]){const xe=x(z),Re=_(z);if(Re&&xe){const $e=Re.length;for(let Ct=$e-1;Ct>=0;--Ct){const nn=z===le?w(Re[Ct],!0):Re[Ct];xe.insertBefore(nn,v(z))}}}return Bn(z),!0},vn=function(z,K,le,xe){return z.length===0?K:K===le||K===xe?vo(K):K},Wn=function(z,K){return z===K||x(z)!==null?!1:(Bt&&at(z),!0)},ar=function(z,K){if(fe(ge.beforeSanitizeElements,z,null),Wn(z,K))return!0;if(yr(z))return Bn(z),!0;const le=oe(P(z));if(me=vn(ge.uponSanitizeElement,me,Ue,sn),fe(ge.uponSanitizeElement,z,{tagName:le,allowedTags:me}),Wn(z,K))return!0;if(tt(z,le))return Bn(z),!0;if(en[le]||!(Be.tagCheck instanceof Function&&Be.tagCheck(le))&&!me[le]){const Re=Nt(z,le,K);return Re===!1&&fe(ge.afterSanitizeElements,z,null),Re}if(I(z)===yo.element&&!dt(z)||(le==="noscript"||le==="noembed"||le==="noframes")&&Dr(rF,z.innerHTML))return Bn(z),!0;if(Vt&&z.nodeType===yo.text){const Re=$n(z.textContent);z.textContent!==Re&&(jc(t.removed,{element:z.cloneNode()}),z.textContent=Re)}return fe(ge.afterSanitizeElements,z,null),!1},jr=function(z,K,le){if(Kt[K]||fn(K,z)||ke&&(K==="id"||K==="name")&&(le in n||le in Ye))return!1;const xe=Ie[K]||Be.attributeCheck instanceof Function&&Be.attributeCheck(K,z);return ln&&Dr(W,K)||Xt&&Dr(ye,K)?!0:xe?Ne[K]||Dr(Se,$c(le,ve,""))||(K==="src"||K==="xlink:href"||K==="href")&&z!=="script"&&xx(le,"data:")===0&&M[z]||It&&!Dr(_e,$c(le,ve,""))?!0:!le:Et(z)&&kt(mt.tagNameCheck,z)&&kt(mt.attributeNameCheck,K,z)||K==="is"&&mt.allowCustomizedBuiltInElements&&kt(mt.tagNameCheck,le)},Gt=pn({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),Et=function(z){return!Gt[Pc(z)]&&Dr(ce,z)},To=function(z,K,le,xe){if(R&&typeof m=="object"&&typeof m.getAttributeType=="function"&&!le)switch(m.getAttributeType(z,K)){case"TrustedHTML":return Y(xe);case"TrustedScriptURL":return ne(xe)}return xe},Nn=function(z,K,le,xe){try{le?z.setAttributeNS(le,K,xe):z.setAttribute(K,xe),yr(z)?Bn(z):vx(t.removed)}catch{qe(K,z)}},Qt=function(z){fe(ge.beforeSanitizeAttributes,z,null);const K=z.attributes;if(!K||yr(z))return;Ie=vn(ge.uponSanitizeAttribute,Ie,We,kn);const le={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:Ie,forceKeepAttr:void 0};let xe=K.length;const Re=oe(z.nodeName);for(;xe--;){const $e=K[xe],Ct=$e.name,nn=$e.namespaceURI,er=$e.value,Cn=oe(Ct),zs=er;let bn=Ct==="value"?zs:z6(zs);if(le.attrName=Cn,le.attrValue=bn,le.keepAttr=!0,le.forceKeepAttr=void 0,fe(ge.uponSanitizeAttribute,z,le),bn=le.attrValue,Xe&&(Cn==="id"||Cn==="name")&&xx(bn,Ge)!==0&&(qe(Ct,z,$e),bn=Ge+bn),tn&&Dr(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,bn)){qe(Ct,z,$e);continue}if(Cn==="attributename"&&bx(bn,"href")){qe(Ct,z,$e);continue}if(!le.forceKeepAttr){if(!le.keepAttr){qe(Ct,z,$e);continue}if(!Je&&Dr(oF,bn)){qe(Ct,z,$e);continue}if(Vt&&(bn=$n(bn)),!jr(Re,Cn,bn)){qe(Ct,z,$e);continue}bn=To(Re,Cn,nn,bn),bn!==zs&&Nn(z,Ct,nn,bn)}}fe(ge.afterSanitizeAttributes,z,null)},Wr=function(z){let K=null;const le=Hr(z);for(fe(ge.beforeSanitizeShadowDOM,z,null);K=le.nextNode();)if(fe(ge.uponSanitizeShadowNode,K,null),ar(K,z),Qt(K),Hn(K.content)&&Wr(K.content),I(K)===yo.element){const xe=T(K);Hn(xe)&&(Rr(xe),Wr(xe))}fe(ge.afterSanitizeShadowDOM,z,null)},Rr=function(z){const K=[{node:z,shadow:null}];for(;K.length>0;){const le=K.pop();if(le.shadow){Wr(le.shadow);continue}const xe=le.node,$e=I(xe)===yo.element,Ct=_(xe);if(Ct)for(let nn=Ct.length-1;nn>=0;--nn)K.push({node:Ct[nn],shadow:null});if($e){const nn=$?$(xe):null;if(typeof nn=="string"&&oe(nn)==="template"){const er=xe.content;Hn(er)&&K.push({node:er,shadow:null})}}if($e){const nn=T(xe);Hn(nn)&&K.push({node:null,shadow:nn},{node:nn,shadow:null})}}};return t.sanitize=function(je){let z=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},K=null,le=null,xe=null,Re=null;if(Ve=!je,Ve&&(je="<!-->"),typeof je!="string"&&!G(je)&&(je=W6(je),typeof je!="string"))throw oa("dirty is not a string, aborting");if(!t.isSupported)return je;gt?(me=sn,Ie=kn):pt(z),(ge.uponSanitizeElement.length>0||ge.uponSanitizeAttribute.length>0)&&(me=vo(me)),ge.uponSanitizeAttribute.length>0&&(Ie=vo(Ie)),t.removed=[];const $e=Bt&&typeof je!="string"&&G(je);if($e){Ft(je);const er=P(je);if(typeof er=="string"){const Cn=oe(er);if(!me[Cn]||en[Cn])throw Te(je),oa("root node is forbidden and cannot be sanitized in-place")}if(yr(je))throw Te(je),oa("root node is clobbered and cannot be sanitized in-place");try{Rr(je)}catch(Cn){throw Te(je),Cn}}else if(G(je))K=cn("<!---->"),le=K.ownerDocument.importNode(je,!0),le.nodeType===yo.element&&le.nodeName==="BODY"||le.nodeName==="HTML"?K=le:K.appendChild(le),Rr(le);else{if(!Rn&&!Vt&&!ht&&je.indexOf("<")===-1)return R&&ee?Y(je):je;if(K=cn(je),!K)return Rn?null:ee?U:""}K&&Pt&&Bn(K.firstChild);const Ct=$e?je:K;try{const er=Hr(Ct);for(;xe=er.nextNode();)ar(xe,Ct),Qt(xe),Hn(xe.content)&&Wr(xe.content)}catch(er){throw $e&&(Te(je),ia(t.removed,Cn=>{Cn.element&&at(Cn.element)})),er}if($e)return ia(t.removed,er=>{er.element&&at(er.element)}),Vt&&Un(je),je;if(Rn){if(Vt&&Un(K),bt)for(Re=Z.call(K.ownerDocument);K.firstChild;)Re.appendChild(K.firstChild);else Re=K;return(Ie.shadowroot||Ie.shadowrootmode)&&(Re=be.call(r,Re,!0)),Re}let nn=ht?K.outerHTML:K.innerHTML;return ht&&me["!doctype"]&&K.ownerDocument&&K.ownerDocument.doctype&&K.ownerDocument.doctype.name&&Dr(tF,K.ownerDocument.doctype.name)&&(nn="<!DOCTYPE "+K.ownerDocument.doctype.name+`>
130
- `+nn),Vt&&(nn=$n(nn)),R&&ee?Y(nn):nn},t.setConfig=function(){let je=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};pt(je),gt=!0,sn=me,kn=Ie},t.clearConfig=function(){Le=null,gt=!1,sn=null,kn=null,R=F,U=""},t.isValidAttribute=function(je,z,K){Le||pt({});const le=oe(je),xe=oe(z);return jr(le,xe,K)},t.addHook=function(je,z){typeof z=="function"&&io(ge,je)&&jc(ge[je],z)},t.removeHook=function(je,z){if(io(ge,je)){if(z!==void 0){const K=L6(ge[je],z);return K===-1?void 0:D6(ge[je],K,1)[0]}return vx(ge[je])}},t.removeHooks=function(je){io(ge,je)&&(ge[je]=[])},t.removeAllHooks=function(){ge=Ix()},t}var cF=YN();function Fw(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var ja=Fw();function XN(e){ja=e}var la={exec:()=>null};function cl(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 on(e,t=""){let n=typeof e=="string"?e:e.source,r={replace:(o,i)=>{let l=typeof i=="string"?i:i.source;return l=l.replace(Fr.caret,"$1"),n=n.replace(o,l),r},getRegex:()=>new RegExp(n,t)};return r}var uF=((e="")=>{try{return!!new RegExp("(?<=1)(?<!1)"+e)}catch{return!1}})(),Fr={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:cl(e=>new RegExp(`^ {0,${e}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`)),hrRegex:cl(e=>new RegExp(`^ {0,${e}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`)),fencesBeginRegex:cl(e=>new RegExp(`^ {0,${e}}(?:\`\`\`|~~~)`)),headingBeginRegex:cl(e=>new RegExp(`^ {0,${e}}#`)),htmlBeginRegex:cl(e=>new RegExp(`^ {0,${e}}<(?:[a-z].*>|!--)`,"i")),blockquoteBeginRegex:cl(e=>new RegExp(`^ {0,${e}}>`))},dF=/^(?:[ \t]*(?:\n|$))+/,fF=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,hF=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,_u=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,pF=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,Bw=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,QN=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,JN=on(QN).replace(/bull/g,Bw).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(),mF=on(QN).replace(/bull/g,Bw).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(),Uw=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table|[ \t]+\n)[^\n]+)*)/,gF=/^[^\n]+/,Hw=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,kF=on(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Hw).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),wF=on(/^(bull)([ \t][^\n]*?)?(?:\n|$)/).replace(/bull/g,Bw).getRegex(),Lh="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",Ww=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,yF=on("^ {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",Ww).replace("tag",Lh).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),eT=e=>on(Uw).replace("hr",_u).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",Lh).getRegex(),vF=eT(/ {0,3}(?:[*+-]|1[.)])[ \t]+[^ \t\n]/),bF=eT(/ {0,3}(?:[*+-]|\d{1,9}[.)])(?:[ \t]|\n|$)/),xF=on(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",bF).getRegex(),Kw={blockquote:xF,code:fF,def:kF,fences:hF,heading:pF,hr:_u,html:yF,lheading:JN,list:wF,newline:dF,paragraph:vF,table:la,text:gF},Rx=on("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",_u).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",Lh).getRegex(),EF={...Kw,lheading:mF,table:Rx,paragraph:on(Uw).replace("hr",_u).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",Rx).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",Lh).getRegex()},SF={...Kw,html:on(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Ww).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:la,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:on(Uw).replace("hr",_u).replace("heading",` *#{1,6} *[^
131
- ]`).replace("lheading",JN).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},_F=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,NF=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,tT=/^( {2,}|\\)\n(?!\s*$)/,TF=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,Ds=/[\p{P}\p{S}]/u,Kl=/[\s\p{P}\p{S}]/u,Nu=/[^\s\p{P}\p{S}]/u,jF=on(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,Kl).getRegex(),$F=/[\p{Pi}\p{Ps}"']/u,nT=/(?!~)[\p{P}\p{S}]/u,CF=/(?!~)[\s\p{P}\p{S}]/u,AF=/(?:[^\s\p{P}\p{S}]|~)/u,IF=on(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",uF?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),rT=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,RF=on(rT,"u").replace(/punct/g,Ds).getRegex(),OF=on(rT,"u").replace(/punct/g,nT).getRegex(),MF=/^(?:\*+(?:((?!\*)(?!openQuote)punct)|([^\s*]))?)|^_+(?:((?!_)(?!openQuote)punct)|([^\s_]))?/,PF=on(MF,"u").replace(/openQuote/g,$F).replace(/punct/g,Ds).getRegex(),oT="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",LF=on(oT,"gu").replace(/notPunctSpace/g,Nu).replace(/punctSpace/g,Kl).replace(/punct/g,Ds).getRegex(),DF=on(oT,"gu").replace(/notPunctSpace/g,AF).replace(/punctSpace/g,CF).replace(/punct/g,nT).getRegex(),zF="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)[\\s](\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|(?:(?!\\*)punct|notPunctSpace)(\\*+)(?!\\*)(?=notPunctSpace)",FF=on(zF,"gu").replace(/notPunctSpace/g,Nu).replace(/punctSpace/g,Kl).replace(/punct/g,Ds).getRegex(),BF=on("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,Nu).replace(/punctSpace/g,Kl).replace(/punct/g,Ds).getRegex(),UF="^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)[\\s](_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)|(?:(?!_)punct|notPunctSpace)(_+)(?!_)(?=notPunctSpace)",HF=on(UF,"gu").replace(/notPunctSpace/g,Nu).replace(/punctSpace/g,Kl).replace(/punct/g,Ds).getRegex(),WF=on(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,Ds).getRegex(),KF="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",ZF=on(KF,"gu").replace(/notPunctSpace/g,Nu).replace(/punctSpace/g,Kl).replace(/punct/g,Ds).getRegex(),qF=on(/\\(punct)/,"gu").replace(/punct/g,Ds).getRegex(),GF=on(/^<(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(),VF=on(Ww).replace("(?:-->|$)","-->").getRegex(),YF=on("^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",VF).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),Hf=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,XF=on(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",Hf).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]+|(?=\))/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),sT=on(/^!?\[(label)\]\[(ref)\]/).replace("label",Hf).replace("ref",Hw).getRegex(),iT=on(/^!?\[(ref)\](?:\[\])?/).replace("ref",Hw).getRegex(),QF=on("reflink|nolink(?!\\()","g").replace("reflink",sT).replace("nolink",iT).getRegex(),Ox=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,Zw={_backpedal:la,anyPunctuation:qF,autolink:GF,blockSkip:IF,br:tT,code:NF,del:la,delLDelim:la,delRDelim:la,emStrongLDelim:RF,emStrongRDelimAst:LF,emStrongRDelimUnd:BF,escape:_F,link:XF,nolink:iT,punctuation:jF,reflink:sT,reflinkSearch:QF,tag:YF,text:TF,url:la},JF={...Zw,emStrongLDelim:PF,emStrongRDelimAst:FF,emStrongRDelimUnd:HF,link:on(/^!?\[(label)\]\((.*?)\)/).replace("label",Hf).getRegex(),reflink:on(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",Hf).getRegex()},Kg={...Zw,emStrongRDelimAst:DF,emStrongLDelim:OF,delLDelim:WF,delRDelim:ZF,url:on(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",Ox).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:on(/^(`+|~+|[^`~])(?:(?=[`~])|(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",Ox).getRegex()},e8={...Kg,br:on(tT).replace("{2,}","*").getRegex(),text:on(Kg.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},af={normal:Kw,gfm:EF,pedantic:SF},Ac={normal:Zw,gfm:Kg,breaks:e8,pedantic:JF},t8={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},Mx=e=>t8[e];function hs(e,t){if(t){if(Fr.escapeTest.test(e))return e.replace(Fr.escapeReplace,Mx)}else if(Fr.escapeTestNoEncode.test(e))return e.replace(Fr.escapeReplaceNoEncode,Mx);return e}function Px(e){try{e=encodeURI(e).replace(Fr.percentDecode,"%")}catch{return null}return e}function Lx(e,t){var i;let n=e.replace(Fr.findPipe,(l,c,u)=>{let h=!1,f=c;for(;--f>=0&&u[f]==="\\";)h=!h;return h?"|":" |"}),r=n.split(Fr.splitPipe),o=0;if(r[0].trim()||r.shift(),r.length>0&&!((i=r.at(-1))!=null&&i.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(Fr.slashPipe,"|");return r}function pi(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 Dx(e){let t=e.split(`
132
- `),n=t.length-1;for(;n>=0&&Fr.blankLine.test(t[n]);)n--;return t.length-n<=2?e:t.slice(0,n+1).join(`
133
- `)}function n8(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 r8(e,t=0){let n=t,r="";for(let o of e)if(o===" "){let i=4-n%4;r+=" ".repeat(i),n+=i}else r+=o,n++;return r}function zx(e,t,n,r,o){let i=t.href,l=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:i,title:l,text:c,tokens:m}}function o8(e,t,n){let r=e.match(n.other.indentCodeCompensation);if(r===null)return t;let o=r[1];return t.split(`
134
- `).map(i=>{let l=i.match(n.other.beginningSpace);if(l===null)return i;let[c]=l;return c.length>=o.length?i.slice(o.length):i}).join(`
135
- `)}var Wf=class{constructor(e){St(this,"options");St(this,"rules");St(this,"lexer");this.options=e||ja}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]:Dx(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=o8(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=pi(n,"#");(this.options.pedantic||!r||this.rules.other.endingSpaceChar.test(r))&&(n=r.trim())}return{type:"heading",raw:pi(t[0],`
136
- `),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:pi(t[0],`
137
- `)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let n=pi(t[0],`
138
- `).split(`
139
- `),r="",o="",i=[];for(;n.length>0;){let l=!1,c=[],u;for(u=0;u<n.length;u++)if(this.rules.other.blockquoteStart.test(n[u]))c.push(n[u]),l=!0;else if(!l)c.push(n[u]);else break;n=n.slice(u);let h=c.join(`
140
- `),f=h.replace(this.rules.other.blockquoteSetextReplace,`
141
- $1`).replace(this.rules.other.blockquoteSetextReplace2,"");r=r?`${r}
142
- ${h}`:h,o=o?`${o}
143
- ${f}`:f;let m=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(f,i,!0),this.lexer.state.top=m,n.length===0)break;let g=i.at(-1);if((g==null?void 0:g.type)==="code")break;if((g==null?void 0:g.type)==="blockquote"){let w=g,y=n.join(`
144
- `),v=w.raw+`
145
- `+y.replace(this.rules.other.blockquoteSetextReplace2,""),_=this.blockquote(v);i[i.length-1]=_,r=`${r}
146
- ${y}`,o=o.substring(0,o.length-w.text.length)+_.text;break}else if((g==null?void 0:g.type)==="list"){let w=g,y=w.raw+`
147
- `+n.join(`
148
- `),v=this.list(y);i[i.length-1]=v,r=r.substring(0,r.length-g.raw.length)+v.raw,o=o.substring(0,o.length-w.raw.length)+v.raw,n=y.substring(i.at(-1).raw.length).split(`
149
- `);continue}}return{type:"blockquote",raw:r,tokens:i,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 i=this.rules.other.listItemRegex(n),l=!1;for(;e;){let u=!1,h="",f="";if(!(t=i.exec(e))||this.rules.block.hr.test(e))break;h=t[0],e=e.substring(h.length);let m=r8(t[2].split(`
150
- `,1)[0],t[1].length),g=e.split(`
151
- `,1)[0],w=!m.trim(),y=0;if(this.options.pedantic?(y=2,f=m.trimStart()):w?y=t[1].length+1:(y=m.search(this.rules.other.nonSpaceChar),y=y>4?1:y,f=m.slice(y),y+=t[1].length),w&&this.rules.other.blankLine.test(g)&&(h+=g+`
152
- `,e=e.substring(g.length+1),u=!0),!u){let v=this.rules.other.nextBulletRegex(y),_=this.rules.other.hrRegex(y),x=this.rules.other.fencesBeginRegex(y),T=this.rules.other.headingBeginRegex(y),N=this.rules.other.htmlBeginRegex(y),j=this.rules.other.blockquoteBeginRegex(y);for(;e;){let $=e.split(`
153
- `,1)[0],O;if(g=$,this.options.pedantic?(g=g.replace(this.rules.other.listReplaceNesting," "),O=g):O=g.replace(this.rules.other.tabCharGlobal," "),x.test(g)||T.test(g)||N.test(g)||j.test(g)||v.test(g)||_.test(g))break;if(O.search(this.rules.other.nonSpaceChar)>=y||!g.trim())f+=`
154
- `+O.slice(y);else{if(w||m.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||x.test(m)||T.test(m)||_.test(m))break;f+=`
155
- `+g}w=!g.trim(),h+=$+`
156
- `,e=e.substring($.length+1),m=O.slice(y)}}o.loose||(l?o.loose=!0:this.rules.other.doubleBlankLine.test(h)&&(l=!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=Dx(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:pi(t[0],`
157
- `),href:r,title:o}}}table(e){var l;let t=this.rules.block.table.exec(e);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let n=Lx(t[1]),r=t[2].replace(this.rules.other.tableAlignChars,"").split("|"),o=(l=t[3])!=null&&l.trim()?t[3].replace(this.rules.other.tableRowBlankLine,"").split(`
158
- `):[],i={type:"table",raw:pi(t[0],`
159
- `),header:[],align:[],rows:[]};if(n.length===r.length){for(let c of r)this.rules.other.tableAlignRight.test(c)?i.align.push("right"):this.rules.other.tableAlignCenter.test(c)?i.align.push("center"):this.rules.other.tableAlignLeft.test(c)?i.align.push("left"):i.align.push(null);for(let c=0;c<n.length;c++)i.header.push({text:n[c],tokens:this.lexer.inline(n[c]),header:!0,align:i.align[c]});for(let c of o)i.rows.push(Lx(c,i.header.length).map((u,h)=>({text:u,tokens:this.lexer.inline(u),header:!1,align:i.align[h]})));return i}}lheading(e){let t=this.rules.block.lheading.exec(e);if(t){let n=t[1].trim();return{type:"heading",raw:pi(t[0],`
160
- `),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)===`
161
- `?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 i=pi(n.slice(0,-1),"\\");if((n.length-i.length)%2===0)return}else{let i=n8(t[2],"()");if(i===-2)return;if(i>-1){let l=(t[0].indexOf("!")===0?5:4)+t[1].length+i;t[2]=t[2].substring(0,i),t[0]=t[0].substring(0,l).trim(),t[3]=""}}let r=t[2],o="";if(this.options.pedantic){let i=this.rules.other.pedanticHrefTitle.exec(r);i&&(r=i[1],o=i[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)),zx(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 i=n[0].charAt(0);return{type:"text",raw:i,text:i}}return zx(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,i,l,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(i=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!i)continue;if(l=[...i].length,r[3]||r[4]){c+=l;continue}else if(r[5]||r[6]){if(o%3&&!((o+l)%3)){u+=l;continue}if(f)break}if(c-=l,c>0)continue;l=Math.min(l,l+c+u);let g=[...r[0]][0].length,w=e.slice(0,o+r.index+g+l);if(Math.min(o,l)%2){let v=w.slice(1,-1);return{type:"em",raw:w,text:v,tokens:this.lexer.inlineTokens(v)}}let y=w.slice(2,-2);return{type:"strong",raw:w,text:y,tokens:this.lexer.inlineTokens(y)}}}}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,i,l,c=o,u=this.rules.inline.delRDelim;for(u.lastIndex=0,t=t.slice(-1*e.length+o);(r=u.exec(t))!==null;){if(i=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!i||(l=[...i].length,l!==o))continue;if(r[3]||r[4]){c+=l;continue}if(c-=l,c>0)continue;l=Math.min(l,l+c);let h=[...r[0]][0].length,f=e.slice(0,o+r.index+h+l),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 i;do i=t[0],t[0]=((n=this.rules.inline._backpedal.exec(t[0]))==null?void 0:n[0])??"";while(i!==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}}}},Xo=class Zg{constructor(t){St(this,"tokens");St(this,"options");St(this,"state");St(this,"inlineQueue");St(this,"tokenizer");this.tokens=[],this.tokens.links=Object.create(null),this.options=t||ja,this.options.tokenizer=this.options.tokenizer||new Wf,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:Fr,block:af.normal,inline:Ac.normal};this.options.pedantic?(n.block=af.pedantic,n.inline=Ac.pedantic):this.options.gfm&&(n.block=af.gfm,this.options.breaks?n.inline=Ac.breaks:n.inline=Ac.gfm),this.tokenizer.rules=n}static get rules(){return{block:af,inline:Ac}}static lex(t,n){return new Zg(n).lex(t)}static lexInline(t,n){return new Zg(n).inlineTokens(t)}lex(t){t=t.replace(Fr.carriageReturn,`
162
- `),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 i,l,c;this.tokenizer.lexer=this,this.options.pedantic&&(t=t.replace(Fr.tabCharGlobal," ").replace(Fr.spaceLine,""));let o=1/0;for(;t;){if(t.length<o)o=t.length;else{this.infiniteLoopError(t.charCodeAt(0));break}let u;if((l=(i=this.options.extensions)==null?void 0:i.block)!=null&&l.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+=`
163
- `: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(`
164
- `)?"":`
165
- `)+u.raw,f.text+=`
166
- `+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(`
167
- `)?"":`
168
- `)+u.raw,f.text+=`
169
- `+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(w=>{g=w.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(`
170
- `)?"":`
171
- `)+u.raw,f.text+=`
172
- `+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(`
173
- `)?"":`
174
- `)+u.raw,f.text+=`
175
- `+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],i=o.lastIndexOf("[");if(!(o.charAt(0)==="!"||!Object.hasOwn(this.tokens.links,o.slice(i+1,-1)))&&!(i>1&&this.linkInText(o.slice(1,i-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,w=y=>{let v=y.lastIndexOf("[");if(!Object.hasOwn(this.tokens.links,y.slice(v+1,-1)))return y;if(v>1&&y.charAt(0)!=="!"){let _=y.slice(1,v-1);if(this.linkInText(_))return"["+_.replace(g,w)+"]["+"a".repeat(y.length-v-2)+"]"}return"["+"a".repeat(y.length-2)+"]"};r=r.replace(g,w)}r=r.replace(this.tokenizer.rules.inline.anyPunctuation,g=>"+".repeat(g.length)),r=r.replace(this.tokenizer.rules.inline.blockSkip,(g,w,y)=>{let v=y?y.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,i="",l=1/0;for(;t;){if(t.length<l)l=t.length;else{this.infiniteLoopError(t.charCodeAt(0));break}o||(i=""),o=!1;let g;if((f=(h=this.options.extensions)==null?void 0:h.inline)!=null&&f.some(y=>(g=y.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 y=n.at(-1);g.type==="text"&&(y==null?void 0:y.type)==="text"?(y.raw+=g.raw,y.text+=g.text):n.push(g);continue}if(g=this.tokenizer.emStrong(t,r,i)){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,i)){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 w=t;if((m=this.options.extensions)!=null&&m.startInline){let y=1/0,v=t.slice(1),_;this.options.extensions.startInline.forEach(x=>{_=x.call({lexer:this},v),typeof _=="number"&&_>=0&&(y=Math.min(y,_))}),y<1/0&&y>=0&&(w=t.substring(0,y+1))}if(g=this.tokenizer.inlineText(w)){t=t.substring(g.raw.length),g.raw.slice(-1)!=="_"&&(i=g.raw.slice(-1)),o=!0;let y=n.at(-1);(y==null?void 0:y.type)==="text"?(y.raw+=g.raw,y.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)}},su=class{constructor(e){St(this,"options");St(this,"parser");this.options=e||ja}space(e){return""}code({text:e,lang:t,escaped:n}){var i;let r=(i=(t||"").match(Fr.notSpaceStart))==null?void 0:i[0],o=e.replace(Fr.endingNewline,"")+`
176
- `;return r?'<pre><code class="language-'+hs(r)+'">'+(n?o:hs(o,!0))+`</code></pre>
177
- `:"<pre><code>"+(n?o:hs(o,!0))+`</code></pre>
178
- `}blockquote({tokens:e}){return`<blockquote>
179
- ${this.parser.parse(e)}</blockquote>
180
- `}html({text:e}){return e}def(e){return""}heading({tokens:e,depth:t}){return`<h${t}>${this.parser.parseInline(e)}</h${t}>
181
- `}hr(e){return`<hr>
182
- `}list(e){let t=e.ordered,n=e.start,r="";for(let l=0;l<e.items.length;l++){let c=e.items[l];r+=this.listitem(c)}let o=t?"ol":"ul",i=t&&n!==1?' start="'+n+'"':"";return"<"+o+i+`>
183
- `+r+"</"+o+`>
184
- `}listitem(e){return`<li>${this.parser.parse(e.tokens)}</li>
185
- `}checkbox({checked:e}){return"<input "+(e?'checked="" ':"")+'disabled="" type="checkbox"> '}paragraph({tokens:e}){return`<p>${this.parser.parseInline(e)}</p>
186
- `}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 i=e.rows[o];n="";for(let l=0;l<i.length;l++)n+=this.tablecell(i[l]);r+=this.tablerow({text:n})}return r&&(r=`<tbody>${r}</tbody>`),`<table>
187
- <thead>
188
- `+t+`</thead>
189
- `+r+`</table>
190
- `}tablerow({text:e}){return`<tr>
191
- ${e}</tr>
192
- `}tablecell(e){let t=this.parser.parseInline(e.tokens),n=e.header?"th":"td";return(e.align?`<${n} align="${e.align}">`:`<${n}>`)+t+`</${n}>
193
- `}strong({tokens:e}){return`<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return`<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return`<code>${hs(e,!0)}</code>`}br(e){return"<br>"}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,tokens:n}){let r=this.parser.parseInline(n),o=Px(e);if(o===null)return r;e=o;let i='<a href="'+e+'"';return t&&(i+=' title="'+hs(t)+'"'),i+=">"+r+"</a>",i}image({href:e,title:t,text:n,tokens:r}){r&&(n=this.parser.parseInline(r,this.parser.textRenderer));let o=Px(e);if(o===null)return hs(n);e=o;let i=`<img src="${e}" alt="${hs(n)}"`;return t&&(i+=` title="${hs(t)}"`),i+=">",i}text(e){return"tokens"in e&&e.tokens?this.parser.parseInline(e.tokens):"escaped"in e&&e.escaped?e.text:hs(e.text)}},qw=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}},Qo=class qg{constructor(t){St(this,"options");St(this,"renderer");St(this,"textRenderer");this.options=t||ja,this.options.renderer=this.options.renderer||new su,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new qw}static parse(t,n){return new qg(n).parse(t)}static parseInline(t,n){return new qg(n).parseInline(t)}parse(t){var r,o;this.renderer.parser=this;let n="";for(let i=0;i<t.length;i++){let l=t[i];if((o=(r=this.options.extensions)==null?void 0:r.renderers)!=null&&o[l.type]){let u=l,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=l;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,i;this.renderer.parser=this;let r="";for(let l=0;l<t.length;l++){let c=t[l];if((i=(o=this.options.extensions)==null?void 0:o.renderers)!=null&&i[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}},ff,Lc=(ff=class{constructor(e){St(this,"options");St(this,"block");this.options=e||ja}preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(e=this.block){return e?Xo.lex:Xo.lexInline}provideParser(e=this.block){return e?Qo.parse:Qo.parseInline}},St(ff,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens","emStrongMask"])),St(ff,"passThroughHooksRespectAsync",new Set(["preprocess","postprocess","processAllTokens"])),ff),s8=class{constructor(...e){St(this,"defaults",Fw());St(this,"options",this.setOptions);St(this,"parse",this.parseMarkdown(!0));St(this,"parseInline",this.parseMarkdown(!1));St(this,"Parser",Qo);St(this,"Renderer",su);St(this,"TextRenderer",qw);St(this,"Lexer",Xo);St(this,"Tokenizer",Wf);St(this,"Hooks",Lc);this.use(...e)}walkTokens(e,t){var r,o;let n=[];for(let i of e)switch(n=n.concat(t.call(this,i)),i.type){case"table":{let l=i;for(let c of l.header)n=n.concat(this.walkTokens(c.tokens,t));for(let c of l.rows)for(let u of c)n=n.concat(this.walkTokens(u.tokens,t));break}case"list":{let l=i;n=n.concat(this.walkTokens(l.items,t));break}default:{let l=i;(o=(r=this.defaults.extensions)==null?void 0:r.childTokens)!=null&&o[l.type]?this.defaults.extensions.childTokens[l.type].forEach(c=>{let u=l[c].flat(1/0);n=n.concat(this.walkTokens(u,t))}):l.tokens&&(n=n.concat(this.walkTokens(l.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 i=t.renderers[o.name];i?t.renderers[o.name]=function(...l){let c=o.renderer.apply(this,l);return c===!1&&(c=i.apply(this,l)),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 i=t[o.level];i?i.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 su(this.defaults);for(let i in n.renderer){if(!(i in o))throw new Error(`renderer '${i}' does not exist`);if(["options","parser"].includes(i))continue;let l=i,c=n.renderer[l],u=o[l];o[l]=(...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 Wf(this.defaults);for(let i in n.tokenizer){if(!(i in o))throw new Error(`tokenizer '${i}' does not exist`);if(["options","rules","lexer"].includes(i))continue;let l=i,c=n.tokenizer[l],u=o[l];o[l]=(...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 Lc;for(let i in n.hooks){if(!(i in o))throw new Error(`hook '${i}' does not exist`);if(["options","block"].includes(i))continue;let l=i,c=n.hooks[l],u=o[l];Lc.passThroughHooks.has(i)?o[l]=h=>{if(this.defaults.async&&Lc.passThroughHooksRespectAsync.has(i))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[l]=(...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,i=n.walkTokens;r.walkTokens=function(l){let c=[];return c.push(i.call(this,l)),o&&(c=c.concat(o.call(this,l))),c}}this.defaults={...this.defaults,...r}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return Xo.lex(e,t??this.defaults)}parser(e,t){return Qo.parse(e,t??this.defaults)}parseMarkdown(e){return(t,n)=>{let r={...n},o={...this.defaults,...r},i=this.onError(!!o.silent,!!o.async);if(this.defaults.async===!0&&r.async===!1)return i(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 i(new Error("marked(): input parameter is undefined or null"));if(typeof t!="string")return i(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 l=o.hooks?await o.hooks.preprocess(t):t,c=await(o.hooks?await o.hooks.provideLexer(e):e?Xo.lex:Xo.lexInline)(l,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?Qo.parse:Qo.parseInline)(u,o);return o.hooks?await o.hooks.postprocess(h):h})().catch(i);try{o.hooks&&(t=o.hooks.preprocess(t));let l=(o.hooks?o.hooks.provideLexer(e):e?Xo.lex:Xo.lexInline)(t,o);o.hooks&&(l=o.hooks.processAllTokens(l)),o.walkTokens&&this.walkTokens(l,o.walkTokens);let c=(o.hooks?o.hooks.provideParser(e):e?Qo.parse:Qo.parseInline)(l,o);return o.hooks&&(c=o.hooks.postprocess(c)),c}catch(l){return i(l)}}}onError(e,t){return n=>{if(n.message+=`
194
- Please report this to https://github.com/markedjs/marked.`,e){let r="<p>An error occurred:</p><pre>"+hs(n.message+"",!0)+"</pre>";return t?Promise.resolve(r):r}if(t)return Promise.reject(n);throw n}}},xa=new s8;function En(e,t){return xa.parse(e,t)}En.options=En.setOptions=function(e){return xa.setOptions(e),En.defaults=xa.defaults,XN(En.defaults),En};En.getDefaults=Fw;En.defaults=ja;function i8(...e){return xa.use(...e),En.defaults=xa.defaults,XN(En.defaults),En}En.use=i8;En.walkTokens=function(e,t){return xa.walkTokens(e,t)};En.parseInline=xa.parseInline;En.Parser=Qo;En.parser=Qo.parse;En.Renderer=su;En.TextRenderer=qw;En.Lexer=Xo;En.lexer=Xo.lex;En.Tokenizer=Wf;En.Hooks=Lc;En.parse=En;En.options;En.setOptions;En.walkTokens;En.parseInline;Qo.parse;Xo.lex;const Ea=100,a8=e=>e.type==="text-delta"||e.type==="thinking-delta"||e.type==="tool-delta";function l8(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 c8={now:()=>performance.now(),after:(e,t)=>void setTimeout(t,e)};function u8(e,t=c8){let n=[],r=!1,o=Number.NEGATIVE_INFINITY;const i=()=>{if(r=!1,n.length===0)return;const l=n;n=[],o=t.now();for(const c of l)e(c)};return l=>{if(l.t==="agent"&&a8(l.event)){const c={...l,event:{...l.event}},u=t.now();if(n.length===0&&u-o>=Ea){o=u,e(c);return}const h=n[n.length-1];h&&l8(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+Ea-u),i));return}i(),e(l)}}const aT="#toyon-link-pending",d8=/!?\[([^[\]\n]*)(?:\]\(([^()\s]*))?$/;function f8(e){const t=e.lastIndexOf(`
195
- `)+1,n=e.slice(t),r=d8.exec(n);return!r||h8(e.slice(0,t))||p8(n.slice(0,r.index))?e:`${e.slice(0,t)}${n.slice(0,r.index)}[${r[1]}](${aT})`}function h8(e){let t=!1;for(const n of e.split(`
196
- `))/^\s*(```|~~~)/.test(n)&&(t=!t);return t}function p8(e){let t=0;for(const n of e)n==="`"&&t++;return t%2===1}const Um="__[a-z][a-z0-9_]*[a-z0-9]__",m8=new RegExp(`^(?:${Um}\\.)+${Um}|^${Um}(?=\\.\\w|\\(|["'])`),g8={name:"dunder",level:"inline",start:e=>e.indexOf("__"),tokenizer(e){const t=m8.exec(e);if(t)return{type:"dunder",raw:t[0],text:t[0]}},renderer:e=>e.text},iu=e=>e.replace(/[&<>]/g,t=>t==="&"?"&amp;":t==="<"?"&lt;":"&gt;");function k8({text:e}){return iu(e)}function w8(e){return`<div class="md-table">${y8.call(this,e)}</div>
197
- `}function y8(e){if(e.header.some(n=>n.text.trim()))return su.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>
198
- <tbody>${t}</tbody></table>
199
- `}function Gg(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 lT(e,t,n){const r=h=>e.map((f,m)=>h(f)&&f.id!==t?m:-1).filter(f=>f>=0),i=[()=>r(h=>h.agent==="waiting"),()=>r(h=>!!h.unseen),()=>r(h=>h.agent==="working")].reduce((h,f)=>h.length>0?h:f(),[]),l=e.findIndex(h=>h.id===t),c=n>0?i.find(h=>h>l)??i[0]:i.findLast(h=>h<l)??i[i.length-1],u=c===void 0?void 0:e[c];return u?{activate:u.id}:null}function Gw(e,t,n){const r=lT(e,t,n);if(r)return r;const o=e[0];return o&&o.id!==t?{activate:o.id}:null}function v8(e,t,n){const r=[Gg(e,t),...n.map(o=>Gg(o.rows,null))].filter(o=>o!==null);return r.length===0?null:{n:r.reduce((o,i)=>o+i.n,0),tier:r.some(o=>o.tier==="waiting")?"waiting":"unseen"}}function b8(e,t,n){const r=[i=>i.agent==="waiting",i=>!!i.unseen];for(const i of r){if(e.some(l=>i(l)&&l.id!==t)){const l=lT(e,t,1);return l&&{origin:null,activate:l.activate}}for(const l of n){const c=l.rows.find(i);if(c)return{origin:l.origin,activate:c.id}}}const o=Gw(e,t,1);return o&&{origin:null,activate:o.activate}}function cT(e,{sock:t,dispatch:n}){var m,g;const r=w=>w?"hide":"show",o=e.repos.some(w=>w.id===e.activeRepoId),i=(m=rn(e,e.activeId))==null?void 0:m.worktree.id,l=[];o&&(l.push({id:"new",label:"new worktree…",key:Dt("new"),onClick:()=>n({a:"open-draft"})}),l.push({id:"refs",label:"open a branch or PR…",key:Dt("refs"),onClick:()=>n({a:"open",overlay:{kind:"refs"}})})),i&&(l.push({id:"jump",label:"jump to file…",key:Dt("quick-open"),onClick:()=>n({a:"open",overlay:{kind:"quick-open"}})}),l.push({id:"search",label:"search in files…",key:Dt("search"),onClick:()=>n({a:"open",overlay:{kind:"search"}})})),Df(e)&&l.push({id:"routes",label:"go to page…",key:Dt("routes"),onClick:()=>n({a:"open",overlay:{kind:"routes"}})}),o&&l.push({id:"chats",label:"search chats…",key:Dt("chats"),onClick:()=>n({a:"open",overlay:{kind:"chats"}})});const c=Gw(e.visible,e.activeId,1);c&&l.push({id:"wt-unseen-next",label:"next that needs you",key:Dt("wt-unseen-next"),onClick:()=>n({a:"activate",id:c.activate})}),l.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&&Ol(e)==="files")} files`,key:Dt("files"),onClick:()=>n(e.layout.changes&&Ol(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=Do(e)?new Set(["chat","design","zen"]):null;return Dn([l,f?u.filter(w=>!f.has(w.id)):u,h])}function Vg(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 i=[{id:`forget-machine:${t}`,label:`forget ${r}…`,danger:!0,onClick:()=>{window.confirm(`Forget ${r}?
200
-
201
- 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 Dn([o,i])}function Vw(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 uT(e,{sock:t}){return[{id:"restart:shell",label:"restart shell",onClick:()=>t==null?void 0:t.send({t:"term-restart",worktreeId:e,stream:Po})}]}function x8(e,t,n,r){return Dn([[...e.flatMap(o=>Vw(o,t,r)),...uT(t,r)],[{id:"terminal",label:`${n?"hide":"show"} terminal`,onClick:()=>r.dispatch({a:"toggle-terminal"})}]])}const au=e=>/^(~|\/|\.\.?\/)/.test(e.trim());function Yw(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 E8(e,t,n){const r=e.map(h=>h.path.slice(0,h.path.lastIndexOf("/"))).filter(Boolean),o=e.find(h=>h.id===t),i=o==null?void 0:o.path.slice(0,o.path.lastIndexOf("/")),l=new Map;for(const h of r)l.set(h,(l.get(h)??0)+1);let c="",u=0;for(const[h,f]of[...l].sort(([m],[g])=>m.localeCompare(g)))(f>u||f===u&&h===i)&&(c=h,u=f);return c?dT(c,n):`~/${KE}`}function dT(e,t){return t&&(e===t||e.startsWith(`${t}/`))?`~${e.slice(t.length)}`:e}function fT(e,t){return`${e.replace(/\/+$/,"")}/${t.trim()}`}function S8(e){const t=e.query.trim(),n=()=>e.entries.map(l=>({kind:l.isFile?"file":"dir",entry:l}));if(!au(t)){const l=e.repos.filter(g=>Jo(t,g.name,g.path)).map(g=>({kind:"repo",repo:g})),c=e.pending.filter(g=>Jo(t,g.name,g.url)).map(g=>({kind:"pending",pending:g})),u=[...l,...c],h=(e.others??[]).flatMap(g=>g.repos.length===0?Jo(t,g.name)?[{kind:"machine",machine:g}]:[]:g.repos.filter(w=>Jo(t,w.name,w.path,g.name)).map(w=>({kind:"repo",repo:w,machine:g})));if(!t){const g=l.find(y=>y.kind==="repo"&&y.repo.id===e.current);return[...g?[g,...l.filter(y=>y!==g)]:l,...c,{kind:"new"},{kind:"disk"},{kind:"add-machine"},...h]}const f=tP(t);if(f)return u.length>0?u:[{kind:"clone",url:f.url,name:f.name}];const m=g=>g.toLowerCase()===t.toLowerCase();return e.repos.some(g=>m(g.name))||e.pending.some(g=>m(g.name))?[...u,...h]:Xc(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 l=t.replace(/\/+$/,"")||"/";if(r.isRepo)return[...n(),{kind:"open",path:l}];if(!r.isDir)return n();const c=Ll(l,e.home);return c==="/"||c===e.home||e.repos.some(h=>h.path.startsWith(`${c}/`))?n():[...n(),{kind:"init",path:l}]}if(t.endsWith("/"))return n();if(!r.parentExists)return[];const{parent:o,name:i}=Yw(t);return Xc(i)?n():[...n(),{kind:"create",name:i,parent:o}]}function Ll(e,t){return t&&(e==="~"||e.startsWith("~/"))?`${t}${e.slice(1)}`:e}function hT(e,t){const n=Ll(e,t).replace(/\/+$/,"");return n.startsWith("/")?dT(n.slice(0,n.lastIndexOf("/"))||"/",t):null}function Yg(e,t){const n=Ll(e,t).replace(/\/+$/,"");return n.slice(n.lastIndexOf("/")+1)||"/"}function _8(e){const t=e.query.trim(),n=t.lastIndexOf("/"),r=n<0?"":t.slice(0,n)||"/",o=Ll(r,e.home);if(!au(t)||!o.startsWith("/"))return[];const i=t.slice(n+1).toLowerCase(),l=e.answered.trim()===t?e.target:null,c=!l||(i?l.parentExists:l.exists&&l.isDir&&!l.isRepo),u=e.entries.filter(f=>{if(f.isRepo||f.isFile)return!1;const m=Ll(f.path,e.home);return(m.slice(0,m.lastIndexOf("/"))||"/")===o&&f.name.toLowerCase().startsWith(i)}),h=hT(r,e.home);return[...c?[{kind:"here",path:r}]:[],...h?[{kind:"up",path:h}]:[],...u.map(f=>({kind:"dir",entry:f}))]}function lu({sock:e,dispatch:t},n){t({a:"open-repo"}),e==null||e.send(n)}function pT(e,t){const{parent:n,name:r}=Yw(t);lu(e,{t:"create-repo",mode:"init",parent:n,name:r})}function N8(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 Dh(e,t,{sock:n,dispatch:r}){const o=[];e.id!==t&&o.push({id:`repo:${e.id}`,label:`switch to ${e.name}`,onClick:()=>r({a:"activate-repo",id:e.id})});const i=[{id:`setup:${e.id}`,label:"project settings…",detail:e.configFile,onClick:()=>r({a:"open",overlay:{kind:"setup",repoId:e.id}})},{id:`archived:${e.id}`,label:"archived worktrees…",onClick:()=>{r({a:"activate-repo",id:e.id}),r({a:"open",overlay:{kind:"chats",names:!0}})}},{id:`forget:${e.id}`,label:"forget project…",danger:!0,onClick:()=>{window.confirm(`Forget ${e.name}?
202
-
203
- 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.`)&&(n==null||n.send({t:"forget-repo",repoId:e.id}))}}];return Dn([o,i])}const Kf={dark:"dark",light:"light",system:"follow system",daylight:"follow daylight"},Zf={use:"while in use",always:"always",off:"off"};function T8(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 mT(e,{sock:t,dispatch:n}){var l;const r=e.themePrefs,o=c=>{var u;return((u=e.themes.find(h=>h.id===c))==null?void 0:u.name)??c},i=AD();return Dn([[{id:"theme",label:"theme…",detail:gh(r,e.themes,ES(e)).name,sub:!0,onClick:()=>n({a:"open",overlay:{kind:"theme",slot:"theme"}})},{id:"appearance",topic:"theme",label:"light or dark…",detail:Kf[r.mode],sub:!0,onClick:()=>n({a:"open",overlay:{kind:"appearance"}})}],[{id:"agent",label:"default agent…",detail:((l=e.agents.find(c=>c.id===e.defaultAgent))==null?void 0:l.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"})}]:[],...i.access==="none"?[]:[{id:"clipboard-offer",label:"offer what is copied",detail:i.access==="denied"?"blocked in site settings":i.on?"on":"off",onClick:()=>ID(!i.on)}]],...e.keepAwake===null?[]:[[{id:"keep-awake",label:"keep awake…",detail:Zf[e.keepAwake],sub:!0,onClick:()=>n({a:"open",overlay:{kind:"keep-awake"}})}]],[{id:"theme-import",topic:"theme",label:"import a VS Code theme…",onClick:()=>T8((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 j8(e,t,n,r,o,i={machines:[],switchTo:()=>{},forget:()=>{}}){const l=[],c=(g,w,y,v,_)=>l.push({id:g,label:w,hint:v,run:y,sub:_}),u=(g,w)=>{for(const y of g){if(!gs(y)||y.disabled!==void 0||y.checked)continue;const v=y.key??(typeof y.detail=="string"?y.detail:void 0),_=w?`${w.scope}:${y.id}`:y.id,x=y.topic?`${y.topic}: ${y.label}`:y.label;c(_,w?`${x} · ${w.name}`:x,y.onClick,v,y.sub)}},h={sock:n,dispatch:t},f=r,m=f==null?void 0:f.worktree.id;if(u(cT(e,h).filter(g=>!gs(g)||g.id!=="commands")),o&&u(Dh(o,o.id,h),{scope:"project",name:o.name}),m&&!Do(e)){c("pick",e.picking==="chat"?"cancel element picker":"pick an element for the chat",()=>eu(m,e.picking,t,"chat"),Dt("pick")),c("inspect",e.picking==="code"?"cancel element picker":"pick an element to open its code",()=>eu(m,e.picking,t,"code"),Dt("inspect"));const g=bg(e);(g==null?void 0:g.act)==="start"?c("reload","start the preview",()=>n==null?void 0:n.send({t:"preview-start",worktreeId:g.id})):c("reload","reload preview",()=>un.post(m,{type:"reload"}))}if(u(mT(e,h)),f&&m){const g=e.repos.find(w=>w.id===f.worktree.repoId)??null;u(dN(f,g,e,h,{hostname:e.hostname,palette:!0}),{scope:"wt",name:wg(f,g)});for(const w of f.procs)u(Vw(w,m,h))}e.visible.forEach((g,w)=>{var _;if(g.worktree.id===m)return;const v=!!e.activeRepoId&&g.repoId!==e.activeRepoId?` in ${((_=e.repos.find(x=>x.id===g.repoId))==null?void 0:_.name)??g.repoId}`:"";c(`go:${g.worktree.id}`,`switch to ${wg(g,o)}${v}`,()=>t({a:"activate",id:g.worktree.id}),LC(w,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 i.machines){for(const w of g.repos)c(`machine:${g.origin}:${w.id}`,`switch to project ${w.name} on ${g.name}`,()=>i.switchTo(g.origin,w.id));c(`forget-machine:${g.origin}`,`forget ${g.name}`,()=>i.forget(g.origin))}return l}function gT(){const e=ct(),t=rt(),{host:n}=Ur(),r=ss(),o=VS(),i=L(ne=>ne.picking),l=L(ne=>ne.layout),c=L(ne=>ne.chatSide),u=L(ne=>ne.blackGround),h=L(ne=>ne.keepAwake),f=L(ne=>ne.railOpen),m=L(ne=>ne.themePrefs),g=L(ne=>ne.themes),w=L(ne=>ne.systemDark),y=L(ne=>ne.daylight),v=L(ne=>ne.rows),_=L(ne=>ne.visible),x=L(ne=>ne.activeId),T=L(ne=>ne.activeRepoId),N=L(ne=>ne.repos),j=L(ne=>ne.agents),$=L(ne=>ne.defaultAgent),O=L(ne=>ne.shipping),I=L(ne=>ne.remote),P=L(ne=>ne.managed),R=L(ne=>ne.frame),U=L(ne=>ne.self),F=L(ne=>ne.archivedPage),B=L(ne=>ne.notesPage),X=L(ne=>ne.archived),ae=L(ne=>ne.knocks),Y=L(ne=>ne.tailscale);return S.useMemo(()=>{const ne={picking:i,layout:l,chatSide:c,blackGround:u,keepAwake:h,railOpen:f,themePrefs:m,themes:g,systemDark:w,daylight:y,rows:v,visible:_,activeId:x,activeRepoId:T,repos:N,agents:j,defaultAgent:$,shipping:O,frame:R,self:U,archivedPage:F,notesPage:B,archived:X,knocks:ae,hostname:n},C={machines:o,switchTo:(H,V)=>{var J;(J=r.get(H))==null||J.store.dispatch({a:"activate-repo",id:V}),r.activate(H)},forget:H=>{const V=Vg(r,H).find(J=>gs(J)&&J.id.startsWith("forget-machine:"));V&&gs(V)&&V.onClick()}};return j8(ne,e,t,rn(ne,x),Ii(ne,T),C)},[i,l,c,u,h,f,m,g,w,y,v,_,x,T,N,j,$,O,I,P,R,U,F,B,X,ae,Y,e,t,n,r,o])}function kT(e,t){const n=t.trim().toLowerCase();if(!n)return e;const r=[];for(const o of e){const i=Xg(o.label.toLowerCase(),n);i>0&&r.push({c:o,score:i})}return r.sort((o,i)=>i.score-o.score),r.map(o=>o.c)}function Xg(e,t){const n=Xw(e,t);if(!n)return 0;let r=0,o=0,i=-1;for(const l of n)o=l===i+1?o+1:1,r+=o+(wT(e,l)?3:0),i=l;return r+Math.max(0,40-e.length/4)}const wT=(e,t)=>t===0||/[\s:\-–—·/.(]/.test(e[t-1]);function Xw(e,t){const n=e.toLowerCase(),r=[];let o=0;for(const i of t.toLowerCase()){let l=-1;if(n[o]===i)l=o;else if(i===" ")l=n.indexOf(" ",o);else for(let c=n.indexOf(i,o);c!==-1;c=n.indexOf(i,c+1))if(wT(n,c)){l=c;break}if(l===-1)return null;r.push(l),o=l+1}return r}const Jo=(e,...t)=>{const n=e.trim().toLowerCase();return!n||t.some(r=>r==null?void 0:r.toLowerCase().includes(n))},$8=/^[^\s]*$/,C8=e=>e.split(/\s+/).slice(1).every(t=>!t||/[a-z0-9]/i.test(t));function Hm(e,t,n){if(e.startsWith("!"))return null;if(e.startsWith("/")){const l=e.indexOf(" "),c=l===-1?e.length:l;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(!$8.test(o)&&!(C8(o)&&(n!=null&&n(o))))return null;let i=t;for(;i<e.length&&!/\s/.test(e[i]??"");)i++;return{kind:"file",query:o,from:r,to:i}}const Qg=new Map,Fx={files:new Set,folders:new Set,worktrees:Qg,titled:[]},Bx=new WeakMap;function yT(e,t=Qg){let n;if(e?(n=Bx.get(e),n||(n={...Fx,files:new Set(e),folders:new Set(kS(e))},Bx.set(e,n))):n=Fx,t===Qg)return n;const r=[...t].map(([o,i])=>({...i,branch:o})).sort((o,i)=>i.title.length-o.title.length);return{...n,worktrees:t,titled:r}}function vT(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 A8=/(^|\s)(@\S+)/g,I8=/[.,;:!?)\]}'"]$/,R8=/^[.,;:!?)\]}'"]*(\s|$)/;function Ux(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 O8(e,t){const n=e.toLowerCase();for(const r of t.titled){const o=r.title.toLowerCase();if(o&&n.startsWith(o)&&R8.test(e.slice(o.length)))return{kind:"worktree",text:`@${e.slice(0,o.length)}`,...r}}return null}function zh(e){const t=[];return e.archived?t.push("archived"):(e.state&&t.push(e.state),e.at!==void 0&&t.push(`last sent ${bo(ur(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 M8(e,t,n){let r=0;for(const o of Qw(e,n)){if(r===t)return o.kind!=="text";r+=o.text.length}return!1}function Qw(e,t){const n=[];let r=0;const o=i=>{if(!i)return;const l=n.at(-1);(l==null?void 0:l.kind)==="text"?l.text+=i:n.push({kind:"text",text:i})};for(const i of e.matchAll(A8)){const l=i.index+(i[1]??"").length;if(l<r)continue;const c=O8(e.slice(l+1),t);let u=(i[2]??"").slice(1),h=c&&/\s/.test(c.text)?c:Ux(u,t);for(;!h&&I8.test(u);)u=u.slice(0,-1),h=u?Ux(u,t):null;h??(h=c),h&&(o(e.slice(r,l)),n.push(h),r=l+h.text.length)}return o(e.slice(r)),n}function Hx(e,t){return Qw(e,t).map(n=>n.kind==="worktree"?`@${n.branch}`:n.text).join("")}function P8(e,t,n){return{text:e.slice(0,t.from)+n+e.slice(t.to),caret:t.from+n.length}}function L8(e,t){const n=t.trim().toLowerCase();if(!n)return e;const r=i=>e.map((l,c)=>({c:l,i:c,score:i(l)})).filter(l=>l.score>0).sort((l,c)=>c.score-l.score||l.i-c.i).map(l=>l.c),o=r(i=>Xg(i.name,n));return o.length>0?o:r(i=>Xg(i.description,n))}const Wx=e=>e.slice(e.lastIndexOf("/")+1);function D8(e,t,n){const r=[],o=new Set;for(const i of e){const l=i.worktree;if(l.repoId!==n)continue;const c=Wx(l.path);o.has(c)||(o.add(c),r.push({dir:c,id:l.id,title:l.title,branch:l.branch}))}for(const i of t??[]){const l=Wx(i.path);i.repoId!==n||o.has(l)||(o.add(l),r.push({dir:l,id:i.id,title:i.title,branch:i.branch,archived:!0}))}return r}const Kx=new WeakMap;function z8(e,t){let n=Kx.get(e.visible);n||(n=new Map,Kx.set(e.visible,n));const r=e.archived[t],o=n.get(t);if(o&&o.archived===r)return o.key;const i=JSON.stringify(D8(e.visible,r,t));return n.set(t,{archived:r,key:i}),i}function F8(e){const t=new Map;for(const n of JSON.parse(e))t.set(n.dir,n);return n=>t.get(n)??null}const bT="wt-[0-9a-f]{4}",B8=new RegExp(`(^|[^\\w\\-/\`])\`?${bT}(?![\\w\\-/\`])`),U8=new RegExp(`^(\`?)(${bT})\\1(?![\\w\\-/\`])`),sa=e=>iu(e).replace(/"/g,"&quot;");function H8(e){return{name:"worktree",level:"inline",start:t=>{const n=B8.exec(t);return n?n.index+n[1].length:void 0},tokenizer(t){const n=U8.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=zh({id:r.id,title:r.title,branch:r.branch,dir:n,...r.archived?{archived:!0}:{}}),i=r.archived?' data-archived=""':"",l=o.dot?` data-tip-dot="${sa(o.dot)}"`:"";return`<span class="chat-mention" data-worktree="${sa(r.id)}" data-branch="${sa(r.branch)}" data-dir="${sa(n)}"${i} data-tip="${sa(o.text)}" data-tip-detail="${sa(o.detail.join(`
204
- `))}"${l} data-tip-placement="follow">@<span class="chat-mention-dot"><span class="dot${o.dot?` ${sa(o.dot)}`:""}"></span></span>${iu(r.title)}</span>`}}}const W8=4*Ea;function K8(e,t,n){if(!e)return{from:t,to:t,at:n,span:Ea};const r=Math.min(xT(e,n),t),o=Math.min(Math.max(n-e.at,Ea),W8);return{from:r,to:t,at:n,span:o}}function xT(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 Z8(e,t){if(t>=e.length)return e;const n=e.charCodeAt(t);return e.slice(0,n>=56320&&n<=57343?t+1:t)}function q8(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]},i=e.inherit(e.COMMENT(),{match:[/(^|\s)/,/#.*$/],scope:{2:"comment"}}),l={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"],w=e.SHEBANG({binary:`(${g.join("|")})`,relevance:10}),y={className:"function",begin:/\w[\w\d_]*\s*\(\s*\)\s*\{/,returnBegin:!0,contains:[e.inherit(e.TITLE_MODE,{begin:/\w[\w\d_]*/})],relevance:0},v=["if","then","else","elif","fi","time","for","while","until","in","do","done","case","esac","coproc","function","select"],_=["true","false"],x={match:/(\/[a-z._-]+)+/},T=["break","cd","continue","eval","exec","exit","export","getopts","hash","pwd","readonly","return","shift","test","times","trap","umask","unset"],N=["alias","bind","builtin","caller","command","declare","echo","enable","help","let","local","logout","mapfile","printf","read","readarray","source","sudo","type","typeset","ulimit","unalias"],j=["autoload","bg","bindkey","bye","cap","chdir","clone","comparguments","compcall","compctl","compdescribe","compfiles","compgroups","compquote","comptags","comptry","compvalues","dirs","disable","disown","echotc","echoti","emulate","fc","fg","float","functions","getcap","getln","history","integer","jobs","kill","limit","log","noglob","popd","print","pushd","pushln","rehash","sched","setcap","setopt","stat","suspend","ttyctl","unfunction","unhash","unlimit","unsetopt","vared","wait","whence","where","which","zcompile","zformat","zftp","zle","zmodload","zparseopts","zprof","zpty","zregexparse","zsocket","zstyle","ztcp"],$=["chcon","chgrp","chown","chmod","cp","dd","df","dir","dircolors","ln","ls","mkdir","mkfifo","mknod","mktemp","mv","realpath","rm","rmdir","shred","sync","touch","truncate","vdir","b2sum","base32","base64","cat","cksum","comm","csplit","cut","expand","fmt","fold","head","join","md5sum","nl","numfmt","od","paste","ptx","pr","sha1sum","sha224sum","sha256sum","sha384sum","sha512sum","shuf","sort","split","sum","tac","tail","tr","tsort","unexpand","uniq","wc","arch","basename","chroot","date","dirname","du","echo","env","expr","factor","groups","hostid","id","link","logname","nice","nohup","nproc","pathchk","pinky","printenv","printf","pwd","readlink","runcon","seq","sleep","stat","stdbuf","stty","tee","test","timeout","tty","uname","unlink","uptime","users","who","whoami","yes"];return{name:"Bash",aliases:["sh","zsh"],keywords:{$pattern:/\b[a-z][a-z0-9._-]+\b/,keyword:v,literal:_,built_in:[...T,...N,"set","shopt",...j,...$]},contains:[w,e.SHEBANG(),y,m,i,l,x,c,u,h,f,n]}}const G8=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_-]*/}}),V8=["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"],Y8=["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"],X8=[...V8,...Y8],Q8=["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(),J8=["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(),e9=["after","backdrop","before","cue","cue-region","first-letter","first-line","grammar-error","marker","part","placeholder","selection","slotted","spelling-error"].sort().reverse(),t9=["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 n9(e){const t=e.regex,n=G8(e),r={begin:/-(webkit|moz|ms|o)-(?=[a-z])/},o="and or not only",i=/@-?\w[\w]*(-\w+)*/,l="[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:"\\."+l,relevance:0},n.ATTRIBUTE_SELECTOR_MODE,{className:"selector-pseudo",variants:[{begin:":("+J8.join("|")+")"},{begin:":(:)?("+e9.join("|")+")"}]},n.CSS_VARIABLE,{className:"attribute",begin:"\\b("+t9.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:i},{begin:/\s/,endsWithParent:!0,excludeEnd:!0,relevance:0,keywords:{$pattern:/[a-z-]+/,keyword:o,attribute:Q8.join(" ")},contains:[{begin:/[a-z-]+(?=:)/,className:"attribute"},...c,n.CSS_NUMBER_MODE]}]},{className:"selector-tag",begin:"\\b("+X8.join("|")+")\\b"}]}}function r9(e){const i={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:i,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:i,illegal:/["']/}]}]}}function o9(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:/\$\{(.*?)\}/}]},i={className:"literal",begin:/\bon|off|true|false|yes|no\b/},l={className:"string",contains:[e.BACKSLASH_ESCAPE],variants:[{begin:"'''",end:"'''",relevance:10},{begin:'"""',end:'"""',relevance:10},{begin:'"',end:'"'},{begin:"'",end:"'"}]},c={begin:/\[/,end:/\]/,contains:[r,i,o,l,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,i,o,l,n]}}]}}const Zx="[A-Za-z$_][0-9A-Za-z$_]*",s9=["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"],i9=["true","false","null","undefined","NaN","Infinity"],ET=["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"],ST=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],_T=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],a9=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","self","global"],l9=[].concat(_T,ET,ST);function c9(e){const t=e.regex,n=(H,{after:V})=>{const J="</"+H[0].slice(1);return H.input.indexOf(J,V)!==-1},r=Zx,o={begin:"<>",end:"</>"},i=/<[A-Za-z0-9\\._:-]+\s*\/>/,l={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(H,V)=>{const J=H[0].length+H.index,Z=H.input[J];if(Z==="<"||Z===","){V.ignoreMatch();return}Z===">"&&(n(H,{after:J})||V.ignoreMatch());let ie;const be=H.input.substring(J);if(ie=be.match(/^\s*=/)){V.ignoreMatch();return}if((ie=be.match(/^\s+extends\s+/))&&ie.index===0){V.ignoreMatch();return}}},c={$pattern:Zx,keyword:s9,literal:i9,built_in:l9,"variable.language":a9},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:[]},w={begin:".?html`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,g],subLanguage:"xml"}},y={begin:".?css`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,g],subLanguage:"css"}},v={begin:".?gql`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,g],subLanguage:"graphql"}},_={className:"string",begin:"`",end:"`",contains:[e.BACKSLASH_ESCAPE,g]},T={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]},N=[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,w,y,v,_,{match:/\$\d+/},m];g.contains=N.concat({begin:/\{/,end:/\}/,keywords:c,contains:["self"].concat(N)});const j=[].concat(T,g.contains),$=j.concat([{begin:/(\s*)\(/,end:/\)/,keywords:c,contains:["self"].concat(j)}]),O={className:"params",begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:c,contains:$},I={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"}}]},P={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:{_:[...ET,...ST]}},R={label:"use_strict",className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},U={variants:[{match:[/function/,/\s+/,r,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:"keyword",3:"title.function"},label:"func.def",contains:[O],illegal:/%/},F={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"};function B(H){return t.concat("(?!",H.join("|"),")")}const X={match:t.concat(/\b/,B([..._T,"super","import","await"].map(H=>`${H}\\s*\\(`)),r,t.lookahead(/\s*\(/)),className:"title.function",relevance:0},ae={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:/\(\)/},O]},ne="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+e.UNDERSCORE_IDENT_RE+")\\s*=>",C={match:[/const|var|let/,/\s+/,r,/\s*/,/=\s*/,/(async\s*)?/,t.lookahead(ne)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[O]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:c,exports:{PARAMS_CONTAINS:$,CLASS_REFERENCE:P},illegal:/#(?![$_A-Za-z])/,contains:[e.SHEBANG({label:"shebang",binary:"node",relevance:5}),R,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,w,y,v,_,T,{match:/\$\d+/},m,P,{scope:"attr",match:r+t.lookahead(":"),relevance:0},C,{begin:"("+e.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",relevance:0,contains:[T,e.REGEXP_MODE,{className:"function",begin:ne,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:$}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:o.begin,end:o.end},{match:i},{begin:l.begin,"on:begin":l.isTrulyOpeningTag,end:l.end}],subLanguage:"xml",contains:[{begin:l.begin,end:l.end,skip:!0,contains:["self"]}]}]},U,{beginKeywords:"while if switch catch for"},{begin:"\\b(?!function)"+e.UNDERSCORE_IDENT_RE+"\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",returnBegin:!0,label:"func.def",contains:[O,e.inherit(e.TITLE_MODE,{begin:r,className:"title.function"})]},{match:/\.\.\./,relevance:0},ae,{match:"\\$"+r,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[O]},X,F,I,Y,{match:/\$[(.]/}]}}const u9="([-+]?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)|NaN|[-+]?Infinity",d9={scope:"number",match:u9,relevance:0};function f9(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,d9,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE],illegal:"\\S"}}function h9(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}]},i={className:"bullet",begin:"^[ ]*([*+-]|(\\d+\\.))(?=\\s+)",end:"\\s+",excludeEnd:!0},l={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 w=[n,u];return[h,f,m,g].forEach(x=>{x.contains=x.contains.concat(w)}),w=w.concat(h,f),{name:"Markdown",aliases:["md","mkdown","mkd"],contains:[{className:"section",variants:[{begin:"^#{1,6}",end:"$",contains:w},{begin:"(?=^.+?\\n[=-]{2,}$)",contains:[{begin:"^[=-]*$"},{begin:"^",end:"\\n",contains:w}]}]},n,i,r,h,f,{className:"quote",begin:"^>\\s+",contains:w,end:"$"},o,u,l,{scope:"literal",match:/&([a-zA-Z0-9]+|#[0-9]{1,7}|#[Xx][0-9a-fA-F]{1,6});/}]}}function p9(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])*",w=`(\\b(${g}))?\\.(${g})|\\b(${g})\\.`,y=`\\b|${r.join("|")}`,v={className:"number",relevance:0,variants:[{begin:`(\\b(${g})|(${w}))[eE][+-]?(${g})[jJ]?(?=${y})`},{begin:`(${w})[jJ]?`},{begin:`\\b([1-9](_?[0-9])*|0+(_?0)*)[lLjJ]?(?=${y})`},{begin:`\\b0[bB](_?[01])+[lL]?(?=${y})`},{begin:`\\b0[oO](_?[0-7])+[lL]?(?=${y})`},{begin:`\\b0[xX](_?[0-9a-fA-F])+[lL]?(?=${y})`},{begin:`\\b(${g})[jJ](?=${y})`}]},_={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,_,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 m9(e){const t=e.regex,n=/(r#)?/,r=t.concat(n,e.UNDERSCORE_IDENT_RE),o=t.concat(n,e.IDENT_RE),i={scope:"title.function.invoke",relevance:0,begin:t.concat(/\b/,/(?!(?:let|for|while|if|else|match)\b)/,o,t.lookahead(/\s*\(/))},l="([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_]+)"+l},{begin:"\\b0o([0-7_]+)"+l},{begin:"\\b0x([A-Fa-f0-9_]+)"+l},{begin:"\\b(\\d[\\d_]*(\\.[0-9_]+)?([eE][+-]?[0-9_]+)?)"+l}],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:"->"},i]}}const qf="[A-Za-z$_][0-9A-Za-z$_]*",NT=["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"],TT=["true","false","null","undefined","NaN","Infinity"],jT=["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"],$T=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],CT=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],AT=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","self","global"],IT=[].concat(CT,jT,$T);function g9(e){const t=e.regex,n=(H,{after:V})=>{const J="</"+H[0].slice(1);return H.input.indexOf(J,V)!==-1},r=qf,o={begin:"<>",end:"</>"},i=/<[A-Za-z0-9\\._:-]+\s*\/>/,l={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(H,V)=>{const J=H[0].length+H.index,Z=H.input[J];if(Z==="<"||Z===","){V.ignoreMatch();return}Z===">"&&(n(H,{after:J})||V.ignoreMatch());let ie;const be=H.input.substring(J);if(ie=be.match(/^\s*=/)){V.ignoreMatch();return}if((ie=be.match(/^\s+extends\s+/))&&ie.index===0){V.ignoreMatch();return}}},c={$pattern:qf,keyword:NT,literal:TT,built_in:IT,"variable.language":AT},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:[]},w={begin:".?html`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,g],subLanguage:"xml"}},y={begin:".?css`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,g],subLanguage:"css"}},v={begin:".?gql`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,g],subLanguage:"graphql"}},_={className:"string",begin:"`",end:"`",contains:[e.BACKSLASH_ESCAPE,g]},T={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]},N=[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,w,y,v,_,{match:/\$\d+/},m];g.contains=N.concat({begin:/\{/,end:/\}/,keywords:c,contains:["self"].concat(N)});const j=[].concat(T,g.contains),$=j.concat([{begin:/(\s*)\(/,end:/\)/,keywords:c,contains:["self"].concat(j)}]),O={className:"params",begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:c,contains:$},I={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"}}]},P={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:{_:[...jT,...$T]}},R={label:"use_strict",className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},U={variants:[{match:[/function/,/\s+/,r,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:"keyword",3:"title.function"},label:"func.def",contains:[O],illegal:/%/},F={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"};function B(H){return t.concat("(?!",H.join("|"),")")}const X={match:t.concat(/\b/,B([...CT,"super","import","await"].map(H=>`${H}\\s*\\(`)),r,t.lookahead(/\s*\(/)),className:"title.function",relevance:0},ae={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:/\(\)/},O]},ne="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+e.UNDERSCORE_IDENT_RE+")\\s*=>",C={match:[/const|var|let/,/\s+/,r,/\s*/,/=\s*/,/(async\s*)?/,t.lookahead(ne)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[O]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:c,exports:{PARAMS_CONTAINS:$,CLASS_REFERENCE:P},illegal:/#(?![$_A-Za-z])/,contains:[e.SHEBANG({label:"shebang",binary:"node",relevance:5}),R,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,w,y,v,_,T,{match:/\$\d+/},m,P,{scope:"attr",match:r+t.lookahead(":"),relevance:0},C,{begin:"("+e.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",relevance:0,contains:[T,e.REGEXP_MODE,{className:"function",begin:ne,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:$}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:o.begin,end:o.end},{match:i},{begin:l.begin,"on:begin":l.isTrulyOpeningTag,end:l.end}],subLanguage:"xml",contains:[{begin:l.begin,end:l.end,skip:!0,contains:["self"]}]}]},U,{beginKeywords:"while if switch catch for"},{begin:"\\b(?!function)"+e.UNDERSCORE_IDENT_RE+"\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",returnBegin:!0,label:"func.def",contains:[O,e.inherit(e.TITLE_MODE,{begin:r,className:"title.function"})]},{match:/\.\.\./,relevance:0},ae,{match:"\\$"+r,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[O]},X,F,I,Y,{match:/\$[(.]/}]}}function k9(e){const t=e.regex,n=g9(e),r=qf,o=["any","void","number","boolean","string","object","never","symbol","bigint","unknown"],i={begin:[/namespace/,/\s+/,e.IDENT_RE],beginScope:{1:"keyword",3:"title.class"}},l={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:qf,keyword:NT.concat(u),literal:TT,built_in:IT.concat(o),"variable.language":AT},f={className:"meta",begin:"@"+r},m=(v,_,x)=>{const T=v.contains.findIndex(N=>N.label===_);if(T===-1)throw new Error("can not find mode to replace");v.contains.splice(T,1,x)};Object.assign(n.keywords,h),n.exports.PARAMS_CONTAINS.push(f);const g=n.contains.find(v=>v.scope==="attr"),w=Object.assign({},g,{match:t.concat(r,t.lookahead(/\s*\?:/))});n.exports.PARAMS_CONTAINS.push([n.exports.CLASS_REFERENCE,g,w]),n.contains=n.contains.concat([f,i,l,w]),m(n,"shebang",e.SHEBANG()),m(n,"use_strict",c);const y=n.contains.find(v=>v.label==="func.def");return y.relevance=0,Object.assign(n,{name:"TypeScript",aliases:["ts","tsx","mts","cts"]}),n}function w9(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]+;/},i={begin:/\s/,contains:[{className:"keyword",begin:/#?[a-z_][a-z1-9_-]+/,illegal:/\n/}]},l=e.inherit(i,{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:[i,u,c,l,{begin:/\[/,end:/\]/,contains:[{className:"meta",begin:/<![a-z]/,end:/>/,contains:[i,l,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 y9(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:/\}/}]},i={className:"string",relevance:0,begin:/'/,end:/'/,contains:[{match:/''/,scope:"char.escape",relevance:0}]},l={className:"string",relevance:0,variants:[{begin:/"/,end:/"/},{begin:/\S+/}],contains:[e.BACKSLASH_ESCAPE,o]},c=e.inherit(l,{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"},w={end:",",endsWithParent:!0,excludeEnd:!0,keywords:t,relevance:0},y={begin:/\{/,end:/\}/,contains:[w],illegal:"\\n",relevance:0},v={begin:"\\[",end:"\\]",contains:[w],illegal:"\\n",relevance:0},_=[r,{className:"meta",begin:"^---\\s*$",relevance:10},{className:"string",begin:"[\\|>]([1-9]?[+-])?[ ]*\\n( +)[^ ][^\\n]*\\n(\\2[^\\n]+\\n?)*"},{begin:"<%[%=-]?",end:"[%-]?%>",subLanguage:"ruby",excludeBegin:!0,excludeEnd:!0,relevance:0},{className:"type",begin:"!\\w+!"+n},{className:"type",begin:"!<"+n+">"},{className:"type",begin:"!"+n},{className:"type",begin:"!!"+n},{className:"meta",begin:"&"+e.UNDERSCORE_IDENT_RE+"$"},{className:"meta",begin:"\\*"+e.UNDERSCORE_IDENT_RE+"$"},{className:"bullet",begin:"-(?=[ ]|$)",relevance:0},e.HASH_COMMENT_MODE,{beginKeywords:t,keywords:{literal:t}},g,{className:"number",begin:e.C_NUMBER_RE+"\\b",relevance:0},y,v,i,l],x=[..._];return x.pop(),x.push(c),w.contains=x,{name:"YAML",case_insensitive:!0,aliases:["yml"],contains:_}}var Wm,qx;function v9(){if(qx)return Wm;qx=1;function e(M){return M instanceof Map?M.clear=M.delete=M.set=function(){throw new Error("map is read-only")}:M instanceof Set&&(M.add=M.clear=M.delete=function(){throw new Error("set is read-only")}),Object.freeze(M),Object.getOwnPropertyNames(M).forEach(re=>{const Ne=M[re],Ze=typeof Ne;(Ze==="object"||Ze==="function")&&!Object.isFrozen(Ne)&&e(Ne)}),M}class t{constructor(re){re.data===void 0&&(re.data={}),this.data=re.data,this.isMatchIgnored=!1}ignoreMatch(){this.isMatchIgnored=!0}}function n(M){return M.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#x27;")}function r(M,...re){const Ne=Object.create(null);for(const Ze in M)Ne[Ze]=M[Ze];return re.forEach(function(Ze){for(const jt in Ze)Ne[jt]=Ze[jt]}),Ne}const o="</span>",i=M=>!!M.scope,l=(M,{prefix:re})=>{if(M.startsWith("language:"))return M.replace("language:","language-");if(M.includes(".")){const Ne=M.split(".");return[`${re}${Ne.shift()}`,...Ne.map((Ze,jt)=>`${Ze}${"_".repeat(jt+1)}`)].join(" ")}return`${re}${M}`};class c{constructor(re,Ne){this.buffer="",this.classPrefix=Ne.classPrefix,re.walk(this)}addText(re){this.buffer+=n(re)}openNode(re){if(!i(re))return;const Ne=l(re.scope,{prefix:this.classPrefix});this.span(Ne)}closeNode(re){i(re)&&(this.buffer+=o)}value(){return this.buffer}span(re){this.buffer+=`<span class="${re}">`}}const u=(M={})=>{const re={children:[]};return Object.assign(re,M),re};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(re){this.top.children.push(re)}openNode(re){const Ne=u({scope:re});this.add(Ne),this.stack.push(Ne)}closeNode(){if(this.stack.length>1)return this.stack.pop()}closeAllNodes(){for(;this.closeNode(););}toJSON(){return JSON.stringify(this.rootNode,null,4)}walk(re){return this.constructor._walk(re,this.rootNode)}static _walk(re,Ne){return typeof Ne=="string"?re.addText(Ne):Ne.children&&(re.openNode(Ne),Ne.children.forEach(Ze=>this._walk(re,Ze)),re.closeNode(Ne)),re}static _collapse(re){typeof re!="string"&&re.children&&(re.children.every(Ne=>typeof Ne=="string")?re.children=[re.children.join("")]:re.children.forEach(Ne=>{h._collapse(Ne)}))}}class f extends h{constructor(re){super(),this.options=re}addText(re){re!==""&&this.add(re)}startScope(re){this.openNode(re)}endScope(){this.closeNode()}__addSublanguage(re,Ne){const Ze=re.root;Ne&&(Ze.scope=`language:${Ne}`),this.add(Ze)}toHTML(){return new c(this,this.options).value()}finalize(){return this.closeAllNodes(),!0}}function m(M){return M?typeof M=="string"?M:M.source:null}function g(M){return v("(?=",M,")")}function w(M){return v("(?:",M,")*")}function y(M){return v("(?:",M,")?")}function v(...M){return M.map(Ne=>m(Ne)).join("")}function _(M){const re=M[M.length-1];return typeof re=="object"&&re.constructor===Object?(M.splice(M.length-1,1),re):{}}function x(...M){return"("+(_(M).capture?"":"?:")+M.map(Ze=>m(Ze)).join("|")+")"}function T(M){return new RegExp(M.toString()+"|").exec("").length-1}function N(M,re){const Ne=M&&M.exec(re);return Ne&&Ne.index===0}const j=/\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)|\\./;function $(M,{joinWith:re}){let Ne=0;return M.map(Ze=>{Ne+=1;const jt=Ne;let Ut=m(Ze),Me="";for(;Ut.length>0;){const Pe=j.exec(Ut);if(!Pe){Me+=Ut;break}Me+=Ut.substring(0,Pe.index),Ut=Ut.substring(Pe.index+Pe[0].length),Pe[0][0]==="\\"&&Pe[1]?Me+="\\"+String(Number(Pe[1])+jt):(Me+=Pe[0],Pe[0]==="("&&Ne++)}return Me}).map(Ze=>`(${Ze})`).join(re)}const O=/\b\B/,I="[a-zA-Z]\\w*",P="[a-zA-Z_]\\w*",R="\\b\\d+(\\.\\d+)?",U="(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)",F="\\b(0b[01]+)",B="!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~",X=(M={})=>{const re=/^#![ ]*\//;return M.binary&&(M.begin=v(re,/.*\b/,M.binary,/\b.*/)),r({scope:"meta",begin:re,end:/$/,relevance:0,"on:begin":(Ne,Ze)=>{Ne.index!==0&&Ze.ignoreMatch()}},M)},ae={begin:"\\\\[\\s\\S]",relevance:0},Y={scope:"string",begin:"'",end:"'",illegal:"\\n",contains:[ae]},ne={scope:"string",begin:'"',end:'"',illegal:"\\n",contains:[ae]},C={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/},H=function(M,re,Ne={}){const Ze=r({scope:"comment",begin:M,end:re,contains:[]},Ne);Ze.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 jt=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 Ze.contains.push({begin:v(/[ ]+/,"(",jt,/[.]?[:]?([.][ ]|[ ])/,"){3}")}),Ze},V=H("//","$"),J=H("/\\*","\\*/"),Z=H("#","$"),ie={scope:"number",begin:R,relevance:0},be={scope:"number",begin:U,relevance:0},ge={scope:"number",begin:F,relevance:0},we={scope:"regexp",begin:/\/(?=[^/\n]*\/)/,end:/\/[gimuy]*/,contains:[ae,{begin:/\[/,end:/\]/,relevance:0,contains:[ae]}]},pe={scope:"title",begin:I,relevance:0},Q={scope:"title",begin:P,relevance:0},W={begin:"\\.\\s*"+P,relevance:0};var _e=Object.freeze({__proto__:null,APOS_STRING_MODE:Y,BACKSLASH_ESCAPE:ae,BINARY_NUMBER_MODE:ge,BINARY_NUMBER_RE:F,COMMENT:H,C_BLOCK_COMMENT_MODE:J,C_LINE_COMMENT_MODE:V,C_NUMBER_MODE:be,C_NUMBER_RE:U,END_SAME_AS_BEGIN:function(M){return Object.assign(M,{"on:begin":(re,Ne)=>{Ne.data._beginMatch=re[1]},"on:end":(re,Ne)=>{Ne.data._beginMatch!==re[1]&&Ne.ignoreMatch()}})},HASH_COMMENT_MODE:Z,IDENT_RE:I,MATCH_NOTHING_RE:O,METHOD_GUARD:W,NUMBER_MODE:ie,NUMBER_RE:R,PHRASAL_WORDS_MODE:C,QUOTE_STRING_MODE:ne,REGEXP_MODE:we,RE_STARTERS_RE:B,SHEBANG:X,TITLE_MODE:pe,UNDERSCORE_IDENT_RE:P,UNDERSCORE_TITLE_MODE:Q});function ve(M,re){M.input[M.index-1]==="."&&re.ignoreMatch()}function ce(M,re){M.className!==void 0&&(M.scope=M.className,delete M.className)}function Se(M,re){re&&M.beginKeywords&&(M.begin="\\b("+M.beginKeywords.split(" ").join("|")+")(?!\\.)(?=\\b|\\s)",M.__beforeBegin=ve,M.keywords=M.keywords||M.beginKeywords,delete M.beginKeywords,M.relevance===void 0&&(M.relevance=0))}function me(M,re){Array.isArray(M.illegal)&&(M.illegal=x(...M.illegal))}function Ue(M,re){if(M.match){if(M.begin||M.end)throw new Error("begin & end are not supported with match");M.begin=M.match,delete M.match}}function Ie(M,re){M.relevance===void 0&&(M.relevance=1)}const We=(M,re)=>{if(!M.beforeMatch)return;if(M.starts)throw new Error("beforeMatch cannot be used with starts");const Ne=Object.assign({},M);Object.keys(M).forEach(Ze=>{delete M[Ze]}),M.keywords=Ne.keywords,M.begin=v(Ne.beforeMatch,g(Ne.begin)),M.starts={relevance:0,contains:[Object.assign(Ne,{endsParent:!0})]},M.relevance=0,delete Ne.beforeMatch},mt=["of","and","for","in","not","or","if","then","parent","list","value"],en="keyword";function Kt(M,re,Ne=en){const Ze=Object.create(null);return typeof M=="string"?jt(Ne,M.split(" ")):Array.isArray(M)?jt(Ne,M):Object.keys(M).forEach(function(Ut){Object.assign(Ze,Kt(M[Ut],re,Ut))}),Ze;function jt(Ut,Me){re&&(Me=Me.map(Pe=>Pe.toLowerCase())),Me.forEach(function(Pe){const Ve=Pe.split("|");Ze[Ve[0]]=[Ut,Be(Ve[0],Ve[1])]})}}function Be(M,re){return re?Number(re):Xt(M)?0:1}function Xt(M){return mt.includes(M.toLowerCase())}const ln={},It=M=>{console.error(M)},Je=(M,...re)=>{console.log(`WARN: ${M}`,...re)},Vt=(M,re)=>{ln[`${M}/${re}`]||(console.log(`Deprecated as of ${M}. ${re}`),ln[`${M}/${re}`]=!0)},tn=new Error;function ht(M,re,{key:Ne}){let Ze=0;const jt=M[Ne],Ut={},Me={};for(let Pe=1;Pe<=re.length;Pe++)Me[Pe+Ze]=jt[Pe],Ut[Pe+Ze]=!0,Ze+=T(re[Pe-1]);M[Ne]=Me,M[Ne]._emit=Ut,M[Ne]._multi=!0}function gt(M){if(Array.isArray(M.begin)){if(M.skip||M.excludeBegin||M.returnBegin)throw It("skip, excludeBegin, returnBegin not compatible with beginScope: {}"),tn;if(typeof M.beginScope!="object"||M.beginScope===null)throw It("beginScope must be object"),tn;ht(M,M.begin,{key:"beginScope"}),M.begin=$(M.begin,{joinWith:""})}}function sn(M){if(Array.isArray(M.end)){if(M.skip||M.excludeEnd||M.returnEnd)throw It("skip, excludeEnd, returnEnd not compatible with endScope: {}"),tn;if(typeof M.endScope!="object"||M.endScope===null)throw It("endScope must be object"),tn;ht(M,M.end,{key:"endScope"}),M.end=$(M.end,{joinWith:""})}}function kn(M){M.scope&&typeof M.scope=="object"&&M.scope!==null&&(M.beginScope=M.scope,delete M.scope)}function Pt(M){kn(M),typeof M.beginScope=="string"&&(M.beginScope={_wrap:M.beginScope}),typeof M.endScope=="string"&&(M.endScope={_wrap:M.endScope}),gt(M),sn(M)}function Rn(M){function re(Me,Pe){return new RegExp(m(Me),"m"+(M.case_insensitive?"i":"")+(M.unicodeRegex?"u":"")+(Pe?"g":""))}class Ne{constructor(){this.matchIndexes={},this.regexes=[],this.matchAt=1,this.position=0}addRule(Pe,Ve){Ve.position=this.position++,this.matchIndexes[this.matchAt]=Ve,this.regexes.push([Ve,Pe]),this.matchAt+=T(Pe)+1}compile(){this.regexes.length===0&&(this.exec=()=>null);const Pe=this.regexes.map(Ve=>Ve[1]);this.matcherRe=re($(Pe,{joinWith:"|"}),!0),this.lastIndex=0}exec(Pe){this.matcherRe.lastIndex=this.lastIndex;const Ve=this.matcherRe.exec(Pe);if(!Ve)return null;const Lt=Ve.findIndex((zn,et)=>et>0&&zn!==void 0),qt=this.matchIndexes[Lt];return Ve.splice(0,Lt),Object.assign(Ve,qt)}}class Ze{constructor(){this.rules=[],this.multiRegexes=[],this.count=0,this.lastIndex=0,this.regexIndex=0}getMatcher(Pe){if(this.multiRegexes[Pe])return this.multiRegexes[Pe];const Ve=new Ne;return this.rules.slice(Pe).forEach(([Lt,qt])=>Ve.addRule(Lt,qt)),Ve.compile(),this.multiRegexes[Pe]=Ve,Ve}resumingScanAtSamePosition(){return this.regexIndex!==0}considerAll(){this.regexIndex=0}addRule(Pe,Ve){this.rules.push([Pe,Ve]),Ve.type==="begin"&&this.count++}exec(Pe){const Ve=this.getMatcher(this.regexIndex);Ve.lastIndex=this.lastIndex;let Lt=Ve.exec(Pe);if(this.resumingScanAtSamePosition()&&!(Lt&&Lt.index===this.lastIndex)){const qt=this.getMatcher(0);qt.lastIndex=this.lastIndex+1,Lt=qt.exec(Pe)}return Lt&&(this.regexIndex+=Lt.position+1,this.regexIndex===this.count&&this.considerAll()),Lt}}function jt(Me){const Pe=new Ze;return Me.contains.forEach(Ve=>Pe.addRule(Ve.begin,{rule:Ve,type:"begin"})),Me.terminatorEnd&&Pe.addRule(Me.terminatorEnd,{type:"end"}),Me.illegal&&Pe.addRule(Me.illegal,{type:"illegal"}),Pe}function Ut(Me,Pe){const Ve=Me;if(Me.isCompiled)return Ve;[ce,Ue,Pt,We].forEach(qt=>qt(Me,Pe)),M.compilerExtensions.forEach(qt=>qt(Me,Pe)),Me.__beforeBegin=null,[Se,me,Ie].forEach(qt=>qt(Me,Pe)),Me.isCompiled=!0;let Lt=null;return typeof Me.keywords=="object"&&Me.keywords.$pattern&&(Me.keywords=Object.assign({},Me.keywords),Lt=Me.keywords.$pattern,delete Me.keywords.$pattern),Lt=Lt||/\w+/,Me.keywords&&(Me.keywords=Kt(Me.keywords,M.case_insensitive)),Ve.keywordPatternRe=re(Lt,!0),Pe&&(Me.begin||(Me.begin=/\B|\b/),Ve.beginRe=re(Ve.begin),!Me.end&&!Me.endsWithParent&&(Me.end=/\B|\b/),Me.end&&(Ve.endRe=re(Ve.end)),Ve.terminatorEnd=m(Ve.end)||"",Me.endsWithParent&&Pe.terminatorEnd&&(Ve.terminatorEnd+=(Me.end?"|":"")+Pe.terminatorEnd)),Me.illegal&&(Ve.illegalRe=re(Me.illegal)),Me.contains||(Me.contains=[]),Me.contains=[].concat(...Me.contains.map(function(qt){return ee(qt==="self"?Me:qt)})),Me.contains.forEach(function(qt){Ut(qt,Ve)}),Me.starts&&Ut(Me.starts,Pe),Ve.matcher=jt(Ve),Ve}if(M.compilerExtensions||(M.compilerExtensions=[]),M.contains&&M.contains.includes("self"))throw new Error("ERR: contains `self` is not supported at the top-level of a language. See documentation.");return M.classNameAliases=r(M.classNameAliases||{}),Ut(M)}function bt(M){return M?M.endsWithParent||bt(M.starts):!1}function ee(M){return M.variants&&!M.cachedVariants&&(M.cachedVariants=M.variants.map(function(re){return r(M,{variants:null},re)})),M.cachedVariants?M.cachedVariants:bt(M)?r(M,{starts:M.starts?r(M.starts):null}):Object.isFrozen(M)?r(M):M}var ke="11.11.2";class Xe extends Error{constructor(re,Ne){super(re),this.name="HTMLInjectionError",this.html=Ne}}const Ge=n,Zt=r,Bt=Symbol("nomatch"),mn=7,an=function(M){const re=Object.create(null),Ne=Object.create(null),Ze=[];let jt=!0;const Ut="Could not find the language '{}', did you forget to load/include a language module?",Me={disableAutodetect:!0,name:"Plain text",contains:[]};let Pe={ignoreUnescapedHTML:!1,throwUnescapedHTML:!1,noHighlightRe:/^(no-?highlight)$/i,languageDetectRe:/\blang(?:uage)?-([\w-]+)\b/i,classPrefix:"hljs-",cssSelector:"pre code",languages:null,__emitter:f};function Ve(Te){return Pe.noHighlightRe.test(Te)}function Lt(Te){let qe=Te.className+" ";qe+=Te.parentNode?Te.parentNode.className:"";const xt=Pe.languageDetectRe.exec(qe);if(xt){const at=yn(xt[1]);return at||(Je(Ut.replace("{}",xt[1])),Je("Falling back to no-highlight mode for this block.",Te)),at?xt[1]:"no-highlight"}return qe.split(/\s+/).find(at=>Ve(at)||yn(at))}function qt(Te,qe,xt){let at="",fn="";typeof qe=="object"?(at=Te,xt=qe.ignoreIllegals,fn=qe.language):(Vt("10.7.0","highlight(lang, code, ...args) has been deprecated."),Vt("10.7.0",`Please use highlight(code, options) instead.
205
- https://github.com/highlightjs/highlight.js/issues/2277`),fn=Te,at=qe),xt===void 0&&(xt=!0);const Ft={code:at,language:fn};Bn("before:highlight",Ft);const cn=Ft.result?Ft.result:zn(Ft.language,Ft.code,xt);return cn.code=Ft.code,Bn("after:highlight",cn),cn}function zn(Te,qe,xt,at){const fn=Object.create(null);function Ft(K,le){return K.keywords[le]}function cn(){if(!Et.keywords){Nn.addText(Qt);return}let K=0;Et.keywordPatternRe.lastIndex=0;let le=Et.keywordPatternRe.exec(Qt),xe="";for(;le;){xe+=Qt.substring(K,le.index);const Re=ar.case_insensitive?le[0].toLowerCase():le[0],$e=Ft(Et,Re);if($e){const[Ct,nn]=$e;if(Nn.addText(xe),xe="",fn[Re]=(fn[Re]||0)+1,fn[Re]<=mn&&(Wr+=nn),Ct.startsWith("_"))xe+=le[0];else{const er=ar.classNameAliases[Ct]||Ct;Un(le[0],er)}}else xe+=le[0];K=Et.keywordPatternRe.lastIndex,le=Et.keywordPatternRe.exec(Qt)}xe+=Qt.substring(K),Nn.addText(xe)}function Hr(){if(Qt==="")return;let K=null;if(typeof Et.subLanguage=="string"){if(!re[Et.subLanguage]){Nn.addText(Qt);return}K=zn(Et.subLanguage,Qt,!0,To[Et.subLanguage]),To[Et.subLanguage]=K._top}else K=Ht(Qt,Et.subLanguage.length?Et.subLanguage:null);Et.relevance>0&&(Wr+=K.relevance),Nn.__addSublanguage(K._emitter,K.language)}function $n(){Et.subLanguage!=null?Hr():cn(),Qt=""}function Un(K,le){K!==""&&(Nn.startScope(le),Nn.addText(K),Nn.endScope())}function yr(K,le){let xe=1;const Re=le.length-1;for(;xe<=Re;){if(!K._emit[xe]){xe++;continue}const $e=ar.classNameAliases[K[xe]]||K[xe],Ct=le[xe];$e?Un(Ct,$e):(Qt=Ct,cn(),Qt=""),xe++}}function Hn(K,le){return K.scope&&typeof K.scope=="string"&&Nn.openNode(ar.classNameAliases[K.scope]||K.scope),K.beginScope&&(K.beginScope._wrap?(Un(Qt,ar.classNameAliases[K.beginScope._wrap]||K.beginScope._wrap),Qt=""):K.beginScope._multi&&(yr(K.beginScope,le),Qt="")),Et=Object.create(K,{parent:{value:Et}}),Et}function G(K,le,xe){let Re=N(K.endRe,xe);if(Re){if(K["on:end"]){const $e=new t(K);K["on:end"](le,$e),$e.isMatchIgnored&&(Re=!1)}if(Re){for(;K.endsParent&&K.parent;)K=K.parent;return K}}if(K.endsWithParent)return G(K.parent,le,xe)}function fe(K){return Et.matcher.regexIndex===0?(Qt+=K[0],1):(z=!0,0)}function tt(K){const le=K[0],xe=K.rule,Re=new t(xe),$e=[xe.__beforeBegin,xe["on:begin"]];for(const Ct of $e)if(Ct&&(Ct(K,Re),Re.isMatchIgnored))return fe(le);return xe.skip?Qt+=le:(xe.excludeBegin&&(Qt+=le),$n(),!xe.returnBegin&&!xe.excludeBegin&&(Qt=le)),Hn(xe,K),xe.returnBegin?0:le.length}function kt(K){const le=K[0],xe=qe.substring(K.index),Re=G(Et,K,xe);if(!Re)return Bt;const $e=Et;Et.endScope&&Et.endScope._wrap?($n(),Un(le,Et.endScope._wrap)):Et.endScope&&Et.endScope._multi?($n(),yr(Et.endScope,K)):$e.skip?Qt+=le:($e.returnEnd||$e.excludeEnd||(Qt+=le),$n(),$e.excludeEnd&&(Qt=le));do Et.scope&&Nn.closeNode(),!Et.skip&&!Et.subLanguage&&(Wr+=Et.relevance),Et=Et.parent;while(Et!==Re.parent);return Re.starts&&Hn(Re.starts,K),$e.returnEnd?0:le.length}function Nt(){const K=[];for(let le=Et;le!==ar;le=le.parent)le.scope&&K.unshift(le.scope);K.forEach(le=>Nn.openNode(le))}let vn={};function Wn(K,le){const xe=le&&le[0];if(Qt+=K,xe==null)return $n(),0;if(vn.type==="begin"&&le.type==="end"&&vn.index===le.index&&xe===""){if(Qt+=qe.slice(le.index,le.index+1),!jt){const Re=new Error(`0 width match regex (${Te})`);throw Re.languageName=Te,Re.badRule=vn.rule,Re}return 1}if(vn=le,le.type==="begin")return tt(le);if(le.type==="illegal"&&!xt){const Re=new Error('Illegal lexeme "'+xe+'" for mode "'+(Et.scope||"<unnamed>")+'"');throw Re.mode=Et,Re}else if(le.type==="end"){const Re=kt(le);if(Re!==Bt)return Re}if(le.type==="illegal"&&xe==="")return le.index===qe.length||(Qt+=`
206
- `),1;if(je>1e5&&je>le.index*3)throw new Error("potential infinite loop, way more iterations than matches");return Qt+=xe,xe.length}const ar=yn(Te);if(!ar)throw It(Ut.replace("{}",Te)),new Error('Unknown language: "'+Te+'"');const jr=Rn(ar);let Gt="",Et=at||jr;const To={},Nn=new Pe.__emitter(Pe);Nt();let Qt="",Wr=0,Rr=0,je=0,z=!1;try{if(ar.__emitTokens)ar.__emitTokens(qe,Nn);else{for(Et.matcher.considerAll();;){je++,z?z=!1:Et.matcher.considerAll(),Et.matcher.lastIndex=Rr;const K=Et.matcher.exec(qe);if(!K)break;const le=qe.substring(Rr,K.index),xe=Wn(le,K);Rr=K.index+xe}Wn(qe.substring(Rr))}return Nn.finalize(),Gt=Nn.toHTML(),{language:Te,value:Gt,relevance:Wr,illegal:!1,_emitter:Nn,_top:Et}}catch(K){if(K.message&&K.message.includes("Illegal"))return{language:Te,value:Ge(qe),illegal:!0,relevance:0,_illegalBy:{message:K.message,index:Rr,context:qe.slice(Rr-100,Rr+100),mode:K.mode,resultSoFar:Gt},_emitter:Nn};if(jt)return{language:Te,value:Ge(qe),illegal:!1,relevance:0,errorRaised:K,_emitter:Nn,_top:Et};throw K}}function et(Te){const qe={value:Ge(Te),illegal:!1,relevance:0,_top:Me,_emitter:new Pe.__emitter(Pe)};return qe._emitter.addText(Te),qe}function Ht(Te,qe){qe=qe||Pe.languages||Object.keys(re);const xt=et(Te),at=qe.filter(yn).filter(ir).map($n=>zn($n,Te,!1));at.unshift(xt);const fn=at.sort(($n,Un)=>{if($n.relevance!==Un.relevance)return Un.relevance-$n.relevance;if($n.language&&Un.language){if(yn($n.language).supersetOf===Un.language)return 1;if(yn(Un.language).supersetOf===$n.language)return-1}return 0}),[Ft,cn]=fn,Hr=Ft;return Hr.secondBest=cn,Hr}function On(Te,qe,xt){const at=qe&&Ne[qe]||xt;Te.classList.add("hljs"),Te.classList.add(`language-${at}`)}function dn(Te){let qe=null;const xt=Lt(Te);if(Ve(xt))return;if(Bn("before:highlightElement",{el:Te,language:xt}),Te.dataset.highlighted){console.log("Element previously highlighted. To highlight again, first unset `dataset.highlighted`.",Te);return}if(Te.children.length>0&&(Pe.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(Te)),Pe.throwUnescapedHTML))throw new Xe("One of your code blocks includes unescaped HTML.",Te.innerHTML);qe=Te;const at=qe.textContent,fn=xt?qt(at,{language:xt,ignoreIllegals:!0}):Ht(at);Te.innerHTML=fn.value,Te.dataset.highlighted="yes",On(Te,xt,fn.language),Te.result={language:fn.language,re:fn.relevance,relevance:fn.relevance},fn.secondBest&&(Te.secondBest={language:fn.secondBest.language,relevance:fn.secondBest.relevance}),Bn("after:highlightElement",{el:Te,result:fn,text:at})}function sr(Te){Pe=Zt(Pe,Te)}const Fn=()=>{Le(),Vt("10.6.0","initHighlighting() deprecated. Use highlightAll() now.")};function hr(){Le(),Vt("10.6.0","initHighlightingOnLoad() deprecated. Use highlightAll() now.")}let oe=!1;function Le(){function Te(){Le()}if(document.readyState==="loading"){oe||window.addEventListener("DOMContentLoaded",Te,!1),oe=!0;return}document.querySelectorAll(Pe.cssSelector).forEach(dn)}function Ye(Te,qe){let xt=null;try{xt=qe(M)}catch(at){if(It("Language definition for '{}' could not be registered.".replace("{}",Te)),jt)It(at);else throw at;xt=Me}xt.name||(xt.name=Te),re[Te]=xt,xt.rawDefinition=qe.bind(null,M),xt.aliases&&Tr(xt.aliases,{languageName:Te})}function $t(Te){delete re[Te];for(const qe of Object.keys(Ne))Ne[qe]===Te&&delete Ne[qe]}function pt(){return Object.keys(re)}function yn(Te){return Te=(Te||"").toLowerCase(),re[Te]||re[Ne[Te]]}function Tr(Te,{languageName:qe}){typeof Te=="string"&&(Te=[Te]),Te.forEach(xt=>{Ne[xt.toLowerCase()]=qe})}function ir(Te){const qe=yn(Te);return qe&&!qe.disableAutodetect}function Wt(Te){Te["before:highlightBlock"]&&!Te["before:highlightElement"]&&(Te["before:highlightElement"]=qe=>{Te["before:highlightBlock"](Object.assign({block:qe.el},qe))}),Te["after:highlightBlock"]&&!Te["after:highlightElement"]&&(Te["after:highlightElement"]=qe=>{Te["after:highlightBlock"](Object.assign({block:qe.el},qe))})}function Yr(Te){Wt(Te),Ze.push(Te)}function dt(Te){const qe=Ze.indexOf(Te);qe!==-1&&Ze.splice(qe,1)}function Bn(Te,qe){const xt=Te;Ze.forEach(function(at){at[xt]&&at[xt](qe)})}function st(Te){return Vt("10.7.0","highlightBlock will be removed entirely in v12.0"),Vt("10.7.0","Please use highlightElement now."),dn(Te)}Object.assign(M,{highlight:qt,highlightAuto:Ht,highlightAll:Le,highlightElement:dn,highlightBlock:st,configure:sr,initHighlighting:Fn,initHighlightingOnLoad:hr,registerLanguage:Ye,unregisterLanguage:$t,listLanguages:pt,getLanguage:yn,registerAliases:Tr,autoDetection:ir,inherit:Zt,addPlugin:Yr,removePlugin:dt}),M.debugMode=function(){jt=!1},M.safeMode=function(){jt=!0},M.versionString=ke,M.regex={concat:v,lookahead:g,either:x,optional:y,anyNumberOfTimes:w};for(const Te in _e)typeof _e[Te]=="object"&&e(_e[Te]);return Object.assign(M,_e),M},xn=an({});return xn.newInstance=()=>an({}),Wm=xn,xn.HighlightJS=xn,xn.default=xn,Wm}var b9=v9();const x9=W1(b9),Gx={},E9="hljs-";function S9(e){const t=x9.newInstance();return e&&i(e),{highlight:n,highlightAuto:r,listLanguages:o,register:i,registerAlias:l,registered:c};function n(u,h,f){const m=f||Gx,g=typeof m.prefix=="string"?m.prefix:E9;if(!t.getLanguage(u))throw new Error("Unknown language: `"+u+"` is not registered");t.configure({__emitter:_9,classPrefix:g});const w=t.highlight(h,{ignoreIllegals:!0,language:u});if(w.errorRaised)throw new Error("Could not highlight with `Highlight.js`",{cause:w.errorRaised});const y=w._emitter.root,v=y.data;return v.language=w.language,v.relevance=w.relevance,y}function r(u,h){const m=(h||Gx).subset||o();let g=-1,w=0,y;for(;++g<m.length;){const v=m[g];if(!t.getLanguage(v))continue;const _=n(v,u,h);_.data&&_.data.relevance!==void 0&&_.data.relevance>w&&(w=_.data.relevance,y=_)}return y||{type:"root",children:[],data:{language:void 0,relevance:w}}}function o(){return t.listLanguages()}function i(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 l(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 _9{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(l,c){return c?l+"_".repeat(c):n.options.classPrefix+l}),o=this.stack[this.stack.length-1],i={type:"element",tagName:"span",properties:{className:r},children:[]};o.children.push(i),this.stack.push(i)}closeNode(){this.stack.pop()}finalize(){}toHTML(){return""}}const RT=S9({bash:q8,css:n9,go:r9,ini:o9,javascript:c9,json:f9,markdown:h9,python:p9,rust:m9,typescript:k9,xml:w9,yaml:y9}),Vx={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 Jw(e,t){const n=e&&(Vx[e]??(RT.registered(e)?e:null));if(n)return n;const r=t.lastIndexOf("."),o=r<0?"":t.slice(r+1).toLowerCase();return(o?Vx[o]:null)??null}const N9=/^(?:diff --git a\/\S+ b\/(\S+)|\+\+\+ (?:b\/)?(\S+))$/gm;function T9(e){const t=new Set;for(const n of e.matchAll(N9)){const r=n[1]??n[2]??"";r&&r!=="/dev/null"&&t.add(r)}return t.size===1?[...t][0]:""}const j9={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 OT(e,t){const n=[[]],r=(i,l)=>{const c=i.split(`
207
- `);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===l?m.text+=h:f.push({text:h,scope:l})}},o=(i,l)=>{for(const c of i)c.type==="text"?r(c.value,l):c.type==="element"&&o(c.children,$9(c)??l)};try{o(RT.highlight(t,e).children,"")}catch{return e.split(`
208
- `).map(i=>i?[{text:i,scope:""}]:[])}return n}function $9(e){var r;const t=((r=e.properties)==null?void 0:r.className)??[];let n=null;for(const o of t){const i=j9[o.startsWith("hljs-")?o.slice(5):o];i&&(n=i)}return n}const Yx=/^\d+\t/;function ey(e,t){if(!t)return[];const n=e.split(`
209
- `),r=Yx.test(n[0]??""),o=r?n.map(l=>{var c;return((c=Yx.exec(l))==null?void 0:c[0])??""}):[],i=r?n.map((l,c)=>l.slice(o[c].length)).join(`
210
- `):e;return OT(i,t).map((l,c)=>{const u=l.map(f=>({text:f.text,changed:!1,scope:f.scope})),h=o[c];return h?[{text:h,changed:!1,scope:""},...u]:u})}function C9(e,t){var r;const n=new Array(e.length);if(t){let o=0;for(let i=0;i<=e.length;i++){const l=(r=e[i])==null?void 0:r.kind;i<e.length&&l!=="hunk"&&l!=="meta"||(A9(e,o,i,t,n),o=i+1)}}return e.map((o,i)=>I9(o.spans,n[i],o.text))}function A9(e,t,n,r,o){var i,l;for(const c of["del","add"]){const u=[];for(let m=t;m<n;m++){const g=(i=e[m])==null?void 0:i.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(`
211
- `),f=OT(h,r);for(const[m,g]of u.entries())(c==="add"||((l=e[g])==null?void 0:l.kind)==="del")&&(o[g]=f[m])}}function I9(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}],i=t!=null&&t.length?t:[{text:n,scope:""}];let l=0,c=0,u=0,h=0;for(;l<o.length&&c<i.length;){const f=o[l],m=i[c],g=Math.min(f.text.length-u,m.text.length-h);if(g>0){const w={text:f.text.slice(u,u+g),changed:f.changed,scope:m.scope},y=r[r.length-1];y&&y.changed===w.changed&&y.scope===w.scope?y.text+=w.text:r.push(w)}u+=g,h+=g,u>=f.text.length&&(l++,u=0),h>=m.text.length&&(c++,h=0)}return r}En.use({extensions:[g8,H8(()=>Vr==null?void 0:Vr.worktrees)],renderer:{code({text:e,lang:t}){const n=Jw((t??"").trim().toLowerCase().split(/\s+/)[0]??"","");return n?`<pre><code>${ey(e,n).map(o=>o.map(i=>i.scope?`<span class="sy-${i.scope}">${iu(i.text)}</span>`:iu(i.text)).join("")).join(`
212
- `)}</code></pre>
213
- `:!1},html(e){return Vr!=null&&Vr.keepHtml?!1:k8(e)},table:w8}});const MT=cF(window);let Vr=null;MT.addHook("afterSanitizeAttributes",e=>{const t=e.tagName==="A"?e.getAttribute("href")??"":"";if(t===aT){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=Vr!=null&&Vr.fileRoot?WN(Vr.fileRoot,t):null,r=n?null:KN(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.path}${r.line?`:${r.line}`:""}`),e.setAttribute("data-tip-placement","follow")),e.tagName==="CODE"&&!e.closest("pre, a")){const i=N6(e.textContent??"");i&&e.setAttribute("data-path",i)}const o=Vr==null?void 0:Vr.base;if(e.tagName==="IMG"&&o){const i=Pw(o.dir,e.getAttribute("src")??"");i&&e.setAttribute("src",o.urls.worktreeFile(o.worktreeId,i,o.version))}});function ka(e,t){Vr=t??null;const n=t!=null&&t.streaming?f8(e):e;try{return MT.sanitize(En.parse(n,{async:!1}))}finally{Vr=null}}function R9(e,t){const[n,r]=S.useState(e),o=S.useRef(null);return S.useEffect(()=>{if(!t){o.current=null;return}o.current=K8(o.current,e.length,performance.now());let i=0;const l=()=>{const c=o.current;if(!c)return;const u=xT(c,performance.now());r(Z8(e,u)),u<c.to&&(i=requestAnimationFrame(l))};return l(),()=>cancelAnimationFrame(i)},[e,t]),t?n:e}function Fh(e,t){var y,v,_,x;const[n,r]=S.useState(()=>ka(e,t)),o=S.useRef(0),i=(y=t==null?void 0:t.base)==null?void 0:y.worktreeId,l=(v=t==null?void 0:t.base)==null?void 0:v.dir,c=(_=t==null?void 0:t.base)==null?void 0:_.version,u=(x=t==null?void 0:t.base)==null?void 0:x.urls,h=t==null?void 0:t.fileRoot,f=t==null?void 0:t.worktrees,m=!!(t!=null&&t.keepHtml),g=!!(t!=null&&t.streaming),w=R9(e,g);return S.useEffect(()=>{const T=i!==void 0&&l!==void 0&&u!==void 0?{worktreeId:i,dir:l,version:c??null,urls:u}:void 0,N=T||h||f||m||g?{base:T,fileRoot:h,worktrees:f,keepHtml:m,streaming:g}:void 0,j=performance.now()-o.current;if(g||j>=Ea){o.current=performance.now(),r(ka(w,N));return}const $=setTimeout(()=>{o.current=performance.now(),r(ka(w,N))},Ea-j);return()=>clearTimeout($)},[w,i,l,c,u,h,f,m,g]),n}const O9=/^ {0,3}(`{3,}|~{3,})/,M9=/^#{1,6} \S/,P9=/^\s*(?:[-*+]|\d+[.)]) \S/,L9=/^> ?\S/,D9=/^\s*\|?\s*:?-{3,}:?\s*(?:\|\s*:?-{3,}:?\s*)+\|?\s*$/,z9=/\[[^\]\n]+\]\((?:https?:|\.{0,2}\/|#)[^)\s]*\)/,F9=/\*\*[^\s*][^*\n]*\*\*/;function B9(e){var i,l;const t=e.split(`
214
- `),n=new Set;let r=null,o=0;for(let c=0;c<t.length;c++){const u=t[c],h=(i=O9.exec(u))==null?void 0:i[1];if(r){h!=null&&h.startsWith(r)&&(r=null,n.add("fence"));continue}if(h){r=h;continue}M9.test(u)&&!((l=t[c+1])!=null&&l.trim())&&n.add("heading"),P9.test(u)&&++o===2&&n.add("list"),L9.test(u)&&n.add("quote"),D9.test(u)&&n.add("table"),z9.test(u)&&n.add("link"),F9.test(u)&&n.add("bold")}return n.size}function U9(e,t){if(t)return kh(t)==="markdown"?"rendered":"plain";const n=B9(e);return n>=2?"rendered":n===1?"source":"plain"}function Bh({n:e,name:t,source:n,lines:r,chars:o,preview:i,text:l,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`,i].filter(Boolean).join(" · "),w=d.jsxs(d.Fragment,{children:[d.jsx(_t,{name:"text",className:"icon-inline"}),d.jsxs("span",{className:"pick-target",children:[d.jsx("b",{children:t?t.slice(t.lastIndexOf("/")+1):n?YM(n):J1("paste",e)}),g&&d.jsxs("span",{className:"pick-file row-dim",children:[" · ",g]})]})]}),y=l!==void 0||c!==void 0;return d.jsx(zw,{className:He("paste-chip",h),label:w,tip:i||void 0,peek:y?d.jsx(DT,{text:l,href:c}):void 0,full:y?d.jsx(LT,{text:l,href:c,path:f||void 0}):void 0,menu:v=>c6({text:l,href:c},v),removeLabel:"Remove attachment",onRemove:u})}function PT(e,t){const[n,r]=S.useState(e??null),[o,i]=S.useState(!1);return S.useEffect(()=>{if(e!==void 0||!t)return;let l=!0;return fetch(t).then(c=>c.ok?c.text():Promise.reject(new Error(String(c.status)))).then(c=>{l&&r(c)}).catch(()=>{l&&i(!0)}),()=>{l=!1}},[e,t]),{text:e??n,failed:o}}function LT({text:e,href:t,path:n}){const{text:r,failed:o}=PT(e,t),i=S.useMemo(()=>r?U9(r,n):"plain",[r,n]),[l,c]=S.useState(null);if(o)return d.jsx("p",{className:"paste-full hint",children:"Toyon could not read that back."});if(!r||i==="plain")return d.jsx("pre",{className:"paste-full paste-text",children:r});const u=l??i==="rendered";return d.jsxs("div",{className:"paste-full paste-doc",children:[d.jsx("div",{className:"paste-doc-head",children:d.jsxs(De,{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(_t,{name:u?"text":"book",className:"icon-inline"})," ",u?"text":"preview"]})}),u?d.jsx(H9,{text:r}):d.jsx("pre",{className:"paste-doc-body paste-text",children:r})]})}function H9({text:e}){const t=S.useMemo(()=>ka(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 W9=2e4;function DT({text:e,href:t}){const{text:n}=PT(e,t);return n?d.jsx("pre",{className:"paste-peek paste-text",children:n.slice(0,W9)}):null}function Uh({name:e,bytes:t,href:n,kept:r,uploading:o,progress:i,onRemove:l,className:c=""}){const u=rt();return d.jsx(zw,{className:He("file-chip",c),label:d.jsxs(d.Fragment,{children:[d.jsx(_t,{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:[" ","· ",_k(t),i!==void 0?d.jsxs(d.Fragment,{children:[" ","· ",d.jsxs("span",{className:"pick-progress",children:[i,"%"]})]}):o&&" · uploading"]})]})]}),tip:e,peek:n?d.jsx(DT,{href:n}):void 0,full:n?d.jsx(LT,{href:n,path:e}):void 0,menu:h=>u6({href:n},h,r&&{...r,sock:u}),removeLabel:"Remove attachment",onRemove:l})}function zT(e){return e.replace(/^([\t ]*)\*\*(\S(?:[^\n]*\S)?)\*\*([\t ]*)$/gm,"$1$2$3")}const FT=120,K9=/^\*\*(\S(?:[^\n]*\S)?)\*\*$/;function BT(e){var n,r;const t=[];for(const o of e.split(/\n[\t ]*\n/)){const i=o.trim();if(!i)continue;const l=((r=(n=K9.exec(i))==null?void 0:n[1])==null?void 0:r.replace(/`/g,""))??"";if(!l||l.length>FT)return[];t.push(l)}return t}function UT(e){const t=BT(e);if(t.length)return t.at(-1);const n=zT(e).trim().replace(/`/g,"");return n&&!n.includes(`
215
- `)&&n.length<=FT?n:""}const Z9={read:"read",edit:"edit",delete:"delete",move:"move",search:"search",execute:"run",think:"think",fetch:"fetch",switch_mode:"mode",other:"tool"},Xx={read:"book",edit:"edit",delete:"trash",move:"move",search:"search",execute:"run",think:"bulb",fetch:"globe",switch_mode:"swap",other:"dot"},HT="Skill",Km=new Map([[vk,"chat"],["Monitor","clock"],["TaskOutput","terminal"],[HT,"layers"]]);function q9(e){if(e.name!==HT)return"";const t=lo(e,"skill").trim();if(!t)return"";const n=lo(e,"args").trim();return n?`/${t} ${n}`:`/${t}`}const Jg={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"},G9=/(^|\s)(-[A-Za-z]*[iI]|--in-place)/,Qx=String.raw`(?:"[^"]*"|'[^']*'|[^\s;&|]+)`,Jx=new RegExp(String.raw`^\s*(?:(?:cd|echo)\s+${Qx}\s*(?:&&|;)|mkdir(?:\s+${Qx})+\s*(?:&&|;)|(?:export\s+)?[A-Za-z_]\w*=(?:"[^"]*"|'[^']*'|[^\s;&|()\`]*)\s*(?:&&|;|(?=\s)))\s*`),V9=/^python[\d.]*$/,Y9=new RegExp(`open\\([^)]*,\\s*["'][wax]|(?<!std(?:out|err))\\.write\\(|\\.write_text\\(`);function WT(e){let t=e;for(let n=t.replace(Jx,"");n!==t;n=t.replace(Jx,""))t=n;return t}const X9=new RegExp("(?<![0-9&])>{1,2}\\s*(?!\\/dev\\/null|&)[^\\s&>]"),KT=/&&|;|\n|\|/;function Q9(e){return e.split(KT).some(t=>/^\s*(?:\S*\/)?sed\s/.test(t)&&G9.test(t))}function J9(e){return e.split(/&&|;|\n/).map(t=>WT(t).trim().split(/\s+/)[0]??"").filter(Boolean).every(t=>Jg[t.slice(t.lastIndexOf("/")+1)]==="trash")}function eB(e){const t=WT(e).trim(),n=t.split(/\s+/)[0]??"",r=n.slice(n.lastIndexOf("/")+1),o=r==="sed"?Q9(e)?void 0:"book":Jg[r];if(o==="book"||o==="search"){const i=t.split(KT)[0]??"";if(X9.test(i))return r==="cat"&&i.includes("<<")?"edit":void 0}if(!(o==="trash"&&!J9(t)))return o||(V9.test(r)?t.includes("<<")&&Y9.test(t)?"edit":void 0:Jg[r])}function lo(e,t){const n=e.input,r=n?n[t]:void 0;return typeof r=="string"?r:""}const tB=/^(?:\/(?:usr\/)?bin\/)?(?:ba|z|da)?sh\s+(?:-[a-zA-Z]+\s+)*(?:'([^']*)'|"((?:[^"\\]|\\.)*)")\s*$/;function ZT(e){const t=tB.exec(e.trim());return t?t[1]!==void 0?t[1]:(t[2]??"").replace(/\\(["\\$`])/g,"$1"):e}const nB="Guardian Review";function qT(e){return e.toolKind==="think"&&e.title===nB}function rB(e){const t=o=>{var l,c;return((c=(l=[...e.matchAll(new RegExp(`^${o}:[ \\t]*(.+)$`,"gm"))].at(-1))==null?void 0:l[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 cu(e,t=[]){const n=ZT(lo(e,"command")),r=e.name===Sf?"":lo(e,"query"),i=GT(e)||n||lo(e,"path")||lo(e,"pattern")||r||q9(e)||(e.title&&e.title!==e.name?e.title:""),l=Hh(lo(e,"description")||i,t),c=e.toolKind&&e.toolKind in Xx?e.toolKind:"other",u=Z9[c],h=e.name===vk,f=c!=="other"||Km.has(e.name),m=e.name===e.title||e.name===_i||e.name===q1,g=l&&(f||m||e.name===Sf)?"":e.name,w=g&&g.toLowerCase()!==u?g:l?"":u,y=(c==="execute"||c==="other")&&n?eB(n):void 0;return{label:h?"ask":u,name:w,icon:Km.get(e.name)??Km.get(e.title??"")??y??Xx[c],hint:l===w?"":l,command:n&&n!==l?n:""}}const oB=/^Async agent launched/m;function sB(e){if(!e.subagent)return!1;const t=e.input;return!!e.detached||(t==null?void 0:t.run_in_background)===!0||!!e.output&&oB.test(e.output)}const iB={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 aB(e){const t=e.toolKind;return e.subagent?lo(e,"prompt")?"":"writing the brief":!rh(e.input)||!V1({name:e.name,kind:t},e.input)?"":bk(t)?iB[t]:"writing the question"}function ek(e,t){const n=VT(t),r=n[0],o=lo(e,"description");return o&&r&&!r.code&&r.text===o?n.slice(1):n}function Dl(e){return GT(e)||lo(e,"path")}function lB(e){return lo(e,"description")}function GT(e){return lo(e,"file_path")||lo(e,"filepath")||lo(e,"filePath")||cB(e)}function cB(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 Hh(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 uB=/^(`{3,})([\w+#.-]*)\s*$/;function VT(e){var c;const t=[];let n=[],r="",o=!1,i=0;const l=()=>{const u=n.join(`
216
- `).replace(/^\n+|\n+$/g,"");u.trim()&&t.push({code:o,diff:dB(u,r),lang:o?r:"",text:u}),n=[]};for(const u of e.split(`
217
- `)){const h=uB.exec(u),f=((c=h==null?void 0:h[1])==null?void 0:c.length)??0;if(!h||o&&(f<i||h[2])){n.push(u);continue}l(),o=!o,i=o?f:0,r=o?(h[2]??"").toLowerCase():""}return l(),t}function dB(e,t){return t==="diff"||t==="patch"||/^diff --git /m.test(e)||/^@@ .*@@/m.test(e)?!0:/^--- /m.test(e)&&/^[+-]/m.test(e)}const fB=/^(diff --git |index [0-9a-f]+\.\.|new file mode |deleted file mode |similarity index |rename (from|to) |Binary files )/;function hB(e){const t=[];for(const n of e.split(`
218
- `)){const r=mB(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 pB(t),t}function pB(e){var t,n,r,o;for(let i=0;i<e.length;){if(((t=e[i])==null?void 0:t.kind)!=="del"&&((n=e[i])==null?void 0:n.kind)!=="add"){i++;continue}let l=i;for(;((r=e[l])==null?void 0:r.kind)==="del";)l++;let c=l;for(;((o=e[c])==null?void 0:o.kind)==="add";)c++;const u=e.slice(i,l),h=e.slice(l,c),f=u.length>0&&h.length>0?dA(u.map(m=>m.text).join(`
219
- `),h.map(m=>m.text).join(`
220
- `)):null;f&&(e1(u,_0(f.before)),e1(h,_0(f.after)));for(const m of[...u,...h])m.spans??(m.spans=[]);i=c}}function e1(e,t){if(t.length===e.length)for(const[n,r]of e.entries())r.spans=t[n]}function mB(e){return e.startsWith("@@")?"hunk":e.startsWith("+++")||e.startsWith("---")||fB.test(e)?"meta":e.startsWith("+")?"add":e.startsWith("-")?"del":""}function gB(e){const t=e.tools.at(-1);return t.done||t.parentToolId?!1:t.name===_i?!t.background:!!t.background}const YT=new Set(["read","edit","fetch"]);function ty(e,t){if(e.isError||!e.toolKind||!YT.has(e.toolKind)||bk(e.toolKind)&&rh(e.input))return"";const{hint:n}=cu(e,t);return n?`${e.parentToolId??""}
221
- ${e.toolKind}
222
- ${n}`:""}function t1(e,t,n){if(!t||!("tools"in t)||e.done||e.isError||!e.toolKind||!YT.has(e.toolKind))return!1;const r=t.tools[0];return r.toolKind===e.toolKind&&r.parentToolId===e.parentToolId&&ty(r,n)!==""}function kB(e,t){const n=e.length-1,r=e[n];if(!r||!("tools"in r)||r.next)return-1;const o=r.tools[0],i=r.tools.at(-1);return o.toolKind!=="edit"||o.parentToolId||!i.done||i.isError?-1:ty(o,t)?n:-1}function XT(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 wB(e){return!e.done||e.isError?!1:!!e.cut||!e.output&&V1({name:e.name,kind:e.toolKind},e.input)}function yB(e,t){return e.name===Sf&&e.done&&!e.isError&&!t}function vB(e,t){const n=XT(e),r=[],o=new Map;let i="";for(const[l,c]of e.entries()){if(c.kind!=="tool"){i="",r.push({at:l,item:c});continue}if(wB(c)||yB(c,l===e.length-1))continue;if(n.has(c.id)){i="";const m={at:l,spawn:c,run:[],end:l};o.set(c.id,{entry:m,key:""}),r.push(m);continue}const u=ty(c,t),h=c.parentToolId?o.get(c.parentToolId):void 0;if(h){const m=h.entry.run,g=m.at(-1);u&&u===h.key&&g?g.tools.push(c):!u&&t1(c,g,t)?g.next=c:m.push({at:l,tools:[c]}),h.key=u,h.entry.end=l;continue}const f=r.at(-1);if(u&&u===i&&f&&"tools"in f){f.tools.push(c);continue}if(!u&&t1(c,f,t)){f.next=c;continue}i=u,r.push({at:l,tools:[c]})}return r}function bB(e){return e.reduce((t,n)=>t+n.tools.length,0)}function xB(e){const t=new Set,n=new Set;let r=!0;for(let i=e.length-1;i>=0;i--){const l=e[i];if(l.kind!=="tool"||!l.parentToolId){r=!1;continue}n.add(l.parentToolId),(r||!l.done)&&t.add(l.parentToolId)}let o=!0;for(let i=e.length-1;i>=0;i--){const l=e[i];yu(l)&&(o=!1),!(l.kind!=="tool"||!l.subagent)&&(l.isError?t.delete(l.id):l.done?sB(l)?o&&!n.has(l.id)&&t.add(l.id):t.delete(l.id):t.add(l.id))}return t}function EB(e,t){const n=[],r=[];let o=-1;for(const i of e)"spawn"in i?t.has(i.spawn.id)?n.push(i):(o=Math.max(o,i.end),r.push({key:o,entry:i})):"tools"in i&&gB(i)?n.push(i):r.push({key:i.at,entry:i});return r.sort((i,l)=>i.key-l.key),{flow:r.map(i=>i.entry),floating:n}}function SB(e){const t=XT(e);return e.some(n=>n.kind==="tool"&&!n.done&&!n.parentToolId&&!n.background&&(!t.has(n.id)||rh(n.input)))}function QT(e,t=!1){const n=new Set;let r=!1,o=!1;return e.forEach((i,l)=>{if(!("tools"in i)||!t&&i.tools[0].parentToolId)return;const c=i.tools.at(-1);if(c.done||c.background||c.name===_i)return;const u=G1({name:c.name,kind:c.toolKind});(o||r&&u)&&n.add(l),r=!0,o||(o=u)}),n}function _B(e){return e.findIndex(t=>!t.tools.at(-1).done)}function ny(e,t){return e.length===t.length&&e.every((n,r)=>n===t[r])}function JT(e,t){return!e||!t?e===t:e.length===t.length&&e.every((n,r)=>{var o,i;return n.at===((o=t[r])==null?void 0:o.at)&&n.next===((i=t[r])==null?void 0:i.next)&&ny(n.tools,t[r].tools)})}function NB(e,t){if(e.length===0)return t;const n=new Map;for(const i of e)n.set(i.at,i);let r=e.length===t.length;const o=t.map((i,l)=>{const c=n.get(i.at),u=c!==void 0&&TB(c,i)?c:i;return u!==e[l]&&(r=!1),u});return r?e:o}function TB(e,t){return"spawn"in e?"spawn"in t&&e.spawn===t.spawn&&e.end===t.end&&JT(e.run,t.run):"tools"in e?"tools"in t&&e.next===t.next&&ny(e.tools,t.tools):"item"in t&&e.item===t.item}function jB(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"&&!qT(r))return t;continue}if(n.item.kind==="thinking"){if(!n.item.text.trim())continue;return UT(n.item.text)?-1:t}if($B(n.item))return-1}}return-1}function $B(e){return e.kind==="assistant"?!!e.text.trim():e.kind==="ask"?e.ask.kind==="question"||!!e.outcome:!0}function CB(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 Wh(e,t,n){if(!t)return[];const r=[];for(const o of e){const i=o.worktree;i.repoId!==t||i.id===n||i.kind!=="worktree"||r.push({id:i.id,title:i.title,branch:i.branch,dir:i.path.slice(i.path.lastIndexOf("/")+1),dot:Ms(o),state:yh(o),at:ya(i)})}return r}function ej(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 AB(e,t){return/[/-]/.test(e)?ej(e,t):null}const n1=e=>e.toLowerCase().replace(/[^a-z0-9]/g,"");function r1(e,t){const n=n1(e);if(!n)return!e.trim();const r=/\s$/.test(e);return[t.title,t.branch].some(o=>{const i=n1(o);return i.includes(n)&&(!r||!i.endsWith(n))})}function ts({id:e,title:t,inert:n}){const r=rt(),o=ct(),i=L(w=>w.visible),l=L(w=>rn(w,e)),c=L(w=>l?null:Object.values(w.archived).flat().find(y=>y.id===e)??null),u=S.useMemo(()=>l?Wh(i,l.worktree.repoId,null).find(w=>w.id===e)??null:null,[i,l,e]),h=(u==null?void 0:u.branch)??(c==null?void 0:c.branch);if(!h)return d.jsx("span",{children:t??e});const f=zh(u??{title:(c==null?void 0:c.title)??t??h,archived:!0,branch:h}),m=zt(f.text,void 0,{placement:"follow",dot:f.dot,detail:f.detail}),g=Ph({kind:"worktree",id:e,archived:!u},null,{sock:r,dispatch:o});return d.jsxs("span",{className:"chat-mention","data-worktree":e,"data-branch":h,"data-archived":u?void 0:"",...m,onClick:n?void 0:w=>{w.stopPropagation(),g==null||g()},children:["@",f.dot&&d.jsx("span",{className:"chat-mention-dot",children:d.jsx("span",{className:`dot ${f.dot}`})}),f.text]})}function IB(e){const t=e.body??"";return e.note?`${t.trimEnd()}
223
-
224
- ---
225
-
226
- You added: ${e.note}
227
- `:t}function RB({item:e,worktreeId:t,marked:n,children:r}){rt();const o=ct(),i=e.via==="plan",l=()=>{if(i&&e.path&&t){Ln({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:IB(e),binary:!1,tooLarge:!1,source:{kind:"text"},seq:Lo()}})};return d.jsx(Ir,{icon:"spawn",word:i?"plan":"piece",tone:"accent",at:e.ts,"data-state":dr({cursor:n}),below:[e.note?`you added: ${e.note}`:void 0,r],children:d.jsxs("span",{className:"daemon-text",children:["from ",d.jsx(ts,{id:e.origin.id,title:e.origin.title}),e.origin.project?` in ${e.origin.project}`:""," · ",d.jsx(De,{variant:"inline","data-tip":i?"Read the plan this worktree was given, beside the chat":"Read the message beside the chat",onClick:l,children:i?"the plan":"the message"})]})})}function Kh({src:e,n:t,name:n,width:r,height:o,bytes:i,kept:l,uploading:c,progress:u,onRemove:h,className:f=""}){const m=rt();return d.jsx(zw,{className:He("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:J1("image",t)}),d.jsxs("span",{className:"pick-file row-dim",children:[" ","· ",n," · ",r,"×",o," · ",_k(i),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=>ou(e,g,l&&{...l,sock:m}),removeLabel:"Remove image",onRemove:h})}function OB({img:e,worktreeId:t,src:n}){return d.jsx(Kh,{className:"in-chat",src:n,...e,kept:{worktreeId:t,file:e.file}})}const MB=/(^|\s)@\S/;function ry({text:e,worktreeId:t,root:n,inField:r}){const o=Gn(),i=rt(),l=L(y=>{var v;return t?(v=y.local[t])==null?void 0:v.files:void 0}),c=L(y=>y.visible),u=L(y=>{var v;return(v=rn(y,t))==null?void 0:v.worktree.repoId}),h=L(y=>u?y.archived[u]:void 0),f=S.useMemo(()=>vT(Wh(c,u,t),h),[c,h,u,t]),m=S.useMemo(()=>yT(l,f),[l,f]),g=S.useMemo(()=>Qw(e,m),[e,m]),w=l===void 0&&t&&MB.test(e)?t:null;return S.useEffect(()=>{w&&Th(w,o.getState(),{sock:i,dispatch:o.dispatch})},[w,o,i]),d.jsx(d.Fragment,{children:g.map((y,v)=>{if(y.kind==="text")return y.text;if(y.kind==="changes"){const N=zt("this worktree's uncommitted files",void 0,{placement:"follow"});return d.jsx("span",{className:"chat-mention","data-changes":"",...N,children:y.text},v)}if(y.kind==="worktree"){const N=zh(y),j=zt(N.text,void 0,{placement:"follow",dot:N.dot,detail:N.detail});return d.jsx("span",{className:"chat-mention","data-worktree":y.id,"data-branch":y.branch,"data-archived":y.archived?"":void 0,...j,children:r?y.text:d.jsxs(d.Fragment,{children:["@",N.dot&&d.jsx("span",{className:"chat-mention-dot",children:d.jsx("span",{className:`dot ${N.dot}`})}),N.text]})},v)}if(!n||!t)return y.text;const _=y.kind==="folder",x=`${n}/${y.path}${_?"/":""}`,T=zt(_?`${y.path}/`:y.path,void 0,{placement:"follow"});return d.jsx("a",{className:"chat-mention",href:x,tabIndex:r?-1:void 0,...T,children:y.text},v)})})}function oy(e,t,n,r){if(e.target.closest("[data-changes]")){n&&r.dispatch({a:"focus-changes",tab:"changes"});return}Dw(e,t,n,r)}function PB(e){return e.length<2||!e.every(t=>{var n;return t.length===1&&((n=t[0])==null?void 0:n.diff)})?null:DB(e.map(t=>t[0].text))}const LB=/^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@/;function DB(e,t=3){let n=[];for(const r of e){const o=zB(r);if(!o)return null;const i=FB(n,o);if(!i)return null;n=i}return n.some(r=>r.kind!=="same")?BB(n,t):null}function zB(e){const t=[];let n=null;for(const r of e.split(`
228
- `)){const o=LB.exec(r);if(o){n={oldStart:Number(o[1]),newStart:Number(o[2]),ops:[]},t.push(n);continue}if(!n)return null;const i=r[0];if(i===" "||i==="-"||i==="+")n.ops.push({mark:i,text:r.slice(1)});else if(r==="")n.ops.push({mark:" ",text:""});else return null}return t.length>0?t:null}function FB(e,t){const n=[];let r=0,o=0,i=0,l=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<=l)return null;for(;r<e.length;){const w=e[r];if((w.kind==="del"?h(r):w.c)>=f.oldStart)break;n.push(w.kind==="del"?w:{...w,c:w.c+i}),c(w),r++}let m=f.oldStart,g=f.newStart;for(const w of f.ops){if(u(),w.mark==="+"){n.push({kind:"add",c:g,text:w.text}),g++;continue}const y=e[r],v=y&&y.kind!=="del"&&y.c===m?y:void 0;if(v){if(v.text!==w.text)return null;r++,c(v),w.mark===" "?n.push({...v,c:g}):v.kind==="same"&&n.push({kind:"del",a:v.a,text:v.text})}else w.mark===" "?n.push({kind:"same",a:m+o,c:g,text:w.text}):n.push({kind:"del",a:m+o,text:w.text});w.mark===" "&&g++,m++}i=g-m,l=m-1}for(;r<e.length;r++){const f=e[r];n.push(f.kind==="del"?f:{...f,c:f.c+i})}return n}function BB(e,t){const n=[];for(const r of HB(e))for(const[o,i]of WB(r.rows,t)){const l=UB(r.rows.slice(o,i)),c=l.filter(m=>m.kind!=="add").length,u=l.filter(m=>m.kind!=="del").length,h=l.find(m=>m.kind!=="add"),f=l.find(m=>m.kind!=="del");n.push(`@@ -${h?h.a:r.oldAt[o]},${c} +${f?f.c:r.newAt[o]},${u} @@`,...l.map(m=>`${m.kind==="add"?"+":m.kind==="del"?"-":" "}${m.text}`))}return n.join(`
229
- `)}function UB(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(i=>i.kind==="del"),...o.filter(i=>i.kind==="add")),n=r}return t}function HB(e){const t=[];let n=null,r=1,o=1;for(const i of e){const l=i.kind==="add"?r:i.a,c=i.kind==="del"?o:i.c;(!n||l!==r||c!==o)&&(n={rows:[],oldAt:[],newAt:[]},t.push(n)),n.rows.push(i),n.oldAt.push(l),n.newAt.push(c),r=l+(i.kind==="add"?0:1),o=c+(i.kind==="del"?0:1)}return t}function WB(e,t){const n=[];let r=0;for(;r<e.length;){if(e[r].kind==="same"){r++;continue}let o=r,i=r;for(;i<e.length;){if(e[i].kind!=="same"){o=i,i++;continue}let l=0;for(;i+l<e.length&&e[i+l].kind==="same";)l++;if(l>t*2||i+l>=e.length)break;i+=l}n.push([Math.max(0,r-t),Math.min(e.length,o+t+1)]),r=o+t+1}return n}function tk({pieces:e}){return d.jsx(d.Fragment,{children:e.map((t,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 Zh({pick:e,worktreeId:t,tipText:n,onHover:r,onOpen:o,onRemove:i,className:l=""}){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=(T,N)=>`${T}${N?`:${N}`:""}`,g=T=>T.split("/").pop()??T,w=(T,N,j,$)=>o?d.jsx("button",{className:"pick-open","data-tip":$,onClick:()=>o(T,N??1),children:j}):j,y=wn("chat"),{host:v}=Ur(),_=S.useRef(null),x=i?()=>{r==null||r(!1),i()}:void 0;return d.jsxs("div",{ref:_,className:He("pick-chip row row-sm",l),"data-tip":n,onMouseEnter:()=>r==null?void 0:r(!0),onMouseLeave:()=>r==null?void 0:r(!1),...y.contextMenu(()=>p6(e,{remove:x,host:v})),children:[d.jsxs("span",{className:"pick-target",children:[d.jsx(_t,{name:"pick",className:"icon-inline"})," ",Vk(e),h&&d.jsxs("span",{className:"pick-file row-dim",children:[" ","· ",w(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:[" ","·"," ",w(f.path,f.line,m(f.path.split("/").pop()??f.path,f.line),`Open the component: ${m(f.path,f.line)}`)]})]}),x&&d.jsx(Ot,{icon:"close",label:"Remove attachment",tone:"quiet",onClick:x}),t&&(h==null?void 0:h.line)&&d.jsx(ZN,{chip:_,children:d.jsx(qB,{worktreeId:t,path:h.path,line:h.line})})]})}const KB=6,ZB=16;function qB({worktreeId:e,path:t,line:n}){const r=iw(),o=rt(),i=L(m=>{var g;return((g=No(m))==null?void 0:g.id)===e}),l=L(m=>{var g;return i?0:(g=fo(m,e).changedRanges[t])==null?void 0:g.offset}),[c,u]=S.useState(null);S.useEffect(()=>{let m=!0;return i||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,i]);const h=S.useMemo(()=>{if(c===null||l===void 0)return null;const m=c.split(`
230
- `),g=n-l,w=Math.max(1,g-KB),y=Math.min(m.length,g+ZB);if(w>y)return null;const v=m.slice(w-1,y);return{from:w,at:g,slice:v,painted:ey(v.join(`
231
- `),Jw("",t))}},[c,l,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 w=h.from+g,y=h.painted[g];return d.jsxs("span",{className:"pick-peek-line","data-state":w===h.at?"current":void 0,children:[d.jsx("span",{className:"pick-peek-n",children:String(w).padStart(f)}),y!=null&&y.length?d.jsx(tk,{pieces:y}):m||" "]},w)})})}function GB({item:e,worktreeId:t}){var w;rt();const n=ct();if(e.state==="held"||e.state==="proposed")return null;if(e.state==="going")return d.jsx(Ir,{icon:"spawn",word:"split",tone:"accent",at:e.ts,children:d.jsx("span",{className:"daemon-text live-text",children:"starting the worktrees"})});if(e.state==="declined")return d.jsx(Ir,{icon:"close",word:"not split",tone:"quiet",at:e.ts,below:e.reason,children:d.jsx("span",{className:"daemon-text",children:"nothing started"})});const r=y=>e.pieces.find(v=>v.id===y),o=y=>{var v;return((v=r(y))==null?void 0:v.title)??y},i=e.outcomes.filter(y=>y.fate==="worktree"&&y.worktreeId),l=e.outcomes.filter(y=>y.fate==="worktree"&&y.after),c=e.outcomes.filter(y=>y.fate==="send"&&y.worktreeId),u=e.outcomes.filter(y=>y.fate==="here").length,h=e.outcomes.filter(y=>y.error),f=[];for(const y of i)f.push(d.jsxs("span",{children:[d.jsx(ts,{id:y.worktreeId,title:y.title??o(y.pieceId)}),y.repoName?` in ${y.repoName}`:""]},y.pieceId));for(const y of l){const v=(w=r(y.pieceId))==null?void 0:w.after;f.push(d.jsxs("span",{children:[o(y.pieceId)," queued after"," ",v&&"id"in v?d.jsx(ts,{id:v.id,title:v.branch}):y.after]},y.pieceId))}for(const y of c)f.push(d.jsxs("span",{children:[o(y.pieceId)," sent to ",d.jsx(ts,{id:y.worktreeId,title:y.title}),y.repoName?` in ${y.repoName}`:""]},y.pieceId));u&&f.push(d.jsx("span",{children:`${u} here`},"here"));const m=e.plan,g=m&&t?d.jsx(De,{variant:"inline",onClick:()=>Ln({dispatch:n},{worktreeId:t,path:m,view:"preview"}),children:e.companion?"the plan":"the list"}):null;return d.jsx(Ir,{icon:"spawn",word:"split",tone:"accent",at:e.ts,below:h.length?h.map(y=>`${o(y.pieceId)}: ${y.error}`).join("; "):void 0,children:d.jsxs("span",{className:"daemon-text",children:[f.length===0?"nothing started":f.map((y,v)=>d.jsxs("span",{children:[v>0&&", ",y]},v)),g&&d.jsxs(d.Fragment,{children:[" · ",g]})]})})}function VB({item:e}){return e.worktreeId?d.jsx(Ir,{icon:"spawn",word:"split",tone:"accent",at:e.ts,children:d.jsxs("span",{className:"daemon-text",children:[d.jsx(ts,{id:e.worktreeId,title:e.title??"the worktree"})," started, its branch having landed"]})}):d.jsx(Ir,{icon:"close",word:"dropped",tone:"quiet",at:e.ts,below:e.reason,children:d.jsx("span",{className:"daemon-text",children:e.title??"a queued piece"})})}function YB({item:e}){return d.jsxs(Ir,{icon:"check",word:e.again?"landed again":"landed",tone:"aqua",at:e.ts,children:[d.jsx("span",{className:"daemon-text",children:e.same?d.jsx(ts,{id:e.worktreeId,title:e.title}):`${e.title} in ${e.repoName}`}),e.url&&d.jsx(De,{variant:"inline",tone:"strong",onClick:()=>window.open(e.url,"_blank"),children:"view PR"})]})}function XB(e){return e.startsWith("!")?e.slice(1).trim():null}function sy(e){if(e.kind!=="tool"||e.name!==_i&&e.name!==q1)return null;const t=e.input;return typeof(t==null?void 0:t.command)=="string"?t.command:null}function tj(e){var t;return e.kind!=="tool"||e.name!==_i||(t=e.input)!=null&&t.landing?null:sy(e)}function QB(e){return e.length>0&&e.every(t=>t.kind==="tool"&&tj(t)!==null&&t.done&&!t.isError)}function JB(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(yu(o))break;if(o.kind!=="tool"||!o.done||n.has(o.id))continue;const i=sy(o);if(i===null)continue;const l=VT(o.output??"").map(u=>u.text).join(`
232
- `),c=zM(l);t.unshift(`$ ${i}${c?`
233
- ${c}`:""}`)}if(t.length!==0)return`Shell commands the user ran since their last message, and what each printed:
234
- ${t.join(`
235
- `)}`}const o1={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 nj(e,t,n,r){const o=e[0];if(!o||!n)return[];const i=Hh(Dl(o),t);return i?i.startsWith("/")?[{label:"open",tip:o1.file,open:()=>Bg(r,n.id,{href:i,path:i})}]:[...ji(i)==="preview"?["preview"]:[],...o.toolKind==="edit"?["diff"]:[],"file"].map(c=>({label:`open ${c}`,tip:o1[c],open:()=>Ln(r,{worktreeId:n.id,path:i,view:c})})):[]}const eU=(...e)=>nj(...e)[0]??null;function tU(e,t,n,r,o){const{sock:i}=r,l=e[0];if(!l)return[];const c=[],u=Hh(Dl(l),t),h=nj(e,t,n,r).map(_=>({id:_.label.replace(" ","-"),label:_.label,onClick:_.open}));u&&!u.startsWith("/")&&n?c.push(...h,...os(()=>i==null?void 0:i.send({t:"reveal",worktreeId:n.id,path:u}),rs(i))):u.startsWith("/")&&c.push(...h,...os(()=>i==null?void 0:i.send({t:"reveal-path",path:u}),rs(i)));const f=[],m=Dl(l);u&&m&&f.push({id:"copy-path",label:"copy path",onClick:()=>Yt(m)});const g=cu(l,t).command,w=lB(l);w&&w!==g&&f.push({id:"copy-description",label:"copy description",onClick:()=>Yt(w)}),g&&f.push({id:"copy-command",label:"copy command",onClick:()=>Yt(g)});const y=e.map(_=>_.output??"").filter(Boolean).join(`
236
- `);y&&f.push({id:"copy-output",label:"copy output",onClick:()=>Yt(y)});const v=o.leaf?[]:[{id:"fold",label:o.open?"collapse":"expand",onClick:o.toggle}];return Dn([c,f,v])}const rj=e=>e.replace(/\n$/,""),nU=1500,s1=4;function oj(e){return e.closest(".md pre, .card-code pre")}function nk(e){const t=oj(e);return t?rj(t.textContent??""):null}function rU(e,t){const n=e.getBoundingClientRect(),r=t.getBoundingClientRect();return{pre:t,top:r.top-n.top+e.scrollTop+s1,right:n.left+e.clientLeft+e.clientWidth-r.right+s1}}function iy(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 w=oj(g.target);n(w&&h.contains(w)?rU(h,w):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),nU);return()=>clearTimeout(h)},[r]),!(t!=null&&t.pre.isConnected))return null;const{pre:i,top:l,right:c}=t,u=r===i;return d.jsx(Ot,{className:"code-copy",style:{top:l,right:c},icon:u?"check":"copy",label:u?"Copied":"Copy code",onClick:()=>{Yt(rj(i.textContent??"")),o(i)}})}function oU(e){for(const t of e.split(`
237
- `)){const n=/^#{1,6}\s+(.+?)\s*#*\s*$/.exec(t);if(n)return n[1];if(t.trim()&&!t.startsWith("<!--"))return null}return null}function sU(e){return e.slice(e.lastIndexOf("/")+1).replace(/\.md$/,"")}function ay(e,t){var c;const n=iw(),r=(c=Rt(e,"git"))==null?void 0:c.version,[o,i]=S.useState(null);return ft([n,e,t,r],()=>{if(!n||!e||!t)return;let u=!0;return n.look(e,t).then(h=>{u&&i({plan:t,title:h?oU(h):null})}),()=>{u=!1}}),(o&&o.plan===t?o.title:null)??(t?sU(t):"")}function sj(e){const t=L(r=>{var o;return(o=rn(r,e))==null?void 0:o.worktree.repoId}),n=L(r=>t?z8(r,t):"");return S.useMemo(()=>n?F8(n):void 0,[n])}function Zm({text:e,menu:t,marked:n,worktreeId:r,fileRoot:o,streaming:i}){const l=sj(r),c=Fh(e,{fileRoot:o,streaming:i,worktrees:l}),u=rt(),h=ct(),f=wn("chat"),m=S.useRef(null);JS(m,c);const g=L(v=>{var _;return r?(_=v.local[r])==null?void 0:_.refusedLink:void 0});ft([c,g],()=>{var _;const v=m.current;if(v)for(const x of v.querySelectorAll("a.file-link, code[data-path]")){const T=x.getAttribute("href")??x.dataset.path,N=g!==void 0&&T===g.href;x.classList.toggle("file-link-refused",N),N?((_=x.dataset).tipWas??(_.tipWas=x.dataset.tip??""),x.dataset.tip=g.message,x.dataset.tipPlacement="bottom",x.dispatchEvent(new MouseEvent("mouseover",{bubbles:!0}))):x.dataset.tipWas!==void 0&&(x.dataset.tipWas?(x.dataset.tip=x.dataset.tipWas,x.dataset.tipPlacement="follow"):(delete x.dataset.tip,delete x.dataset.tipPlacement),delete x.dataset.tipWas)}});const w=S.useRef(null),y=iy(w);return d.jsxs("div",{ref:w,className:"msg-assistant md row-edge","data-state":dr({cursor:n}),...f.contextMenu((v,_)=>t(Lw(_,o),nk(_))),onClick:v=>Dw(v,o,r,{sock:u,dispatch:h}),children:[d.jsx("div",{ref:m}),y]})}const qm=40;function ij(e,t){return e.map(n=>{const r=Jw(n.lang,t||(n.diff?T9(n.text):""));if(n.diff){const o=hB(n.text);return{...n,lines:o,painted:C9(o,r)}}return{...n,lines:[],painted:n.code?ey(n.text,r):[]}})}function aj({blocks:e,path:t,worktreeId:n}){rt();const r=ct();return d.jsx("div",{className:"tool-out",children:e.map((o,i)=>o.diff?d.jsxs("pre",{className:"tool-block diff",children:[o.lines.slice(0,qm).map((l,c)=>{var u;return l.kind==="hunk"?d.jsx("span",{className:"dl hunk",title:l.text},c):d.jsx("span",{className:`dl ${l.kind}`,children:(u=o.painted[c])!=null&&u.length?d.jsx(tk,{pieces:o.painted[c]}):l.text||" "},c)}),o.lines.length>qm&&d.jsxs("button",{type:"button",className:"dl more",disabled:!t||!n,"data-tip":t&&n?"Open this file's diff":void 0,onClick:()=>n&&Ln({dispatch:r},{worktreeId:n,path:t,view:"diff"}),children:[o.lines.length-qm," more lines"]})]},i):o.code?d.jsx("pre",{className:"tool-block",children:o.painted.length?o.painted.map((l,c)=>d.jsxs(S.Fragment,{children:[c>0?`
238
- `:null,d.jsx(tk,{pieces:l})]},c)):o.text},i):d.jsx("p",{className:"tool-note",children:o.text},i))})}function iU({image:e,worktreeId:t}){const n=Ur().attachment(t,e.file),r={worktreeId:t,file:e.file,sock:rt()},[o,i]=S.useState(!1),l=wn("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:()=>i(!0),...l.contextMenu(()=>ou(n,{open:()=>i(!0)},r)),children:d.jsx("img",{src:n,alt:e.file})}),o&&d.jsx(Mw,{owner:"chat",onClose:()=>i(!1),menu:()=>ou(n,{},r),children:d.jsx("img",{src:n,alt:e.file})})]})}const aU=S.memo(function({item:t,roots:n,worktreeId:r}){const o=S.useMemo(()=>ij(ek(t,t.output??""),Dl(t)),[t]),i=cu(t,n).command,l=r?t.images??[]:[];return!i&&o.length===0&&l.length===0?null:d.jsxs("div",{className:"tool-part",children:[i&&d.jsx("pre",{className:"tool-block cmd",children:i}),o.length>0&&d.jsx(aj,{blocks:o,path:lj(t,n),worktreeId:r}),l.length>0&&r&&d.jsx("div",{className:"tool-out",children:l.map(c=>d.jsx(iU,{image:c,worktreeId:r},c.file))})]})});function lj(e,t){const n=Hh(Dl(e),t??[]);return n.startsWith("/")?"":n}const lU=S.memo(function({text:t,item:n,roots:r,worktreeId:o}){const i=Dl(n),l=S.useMemo(()=>ij([{code:!0,diff:!0,lang:"diff",text:t}],i),[t,i]);return d.jsx("div",{className:"tool-part",children:d.jsx(aj,{blocks:l,path:lj(n,r),worktreeId:o})})});function rk({className:e,state:t,auto:n,leaf:r,growing:o,label:i,summary:l,menu:c,children:u}){const[h,f]=S.useState(null),m=S.useRef(null),g=S.useRef(null),w=QS(g),y=tD(".chat-log"),v=!r&&(h??n),[_,x]=S.useState(v);S.useEffect(()=>{v&&x(!0)},[v]);const T=()=>{r||(v||y(m.current),f(!v))},N=wn("chat");return d.jsxs("details",{ref:m,className:He(e,r&&"leaf"),"data-state":t,open:v,onToggle:j=>{if(!j.currentTarget.open||o)return;const $=g.current;$&&($.scrollTop=0,w.read())},...N.contextMenu((j,$)=>c({open:v,leaf:!!r,toggle:T},$)),tabIndex:-1,onPointerDown:()=>{var j;return(j=m.current)==null?void 0:j.focus({preventScroll:!0})},onKeyDown:j=>{if((j.key==="ArrowLeft"||j.key==="ArrowRight")&&!r){if(j.shiftKey||j.altKey||j.metaKey||j.ctrlKey)return;Ih([{depth:0,open:v}],0,j.key)&&T();return}j.key!=="Escape"||!v||(j.stopPropagation(),f(!1))},children:[d.jsx("summary",{"aria-label":i,tabIndex:r?-1:void 0,onClick:j=>{j.preventDefault(),T()},children:l}),d.jsx("div",{className:"tool-body",ref:g,children:v||_?u:null})]})}function cU({markdown:e,streaming:t,worktreeId:n,fileRoot:r}){const o=sj(n),i=Fh(e,r||t||o?{fileRoot:r,streaming:t,worktrees:o}:void 0),l=rt(),c=ct(),u=S.useRef(null);JS(u,i);const h=S.useRef(null),f=iy(h);return d.jsx("div",{className:"tool-part",children:d.jsxs("div",{ref:h,className:"tool-out thought-out md",onClick:m=>Dw(m,r,n,{sock:l,dispatch:c}),children:[d.jsx("div",{ref:u}),f]})})}const uU=S.memo(function({item:t,open:n,streaming:r,worktreeId:o,fileRoot:i}){const l=BT(t.text),c=l.slice(0,-1),u=r?"Thinking":"Thought",h=d.jsx(cU,{markdown:l.length?c.join(`
239
-
240
- `):zT(t.text),streaming:r,worktreeId:o,fileRoot:i}),f=l.at(-1)??(r?"":UT(t.text));if(f){const m=c.length===0;return d.jsx(rk,{className:"tool-row",auto:!1,leaf:m,growing:r,label:f,menu:(g,w)=>Dn([Ug(nk(w)),[{id:"copy",label:"copy thought",onClick:()=>Yt(t.text)}],...m?[]:[[{id:"fold",label:g.open?"collapse":"expand",onClick:g.toggle}]]]),summary:d.jsxs(d.Fragment,{children:[d.jsx(_t,{name:"bulb",className:"tool-icon"}),d.jsx("span",{className:He("tool-hint thought-line",r&&"live-text"),children:f})]}),children:m?null:h})}return d.jsx(rk,{className:"tool-row",auto:!!n,growing:r,label:u,menu:(m,g)=>Dn([Ug(nk(g)),[{id:"copy",label:"copy thought",onClick:()=>Yt(t.text)}],[{id:"fold",label:m.open?"collapse":"expand",onClick:m.toggle}]]),summary:d.jsxs(d.Fragment,{children:[d.jsx(_t,{name:"bulb",className:"tool-icon"}),d.jsx("span",{className:He("tool-name",r&&"live-text"),children:u})]}),children:h})}),aa=6,dU={land:"the land",commit:"the commit","sync-main":"the sync","pull-main":"the pull"},lf=S.memo(function e({tools:t,run:n,next:r,live:o,working:i,held:l,since:c,queued:u,roots:h,worktreeId:f,marked:m}){const g=t[0],w=S.useMemo(()=>PB(t.map(pe=>ek(pe,pe.output??""))),[t]),y=t.at(-1)??g,v=!y.done,_=v&&!!y.background,T=(v||!!r||!!l)&&!u||!!i,N=v&&!!u,j=Ei(v||i?c:void 0),$=n?_B(n):-1,O=S.useMemo(()=>n?QT(n,!0):void 0,[n]),I=!!o,P=cu(g,h),R=v?aB(g):"",{label:U,icon:F}=P,B=qT(g),X=R?"":B?"Guardian":P.name,ae=R&&g.subagent?P.hint:"",Y=ae||R||(B?rB(g.output??""):P.hint),ne=!(n&&n.length>0)&&!w&&t.every(pe=>{var Q;return!cu(pe,h).command&&ek(pe,pe.output??"").length===0&&!((Q=pe.images)!=null&&Q.length)}),C=n?bB(n):0,H=QB(t),V=[U,Y].filter(Boolean).join(" ")+(_?", in the background":"")+(N?", queued":"")+(H?", done":""),J=R?"":n?`${C} ${C===1?"call":"calls"}`:t.length>1?`×${t.length}`:"",Z=Gn(),ie=rt(),be=L(pe=>{var Q;return f?(Q=pe.shipping[f])==null?void 0:Q.op:void 0}),ge=v&&g.name===_i&&f?{worktreeId:f,toolId:y.id}:null,we=v?null:(()=>{const pe=rn(Z.getState(),f);return eU(t,h??[],pe?{id:pe.worktree.id}:null,{sock:ie,dispatch:Z.dispatch})})();return d.jsxs(rk,{className:He("tool-row",t.some(pe=>pe.isError)&&"error",g.parentToolId&&"nested",n&&"spawn",N&&"queued"),state:dr({cursor:m}),auto:I,leaf:ne,growing:T,label:n&&J?`${V}, ${J}`:t.length>1?`${V}, ${t.length} calls`:V,menu:pe=>{const Q=rn(Z.getState(),f),W=Q?{id:Q.worktree.id}:null;return tU(t,h??[],W,{sock:ie,dispatch:Z.dispatch},pe)},summary:d.jsxs(d.Fragment,{children:[d.jsx(_t,{name:n?"spawn":F,className:"tool-icon"}),X&&d.jsx("span",{className:He("tool-name",T&&!Y&&"live-text"),children:X}),R&&!ae?d.jsx("span",{className:"tool-writing","data-tip":Y,children:d.jsx(Ml,{})}):Y&&d.jsx("span",{className:He("tool-hint",T&&"live-text"),children:Y}),_&&d.jsx("span",{className:"tool-status",children:"in the background"}),N&&d.jsx("span",{className:"tool-status",children:"queued"}),H&&d.jsx(_t,{name:"check",className:"tool-done"}),j>=aa&&d.jsx("span",{className:He("tool-age",$>=0&&"tool-age-folded"),children:da(j)}),J&&d.jsx("span",{className:"tool-count",children:J}),ae&&d.jsx("span",{className:"tool-writing","data-tip":R,children:d.jsx(Ml,{})}),ge&&d.jsx(Ot,{icon:"stop",className:"tool-stop",label:be?`Stop ${dU[be]}: this step is killed, and what it printed so far stays`:_?"Kill what the command left running; what it printed so far stays":"Kill the command and everything it started; what it printed so far stays",onClick:pe=>{pe.preventDefault(),pe.stopPropagation(),ie==null||ie.send({t:"exec-stop",...ge})}}),we&&d.jsx(Ot,{icon:"eye",className:"tool-open",label:we.tip,onClick:pe=>{pe.preventDefault(),pe.stopPropagation(),we.open()}})]}),children:[n&&n.length>0&&d.jsx("div",{className:"spawn-run",children:n.map((pe,Q)=>d.jsx(e,{tools:pe.tools,next:pe.next,since:Q===$?c:void 0,queued:O==null?void 0:O.has(Q),roots:h,worktreeId:f},pe.at))}),w?d.jsx(lU,{text:w,item:g,roots:h,worktreeId:f}):t.map(pe=>d.jsx(aU,{item:pe,roots:h,worktreeId:f},pe.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&&ny(e.tools,t.tools)&&JT(e.run,t.run));function fU({item:e}){const t=rt(),n=ct(),r=L(v=>v.activeId),o=L(v=>v.layout.term),i=L(v=>{var _;return((_=v.rows.find(x=>x.id===v.activeId))==null?void 0:_.login)??!1}),l=L(v=>v.managed.problem),[c,u]=S.useState(""),[h,f]=S.useState(null),m=S.useRef(!1);if(ft([i],()=>{i&&m.current&&r&&n({a:"term-stream",id:r,stream:Rs,tall:!0})}),ft([e.done],()=>{e.done&&m.current&&o&&n({a:"toggle-terminal"}),m.current=!1}),!r)return null;const g=e.provider==="aws",w=(v,_)=>{t==null||t.send({t:"agent-auth",worktreeId:r,methodId:v,..._?{apiKey:_}:{}})},y=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,_)=>v.needsKey?d.jsx(De,{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(De,{variant:"outline",tone:g&&_===0?"primary":void 0,"data-tip":v.kind==="terminal"&&!v.description?"opens in the terminal pane":v.description,onClick:()=>{w(v.id),v.kind==="terminal"&&(m.current=!0)},children:v.name},v.id)),d.jsx(De,{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&&i&&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:l?"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&&y&&d.jsxs("form",{className:"auth-key",onSubmit:v=>{v.preventDefault(),c.trim()&&(w(y.id,c.trim()),u(""),f(null))},children:[d.jsx(zo,{type:"password",autoFocus:!0,placeholder:`${y.name} for ${e.agentName}`,value:c,onChange:v=>u(v.target.value)}),d.jsx(De,{type:"submit",children:"use key"})]})]})}const hU=S.memo(function({item:t,worktreeId:n,onPickHover:r,marked:o,streaming:i}){const l=Gn(),c=rt(),u=Ur(),h=wn("chat"),f={sock:c,dispatch:l.dispatch},m=()=>{var w;return(w=rn(l.getState(),n))==null?void 0:w.worktree.path},g=w=>w&&n&&d.jsx(Mh,{children:d.jsx("div",{className:"msg-attachments",children:w.map(y=>y.kind==="image"?d.jsx(OB,{img:y,worktreeId:n,src:u.attachment(n,y.file)},`${y.kind}-${y.n}`):y.kind==="file"?d.jsx(Uh,{className:"in-chat",name:y.name,bytes:y.bytes,href:y.text?u.attachment(n,y.file):void 0,kept:{worktreeId:n,file:y.file}},`${y.kind}-${y.n}`):y.kind==="paste"?d.jsx(Bh,{className:"in-chat",n:y.n,name:y.name,source:y.source,lines:y.lines,chars:y.chars,preview:y.preview,href:u.attachment(n,y.file)},`${y.kind}-${y.n}`):d.jsx(Zh,{pick:y,className:"in-chat",tipText:"Hover to highlight on the page",onHover:v=>r==null?void 0:r(y,v),worktreeId:n,onOpen:(v,_)=>ga(l,c,n,v,_)},`${y.kind}-${y.n}`))})});switch(t.kind){case"user":{const w=g(t.attachments),y=m();return d.jsxs("div",{className:"msg-user row-edge","data-state":dr({cursor:o}),...h.contextMenu((v,_)=>ra(t,n??null,f,{link:Lw(_,y)})),onClick:v=>oy(v,y,n,f),children:[w,d.jsx(ry,{text:t.text,worktreeId:n,root:y})]})}case"assistant":return d.jsx(Zm,{text:t.text,menu:(w,y)=>ra(t,n??null,f,{link:w,code:y}),marked:o,worktreeId:n,fileRoot:m(),streaming:i});case"error":return d.jsx("div",{className:"msg-assistant msg-error",...h.contextMenu(()=>ra(t,n??null,f)),children:t.text});case"auth":return d.jsx(fU,{item:t});case"ask":{const w=AL(t);if(w){const x=Hk(w.questions,w.answers).join(`
241
- `),T={kind:"assistant",text:x};return d.jsxs(d.Fragment,{children:[d.jsx(Zm,{text:w.message,menu:(N,j)=>ra({kind:"assistant",text:w.message},n??null,f,{link:N,code:j}),worktreeId:n,fileRoot:m()}),d.jsx("div",{className:"msg-user row-edge","data-state":dr({cursor:o}),...h.contextMenu(()=>ra(T,n??null,f)),children:x})]})}const y=RL(t);if(!y)return d.jsx(_6,{item:t});const v=y.file,_={kind:"assistant",text:y.choice};return d.jsxs(d.Fragment,{children:[v?d.jsx(pU,{file:v,worktreeId:n}):y.text&&d.jsx(Zm,{text:y.text,menu:(x,T)=>ra({kind:"assistant",text:y.text},n??null,f,{link:x,code:T}),worktreeId:n,fileRoot:m()}),d.jsx("div",{className:"msg-user",...h.contextMenu(()=>ra(_,n??null,f)),children:y.choice})]})}case"blocked":return d.jsxs(Ir,{icon:"lock",word:"blocked",tone:"red",below:t.reason,...h.contextMenu(()=>Ow(t.path,void 0,rs(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(Ir,{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"asked":return d.jsx(Ir,{icon:"send",word:"asked",tone:"quiet",children:d.jsx("span",{className:"daemon-text",children:t.why})});case"stopped":return d.jsx(Ir,{icon:"stop",word:"stopped",tone:"quiet"});case"landed":return d.jsx(gU,{item:t});case"handed":return d.jsx(RB,{item:t,worktreeId:n,marked:o,children:g(t.attachments)});case"piece-landed":return d.jsx(YB,{item:t});case"pieces":return d.jsx(GB,{item:t,worktreeId:n});case"piece-later":return d.jsx(VB,{item:t});case"restored":return d.jsx(mU,{item:t});case"adopted":return d.jsx(Ir,{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 pU({file:e,worktreeId:t}){const n=rt(),r=ct(),o=wn("chat"),i=ay(t??void 0,e);return d.jsx(Ir,{icon:"file",word:"plan",tone:"quiet",...o.contextMenu(()=>Ow(e,t?()=>n==null?void 0:n.send({t:"reveal",worktreeId:t,path:e}):void 0,rs(n))),children:d.jsx("span",{className:"daemon-text",children:d.jsx(De,{variant:"inline",tone:"strong","data-tip":e,onClick:()=>t&&Ln({dispatch:r},{worktreeId:t,path:e,view:"preview"}),children:i})})})}function mU({item:e}){return d.jsx(Ir,{icon:"reload",word:"restored",tone:"quiet",at:e.ts,children:d.jsxs("span",{className:"daemon-text",children:["after ",Yk(e.ts-e.archivedAt)," in the archive, back on ",e.branch,e.uncommitted?" with its uncommitted changes":""]})})}function gU({item:e}){const t=AN(e.ts),n=e.mark&&_w(e.mark),r=`${e.text}, ${t}`;return d.jsx(Ir,{icon:"check",word:"landed",tone:"aqua",at:e.ts,below:n?r:void 0,children:d.jsx("span",{className:"daemon-text",children:n??r})})}const qh=".jump-seat, .draft-intro, .chat-input";function kU(e){const t=e instanceof Element?e:e.parentElement;return!!(t!=null&&t.closest(qh))}function i1(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(${qh}) *)`)){const o=n.get(r.dataset.worktree??"");if(!o)continue;const i=zh({...o,dir:r.dataset.dir}),l=r.querySelector(".dot"),c=`dot ${o.dot}`;l&&l.className!==c&&(l.className=c);const u=i.detail.join(`
242
- `);r.dataset.tipDetail!==u&&(r.dataset.tipDetail=u),r.dataset.tipDot!==o.dot&&(r.dataset.tipDot=o.dot)}}function wU(e,t){const n=L(o=>o.visible),r=L(o=>{var i;return(i=rn(o,t))==null?void 0:i.worktree.repoId});S.useEffect(()=>{const o=e.current;if(!o||!r)return;const i=Wh(n,r,null);i1(o,i);let l=0;const c=new MutationObserver(u=>{u.every(h=>kU(h.target))||(cancelAnimationFrame(l),l=requestAnimationFrame(()=>i1(o,i)))});return c.observe(o,{childList:!0,subtree:!0}),()=>{c.disconnect(),cancelAnimationFrame(l)}},[e,n,r])}const cj=e=>e===""||e==="!";function a1(e,t){const n=new Set,r=[];for(let o=e.length-1;o>=0;o--){const i=e[o],l=tj(i),c=l!==null?`!${l}`:t?null:i.kind==="user"?i.text:i.kind==="ask"?IL(i):null;c===null||!c.trim()||n.has(c)||(n.add(c),r.push({text:c,at:o}))}return r}function yU(e,t,n,r){if(!t){if(r!=="up"&&r!=="first"||!cj(n))return null;const c=a1(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=a1(e,t.from==="!"),i=r==="first"?o.length-1:o.findIndex(c=>c.at===t.at)+(r==="up"?1:-1);if(i<0)return{walk:null,text:t.from};const l=o[i];return l?{walk:{at:l.at,from:t.from},text:l.text}:{walk:t,text:n}}function vU(e,t,n,r){const o=new Map;return{rows:t.map((l,c)=>{const u=n(l,c),h=e.get(l.at),f=h&&h.row.kind===u.kind&&bU(h.row.props,u.props)?h.el:r(l,u);return o.set(l.at,{row:u,el:f}),f}),cache:o}}function bU(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 i=e[o],l=t[o];if(!Object.is(i,l)&&(!Array.isArray(i)||!Array.isArray(l)||i.length!==l.length||!i.every((c,u)=>Object.is(c,l[u]))))return!1}return!0}const xU=4;function EU(e,t,n){const r=Math.max(t,0);return n?e>=r+1:e>=r+xU}function SU(e,t,n){S.useEffect(()=>{const r=e.current,o=r==null?void 0:r.parentElement,i=r==null?void 0:r.querySelector(":scope > .chat-input");if(!r||!o||!i){n(!1);return}let l=0,c=!1,u=0,h=0;const f=()=>o.style.setProperty("--cover",`${c?h:u}px`),m=()=>{if(u=i.offsetHeight,h=u,t&&i.classList.contains("foldable")){const _=r.scrollTop;i.classList.add("fold-measure"),h=i.offsetHeight,i.classList.remove("fold-measure"),r.scrollTop=_}l=u-h,o.style.setProperty("--box-h",`${u}px`),o.style.setProperty("--fold",`${l}px`),o.style.setProperty("--keep",`${h}px`),f()},g=()=>{if(!t)return;const _=EU(r.scrollHeight-r.scrollTop-r.clientHeight,l,c);_!==c&&(c=_,f(),n(c))};m(),g(),r.addEventListener("scroll",g,{passive:!0});const w=new ResizeObserver(()=>{m(),g()});w.observe(i);let y=i.className;const v=new MutationObserver(()=>{i.className!==y&&(y=i.className,m(),g())});return v.observe(i,{attributes:!0,attributeFilter:["class"]}),()=>{r.removeEventListener("scroll",g),w.disconnect(),v.disconnect();for(const _ of["--box-h","--fold","--keep","--cover"])o.style.removeProperty(_);n(!1)}},[e,t,n])}const _U={get current(){return Hc.el}},NU={upTo:e=>e.querySelector(":scope > .jump-seat"),except:qh};function ok({items:e,next:t,worktreeId:n,onOpen:r}){const o=Ur();return d.jsx(Mh,{children:d.jsx("div",{className:"msg-attachments",children:Sk(e,t).map(([i,l])=>i.kind==="image"?d.jsx(Kh,{className:"in-chat",src:"local"in i&&i.local||o.upload(i.upload),n:l,name:i.name,width:i.width,height:i.height,bytes:i.bytes,progress:"progress"in i?i.progress:void 0},`image-${l}`):i.kind==="file"?d.jsx(Uh,{className:"in-chat",name:i.name,bytes:i.bytes,href:i.text&&i.upload?o.upload(i.upload):void 0,progress:"progress"in i?i.progress:void 0},`file-${l}`):i.kind==="paste"?d.jsx(Bh,{className:"in-chat",n:l,name:i.name,source:i.source,...Lk(i.text),text:i.text},`paste-${l}`):d.jsx(Zh,{className:"in-chat",pick:i,worktreeId:n,onOpen:r},`pick-${l}`))})})}function TU({entry:e,next:t,worktreeId:n,onOpen:r}){const o=ct(),i=Rt(e.id,"draft"),l=Rt(e.id,"attachments");return d.jsxs("div",{className:"msg-user queued-msg",children:[d.jsxs("span",{className:"queued-tag",children:[d.jsx(_t,{name:"clock",className:"icon-inline"}),d.jsx("span",{className:"live-text",children:"uploading"})]}),d.jsxs("span",{className:"queued-actions",children:[d.jsx(Ot,{icon:"edit",label:"Edit: puts it back in the input",onClick:()=>o({a:"unsend",id:e.id})}),d.jsx(Ot,{icon:"close",label:"Remove: it is not sent",onClick:()=>o({a:"drop-out",id:e.id})})]}),d.jsxs("div",{className:"queued-text",children:[l.length>0&&d.jsx(ok,{items:l,next:t,worktreeId:n,onOpen:r}),i]})]})}const jU=new Set;function Gm({active:e,archived:t,found:n,lead:r,tail:o,foot:i}){var xn;const l=rt(),c=Gn(),u=ct(),h=L(M=>M.frame==="phone"),f=(e==null?void 0:e.worktree.id)??(t==null?void 0:t.id)??(n==null?void 0:n.id)??null,m=Rt(f,"chat"),g=Rt(f,"queue"),w=Rt(f,"sending"),y=S.useMemo(()=>sg(vS(m)),[m]),v=S.useMemo(()=>{let M=y;return g.map(re=>{const Ne=M;return M=Fc(M,re.attachments??[]),Ne})},[g,y]),_=L(M=>M.outbox),x=S.useMemo(()=>{let M=g.reduce((re,Ne)=>Fc(re,Ne.attachments??[]),y);return _.filter(re=>re.log===f).map(re=>{const Ne=M;return M=Fc(M,re.kinds.map(Ze=>({kind:Ze}))),{entry:re,next:Ne}})},[_,f,g,y]),T=w!=null&&w.message?g.findIndex(M=>{var re;return M.text===((re=w.message)==null?void 0:re.text)}):-1,N=S.useRef(null);wU(N,f),J5(N,NU);const[j,$]=S.useState(null),O=S.useCallback(()=>{const M=(N.current&&Fg(N.current))??"";$(re=>({seed:M||(re==null?void 0:re.seed)||"",seq:((re==null?void 0:re.seq)??0)+1}))},[]),I=S.useCallback(M=>!(M!=null&&M.closest("[data-pane]"))&&!c.getState().overlay,[c]);LN(_U,Iw,O,I);const P=M=>{if($(null),M){const re=window.getSelection();re==null||re.removeAllRanges(),re==null||re.addRange(M)}},R=QS(N,m);ft([f],()=>R.jump());const U=R.offStart&&R.moving==="up",F=R.offEnd&&(R.moving==="down"||R.away),B=M=>M.preventDefault(),X=(U||F)&&d.jsxs("div",{className:He("jump",R.away&&"jump-news"),children:[U&&d.jsx("button",{className:"jump-up",onMouseDown:B,onClick:R.start,"data-tip":"Jump to start",children:d.jsx(_t,{name:"caret-up",className:"icon-inline"})}),F&&d.jsxs("button",{className:"jump-down",onMouseDown:B,onClick:R.jump,"data-tip":"Jump to latest",children:[d.jsx(_t,{name:"caret",className:"icon-inline"}),R.away&&" new messages"]})]}),ae=S.useCallback(M=>u({a:"reading",on:M}),[u]);SU(N,h,ae);const Y=Rt(f,"mark"),ne=(Y==null?void 0:Y.by)==="walk"?Y.at:void 0,C=S.useRef(null),H=()=>{const M=N.current,re=M==null?void 0:M.querySelector(':scope > [data-state~="cursor"]');if(!M||!re)return;const Ne=parseFloat(getComputedStyle(M).paddingTop)||0;M.scrollTop+=re.getBoundingClientRect().top-M.getBoundingClientRect().top-Ne,R.read()};ft([ne],()=>{const M=N.current;if(M){if(ne===void 0){const re=C.current;if(C.current=null,!re||!cj(fo(c.getState(),f).draft))return;re.bottom?R.jump():(M.scrollTop=re.top,R.read());return}C.current??(C.current={bottom:R.pinned(),top:M.scrollTop}),H()}});const V=Rt(f,"sent");ft([V],()=>{V&&R.jump()});const J=x.length,Z=S.useRef(J);ft([J],()=>{J>Z.current&&R.jump(),Z.current=J});const ie=(Y==null?void 0:Y.by)==="reveal"?Y:void 0,be=S.useMemo(()=>ie?CB(m,ie.seq):-1,[m,ie]),ge=ne??(be>=0?be:void 0);ft([ie==null?void 0:ie.n,be],()=>{be>=0&&H()});const we=S.useCallback((M,re)=>{f&&(re?un.post(f,{type:"highlight-selector",selector:M.selector,label:Vk(M)}):un.post(f,{type:"highlight-clear"}))},[f]),pe=Fo(e==null?void 0:e.agent),Q=Rt(f,"cardParked"),W=S.useMemo(()=>{const M=vw(m);return!!M&&Q!==M.id},[m,Q]),ye=e==null?void 0:e.worktree,_e=(ye==null?void 0:ye.path)??(t==null?void 0:t.path)??(n==null?void 0:n.path),ve=S.useMemo(()=>_e?[_e]:[],[_e]),ce=S.useMemo(()=>vB(m,ve),[m,ve]),Se=S.useMemo(()=>pe?xB(m):jU,[pe,m]),me=S.useMemo(()=>EB(ce,Se),[ce,Se]),Ue=me.floating,Ie=S.useRef([]),We=S.useMemo(()=>(Ie.current=NB(Ie.current,me.flow),Ie.current),[me]),mt=(e==null?void 0:e.agent)==="working",en=mt||(e==null?void 0:e.agent)==="waiting",Kt=S.useMemo(()=>en?jB(We):-1,[en,We]),Be=We.at(-1),Xt=mt&&Be&&"item"in Be&&(Be.item.kind==="thinking"||Be.item.kind==="assistant")?We.length-1:-1,ln=(xn=ce.findLast(M=>{var re;return"tools"in M&&((re=M.tools[0])==null?void 0:re.name)===_i}))==null?void 0:xn.at,It=Rt(f,"chatAt"),Je=Ei(pe?It:void 0),Vt=Rt(f,"usage"),tn=(Vt==null?void 0:Vt.heard)!==void 0&&It!==void 0&&Vt.heard>It?Vt.heard:void 0,ht=Ei(pe?tn:void 0),gt=Ei(w&&!pe?w.at:void 0),sn=SB(m),kn=Ue.length>0,Pt=Xt>=0||sn||kn,Rn=mt&&!Pt&&Je<aa?kB(We,ve):-1,bt=S.useMemo(()=>QT(We),[We]),ee=Rt(f,"running"),ke=M=>ee&&M.tools.some(re=>re.id===ee.id)?ee.at:void 0,Xe=e==null?void 0:e.worktree.path,Ge=M=>`${f??""}:${M}`,Zt=(M,re)=>"spawn"in M?{kind:"tool",props:{tools:[M.spawn],run:M.run,roots:ve,worktreeId:f}}:"tools"in M?{kind:"tool",props:{tools:M.tools,next:M.next,live:re===Kt||M.at===ln,held:re===Rn,since:ke(M),queued:bt.has(re),roots:ve,worktreeId:f,marked:M.at===ge}}:M.item.kind==="thinking"?{kind:"thought",props:{item:M.item,open:re===Kt,streaming:re===Xt,worktreeId:f,fileRoot:Xe}}:{kind:"item",props:{item:M.item,worktreeId:f,onPickHover:we,marked:M.at===ge,streaming:mt&&re===We.length-1}},Bt=S.useRef(new Map),mn=vU(Bt.current,We,Zt,(M,re)=>re.kind==="tool"?d.jsx(lf,{...re.props},Ge(M.at)):re.kind==="thought"?d.jsx(uU,{...re.props},Ge(M.at)):d.jsx(hU,{...re.props},Ge(M.at)));Bt.current=mn.cache;const an=d.jsxs("div",{className:"chat-wrap",children:[d.jsxs("div",{className:"chat-log",ref:N,children:[r,mn.rows,Ue.map(M=>{var re;return"spawn"in M?d.jsx(lf,{tools:[M.spawn],run:M.run,working:!0,since:It,roots:ve,worktreeId:f},Ge(M.at)):((re=M.tools[0])==null?void 0:re.name)===_i?d.jsx(lf,{tools:M.tools,live:M.at===ln,since:ke(M),roots:ve,worktreeId:f,marked:M.at===ge},Ge(M.at)):d.jsx(lf,{tools:M.tools,since:It,roots:ve,worktreeId:f},Ge(M.at))}),f&&(w==null?void 0:w.message)&&d.jsxs("div",{className:"msg-user",onClick:M=>oy(M,_e,f,{sock:l,dispatch:u}),children:[w.message.attachments&&d.jsx(ok,{items:w.message.attachments,next:y,worktreeId:f,onOpen:(M,re)=>ga(c,l,f,M,re)}),d.jsx(ry,{text:w.message.text,worktreeId:f,root:_e})]}),e&&(w||pe&&!(e.agent==="waiting"&&W)&&!sn&&!kn&&Rn<0&&!(Pt&&Je<aa))&&d.jsx("div",{className:"working-row",children:e.agent==="waiting"?"waiting for your answer…":Pt?Je>=aa&&d.jsxs("span",{children:["quiet for",d.jsx("span",{className:"working-num",children:da(Je)})]}):d.jsxs("span",{className:"working-mark",children:[d.jsx(Ml,{}),!pe&&w?gt>=aa&&d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"working-word",children:"waiting for the agent"}),d.jsx("span",{className:"working-num",children:da(gt)})]}):tn!==void 0?ht>=aa&&d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"working-word",children:"thinking"}),d.jsx("span",{className:"working-num",children:da(ht)})]}):Je>=aa&&d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"working-word",children:"waiting for the model"}),d.jsx("span",{className:"working-num",children:da(Je)})]})]})}),f&&g.map((M,re)=>re===T?null:d.jsxs("div",{className:"msg-user queued-msg",children:[d.jsxs("span",{className:"queued-tag",children:[d.jsx(_t,{name:"clock",className:"icon-inline"}),"queued"]}),d.jsxs("span",{className:"queued-actions",children:[d.jsx(Ot,{icon:"edit",label:"Edit: removes from queue, puts it back in the input",onClick:()=>b_(c,l,f,re)}),d.jsx(Ot,{icon:"close",label:"Remove from queue",onClick:()=>l==null?void 0:l.send({t:"unqueue",worktreeId:f,index:re})})]}),d.jsxs("div",{className:"queued-text",children:[M.attachments&&d.jsx(ok,{items:M.attachments,next:v[re]??y,worktreeId:f,onOpen:(Ne,Ze)=>ga(c,l,f,Ne,Ze)}),M.text]})]},`q-${re}`)),f&&x.map(({entry:M,next:re})=>d.jsx(TU,{entry:M,next:re,worktreeId:f,onOpen:(Ne,Ze)=>ga(c,l,f,Ne,Ze)},M.id)),o,d.jsx("div",{className:"jump-seat",children:X}),h&&i]}),j&&d.jsx(MN,{root:N,body:N,skip:qh,seed:j.seed,seq:j.seq,onClose:P,onReveal:R.read})]});return h?an:d.jsxs(d.Fragment,{children:[an,i]})}function $U(){try{return localStorage.getItem(Ke.installOffered)==="1"}catch{return!1}}let Gf={prompt:null,offered:typeof localStorage<"u"&&$U()};const sk=new Set;function ik(e){Gf={...Gf,...e};for(const t of sk)t()}typeof window<"u"&&(window.addEventListener("beforeinstallprompt",e=>{e.preventDefault(),ik({prompt:e})}),window.addEventListener("appinstalled",()=>ik({prompt:null})));function uj(e){return sk.add(e),()=>{sk.delete(e)}}function dj(){return S.useSyncExternalStore(uj,()=>Gf.prompt)}function CU(){return S.useSyncExternalStore(uj,()=>Gf.offered)}function l1(){try{localStorage.setItem(Ke.installOffered,"1")}catch{}ik({offered:!0})}function AU(e){return!e.prompt||e.offered||e.agent!=="idle"?!1:e.chat.some(t=>t.kind==="assistant")}function fj({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(es,{k:r}),o]},r)),t&&d.jsx("span",{className:"key-note",children:t})]})}const IU={side:"top",align:"start",offset:4,alignOffset:-10,matchWidth:-20,flip:"side",margin:8};function RU({results:e,keyOf:t,row:n,rowClass:r,nav:o,listRef:i,empty:l,note:c,groupOf:u,groupHead:h}){const f=new Set(u?e.map(u):[]);return d.jsxs(Ls,{className:"inline-picker",anchor:"parent",placement:IU,children:[d.jsxs("div",{className:"picker-list",ref:i,children:[e.map((m,g)=>{const w=u==null?void 0:u(m),y=w!==void 0&&f.size>1&&(g===0||(u==null?void 0:u(e[g-1]))!==w)?d.jsx("div",{className:"picker-group",children:(h==null?void 0:h(w))??w}):null;return d.jsxs(S.Fragment,{children:[y,d.jsx("button",{className:He("picker-item",r==null?void 0:r(m)),"data-state":dr({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:l})]}),d.jsx(fj,{hints:[["↑↓","moves"],["tab","inserts"],["esc","dismisses"]],note:c})]})}const c1=e=>Math.max(0,Math.min(1,Number.isFinite(e)?e:0));function OU({fraction:e,level:t,className:n}){const o=2*Math.PI*5.5,i=c1(e),l=S.useId(),c=3.5,u=2*c*c1(t);return d.jsxs("svg",{className:He("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:l,children:d.jsx("circle",{cx:"7",cy:"7",r:c})}),d.jsx("rect",{className:"ring-level",clipPath:`url(#${l})`,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*i} ${o}`})]})}function MU(e,t=qc.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 ly(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=hj(e);return r&&n.push({id:"install",label:r,onClick:()=>t==null?void 0:t.send({t:"install-agent",agent:e.id})}),n}function hj(e){return e.install?e.install==="missing"?"install":"install again":null}const Gh=e=>e.reason??"not installed",ps="";function PU(e){var h;const t=DU(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(" · "),i=e.name.replace(/\s*\([^)]*\)$/,""),l=r.match(/^(.+?) (\d+(?:\.\d+)*)(?: with (.+))?$/);if(!(l!=null&&l[2])||l[1]!==i)return{label:e.name,...e.description?{description:e.description}:{}};const u=[l[3]??((h=e.name.match(/\(([^)]*)\)$/))==null?void 0:h[1]),...o].filter(Boolean).join(" · ");return{label:i,version:l[2],...u?{description:u}:{}}}const LU=/(?:^|[./])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 DU(e){const t=e.match(LU),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 pj(e,t,n,r,o){const i=Y1(e),l=jC(e,o),c=v=>l&&v===(i==null?void 0:i.id)?l.id:v,u=c(t||n||(i==null?void 0:i.id)||ps),h=c(t||(i==null?void 0:i.id)||ps),f=l?e.filter(v=>v!==i):e,m=f.some(v=>v.id===u),g=f.map(v=>({c:v,words:PU(v)})),w=v=>[v.label,v.version].filter(Boolean).join(" "),y=[...i?[]:[{id:ps,label:r.label,description:r.description}],...g.map(({c:v,words:_})=>{const x=g.filter(N=>w(N.words)===w(_)).length===1?_:void 0,T=x?x.description:v.description;return{id:v.id,label:x?x.label:v.name,...x!=null&&x.version?{suffix:x.version}:{},...x!=null&&x.version&&g.some(N=>N.c!==v&&N.words.label===x.label)?{chip:w(x)}:{},description:v===l?["default",T].filter(Boolean).join(" · "):T}}),...u&&!m?[{id:u,label:u}]:[]];if(u!==h){const v=y.find(T=>T.id===u),_=y.findIndex(T=>T.id===h),x=y[_];if(x){const T=(v==null?void 0:v.chip)??(v==null?void 0:v.label)??u;y[_]={...x,description:[`${T} now`,x.description].filter(Boolean).join(" · ")}}}return{rows:y,shown:u,picked:h}}const Ic=(e,t)=>`${e} ${t}`;function zU(e){const t=e.indexOf(" ");return t<0?{agent:e,model:ps}:{agent:e.slice(0,t),model:e.slice(t+1)}}function FU(e,t,n){const r=e.length>1;let o=Ic(t,n);return{rows:e.flatMap(l=>{var f;const c=l.short??l.name,u=l.id===t;if(!l.available||!((f=l.models)!=null&&f.length))return u&&(o=Ic(l.id,ps)),[{id:Ic(l.id,ps),label:c,description:l.available?l.checkFailed??"its own default model; the rest are listed once it has run":Gh(l),disabled:!l.available}];const h=pj(l.models,u?n:ps,void 0,{label:`${c} default`,description:`whatever ${l.name} runs when nothing is asked for`},l.defaultModel);return u&&(o=Ic(l.id,h.shown)),h.rows.map(m=>({...m,id:Ic(l.id,m.id),...r&&m.id!==ps?{prefix:c}:{}}))}),shown:o}}function uu({anchored:e=!1,...t}){return e?d.jsx(BU,{...t,anchored:e===!0?{}:e}):d.jsx(UU,{...t})}function BU({onClose:e,onEscape:t,boxClass:n="",bare:r=!1,anchored:o,coverBy:i,id:l,children:c}){const{onKey:u,back:h}=mj(t);return d.jsx(Ls,{className:He(r?"":"overlay-box","anchored",n),id:l,anchor:"parent",placement:{side:"bottom",align:"start",cover:!0,margin:0,...o},coverBy:i,onDismiss:e?()=>e():void 0,onKey:u,onBack:()=>h()||(e==null?void 0:e()),children:c})}function UU({onClose:e,onEscape:t,boxClass:n="",bare:r=!1,id:o,children:i}){const{onKey:l,back:c}=mj(t);return d.jsx(Ls,{className:"overlay scrim",id:o,onDismiss:e?()=>e():void 0,onKey:l,onBack:()=>c()||(e==null?void 0:e()),onClick:u=>{e&&u.target===u.currentTarget&&e()},children:d.jsx("div",{className:He(r?"":"overlay-box",n),children:i})})}function mj(e){const t=Gn(),n=()=>{if(e)return e(),!0;const o=t.getState();return!o.overlay||o.choosingFolder?!1:(t.dispatch({a:"close",back:RS(o.overlay)}),!0)};return{onKey:o=>{o.key==="Escape"&&n()&&o.stopPropagation()},back:n}}function HU(e){const t=e.value.length;e.setSelectionRange(t,t)}function WU({text:e,params:t}){if(t.length===0)return e;const n=[];let r=0;for(const[o,i]of t)o>r&&n.push(e.slice(r,o)),n.push(d.jsx("span",{className:"picker-ghost-param",children:e.slice(o,i)},o)),r=i;return r<e.length&&n.push(e.slice(r)),n}function Br({items:e,filter:t,keyOf:n,row:r,rowClass:o,rowTitle:i,onPick:l,onBack:c,onActive:u,onSide:h,onTab:f,onQuery:m,completionOf:g,narrowTo:w,placeholder:y,initialQuery:v="",initialIndex:_,selectOnMount:x=!1,idleWhen:T,onIdlePick:N,anchored:j=!1,onEscape:$,lead:O,trailing:I,empty:P="no matches",footer:R,keys:U,rowMenu:F,groupOf:B,groupHead:X,headAlone:ae=!1,field:Y}){const ne=wn("picker"),[C,H]=S.useState(v),V=S.useMemo(()=>t(e,C),[e,C,t]),J=S.useRef(null),Z=Na(),ie=Q4(x,!Z&&!Y);S.useEffect(()=>{if(!m)return;const me=setTimeout(()=>m(C),150);return()=>clearTimeout(me)},[C,m]);const be=q_({results:V,keyOf:n,q:C,onPick:l,listRef:J,onActive:u,onSide:h,completionOf:g,narrowTo:w,setQ:H,initialIndex:_,idle:(T==null?void 0:T(v))??!1,onIdlePick:N}),{index:ge,ghost:we}=be,pe=Y?Y.open:!0;ft([pe,v],()=>{!Y||pe||(H(v),be.setIndex(T!=null&&T(v)?-1:0))}),ft([pe],()=>{if(!Y||!pe||Z)return;const me=()=>{const Ie=ie.current;!Ie||document.activeElement===Ie||(Ie.focus(),x&&Ie.select())};me();const Ue=requestAnimationFrame(me);return()=>cancelAnimationFrame(Ue)});const Q=S.useRef(!1),W=typeof U=="function"?U(be.active,C):U,ye=[];W!=null&&W.nav&&ye.push(["↑↓",W.nav]),W!=null&&W.side&&h&&ye.push(["←→",W.side]),W!=null&&W.complete&&(we!=null&&we.accept)&&ye.push(["tab",W.complete]),W!=null&&W.tab&&f&&ye.push(["tab",W.tab]),W!=null&&W.pick&&ye.push(["enter",W.pick]),W!=null&&W.back&&ye.push(["esc",W.back]);const _e=me=>d.jsxs("div",{...Y==null?void 0:Y.attrs,className:He("picker-input",Y&&"picker-field",Y==null?void 0:Y.className),"data-open":(Y==null?void 0:Y.open)||void 0,onMouseDown:Ue=>{var Ie;Ue.target.closest("input, .float")||(Ue.preventDefault(),(Ie=ie.current)==null||Ie.focus())},children:[O,d.jsxs("div",{className:"picker-caret",children:[d.jsx(zo,{font:"mono",bare:!0,ref:ie,value:C,spellCheck:!1,"aria-controls":Y==null?void 0:Y.id,"aria-expanded":Y?Y.open:void 0,onFocus:()=>{Y&&!Y.open&&Y.onOpen()},onBlur:Ue=>{const Ie=Ue.relatedTarget;Y!=null&&Y.open&&Ie instanceof Element&&!Ie.closest(".float")&&c()},onMouseDown:Ue=>{const Ie=document.activeElement!==Ue.currentTarget;if(Q.current=Ie,Y&&Ie){const We=document.getSelection();We&&(!We.isCollapsed||We.toString()!=="")&&We.removeAllRanges()}},onClick:Ue=>{if(!Y||!Q.current)return;Q.current=!1;const Ie=Ue.currentTarget;setTimeout(()=>{document.activeElement===Ie&&Ie.selectionStart===Ie.selectionEnd&&Ie.select()},0)},onChange:Ue=>{H(Ue.target.value),be.setIndex(T!=null&&T(Ue.target.value)?-1:0),Y&&!Y.open&&Y.onOpen()},onKeyDown:Ue=>{var Ie;if(Y&&!Y.open){if(Ue.key==="ArrowDown"||Ue.key==="ArrowUp")Y.onOpen();else if(Ue.key==="Escape"){HU(Ue.currentTarget),Ue.currentTarget.blur();return}}if(F&&be.active&&(Ue.key==="ContextMenu"||Ue.key==="F10"&&Ue.shiftKey)){const We=(Ie=J.current)==null?void 0:Ie.querySelector('[data-state~="cursor"]');if(We){Ue.preventDefault(),Ue.stopPropagation(),co.open({items:F(be.active),owner:"picker",target:We,anchor:We.getBoundingClientRect()});return}}be.onKeyDown(Ue)||!f||Ue.key!=="Tab"||Ue.shiftKey||(Ue.preventDefault(),f())},placeholder:y}),we&&d.jsxs("div",{className:"picker-ghost","aria-hidden":"true",children:[d.jsx("span",{className:"picker-typed",children:C}),WU(we)]})]}),I,me]}),ve=new Map;if(B)for(const me of V)ve.set(B(me),(ve.get(B(me))??0)+1);const ce=d.jsxs("div",{className:"picker-list",ref:J,onMouseDown:me=>{Y&&me.target!==me.currentTarget&&me.preventDefault()},children:[V.map((me,Ue)=>{const Ie=B==null?void 0:B(me),We=Ie!==void 0&&(ae||ve.size>1)&&(Ue===0||(B==null?void 0:B(V[Ue-1]))!==Ie)?d.jsx("div",{className:"picker-group",children:(X==null?void 0:X(Ie,ve.get(Ie)??0))??Ie}):null;return d.jsxs(S.Fragment,{children:[We,d.jsx("button",{className:He("picker-item",o==null?void 0:o(me)),"data-state":dr({cursor:Ue===ge}),title:i==null?void 0:i(me),onMouseMove:()=>Ue!==ge&&be.setIndex(Ue),onClick:()=>{var mt;be.pick(me),(mt=ie.current)==null||mt.focus()},...ne.contextMenu(()=>(F==null?void 0:F(me))??[]),children:r(me,Ue===ge,C)})]},n(me))}),V.length===0&&d.jsx("div",{className:"empty",children:typeof P=="function"?P(C):P}),R==null?void 0:R(C,V)]}),Se=ye.length>0&&d.jsx(fj,{hints:ye});return Y?_e(Y.open&&d.jsxs(uu,{onClose:c,onEscape:$,boxClass:"picker",anchored:j,id:Y.id,children:[ce,Se]})):d.jsxs(uu,{onClose:c,onEscape:$,boxClass:"picker",anchored:j,coverBy:O?".picker-input > *:first-child":I?".picker-input > *:last-child":void 0,children:[_e(),ce,Se]})}function vi({value:e,reads:t,options:n,onChange:r,placeholder:o,hint:i,className:l,onClose:c}){const[u,h]=S.useState(!1),f=()=>{h(!1),c==null||c()},m=t??e,g=n.find(y=>y.id===m),w=(g==null?void 0:g.chip)??(g==null?void 0:g.label)??m;return d.jsxs("span",{className:"chip-picker",children:[d.jsx(De,{variant:"ghost",tone:"chrome",mono:!0,on:u,className:He("chip-picker-btn",l),...zt(i),onClick:()=>u?f():h(!0),children:w}),u&&d.jsx(Br,{anchored:{flip:"both",margin:0},onEscape:f,items:n,filter:(y,v)=>{const _=v.trim().toLowerCase().split(/\s+/).filter(Boolean);return y.filter(x=>{const T=`${x.prefix??""} ${x.label??x.id} ${x.suffix??""} ${x.id}`.toLowerCase();return _.every(N=>T.includes(N))})},keyOf:y=>y.id,initialIndex:y=>Math.max(0,y.findIndex(v=>v.id===e)),lead:d.jsx(De,{tone:"chrome",mono:!0,on:!0,className:"chip-picker-lead",onClick:f,children:w}),placeholder:o,rowClass:()=>"picker-row",row:y=>d.jsxs(d.Fragment,{children:[y.id===e&&d.jsx("span",{className:"row-current","aria-hidden":"true"}),d.jsxs("span",{className:He("chip-option",y.disabled&&"chip-option-off"),"aria-disabled":y.disabled,children:[d.jsxs("span",{className:"chip-option-name",children:[y.prefix?`${y.prefix} `:null,y.label??y.id,y.suffix?d.jsx("span",{className:"chip-option-suffix",children:` ${y.suffix}`}):null]}),y.description&&d.jsx("span",{className:"chip-option-desc row-dim",children:y.description})]})]}),onPick:y=>{y.disabled||(r(y.id),f())},onBack:f})]})}function gj({choices:e,value:t,current:n,runs:r,what:o,defaultLabel:i,defaultDescription:l,placeholder:c,className:u,onChange:h,onClose:f}){const{rows:m,shown:g,picked:w}=S.useMemo(()=>pj(e,t,n,{label:i,description:l},r),[e,t,n,r,i,l]);if(e.length===0)return null;const y=m.find(_=>_.id===g),v=(y==null?void 0:y.chip)??(y==null?void 0:y.label)??g;return d.jsx(vi,{value:w,reads:g,options:m,onChange:h,onClose:f,className:u,hint:t?`asked for ${v}; click to change`:`${v}, the agent's choice; click to pick ${o}`,placeholder:c})}function KU(e){const[t,n]=xo(Ke.effortPrefix+(e??""),ps,r=>r??"",mo().storage);return[t,n]}function u1({efforts:e,value:t,current:n,runs:r,onChange:o,onClose:i}){return d.jsx(gj,{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:i})}function ZU(e){const[t,n]=xo(Ke.modePrefix+((e==null?void 0:e.id)??""),_f,r=>gu.some(o=>o.id===r)?r:_f,mo().storage);return[t,n]}const qU=e=>{var t;return((t=gu.find(n=>n.id===e))==null?void 0:t.description)??""};function d1({value:e,onChange:t,onClose:n}){return d.jsx(vi,{value:e,options:gu.map(r=>({id:r.id,label:r.name,description:r.description})),onChange:t,onClose:n,className:He("mode-chip",e!=="auto"&&"mode-held"),hint:`${e}: ${qU(e)}. Click to change`,placeholder:"what the agent may do without asking"})}function GU(e){const[t,n]=xo(Ke.modelPrefix+(e??""),ps,r=>r??"",mo().storage);return[t,n]}function VU(e,t,n){e.set(Ke.modelPrefix+t,n)}function f1({models:e,value:t,current:n,runs:r,onChange:o,onClose:i}){return d.jsx(gj,{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:i})}function YU({agents:e,agent:t,model:n,onChange:r,onClose:o}){const{rows:i,shown:l}=S.useMemo(()=>FU(e,t,n),[e,t,n]);if(i.length===0)return null;const c=i.find(h=>h.id===l),u=c?[c.prefix,c.label,c.suffix].filter(Boolean).join(" "):n;return d.jsx(vi,{value:l,options:i,onChange:h=>{const f=zU(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 kj(e){const t=Rh(e),[n,r]=xo(Ke.profilePrefix+((e==null?void 0:e.id)??""),(e==null?void 0:e.config.defaultProfile)??"",i=>i??void 0,mo().storage);return[t.length===0?void 0:t.includes(n)?n:e==null?void 0:e.config.defaultProfile,r]}function XU({repo:e,value:t,onChange:n,onClose:r}){const o=Rh(e);if(o.length===0||!t)return null;const i=(e==null?void 0:e.config.profiles)??{},l=(e==null?void 0:e.configFile)??"the settings",c=u=>{var m;const h=((m=i[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 ${l}`:f};return d.jsx(vi,{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 ${l}`,placeholder:"the profile the worktree runs"})}function du(e,t,n){if(!t)return e;const r=new Set(t.map(l=>l-n)),o=[];let i="";for(let l=0;l<e.length;l++)r.has(l)?(i&&o.push(i),i="",o.push(d.jsx("b",{className:"hit",children:e[l]},l))):i+=e[l];return i&&o.push(i),o}function QU({c:e,query:t}){const n=t.trim();return d.jsxs(d.Fragment,{children:[d.jsxs("span",{className:"picker-name",children:["/",du(e.name,n?Xw(e.name,n):null,0)]}),d.jsx("span",{className:"picker-desc row-dim",children:e.description})]})}function jn({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 JU(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 e7=/ \| | - | \u2013 | \u2014 | \u00b7 |: /,t7=/^(\d+|[0-9a-f]{8}-[0-9a-f-]{27}|[0-9a-f]{12,})$/i,n7=/^[[:$*{]|\[/;function r7(e){const t=new Map,n=e.filter(i=>!!i.title);if(new Set(n.map(i=>i.path)).size<2)return t;const r=n.map(i=>({path:i.path,parts:i.title.split(e7).map(l=>l.trim()).filter(Boolean)})),o=new Map;for(const{path:i,parts:l}of r)for(const c of l)o.set(c,(o.get(c)??new Set).add(i));for(const{path:i,parts:l}of r){const c=l.filter(u=>{var h;return(((h=o.get(u))==null?void 0:h.size)??0)<2});c.length>0&&t.set(i,c.join(" "))}return t}function cy(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(t7.test(r)||n7.test(r))continue;const o=r.replace(/[-_.]+/g," ").trim();if(o)return o[0].toUpperCase()+o.slice(1)}return"Home"}const Vm=8,o7=3,s7=50,i7=3;function a7(e,t,n=[]){const r=new Map,o=[],i=new Map;for(const l of(t==null?void 0:t.routes)??[]){if(l.endpoint)continue;const c=l.dynamic?mP(l.path):null;c?(o.push(c),i.set(l.path,l)):r.set(l.path,l)}return{history:e,statics:r,templates:o,templateRoutes:i,unseen:(t==null?void 0:t.unseen)??{},titles:r7(e),links:new Map(n.map(l=>[l.path,l.text]))}}function l7(e){if(!e)return"/";try{const t=new URL(e);return t.pathname+t.search+t.hash}catch{return"/"}}function c7(e){const t=e.trim();return/^[/?#]/.test(t)?t:`/${t}`}function u7(e,t){const n=/^[/?#]/.test(t)?e:e.replace(/^\//,"");return t&&n.toLowerCase().startsWith(t.toLowerCase())?n:null}const wj=e=>/^\[\[?\.\.\.|^\*$|^\$$/.test(e),Dc=e=>wj(e)||/[[:$*{]/.test(e)&&!/^[^[{:$*]+\?$/.test(e),d7=e=>mh(`/${e}`).text.slice(1),uy=e=>e.split("/").filter(Boolean);function dy(e,t){const n=t.startsWith("/"),r=t.replace(/^\//,"").split("/"),o=uy(e);let i="";const l=[],c=m=>{const g=d7(m);l.push([i.length,i.length+g.length]),i+=g};for(let m=0;m<r.length;m++){const g=r[m],w=o[m];if(w===void 0)return null;if(m<r.length-1){if(wj(w))return{show:t,accept:t};if(Dc(w)){if(!g)return null}else if(g.toLowerCase()!==w.toLowerCase())return null;i+=`${Dc(w)?g:w}/`;continue}if(Dc(w))g?i+=g:c(w);else{if(!w.toLowerCase().startsWith(g.toLowerCase()))return null;i+=w}}for(const m of o.slice(r.length))i+="/",Dc(m)?c(m):i+=m;const u=n?1:0,h=(n?"/":"")+i,f=l[0];return{show:h,accept:f?h.slice(0,f[0]+u):h,params:l.map(([m,g])=>[m+u,g+u])}}function f7(e,t){const n=dy(e,t);return n?n.accept.length>t.length?n.accept:t:mh(e).literal}function yj(e,t){if(e.kind==="go")return null;if(e.template){const n=dy(e.path,t);return n&&n.show.length>t.length?n:null}return u7(e.path,t)}const h7=e=>e.trim().replace(/^\//,"").toLowerCase();function vj(e,t){for(let n=0;n<e.length;n++)if("/-_.#".includes(e[n])&&e.startsWith(t,n+1))return!0;return!1}function p7(e,t,n){const r=e.replace(/^\//,"").toLowerCase(),o=t.toLowerCase();return r===n?100:r.startsWith(n)?80:vj(r,n)?60:o.startsWith(n)?50:o.split(/\s+/).some(i=>i.startsWith(n))?45:r.includes(n)||o.includes(n)?20:0}function m7(e,t){const{text:n,literal:r}=mh(e);return r.replace(/^\//,"").toLowerCase().startsWith(t)?80:dy(e,t)?70:vj(n.replace(/^\//,"").toLowerCase(),t)?60:0}function g7(e,t){const n=uy(e).findIndex(Dc);return n>=0&&t.split("/").length>n}function Wc(e,t,n){var c;const r=e.statics.get(t),o=r?null:gP(e.templates,t),i=(r==null?void 0:r.file)??(o?(c=e.templateRoutes.get(o.path))==null?void 0:c.file:void 0),l=i?e.unseen[i]:void 0;return{kind:"page",path:t,title:e.titles.get(t)||e.links.get(t)||cy(t),template:!1,visited:n<Number.POSITIVE_INFINITY,...i?{file:i}:{},...l?{badge:l}:{},rank:n,group:(o==null?void 0:o.path)??t,score:0}}function bj(e,t){const n=e.unseen[t.file];return{kind:"page",path:t.path,title:cy(t.path),template:!0,visited:!1,file:t.file,...n?{badge:n}:{},rank:Number.POSITIVE_INFINITY,group:t.path,score:0}}function vf({rank:e,group:t,score:n,...r}){return r}const Vf=e=>uy(e).length,Yf=e=>e.badge==="new"?0:e.badge==="changed"?1:2;function k7(e,t){const n=new Set,r=[];e.history.forEach((f,m)=>{if(f.path===t)return;const g=Wc(e,f.path,m);n.has(g.group)||(n.add(g.group),r.push(g))});const o=new Set(r.map(f=>f.path)),i=r.filter(f=>f.badge);for(const[f,m]of e.statics)e.unseen[m.file]&&f!==t&&!o.has(f)&&i.push(Wc(e,f,Number.POSITIVE_INFINITY));for(const f of e.templateRoutes.values())e.unseen[f.file]&&!n.has(f.path)&&i.push(bj(e,f));i.sort((f,m)=>Yf(f)-Yf(m)||f.rank-m.rank);const l=r.filter(f=>!f.badge),c=i.slice(0,Vm-Math.min(o7,l.length));for(const f of l)c.length<Vm&&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)=>Vf(f)-Vf(m)||(f<m?-1:f>m?1:0));for(const f of h){if(c.length>=Vm)break;c.push(Wc(e,f,Number.POSITIVE_INFINITY))}return c.map(vf)}function w7(e,t,n){const r=h7(t),o=c7(t),i=new Map;e.history.forEach((w,y)=>{w.path!==n&&i.set(w.path,Wc(e,w.path,y))});for(const w of[...e.statics.keys(),...e.links.keys()])w!==n&&!i.has(w)&&i.set(w,Wc(e,w,Number.POSITIVE_INFINITY));const l=[];for(const w of i.values()){const y=p7(w.path,w.title,r);y>0&&l.push({...w,score:y})}let c=null;for(const w of e.templates){const y=e.templateRoutes.get(w.path);if(!c&&!e.statics.has(o)&&w.re.test(o)){c=y;continue}const v=m7(w.path,r);v>=60&&l.push({...bj(e,y),score:v})}l.sort((w,y)=>y.score-w.score||w.rank-y.rank||Yf(w)-Yf(y)||Vf(w.path)-Vf(y.path)||(w.path<y.path?-1:w.path>y.path?1:0));const u=new Map,h=[];for(const w of l){if(!w.template&&w.group!==w.path){const y=u.get(w.group)??0;if(y>=i7&&!g7(w.group,r))continue;u.set(w.group,y+1)}if(h.push(w),h.length>=s7)break}if(h.some(w=>w.score===100))return h.map(vf);const f={kind:"go",path:o,...c?{title:cy(c.path)}:{}},m=h[0];return!c&&m!==void 0&&m.score>=80&&y7(m.path,r)?[...h.map(vf),f]:[f,...h.map(vf)]}function y7(e,t){const n=e.replace(/^\//,"").toLowerCase().slice(t.length);return!t.endsWith("/")&&n.length>0&&!/^[/?#]/.test(n)}function xj(e,{query:t,current:n,here:r}){return t===n||t.trim()===""?k7(e,r):w7(e,t,r)}const v7=[],b7=[];function Ej(e,t){const n=L(i=>(t?i.visits[t]:void 0)??v7),r=Rt(e,"pages"),o=Rt(e,"links");return ft([e],()=>{wS(r)&&un.post(e,{type:"links"})}),S.useMemo(()=>a7(n,r,o),[n,r,o])}function x7({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}=mh(e.path),r=[];let o=0;for(const[i,l]of n)i>o&&r.push(t.slice(o,i)),r.push(d.jsx("span",{className:"bar-route-param",children:t.slice(i,l)},i)),o=l;return o<t.length&&r.push(t.slice(o)),d.jsx("span",{className:"bar-route-path row-dim",children:r})}function Sj({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(x7,{row:e}),e.badge?d.jsx("span",{className:e.badge==="new"?"badge-new":"badge-changed",children:e.badge}):null]})}const _j=e=>e.kind==="page"&&e.file?e.file:e.path,Nj=(e,t)=>e.kind==="page"&&e.template?f7(e.path,t):null,Tj=e=>e.kind==="page"&&e.template?"fills in the parameter":"goes there";function jj(e,t,n){return e.kind!=="page"?[]:Nh([...e.file&&t.dir?Is({id:t.worktreeId,dir:t.dir},e.file,{},n):[],d_,...e.visited?JU(t.repoId,e.path,n):[]])}function E7({worktreeId:e,repoId:t,url:n,open:r}){const o=ct(),i=rt(),l=L(y=>{const v=rn(y,e);return v?v.worktree.path:null}),c=Ej(e,t),u=l7(n),h=n?ph(n):null,f=S.useCallback((y,v)=>xj(c,{query:v,current:u,here:h}),[c,u,h]),m=S.useCallback(y=>y===u||y.trim()==="",[u]),g=()=>o({a:"close"}),w=S.useMemo(()=>({open:r,onOpen:()=>o({a:"open",overlay:{kind:"routes"}}),id:"routes",className:"bar-path",attrs:zt("Go to a page",Dt("routes"))}),[r,o]);return d.jsx(Br,{anchored:{matchWidth:0,cover:!1,offset:-1},field:w,items:b7,filter:f,initialQuery:u,selectOnMount:!0,idleWhen:m,onIdlePick:y=>{y.trim()===""?un.post(e,{type:"navigate",path:"/"}):un.post(e,{type:"reload"}),g()},keyOf:y=>`${y.kind}:${y.path}`,rowClass:()=>"picker-row",rowTitle:_j,completionOf:(y,v)=>m(v)?null:yj(y,v),narrowTo:Nj,onPick:y=>{un.post(e,{type:"navigate",path:y.path}),g()},onBack:g,rowMenu:y=>jj(y,{worktreeId:e,repoId:t,dir:l},{sock:i,dispatch:o}),placeholder:"type a path",keys:(y,v)=>({complete:"completes the path",pick:y?Tj(y):v.trim()===""?"goes to the root":"reloads",back:"closes"}),empty:"no pages yet; type a path",row:y=>d.jsx(Sj,{row:y})})}function $j(e,t){const n=t.trim();return d.jsx(jn,{label:du(e.label,n?Xw(e.label,n):null,0),hint:e.hint&&d.jsx(es,{k:e.hint})})}function Cj({anchored:e,trailing:t}){const n=ct(),r=gT(),o=L(i=>{var l;return((l=i.paletteReturn)==null?void 0:l.mode)==="commands"?i.paletteReturn.q:""});return d.jsx(Br,{anchored:e,trailing:t,items:r,filter:kT,rowClass:()=>"picker-row",keyOf:i=>i.id,onPick:(i,l)=>{i.sub?n({a:"palette-return",v:{mode:"commands",q:l}}):n({a:"close"}),i.run()},onBack:()=>n({a:"close"}),placeholder:"run a command…",keys:{pick:"runs",back:"closes"},initialQuery:o,empty:"no matching command",row:(i,l,c)=>$j(i,c)})}function Aj(e,t){const n=new Map(t.map(l=>[l.path,l])),r=t.filter(l=>l.xy==="??"&&l.path.endsWith("/")).map(l=>l.path),o=e.map(l=>{const c=n.get(l)??(r.some(u=>l.startsWith(u))?{path:l,xy:"??"}:void 0);return c?{path:l,status:c}:{path:l}}),i=new Set(e);for(const l of t)!i.has(l.path)&&!l.path.endsWith("/")&&o.push({path:l.path,status:l});return o}function h1(e,t){const n=e.split("/"),r=t.split("/");for(let o=0;;o++){const i=n[o],l=r[o];if(i===void 0||l===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(i!==l)return i<l?-1:1}}function Ij(e,t,n,r=50){const o=Aj(e,t),i=n.trim().toLowerCase();if(!i){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)||h1(m.path,g.path)),f=o.filter(m=>!m.status).sort((m,g)=>h1(m.path,g.path));return{rows:[...h,...f].slice(0,r),changed:Math.min(h.length,r)}}const l=Oj(o,i);return l.sort((c,u)=>u.score-c.score||c.row.path.localeCompare(u.row.path)),{rows:l.slice(0,r).map(c=>c.row),changed:0}}function Rj(e,t){const n=e.toLowerCase(),r=p1(n,t);return r<=0?0:p1(n.slice(n.lastIndexOf("/")+1),t)>0?r+10:r}function Oj(e,t){const n=[];for(const r of e){const o=Rj(r.path,t);o>0&&n.push({row:r,score:r.status?o+4:o})}return n}function S7(e,t,n,r,o){const i=r.trim().toLowerCase();if(!i)return Ij(e,n,r,o).rows.map(u=>({kind:"file",path:u.path,status:u.status}));const l=Oj(Aj(e,n),i).map(({row:u,score:h})=>({row:{kind:"file",path:u.path,status:u.status},score:h}));for(const u of t){const h=Rj(u,i);h>0&&l.push({row:{kind:"folder",path:u},score:h})}const c=u=>u.kind==="folder"?1:0;return l.sort((u,h)=>h.score-u.score||c(u.row)-c(h.row)||u.row.path.localeCompare(h.row.path)),l.slice(0,o).map(u=>u.row)}function _7(e,t){const n=e.toLowerCase(),r=[];let o=0;for(const i of t.toLowerCase()){const l=n.indexOf(i,o);if(l===-1)return null;r.push(l),o=l+1}return r}function p1(e,t){let n=0,r=0,o=0;for(const i of t){const l=e.indexOf(i,r);if(l===-1)return 0;o=l===r?o+1:1,n+=o+(l===0||e[l-1]==="/"||e[l-1]==="."?3:0),r=l+1}return n+Math.max(0,40-e.length/4)}function N7(e){const t=e.lastIndexOf("/");return t===-1?[e,""]:[e.slice(t+1),e.slice(0,t+1)]}const m1=[],T7=[],j7=[];function $7({worktreeId:e}){var _;const t=ct(),n=rt(),r=Gn(),o=L(x=>x.connected);ft([e,o,n],()=>Th(e,r.getState(),{sock:n,dispatch:t}));const i=i_(e),l=i.files??T7,c=((_=i.git)==null?void 0:_.files)??j7,u=gT(),h=L(x=>{var T;return((T=x.paletteReturn)==null?void 0:T.mode)==="quick-open"?x.paletteReturn.q:""}),f=L(x=>{var N;const T=(N=rn(x,e))==null?void 0:N.worktree;return T?T.path:null}),m=L(x=>{var T;return((T=rn(x,e))==null?void 0:T.repoId)??null}),g=L(x=>{var T;return((T=Df(x))==null?void 0:T.worktreeId)===e}),w=Ej(e,m),y=i.page.url?ph(i.page.url):null,v=S.useCallback((x,T)=>T.startsWith(">")?kT(u,T.slice(1)).map(N=>({kind:"cmd",c:N})):T.startsWith("/")?g?xj(w,{query:T,current:"/",here:y}).map(N=>({kind:"page",page:N})):m1:Ij(l,c,T).rows.map(N=>({kind:"file",path:N.path,status:N.status})),[u,l,c,g,w,y]);return d.jsx(Br,{items:m1,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"?_j(x.page):void 0,completionOf:(x,T)=>x.kind==="page"?yj(x.page,T):null,narrowTo:(x,T)=>x.kind==="page"?Nj(x.page,T):null,onPick:(x,T)=>{x.kind==="cmd"?(x.c.sub?t({a:"palette-return",v:{mode:"quick-open",q:T}}):t({a:"close"}),x.c.run()):x.kind==="page"?(un.post(e,{type:"navigate",path:x.page.path}),t({a:"close"})):(Ln({dispatch:t},{worktreeId:e,path:x.path,view:ji(x.path)}),t({a:"close"}))},onBack:()=>t({a:"close"}),rowMenu:x=>x.kind==="file"&&f?Is({id:e,dir:f},x.path,{},{sock:n,dispatch:t}):x.kind==="page"&&m?jj(x.page,{worktreeId:e,repoId:m,dir:f},{sock:n,dispatch:t}):[],placeholder:"jump to file · type > for commands, / for pages",keys:(x,T)=>T.startsWith("/")?{complete:"completes the path",pick:(x==null?void 0:x.kind)==="page"?Tj(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,T,N)=>x.kind==="cmd"?$j(x.c,N.slice(1)):x.kind==="page"?d.jsx(Sj,{row:x.page}):ak(x.path,x.status,N,{gutter:c.length>0})})}function ak(e,t,n,{folder:r=!1,gutter:o=!0}={}){const[i,l]=N7(e),c=n.trim()?_7(e,n.trim()):null;return d.jsxs(d.Fragment,{children:[o&&d.jsx("span",{className:`xy ${t?Zk(t.xy):""}`,children:t?qk(t.xy):""}),d.jsxs("span",{className:"name",children:[du(i,c,l.length),r&&"/"]}),d.jsx("span",{className:"dir row-dim",children:l&&d.jsxs(d.Fragment,{children:["‎",du(l,c,0),"‎"]})}),t&&d.jsx(_N,{f:t})]})}function C7(e,t,n){var l;if(!e)return null;if(e.available)return e.checkFailed?{kind:"unready",text:e.checkFailed,retry:null}:((l=e.auth)==null?void 0:l.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: ${Gh(e)}`,retry:hj(e),...o}}function Rc({icon:e,verb:t,tip:n,onPress:r,onDismiss:o,className:i,children:l}){return d.jsxs("div",{className:He("composer-offer",i),children:[d.jsx(_t,{name:e,className:"icon-inline"}),d.jsxs("span",{className:"composer-offer-line",children:[d.jsx(De,{variant:"inline",tone:"strong","data-tip":n,onClick:r,children:t})," ",l]}),o&&d.jsx(Ot,{icon:"close",tone:"quiet",className:"composer-offer-close",label:"Not this one",onClick:o})]})}function Mj({item:e,n:t,onRemove:n}){const r=Ur();return e.kind==="image"?d.jsx(Kh,{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(Uh,{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(Bh,{n:t,name:e.name,source:e.source,lines:e.lines,chars:e.chars,preview:e.preview,text:e.text,onRemove:n})}function A7(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",...I7(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=sy(n);return r===null?null:{verb:"fix",key:n.id,toolId:n.id,command:r}}function I7(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 lk=new Set;const ck=new Set;function R7(e){return ck.add(e),()=>{ck.delete(e)}}function g1(e){lk=new Set(lk).add(e);for(const t of ck)t()}function O7(){return S.useSyncExternalStore(R7,()=>lk)}const M7=e=>gu.some(t=>t.id===e);function P7(e){return[...gu.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:"split",description:"a new worktree for part of this work, here or in another project, born with a plan for it",hint:"<project> [<message>]"}]}function L7(e,t,n){const r=e.trim();if(!r)return{pick:!0};const o=r.search(/\s/),i=o===-1?r:r.slice(0,o),l=o===-1?void 0:r.slice(o).trim()||void 0,c=i.toLowerCase(),u=t.find(m=>m.id===n);if(c==="here"&&u)return{repo:u,...l?{text:l}:{}};const h=t.filter(m=>m.name.toLowerCase()===c),f=h.length>0?h:t.filter(m=>m.name.toLowerCase().startsWith(c));return f.length===0?{error:`no open project named "${i}"`}:f.length>1?{error:`"${i}" names more than one project`}:{repo:f[0],...l?{text:l}:{}}}function Pj(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 D7(e,t){const n=Pj(e,t);return[...n.yours,...n.own,...n.rest]}function k1(e,t){const n=Pj(e,t);return{rows:[...n.yours,...n.own],more:n.rest.length}}function z7(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 fu({rows:e,cursor:t,onCursor:n,onPick:r,onHint:o,hover:i=!1}){const l=Na(),c=S.useRef(null),[u,h]=S.useState(null),f=l&&!!o;X_(c,{rowOf:g=>{if(!f||g.closest("textarea"))return null;const w=g.closest(".slide"),y=w==null?void 0:w.dataset.row,v=y===void 0?void 0:e[Number(y)];return w&&y!==void 0&&(v!=null&&v.hint)&&!v.field?{el:w,key:y,rungs:1,rung:120}:null},onSlide:h,onPick:g=>o==null?void 0:o(Number(g))});const m=g=>{var w;g.target instanceof HTMLTextAreaElement||(g.preventDefault(),(w=g.currentTarget.querySelector("textarea"))==null||w.focus())};return d.jsx("div",{className:He("choices",i&&"choices-hover",l&&"choices-touch"),ref:c,children:e.map((g,w)=>{const y=!l&&t===w,v=dr({cursor:y,checked:g.checked}),_=g.tone==="deny"&&"choice-deny",x=()=>n==null?void 0:n(w),T=j=>{var I;if(!f)return j;const $=(u==null?void 0:u.key)===String(w)?u.step:null,O=$!==null&&$>0&&((I=g.hint)==null?void 0:I.on)!==!1;return d.jsxs("div",{className:"slide","data-row":w,children:[j,$!==null&&g.hint&&d.jsxs("span",{className:"slide-verb","data-rung":O?"hint":void 0,"aria-hidden":"true",children:[d.jsx("span",{className:"slide-word",children:g.hint.label}),d.jsx(_t,{name:g.hint.icon})]})]},w)},N=d.jsxs(d.Fragment,{children:[!l&&d.jsx(es,{k:String(w+1),className:"choice-num row-dim"}),d.jsx("span",{className:"choice-label",children:g.label}),!l&&g.hint&&d.jsxs("span",{className:He("choice-hint row-dim",y&&g.hint.on!==!1&&"on"),children:[d.jsx(es,{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?T(d.jsxs("div",{className:He("picker-item choice row-edge",_),"data-state":v,onMouseMove:x,onMouseDown:m,children:[N,d.jsx(nu,{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:j=>{var $;return($=g.field)==null?void 0:$.onChange(j.target.value)}}),l&&g.field.onSend&&d.jsx(Ot,{className:"choice-send",icon:"send",tone:"primary",label:"Send",onClick:g.field.onSend})]},w)):T(d.jsx("button",{type:"button",className:He("picker-item choice row-edge",_),"data-state":v,disabled:g.disabled,onMouseMove:x,onClick:()=>r(w),children:N},w))})})}function Lj(e){return bf(e.key)&&(e.metaKey||e.ctrlKey)&&!e.altKey?!1:e.metaKey||e.ctrlKey||e.altKey}const Dj=e=>e.length===1&&e>="1"&&e<="9",bf=e=>e==="Enter"||e==="NumpadEnter";function F7(e,t,n){const r=bf(e.key)&&(e.metaKey||e.ctrlKey);return t?e.key==="Escape"||e.key==="Tab"&&!e.shiftKey?{kind:"field-leave"}:r?{kind:"submit"}:bf(e.key)&&!e.shiftKey?{kind:"field-enter"}:{kind:"typing"}:Lj(e)?{kind:"chord"}:e.key==="Escape"?{kind:"escape"}:r?{kind:"submit"}:bf(e.key)||e.key===" "&&n.spacePicks?n.cursor===void 0?{kind:"submit"}:{kind:"pick",at:n.cursor,by:"enter"}:e.key==="ArrowUp"||e.key==="ArrowDown"?n.cursor===void 0?null:{kind:"cursor",to:xu(n.cursor,e.key==="ArrowUp"?-1:1,n.count)}:Dj(e.key)&&Number(e.key)<=n.count?{kind:"pick",at:Number(e.key)-1,by:"digit"}:null}function fy(e,t){var o,i,l,c;const n=e.target instanceof HTMLTextAreaElement,r=F7(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?(i=t.onFieldEnter)==null||i.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(),(l=t.onCursor)==null||l.call(t,r.to),!0;case"field-enter":return e.preventDefault(),(c=t.onFieldEnter)==null||c.call(t),!0}}function zj(e){return!e||e===document.body?!1:e.closest(".monaco-editor, .xterm")?!0:(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement)&&!e.closest(".chat-input")}function B7(e,t){ft([t],()=>{const o=requestAnimationFrame(()=>{var i;zj(document.activeElement)||(i=e.current)==null||i.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},i=()=>{n.current=!1,r()};return window.addEventListener("pointerdown",o,!0),window.addEventListener("pointerup",i,!0),window.addEventListener("pointercancel",i,!0),()=>{window.removeEventListener("pointerdown",o,!0),window.removeEventListener("pointerup",i,!0),window.removeEventListener("pointercancel",i,!0)}},[r]),o=>{!o.relatedTarget&&!n.current&&r()}}function Xf(e){var n,r;const t=document.activeElement;zj(t)||t&&((n=e.current)!=null&&n.contains(t))||(r=e.current)==null||r.focus({preventScroll:!0})}function Qf({root:e,id:t,onKeyDown:n,onKeyUp:r,onPaste:o,children:i}){const l=B7(e,t);return d.jsx("div",{ref:e,className:"card",tabIndex:-1,onKeyDown:n,onKeyUp:r,onPaste:o,onBlur:l,children:i})}function hu({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 uk(e){const t=S.useRef(null),n=iy(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 U7({children:e}){return d.jsx("div",{className:"card-foot",children:e})}function H7(e){const t=e.findIndex(n=>n.kind.startsWith("reject"));return t<0?null:t}function W7(e){const{key:t}=e;return t.length!==1||t===" "||t==="n"||Dj(t)||Lj(e)?null:t}const w1=[{selected:[]}];function K7({item:e,ask:t,worktreeId:n,rootRef:r}){var F;const o=rt(),i=ct(),l=L(B=>B.activeId),c=Rt(n,"card"),u=(c==null?void 0:c.id)===e.id?c.draft:w1,h=(F=u[0])==null?void 0:F.note,f=h!==void 0,m=f?t.choices.findIndex(B=>{var X;return B.id===((X=u[0])==null?void 0:X.selected[0])}):-1,g=S.useRef(null),[w,y]=S.useState(0),v=t.plan,_=S.useMemo(()=>t.detail&&!v?ka(t.detail):"",[t.detail,v]),x=()=>{v&&l===n&&Ln({dispatch:i},{worktreeId:n,path:v,view:"preview",focus:!1})};ft([e.id,v],x);const T=t.pieces,N=L(B=>{var ae;const X=T?(ae=fo(B,n).chat)==null?void 0:ae.find(Y=>Y.kind==="pieces"&&Y.id===T):null;return(X==null?void 0:X.kind)==="pieces"?X:null}),j=B=>i({a:"card-draft",id:n,card:{id:e.id,draft:B,current:0}}),$=(B,X)=>{const ae=t.choices[B];ae&&(j([{selected:[ae.id],note:X}]),y(B),requestAnimationFrame(()=>{const Y=g.current;Y&&(Y.focus(),Y.setSelectionRange(Y.value.length,Y.value.length))}))},O=B=>{const X=t.choices[B];if(!X)return;const ae=h==null?void 0:h.trim();o==null||o.send({t:"agent-decide",worktreeId:n,askId:e.id,choiceId:X.id,...ae?{note:ae}:{}}),i({a:"answered",id:n})},I=()=>i({a:"card-park",id:n,cardId:e.id}),P=()=>{var B;h!=null&&h.trim()||j(w1),(B=r.current)==null||B.focus()},R=B=>{if(fy(B,{count:t.choices.length,cursor:w,onCursor:y,onPick:O,onEscape:I,onFieldEnter:()=>O(m),onFieldLeave:P}))return;if(B.key==="n"){B.preventDefault(),$(w,h??"");return}const X=W7(B);X!==null&&(B.preventDefault(),$(f?m:H7(t.choices)??w,(h??"")+X))},U=t.choices.map((B,X)=>{const ae=B.kind.startsWith("reject"),Y=f&&X===m;return{label:B.name,tone:ae?"deny":void 0,hint:{k:"n",label:"add context",icon:"edit",on:!f},checked:Y,field:Y?{ref:g,value:h,placeholder:ae?"what to change, sent with your no":"a note for the work, sent with your yes",enterKeyHint:"send",onChange:ne=>j([{selected:[B.id],note:ne}]),onSend:()=>O(m)}:void 0}});return d.jsxs(Qf,{root:r,id:e.id,onKeyDown:R,children:[d.jsx(hu,{sub:N?d.jsxs(d.Fragment,{children:[hz(N,n)," ",d.jsx(De,{variant:"inline","data-tip":"Read the list at the head of the plan; any row can still be moved",onClick:()=>v&&Ln({dispatch:i},{worktreeId:n,path:v,view:"preview"}),children:"The list is on the plan"}),"."]}):void 0,children:t.title}),t.command&&d.jsx(uk,{code:ZT(t.command)}),_&&d.jsx(uk,{html:_}),d.jsx(fu,{rows:U,cursor:w,onCursor:B=>{y(B),Xf(r)},onPick:O,onHint:B=>$(B,h??"")})]})}const Z7=[{selected:[]}];function q7({item:e,worktreeId:t,rootRef:n}){var X,ae;const r=rt(),o=ct(),i=Rt(t,"card"),l=(i==null?void 0:i.id)===e.id?i.draft:Z7,c=(X=l[0])==null?void 0:X.note,u=c!==void 0,h=u?Number(((ae=l[0])==null?void 0:ae.selected[0])??0):-1,f=(Y,ne=0)=>o({a:"card-draft",id:t,card:{id:e.id,draft:[{...Y[0]??{selected:[]},selected:[String(ne)]}],current:0}}),m=S.useRef(null),[g,w]=S.useState(0),[y,v]=S.useState(null),_=y!==null,x=e.pieces.length===1?e.pieces[0]:void 0,T=e.plan,N=()=>{T&&Ln({dispatch:o},{worktreeId:t,path:T,view:"preview"})},j=S.useMemo(()=>x?ka(x.plan):"",[x]),$=S.useMemo(()=>x?pz(e,x):[{fate:"worktree",label:"go",notes:!0},{fate:null,label:"not now",notes:!1}],[e,x]),O=Y=>{if(_||!r)return;const ne=$[Y];ne&&(ne.fate===null?r.send(Ub(e,t,!1,void 0)):(x&&ne.fate!==$h(e,x)&&r.send($_(e,t,x.id,ne.fate)),r.send(Ub(e,t,!0,c)),v(Y)),o({a:"answered",id:t}))},I=()=>{var ne;const Y=(ne=$[g])!=null&&ne.notes?g:$.findIndex(C=>C.notes);Y!==-1&&((!u||h!==Y)&&f(Mf(l,0,c??""),Y),w(Y),requestAnimationFrame(()=>{var C;return(C=m.current)==null?void 0:C.focus()}))},P=()=>o({a:"card-park",id:t,cardId:e.id}),R=()=>{var ne;const Y=kf(l,0);Y!==l&&f(Y,h),(ne=n.current)==null||ne.focus()},U=Y=>{fy(Y,{count:$.length,cursor:g,onCursor:w,onPick:O,onEscape:P,onFieldEnter:()=>O(h),onFieldLeave:R})||(Y.key==="n"?(Y.preventDefault(),I()):Y.key==="r"&&T&&!x&&(Y.preventDefault(),N()))},F=$.map((Y,ne)=>({label:Y.label,...y===ne?{description:"starting"}:Y.description?{description:Y.description}:{},...Y.notes?{hint:{k:"n",label:"add context",icon:"edit",on:!u}}:{},tone:Y.fate===null?"deny":void 0,checked:u&&ne===h,field:u&&ne===h?{ref:m,value:c??"",placeholder:x?"a note for the agent there, sent with it":"a note for every piece's agent, sent with go",enterKeyHint:"send",onChange:C=>f(Mf(l,0,C),h),onSend:()=>O(h)}:void 0,disabled:_}));if(x)return d.jsxs(Qf,{root:n,id:e.id,onKeyDown:U,children:[d.jsx(hu,{sub:d.jsxs(d.Fragment,{children:[x.project?`Starts a worktree in ${x.project.name}, in ${e.mode} mode${e.mode==="auto"?", which runs without asking":""}, with this as its plan. `:"","Nothing has started yet."]}),children:$g(e)}),d.jsx(uk,{html:j}),d.jsx(fu,{rows:F,cursor:g,onCursor:Y=>{w(Y),Xf(n)},onPick:O})]});const B=T?d.jsx(De,{variant:"inline","data-tip":"Open it beside the box (r)",onClick:N,children:"Read the list"}):"The list is the agent's";return d.jsxs(Qf,{root:n,id:e.id,onKeyDown:U,children:[d.jsx(hu,{sub:d.jsxs(d.Fragment,{children:[B," and change any row's fate there. Nothing has started yet."]}),children:$g(e)}),d.jsx(fu,{rows:F,cursor:g,onCursor:Y=>{w(Y),Xf(n)},onPick:O})]})}function G7({item:e,ask:t,worktreeId:n,rootRef:r,numbers:o,onAnswer:i}){const l=rt(),c=ct(),u=Gn(),h=L(Q=>Q.clientId),{message:f,questions:m}=t,g=bl(e.id),w=Rt(g,"attachments"),y=L_(g,n),v=Rt(n,"card"),_=S.useMemo(()=>(v==null?void 0:v.id)===e.id?v:{id:e.id,draft:NL(m),current:0},[v,e.id,m]),{draft:x,current:T}=_,N=T===gl(m),j=m[T],$=x[T],O=!!(j!=null&&j.multi),[I,P]=S.useState(()=>ml(j,$)),R=S.useRef(null);S.useEffect(()=>{const Q=window.visualViewport;if(!Q)return;const W=()=>{R.current&&R.current===document.activeElement&&R.current.scrollIntoView({block:"nearest"})};return Q.addEventListener("resize",W),()=>Q.removeEventListener("resize",W)},[]);const U=(Q,W)=>c({a:"card-draft",id:n,card:{id:e.id,draft:Q,current:W}}),F=o_(),B=Q=>{if(F)return;if(i){Q&&i(Q);return}const W=Q?w:[],ye={t:"agent-answer",worktreeId:n,askId:e.id,...Q?{answers:Q}:{}};W.some(Ti)?c({a:"hold-send",id:g,log:n,text:Hk(m,Q).join(`
243
- `),frame:ye}):(l==null||l.send({...ye,...W.length?{attachments:W.map(Sl),boxId:g,clientId:h}:{}}),W.length&&c({a:"clear-attachments",id:g})),c({a:"answered",id:n})},X=()=>c(i?{a:"ask-revive",id:n}:{a:"card-park",id:n,cardId:e.id}),ae=()=>{Yd(m,x)&&B(x)},Y=Q=>{P(ml(m[Q],x[Q])),U(x,Q)},ne=Q=>{j!=null&&j.note&&(U(wb(x,T,Q,O),T),requestAnimationFrame(()=>{var W;return(W=R.current)==null?void 0:W.focus()}))},C=Q=>{if(!(j!=null&&j.note))return;const W=j.options[Q];if(P(Q),!W||O)return ne(!W);U(wb(kb(x,T,W.value,!1),T,!1,!1),T),requestAnimationFrame(()=>{var ye;return(ye=R.current)==null?void 0:ye.focus()})},H=()=>C(I),V=Q=>{if(jL(j,Q))return P(Q),ne(!0);const W=j==null?void 0:j.options[Q];if(!j||!W)return;const ye=kb(kf(x,T),T,W.value,O);if(O){P(Q),U(ye,T);return}const _e=yb(m,ye,T);P(_e.cursor),U(ye,_e.current),_e.send&&Yd(m,ye)&&B(ye)},J=()=>{var W;const Q=kf(x,T);Q!==x&&(U(Q,T),P(ml(j,Q[T]))),(W=r.current)==null||W.focus()},Z=()=>{var ye;const Q=kf(x,T);if((ye=r.current)==null||ye.focus(),!El(Q[T])){Q!==x&&(U(Q,T),P(ml(j,Q[T])));return}const W=yb(m,Q,T);P(W.cursor),U(Q,W.current),W.send&&Yd(m,Q)&&B(Q)},ie=Q=>{if(y.onPasteKey(Q),!fy(Q,{count:N?m.length:TL(j),cursor:N?void 0:I,spacePicks:O,onCursor:P,onPick:W=>N?Y(W):V(W),onSubmit:ae,onEscape:X,onFieldEnter:Z,onFieldLeave:J})){if(Q.key==="ArrowLeft"||Q.key==="ArrowRight"||Q.key==="Tab"){Q.preventDefault();const W=Q.key==="ArrowLeft"||Q.key==="Tab"&&Q.shiftKey;return Y(OL(T,W?-1:1,PL(m)))}if(Q.key==="n"&&(j!=null&&j.note))return Q.preventDefault(),H();if(Q.key==="s"&&!i)return Q.preventDefault(),B()}},be=Q=>m.length===1&&!Q.multi,ge=(Q,W)=>d.jsxs(U7,{children:[(!Q||!be(Q))&&d.jsx(De,{variant:"outline",size:"md",disabled:F||!Yd(m,x),onClick:ae,children:"send"}),(Q==null?void 0:Q.note)&&W&&W.selected.length>0&&W.note===void 0&&d.jsxs(De,{tone:"quiet",size:"md",onClick:()=>ne(!1),children:[d.jsx(es,{k:"n",chip:!0}),"add a note"]}),!i&&d.jsxs(De,{tone:"quiet",size:"md",onClick:()=>B(),children:[d.jsx(es,{k:"s",chip:!0}),"skip"]}),d.jsx(Ot,{className:"card-attach",icon:"attach",tone:"chrome",label:"Attach a picture or a file",onClick:()=>R_(u,g)})]}),we=w.length>0&&d.jsx(Mh,{children:d.jsx("div",{className:"card-chips",children:Sk(w,o).map(([Q,W])=>{const ye=()=>c({a:"detach",id:g,key:Q.key});return Q.kind==="pick"?null:d.jsx(Mj,{item:Q,n:W,onRemove:ye},Q.key)})})}),pe=(Q,W)=>{const ye=W===T,_e=x[W],ve=cS(_e,!!Q.multi),ce=me=>({ref:ye?R:void 0,value:(_e==null?void 0:_e.note)??"",placeholder:me,enterKeyHint:gl(m)===-1?"send":"next",onChange:Ue=>U(Mf(x,W,Ue),W),...gl(m)===-1?{onSend:Z}:{}}),Se=Q.options.map(me=>{const Ue=!!(_e!=null&&_e.selected.includes(me.value));return{label:d.jsxs(d.Fragment,{children:[Wk(me.label),LL(me.label)&&d.jsx("span",{className:"badge-recommended",children:"recommended"})]}),description:me.description,sample:me.preview,hint:Q.note&&!Q.multi?{k:"n",label:"add a note",icon:"edit",on:(_e==null?void 0:_e.note)===void 0}:void 0,checked:Ue,field:Ue&&!ve&&(_e==null?void 0:_e.note)!==void 0?ce("a note for the agent, sent with your pick"):void 0}});return Q.note&&Se.push({label:Q.note.label,description:ve?void 0:"your own answer",checked:ve,field:ve?ce("your own answer"):void 0}),d.jsxs("div",{className:He("card-page",!ye&&"card-page-off"),children:[d.jsx(hu,{children:Q.text||f}),ye&&we,d.jsx(fu,{rows:Se,cursor:ye?I:void 0,onCursor:me=>{P(me),Xf(r)},onPick:me=>{var Ue;V(me),(Ue=r.current)==null||Ue.focus()},onHint:C}),ge(Q,_e)]},Q.id)};return d.jsxs(Qf,{root:r,id:e.id,onKeyDown:ie,onKeyUp:y.onPasteKeyUp,onPaste:y.onPaste,children:[m.length>1&&d.jsx("div",{className:"card-tabs",children:d.jsx(Ah,{label:"questions",owner:"ask",items:[...m.map((Q,W)=>({id:String(W),label:Q.header||`question ${W+1}`,lead:d.jsx("span",{className:He("dot card-step",El(x[W])&&"answered")})})),{id:String(m.length),label:"send",far:!0}],current:String(T),onPick:Q=>{var W;Y(Number(Q)),(W=r.current)==null||W.focus()}})}),d.jsxs("div",{className:"card-pages",children:[m.map(pe),gl(m)!==-1&&d.jsxs("div",{className:He("card-page",!N&&"card-page-off"),children:[d.jsx(hu,{children:"Send these answers?"}),N&&we,d.jsx(fu,{hover:!0,rows:m.map((Q,W)=>{const ye=El(x[W])?CL(Q,x[W]):void 0;return{label:d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"row-dim",children:Q.header||`question ${W+1}`})," ",d.jsx("span",{className:He(!ye&&"row-dim"),children:ye?ye.pick:"no answer yet"})]}),description:ye==null?void 0:ye.note}}),onPick:Q=>{var W;Y(Q),(W=r.current)==null||W.focus()}}),ge()]})]})]})}const V7=H_("top"),Y7=5*6e4;function Fj({usage:e,limits:t,auth:n,now:r}){const o=t?P5(t,r):[],i=o.length?j5(n):void 0,l=t&&r-t.at>Y7?Yk(r-t.at):null,c=(e==null?void 0:e.cost)!==void 0?` · ${Su(e.cost)}`:"";return d.jsxs("div",{className:"usage-figures",children:[e&&d.jsx(y1,{name:"context",used:e.used/e.size,sub:`${ux(e.used)} of ${ux(e.size)}${c}`}),i&&d.jsx("div",{className:"usage-who section-title",children:i}),o.map(u=>d.jsx(y1,{name:u.name,used:u.used,sub:u.sub},u.key)),l&&d.jsxs("div",{className:"usage-stale hint",children:["read ",l," ago"]})]})}function X7({onClose:e,...t}){return d.jsx(Ls,{className:"usage-panel",anchor:"parent",placement:V7,onDismiss:e,onKey:n=>{n.key==="Escape"&&(n.stopPropagation(),e())},children:d.jsx(Fj,{...t})})}function y1({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 Bj(e,t,n){const r=S.useRef(n);r.current=n,ft([e,t,n==null?void 0:n.id],()=>{if(!e||!t)return;const o=()=>{const i=r.current;i!=null&&i.available&&e.send({t:"agent-check",agent:i.id})};return o(),window.addEventListener("focus",o),()=>window.removeEventListener("focus",o)})}const v1="not answering; send once Toyon is back",b1=[],Q7=[],J7=new Set(["ArrowLeft","ArrowRight","Home","End","PageUp","PageDown"]),eH=150,tH=3,x1=e=>({kind:"cmd",c:e});function nH(e,t){var r;const n=e.after;return"id"in n?n.branch:((r=t.find(o=>o.proposalId===e.proposalId&&o.pieceId===n.piece))==null?void 0:r.title)??"another piece"}function rH(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 oH(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 Kc({active:e,draft:t,archived:n,found:r,project:o,greenfield:i,placement:l="dock"}){var qu,Gu,Vu,Yu,Xu,Xr,Qs;const c=l==="screen",u=ct(),h=rt(),{storage:f}=mo(),m=Gn(),g=!!t,w=(e==null?void 0:e.worktree.id)??null,y=e==null?void 0:e.worktree.repoId,v=o?Al:n?n.id:r?r.id:Ul(e),_=!!n||!!r,x=n?n.restorable:!!r&&!r.locked,T=Rt(v,"draft"),N=Rt(v,"attachments"),j=Rt(v,"notice"),$=((qu=e==null?void 0:e.worktree.owns)==null?void 0:qu.join(", "))??"",O=S.useRef({id:w,owns:$});ft([w,$],()=>{const D=O.current;O.current={id:w,owns:$},!(D.id!==w||D.owns===$||!$||!v||n)&&u({a:"notice",id:v,text:`Running its own ${$} here now: this branch changed it.`})});const I=Rt(v,"mark"),P=(I==null?void 0:I.by)==="walk"?I:void 0,R=Rt(w,"chat"),U=Rt(w,"queue"),F=S.useMemo(()=>w&&!g?vw(R):null,[w,g,R]),B=Rt(w,"cardParked"),X=Rt(w,"sending"),ae=S.useMemo(()=>w&&!g&&!X?lS(R):null,[w,g,X,R]),Y=Rt(w,"askRevived"),ne=!F&&ae&&Y===ae.id?ae:null,C=F&&B!==F.id?F:ne,H=ne?bl(ne.id):null,V=Rt(H,"attachments"),J=F?B===F.id?F:null:ae&&!ne?ae:null,Z=S.useRef(null),ie=Na(),be=fw(),ge=Rt(be,"page"),we=bu(),pe=OD(),Q=dj(),W=CU(),ye=O7(),_e=S.useMemo(()=>w&&!g?A7(R,{queued:U.length,sending:!!X,card:!!(C||J),dismissed:ye}):null,[w,g,R,U.length,X,C,J,ye]),ve=D=>v&&u({a:"set-draft",id:v,text:D}),ce=L(D=>D.clientId),Se=L(D=>D.repos),me=L(D=>D.repos.find(ze=>ze.id===(e==null?void 0:e.worktree.repoId))??null),Ue=L(D=>D.defaultAgent),Ie=L(D=>D.agentChosen),We=g||!!i||!!o,mt=!We&&!!e&&!e.worktree.agent,en=We||mt,Kt=(t==null?void 0:t.agent)??Ue,Be=L(D=>D.agents.find(ze=>ze.id===(en?Kt:e==null?void 0:e.worktree.agent)));Bj(h,w??(We?"new":null),Be);const Xt=!!(Be!=null&&Be.quick),ln=(Be==null?void 0:Be.models)??b1,It=(Be==null?void 0:Be.efforts)??b1,Je=Be==null?void 0:Be.defaultModel,Vt=Be==null?void 0:Be.defaultEffort,[tn,ht]=GU(Kt),[gt,sn]=KU(Kt),kn=L(D=>D.agents),Pt=(D,ze)=>{if(D===Kt){ht(ze);return}VU(f,D,ze),Rn(D)},Rn=D=>{g?u({a:"draft-agent",id:D}):h==null||h.send({t:"set-default-agent",agent:D})},bt=C7(Be,kn,en),ee=bt==null?void 0:bt.other,ke=Rt(w,"model"),Xe=Rt(w,"effort"),Ge=Rt(w,"usage")??(e==null?void 0:e.usage),[Zt]=kj(me),Bt=(t==null?void 0:t.profile)??Zt,[mn,an]=ZU(me),xn=(e==null?void 0:e.worktree.mode)??_f,M=L(D=>D.picking),re=L(D=>D.layout.term),Ne=pS((e==null?void 0:e.procs)??[]),Ze=wn("composer"),jt=Rt(w,"files"),Ut=S.useMemo(()=>kS(jt??Q7),[jt]),Me=L(D=>D.visible),Pe=S.useMemo(()=>Wh(Me,y,w),[Me,y,w]),Ve=L(D=>y?D.archived[y]:void 0),Lt=S.useMemo(()=>vT(Pe,Ve),[Pe,Ve]),qt=S.useMemo(()=>yT(jt,Lt),[jt,Lt]),zn=S.useMemo(()=>[...Pe,...(Ve??[]).map(D=>({title:D.title,branch:D.branch,dir:D.path.slice(D.path.lastIndexOf("/")+1)}))],[Pe,Ve]),et=Rt(w,"git"),Ht=(et==null?void 0:et.files.length)??(e==null?void 0:e.dirty)??0,On=(et==null?void 0:et.unpushed)??(e==null?void 0:e.unpushed)??0,dn=L(D=>{var ze;return w?(ze=D.shipping[w])==null?void 0:ze.op:void 0}),sr=L(D=>{var ze;return w?(ze=D.shipping[w])==null?void 0:ze.step:void 0}),Fn=L(D=>Il(D,y)),hr=L(D=>{var ze;return Fn?(ze=D.shipping[Fn.id])==null?void 0:ze.op:void 0}),oe=Fn&&me&&We?pN(me.defaultBranch,Fn):null,Le=L(D=>g?ZL(D.rows,y,Kt,Ue):w),Ye=Rt(Le,"commands"),$t=Ye.some(D=>D.name==="compact"),pt=Fo(e==null?void 0:e.agent),yn=L(D=>SS(D,w)),Tr=pt&&!!w&&!g,ir=e==null?void 0:e.worktree.lastTurn,Wt=!T.trim()&&N.length===0,Yr=!g&&!i&&Wt&&!pt?ir:void 0,dt=!g&&!i&&e&&ca(e.worktree)?e.worktree.landing:void 0,Bn=!!(dt!=null&&dt.ready)&&!dt.stale&&!Jd(dt,Ht,Xt,Be==null?void 0:Be.name),st=Wt&&(!pt||Bn)?dt:void 0,Te=Ht>0&&!!(st!=null&&st.subject),qe=Ht||(((Gu=et==null?void 0:et.extras)==null?void 0:Gu.committed.length)??0),xt=!g&&!i&&Wt&&!pt&&!!e,at=!!(e!=null&&e.worktree.landed)&&Ht===0,fn=xt&&at,Ft=e?ih({...e.worktree,landed:at}):void 0,cn=xt&&!fn?Ft:void 0,Hr=!at&&(Ft==null?void 0:Ft.state)==="open"?Ft:void 0,$n=!!Hr&&(Ht>0||On>0),Un=(Ft==null?void 0:Ft.state)==="closed",yr=bi((me==null?void 0:me.config)??{}),Hn=S.useMemo(()=>P7(Nf(bi((me==null?void 0:me.config)??{}),me==null?void 0:me.defaultBranch)),[me]),G=()=>w&&(h==null?void 0:h.send({t:"chat",worktreeId:w,text:"/compact"})),fe=We?"nothing to compact until the first reply":$t?pt?"wait for the turn to end":void 0:"this agent offers no compact command",tt=$t&&Ge?C5(Ge.used/Ge.size):void 0,kt=Be==null?void 0:Be.limits,Nt=We?void 0:Ge,vn=(!!w||We)&&!!(Nt||kt),Wn=Date.now(),[ar,jr]=S.useState(!1),Gt=S.useRef(0),Et=ie?()=>d.jsx(Fj,{usage:Nt,limits:kt,auth:Be==null?void 0:Be.auth,now:Date.now()}):void 0,To=()=>{window.clearTimeout(Gt.current),jr(!1)};ft([w],To);const Nn=hw(),Qt=(Nn==null?void 0:Nn.owner)==="composer"&&Nn.key==="usage";ft([Qt],()=>{Qt&&To()});const Wr=()=>[{id:"compact",label:"compact the context",detail:fe||!Ge?void 0:$5(Ge.used/Ge.size),disabled:fe,onClick:G}],[Rr,je]=S.useState(0),[z,K]=S.useState(null),[le,xe]=S.useState(null),Re=S.useRef(null),$e=v&&!_&&!o?Hm(T,Rr,D=>Pe.some(ze=>r1(D,ze))):null,Ct=$e==null?void 0:$e.kind,nn=$e==null?void 0:$e.query,er=S.useMemo(()=>{if(nn===void 0)return[];if(Ct==="command")return nn.trim()?L8(D7(Hn,Ye),nn).slice(0,8).map(x1):k1(Hn,Ye).rows.map(x1);const D=[],ze=(et==null?void 0:et.files.length)??0;ze>0&&"changes".startsWith(nn.toLowerCase())&&D.push({kind:"changes",n:ze});const Tt=nn.trim(),At=Tt?Pe.filter(Vn=>r1(Tt,Vn)):Pe.slice(0,tH);return D.push(...At.map(Vn=>({kind:"worktree",...Vn}))),D.push(...S7(jt??[],Ut,(et==null?void 0:et.files)??[],nn,8)),D},[Ct,nn,jt,Ut,et,Ye,Hn,Pe]),Cn=$e!==null&&$e.from!==z&&!P&&!($e.kind==="file"&&M8(T,$e.from,qt)),zs=Ct==="command"&&nn!==void 0&&!nn.trim()?k1(Hn,Ye).more:0,bn=S.useRef(null),Ri=S.useRef(null),$a=S.useRef(null),ju=(D,ze,Tt,At)=>{var Hi;const{text:Vn,caret:rr}=E_(T.slice(0,ze)+T.slice(Tt),ze,At);ve(Vn),K(((Hi=Hm(Vn,rr))==null?void 0:Hi.from)??null),requestAnimationFrame(()=>{D.focus(),D.setSelectionRange(rr,rr),je(rr)})},Fs=D=>{const ze=bn.current;return!D||!ze?!1:(ju(ze,ze.selectionStart,ze.selectionEnd,D),!0)},{onPaste:Oi,onPasteKey:Bs,onPasteKeyUp:Ca}=L_(v,w,D=>Fs(ej(D,zn)));Bz(Ri,bn,D=>Fs(AB(D,zn)));const Aa=()=>{var D;return(D=Z.current??bn.current)==null?void 0:D.focus()},ys=Aa;ft([i?e==null?void 0:e.worktree.id:null],()=>{if(!i)return;const D=requestAnimationFrame(()=>{var Tt;const ze=document.activeElement;(!ze||ze===document.body)&&((Tt=bn.current)==null||Tt.focus())});return()=>cancelAnimationFrame(D)});const Us=L(D=>D.focusChat),Mi=S.useRef(Us),Hs=!!a_();ft([Us],()=>{if(Us===Mi.current||(Mi.current=Us,Hs!==!!i))return;const D=requestAnimationFrame(Aa);return()=>cancelAnimationFrame(D)});const Pi=C==null?void 0:C.id,Uo=S.useRef({id:w,cardUpId:Pi});ft([w,Pi],()=>{const D=Uo.current;if(Uo.current={id:w,cardUpId:Pi},Pi||!D.cardUpId||D.id!==w||Hs!==!!i||ie&&!J)return;const ze=requestAnimationFrame(()=>{var At;const Tt=document.activeElement;(!Tt||Tt===document.body)&&((At=bn.current)==null||At.focus())});return()=>cancelAnimationFrame(ze)});const Ws=L(D=>D.walked),Li=S.useRef(Ws);ft([Ws],()=>{if(Ws===Li.current||(Li.current=Ws,Hs!==!!i))return;const D=requestAnimationFrame(()=>{const ze=document.activeElement;(!ze||ze===document.body||ze.closest(".rail"))&&Aa()});return()=>cancelAnimationFrame(D)});const Ia=q_({results:er,keyOf:D=>D.kind==="cmd"?`c:${D.c.name}`:D.kind==="changes"?"changes":D.kind==="worktree"?`w:${D.id}`:`f:${D.path}`,q:($e==null?void 0:$e.query)??"",listRef:Re,tabPicks:!0,onPick:D=>{if(!$e)return;const{text:ze,caret:Tt}=P8(T,$e,oH(D));ve(ze),K($e.from),xe(D.kind==="cmd"&&D.c.hint?{name:D.c.name,hint:D.c.hint}:null),requestAnimationFrame(()=>{const At=bn.current;At&&(At.focus(),At.setSelectionRange(Tt,Tt),je(Tt))})}}),pr=w||_?XB(T):null,Ra=le&&T===`/${le.name} `?le.hint:null,$u=pr===""&&e?g?" 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,$r=Ra??$u,is=(e==null?void 0:e.worktree.title)??"untitled",as=(Vu=ir==null?void 0:ir.recap)==null?void 0:Vu.text,vs=()=>{w&&Si(h,u,{t:"land",worktreeId:w})},Cu=D=>{w&&(h==null||h.send({t:"judge",worktreeId:w,...D?{note:D}:{}}))},ql=!!((Yu=me==null?void 0:me.config.check)!=null&&Yu.trim()),Di=jw(dt,Ht,Xt),zi=xt&&!dn&&!We&&ca(e.worktree)&&!at&&!Un&&qe>0&&(!dt||!!dt.stale||Di==="unanswered"),Fi="Archive this worktree when you are done here; the rail's archived section brings it back with its chat.",Au=$n?"update":Tk(yr,(e==null?void 0:e.worktree)??{}),Iu=me?sh(me):"main",Yh=$n&&Hr?`Commit, take ${Iu} in and push the branch; PR #${Hr.number} takes the new commits.`:`${Nf(yr,me==null?void 0:me.defaultBranch)}.`,Ru=cn&&!as?{links:J3(cn)}:{},vr=w?fn?{word:"archive",kind:"archive",line:(Ft==null?void 0:Ft.state)==="merged"?Cs(Ft):`landed on ${(me==null?void 0:me.defaultBranch)??"main"}.`,tip:Fi,run:()=>Nl(h,u,[w])}:(cn==null?void 0:cn.state)==="open"&&!$n?wN(cn)?{word:"land",kind:"merge",line:ef(as??Cs(cn)),tip:`${Cs(cn)} Merge the PR now, by the method the repo allows.`,...Ru,run:vs,ships:!0}:{word:"view",kind:"view",line:ef(as??Cs(cn)),tip:`${Cs(cn)} Open the PR on GitHub.`,...Ru,run:()=>window.open(cn.url,"_blank")}:(cn==null?void 0:cn.state)==="closed"?{word:"archive",kind:"archive",line:Cs(cn),tip:`${Cs(cn)} ${Fi}`,run:()=>Nl(h,u,[w])}:zi?{word:"check",kind:"check",line:(dt==null?void 0:dt.subject)??ef(as??o5(qe)),tip:yN(dt,ql,Di),run:Cu}:st!=null&&st.ready&&!Jd(st,Ht,Xt,Be==null?void 0:Be.name)?{word:Au,kind:"ship",line:st.subject??ef(as??(ex(st,qe)||"ready")),tip:[ex(st,qe),r5(Iu,e==null?void 0:e.behind),Yh,st.subject&&Ht>0?"Tab from the word edits the message first.":""].filter(Boolean).join(" "),run:vs,ships:!0}:null:null,Ou=(Xu=e==null?void 0:e.worktree.lands)==null?void 0:Xu.at(-1),Mu=Ou&&_w(Ou),Gl=((vr==null?void 0:vr.kind)==="ship"||(vr==null?void 0:vr.kind)==="check")&&st?s5(st,Di):(vr==null?void 0:vr.word)==="archive"&&Mu?ho(Mu):null,Vl=S.useRef(null);dn!=="land"&&(Vl.current=w&&(vr!=null&&vr.ships)?{id:w,verb:vr,under:Gl}:null);const Oa=dn==="land"&&Wt&&((Xr=Vl.current)==null?void 0:Xr.id)===w?Vl.current:null,An=Oa?Oa.verb:vr,Pu=(Qs=An==null?void 0:An.links)!=null&&Qs.length?e5(An.line,An.links):null,Ma=!!(An!=null&&An.ships)&&dn==="land",Yl=aw(sr,lw),Pa=ru(e,"commit"),Ks=ru(e,"check"),Zs=bN(Ma?Pa:Ks),Lu=Ei(Cw(Zs)?Zs==null?void 0:Zs.since:void 0),Xl=st?st.check==="pending"&&Ks&&Zs===Ks?Bf("Checking the work",Ks,Lu):Jd(st,Ht,Xt,Be==null?void 0:Be.name):null,La=An&&Ma?Yl?`${An.word}: ${Yl}`:`${An.word} ${An.line}`:null,Du=La&&Pa&&Zs===Pa?Bf(La,Pa,Lu):La,zu=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?An?"":Xl||(cn?Cs(cn):Yr?$w(Yr):i?`describe ${is}…`:We?"describe a change":c?`message agent on ${is}`:`message agent on ${is}; / for a command, ! for a shell command`):"no worktree selected",Da=T!==""||$r||!e?null:Ma?Yl?null:Oa?Oa.under:Gl:An?Gl:cn||Xl?as??(st==null?void 0:st.subject)??null:null,Fu=S.useRef(!1);S.useEffect(()=>{const D=Cn&&!Fu.current;Fu.current=Cn,D&&(($e==null?void 0:$e.kind)==="file"&&w?Th(w,m.getState(),{sock:h,dispatch:u}):($e==null?void 0:$e.kind)==="command"&&Le&&Ye.length===0&&(h==null||h.send({t:"list-commands",worktreeId:Le})))},[Cn,$e==null?void 0:$e.kind,Ye.length,w,Le,h,m,u]);const Bu=()=>{if(!e)return;const D=[],ze=ge;if(ze.url)try{const Vn=new URL(ze.url);D.push(`current route: ${Vn.pathname}${Vn.search}`)}catch{}ze.title&&D.push(`page title: ${ze.title}`);const Tt=[];i&&Tt.push(MU(e.worktree.title,me==null?void 0:me.configFile)),D.length>0&&Tt.push(`What the user is looking at right now:
244
- ${D.join(`
245
- `)}`);const At=JB(R);return At&&Tt.push(At),Tt.length>0?Tt:void 0},Uu=D=>{We?an(D):w&&D!==xn&&(h==null||h.send({t:"set-worktree-mode",worktreeId:w,mode:D}))},tr=D=>v&&u({a:"notice",id:v,text:D}),ls=o_(),Xh=(D,ze="")=>{if(!e||!w)return;if(D==="split"){if(We)return tr("a new worktree has nothing to continue yet");const At=L7(ze,Se,e.worktree.repoId);"pick"in At?u({a:"open",overlay:{kind:"split",worktreeId:w}}):"error"in At?tr(At.error):h==null||h.send({t:"pieces-ask",worktreeId:w,repoId:At.repo.id,...At.text?{text:At.text}:{}});return}if(D==="archive"){at||Un?Nl(h,u,[w]):tr("archive is for a landed worktree; this one has not landed");return}if(D==="check"){We||!ca(e.worktree)?tr("nothing to check from here"):pt?tr("wait for the turn to end"):qe===0?tr("nothing to check: no changes here"):Cu(ze||void 0);return}const Tt=dt?Jd(dt,Ht,Xt,Be==null?void 0:Be.name):null;We||!ca(e.worktree)?tr("nothing to land from here"):at?tr(`already landed on ${(me==null?void 0:me.defaultBranch)??"main"}`):Tt?tr(Tt):pt&&(!dt||dt.stale)?tr("wait for the turn to end"):dt!=null&&dt.stale?tr("the work changed since this was checked; check again first"):vs()},Bi=N.some(Ti),Ql=()=>{var D;ie&&((D=bn.current)==null||D.blur())},qs=()=>{v&&(h==null||h.send({t:"set-draft",boxId:v,text:T,clientId:ce})),Ql()},Gs=(D,ze,Tt,At)=>{u({a:"hold-send",id:D,log:ze,text:Tt,frame:At}),Ql()},za=()=>{if(!v)return;const D=z7(T,Hn),ze=D&&M7(D.name)?D.name:void 0;if(o){if(o.busy)return;if(ls)return tr(v1);if(o.why)return tr(o.why);(Kt!==Ue||!Ie)&&(h==null||h.send({t:"set-default-agent",agent:Kt})),qs(),o.create();return}if(Wt)return;if(ls&&!(ze&&!(D!=null&&D.args)))return tr(v1);const Tt=pr===null&&(!D||!!ze&&!!D.args);if(bt&&bt.kind!=="unready"&&Be&&Tt){tr(bt.kind==="installing"?`${Be.name} is still installing`:bt.retry?`nothing runs here until ${Be.name} is installed`:bt.text);return}const At=Hx(T.trim(),qt),Vn=()=>({text:At,attachments:N.length?N.map(Sl):void 0});if(n){if(!n.restorable)return;if(pr!==null){tr("nothing runs here until it is restored");return}const Qr={t:"restore-worktree",archiveId:n.id,clientId:ce};if(Bi)return Gs(v,v,At,Qr);qs(),h==null||h.send(Mc(Qr,v,At,N)),u({a:"sending",id:v,message:Vn()}),u({a:"sent-box",id:v});return}if(r){if(r.locked)return;if(pr!==null){tr("nothing runs here until Toyon takes it over; its menu on the rail opens a shell");return}const Qr={t:"adopt-worktree",worktreeId:r.id,clientId:ce};if(Bi)return Gs(v,v,At,Qr);qs(),h==null||h.send(Mc(Qr,v,At,N)),u({a:"sending",id:v,message:Vn()}),u({a:"sent-box",id:v});return}if(!e||!w)return;if(pr!==null){if(pr&&dn&&!g){tr(`${kA(dn)} is running here; run the command once it is done`);return}pr&&g?u({a:"term-run",id:w,command:pr}):pr&&(h==null||h.send({t:"exec",worktreeId:w,command:pr})),ve("");return}if(D&&!ze){Xh(D.name,D.args),ve("");return}if(ze&&!(D!=null&&D.args)){Uu(ze),ve("");return}const rr=D?Hx(D.args,qt):At,Hi=Bu(),bs=N.length?N.map(Sl):void 0;if(ze&&Uu(ze),We){const Qr=ku(e.worktree)?{worktreeId:w}:{},Wi={clientId:ce,repoId:e.worktree.repoId,context:Hi,agent:Kt,profile:Bt,mode:ze??mn,...tn?{model:tn}:{},...gt?{effort:gt}:{},...t!=null&&t.carry?{carry:!0}:{}};(Kt!==Ue||!Ie)&&(h==null||h.send({t:"set-default-agent",agent:Kt}));const Ba={t:"create-worktree",...Wi,...Qr};Bi?Gs(v,v,rr,Ba):(qs(),h==null||h.send(Mc(Ba,v,rr,N)),u({a:"sending",id:v,message:{text:rr,attachments:bs}}),u({a:"sent-box",id:v}))}else{mt&&(h==null||h.send({t:"set-worktree-model",worktreeId:w,model:tn}),h==null||h.send({t:"set-worktree-effort",worktreeId:w,effort:gt}));const Qr={t:"chat",worktreeId:w,clientId:ce,context:Hi};Bi?Gs(v,w,rr,Qr):(qs(),h==null||h.send(Mc(Qr,v,rr,N)),yn||u({a:"sending",id:w,message:{text:rr,attachments:bs}}),u({a:"sent-box",id:v}))}i&&u({a:"show-chat"})},Vs=D=>{if(!w||(ne==null?void 0:ne.ask.kind)!=="question")return;if(!D.some(El))return u({a:"ask-revive",id:w});const ze=Hk(ne.ask.questions,D).join(`
246
- `),Tt={t:"chat",worktreeId:w,clientId:ce,context:Bu()};if(H&&V.some(Ti))Gs(H,w,ze,Tt);else{const At=V.length?V.map(Sl):void 0,Vn=At&&H?{attachments:At,boxId:H}:{};h==null||h.send({...Tt,text:ze,...Vn}),At&&H&&u({a:"clear-attachments",id:H}),u({a:"sending",id:w,message:{text:ze,attachments:At}})}u({a:"answered",id:w}),u({a:"ask-revive",id:w})},Jl=L(D=>D.autoSend);ft([Jl,w],()=>{!Jl||Jl!==w||Wt||Hs!==!!i||(u({a:"auto-sent"}),za())});const Qh=()=>{const D=N[N.length-1];return!v||!D?!1:(u({a:"detach",id:v,key:D.key}),!0)},Hu=D=>{v&&(u({a:"walk",id:v,walk:D.walk,text:D.text}),requestAnimationFrame(()=>{var ze;(ze=bn.current)==null||ze.setSelectionRange(D.text.length,D.text.length),je(D.text.length)}))},ec=()=>{v&&P&&u({a:"walk",id:v,walk:null,text:T})},tc=We?[]:vS(R),Ys=We?[]:U.flatMap(D=>D.attachments??[]),jo=e==null?void 0:e.worktree.plan,Jh=ay(e==null?void 0:e.worktree.id,jo),Xs=(e==null?void 0:e.worktree.queued)??[],Wu=Tr&&!C,Ku=L(D=>D.reading),[Ui,Fa]=S.useState(!1),nc=c&&!J&&(C?!Ui:Wt&&!pe),rc=nc&&Ku;S.useEffect(()=>{if(c)return u({a:"typing",on:Ui}),()=>u({a:"typing",on:!1})},[c,Ui,u]);const Zu=D=>{if(!rc||D.target instanceof Element&&D.target.closest("button, a, [role=button]"))return;const ze=D.currentTarget.closest(".chat-log");ze&&(ze.scrollTop=ze.scrollHeight)};return d.jsxs("div",{ref:Ri,className:He("composer chat-input",Wu&&"stopping",nc&&"foldable",rc&&"lean"),onClick:Zu,onFocus:D=>Fa(D.target instanceof HTMLTextAreaElement),onBlur:()=>Fa(!1),children:[jo&&e&&d.jsxs("div",{className:"composer-plan",...Ze.contextMenu(()=>Ow(jo,()=>h==null?void 0:h.send({t:"reveal",worktreeId:e.worktree.id,path:jo}),rs(h))),children:[d.jsx(_t,{name:"text",className:"icon-inline"}),d.jsx(De,{variant:"inline",className:"composer-plan-path","data-tip":jo,onClick:()=>Ln({dispatch:u},{worktreeId:e.worktree.id,path:jo,view:"preview"}),children:Jh})]}),J&&w&&d.jsx(Rc,{icon:"chat",verb:"answer",tip:"Bring the question back into the box",onPress:()=>{u(J.kind==="ask"&&J.outcome?{a:"ask-revive",id:w,askId:J.id}:{a:"card-unpark",id:w}),u({a:"focus-chat"})},children:wz(J)}),(_e==null?void 0:_e.verb)==="fix"&&"toolId"in _e&&w&&d.jsxs(Rc,{icon:"run",verb:_e.verb,tip:"Send the agent what it printed and ask for a fix",onPress:()=>h==null?void 0:h.send({t:"fix",worktreeId:w,toolId:_e.toolId}),onDismiss:()=>g1(_e.key),children:["what failed in ",d.jsx("code",{children:_e.command})]}),(_e==null?void 0:_e.verb)==="continue"&&w&&d.jsx(Rc,{icon:"send",verb:_e.verb,tip:_e.after==="stop"?"Send the agent on from where its turn stopped":_e.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:w}),onDismiss:()=>g1(_e.key),children:_e.after==="stop"?"where it stopped":_e.again?"after the same error again":"after the error"}),pe&&v&&!C&&(e||x||o)&&d.jsx(Rc,{icon:"copy",verb:"attach",tip:"Attach it, as a paste would",onPress:()=>{Rz(m,v,pe),Aa()},onDismiss:l_,children:pe.kind==="image"?"the image you copied":`the text you copied, ${pe.text.split(`
247
- `).length} lines`}),Q&&w&&!g&&!C&&AU({prompt:Q,offered:W,agent:e==null?void 0:e.agent,chat:R})&&d.jsx(Rc,{icon:"download",verb:"install",tip:"Install Toyon as an app: a window of its own, with a Dock icon and no browser bar",onPress:()=>{l1(),Q.prompt()},onDismiss:l1,children:"Toyon as a window of its own, with a Dock icon and no browser bar"}),v&&!C&&pr===null&&d.jsx(Mh,{children:Sk(N,Fc(sg(tc),Ys)).map(([D,ze])=>{const Tt=()=>u({a:"detach",id:v,key:D.key});return D.kind!=="pick"?d.jsx(Mj,{item:D,n:ze,onRemove:Tt},D.key):d.jsx(Zh,{pick:D,tipText:D.html,onHover:At=>be&&un.post(be,At?{type:"highlight-selector",selector:D.selector,label:Vk(D)}:{type:"highlight-clear"}),worktreeId:w,onOpen:(At,Vn)=>w&&ga(m,h,w,At,Vn),onRemove:Tt},D.key)})}),Cn&&$e&&d.jsx(RU,{results:er,keyOf:D=>D.kind==="cmd"?`c:${D.c.name}`:D.kind==="changes"?"changes":D.kind==="worktree"?`w:${D.id}`:D.kind==="folder"?`d:${D.path}`:`f:${D.path}`,rowClass:D=>D.kind==="file"||D.kind==="folder"?"qo-file":D.kind==="changes"||D.kind==="worktree"?"picker-row":"picker-row picker-cmd",nav:Ia,listRef:Re,empty:rH($e.kind,jt,Ye.length,Le!==null),note:zs>0?`type to find ${zs} more`:void 0,groupOf:D=>D.kind==="worktree"?"worktrees":D.kind==="cmd"?"commands":"files",row:D=>{const ze=((et==null?void 0:et.files.length)??0)>0;return D.kind==="file"?ak(D.path,D.status,$e.query,{gutter:ze}):D.kind==="folder"?ak(D.path,void 0,$e.query,{folder:!0,gutter:ze}):D.kind==="changes"?d.jsx(jn,{label:"@changes",hint:`${D.n} uncommitted ${D.n===1?"file":"files"}`}):D.kind==="worktree"?d.jsxs(d.Fragment,{children:[d.jsx("span",{className:`dot ${D.dot}`}),d.jsx(jn,{label:D.title,hint:ur(D.at)})]}):d.jsx(QU,{c:D.c,query:$e.query})}}),C&&w?C.kind==="pieces"?d.jsx(q7,{item:C,worktreeId:w,rootRef:Z},C.id):C.ask.kind==="question"?d.jsx(G7,{item:C,ask:C.ask,worktreeId:w,rootRef:Z,numbers:Fc(sg(tc),Ys),onAnswer:ne?Vs:void 0},C.id):d.jsx(K7,{item:C,ask:C.ask,worktreeId:w,rootRef:Z},C.id):d.jsxs("div",{className:He("composer-field",pr!==null&&"shell",P&&"recalled"),children:[d.jsx(nu,{size:"lg",bare:!0,font:pr!==null?"mono":"ui",ref:bn,value:T,onChange:D=>{var rr;const ze=D.target.value,Tt=D.target.selectionStart??ze.length;ve(ze),je(Tt),Ia.setIndex(0);const{inputType:At}=D.nativeEvent;K(At==="insertFromPaste"||At==="insertFromDrop"?((rr=Hm(ze,Tt))==null?void 0:rr.from)??null:null)},onKeyUp:D=>{Ca(),je(D.currentTarget.selectionStart??0)},onClick:D=>{je(D.currentTarget.selectionStart??0),ec()},onPaste:Oi,onDrop:D=>{const ze=iN(m,D);if(!ze)return;D.stopPropagation();const Tt=D.currentTarget,At=K3(Tt,D.clientX,D.clientY)??T.length;ju(Tt,At,At,ze.words)},onScroll:D=>{$a.current&&($a.current.scrollTop=D.currentTarget.scrollTop)},onKeyDown:D=>{var ze;if(Bs(D),!D.nativeEvent.isComposing){if(Cn){if(D.key==="Escape"){D.preventDefault(),D.stopPropagation(),K(($e==null?void 0:$e.from)??null);return}if(Ia.onKeyDown(D))return}if((D.key==="ArrowUp"||D.key==="ArrowDown")&&!D.altKey&&!D.ctrlKey){const Tt=D.key==="ArrowUp",At=U.at(-1);if(Tt&&!D.metaKey&&!P&&T===""&&w&&!g&&At!==void 0){D.preventDefault(),b_(m,h,w,U.length-1);return}const Vn=D.metaKey?Tt?"first":"box":Tt?"up":"down",rr=w?yU(R,P??null,T,Vn):null;if(rr){D.preventDefault(),(rr.walk!==P||rr.text!==T)&&Hu(rr);return}}if(P&&D.key==="Escape"){D.preventDefault(),D.stopPropagation(),Hu({walk:null,text:P.from});return}if(D.key==="Escape"&&pt&&w&&!g){D.preventDefault(),D.stopPropagation(),h==null||h.send({t:"stop-agent",worktreeId:w});return}if(P&&J7.has(D.key)&&ec(),D.key==="Tab"&&!D.shiftKey&&T===""){const Tt=(ze=D.currentTarget.closest(".composer"))==null?void 0:ze.querySelector(".composer-verb");if(Tt&&!Tt.disabled){D.preventDefault(),Tt.focus();return}if(Te){D.preventDefault(),u({a:"edit-commit"});return}}D.key==="Enter"&&(ie?D.metaKey||D.ctrlKey:!D.shiftKey)?(D.preventDefault(),za()):D.key==="Backspace"&&T===""&&Qh()&&D.preventDefault()}},placeholder:Da||An?"":zu,disabled:o?o.busy:!e&&!x}),$r&&d.jsxs("div",{className:"composer-ghost","aria-hidden":"true",children:[d.jsx("span",{className:"picker-typed",children:T}),$r]}),w&&pr===null&&T.includes("@")&&d.jsx("div",{ref:$a,className:"composer-ghost composer-marks","aria-hidden":"true",onClick:D=>oy(D,e==null?void 0:e.worktree.path,w,{sock:h,dispatch:u}),children:d.jsx(ry,{text:T,worktreeId:w,root:e==null?void 0:e.worktree.path,inField:!0})}),(Da||An)&&d.jsxs("div",{className:"composer-ghost composer-standing","aria-hidden":An?void 0:"true",children:[d.jsx("span",{className:He("composer-placeholder",Ma&&"live-text"),children:Du||(An?d.jsxs(d.Fragment,{children:[d.jsx(De,{variant:"inline",tone:"strong",className:"composer-verb",disabled:!!An.ships&&!!dn||ls,...zt(An.tip,void 0,{placement:"top"}),onClick:()=>{var D;An.run(),ie||(D=bn.current)==null||D.focus()},onKeyDown:D=>{D.key==="Tab"&&!D.shiftKey&&Te&&(D.preventDefault(),u({a:"edit-commit"}))},children:An.word})," ",d.jsx("span",{className:"composer-verb-line",children:Pu?Pu.map(D=>typeof D=="string"?D:d.jsxs(De,{variant:"inline",className:"composer-verb-tail",...zt(D.tip,void 0,{placement:"top"}),onClick:()=>{var ze;window.open(D.url,"_blank"),ie||(ze=bn.current)==null||ze.focus()},...Ze.contextMenu(()=>[{id:"open-link",label:D.open,onClick:()=>window.open(D.url,"_blank")},{id:"copy-link",label:"copy link",onClick:()=>Yt(D.url)}]),children:[D.text," ",d.jsx(_t,{name:"external",className:"icon-inline"})]},D.text)):An.line})]}):zu)}),Da&&d.jsxs(d.Fragment,{children:[`
248
- `,d.jsx("span",{className:"composer-subline",children:Da})]})]}),Wu&&d.jsx(Ot,{icon:"stop",tone:"danger",className:He("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${U.length?"; queued messages go next":""})`,hint:"esc",onClick:()=>w&&(h==null?void 0:h.send({t:"stop-agent",worktreeId:w}))})]}),j&&d.jsx("div",{className:"hint composer-notice",role:"status",children:j}),!C&&d.jsxs("div",{className:"hint composer-knobs",children:[d.jsxs("span",{className:"spawn-left",children:[en?kn.length>1?d.jsx(YU,{agents:kn,agent:Kt,model:tn,onChange:Pt,onClose:ys}):d.jsx(f1,{models:ln,value:tn,runs:Je,onChange:ht,onClose:ys}):e&&d.jsx(f1,{models:ln,value:e.worktree.model??"",current:ke,runs:Je,onChange:D=>h==null?void 0:h.send({t:"set-worktree-model",worktreeId:e.worktree.id,model:D}),onClose:ys}),en?d.jsx(u1,{efforts:It,value:gt,runs:Vt,onChange:sn,onClose:ys}):e&&d.jsx(u1,{efforts:It,value:e.worktree.effort??"",current:Xe,runs:Vt,onChange:D=>h==null?void 0:h.send({t:"set-worktree-effort",worktreeId:e.worktree.id,effort:D}),onClose:ys}),We?!o&&d.jsx(d1,{value:mn,onChange:an,onClose:ys}):e&&d.jsx(d1,{value:xn,onChange:D=>h==null?void 0:h.send({t:"set-worktree-mode",worktreeId:e.worktree.id,mode:D}),onClose:ys}),vn&&d.jsxs("span",{className:"usage-knob",onMouseEnter:()=>{Qt||(window.clearTimeout(Gt.current),Gt.current=window.setTimeout(()=>jr(!0),eH))},onMouseLeave:()=>{window.clearTimeout(Gt.current),jr(!1)},onFocus:D=>{Qt||!D.target.matches(":focus-visible")||(window.clearTimeout(Gt.current),jr(!0))},onBlur:To,children:[d.jsx(Ot,{icon:d.jsx(OU,{fraction:Nt?Nt.used/Nt.size:0,level:kt?R5(kt,Wn):void 0}),tone:"chrome",on:Qt,silent:!0,label:Nt?`${Math.round(100*Nt.used/Nt.size)}% of context`:kt?dx(kt,Wn):"",detail:[...Nt&&kt?[dx(kt,Wn)]:[],...tt?[tt]:[]],...Ze.dropdown(Wr,"left","usage",Et),...Ze.contextMenu(Wr,"usage")}),ar&&d.jsx(X7,{usage:Nt,limits:kt,auth:Be==null?void 0:Be.auth,now:Wn,onClose:To})]})]}),d.jsxs("span",{className:"spawn-tools",children:[v&&(e||x||o)&&d.jsx(Ot,{icon:"attach",tone:"chrome",label:c?"Attach a picture or a file":"Attach a picture or a file, or drop one here",onClick:()=>R_(m,v)}),!i&&!_&&!c&&!o&&d.jsx(Ot,{icon:"terminal",tone:"chrome",on:re,className:"composer-term",disabled:!e,label:Ne?Ne.tip:"Terminal",hint:Dt("terminal"),badge:Ne&&d.jsx("span",{className:"composer-term-dot"}),onClick:()=>{u(Ne&&!re&&w?{a:"term-stream",id:w,stream:Ne.stream}:{a:"toggle-terminal"})},...Ze.contextMenu(()=>e&&w?x8(e.procs,w,re,{sock:h,dispatch:m.dispatch}):[])}),!i&&!we&&!_&&!c&&!o&&d.jsx(Ot,{icon:"pick",label:"Pick an element on the page to attach",hint:Dt("pick"),on:M==="chat",disabled:!be,onClick:()=>be&&eu(be,M,u,"chat")}),ie&&v&&(e||x||o)&&d.jsx(Ot,{icon:"send",tone:"primary",label:o?"Create the project":"Send",disabled:ls||(o?o.busy:Wt),onMouseDown:D=>D.preventDefault(),onClick:za})]})]}),(bt||oe&&Fn||Xs.length>0)&&d.jsxs("div",{className:"composer-notes",children:[Xs.map(D=>d.jsx("div",{className:"hint composer-note",children:d.jsxs("span",{children:[D.title," starts when"," ","id"in D.after?d.jsx(ts,{id:D.after.id,title:D.after.branch}):nH(D,Xs)," ","lands"]})},`${D.proposalId}/${D.pieceId}`)),bt&&Be&&d.jsxs("div",{className:"hint composer-note",role:"status",children:[d.jsx("span",{children:bt.text}),(bt.retry||ee)&&d.jsxs("span",{className:"composer-note-actions",children:[bt.retry&&d.jsx(De,{variant:"outline",onClick:()=>h==null?void 0:h.send({t:"install-agent",agent:Be.id}),children:bt.retry}),ee&&d.jsxs(De,{variant:"outline","data-tip":`${ee.name} is installed and takes this message instead`,onClick:()=>Rn(ee.id),children:["use ",ee.name]})]})]}),oe&&Fn&&d.jsxs("div",{className:"hint composer-note",children:[d.jsx("span",{children:oe}),Y3(Fn)&&d.jsx(De,{variant:"outline",busy:hr==="pull-main",disabled:!!hr,"data-tip":"Fast-forward main to origin",onClick:()=>Si(h,u,{t:"pull-main",worktreeId:Fn.id}),children:"pull"})]})]})]})}function Uj({children:e,className:t,tip:n,...r}){return d.jsxs("label",{className:He("check",t),"data-tip":n,children:[d.jsx("input",{type:"checkbox",className:"check-box",...r}),d.jsx("span",{children:e})]})}function sH({draft:e,lead:t}){const n=ct(),r=L(u=>Ii(u,t==null?void 0:t.repoId)),[o]=kj(r),i=e.profile??o,l=L(u=>{var h;return((h=Il(u,t==null?void 0:t.repoId))==null?void 0:h.dirty)??0}),c=!!t&&!!r&&l>0;return!i&&!c?null:d.jsxs("div",{className:"draft-intro",children:[i&&d.jsx("div",{className:"draft-row hint",children:d.jsx(XU,{repo:r,value:i,onChange:u=>n({a:"draft-profile",profile:u})})}),c&&d.jsx("div",{className:"draft-notes",children:d.jsxs(Uj,{className:"hint draft-note",checked:!!e.carry,tip:`Move the ${l} uncommitted ${l===1?"file":"files"} into the new worktree, leaving ${r.defaultBranch} clean`,onChange:u=>n({a:"draft-carry",v:u.currentTarget.checked}),children:[d.jsxs("span",{className:"badge-dirty",children:["~",l]})," on ",r.defaultBranch," come along"]})})]})}function iH({row:e}){const t=rt(),n=L(l=>l.clientId),r=L(l=>l.home),o=r&&e.path.startsWith(`${r}/`)?`~${e.path.slice(r.length)}`:e.path,i=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(Ir,{icon:e.locked?"lock":"branch",word:e.locked?"held":"discovered",tone:"quiet",below:i,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(De,{variant:"inline",tone:"strong",onClick:()=>t==null?void 0:t.send({t:"adopt-worktree",worktreeId:e.id,clientId:n}),children:"take over"})]})}function Zc({placement:e,className:t,width:n,archived:r,found:o}){const i=ct(),l=Ps(),c=ED(),u=Rt(l==null?void 0:l.worktree.id,"sending"),h=Wl(),f=e==="centre"&&!r&&(h!=null&&h.assumed)?h:null,m=L(v=>{var _;return((_=v.dragFiles)==null?void 0:_.at)==="chat"}),g=Gn(),w=S.useMemo(()=>({onDragOver:v=>W3(g,v),onDrop:v=>{const _=iN(g,v);_&&S_(g,_.boxId,_.words)}}),[g]),y=d.jsxs(d.Fragment,{children:[!r&&!o&&c&&!u&&d.jsx(sH,{draft:c,lead:l}),r?d.jsx(Kc,{active:null,archived:r,placement:e}):o?d.jsx(Kc,{active:null,found:o,placement:e}):d.jsx(Kc,{active:l,draft:c,placement:e})]});return d.jsx("div",{className:He(e==="dock"?"chat-dock":e==="centre"?"chat-centre":"chat-screen",t,m&&"drop-over"),style:n===void 0?void 0:{width:n},...w,ref:v=>{var _;v?Hc.el=v:(_=Hc.el)!=null&&_.isConnected||(Hc.el=null)},children:r?d.jsx(Gm,{active:null,archived:r,tail:d.jsx(z5,{item:r}),foot:y}):o?d.jsx(Gm,{active:null,found:o,tail:d.jsx(iH,{row:o}),foot:y}):d.jsx(Gm,{active:l,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(De,{variant:"inline",onClick:()=>i({a:"open",overlay:{kind:"setup",repoId:f.id}}),children:"add a dev server"})]}),foot:y})})}const aH="modulepreload",lH=function(e){return"/"+e},E1={},dk=function(t,n,r){let o=Promise.resolve();if(n&&n.length>0){let l=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=l(n.map(h=>{if(h=lH(h),h in E1)return;E1[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":aH,f||(g.as="script"),g.crossOrigin="",g.href=h,u&&g.setAttribute("nonce",u),document.head.appendChild(g),f)return new Promise((w,y)=>{g.addEventListener("load",w),g.addEventListener("error",()=>y(Error(`Unable to preload CSS for ${h}`)))})}))}function i(l){const c=new Event("vite:preloadError",{cancelable:!0});if(c.payload=l,window.dispatchEvent(c),!c.defaultPrevented)throw l}return o.then(l=>{for(const c of l||[])c.status==="rejected"&&i(c.reason);return t().catch(i)})},hy=800;function cH(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 Go=e=>`${e.worktreeId}
249
- ${e.ref??""}
250
- ${e.since??""}
251
- ${e.path}`;class uH{constructor(t){St(this,"files",new Map);St(this,"looks",new Map);this.d=t}start(){var i,l;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(Go(c))};(i=this.d.win)==null||i.addEventListener("focus",r);const o=()=>{for(const[c,u]of this.files)u.timer!==void 0&&this.saveNow(c)};return(l=this.d.win)==null||l.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(Go(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=Lo();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=Go(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(Go(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(Go(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 i,l,c,u;t.connected&&!n.connected&&this.dropped();const r=(i=n.editor)!=null&&i.loose?null:n.editor,o=(l=t.editor)!=null&&l.loose?null:t.editor;if(o&&(!r||Go(o)!==Go(r))&&this.closed(Go(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=fo(t,r.worktreeId).git)==null?void 0:c.version)!==((u=fo(n,r.worktreeId).git)==null?void 0:u.version)&&this.refresh(Go(r))}opened(t){const n=Go(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 l;if(t.out||!this.d.store.getState().connected)return;const{worktreeId:n,path:r,ref:o,since:i}=t.file;if(t.reread){t.reread=!1;const c=Lo();t.out={seq:c},this.d.send({t:"read-file",worktreeId:n,path:r,ref:o,since:i,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=Lo();t.pending=null,t.out={seq:u,write:c},this.d.send({t:"write-file",worktreeId:n,path:r,content:c,base:((l=t.base)==null?void 0:l.version)??null,seq:u});return}!t.open&&!t.buffer&&t.pending===null&&!t.conflict&&this.files.delete(Go(t.file))}read(t,n){var g,w;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:i,version:l,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:i,version:l,writable:c,binary:u,tooLarge:h}}),!u&&!h&&(l!==null||r.ref)&&this.askBlame(t,l));const f={after:t.buffer?t.buffer.normalize(i):i,version:l};if(!t.base){t.base={text:f.after,version:l};return}const m=((g=t.buffer)==null?void 0:g.text())??t.pending??t.base.text;switch(cH(t.base,m,t.pending,f)){case"same":break;case"adopt":t.base={text:f.after,version:l};break;case"apply":(w=t.buffer)==null||w.replace(f.after),t.base={text:f.after,version:l};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=Lo();t.blame={seq:r,version:n};const{worktreeId:o,path:i,ref:l}=t.file;this.d.send({t:"blame-file",worktreeId:o,path:i,ref:l,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:i}=n;this.d.store.dispatch({a:"editor-blame",file:t.file,blame:{commits:o,lines:i,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)},hy))}saveNow(t){const n=this.files.get(t);if(!(n!=null&&n.buffer))return;this.cancelTimer(n);const r=n.buffer.text();r.length>If||(n.pending=r,this.next(n))}cancelTimer(t){t.timer!==void 0&&(this.d.timers.clear(t.timer),t.timer=void 0)}}const Hj={attach:()=>{},edited:()=>{},saveNow:()=>{}},dH=e=>({timers:{set:(t,n)=>setTimeout(t,n),clear:t=>clearTimeout(t)},win:typeof window>"u"?null:window,send:e}),fk=new Map;function fH(e){const t=fk.get(e.seq);return t?(fk.delete(e.seq),t(e),!0):!1}function hH(e,t,n,r){if(e.kind==="bytes"||e.kind==="text")return Hj;if(e.kind==="grant")return pH(e,t,n,r);const o=e.handle;let i=null,l,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=()=>{l!==void 0&&r.timers.clear(l),l=void 0},g=()=>{h||(h=!0,m(),n(`read-only: the browser would not save ${t}`))},w=async _=>{if(!await f())return g();const x=await o.createWritable();await x.write(_),await x.close()},y=()=>{if(!i||h)return;m();const _=i.text();u=u.then(()=>w(_)).catch(g)},v=()=>{l!==void 0&&y()};return{attach(_){var x,T;if(_){i=_,(x=r.win)==null||x.addEventListener("pagehide",v);return}l!==void 0&&y(),i=null,(T=r.win)==null||T.removeEventListener("pagehide",v)},edited(){!i||h||(f().then(_=>{_||g()}),m(),l=r.timers.set(y,hy))},saveNow:y}}function pH(e,t,n,r){let o=null,i,l=e.version,c=!1,u=null,h=!1;const f=()=>{i!==void 0&&r.timers.clear(i),i=void 0},m=v=>{h||(h=!0,f(),u=null,n(v))},g=v=>{if(!r.send)return;const _=Lo();c=!0,fk.set(_,x=>{if(c=!1,x.ok?l=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 T=u;u=null,g(T)}}),r.send({t:"write-loose",id:e.id,content:v,base:l,seq:_})},w=()=>{if(!o||h)return;f();const v=o.text();v.length>If||(c?u=v:g(v))},y=()=>{i!==void 0&&w()};return{attach(v){var _,x;if(v){o=v,(_=r.win)==null||_.addEventListener("pagehide",y);return}i!==void 0&&w(),o=null,(x=r.win)==null||x.removeEventListener("pagehide",y)},edited(){!o||h||(f(),i=r.timers.set(w,hy))},saveNow:w}}function py({kind:e,className:t,height:n,resizable:r=!0,onDragStart:o,title:i,tabs:l,actions:c,menu:u,full:h,onToggleFull:f,onClose:m,closeHint:g="esc",children:w}){const y=wn("pane"),v=f&&d.jsxs(De,{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(_t,{name:h?"split":"full",className:"icon-inline"})," ",h?"split":"full"]}),_=d.jsxs("span",{className:"pane-shape",children:[v,d.jsx(Ot,{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:He("pane-head",l&&"pane-head-tabs"),...y.contextMenu(()=>(u==null?void 0:u())??[]),children:l?d.jsx(Ah,{...l,end:d.jsxs(d.Fragment,{children:[c,_]})}):d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"pane-title",children:i}),c,_]})}),w]})}function mH({src:e,path:t,full:n,onFull:r}){const o=wn("editor");return d.jsxs(d.Fragment,{children:[d.jsx("button",{type:"button",className:"editor-image",onClick:()=>r(!0),...o.contextMenu(()=>ou(e,{open:()=>r(!0)})),children:d.jsx("img",{src:e,alt:t})}),n&&d.jsx(Mw,{owner:"editor",onClose:()=>r(!1),menu:()=>ou(e),children:d.jsx("img",{src:e,alt:t})})]})}const gH={image:mH};function kH({kind:e,src:t,path:n,openSeq:r,focus:o,full:i,onFull:l}){const c=S.useRef(null);ft([r],()=>{var h;o&&((h=c.current)==null||h.focus())});const u=gH[e];return d.jsx("div",{ref:c,className:"editor-viewer",tabIndex:-1,children:d.jsx(u,{src:t,path:n,full:i,onFull:l})})}const wH="img[src], source[src], video[src], audio[src], video[poster], link[href], object[data]";function yH(e,t){if(!t)return e;const n=new DOMParser().parseFromString(e,"text/html");let r=!1;for(const o of n.querySelectorAll(wH))for(const i of["src","href","poster","data"]){const l=o.getAttribute(i),c=l===null?null:Pw(t.dir,l);c&&(o.setAttribute(i,t.urls.worktreeFile(t.worktreeId,c,t.version)),r=!0)}return r?`${n.doctype?`<!doctype html>
252
- `:""}${n.documentElement.outerHTML}`:e}function vH({text:e,path:t,worktreeId:n,version:r,openSeq:o,focus:i}){const l=S.useRef(null);ft([o],()=>{var f;i&&((f=l.current)==null||f.focus())});const c=Ur(),u=HN(t),h=S.useMemo(()=>yH(e,r===void 0?null:{worktreeId:n,dir:u,version:r,urls:c}),[e,n,u,r,c]);return d.jsx("div",{ref:l,className:"editor-viewer",tabIndex:-1,children:d.jsx("iframe",{className:"editor-frame",title:t,sandbox:"",srcDoc:h})})}function bH(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 xH(e){const t=new Map,n=Array.from(e.querySelectorAll("h1, h2, h3, h4, h5, h6")),r=bH(n.map(o=>Number(o.tagName[1])));return n.map((o,i)=>{var u;const l=((u=o.textContent)==null?void 0:u.trim())??"",c=t.get(l)??0;return t.set(l,c+1),{id:`${c}
253
- ${l}`,level:Number(o.tagName[1]),depth:r[i],text:l,el:o}})}const EH=48,SH=16;function Wj({html:e,openSeq:t=0,focus:n=!0,onLink:r,onChat:o,lead:i,leadOnly:l=!1}){const c=S.useRef(null),u=S.useRef(null),[h,f]=S.useState([]),[m,g]=S.useState(-1),[w,y]=S.useState(null),v=N=>{var j;if(y(null),N){const $=window.getSelection();$==null||$.removeAllRanges(),$==null||$.addRange(N)}(j=c.current)==null||j.focus()};ft([t],()=>{var N;n&&((N=c.current)==null||N.focus())}),ft([e,l],()=>{f(u.current?xH(u.current):[])}),S.useLayoutEffect(()=>{const N=c.current;if(!N)return;let j=0;const $=()=>{if(j=0,N.scrollTop+N.clientHeight>=N.scrollHeight-1){g(h.length-1);return}const I=N.scrollTop+EH;let P=-1;for(let R=0;R<h.length;R++)h[R].el.offsetTop<=I&&(P=R);g(P)},O=()=>{j||(j=requestAnimationFrame($))};return $(),N.addEventListener("scroll",O),()=>{N.removeEventListener("scroll",O),j&&cancelAnimationFrame(j)}},[h]);const _=N=>{var $,O;const j=($=h[N])==null?void 0:$.el;(O=c.current)==null||O.scrollTo({top:Math.max(0,j?j.offsetTop-SH:0),behavior:"smooth"})},x=N=>{const j=N.target.closest("a"),$=j==null?void 0:j.getAttribute("href");!$||(j==null?void 0:j.target)==="_blank"||(N.preventDefault(),r==null||r($))},T=N=>{var j;if(Iw(N)){N.preventDefault(),N.stopPropagation();const $=(u.current&&Fg(u.current))??"";y(O=>({seed:$||(O==null?void 0:O.seed)||"",seq:((O==null?void 0:O.seq)??0)+1}));return}if(N.key==="Escape"&&w){N.stopPropagation(),v(null);return}if(PN(N)&&u.current){N.preventDefault(),DN(u.current);return}if(o&&((j=eE(N))==null?void 0:j.id)==="composer"&&u.current){const $=Fg(u.current);if(!$)return;N.preventDefault(),N.stopPropagation(),o($)}};return d.jsxs(d.Fragment,{children:[d.jsxs("div",{ref:c,className:"document",tabIndex:-1,onClick:x,onKeyDown:T,children:[i,!l&&d.jsx("div",{ref:u,className:"md md-preview",dangerouslySetInnerHTML:{__html:e}})]}),w&&d.jsx(MN,{root:c,body:u,seed:w.seed,seq:w.seq,onClose:v}),d.jsx(_H,{heads:h,at:m,onJump:_})]})}function _H({heads:e,at:t,onJump:n}){const[r,o]=S.useState(!1),i=S.useRef(null);return e.length<2?null:d.jsxs(d.Fragment,{children:[d.jsx("div",{ref:i,className:"document-outline","aria-hidden":!0,onPointerEnter:l=>{l.pointerType==="mouse"&&o(!0)},onClick:()=>o(l=>!l),children:e.map((l,c)=>d.jsx("span",{className:"document-outline-tick","data-level":l.level,"data-state":dr({current:c===t})},l.id))}),r&&d.jsx(Ls,{className:"document-outline-list",anchor:()=>{var l;return((l=i.current)==null?void 0:l.getBoundingClientRect())??null},placement:{side:"right",align:"center",cover:!0},trigger:i.current,onDismiss:()=>o(!1),onPointerLeave:l=>{l.pointerType==="mouse"&&o(!1)},children:e.map((l,c)=>d.jsx("button",{type:"button",className:"row document-outline-row","data-level":l.level,"data-state":dr({current:c===t}),onClick:()=>n(c),children:d.jsx("span",{className:"document-outline-label",style:{"--outline-depth":l.depth},children:l.text})},l.id))})]})}function NH({text:e,path:t,worktreeId:n,version:r,openSeq:o,focus:i,onChat:l,lead:c,leadOnly:u}){rt();const h=Ur(),f=ct(),m=HN(t),g=Fh(e,{keepHtml:!0,base:r===void 0?void 0:{worktreeId:n,dir:m,version:r,urls:h}}),w=y=>{const v=Pw(m,y);v&&Ln({dispatch:f},{worktreeId:n,path:v,view:ji(v)})};return d.jsx(Wj,{html:g,openSeq:o,focus:i,onLink:w,onChat:l,lead:c,leadOnly:u})}function TH({refs:e,worktreeId:t}){const n=Ur();return e.length===0?null:d.jsx("div",{className:"editor-piece-chips",children:e.map(r=>r.kind==="image"?d.jsx(Kh,{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(Uh,{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(Bh,{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(Zh,{className:"in-chat",pick:r,worktreeId:t},`pick-${r.n}`))})}function jH({text:e}){const t=S.useMemo(()=>ka(e),[e]);return d.jsx("div",{className:"editor-piece-text md",dangerouslySetInnerHTML:{__html:t}})}function $H(e,t){return e.kind==="piece"?`after ${e.title} lands`:e.id===t?"after this branch lands":`after ${e.branch} lands`}function CH({piece:e,fate:t,wait:n,selfId:r}){return t==="send"&&e.to?d.jsxs(d.Fragment,{children:["sent to ",d.jsx(ts,{id:e.to.id,title:e.to.title,inert:!0})]}):d.jsxs(d.Fragment,{children:[j_(e,t),t==="worktree"&&n?` ${$H(n,r)}`:""]})}function AH({item:e,piece:t}){const n=e.outcomes.find(l=>l.pieceId===t.id),r=e.later.findLast(l=>l.pieceId===t.id);if(e.state==="going")return d.jsx("span",{className:"live-text",children:"starting"});if(!n)return null;if(n.error)return d.jsx(d.Fragment,{children:n.error});if(n.fate==="here")return d.jsx(d.Fragment,{children:"here"});if(n.fate==="skip")return d.jsx(d.Fragment,{children:"skipped"});if(n.fate==="send")return d.jsxs(d.Fragment,{children:["sent to"," ",n.worktreeId?d.jsx(ts,{id:n.worktreeId,title:n.title}):n.title??"the worktree",n.repoName?` in ${n.repoName}`:""]});const o=n.worktreeId?n:r!=null&&r.worktreeId?r:null;if(o!=null&&o.worktreeId)return d.jsxs(d.Fragment,{children:[d.jsx(ts,{id:o.worktreeId,title:o.title}),"repoName"in o&&o.repoName?` in ${o.repoName}`:""]});if(r!=null&&r.reason)return d.jsx(d.Fragment,{children:r.reason});const i=t.after;return d.jsxs(d.Fragment,{children:["queued until"," ",i&&"id"in i?d.jsx(ts,{id:i.id,title:i.branch}):n.after??"its turn"," ","lands"]})}function IH({item:e,worktreeId:t}){const n=rt(),[r,o]=S.useState(null),i=e.state==="held"||e.state==="proposed",l=(u,h)=>n==null?void 0:n.send($_(e,t,u.id,h)),c=u=>{u.key!=="Escape"||r===null||(u.preventDefault(),u.stopPropagation(),o(null))};return d.jsxs("section",{className:"editor-pieces",onKeyDown:c,children:[d.jsx("div",{className:"editor-pieces-title section-title",children:"Worktrees"}),i&&e.stale&&d.jsx("div",{className:"editor-pieces-note hint",children:"the plan changed since these were read"}),e.pieces.map(u=>{const h=$h(e,u),f=yw(e,u),m=i?gz(u).filter(g=>g!==h):[];return d.jsxs("details",{className:"editor-piece",open:r===u.id,onToggle:g=>{g.currentTarget.open?o(u.id):r===u.id&&o(null)},children:[d.jsxs("summary",{className:"row editor-piece-row",children:[d.jsx("span",{className:"editor-piece-title",children:u.title}),d.jsx("span",{className:"editor-piece-fate hint",children:i?d.jsx(CH,{piece:u,fate:h,wait:f,selfId:t}):d.jsx(AH,{item:e,piece:u})})]}),d.jsxs("div",{className:"editor-piece-body",children:[i&&d.jsxs("p",{className:"editor-piece-line hint",children:[mz(u,h,f),m.length>0&&d.jsxs(d.Fragment,{children:[" ","Instead:"," ",m.map((g,w)=>d.jsxs("span",{children:[w>0&&" · ",d.jsx(De,{variant:"inline",onClick:()=>l(u,g),children:g==="send"&&u.to?`send to ${u.to.title}`:j_(u,g)})]},g))]})]}),d.jsx(jH,{text:u.plan}),d.jsx(TH,{refs:u.attachments,worktreeId:t})]})]},u.id)})]})}const RH=S.lazy(async()=>{const[e]=await Promise.all([dk(()=>import("./Editor-B-1lrUVF.js").then(t=>t.E),__vite__mapDeps([0,1,2])),dk(()=>import("./grammar-DBMSnNcB.js"),[]).then(t=>t.grammarsReady)]);return e});function S1({what:e}){return XS(!0,3e3)?d.jsx("div",{className:"empty",children:d.jsxs("span",{className:"live-text",children:["loading ",e]})}):null}const OH=()=>{},MH=[],PH={diff:"diff",file:"text",preview:"book"};function LH({path:e,note:t,title:n,worktreeId:r}){const o=Gn(),i=mS(e),l=n??i.name,c=n?"":i.dir;return d.jsxs("span",{className:"editor-title","data-tip":c||n?e:void 0,draggable:!!r,onDragStart:r?u=>tu(u,{kind:"paths",worktreeId:r,items:[{path:e,folder:!1}]}):void 0,onDragEnd:r?()=>Eu(o):void 0,children:[d.jsxs("span",{className:"editor-name",children:[l,t]}),c&&d.jsx("span",{className:"editor-dir row-dim",children:c})]})}function DH(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 Kj({editor:e,height:t,full:n=!1,onToggleFull:r,onDragStart:o,placement:i="stack"}){const l=i==="screen",c=ct(),u=Gn(),h=rt(),f=Ur(),m=iw(),g=Eh(),{worktreeId:w,path:y,ref:v,since:_}=e,x=e.loose,T=L(we=>{var pe;return((pe=No(we))==null?void 0:pe.id)===w}),N=L(we=>{var Q,W;const pe=(Q=rn(we,w))==null?void 0:Q.worktree;return pe?pe.path:(W=No(we))==null?void 0:W.path}),j=v!==void 0,$=L(we=>{var pe;return(pe=rn(we,w))==null?void 0:pe.worktree.plan}),O=!x&&!j&&$===y,I=ay(O?w:void 0,O?y:void 0),P=L(we=>uz(fo(we,w).chat??MH)),R=S.useMemo(()=>{if(j||x||e.view!=="preview"||!P)return null;const we=P.plan??$;return we&&y===we?P:null},[j,x,e.view,$,y,P]),U=S.useMemo(()=>x?hH(x.source,y,we=>c({a:"editor-refused",file:{worktreeId:w,path:y},message:we}),dH(h?we=>h.send(we):null)):(m==null?void 0:m.bind({worktreeId:w,path:y,...v?{ref:v}:{},..._?{since:_}:{}}))??Hj,[m,w,y,v,_,x,c,h]),F=L(we=>fo(we,w).changedRanges[y]);S.useEffect(()=>{!F&&!j&&!T&&!x&&(h==null||h.send({t:"changed-ranges",worktreeId:w,path:y}))},[w,y,F,j,T,x,h]);const B=(F==null?void 0:F.offset)??0,X=e.disk,ae=e.view??"diff",Y=!!X&&(X.before===""||X.before===X.after),ne=g_(y,Y).filter(we=>we!==ae&&!(x&&we==="diff")),C=(x==null?void 0:x.source.kind)==="grant"?x.source:null,H=j||T||x&&!C?null:JP(y),[V,J]=S.useState(!1),[Z,ie]=xo(Ke.editorWrap,!1,we=>we===null?void 0:we==="1"),be=!!X&&!H&&!X.binary&&!X.tooLarge&&ae!=="preview",ge=e.line&&!e.line.fiber?e.line.n:void 0;return d.jsxs(py,{kind:"editor",className:He("editor-pane",n&&"full"),height:n||l?void 0:t,resizable:!n&&!l,onDragStart:o??OH,title:d.jsx(LH,{path:y,note:j?` at ${v==null?void 0:v.slice(0,7)}`:_?", last turn":void 0,title:O&&I?I:void 0,worktreeId:x?void 0:w}),menu:()=>N&&!x?Is({id:w,dir:N},y,{discard:!j&&!T,kept:T,ref:v,showing:e.view??void 0,noDiff:Y},{sock:h,dispatch:c}):[],onClose:()=>c({a:"close-editor"}),full:n,onToggleFull:l?void 0:r,actions:d.jsxs(d.Fragment,{children:[!H&&ne.length>0&&d.jsx("span",{className:"editor-views",children:ne.map(we=>d.jsxs(De,{variant:"outline",tone:"quiet",mono:!0,className:"deep-link",onClick:()=>c({a:"editor-view",v:we}),"data-tip":DH(we,ae),children:[d.jsx(_t,{name:PH[we],className:"icon-inline"})," ",we]},we))}),H==="image"&&d.jsxs(De,{variant:"outline",tone:"quiet",mono:!0,className:"deep-link",onClick:()=>J(!0),"data-tip":"Full size: see the picture over the window",children:[d.jsx(_t,{name:"zen",className:"icon-inline"})," full size"]}),be&&d.jsxs(De,{variant:"outline",tone:"quiet",mono:!0,className:"deep-link",onClick:()=>ie(!Z),"data-tip":Z?"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(_t,{name:"wrap",className:"icon-inline"})," ",Z?"unwrap":"wrap"]})]}),children:[X&&d.jsx(zH,{editor:e,disk:X,files:m}),d.jsx("div",{className:"editor-body",children:X?H?d.jsx(kH,{kind:H,src:C?f.loose(C.id,C.version):f.worktreeFile(w,y,X.version),path:y,openSeq:e.seq,focus:e.focus,full:V,onFull:J}):X.binary?d.jsx("div",{className:"empty",children:"not a text file: open it in another editor"}):X.tooLarge?d.jsx("div",{className:"empty",children:"too large to open here: open it in another editor"}):ae==="preview"&&kh(y)==="html"?d.jsx(vH,{text:X.after,path:y,worktreeId:w,version:j||T||x?void 0:X.version,openSeq:e.seq,focus:e.focus}):ae==="preview"?d.jsx(NH,{text:X.after,path:y,worktreeId:w,lead:R?d.jsx(IH,{item:R,worktreeId:w}):void 0,leadOnly:!!R&&dz(R),version:j||T||x?void 0:X.version,openSeq:e.seq,focus:e.focus,onChat:we=>zb(u,{worktreeId:w,text:we,name:y})}):d.jsx(Sw,{pane:!0,children:d.jsx(S.Suspense,{fallback:d.jsx(S1,{what:ae}),children:d.jsx(RH,{file:{worktreeId:w,path:y,...v?{ref:v}:{},..._?{since:_}:{}},disk:X,blame:e.blame,view:ae,openSeq:e.seq,line:ge,focus:e.focus,readOnly:j||!X.writable||l,numbers:!l,wrap:Z,theme:g,sync:U,onCopy:x?void 0:(we,pe,Q)=>MD(Q,{worktreeId:w,path:we,...pe,...v?{ref:v}:{}}),onChat:(we,pe)=>zb(u,pe&&(x?{worktreeId:w,text:pe.text,name:we}:{worktreeId:w,text:pe.text,source:{path:we,startLine:pe.startLine,endLine:pe.endLine,...v?{ref:v}:{}}})),onNew:()=>u.dispatch({a:"open-draft"}),onLineHover:j||x?void 0:we=>{we==null?un.post(w,{type:"highlight-clear"}):un.post(w,{type:"highlight-file",path:y,ranges:[[we+B,we+B]]})}},`${w}
254
- ${x?"loose":v??_??""}
255
- ${y}`)})}):d.jsx(S1,{what:y},y)})]})}function zH({editor:e,disk:t,files:n}){var h;const{worktreeId:r,path:o,ref:i,since:l,conflict:c}=e,u={worktreeId:r,path:o,...i?{ref:i}:{},...l?{since:l}:{}};if(c){const f=c.version===null;return d.jsxs("div",{className:"editor-note",children:[d.jsx("span",{className:"editor-note-text",children:f?"deleted on disk; your edits are not saved":"changed on disk; your edits are not saved"}),d.jsx(De,{variant:"outline",onClick:()=>n==null?void 0:n.reload(u),"data-tip":f?"Close the file; your edits go with it":"Take the file as it is on disk; undo brings your edits back",children:f?"close":"reload"}),d.jsx(De,{variant:"outline",tone:"danger",onClick:()=>n==null?void 0:n.keepMine(u),"data-tip":f?"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)==="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"]})}):i===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 Zj(e,t,n=!1){var o;const r=((o=t.find(i=>i.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 FH=(e,t)=>{const n=gg(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"}},Jf="https://github.com/toyon-dev/toyon",BH=e=>`${Jf}/releases/tag/v${e}`,UH=`${Jf}/releases/latest`,HH=4e3;function WH(e,t,n,r){if(r==="asking")return{value:`${e} checking`,text:`Asking ${gg(n)} for the newest version`,act:"check",busy:!0};const o=gg(r.registry),i={act:"check",busy:!1};if(r.latest===null)return{...i,value:`${e} no answer`,text:`Could not reach ${o}. Press to ask again`,settles:!0};if(JE(r.latest,e)){const l=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{...i,value:`${r.latest} out`,text:`Toyon ${r.latest} is out. ${l}`}}return{...i,value:`${e} up to date`,text:`Toyon ${e} is the newest version ${o} lists. Press to ask again`,settles:!0}}function KH(e,t,n,r,o,i=!1,l=null,c=null){if(n){if(n.restarting){const h=n.installed??n.running,f=n.restarting.length>0?J_(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=Zj(r,o,i);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?WH(e,t,l,c):{value:e,text:`Toyon ${e}, ${FH(t,l)}`,act:"check",busy:!1}}function ZH(e,t,n){const r=o=>()=>window.open(o,"_blank");return Dn([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(BH(e))},{id:"latest-release",label:"latest release",onClick:r(UH)},{id:"repo",label:"Toyon on GitHub",onClick:r(Jf)},{id:"report",label:"report a problem",onClick:r(`${Jf}/issues/new`)}],[{id:"copy-version",label:"copy version",onClick:()=>Yt(e)}]])}const qH=UC.map(e=>({title:e,rows:KC(e).map(t=>[Dt(t),Bc[t].label])}));function GH(){const e=ct(),t=rt(),n=wn("keys"),r=L(m=>m.themePrefs),o=L(m=>m.themes),i=L(m=>m.chatSide),l=L(m=>m.keepAwake),c=sw(),u=L(m=>m.agents),h=Wl(),f=m=>{e({a:"palette-return",v:{mode:"keys",q:""}}),e(m)};return d.jsxs(uu,{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(De,{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(()=>Dh(h,h.id,{sock:t,dispatch:e})),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(m=>d.jsx(XH,{agent:m},m.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(De,{variant:"field",mono:!0,onClick:()=>f({a:"open",overlay:{kind:"appearance"}}),children:Kf[r.mode]})]}),d.jsxs("div",{className:"keys-setting",children:[d.jsx("span",{className:"keys-d",children:"theme"}),d.jsx(De,{variant:"field",mono:!0,onClick:()=>f({a:"open",overlay:{kind:"theme",slot:"theme"}}),children:gh(r,o,c).name})]}),d.jsxs("div",{className:"keys-setting",children:[d.jsx("span",{className:"keys-d",children:"chat side"}),d.jsx(De,{variant:"field",mono:!0,onClick:()=>e({a:"toggle-chat-side"}),children:i})]}),d.jsx("div",{className:"section-title keys-h",children:"Toyon"}),l!==null&&d.jsxs("div",{className:"keys-setting",children:[d.jsx("span",{className:"keys-d",children:"keep awake"}),d.jsx(De,{variant:"field",mono:!0,onClick:()=>f({a:"open",overlay:{kind:"keep-awake"}}),children:Zf[l]})]}),d.jsx(VH,{}),d.jsx(YH,{})]})]}),d.jsx("div",{className:"keys-card",children:qH.map(m=>d.jsxs("div",{children:[d.jsx("div",{className:"section-title keys-h",children:m.title}),m.rows.map(([g,w])=>d.jsxs("div",{className:"keys-row",children:[d.jsx(es,{k:g}),d.jsx("span",{className:"keys-d",children:w})]},g))]},m.title))})]})}function VH(){const e=rt(),t=ct(),n=wn("keys"),r=L(N=>N.version),o=L(N=>N.install),i=L(N=>N.registry),l=L(N=>N.update),c=L(N=>N.self),u=L(N=>N.rebuilt),h=L(N=>N.repos),f=L(N=>N.managed.updates),m=L(N=>N.updateCheck),g=L(N=>N.frame),w=L(N=>N.newProject!==null),y=KH(r,o,l,c,h,u,i,m),v=!f&&(y.act==="update"||y.act==="check"),_=y.settles&&m&&m!=="asking"?m:null;S.useEffect(()=>{if(!_)return;const N=()=>t({a:"update-check-settle",check:_}),j=setTimeout(N,HH);return()=>{clearTimeout(j),N()}},[_,t]);const x=()=>{y.act==="restart"?e==null||e.send({t:"restart-daemon"}):y.act==="reload"?window.location.reload():y.act==="rebuild"&&c?e==null||e.send({t:"run-after-land",repoId:c.repoId}):y.act==="update"?e==null||e.send({t:"update-now"}):y.act==="check"&&e&&(t({a:"update-check"}),e.send({t:"check-update"}))},T=()=>ZH(r,y.act==="check"&&!y.busy?{run:x,...v?{off:"managed by your organization"}:{}}:null,g==="phone"||w?void 0:()=>t({a:"open-release-notes"}));return d.jsxs("div",{className:"keys-setting",...n.contextMenu(T),children:[d.jsx("span",{className:"keys-d",children:"version"}),d.jsx(De,{variant:"field",mono:!0,busy:y.busy,disabled:v,onClick:x,...zt(v?"updates are managed by your organization":y.text,void 0,{detail:y.detail}),children:y.value})]})}function YH(){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: ${DM(e).join(", ")||"nothing turned off"}`;return d.jsx("div",{className:"hint",children:t})}function qj(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 Gj(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":Gh(e)}function XH({agent:e}){const t=ct(),n=rt(),r=wn("keys");return d.jsxs("div",{className:"keys-setting",children:[d.jsx("span",{className:"keys-d",children:e.name}),d.jsx(De,{variant:"field",mono:!0,"data-tip":Gj(e),...r.contextMenu(()=>ly(e,{sock:n})),onClick:()=>{t({a:"palette-return",v:{mode:"keys",q:""}}),t({a:"open",overlay:{kind:"agent-page",agent:e.id}})},children:qj(e)})]})}function QH({agentId:e}){const t=ct(),n=rt(),r=Wl(),o=L(g=>g.home),i=L(g=>g.agents.find(w=>w.id===e)??null),l=L(g=>g.agentConfigs[e]??null),c=wn("keys");if(S.useEffect(()=>{n==null||n.send({t:"agent-config",agent:e,...r?{repoId:r.id}:{}})},[n,e,r]),Bj(n,e,i??void 0),!i)return null;const u=ly(i,{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(uu,{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(Ot,{icon:"back",label:"back to settings",hint:"esc",onClick:h})}),d.jsx("div",{className:"section-title keys-h",children:i.name}),d.jsxs("div",{className:"keys-setting",children:[d.jsx("span",{className:"keys-d",children:"signed in"}),d.jsx(De,{variant:"field",mono:!0,"data-tip":Gj(i),disabled:u.length===0,...c.dropdown(()=>u,"right"),children:qj(i)})]}),d.jsxs("div",{className:"keys-setting",children:[d.jsx("span",{className:"keys-d",children:"commit messages"}),d.jsx("span",{className:"keys-d",children:i.quick?"its quick model writes one after each turn":"none: it has no quick model, so you write them in the changes panel; quickModel in agents.json names one"})]}),d.jsx("div",{className:"section-title keys-h",children:"MCP servers it will load"}),l===null?d.jsx("div",{className:"keys-setting",children:d.jsx("span",{className:"keys-d live-text",children:"reading"})}):l.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"})]}):l.servers.map(g=>d.jsx(JH,{s:g},`${g.scope}:${g.name}`)),l&&l.files.length>0&&d.jsxs(d.Fragment,{children:[d.jsx("div",{className:"section-title keys-h",children:"the files it reads"}),l.files.map(g=>d.jsxs("div",{className:"keys-setting",children:[d.jsx("span",{className:"keys-d",children:g.label}),g.exists?d.jsx(De,{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 JH({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 eW(){const e=ct(),t=rt(),n=L(o=>o.agents),r=L(o=>o.defaultAgent);return d.jsx(Br,{items:n,filter:(o,i)=>o.filter(l=>Jo(i,l.name,l.id)),rowClass:o=>o.available?"picker-row":"picker-row dim",keyOf:o=>o.id,initialIndex:o=>Math.max(0,o.findIndex(i=>i.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=>ly(o,{sock:t}),placeholder:"default agent for new worktrees",keys:{pick:"sets",back:"closes"},row:o=>d.jsx(jn,{label:o.name,current:o.id===r,hint:o.available?o.checkFailed??(o.sandboxed?void 0:"unsandboxed"):Gh(o)})})}const tW=["dark","light","system","daylight"],nW=new Intl.DateTimeFormat(void 0,{hour:"numeric",minute:"2-digit"});function rW(){const e=ct(),t=rt(),n=L(u=>u.themePrefs),r=L(u=>u.themes),o=sw(),i=L(u=>u.daylight),l=u=>{var h;return((h=r.find(f=>f.id===n[Fk({...n,mode:u},o)]))==null?void 0:h.name)??""},c=u=>{if(u==="system")return`${o.system?"dark":"light"} now · ${l(u)}`;if(u!=="daylight")return l(u);const h=i&&i.until>Date.now()?` · ${o.daylight?"light":"dark"} at ${nW.format(i.until)}`:"";return`${o.daylight?"dark":"light"} now${h} · ${l(u)}`};return d.jsx(Br,{items:tW,filter:(u,h)=>u.filter(f=>Jo(h,Kf[f])),rowClass:()=>"picker-row",keyOf:u=>u,initialIndex:u=>u.indexOf(n.mode),onActive:u=>e({a:"preview-theme",theme:u?gh({...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(jn,{label:Kf[u],current:u===n.mode,hint:c(u)})})}const oW=2,hk=e=>GE(e).join(" ").length<oW,sW=e=>({kind:"chat",id:e.id,name:e.name,hint:e.branch??"",fields:[e.name,e.branch??""]}),iW=e=>({kind:"chat",id:e.id,name:e.title,hint:$N(e),fields:[e.title,e.branch],prompt:e.prompt,archived:e});function aW(e,t,n){const r=GE(t),o=n==="all"&&!hk(t);return e.filter(i=>{if(i.kind==="hit")return o;const l=n==="names"&&i.prompt?[...i.fields,i.prompt]:i.fields;return r.every(c=>l.some(u=>u.toLowerCase().includes(c)))})}const lW=e=>e.flatMap(([t,n])=>Array.from({length:n},(r,o)=>t+o));function cW({repoId:e,scope:t}){const n=ct(),r=rt(),o=L(j=>j.clientId),i=L(j=>j.frame),l=L(j=>j.chats[e]),c=uw(),u=L(j=>j.archived[e]),[h,f]=S.useState(t),m=S.useCallback(()=>f(j=>j==="all"?"names":"all"),[]);S.useEffect(()=>{r==null||r.send({t:"list-archived",repoId:e})},[r,e]);const g=S.useMemo(()=>[...c.filter(j=>!_r(j.worktree)).map(sW),...(u??[]).map(iW)],[c,u]),w=S.useMemo(()=>new Map(g.map(j=>[j.id,j])),[g]),y=S.useMemo(()=>[...g,...((l==null?void 0:l.hits)??[]).map(j=>({kind:"hit",hit:j}))],[g,l]),v=S.useMemo(()=>{const j=new Map;for(const $ of(l==null?void 0:l.hits)??[])j.set($.worktreeId,Math.max(j.get($.worktreeId)??0,$.ts));return j},[l]),_=S.useCallback((j,$)=>aW(j,$,h),[h]),x=S.useCallback(j=>{h==="all"&&!hk(j)&&(r==null||r.send({t:"search-chats",repoId:e,query:j.trim()}))},[r,e,h]),T=j=>!l||l.query!==j.trim(),N=j=>h==="all"&&!hk(j);return d.jsx(Br,{items:y,filter:_,onQuery:x,onTab:m,trailing:d.jsx(De,{tone:"chrome",on:h==="names","aria-pressed":h==="names",onClick:m,children:"names only"}),keyOf:j=>j.kind==="hit"?`h:${j.hit.worktreeId}:${j.hit.seq}`:`w:${j.id}`,rowClass:j=>j.kind==="hit"?"chats-hit":He("picker-row",j.archived&&!j.archived.restorable&&"dim"),rowTitle:j=>{var $;return j.kind==="hit"?j.hit.text:(($=j.archived)==null?void 0:$.prompt)??j.name},groupOf:j=>j.kind==="hit"?`h:${j.hit.worktreeId}`:j.archived?"archived":"open",groupHead:(j,$)=>{if(!j.startsWith("h:"))return`${j} · ${$}`;const O=j.slice(2),I=w.get(O),P=l==null?void 0:l.asks[O],R=v.get(O)??0;return d.jsxs(d.Fragment,{children:[d.jsxs("span",{className:"chats-name",children:[(I==null?void 0:I.name)??"a worktree",(I==null?void 0:I.archived)&&d.jsxs(d.Fragment,{children:[" ",d.jsx("span",{className:"row-dim",children:"archived"})]})]}),R>0&&d.jsx("span",{className:"picker-group-tail",children:ur(R)}),P&&d.jsx("span",{className:"picker-group-line",children:Oh(P,mN*2)})]})},headAlone:!0,onPick:j=>{const $=j.kind==="hit"?j.hit.worktreeId:j.id,O=j.kind==="hit"?j.hit.archived:!!j.archived;n(O?{a:"open-archived",id:$}:{a:"activate",id:$}),j.kind==="hit"&&n({a:"reveal",id:$,seq:j.hit.seq}),n({a:"close"})},onBack:()=>n({a:"close"}),rowMenu:j=>j.kind==="chat"&&j.archived?yf(j.archived,{clientId:o,frame:i},{sock:r,dispatch:n}):[],placeholder:h==="names"?"find a chat by name…":"search in chats…",keys:j=>({nav:"moves",tab:h==="names"?"searches messages too":"searches names only",pick:j?j.kind==="hit"?"opens the chat there":"opens its chat":void 0,back:"closes"}),empty:j=>j.trim()?N(j)?T(j)?d.jsx("span",{className:"live-text",children:"searching"}):"no chat says that":"no chat is named that":u?"no chats yet":d.jsx("span",{className:"live-text",children:"looking"}),footer:(j,$)=>{const O=$.filter(I=>I.kind==="hit").length;return l!=null&&l.truncated&&!T(j)&&O>0?d.jsxs("div",{className:"empty",children:["showing the first ",O,"; narrow the search"]}):null},row:j=>j.kind==="chat"?d.jsx(jn,{label:j.name,hint:j.hint}):d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"chats-text",children:du(j.hit.text,lW(j.hit.match),0)}),d.jsxs("span",{className:"chats-said row-dim",children:[j.hit.role==="user"?"you":"the agent",j.hit.ts>0&&ur(j.hit.ts)!==ur(v.get(j.hit.worktreeId)??0)?` · ${ur(j.hit.ts)}`:""]})]})})}const Zl=function(e,t){let o=e;const i=zc[t];let l=null,c=0,u=null;const h=[],f={},m=function(I,P){c=o*4+17,l=(function(R){const U=new Array(R);for(let F=0;F<R;F+=1){U[F]=new Array(R);for(let B=0;B<R;B+=1)U[F][B]=null}return U})(c),g(0,0),g(c-7,0),g(0,c-7),v(),y(),x(I,P),o>=7&&_(I),u==null&&(u=j(o,i,h)),T(u,P)},g=function(I,P){for(let R=-1;R<=7;R+=1)if(!(I+R<=-1||c<=I+R))for(let U=-1;U<=7;U+=1)P+U<=-1||c<=P+U||(0<=R&&R<=6&&(U==0||U==6)||0<=U&&U<=6&&(R==0||R==6)||2<=R&&R<=4&&2<=U&&U<=4?l[I+R][P+U]=!0:l[I+R][P+U]=!1)},w=function(){let I=0,P=0;for(let R=0;R<8;R+=1){m(!0,R);const U=gi.getLostPoint(f);(R==0||I>U)&&(I=U,P=R)}return P},y=function(){for(let I=8;I<c-8;I+=1)l[I][6]==null&&(l[I][6]=I%2==0);for(let I=8;I<c-8;I+=1)l[6][I]==null&&(l[6][I]=I%2==0)},v=function(){const I=gi.getPatternPosition(o);for(let P=0;P<I.length;P+=1)for(let R=0;R<I.length;R+=1){const U=I[P],F=I[R];if(l[U][F]==null)for(let B=-2;B<=2;B+=1)for(let X=-2;X<=2;X+=1)B==-2||B==2||X==-2||X==2||B==0&&X==0?l[U+B][F+X]=!0:l[U+B][F+X]=!1}},_=function(I){const P=gi.getBCHTypeNumber(o);for(let R=0;R<18;R+=1){const U=!I&&(P>>R&1)==1;l[Math.floor(R/3)][R%3+c-8-3]=U}for(let R=0;R<18;R+=1){const U=!I&&(P>>R&1)==1;l[R%3+c-8-3][Math.floor(R/3)]=U}},x=function(I,P){const R=i<<3|P,U=gi.getBCHTypeInfo(R);for(let F=0;F<15;F+=1){const B=!I&&(U>>F&1)==1;F<6?l[F][8]=B:F<8?l[F+1][8]=B:l[c-15+F][8]=B}for(let F=0;F<15;F+=1){const B=!I&&(U>>F&1)==1;F<8?l[8][c-F-1]=B:F<9?l[8][15-F-1+1]=B:l[8][15-F-1]=B}l[c-8][8]=!I},T=function(I,P){let R=-1,U=c-1,F=7,B=0;const X=gi.getMaskFunction(P);for(let ae=c-1;ae>0;ae-=2)for(ae==6&&(ae-=1);;){for(let Y=0;Y<2;Y+=1)if(l[U][ae-Y]==null){let ne=!1;B<I.length&&(ne=(I[B]>>>F&1)==1),X(U,ae-Y)&&(ne=!ne),l[U][ae-Y]=ne,F-=1,F==-1&&(B+=1,F=7)}if(U+=R,U<0||c<=U){U-=R,R=-R;break}}},N=function(I,P){let R=0,U=0,F=0;const B=new Array(P.length),X=new Array(P.length);for(let C=0;C<P.length;C+=1){const H=P[C].dataCount,V=P[C].totalCount-H;U=Math.max(U,H),F=Math.max(F,V),B[C]=new Array(H);for(let be=0;be<B[C].length;be+=1)B[C][be]=255&I.getBuffer()[be+R];R+=H;const J=gi.getErrorCorrectPolynomial(V),ie=pu(B[C],J.getLength()-1).mod(J);X[C]=new Array(J.getLength()-1);for(let be=0;be<X[C].length;be+=1){const ge=be+ie.getLength()-X[C].length;X[C][be]=ge>=0?ie.getAt(ge):0}}let ae=0;for(let C=0;C<P.length;C+=1)ae+=P[C].totalCount;const Y=new Array(ae);let ne=0;for(let C=0;C<U;C+=1)for(let H=0;H<P.length;H+=1)C<B[H].length&&(Y[ne]=B[H][C],ne+=1);for(let C=0;C<F;C+=1)for(let H=0;H<P.length;H+=1)C<X[H].length&&(Y[ne]=X[H][C],ne+=1);return Y},j=function(I,P,R){const U=_1.getRSBlocks(I,P),F=N1();for(let X=0;X<R.length;X+=1){const ae=R[X];F.put(ae.getMode(),4),F.put(ae.getLength(),gi.getLengthInBits(ae.getMode(),I)),ae.write(F)}let B=0;for(let X=0;X<U.length;X+=1)B+=U[X].dataCount;if(F.getLengthInBits()>B*8)throw"code length overflow. ("+F.getLengthInBits()+">"+B*8+")";for(F.getLengthInBits()+4<=B*8&&F.put(0,4);F.getLengthInBits()%8!=0;)F.putBit(!1);for(;!(F.getLengthInBits()>=B*8||(F.put(236,8),F.getLengthInBits()>=B*8));)F.put(17,8);return N(F,U)};f.addData=function(I,P){P=P||"Byte";let R=null;switch(P){case"Numeric":R=uW(I);break;case"Alphanumeric":R=dW(I);break;case"Byte":R=fW(I);break;case"Kanji":R=hW(I);break;default:throw"mode:"+P}h.push(R),u=null},f.isDark=function(I,P){if(I<0||c<=I||P<0||c<=P)throw I+","+P;return l[I][P]},f.getModuleCount=function(){return c},f.make=function(){if(o<1){let I=1;for(;I<40;I++){const P=_1.getRSBlocks(I,i),R=N1();for(let F=0;F<h.length;F++){const B=h[F];R.put(B.getMode(),4),R.put(B.getLength(),gi.getLengthInBits(B.getMode(),I)),B.write(R)}let U=0;for(let F=0;F<P.length;F++)U+=P[F].dataCount;if(R.getLengthInBits()<=U*8)break}o=I}m(!1,w())},f.createTableTag=function(I,P){I=I||2,P=typeof P>"u"?I*4:P;let R="";R+='<table style="',R+=" border-width: 0px; border-style: none;",R+=" border-collapse: collapse;",R+=" padding: 0px; margin: "+P+"px;",R+='">',R+="<tbody>";for(let U=0;U<f.getModuleCount();U+=1){R+="<tr>";for(let F=0;F<f.getModuleCount();F+=1)R+='<td style="',R+=" border-width: 0px; border-style: none;",R+=" border-collapse: collapse;",R+=" padding: 0px; margin: 0px;",R+=" width: "+I+"px;",R+=" height: "+I+"px;",R+=" background-color: ",R+=f.isDark(U,F)?"#000000":"#ffffff",R+=";",R+='"/>';R+="</tr>"}return R+="</tbody>",R+="</table>",R},f.createSvgTag=function(I,P,R,U){let F={};typeof arguments[0]=="object"&&(F=arguments[0],I=F.cellSize,P=F.margin,R=F.alt,U=F.title),I=I||2,P=typeof P>"u"?I*4:P,R=typeof R=="string"?{text:R}:R||{},R.text=R.text||null,R.id=R.text?R.id||"qrcode-description":null,U=typeof U=="string"?{text:U}:U||{},U.text=U.text||null,U.id=U.text?U.id||"qrcode-title":null;const B=f.getModuleCount()*I+P*2;let X,ae,Y,ne,C="",H;for(H="l"+I+",0 0,"+I+" -"+I+",0 0,-"+I+"z ",C+='<svg version="1.1" xmlns="http://www.w3.org/2000/svg"',C+=F.scalable?"":' width="'+B+'px" height="'+B+'px"',C+=' viewBox="0 0 '+B+" "+B+'" ',C+=' preserveAspectRatio="xMinYMin meet"',C+=U.text||R.text?' role="img" aria-labelledby="'+$([U.id,R.id].join(" ").trim())+'"':"",C+=">",C+=U.text?'<title id="'+$(U.id)+'">'+$(U.text)+"</title>":"",C+=R.text?'<description id="'+$(R.id)+'">'+$(R.text)+"</description>":"",C+='<rect width="100%" height="100%" fill="white" cx="0" cy="0"/>',C+='<path d="',Y=0;Y<f.getModuleCount();Y+=1)for(ne=Y*I+P,X=0;X<f.getModuleCount();X+=1)f.isDark(Y,X)&&(ae=X*I+P,C+="M"+ae+","+ne+H);return C+='" stroke="transparent" fill="black"/>',C+="</svg>",C},f.createDataURL=function(I,P){I=I||2,P=typeof P>"u"?I*4:P;const R=f.getModuleCount()*I+P*2,U=P,F=R-P;return kW(R,R,function(B,X){if(U<=B&&B<F&&U<=X&&X<F){const ae=Math.floor((B-U)/I),Y=Math.floor((X-U)/I);return f.isDark(Y,ae)?0:1}else return 1})},f.createImgTag=function(I,P,R){I=I||2,P=typeof P>"u"?I*4:P;const U=f.getModuleCount()*I+P*2;let F="";return F+="<img",F+=' src="',F+=f.createDataURL(I,P),F+='"',F+=' width="',F+=U,F+='"',F+=' height="',F+=U,F+='"',R&&(F+=' alt="',F+=$(R),F+='"'),F+="/>",F};const $=function(I){let P="";for(let R=0;R<I.length;R+=1){const U=I.charAt(R);switch(U){case"<":P+="&lt;";break;case">":P+="&gt;";break;case"&":P+="&amp;";break;case'"':P+="&quot;";break;default:P+=U;break}}return P},O=function(I){I=typeof I>"u"?2:I;const R=f.getModuleCount()*1+I*2,U=I,F=R-I;let B,X,ae,Y,ne;const C={"██":"█","█ ":"▀"," █":"▄"," ":" "},H={"██":"▀","█ ":"▀"," █":" "," ":" "};let V="";for(B=0;B<R;B+=2){for(ae=Math.floor((B-U)/1),Y=Math.floor((B+1-U)/1),X=0;X<R;X+=1)ne="█",U<=X&&X<F&&U<=B&&B<F&&f.isDark(ae,Math.floor((X-U)/1))&&(ne=" "),U<=X&&X<F&&U<=B+1&&B+1<F&&f.isDark(Y,Math.floor((X-U)/1))?ne+=" ":ne+="█",V+=I<1&&B+1>=F?H[ne]:C[ne];V+=`
256
- `}return R%2&&I>0?V.substring(0,V.length-R-1)+Array(R+1).join("▀"):V.substring(0,V.length-1)};return f.createASCII=function(I,P){if(I=I||1,I<2)return O(P);I-=1,P=typeof P>"u"?I*2:P;const R=f.getModuleCount()*I+P*2,U=P,F=R-P;let B,X,ae,Y;const ne=Array(I+1).join("██"),C=Array(I+1).join(" ");let H="",V="";for(B=0;B<R;B+=1){for(ae=Math.floor((B-U)/I),V="",X=0;X<R;X+=1)Y=1,U<=X&&X<F&&U<=B&&B<F&&f.isDark(ae,Math.floor((X-U)/I))&&(Y=0),V+=Y?ne:C;for(ae=0;ae<I;ae+=1)H+=V+`
257
- `}return H.substring(0,H.length-1)},f.renderTo2dContext=function(I,P){P=P||2;const R=f.getModuleCount();for(let U=0;U<R;U++)for(let F=0;F<R;F++)I.fillStyle=f.isDark(U,F)?"black":"white",I.fillRect(F*P,U*P,P,P)},f};Zl.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};Zl.createStringToBytes=function(e,t){const n=(function(){const o=mW(e),i=function(){const u=o.read();if(u==-1)throw"eof";return u};let l=0;const c={};for(;;){const u=o.read();if(u==-1)break;const h=i(),f=i(),m=i(),g=String.fromCharCode(u<<8|h),w=f<<8|m;c[g]=w,l+=1}if(l!=t)throw l+" != "+t;return c})(),r=63;return function(o){const i=[];for(let l=0;l<o.length;l+=1){const c=o.charCodeAt(l);if(c<128)i.push(c);else{const u=n[o.charAt(l)];typeof u=="number"?(u&255)==u?i.push(u):(i.push(u>>>8),i.push(u&255)):i.push(r)}}return i}};const zr={MODE_NUMBER:1,MODE_ALPHA_NUM:2,MODE_8BIT_BYTE:4,MODE_KANJI:8},zc={L:1,M:0,Q:3,H:2},mi={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7},gi=(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={},i=function(l){let c=0;for(;l!=0;)c+=1,l>>>=1;return c};return o.getBCHTypeInfo=function(l){let c=l<<10;for(;i(c)-i(t)>=0;)c^=t<<i(c)-i(t);return(l<<10|c)^r},o.getBCHTypeNumber=function(l){let c=l<<12;for(;i(c)-i(n)>=0;)c^=n<<i(c)-i(n);return l<<12|c},o.getPatternPosition=function(l){return e[l-1]},o.getMaskFunction=function(l){switch(l){case mi.PATTERN000:return function(c,u){return(c+u)%2==0};case mi.PATTERN001:return function(c,u){return c%2==0};case mi.PATTERN010:return function(c,u){return u%3==0};case mi.PATTERN011:return function(c,u){return(c+u)%3==0};case mi.PATTERN100:return function(c,u){return(Math.floor(c/2)+Math.floor(u/3))%2==0};case mi.PATTERN101:return function(c,u){return c*u%2+c*u%3==0};case mi.PATTERN110:return function(c,u){return(c*u%2+c*u%3)%2==0};case mi.PATTERN111:return function(c,u){return(c*u%3+(c+u)%2)%2==0};default:throw"bad maskPattern:"+l}},o.getErrorCorrectPolynomial=function(l){let c=pu([1],0);for(let u=0;u<l;u+=1)c=c.multiply(pu([1,yi.gexp(u)],0));return c},o.getLengthInBits=function(l,c){if(1<=c&&c<10)switch(l){case zr.MODE_NUMBER:return 10;case zr.MODE_ALPHA_NUM:return 9;case zr.MODE_8BIT_BYTE:return 8;case zr.MODE_KANJI:return 8;default:throw"mode:"+l}else if(c<27)switch(l){case zr.MODE_NUMBER:return 12;case zr.MODE_ALPHA_NUM:return 11;case zr.MODE_8BIT_BYTE:return 16;case zr.MODE_KANJI:return 10;default:throw"mode:"+l}else if(c<41)switch(l){case zr.MODE_NUMBER:return 14;case zr.MODE_ALPHA_NUM:return 13;case zr.MODE_8BIT_BYTE:return 16;case zr.MODE_KANJI:return 12;default:throw"mode:"+l}else throw"type:"+c},o.getLostPoint=function(l){const c=l.getModuleCount();let u=0;for(let m=0;m<c;m+=1)for(let g=0;g<c;g+=1){let w=0;const y=l.isDark(m,g);for(let v=-1;v<=1;v+=1)if(!(m+v<0||c<=m+v))for(let _=-1;_<=1;_+=1)g+_<0||c<=g+_||v==0&&_==0||y==l.isDark(m+v,g+_)&&(w+=1);w>5&&(u+=3+w-5)}for(let m=0;m<c-1;m+=1)for(let g=0;g<c-1;g+=1){let w=0;l.isDark(m,g)&&(w+=1),l.isDark(m+1,g)&&(w+=1),l.isDark(m,g+1)&&(w+=1),l.isDark(m+1,g+1)&&(w+=1),(w==0||w==4)&&(u+=3)}for(let m=0;m<c;m+=1)for(let g=0;g<c-6;g+=1)l.isDark(m,g)&&!l.isDark(m,g+1)&&l.isDark(m,g+2)&&l.isDark(m,g+3)&&l.isDark(m,g+4)&&!l.isDark(m,g+5)&&l.isDark(m,g+6)&&(u+=40);for(let m=0;m<c;m+=1)for(let g=0;g<c-6;g+=1)l.isDark(g,m)&&!l.isDark(g+1,m)&&l.isDark(g+2,m)&&l.isDark(g+3,m)&&l.isDark(g+4,m)&&!l.isDark(g+5,m)&&l.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)l.isDark(g,m)&&(h+=1);const f=Math.abs(100*h/c/c-50)/5;return u+=f*10,u},o})(),yi=(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})(),pu=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 i=new Array(e.length-o+t);for(let l=0;l<e.length-o;l+=1)i[l]=e[l+o];return i})(),r={};return r.getAt=function(o){return n[o]},r.getLength=function(){return n.length},r.multiply=function(o){const i=new Array(r.getLength()+o.getLength()-1);for(let l=0;l<r.getLength();l+=1)for(let c=0;c<o.getLength();c+=1)i[l+c]^=yi.gexp(yi.glog(r.getAt(l))+yi.glog(o.getAt(c)));return pu(i,0)},r.mod=function(o){if(r.getLength()-o.getLength()<0)return r;const i=yi.glog(r.getAt(0))-yi.glog(o.getAt(0)),l=new Array(r.getLength());for(let c=0;c<r.getLength();c+=1)l[c]=r.getAt(c);for(let c=0;c<o.getLength();c+=1)l[c]^=yi.gexp(yi.glog(o.getAt(c))+i);return pu(l,0).mod(o)},r},_1=(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,i){const l={};return l.totalCount=o,l.dataCount=i,l},n={},r=function(o,i){switch(i){case zc.L:return e[(o-1)*4+0];case zc.M:return e[(o-1)*4+1];case zc.Q:return e[(o-1)*4+2];case zc.H:return e[(o-1)*4+3];default:return}};return n.getRSBlocks=function(o,i){const l=r(o,i);if(typeof l>"u")throw"bad rs block @ typeNumber:"+o+"/errorCorrectionLevel:"+i;const c=l.length/3,u=[];for(let h=0;h<c;h+=1){const f=l[h*3+0],m=l[h*3+1],g=l[h*3+2];for(let w=0;w<f;w+=1)u.push(t(m,g))}return u},n})(),N1=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 i=0;i<o;i+=1)n.putBit((r>>>o-i-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},uW=function(e){const t=zr.MODE_NUMBER,n=e,r={};r.getMode=function(){return t},r.getLength=function(l){return n.length},r.write=function(l){const c=n;let u=0;for(;u+2<c.length;)l.put(o(c.substring(u,u+3)),10),u+=3;u<c.length&&(c.length-u==1?l.put(o(c.substring(u,u+1)),4):c.length-u==2&&l.put(o(c.substring(u,u+2)),7))};const o=function(l){let c=0;for(let u=0;u<l.length;u+=1)c=c*10+i(l.charAt(u));return c},i=function(l){if("0"<=l&&l<="9")return l.charCodeAt(0)-48;throw"illegal char :"+l};return r},dW=function(e){const t=zr.MODE_ALPHA_NUM,n=e,r={};r.getMode=function(){return t},r.getLength=function(i){return n.length},r.write=function(i){const l=n;let c=0;for(;c+1<l.length;)i.put(o(l.charAt(c))*45+o(l.charAt(c+1)),11),c+=2;c<l.length&&i.put(o(l.charAt(c)),6)};const o=function(i){if("0"<=i&&i<="9")return i.charCodeAt(0)-48;if("A"<=i&&i<="Z")return i.charCodeAt(0)-65+10;switch(i){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 :"+i}};return r},fW=function(e){const t=zr.MODE_8BIT_BYTE,n=Zl.stringToBytes(e),r={};return r.getMode=function(){return t},r.getLength=function(o){return n.length},r.write=function(o){for(let i=0;i<n.length;i+=1)o.put(n[i],8)},r},hW=function(e){const t=zr.MODE_KANJI,n=Zl.stringToBytes;(function(i,l){const c=n(i);if(c.length!=2||(c[0]<<8|c[1])!=l)throw"sjis not supported."})("友",38726);const r=n(e),o={};return o.getMode=function(){return t},o.getLength=function(i){return~~(r.length/2)},o.write=function(i){const l=r;let c=0;for(;c+1<l.length;){let u=(255&l[c])<<8|255&l[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),i.put(u,13),c+=2}if(c<l.length)throw"illegal char at "+(c+1)},o},Vj=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 i=0;i<o;i+=1)t.writeByte(n[i+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},pW=function(){let e=0,t=0,n=0,r="";const o={},i=function(c){r+=String.fromCharCode(l(c&63))},l=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;)i(e>>>t-6),t-=6},o.flush=function(){if(t>0&&(i(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},mW=function(e){const t=e;let n=0,r=0,o=0;const i={};i.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|l(u.charCodeAt(0)),o+=6}const c=r>>>o-8&255;return o-=8,c};const l=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 i},gW=function(e,t){const n=e,r=t,o=new Array(e*t),i={};i.setPixel=function(h,f,m){o[f*n+h]=m},i.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 l=function(h){const f=h;let m=0,g=0;const w={};return w.write=function(y,v){if(y>>>v)throw"length over";for(;m+v>=8;)f.writeByte(255&(y<<m|g)),v-=8-m,y>>>=8-m,g=0,m=0;g=y<<m|g,m=m+v},w.flush=function(){m>0&&f.writeByte(g)},w},c=function(h){const f=1<<h,m=(1<<h)+1;let g=h+1;const w=u();for(let T=0;T<f;T+=1)w.add(String.fromCharCode(T));w.add(String.fromCharCode(f)),w.add(String.fromCharCode(m));const y=Vj(),v=l(y);v.write(f,g);let _=0,x=String.fromCharCode(o[_]);for(_+=1;_<o.length;){const T=String.fromCharCode(o[_]);_+=1,w.contains(x+T)?x=x+T:(v.write(w.indexOf(x),g),w.size()<4095&&(w.size()==1<<g&&(g+=1),w.add(x+T)),x=T)}return v.write(w.indexOf(x),g),v.write(m,g),v.flush(),y.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 i},kW=function(e,t,n){const r=gW(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=Vj();r.write(o);const i=pW(),l=o.toByteArray();for(let c=0;c<l.length;c+=1)i.writeByte(l[c]);return i.flush(),"data:image/gif;base64,"+i};Zl.stringToBytes;function wW(e){const t=Zl(0,"M");t.addData(e,"Byte"),t.make();const n=t.getModuleCount();return Array.from({length:n},(r,o)=>Array.from({length:n},(i,l)=>t.isDark(o,l)))}const cr={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 ${eh(e)}.`,waiting:(e,t)=>`Toyon on ${eh(e)} is asking whether to let ${t} in.`,added:e=>`Added ${e}.`,notKept:e=>`Let in, but not listed: ${e}`,add:"add"};function yW(e,t){return e.reached?e.toyon&&!e.toyon.answering?cr.notAnswering:t?cr.listed:e.toyon?null:cr.noToyon:cr.offline}function T1(e){var t;return(t=e.toyon)!=null&&t.answering?0:e.toyon?1:e.reached?2:3}function eh(e){try{return new URL(e).host}catch{return e}}function Yj(e,t,n){const r=eh(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 vW(e,t,n){const r=(o,i)=>({word:o,note:i,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",cr.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 bW=e=>e==="phone"?"phone":"laptop";function j1({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:He("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(_t,{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:He("tailnet-right",typeof t.right=="string"&&"hint"),children:t.right})]},t.key))})}const $1=(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:bW(e.kind),right:t}},Ym=4;function xW({text:e}){const{size:t,d:n}=S.useMemo(()=>{const r=wW(e);let o="";return r.forEach((i,l)=>{i.forEach((c,u)=>{c&&(o+=`M${u+Ym} ${l+Ym}h1v1h-1z`)})}),{size:r.length+Ym*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 EW=5e3;function SW(e){return e.from===null?"A device that opened this address":`A Toyon page at ${eh(e.from)}`}function _W({knock:e,letIn:t,onAnswer:n}){return d.jsxs("div",{className:He("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?`${SW(e)} wants in.`:t?"is in.":"was turned away."})]}),t===null&&d.jsxs("div",{className:"devices-actions",children:[d.jsx(De,{tone:"primary",onClick:()=>n(!0),children:"let in"}),d.jsx(De,{variant:"outline",onClick:()=>n(!1),children:"not now"})]})]})}function NW({host:e,noPhone:t}){return d.jsxs("div",{className:"devices-address",children:[d.jsx("div",{className:"devices-frame",children:d.jsx(xW,{text:JC(e)})}),d.jsxs("div",{className:"devices-about",children:[d.jsx("p",{className:"devices-line",children:cr.scan}),t&&d.jsx("p",{className:"devices-note",children:cr.noPhone})]})]})}function TW(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)=>T1(r.d)-T1(o.d)||r.i-o.i).map(({d:r})=>r);return[...t,...n]}function jW(){const e=ct(),t=ss(),n=Ur(),r=L(ve=>ve.frame==="desk"),o=L(ve=>{var ce;return((ce=ve.remote)==null?void 0:ce.host)??null}),i=L(ve=>ve.machine),l=L(ve=>ve.tailscale),c=L(ve=>ve.knocks),[u,h]=S.useState(""),[f,m]=S.useState({kind:"idle"}),[g,w]=S.useState([]),y=()=>e({a:"close"}),v=f.kind==="asking"||f.kind==="waiting",_=fD(()=>dL(n),EW,!v),x=S.useRef(new AbortController);S.useEffect(()=>()=>x.current.abort(),[]);const T=async ve=>{if(v)return;const ce=x.current.signal;m({kind:"asking",origin:ve});const Se=await aS(ve,ce,Ie=>m({kind:"waiting",origin:ve,word:Ie}));if(ce.aborted)return;if(typeof Se=="string"){m({kind:"failed",line:Yj(Se,ve,"this page")});return}const me=t.serving(),Ue=await gL(Bk(me.origin,me.token),ve,Se.token);m(Ue?{kind:"failed",line:cr.notKept(Ue)}:{kind:"added",name:t.displayName(ve)})},N=()=>{const ve=eA(u);ve?T(ve):m({kind:"failed",line:cr.notAnAddress})},j=()=>{x.current.abort(),x.current=new AbortController,m({kind:"idle"})},$=(ve,ce)=>{w(Se=>Se.some(me=>me.knock.id===ve.id)?Se:[...Se,{knock:ve,letIn:ce}]),kL(n,ve.id,ce)},O=c.filter(ve=>!g.some(ce=>ce.knock.id===ve.id)),I=[...g,...O.map(ve=>({knock:ve,letIn:null}))],[P,R]=S.useState(!1),[U,F]=S.useState(null),B=async ve=>{R(!0),F(null);const ce=await(ve?fL(n):hL(n));R(!1),ce&&F(ce)},X=(_==null?void 0:_.here)===!0,ae=vW(_,l,o),Y=o!==null,ne=r&&(X||_===void 0)?d.jsx(De,{variant:"outline",size:"sm",on:Y,"aria-pressed":Y,busy:P,disabled:!Y&&(l==null?void 0:l.state)!=="ready",onClick:()=>void B(!Y),...zt(Y?"Take this machine's name off your tailnet":"Give this machine a name on your tailnet"),children:Y?"on":"off"}):null,[C,H]=S.useState(!1),[V,J]=S.useState(null),Z=ve=>{window.open(ve,"_blank","noopener")===null?J(ve):J(null)},ie=async ve=>{if(H(!0),F(null),ve==="connect"){const ce=await pL(n);ce&&F(ce)}else{const ce=await mL(n);"url"in ce?Z(ce.url):F(ce.why)}H(!1)},be=r&&ae.offer!==null?V!==null?d.jsx(De,{variant:"outline",size:"sm",onClick:()=>Z(V),children:"open the sign-in page"}):d.jsx(De,{variant:"outline",size:"sm",busy:C,onClick:()=>void ie(ae.offer??"connect"),...ae.note?zt(ae.note):{},children:ae.offer==="connect"?"connect":"sign in"}):null,ge=ae.word===null&&ne===null&&be===null?"this machine":d.jsxs(d.Fragment,{children:[ae.word&&d.jsx("span",{className:"hint",children:ae.word}),ne??be]}),we=[{key:"self",name:i??"This machine",host:o??void 0,reached:_===void 0?null:X,icon:"laptop",right:ge}],pe=_?TW(_).map(ve=>{if(ve.kind==="phone"||ve.host==="")return $1(ve,ve.reached?void 0:"not answering");const ce=`https://${ve.host}`,Se=yW(ve,t.get(ce)!==null);return $1(ve,Se??d.jsx(De,{variant:"outline",size:"sm",disabled:v,onClick:()=>void T(ce),children:cr.request}))}):[],Q=r&&o!==null&&_!==null&&(_===void 0||_.here),W=_==null?void 0:_.devices.some(ve=>ve.kind==="machine"&&ve.host!==""&&ve.reached&&ve.toyon===null),ye=Q&&_!==void 0&&!_.devices.some(ve=>ve.kind==="phone"),_e=(()=>{switch(f.kind){case"asking":return cr.asking(f.origin);case"waiting":return cr.waiting(f.origin,f.word);case"added":return cr.added(f.name);case"failed":return f.line;case"idle":return null}})();return d.jsxs(uu,{boxClass:"devices-card",onClose:y,children:[d.jsx("div",{className:"devices-title",children:cr.title}),d.jsx(j1,{rows:we}),ae.note&&ae.offer===null&&d.jsx("p",{className:"devices-note",children:ae.note}),U&&d.jsx("p",{className:"devices-note",children:U}),r&&!Y&&(l==null?void 0:l.state)==="ready"&&d.jsx("p",{className:"devices-note",children:cr.turnOn}),Q&&o!==null&&d.jsx(NW,{host:o,noPhone:ye}),f.kind==="waiting"&&d.jsx("div",{className:"knock-word devices-word",children:f.word}),_e&&d.jsx("p",{className:He("devices-line",f.kind==="failed"&&"devices-failed"),children:_e}),_!==void 0&&d.jsxs(d.Fragment,{children:[pe.length>0&&d.jsx("div",{className:"devices-others",children:d.jsx(j1,{rows:pe})}),(_==null?void 0:_.devices.length)===0&&d.jsx("p",{className:"devices-note",children:cr.noneOnTailnet}),W&&d.jsx("p",{className:"devices-note",children:cr.missing})]}),!v&&d.jsxs("form",{className:"devices-form",onSubmit:ve=>{ve.preventDefault(),N()},children:[d.jsx(zo,{size:"md",font:"ui",value:u,placeholder:cr.placeholder,"aria-label":"Address of the other machine",onChange:ve=>h(ve.target.value),className:"devices-field"}),d.jsx(De,{type:"submit",variant:"outline",disabled:!u.trim(),children:cr.add})]}),v&&d.jsx("div",{className:"devices-actions",children:d.jsx(De,{tone:"quiet",onClick:j,children:"cancel"})}),O.length>0&&d.jsx("p",{className:"devices-line devices-centred",children:cr.knocking}),I.map(ve=>d.jsx(_W,{knock:ve.knock,letIn:ve.letIn,onAnswer:ce=>$(ve.knock,ce)},ve.knock.id))]})}function $W({worktreeId:e,hits:t}){const n=ct(),r=rt(),o=L(c=>c.layout.changes),i=L(c=>{var h;const u=(h=rn(c,e))==null?void 0:h.worktree;return u?u.path:null}),l=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(Br,{items:t,filter:l,keyOf:c=>`${c.path}:${c.line}`,rowClass:()=>"search-hit",rowTitle:c=>`${c.path}:${c.line}`,onPick:c=>{Ln({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=>i?Is({id:e,dir:i},c.path,{},{sock:r,dispatch:n}):[],placeholder:"lines that could write this element",keys:{pick:"opens the file",back:"closes"},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 CW({project:e}){const t=ct(),n=rt(),r=L(h=>h.paths),o=L(h=>h.home),i=S.useCallback(h=>{au(h)&&(n==null||n.send({t:"browse-path",path:h}))},[n]),l=S.useCallback((h,f)=>_8({query:f,entries:r.entries,target:r.target,answered:r.query,home:o}),[r,o]),c=Xc(e.name)?null:e.name.trim(),u=h=>`${h.replace(/\/+$/,"")}/`;return d.jsx(Br,{initialQuery:u(e.parent),lead:d.jsx("span",{className:"picker-chip",children:c??"new project"}),items:[],filter:l,keyOf:h=>h.kind==="dir"?`d:${h.entry.path}`:`${h.kind}:${h.path}`,rowClass:()=>"picker-row folder-row",onQuery:i,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(jn,{label:`put ${c??"it"} in ${Yg(h.path,o)}`,hint:d.jsx("bdi",{children:c?fT(h.path,c):h.path})}):h.kind==="up"?d.jsx(jn,{label:`up to ${Yg(h.path,o)}`,hint:d.jsx("bdi",{children:h.path})}):d.jsx(jn,{label:h.entry.name})})}const AW={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 IW(){const e=ct(),t=rt(),n=L(r=>r.keepAwake);return d.jsx(Br,{items:[...TC],filter:(r,o)=>r.filter(i=>Jo(o,Zf[i])),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",keys:{pick:"sets",back:"closes"},row:r=>d.jsx(jn,{label:Zf[r],current:r===n,hint:AW[r]})})}function RW(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=Gg(t.rows,null);return n?`${n.n} ${n.tier==="waiting"?"waiting":"unread"}`:"all quiet"}function pk(e){try{return tA(new URL(e).hostname)}catch{return!1}}function OW(e){const t=new Set,n=e.build({...e.serving,serving:!0}),r=[];let o=n,i=[n];const l=()=>{i=[n,...r];for(const y of t)y()},c=new Map,u=y=>{var _;if(y.serving)return;(((_=y.store.getState().remote)==null?void 0:_.front)==="edge"||pk(y.origin))&&y!==o?y.sock.suspend():y.sock.resume()},h=y=>{var _;let v=(_=y.store.getState().remote)==null?void 0:_.front;c.set(y.origin,y.store.subscribe(()=>{var T;const x=(T=y.store.getState().remote)==null?void 0:T.front;x!==v&&(v=x,u(y))}))},f=()=>i,m={list:f,active:()=>o,serving:()=>n,get:y=>f().find(v=>v.origin===y)??null,displayName(y){const v=f().find(x=>x.origin===y);return v?f().filter(x=>x.name===v.name).length>1?`${v.name} (${new URL(v.origin).host})`:v.name:y},activate(y){const v=f().find(x=>x.origin===y);if(!v||v===o)return;const _=o;o=v,u(_),u(v),l()},add(y){var x;const v=r.find(T=>T.origin===y.origin);if(y.origin===n.origin)return n;if(v){if(v.token===y.token)return v;(x=c.get(v.origin))==null||x(),v.dispose(),r.splice(r.indexOf(v),1),o===v&&(o=n)}const _=e.build({...y,serving:!1});return r.push(_),h(_),pk(_.origin)&&_.sock.suspend(),l(),_},remove(y){var _;const v=r.find(x=>x.origin===y);v&&((_=c.get(y))==null||_(),c.delete(y),v.dispose(),v.storage.clear(),v.forget(),r.splice(r.indexOf(v),1),o===v&&(o=n),l())},broadcast(y){for(const v of f())v.store.dispatch(y)},subscribe(y){return t.add(y),()=>t.delete(y)}},g=y=>{for(const v of y)m.add(v);for(const v of[...r])y.some(_=>_.origin===v.origin)||m.remove(v.origin)};let w=n.store.getState().handed;return n.store.subscribe(()=>{const y=n.store.getState().handed;y!==w&&(w=y,g(w))}),g(w),m}function my({form:e,anchored:t}){var ne;const n=ct(),r=rt(),o=ss(),i=mo(),l=o.displayName(i.origin),c=L(C=>C.repos),u=L(C=>C.newProject?null:C.activeRepoId),h=L(C=>C.rows),f=L(C=>C.paths),m=L(C=>C.home),g=L(C=>C.pending),w=L(C=>C.folderDialog),y=S.useRef(""),v=S.useMemo(()=>v0(c,h),[c,h]),_=VS(),x=YS(),T=S.useMemo(()=>_.map(C=>{var H;return{...C,repos:v0(C.repos,((H=x.find(V=>V.origin===C.origin))==null?void 0:H.rows)??[])}}),[_,x]),N=S.useCallback(C=>{y.current=C,au(C)&&(r==null||r.send({t:"browse-path",path:C}))},[r]),j=S.useCallback((C,H)=>S8({query:H,repos:v,pending:g,entries:[...f.entries].sort((V,J)=>Number(J.isRepo)-Number(V.isRepo)),target:f.target,answered:f.query,home:m,others:T,current:u}),[v,f,g,m,T,u]),$=C=>Xj(h,C),O=()=>n({a:"close"}),I=()=>n({a:"close",back:!0}),P={sock:r,dispatch:n},R=C=>lu(P,{t:"register-repo",path:C}),U=(C,H)=>lu(P,{t:"create-repo",mode:"create",parent:C,name:H}),F=(C,H,V)=>n({a:"new-project",v:Qk({mode:C,name:H,parent:E8(c,u,m),...V?{url:V}:{}})}),B=()=>n({a:"open",overlay:{kind:"projects",form:"disk"}}),X=()=>{const C=y.current.trim(),H=C.lastIndexOf("/"),V=au(C)&&H>=0?C.slice(0,H)||"/":"~";r==null||r.send({t:"choose-file",start:V}),O()},ae=()=>n({a:"open",overlay:{kind:"devices"}}),Y=(C,H)=>{const V=o.get(C);V&&(V.store.dispatch({a:"activate-repo",id:H}),o.activate(C))};return d.jsx(Br,{anchored:e==="pill"&&(t??!0),initialQuery:e==="disk"?"~/":"",lead:e==="disk"?void 0:d.jsx("span",{className:"picker-chip",children:((ne=c.find(C=>C.id===u))==null?void 0:ne.name)??"no project"}),trailing:e==="disk"?w?d.jsx(Ot,{icon:"file",label:"Open a file from Finder",onClick:X}):void 0:d.jsx(Ot,{icon:"folder",label:"Find a project or file on disk",onClick:B}),items:[],filter:j,initialIndex:C=>C.findIndex(H=>H.kind==="repo"&&!H.machine&&H.repo.id===u),groupOf:C=>C.kind==="machine"||C.kind==="repo"&&C.machine?C.machine.origin:i.origin,groupHead:C=>C===i.origin?l:d.jsx(MW,{origin:C}),keyOf:C=>C.kind==="repo"?C.machine?`${C.machine.origin}:${C.repo.id}`:C.repo.id:C.kind==="dir"?`d:${C.entry.path}`:C.kind==="file"?`f:${C.entry.path}`:C.kind==="open"?`open:${C.path}`:C.kind==="init"?`init:${C.path}`:C.kind==="pending"?`p:${C.pending.id}`:C.kind==="clone"?`clone:${C.url}`:C.kind==="new"?"new-project":C.kind==="disk"?"open-folder":C.kind==="add-machine"?"add-machine":C.kind==="machine"?`machine:${C.machine.origin}`:`new:${C.parent??""}/${C.name}`,rowClass:C=>He("picker-row",(C.kind==="new"||C.kind==="disk"||C.kind==="add-machine")&&"new-project-row"),onQuery:N,completionOf:C=>C.kind==="dir"?C.entry.isRepo?C.entry.path:`${C.entry.path}/`:C.kind==="file"?C.entry.path:null,narrowTo:C=>C.kind==="dir"&&!C.entry.isRepo?`${C.entry.path}/`:null,onPick:C=>{if(C.kind==="clone")return F("clone",C.name,C.url);if(C.kind==="create"&&!C.parent)return F("create",C.name);if(C.kind==="new")return F("create","");if(C.kind==="disk")return B();if(C.kind==="add-machine")return ae();C.kind==="machine"?o.activate(C.machine.origin):C.kind==="pending"?n({a:"watch-import",id:C.pending.id}):C.kind==="repo"&&C.machine?Y(C.machine.origin,C.repo.id):C.kind==="repo"?n({a:"activate-repo",id:C.repo.id}):C.kind==="open"?R(C.path):C.kind==="file"?i6(r,C.entry.path):C.kind==="init"?pT(P,C.path):C.kind==="dir"?R(C.entry.path):C.parent&&U(C.parent,C.name),O()},onBack:I,rowMenu:C=>C.kind==="machine"||C.kind==="repo"&&C.machine?Vg(o,C.machine.origin):C.kind==="repo"?Dh(C.repo,u,P):C.kind==="pending"?N8(C.pending,P):[],placeholder:c.length>1?"switch project, or type a name or path":"type a name or a path to start",keys:C=>({complete:"completes the path",pick:(C==null?void 0:C.kind)==="dir"&&!C.entry.isRepo?"descends":(C==null?void 0:C.kind)==="pending"?"watches it":(C==null?void 0:C.kind)==="create"?C.parent?"creates it":"names it":(C==null?void 0:C.kind)==="clone"?"clones it":(C==null?void 0:C.kind)==="new"?"starts one":(C==null?void 0:C.kind)==="disk"?"browses":(C==null?void 0:C.kind)==="add-machine"?"adds one":(C==null?void 0:C.kind)==="machine"||(C==null?void 0:C.kind)==="repo"&&C.machine?"switches machine":"opens",back:"closes"}),empty:"nothing here; keep typing a path (~/… or /…)",row:C=>C.kind==="repo"&&C.machine?d.jsx(jn,{label:C.repo.name,hint:d.jsx(PW,{origin:C.machine.origin,repo:C.repo})}):C.kind==="repo"?d.jsx(jn,{label:C.repo.name,current:C.repo.id===u,hint:$(C.repo)}):C.kind==="pending"?d.jsx(jn,{label:C.pending.name,hint:C.pending.error?"import failed":d.jsx("span",{className:"live-text",children:"importing"})}):C.kind==="dir"?d.jsx(jn,{label:C.entry.name,hint:C.entry.isRepo?"git repo":void 0}):C.kind==="file"?d.jsx(jn,{label:C.entry.name,hint:"file"}):C.kind==="open"?d.jsx(jn,{label:`open ${C.path}`,hint:"register with this daemon"}):C.kind==="init"?d.jsx(jn,{label:`open ${C.path}`,hint:"no git yet; starts it here with the files in it"}):C.kind==="clone"?d.jsx(jn,{label:`clone ${C.name}`,hint:LW(C.url)}):C.kind==="new"?d.jsx(jn,{label:d.jsxs(d.Fragment,{children:[d.jsx(_t,{name:"plus",className:"icon-inline"}),"new project"]})}):C.kind==="disk"?d.jsx(jn,{label:d.jsxs(d.Fragment,{children:[d.jsx(_t,{name:"folder",className:"icon-inline"}),"open folder or file"]})}):C.kind==="add-machine"?d.jsx(jn,{label:d.jsxs(d.Fragment,{children:[d.jsx(_t,{name:"devices",className:"icon-inline"}),"add a machine"]})}):C.kind==="machine"?d.jsx(jn,{label:`switch to ${o.displayName(C.machine.origin)}`}):d.jsx(jn,{label:`create ${C.name}`,hint:C.parent?`in ${C.parent}`:"new project"})})}function Xj(e,t){const n=e.filter(u=>u.repoId===t.id),r=n.filter(Sn).filter(u=>u.worktree.kind!=="spare"),o=r.filter(u=>Fo(u.agent)).length,i=r.length-1,l=n.length-n.filter(Sn).length;return[i>0?`${i} worktree${i===1?"":"s"}`:null,o>0?`${o} working`:null,l>0?`${l} discovered`:null].filter(Boolean).join(" · ")||void 0}function MW({origin:e}){const t=ss(),n=t.get(e)??t.active(),r=dl(n,m=>m.rows),o=dl(n,m=>m.connected),i=dl(n,m=>m.connectFailure),l=dl(n,m=>m.incompatible),c=dl(n,m=>{var g;return(g=m.remote)==null?void 0:g.front}),u=t.displayName(e),h=RW(u,{rows:r.filter(Sn),connected:o,connectFailure:i,incompatible:l,suspended:(c==="edge"||pk(e))&&!o}),f=/^\d+ /.test(h);return d.jsxs(d.Fragment,{children:[u,d.jsx("span",{className:He("picker-group-tail",f&&"picker-group-owed"),children:h})]})}function PW({origin:e,repo:t}){const n=ss(),r=n.get(e),o=dl(r??n.active(),i=>i.rows);return d.jsx(d.Fragment,{children:r?Xj(o,t):null})}function LW(e){const t=e.match(/^[a-z+]+:\/\/(?:[^@/]*@)?([^/:]+)/i)??e.match(/^[^@]+@([^:]+):/);return(t==null?void 0:t[1])??"git remote"}function DW(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:()=>Yt(r)})}const n=[{id:"copy-ref",label:e.kind==="pr"?"copy PR number":"copy branch name",onClick:()=>Yt(e.ref)}];return Dn([t,n])}const zW=[],FW={branch:"branch",remote:"globe",pr:"pr"},C1={pr:0,branch:1,remote:2},BW={pr:"pull requests",branch:"branches",remote:"remote branches"};function UW({repoId:e}){const t=ct(),n=rt(),r=L(m=>m.clientId),o=L(m=>m.refs[e]),i=L(m=>m.rows),l=m=>{var g;return((g=i.find(w=>w.id===m))==null?void 0:g.name)??"a worktree"},c=S.useCallback(m=>[...m].sort((g,w)=>C1[g.kind]-C1[w.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 ${l(m.openIn)}`:m.merged?"merged":m.pr?`${m.pr.author}${m.pr.draft?" · draft":""}${m.pr.fork?" · fork":""}`:m.subject??"";return d.jsx(Br,{items:(o==null?void 0:o.refs)??zW,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:DW,groupOf:m=>m.kind,groupHead:(m,g)=>`${BW[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(jn,{label:d.jsxs(d.Fragment,{children:[d.jsx(_t,{name:FW[m.kind],className:"icon-inline"}),d.jsx("span",{className:"ref-name",children:m.name})]}),hint:f(m)})})}const A1=[],Xm=2;function HW({worktreeId:e}){const t=ct(),n=rt(),r=i_(e).search,o=L(h=>h.layout.changes),i=L(h=>{var m;const f=(m=rn(h,e))==null?void 0:m.worktree;return f?f.path:null}),l=S.useCallback((h,f)=>f.trim().length>=Xm?h:A1,[]),c=S.useCallback(h=>{const f=h.trim();f.length>=Xm&&(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(Br,{items:(r==null?void 0:r.hits)??A1,filter:l,onQuery:c,keyOf:h=>`${h.path}:${h.line}`,rowClass:()=>"search-hit",rowTitle:h=>`${h.path}:${h.line}`,onPick:h=>{Ln({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=>i?Is({id:e,dir:i},h.path,{},{sock:n,dispatch:t}):[],placeholder:"search in files…",keys:{pick:"opens the file",back:"closes"},empty:h=>h.trim().length<Xm?"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=>d.jsxs(d.Fragment,{children:[d.jsxs("span",{className:"search-loc",children:[h.path,":",h.line]}),d.jsx("span",{className:"search-text",children:h.text})]})})}function WW({worktreeId:e}){const t=ct(),n=rt(),r=L(g=>g.clientId),o=L(g=>rn(g,e)),i=L(g=>g.repos),c=Rt(e,"draft").trim(),u=o==null?void 0:o.worktree.repoId,h=S.useMemo(()=>[...i.filter(g=>g.id===u),...i.filter(g=>g.id!==u)],[i,u]),f=()=>t({a:"close"}),m=g=>{if(!o)return f();n==null||n.send({t:"pieces-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(Br,{lead:d.jsx("span",{className:"picker-chip",children:(o==null?void 0:o.worktree.title)??"worktree"}),items:h,filter:(g,w)=>g.filter(y=>y.id===u&&Jo(w,"here")||Jo(w,y.name,y.path)),keyOf:g=>g.id,row:g=>d.jsx(jn,{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",keys:{pick:"continues there",back:"closes"},footer:c?()=>d.jsxs("div",{className:"empty",children:["with your message: ",c.split(`
258
- `)[0]]}):void 0})}const I1=e=>e.source==="file"?"~/.toyon/themes":e.source==="vscode"?"VS Code":"";function KW({slot:e}){const t=ct(),n=rt(),r=L(T=>T.themePrefs),o=L(T=>T.themes),i=sw(),l=Fk(r,i),c=r[e==="theme"?l:e],u=()=>t({a:"close"}),h=()=>t({a:"close",back:!0}),f=T=>t({a:"preview-theme",theme:T}),[m,g]=S.useState(null),[w,y]=S.useState(null),v=(T,N)=>T[N??l]??T.dark??T.light??null,_=S.useMemo(()=>ZP(o),[o]),x=S.useMemo(()=>o.filter(T=>T.kind===e),[o,e]);return ft([m,w],()=>{e==="theme"&&f(m?v(m,w):null)}),e!=="theme"?d.jsx(Br,{items:x,filter:(T,N)=>T.filter(j=>Jo(N,j.name,j.id)),rowClass:()=>"picker-row",keyOf:T=>T.id,initialIndex:T=>T.findIndex(N=>N.id===c),onActive:f,onPick:T=>{n==null||n.send({t:"set-theme",prefs:{...r,[e]:T.id}}),u()},onBack:h,placeholder:`${e} slot override`,keys:{nav:"preview",pick:"keeps",back:"reverts"},empty:"no matching theme",row:T=>d.jsx(jn,{label:T.name,current:T.id===c,hint:I1(T)})}):d.jsx(Br,{items:_,filter:(T,N)=>T.filter(j=>{var $,O;return Jo(N,j.name,($=j.dark)==null?void 0:$.name,(O=j.light)==null?void 0:O.name)}),rowClass:()=>"picker-row",keyOf:T=>{var N,j;return T.name+(((N=T.dark)==null?void 0:N.id)??((j=T.light)==null?void 0:j.id))},initialIndex:T=>T.findIndex(N=>{var j,$;return((j=N.dark)==null?void 0:j.id)===c||(($=N.light)==null?void 0:$.id)===c}),onActive:g,onSide:T=>{var N;T.dark&&T.light&&y((((N=v(T,w))==null?void 0:N.kind)??l)==="dark"?"light":"dark")},onPick:T=>{n==null||n.send({t:"set-theme",prefs:qP(r,T)}),u()},onBack:h,placeholder:"theme",keys:{nav:"preview",side:"dark/light",pick:"keeps",back:"reverts"},empty:"no matching theme",row:(T,N)=>{var I,P;const j=v(T,N?w:null),$=I1(T.dark??T.light),O=((I=T.dark)==null?void 0:I.id)===c||((P=T.light)==null?void 0:P.id)===c;return d.jsx(jn,{label:T.name,current:O,hint:d.jsxs("span",{className:"theme-kinds",children:[$&&d.jsx("span",{children:$}),d.jsx("span",{className:"kind","data-state":dr({current:N&&(j==null?void 0:j.kind)==="dark"}),children:T.dark?"dark":""}),d.jsx("span",{className:"kind","data-state":dr({current:N&&(j==null?void 0:j.kind)==="light"}),children:T.light?"light":""})]})})}})}function Qj(){const e=bD(),t=L(i=>i.frame==="phone"),n=Hl(),r=L(i=>i.activeRepoId),o=L(i=>i.newProject);return d.jsxs(d.Fragment,{children:[(e==null?void 0:e.kind)==="quick-open"&&n&&d.jsx($7,{worktreeId:n}),(e==null?void 0:e.kind)==="search"&&n&&d.jsx(HW,{worktreeId:n}),(e==null?void 0:e.kind)==="element-sources"&&d.jsx($W,{worktreeId:e.worktreeId,hits:e.hits}),(e==null?void 0:e.kind)==="refs"&&r&&d.jsx(UW,{repoId:r}),(e==null?void 0:e.kind)==="chats"&&r&&d.jsx(cW,{repoId:r,scope:e.names?"names":"all"}),(e==null?void 0:e.kind)==="keys"&&d.jsx(GH,{}),(e==null?void 0:e.kind)==="devices"&&d.jsx(jW,{}),(e==null?void 0:e.kind)==="theme"&&d.jsx(KW,{slot:e.slot}),(e==null?void 0:e.kind)==="appearance"&&d.jsx(rW,{}),(e==null?void 0:e.kind)==="keep-awake"&&d.jsx(IW,{}),(e==null?void 0:e.kind)==="agent"&&d.jsx(eW,{}),(e==null?void 0:e.kind)==="agent-page"&&d.jsx(QH,{agentId:e.agent}),(e==null?void 0:e.kind)==="split"&&d.jsx(WW,{worktreeId:e.worktreeId}),(e==null?void 0:e.kind)==="commands"&&!t&&d.jsx(Cj,{}),(e==null?void 0:e.kind)==="projects"&&e.form!=="pill"&&d.jsx(my,{form:e.form},e.form),(e==null?void 0:e.kind)==="choose-folder"&&o&&d.jsx(CW,{project:o})]})}const xf="Lost the daemon; retrying",R1="Not answering";function ZW(e,t){return e!=="down"&&e!=="blocked"?xf:t===null?R1:`${R1}; as of ${bo(ur(t))}`}const qW="Not run by Toyon",Jj="new worktree",GW=(e,t)=>`in ${e}, started from ${t}`,VW=e=>`in ${e}, here while it needs you`,YW=new Set(["waiting","stopping","working","starting","failed","crashed"]);function mk(e,t){if(!Sn(e))return e.locked?`Held by ${e.lockReason??"another tool"}`:t.path;if(t.op)return Kk(t.op);if(_r(e.worktree))return Jj;const n=yh(e,t.needsSetup),r=e.worktree.lastTurn;return!YW.has(Ms(e))&&r?$w(r):t.at&&t.at!=="now"?`${n} · ${t.at}`:n}function XW(e,t){if(!Sn(e)||t)return!1;const n=Ms(e);return(n==="idle"||n==="asleep")&&!e.unseen}function QW(e){const t=e.worktree.lastTurn,n=e.worktree.landed?Nw(e.worktree.lands):[],r=t?(Fo(e.agent)?a5:$w)(t):void 0,o=ih(e.worktree),i=o&&!e.worktree.landed?Cs(o):void 0;return[...n,r,i].filter(l=>!!l)}function JW(e,t,n,r){let o;const i=(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&&i(f.worktree.title,f.worktree.lands);for(const f of t)i(f.title,f.lands);const l=o&&gN(o.mark),c=o?`Landed ${o.title} ${bo(ur(o.mark.at))}${l?`: ${ho(l)}`:"."}`:void 0,u=n?pN(r,n):null,h=u?ho(`${u.charAt(0).toUpperCase()}${u.slice(1)}`):n!=null&&n.fetchedAt?`Level with origin, fetched ${bo(ur(n.fetchedAt))}.`:void 0;return[c,h].filter(f=>!!f)}function eK(e){const t=e.prompt?Oh(e.prompt):"";return[...t?[t]:[],...Nw(e.lands)]}function tK(e){const n=[e.auto&&nK(e.auto,!!e.landed),e.cost!==void 0?Su(e.cost):void 0].filter(r=>!!r);return n.length?n:void 0}function nK(e,t){const{what:n,idle:r}=CC(e);return r?`${t?"":`${n}, `}${r} idle`:n}const O1=25;function rK(e,t){if(e.length<=O1+1)return{shown:e,rest:0};const n=e.slice(0,O1),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 oK(e,t,n){const r=e.indexOf(t);return r<0?null:e[r+(n?1:-1)]??null}const sK=.5;function iK(e){const t=e.usage,n=t&&t.size>0?t.used/t.size:0,r=[n>=sK?`${Math.round(100*n)}% of context`:void 0,e.queued?`${e.queued} queued`:void 0,(t==null?void 0:t.cost)!==void 0?Su(t.cost):void 0].filter(o=>!!o);return r.length?r:void 0}function aK(e){const t=e.filter(gs).find(n=>n.id==="archive")??null;return[...t?[{id:"archive",label:t.label,icon:"archive",item:t}]:[],{id:"more",label:"more",icon:"more",item:null}]}function lK(e){return e.altKey?"Alt":e.ctrlKey?"Control":e.metaKey?"Meta":null}function cK(e,t){return t==="Alt"?e.altKey:t==="Control"?e.ctrlKey:e.metaKey}const uK=200,e$={set:(e,t)=>setTimeout(e,t),clear:e=>clearTimeout(e)};function dK(e,t=e$){let n=null,r=!1,o=null;const i=()=>{r||(r=!0,e(!0))},l=()=>{o!==null&&(t.clear(o),o=null)},c=()=>{l(),n=null,r&&(r=!1,e(!1))};return{press(u){const h=n!==null;n=lK(u),l(),n&&(h?i():o=t.set(()=>{o=null,i()},uK))},keyup(u){n&&u===n&&c()},mods(u){n&&!cK(u,n)&&c()},end:c}}const fK=350,hK=80,pK=2e3;function mK(e,t=e$){let n=!1,r=null,o=null,i=null,l=null;const c=()=>{r&&(t.clear(r.pending),r=null)},u=()=>{i!==null&&t.clear(i),l!==null&&t.clear(l),i=null,l=null},h=()=>{c(),u(),o=null,n&&(n=!1,e(!1))};return{over(f){u(),l=t.set(h,pK),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()},fK)}))},leave(){n&&(i!==null&&t.clear(i),i=t.set(h,hK))},end:h}}const cf=e=>e>999?"1k+":String(e);function t$({width:e,placement:t="strip"}){const n=t==="screen",r=Na(),o=L(ee=>ee.chatSide)==="left"?"right":"left",i=ct(),l=rt(),{host:c}=Ur(),u=uw(),h=u[0]&&_r(u[0].worktree)?u[0]:null,f=h?u.slice(1):u,m=L(ee=>Il(ee,ee.activeRepoId)),g=ee=>h&&ee.id===h.id&&m?{behind:m.behind,dirty:m.dirty}:ee,[,w]=S.useState(0);S.useEffect(()=>{const ee=setInterval(()=>w(ke=>ke+1),6e4);return()=>clearInterval(ee)},[]);const y=pD(),v=mD(),_=gD(),x=kD(),T=(ee,ke,Xe)=>{ee.key!=="ArrowLeft"&&ee.key!=="ArrowRight"||ee.shiftKey||ee.altKey||ee.metaKey||ee.ctrlKey||(ee.preventDefault(),Ih([{depth:0,open:ke}],0,ee.key)&&i({a:Xe}))},N=_a(),j=L(ee=>ee.notesPage),$=L(ee=>ee.clientId),O=L(ee=>ee.frame),I=L(ee=>ee.activeRepoId),P=L(ee=>ee.connected);S.useEffect(()=>{l&&P&&I&&l.send({t:"list-archived",repoId:I})},[l,P,I]);const R=Hl(),U=r_(),F=L(ee=>ee.layout),B=L(ee=>ee.railOpen),X=L(ee=>ee.railPeek),ae=S.useRef(null),[Y,ne]=S.useState(!1);ft([X],()=>{var ee;X&&!n&&!r&&!((ee=ae.current)!=null&&ee.matches(":hover"))&&ne(!0)}),S.useEffect(()=>{if(!Y)return;let ee=null;const ke=Xe=>{if(!ee){ee={x:Xe.clientX,y:Xe.clientY};return}Math.abs(Xe.clientX-ee.x)+Math.abs(Xe.clientY-ee.y)<3||ne(!1)};return window.addEventListener("pointermove",ke),()=>window.removeEventListener("pointermove",ke)},[Y]);const[C,H]=S.useState(!1),V=S.useMemo(()=>mK(H),[]);S.useEffect(()=>()=>V.end(),[V]);const J=L(ee=>{var ke;return((ke=ee.dragFiles)==null?void 0:ke.at)==="rail"?ee.dragFiles.worktreeId:null}),Z=L(ee=>ee.focusRail),ie=S.useRef(Z),be=S.useRef(null);ft([Z],()=>{if(Z===ie.current)return;ie.current=Z;const ee=requestAnimationFrame(()=>{var ke,Xe;return(Xe=(ke=be.current)==null?void 0:ke.querySelector('[data-state~="current"]'))==null?void 0:Xe.focus()});return()=>cancelAnimationFrame(ee)});const ge=(ee,ke,Xe,Ge,Zt)=>{var mn,an;if(ee.key!=="ArrowUp"&&ee.key!=="ArrowDown"||ee.altKey||ee.ctrlKey||ee.metaKey)return;ee.preventDefault();const Bt=oK(ke,Xe,ee.key==="ArrowDown");Bt!==null&&(Zt(Bt),(an=(mn=be.current)==null?void 0:mn.querySelector(`[${Ge}="${Bt}"]`))==null||an.focus())},we=L(ee=>ee.repos),pe=L(ee=>ee.shipping),Q=L(ee=>ee.rows),W=ee=>we.find(ke=>ke.id===ee.repoId)??null,ye=ee=>I?tw(ee,I,Q):null,_e=ee=>I&&ee.repoId!==I?W(ee):null,ve=wn("rail"),ce=Gn(),Se=hw(),me=L(ee=>ee.home),Ue=ee=>{const ke=ee.worktree?ee.worktree.path:ee.path;return me&&ke.startsWith(`${me}/`)?`~${ke.slice(me.length)}`:ke},[Ie,We]=S.useState(!1),[mt,en]=S.useState([]),Kt=ee=>{!hf(ee.worktree)||_e(ee)||(We(!0),en(ke=>ke.includes(ee.worktree.id)?ke.filter(Xe=>Xe!==ee.worktree.id):[...ke,ee.worktree.id]))},Be=()=>{We(!1),en([])};ft([Ie],()=>{const ee=ke=>ke.key==="Escape"&&Be();return Ie&&window.addEventListener("keydown",ee),()=>window.removeEventListener("keydown",ee)});const Xt={sock:l,dispatch:i},ln=ee=>{We(!0),en(ke=>ee===R||ke.includes(ee)?ke:[...ke,ee])},It=ee=>Sn(ee)?dN(ee,W(ee),{layout:F,shipping:pe,frame:O},Xt,{..._e(ee)?{}:{graft:ln},hostname:c}):q3(ee,{clientId:$,frame:O},Xt,c),[Je,Vt]=S.useState(null),tn=ee=>Sn(ee)?aK(It(ee)):[];X_(be,{rowOf:ee=>{if(!n||Ie)return null;const ke=ee.closest(".slide"),Xe=ke==null?void 0:ke.dataset.row,Ge=Xe?u.find(Zt=>Zt.id===Xe):void 0;return ke&&Xe&&Ge?{el:ke,key:Xe,rungs:tn(Ge).length}:null},onSlide:Vt,onPick:(ee,ke)=>{var Zt;const Xe=u.find(Bt=>Bt.id===ee),Ge=Xe?tn(Xe)[ke-1]:void 0;if(!(!Xe||!Ge)){if(Ge.id==="more"){const Bt=(Zt=be.current)==null?void 0:Zt.querySelector(`.slide[data-row="${ee}"]`);Bt&&ve.openUnder(Bt,()=>It(Xe),ee)}else if(Ge.item&&!Ge.item.disabled){const Bt=Ge.item.onClick;window.setTimeout(Bt,V_)}}}});const ht=rK(_,(N==null?void 0:N.id)??null),gt=ht.shown.some(ee=>(ee.dirty??0)>0),sn=ee=>d.jsxs("button",{type:"button",className:He("row row-edge row-quiet rail-disc-item rail-arch-item",(Se==null?void 0:Se.owner)==="rail"&&Se.key===ee.id&&"menu-open"),"data-state":dr({current:!n&&(N==null?void 0:N.id)===ee.id}),"data-arch":ee.id,...zt(L5(ee),void 0,{placement:o,card:!0,detail:eK(ee),aside:tK(ee)}),onClick:()=>i({a:"open-archived",id:ee.id}),onKeyDown:ke=>ge(ke,ht.shown.map(Xe=>Xe.id),ee.id,"data-arch",Xe=>i({a:"open-archived",id:Xe})),...ve.contextMenu(()=>yf(ee,{clientId:$,frame:O},Xt),ee.id),children:[d.jsxs("span",{className:"rail-gut",onClick:r?ke=>{ke.stopPropagation(),ve.openUnder(ke.currentTarget,()=>yf(ee,{clientId:$,frame:O},Xt),ee.id)}:void 0,children:[d.jsx("span",{className:"rail-at row-dim",children:ur(ee.archivedAt)}),d.jsx("span",{className:"rail-more",...zt("Actions"),onClick:ke=>{ke.stopPropagation(),ve.openUnder(ke.currentTarget,()=>yf(ee,{clientId:$,frame:O},Xt),ee.id)},children:d.jsx(_t,{name:"more"})})]}),d.jsx("span",{className:"branch",children:ee.title}),gt&&d.jsx("span",{className:"rail-counts",children:d.jsx("span",{className:"rail-count row-dim","data-tip":ee.dirty?`${ee.dirty} uncommitted, kept`:void 0,children:ee.dirty?`~${cf(ee.dirty)}`:""})}),ee.auto?d.jsx("span",{className:"rail-glyph rail-auto row-dim",children:d.jsx(_t,{name:"clock",className:"icon-inline"})}):d.jsx("span",{className:"dot"}),n&&d.jsx("span",{className:"rail-at rail-at-end row-dim",children:ur(ee.archivedAt)})]},ee.id),kn=[...u,...y].map(g),Pt=["ahead","dirty","behind"].filter(ee=>kn.some(ke=>(ke[ee]??0)>0)),Rn=ee=>{const ke=Pt.findIndex(Xe=>(ee[Xe]??0)>0);return new Set(ke<0?[]:Pt.slice(ke))},bt=ee=>{var zn;const ke=Sn(ee)?ee:null,Xe=!!ke&&_r(ke.worktree),Ge=g(ee),Zt=we.find(et=>et.id===ee.repoId)??null,Bt=Zt?sh(Zt):"main",mn=Zt&&mA(Zt)&&(m!=null&&m.fetchedAt)?` as of ${hN(m.fetchedAt)}`:"",an=Rn(Ge),xn=!!Ge.ahead&&!Ge.dirty,M=ee.id,re=(Se==null?void 0:Se.owner)==="rail"&&Se.key===M,Ne=ke?ye(ke):null,Ze=ke?_e(ke):null,jt=ke&&!Ze&&Ie&&hf(ke.worktree)&&M!==R,Ut=ke&&ke.worktree.kind==="worktree"&&!Ze?{title:ke.worktree.title,branch:ke.worktree.branch}:null,Me=hS(ee,(zn=pe[M])==null?void 0:zn.op),Pe=d.jsxs("button",{type:"button",className:He("row row-edge",ke?"rail-item":"row-quiet rail-disc-item",n&&XW(ee,Me)&&"row-quiet",re&&"menu-open",J===M&&"drop-over"),"data-state":dr({current:!n&&M===R&&!N&&!j,checked:mt.includes(M)}),...ke?zt(U?xf:Me?Kk(Me):yh(ee,Lf(W(ke))),void 0,{placement:o,card:!0,aside:iK(ee),detail:_r(ke.worktree)?JW(u,_,m,Bt):[...Ze?[Ne?GW(Ze.name,Ne.worktree.title):VW(Ze.name)]:[],...QW(ke)],dot:U?void 0:Me?"spinner":Ms(ee)}):zt(U?xf:ee.locked?`Held by ${ee.lockReason??"another tool"}`:qW,void 0,{placement:o,card:!0,detail:Ue(ee),dot:U||ee.locked?void 0:"discovered"}),"data-wt":M,draggable:Ut!==null,onDragStart:Ut!==null?et=>tu(et,{kind:"worktree",worktreeId:M,...Ut}):void 0,onDragEnd:()=>Eu(ce),onKeyDown:et=>{if(Ie)return;const Ht=(ke?u:y).map(On=>On.id);ge(et,Ht,M,"data-wt",On=>i({a:"activate",id:On}))},onClick:et=>{ke&&!Ze&&(Ie||et.shiftKey)?M===R?We(!0):Kt(ke):Xe&&!n?i({a:"open-draft"}):(i({a:"activate",id:M}),ke&&!r&&i({a:"walked"}))},...ve.contextMenu(()=>It(ee),M),children:[d.jsx("span",{className:"rail-gut",onClick:r&&!Ie?et=>{et.stopPropagation(),ve.openUnder(et.currentTarget,()=>It(ee),M)}:void 0,children:jt?d.jsx("input",{type:"checkbox",className:"rail-graft-check",checked:mt.includes(M),readOnly:!0,tabIndex:-1}):!Ie&&d.jsxs(d.Fragment,{children:[ke&&!Xe&&d.jsx("span",{className:"rail-at row-dim",children:ur(ya(ke.worktree))}),d.jsx("span",{className:"rail-more",...zt("Actions"),onClick:et=>{et.stopPropagation(),ve.openUnder(et.currentTarget,()=>It(ee),M)},children:d.jsx(_t,{name:"more"})})]})}),Xe?d.jsxs("span",{className:"branch rail-main-label",children:[d.jsx(_t,{name:"plus",className:"icon-inline"}),"new worktree"]}):d.jsx("span",{className:He("branch",(ke==null?void 0:ke.worktree.unnamed)&&"row-dim"),children:wg(ee,ke?W(ke):null)}),(ke==null?void 0:ke.worktree.mode)&&ke.worktree.mode!=="auto"&&d.jsx("span",{className:"rail-badge badge-mode","data-tip":`${ke.worktree.mode} mode: the agent waits for you`,children:ke.worktree.mode}),ke&&(()=>{const et=W(ke),Ht=aN(ke.worktree,et);return Ht&&Ht!==(et==null?void 0:et.config.defaultProfile)?d.jsx("span",{className:"rail-badge badge-profile","data-tip":`runs the ${Ht} profile`,children:Ht}):null})(),Ze&&d.jsx("span",{className:"rail-guest row-dim",children:Ze.name}),d.jsxs("span",{className:"rail-counts",children:[an.has("ahead")&&d.jsx("span",{className:"rail-count badge-ahead","data-tip":Ge.ahead?`${Ge.ahead} ahead of ${Bt}`:void 0,children:Ge.ahead?`+${cf(Ge.ahead)}`:""}),an.has("dirty")&&!xn&&d.jsx("span",{className:"rail-count badge-dirty","data-tip":Ge.dirty?`${Ge.dirty} uncommitted${Xe?" on main":""}`:void 0,children:Ge.dirty?`~${cf(Ge.dirty)}`:""}),an.has("behind")&&d.jsx("span",{className:"rail-count rail-behind row-dim","data-tip":Ge.behind?`${Ge.behind} behind ${Xe?"origin":Bt}${Xe?"":mn}`:void 0,children:Ge.behind?cf(Ge.behind):""}),n&&ke&&d.jsx("span",{className:"rail-at row-dim",children:Xe?"":ur(ya(ke.worktree))})]}),(()=>{if(Me)return d.jsx(Ml,{size:"dot"});if(ee.locked)return d.jsx("span",{className:"rail-glyph rail-lock row-dim",children:d.jsx(_t,{name:"lock",className:"icon-inline"})});if(!ke)return d.jsx("span",{className:"dot discovered"});const et=Ie||U?null:pS(ee.procs),Ht=ee.unseen?" unseen":"",On=Ms(ee);return Xe&&!et&&On!=="crashed"&&!U?d.jsxs(d.Fragment,{children:[d.jsx("span",{className:`dot ${On} rail-main-dot`}),d.jsx("span",{className:"rail-glyph rail-main-strip",children:d.jsx(_t,{name:"plus"})})]}):!et||On!=="crashed"?d.jsx("span",{className:`dot ${On}${Ht}`}):d.jsx("span",{className:`dot crashed clickable${Ht}`,...zt(et.tip),onClick:dn=>{dn.stopPropagation(),i({a:"activate",id:M}),i({a:"term-stream",id:M,stream:et.stream})}})})(),n&&d.jsx("span",{className:"rail-say row-dim",children:mk(ee,{needsSetup:Lf(ke?W(ke):null),path:Ue(ee),op:Me})})]},M);if(!n||!ke)return Pe;const Ve=(Je==null?void 0:Je.key)===M?Je.step:null,Lt=Ve===null?null:tn(ee)[Math.max(0,Ve-1)],qt=!!Lt&&Ve!==null&&Ve>0&&(Lt.id==="more"||!!Lt.item&&!Lt.item.disabled);return d.jsxs("div",{className:"slide","data-row":M,children:[Pe,Lt&&d.jsxs("span",{className:"slide-verb","data-rung":qt?Lt.id:void 0,"aria-hidden":"true",children:[d.jsx("span",{className:"slide-word",children:Lt.label}),d.jsx(_t,{name:Lt.icon})]})]},M)};return d.jsx("div",{ref:ae,className:He("rail",n&&"rail-screen",!n&&(Ie||(Se==null?void 0:Se.owner)==="rail"||X||C)&&"hold",Y&&"quiet",(n||B)&&"pinned",U&&"offline"),style:e!==void 0&&!n?{"--rail-width":`${e}px`}:void 0,onClick:r&&!n&&!B?ee=>{ee.target instanceof Element&&ee.target.closest("button, .rail-gut")||i({a:"toggle-rail"})}:void 0,onDragOver:ee=>{var Zt;if(!Ig(ee.dataTransfer))return;const ke=ee.target instanceof Element?(Zt=ee.target.closest("[data-wt]"))==null?void 0:Zt.dataset.wt:void 0,Xe=ke?[...u,...y].find(Bt=>Bt.id===ke):void 0;if(!Xe||Ie||Xe.id===R)return V.over(null);const Ge=!n&&Sn(Xe)&&_r(Xe.worktree);V.over({id:Xe.id,land:()=>i(Ge?{a:"open-draft"}:{a:"activate",id:Xe.id})})},onDragLeave:V.leave,onDrop:V.end,children:d.jsxs("div",{className:"rail-panel","data-tip":U?xf:void 0,"data-tip-placement":"follow",children:[d.jsxs("div",{className:"rail-list",ref:be,children:[h&&!n&&bt(h),f.map(bt),Ie&&d.jsxs("div",{className:"rail-graft",children:[(()=>{const ee=u.find(Ge=>Ge.worktree.id===R&&hf(Ge.worktree)&&!_e(Ge)),ke=mt.filter(Ge=>Ge!==(ee==null?void 0:ee.worktree.id)),Xe=ke.map(Ge=>{var Zt;return((Zt=u.find(Bt=>Bt.worktree.id===Ge))==null?void 0:Zt.worktree.title)??Ge}).join(", ");return d.jsxs(De,{size:"md",tone:"primary",disabled:!ee||ke.length===0,"data-tip":ee?`Merge the checked worktrees into ${ee.worktree.title} and remove them`:"Select a worktree to graft onto",onClick:()=>{ee&&window.confirm(`Graft ${Xe} onto ${ee.worktree.title}?
259
-
260
- Their branches are merged in, then their directories and branches are removed.`)&&(l==null||l.send({t:"graft",targetId:ee.worktree.id,sourceIds:ke}),Be())},children:["graft ",ke.length]})})(),d.jsxs(De,{size:"md",disabled:!mt.some(ee=>{var ke;return(((ke=u.find(Xe=>Xe.worktree.id===ee))==null?void 0:ke.behind)??0)>0}),"data-tip":"Pull main into every selected worktree that's behind",onClick:()=>{for(const ee of mt){const ke=u.find(Xe=>Xe.worktree.id===ee);((ke==null?void 0:ke.behind)??0)>0&&Si(l,i,{t:"sync-main",worktreeId:ee})}Be()},children:[d.jsx(_t,{name:"pull",className:"icon-inline"})," sync"]}),d.jsx(De,{size:"md",tone:"danger",disabled:mt.length===0,"data-tip":"Archive all selected worktrees; their chats and work are kept",onClick:()=>{window.confirm(`Archive ${mt.length} worktree(s)?
261
-
262
- Their directories and branches go. The chats, commits and any uncommitted changes are kept, and each can be restored.`)&&(Nl(l,i,mt),Be())},children:"archive…"}),d.jsx(Ot,{icon:"close",label:"Cancel",hint:"esc",onClick:Be})]}),!Ie&&y.length>0&&d.jsxs(d.Fragment,{children:[d.jsxs("button",{className:"section-title section-row section-fold rail-disc-head","aria-expanded":v,...zt(`${y.length} worktree${y.length===1?"":"s"} here that Toyon did not make`,void 0,{placement:o}),onClick:()=>i({a:"toggle-discovered"}),onKeyDown:ee=>T(ee,v,"toggle-discovered"),children:[d.jsx("span",{className:"rail-gut",children:d.jsx(_t,{name:"caret",className:He("icon-inline disc-caret",!v&&"shut")})}),d.jsx("span",{className:"rail-label",children:"discovered"})]}),v&&y.map(bt)]}),!Ie&&_.length>0&&d.jsxs(d.Fragment,{children:[d.jsxs("button",{type:"button",className:"section-title section-row section-fold rail-disc-head","aria-expanded":x,...zt(`${_.length} archived worktree${_.length===1?"":"s"}, kept with ${_.length===1?"its chat":"their chats"}`,void 0,{placement:o}),onClick:()=>i({a:"toggle-archived"}),onKeyDown:ee=>T(ee,x,"toggle-archived"),children:[d.jsx("span",{className:"rail-gut",children:d.jsx(_t,{name:"caret",className:He("icon-inline disc-caret",!x&&"shut")})}),d.jsx("span",{className:"rail-label",children:"archived"})]}),x&&ht.shown.map(sn),x&&ht.rest>0&&I&&d.jsxs("button",{type:"button",className:"row row-quiet rail-disc-item rail-arch-item",...zt("Find an older one by its name, branch or first message",void 0,{placement:o}),onClick:()=>i({a:"open",overlay:{kind:"chats",names:!0}}),children:[d.jsx("span",{className:"rail-gut"}),d.jsxs("span",{className:"branch row-dim",children:[ht.rest," more"]}),d.jsx("span",{className:"dot"})]})]})]}),!n&&d.jsx("div",{className:"rail-foot",children:d.jsx(Ot,{icon:"worktrees",label:"Worktree panel",hint:Dt("rail"),tone:"chrome",on:B,onClick:()=>i({a:"toggle-rail"})})})]})})}const th=["home","chat","preview","changes"],gK=(e,t)=>th.indexOf(t)<th.indexOf(e)?"left":"right";function kK(e,t,n){if(e==="home")return null;const r=th.filter(i=>i!=="preview"||n),o=r.indexOf(e);return o<0?null:r[o+(t==="right"?-1:1)]??null}function wK({screen:e,tabs:t,fold:n,beside:r=!1,away:o=!1}){const i=ct(),l=ss(),c=mo(),u=L(ge=>ge.reading),h=L(ge=>ge.typing),f=vD(),m=Wl(),g=L(ge=>ge.repos),w=Ps(),y=Hl(),v=_a(),_=dw(),x=uw(),T=r_(),N=L(ge=>ge.connectFailure),j=L(ge=>ge.recalledAt??ge.heardAt);Ei(T&&j!==null?j:void 0);const $=ZW(N,j),O=YS(),I=v8(x,y,O),P=x.find(ge=>_r(ge.worktree)),R=e==="home",U=!R&&!v&&!!w&&_r(w.worktree),F=L(ge=>{var we;return U&&w?hS(w,(we=ge.shipping[w.id])==null?void 0:we.op):null}),B=ow().length,X=l.displayName(c.origin),ae=R?(f==null?void 0:f.name)??X:U?Jj:(v==null?void 0:v.title)??(w==null?void 0:w.worktree.title)??(_==null?void 0:_.name)??null,Y=x.filter(ge=>!_r(ge.worktree)).length,ne=Y===0?"no worktrees yet":`${Y} ${Y===1?"worktree":"worktrees"}`,C=L(ge=>ge.sharing),H=R?T?$:C||(f&&B>1?`${X} · ${ne}`:ne):v?$N(v):T?$:U?F?Kk(F):(f==null?void 0:f.name)??null:w?mk(w,{needsSetup:Lf(m),path:w.worktree.path,at:ur(ya(w.worktree))}):_?mk(_,{needsSetup:!1,path:_.path}):null,V=!R&&!v&&!!w&&Ms(w)==="waiting",J=L(ge=>{var we;return((we=ge.overlay)==null?void 0:we.kind)==="projects"&&ge.overlay.form==="pill"})&&!r,Z=L(ge=>{var we;return((we=ge.overlay)==null?void 0:we.kind)==="commands"})&&!r,ie=d.jsxs("div",{className:"phone-title",children:[R&&(g.length>1||B>1)?d.jsxs("span",{className:"phone-drop phone-switch",children:[d.jsxs(De,{tone:"chrome",on:J,onClick:()=>i({a:"toggle",overlay:{kind:"projects",form:"pill"}}),children:[d.jsx("span",{className:"phone-name",children:ae}),d.jsx(_t,{name:"caret",className:"icon-inline"})]}),J&&d.jsx(my,{form:"pill",anchored:{margin:6}})]}):d.jsx("span",{className:"phone-name",children:ae}),H&&d.jsx("span",{className:He("phone-sub",V&&"phone-sub-asks"),children:H})]}),be=I&&d.jsxs(De,{size:"md",tone:"primary",onClick:()=>{const ge=b8(x,y,O);if(!ge)return;if(ge.origin===null)return i({a:"activate",id:ge.activate});const we=l.get(ge.origin);we&&(we.store.dispatch({a:"activate",id:ge.activate}),l.activate(ge.origin))},children:[I.n," ",I.tier]});return d.jsxs("div",{className:"phone-bar",children:[d.jsxs("div",{className:"phone-bar-row",children:[!R&&d.jsx(Ot,{icon:"back",label:"Worktrees",tone:"chrome",onClick:()=>i({a:"screen",to:"home"})}),t?d.jsx("div",{className:"phone-tabs",children:t}):ie,!t&&be,R&&P&&d.jsx(Ot,{icon:"plus",label:"New worktree",tone:"chrome",onClick:()=>i({a:"activate",id:P.id})}),d.jsxs("span",{className:"phone-drop",children:[d.jsx(Ot,{icon:"more",label:"Menu",tone:"chrome",on:Z,onClick:()=>i({a:"toggle",overlay:{kind:"commands"}})}),Z&&d.jsx(Cj,{anchored:{flip:"align",margin:6},trailing:d.jsx(Ot,{icon:"close",label:"Close",tone:"chrome",onClick:()=>i({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:[ie,be]})})]})}const Ef="toyonDepth",n$="toyonOver",Qm=-1;function Jm(e){if(e.frame!=="phone"||!e.heard&&e.recalledAt===null)return null;if(!(e.screen!=="home"&&(_o(e,e.activeId)!==null||No(e)!==null)))return 0;const n=rn(e,e.activeId)!==null&&!Do(e)&&No(e)===null;return 1+(e.screen==="changes"||e.screen==="preview"&&n?1:0)+(e.editor?1:0)}const r$=(()=>{const e=new Set;return{watch(t){return e.add(t),()=>e.delete(t)},tell(t){for(const n of e)n(t)}}})(),eg=e=>{const t=e&&typeof e=="object"?e[Ef]:void 0;return typeof t=="number"?t:null},yK=e=>!!e&&typeof e=="object"&&e[n$]===!0;function vK(e,t=window,n=Pl,r=r$){const o=t.history;let i=eg(o.state)??Qm,l=eg(o.state)!==null,c=null;const u=()=>{const N=n.open();c&&!N.includes(c)&&(c=null);for(let j=N.length-1;j>=0;j--){const $=N[j];if($!=null&&$.dismiss&&$!==c)return $}return null};let h=!1;const f=()=>{const N=Jm(e.getState());if(N===null||h)return;l||(o.replaceState({[Ef]:Qm},""),l=!0);const j=N+(u()?1:0);if(j!==i)if(j>i){for(let $=i+1;$<=j;$++)o.pushState({[Ef]:$,[n$]:$>N},"");i=j}else o.go(-1),h=!0};let m=!1;const g=()=>{m||(m=!0,queueMicrotask(()=>{m=!1,f()}))},w=(N,j,$)=>{const O=u();if(O){c=O,n.shut(O);return}const I=$===0?"home":N.editor&&$===j-1?N.screen:"chat";e.dispatch({a:"screen",to:I})},y=N=>{const j=h;h=!1,i=eg(N.state)??Qm;const $=e.getState(),O=Jm($);if(O===null)return;if(i<0){o.pushState({[Ef]:0},""),i=0,f();return}if(j){f();return}const I=O+(u()?1:0);I!==i&&(I>i?w($,O,i):I===0&&$.activeId&&!yK(N.state)&&e.dispatch({a:"screen",to:"chat"}),f())},v=N=>{if(h){h=!1,f();return}const j=e.getState(),$=Jm(j);$===null||$===0||j.screen==="preview"&&!j.editor&&$===2||N.dir==="forward"||w(j,$,$+(u()?1:0)-1)};t.addEventListener("popstate",y);const _=e.subscribe(f),x=n.watch(g),T=r.watch(v);return f(),()=>{t.removeEventListener("popstate",y),_(),x(),T()}}function bK({gated:e,active:t,url:n,onTouch:r}){const o=bh(t),i=qz(mo(),o?n:null,e),l=S.useRef(null),c=S.useRef(r);return c.current=r,S.useEffect(()=>{if(!i)return;const u=new URL(i,location.href).origin,h=f=>{var w,y;const m=(w=l.current)==null?void 0:w.contentWindow;if(!m||f.source!==m||f.origin!==u||!((y=f.data)!=null&&y.__toyon))return;const g=qE(f.data);(g==null?void 0:g.type)==="traversed"?r$.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)},[i]),d.jsx("div",{className:"phone-preview",children:o&&i?d.jsx("iframe",{ref:l,className:"phone-preview-frame",src:i,title:t.worktree.title}):d.jsx(ws,{wide:!0,children:d.jsx("p",{className:"status-line",children:yh(t)})})})}function xK(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 EK=Of(),SK=!F_(),_K={current:null};function NK(){const e=S.useRef(null),t=S.useRef(null),n=S.useRef(null);cD(e),uD(e);const r=ct(),o=L(H=>H.screen),i=Ps(),l=_a(),c=dw(),u=L(H=>H.editor),h=L(H=>H.remote),f=bu(),m=L(H=>H.connected),g=L(H=>H.heard),w=L(H=>H.recalledAt!==null||H.heard),y=L(H=>H.connectFailure),v=Na(),_=mo(),x=ss(),[T,N]=S.useState(null),j=L(H=>H.incompatible),$=tN({connected:m,heard:g,standing:w,connectFailure:y,hasToken:_.serving?EK:!0,projectChord:Dt("project"),title:(i==null?void 0:i.worktree.title)??null,machine:_.serving?null:x.displayName(_.origin)}),O=o!=="home"&&(i!==null||l!==null||c!==null),I=O&&!f&&!l?i:null,{host:P}=Ur(),R=I?dS(I.worktree.id,I.worktree.proxyPort,h,P):null,U=o==="preview"&&!I?"chat":o,F=xK({incompatible:j,serving:_.serving,machine:x.displayName(_.origin),said:$!==null,onWorktree:O,editor:u!==null,tab:U}),B=F.kind==="home"?"home":F.kind==="tab"?F.tab:null,X=I!==null&&R!==null,ae=$3(SK?e:_K,{take:(H,V)=>{if(F.kind!=="tab"||T!==null)return null;const J=kK(F.tab,V,X);return J?(N(J),(J==="home"?t:n).current):null},onEnd:H=>{H&&T&&r({a:"screen",to:T}),N(null)}}),Y=(H,V)=>d.jsx(wK,{screen:H==="home"?"home":"chat",beside:V,fold:H!=="chat"||u!==null,away:T!==null&&T!=="home",tabs:H!=="home"&&$===null&&d.jsx(Ah,{fill:!0,segmented:!0,owner:"phone-tabs",label:"worktree",items:C,current:H,onPick:J=>r({a:"screen",to:J})})}),ne=F.kind==="updated"?d.jsx(eN,{foreign:F.foreign??void 0}):F.kind==="say"&&$?d.jsx(ws,{wide:!0,children:d.jsx("p",{className:He("status-line",$.live&&"live-text"),children:$.text})}):F.kind==="editor"&&u?d.jsx(Kj,{editor:u,placement:"screen"}):null,C=[{id:"chat",label:"chat"},...I&&R?[{id:"preview",label:"preview",trail:d.jsx(Ot,{icon:"external",label:"Open in browser",tone:"chrome",onClick:()=>Gz(_,R,Rg(_,h))})}]:[],{id:"changes",label:"code"}];return d.jsxs("div",{ref:e,className:"app phone","data-chat-side":"left","data-touch":v||void 0,"data-hover":!v||void 0,children:[d.jsx(W_,{}),d.jsx(G_,{}),d.jsx("div",{className:"phone-screen",children:d.jsxs("div",{className:"center-root",children:[d.jsxs("div",{className:"phone-track",ref:t,children:[(!O||T==="home")&&d.jsxs("div",{className:"phone-face","data-side":O?"left":void 0,children:[Y("home",O),!O&&B===null?ne:d.jsx(t$,{placement:"screen"})]},"home"),O&&d.jsxs("div",{className:"phone-face",children:[Y(U,!1),d.jsxs("div",{className:"phone-track",ref:n,children:[B===null&&d.jsx("div",{className:"phone-face",children:ne},"cover"),th.map(H=>{if(H==="home")return null;const V=H===B,J=H===T&&!V;return!V&&!J&&!(H==="preview"&&X)?null:d.jsx("div",{className:"phone-face",hidden:!V&&!J,"data-side":J&&B?gK(B,H):void 0,children:H==="chat"?d.jsx(Zc,{placement:"screen",archived:l,found:c}):H==="changes"?d.jsx(NN,{placement:"screen"}):I&&R?d.jsx(bK,{gated:Rg(_,h),active:I,url:R,onTouch:ae},I.worktree.id):null},H)})]})]},"worktree")]}),d.jsx(Qj,{})]})})]})}function TK(){try{const e=localStorage.getItem(Ke.theme);if(e){const t=JSON.parse(e);if(t!=null&&t.colors&&typeof t.colors.surface0=="string")return t}}catch{}return wu}function jK(){if(Ew()!=="phone")return"surface0";try{const e=sessionStorage.getItem(Ke.ground);if(e==="surface0"||e==="surface1")return e}catch{}return"surface1"}function o$(e,t={}){var i,l;const n=document.documentElement;for(const[c,u]of Object.entries(UP(e)))n.style.setProperty(c,u);n.style.colorScheme=e.kind,n.dataset.theme=e.kind;const r=t.ground??jK();n.dataset.ground=r;const o=Ew()==="phone"?e.colors[r]:e.colors.surface1;if((i=document.querySelector('meta[name="theme-color"]'))==null||i.setAttribute("content",o),(l=document.querySelector('link[rel="manifest"]'))==null||l.setAttribute("href",t.black?"/manifest.json?black=1":"/manifest.json"),t.remember!==!1)try{localStorage.setItem(Ke.theme,JSON.stringify(e))}catch{}}function s$(e){const t=zk(e);return{type:"theme",accent:t,accentFg:XP(t)}}function $K(){var e;return((e=window.matchMedia)==null?void 0:e.call(window,"(prefers-color-scheme: dark)").matches)??!0}const CK=12*36e5;function AK(){try{const e=localStorage.getItem(Ke.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<CK?{dark:!t.dark,until:0}:null}catch{return null}}function IK(e){try{localStorage.setItem(Ke.daylight,JSON.stringify(e))}catch{}}function RK(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 OK(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 M1(e,t){return t==="reading"?"Reading the release notes":`No release notes could be read from Toyon ${e}.`}function MK(){const e=Ur(),t=L(i=>i.version),[n,r]=S.useState(void 0);S.useEffect(()=>{let i=!0;return cL(e).then(l=>{i&&r(l)}),()=>{i=!1}},[e]);const o=Fh(n??"",{keepHtml:!0});return n?d.jsx("div",{className:"notes-page",children:d.jsx(Wj,{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:M1(t,"reading")}):M1(t,"missing")})})}function gk(e,t){return[{id:"copy-name",label:"copy name",detail:e,onClick:()=>Yt(e)},{id:"copy-value",label:"copy value",detail:t,onClick:()=>Yt(t)}]}function kk(e){return[{id:"copy-value",label:"copy value",detail:e,onClick:()=>Yt(e)}]}function PK(e,t,{sock:n},r){return t?Dn([[{id:"source",label:"open source",onClick:r}],os(()=>n==null?void 0:n.send({t:"reveal",worktreeId:e.id,path:t}),rs(n)),[{id:"copy-path",label:"copy path",onClick:()=>Yt(t)}]]):[]}function mu(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(i=>i+i).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 LK(e){const t=/^#([0-9a-f]{3,8})$/i.exec(e.trim());return t?t[1].length===4||t[1].length===8:!1}function P1([e,t,n]){const r=o=>{const i=o/255;return i<=.03928?i/12.92:((i+.055)/1.055)**2.4};return .2126*r(e)+.7152*r(t)+.0722*r(n)}function i$(e,t){if(LK(e))return null;const n=mu(e);if(!n)return null;const r=mu(t);if(!r)return null;const[o,i]=[P1(n),P1(r)];return`${((Math.max(o,i)+.05)/(Math.min(o,i)+.05)).toFixed(2)}:1`}function DK({worktreeId:e,height:t,full:n,onToggleFull:r,onDragStart:o}){const i=ct(),l=rt(),c=L(h=>fo(h,e).design);S.useEffect(()=>{c||l==null||l.send({t:"design-scan",worktreeId:e})},[c,e,l]),S.useEffect(()=>()=>un.post(e,{type:"highlight-clear"}),[e]);const u={outline:h=>un.post(e,h),clear:()=>un.post(e,{type:"highlight-clear"}),open:h=>Ln({dispatch:i},{worktreeId:e,path:h})};return d.jsx(py,{kind:"design",className:He("design-pane",n&&"full"),height:n?void 0:t,resizable:!n,onDragStart:o,title:c?d.jsx("span",{children:UK(c)}):void 0,onClose:()=>i({a:"toggle-design"}),closeHint:Dt("design"),full:n,onToggleFull:r,actions:d.jsxs(De,{variant:"outline",onClick:()=>l==null?void 0:l.send({t:"design-scan",worktreeId:e}),"data-tip":"Scan this worktree again",children:[d.jsx(_t,{name:"reload",className:"icon-inline"})," rescan"]}),children:c?d.jsxs("div",{className:"design-body",style:BK,onMouseLeave:u.clear,children:[c.tokens.length===0&&c.literals.length>0?d.jsx(GK,{literals:c.literals,outline:u.outline,clear:u.clear}):d.jsx(ZK,{tokens:c.tokens,coverage:c.coverage,outline:u.outline,clear:u.clear}),d.jsx(rZ,{index:c,outline:u.outline,clear:u.clear,onOpen:u.open}),d.jsx(oZ,{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 zK=720,FK=132,BK={"--design-column":`${zK}px`,"--design-cell":`${FK}px`};function UK(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 vl=e=>`${e} use${e===1?"":"s"}`;function Vh({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 nh({children:e}){return d.jsx("p",{className:"design-gap",children:e})}const HK=[{kind:"font",label:"type"},{kind:"color",label:"color"},{kind:"length",label:"size & radius"},{kind:"shadow",label:"shadow"},{kind:"other",label:"computed"}];function WK(e){return e.find(t=>t.kind==="color"&&mu(t.resolved??t.value)!==null)}function KK(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 ZK({tokens:e,coverage:t,outline:n,clear:r}){const o=WK(e),i=o&&(o.resolved??o.value),l=new Map;for(const u of e){const h=(u.resolved??u.value).trim().toLowerCase();l.set(h,[...l.get(h)??[],u.name])}const c=u=>(l.get((u.resolved??u.value).trim().toLowerCase())??[]).filter(h=>h!==u.name);return d.jsx(Vh,{title:"Tokens",children:e.length===0?d.jsx(nh,{children:KK(t)}):HK.map(({kind:u,label:h})=>{const f=e.filter(g=>g.kind===u);if(f.length===0)return null;const m=l$(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(c$,{groups:JK(f),outline:n,clear:r}):d.jsx("div",{className:"design-breakout",style:a$(f.length),children:d.jsx("div",{className:"design-grid",children:f.map(g=>{const w=g.resolved??g.value,y=g.kind==="color"&&i?i$(w,i):null;return d.jsx(u$,{kind:g.kind,name:g.name,lines:g.resolved?[g.value,g.resolved]:[g.value],actual:w,ratio:y,largest:m,tipText:tZ(g,y,o,c(g)),menu:()=>gk(g.name,w),outline:n,clear:r},g.name)})})})]},u)})})}const qK=[{role:"color",kind:"color",label:"color"},{role:"radius",kind:"length",label:"radius"},{role:"shadow",kind:"shadow",label:"shadow"}];function GK({literals:e,outline:t,clear:n}){const r=e.find(i=>i.ground&&mu(i.value)!==null),o=eZ(e);return d.jsxs(Vh,{title:"Values",note:"written out in the rules; no custom properties",children:[o.length>0&&d.jsx("div",{className:"design-group",children:d.jsx(c$,{groups:o,outline:t,clear:n})}),qK.map(({role:i,kind:l,label:c})=>{const u=e.filter(f=>f.role===i);if(u.length===0)return null;const h=l$(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:a$(u.length),children:d.jsx("div",{className:"design-grid",children:u.map(f=>{const m=l==="color"&&r?i$(f.value,r.value):null;return d.jsx(u$,{kind:l,name:f.value,lines:[vl(f.uses)],actual:f.value,ratio:m,largest:h,tipText:nZ(f,m,r),menu:()=>kk(f.value),outline:t,clear:n},f.value)})})})]},i)})]})}function a$(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 l$(e){return e.reduce((t,n)=>Math.max(t,Math.abs(Number.parseFloat(n))||0),0)}const VK=["color","background-color","border-top-color","border-right-color","border-bottom-color","border-left-color","outline-color"];function YK(e,t){if(!e)return[];const n=getComputedStyle(e);return t.map(r=>[r,n.getPropertyValue(r)])}const wk=e=>(e.split(",")[0]??e).replace(/["']/g,"").trim();function XK(e){const t=/^[1-9]00\s+([\d.]+)px(?:\s*\/\s*([\d.]+)(px)?)?\s+(.+)$/.exec(e.trim());if(!t)return{family:wk(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:wk(t[4]??""),size:n,lead:o}}function tg(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 QK(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 JK(e){const t=e.map(n=>({token:n,actual:n.resolved??n.value,...XK(n.resolved??n.value)}));return[...new Set(t.map(n=>n.family))].map(n=>{const r=t.filter(i=>i.family===n),o=r.find(i=>i.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}
263
- ${o.actual}`:void 0,menu:()=>o?gk(o.token.name,o.actual):[],rows:r.filter(i=>i.size!==null).sort((i,l)=>(l.size??0)-(i.size??0)).map(i=>({key:i.token.name,sample:`${i.family} ${i.size}${i.lead===null?"":`/${i.lead}`}`,style:{font:i.actual},name:i.token.name,label:i.token.name,tipText:`${i.token.name}
264
- ${i.actual}`,menu:()=>gk(i.token.name,i.actual)}))}})}function eZ(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 i=t.find(c=>c.value===o),l=o==="initial"?"default face":wk(o);return{family:l,stack:o,name:i?vl(i.uses):void 0,label:l,tipText:i?`${i.value}
265
- ${vl(i.uses)}: ${i.selectors.join(", ")}`:void 0,menu:()=>i?kk(i.value):[],rows:n.filter(c=>(c.family??"initial")===o).sort((c,u)=>tg(u.value)-tg(c.value)).map(c=>{const u=tg(c.value),h=QK(c.lead,u),f=c.value.endsWith("px")?`${u}`:c.value;return{key:`${c.value}/${c.lead??""}`,sample:`${l} ${f}${h===null?"":`/${h}`}`,style:{fontFamily:o,fontSize:c.value,lineHeight:c.lead},name:vl(c.uses),label:c.value,tipText:`${c.value}${c.lead?` / ${c.lead}`:""}
266
- ${vl(c.uses)}: ${c.selectors.join(", ")}`,menu:()=>kk(c.value)}})}})}function c$({groups:e,outline:t,clear:n}){const r=(i,l,c)=>t({type:"highlight-computed",props:YK(i.currentTarget.querySelector(".design-face-sample"),l?["font-family","font-size","line-height"]:["font-family"]),match:"all",label:c}),o=wn("design");return d.jsx("div",{className:"design-faces",children:e.map(i=>d.jsxs("div",{className:"design-face-group",children:[d.jsxs("div",{className:"design-face-head row-edge",onMouseEnter:l=>r(l,!1,i.label),onMouseLeave:n,...o.contextMenu(i.menu),...i.tipText?zt(i.tipText,void 0,{placement:"follow"}):{},children:[d.jsx("span",{className:"design-face-sample design-face-family",style:{fontFamily:i.stack},children:i.family}),i.name&&d.jsx("span",{className:"design-face-name row-dim",children:i.name})]}),i.rows.map(l=>d.jsxs("div",{className:"design-face row-edge",onMouseEnter:c=>r(c,!0,l.label),onMouseLeave:n,...o.contextMenu(l.menu),...zt(l.tipText,void 0,{placement:"follow"}),children:[d.jsx("span",{className:"design-face-sample",style:l.style,children:l.sample}),d.jsx("span",{className:"design-face-name row-dim",children:l.name})]},l.key))]},i.stack))})}function u$({kind:e,name:t,lines:n,actual:r,ratio:o,largest:i,tipText:l,menu:c,outline:u,clear:h}){const f=e==="color"&&mu(r)!==null,m=e==="length"?Number.parseFloat(r):Number.NaN,g=wn("design");return d.jsxs("div",{className:"design-cell","data-kind":e,...g.contextMenu(c),onMouseEnter:f?w=>{const y=w.currentTarget.querySelector(".design-fill"),v=y?getComputedStyle(y).backgroundColor:"";u({type:"highlight-computed",props:VK.map(_=>[_,v]),match:"any",label:t})}:void 0,onMouseLeave:f?h:void 0,...zt(l),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((w,y)=>d.jsxs("span",{className:"design-cell-line",children:[d.jsx("span",{className:"design-cell-value",children:w}),y===0&&o&&d.jsx("span",{className:"design-cell-note",children:o})]},w)),Number.isFinite(m)&&i>0&&d.jsx("span",{className:"design-scale",style:{width:`${Math.max(2,Math.abs(m)/i*100)}%`}})]})]})}function tZ(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 i=e.name===n.name;o.push(i?"the ground these ratios are measured against":`${t} against ${n.name}`)}return o.join(`
267
- `)}function nZ(e,t,n){const r=[e.value,`${vl(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(`
268
- `)}function d$({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 rZ({index:e,outline:t,clear:n,onOpen:r}){const{components:o,typed:i}=e;if(o.length===0)return null;const l=o.filter(h=>h.imports>=2),c=o.filter(h=>h.imports<2),u=h=>d.jsx(f$,{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(Vh,{title:"Components",note:`${l.length} reused of ${o.length}`,children:[!i&&d.jsx(nh,{children:"No TypeScript in this project, so the values each prop allows are not listed."}),d.jsx(d$,{shared:l.map(u),rest:c.map(u)})]})}function oZ({index:e,outline:t,clear:n,onOpen:r}){const{classes:o,coverage:i}=e,l=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(sZ,{cls:g,outline:t,clear:n,onOpen:r},g.name);return d.jsx(Vh,{title:"Classes",note:f,children:o.length===0?d.jsx(nh,{children:"No stylesheet in this project defines a class. Utility-first CSS generates its own."}):l.length===0?d.jsx(nh,{children:i.classAttrs>0?`${i.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(d$,{shared:c.map(m),rest:u.map(m)})})}function sZ({cls:e,outline:t,clear:n,onOpen:r}){return d.jsx(f$,{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 f$({count:e,name:t,path:n,onEnter:r,onLeave:o,onOpen:i,children:l}){const c=Ps(),u=rt();ct();const h=wn("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:i,disabled:!n,...h.contextMenu(()=>c?PK({id:c.worktree.id},n,{sock:u},i):[]),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}),l]})})}function iZ({worktreeId:e,procs:t,borrowed:n,login:r,current:o,onRestart:i}){const l=rt();ct();const c={sock:l},u=(f,m)=>d.jsx(Ot,{icon:"reload",label:m,onClick:()=>i(f)}),h={id:Rs,label:"login",tip:zt("The agent's login; it closes once you are in",void 0,{placement:"top"}),trail:u(Rs,"Run the login again")};return r&&o===Rs?[h]:[{id:Po,label:"shell",tip:zt("A shell in this worktree",void 0,{placement:"top"}),menu:()=>uT(e,c),trail:u(Po,"Restart the shell")},...r?[h]:[],...t.map(f=>({id:f.name,label:f.name,lead:d.jsx("span",{className:`dot ${f.status}`}),tip:zt(UL(f.status),void 0,{placement:"top",dot:f.status,name:f.name,detail:f.command,aside:[`:${f.port}`]}),menu:()=>Vw(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:zt(`${f} runs on main for every worktree; this one reaches it at its usual address`,void 0,{placement:"top"})}))]}const aZ=S.lazy(()=>dk(()=>import("./XTerm-CZl-vWEO.js"),__vite__mapDeps([3,4]))),lZ=[];function cZ({worktreeId:e,opened:t,height:n,onDragStart:r}){const o=ct(),i=rt(),l=Eh(),c=L(F=>F.connected),u=L(F=>F.focusTerm),h=Ps(),f=(h==null?void 0:h.procs)??[],m=(h==null?void 0:h.borrowed)??lZ,g=(h==null?void 0:h.login)??!1,w=Rt(e,"termStream"),y=L(F=>{var B;return((B=F.termRun)==null?void 0:B.id)===e&&w===Po?F.termRun.command:null}),[v,_]=S.useState(null),x=m.includes(w);S.useEffect(()=>{w===Po||(w===Rs?g:f.some(B=>B.name===w)||m.includes(w))||o({a:"term-stream",id:e,stream:Po})},[f,m,g,w,e,o]);const T=F=>{F!==w&&(_(null),o({a:"term-stream",id:e,stream:F}))},N=S.useRef(!1),[j,$]=S.useState(0),O=F=>{F===Po&&F===w&&(N.current=!0),i==null||i.send({t:"term-restart",worktreeId:e,stream:F}),F===Rs&&F===w&&(_(null),$(B=>B+1))},I=(F,B)=>{if(F)return _(null);if(N.current){N.current=!1,$(X=>X+1);return}_({code:B})},P=iZ({worktreeId:e,procs:f,borrowed:m,login:g,current:w,onRestart:O}),R=S.useRef(!t),U=!R.current;return S.useEffect(()=>{R.current=!1},[]),d.jsxs(py,{kind:"terminal",className:"term-pane",height:n,onDragStart:r,tabs:{items:P,current:w,onPick:T,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(Jc,{pane:!0,title:`${w} runs on main`,body:"Every worktree reaches main's copy until its own changes touch it, or until asked.",action:d.jsx(De,{variant:"outline",onClick:()=>i==null?void 0:i.send({t:"own-procs",worktreeId:e,names:[w]}),children:"run it here"})}),d.jsx(Sw,{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(aZ,{worktreeId:e,stream:w,theme:l,sock:i,connected:c,focusOnMount:U,focusReq:u,onAlive:I,run:y,onRan:()=>o({a:"term-ran"}),onEscape:()=>o({a:"toggle-terminal"})},`${w}:${j}`)})})]}),v!==null&&!x&&d.jsx(Jc,{pane:!0,title:w===Po?"the shell exited":w===Rs?"the login did not finish":`${w} exited`,body:v.code===void 0?void 0:`exit code ${v.code}`,action:d.jsx(De,{variant:"outline",onClick:()=>O(w),children:"restart"})})]})}function uZ(e){return e==="reserved"?"checking out a fresh worktree":e==="warming"?"copying dependencies and running setup":"starting dev servers"}const dZ="preview off; it starts when the agent writes a file";function fZ({worktree:e,log:t}){const n=rt(),r=ct(),o=e.procs,i=v=>n==null?void 0:n.send({t:"term-restart",worktreeId:e.id,stream:v.name}),l=o.some(v=>v.status==="crashed"||v.status==="unreachable"),c=L(v=>v.clientId),u=ru(e,"setup"),h=u&&u.status!=="terminated"?u:null,f=Ei(Cw(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}),w=h&&(h.status==="running"||h.status==="detached"),y=()=>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":Lg[h.status],children:Bf("setup",h,f)}):m?dZ:d.jsx("span",{className:"live-text",children:uZ(e.worktree.phase)})}):d.jsx("ul",{className:"boot-procs",children:o.map(v=>d.jsxs("li",{className:He("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:hZ(v)}),(v.status==="crashed"||v.status==="unreachable")&&d.jsx(De,{variant:"outline",onClick:()=>i(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(De,{variant:"outline",size:"lg",onClick:g,children:"start preview"})}),w&&d.jsx("div",{className:"status-actions",children:d.jsx(De,{variant:"outline","data-tip":EN("setup"),onClick:()=>n==null?void 0:n.send({t:"run-stop",worktreeId:e.id,kind:"setup"}),children:"stop setup"})}),l&&d.jsxs("div",{className:"status-actions",children:[e.agent==="idle"&&d.jsx(De,{variant:"outline",size:"lg",onClick:y,children:"ask the agent to fix it"}),d.jsx(De,{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(`
269
- `)})]})}function hZ(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 pZ(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 L1(e){if(!e)return"/";try{const t=new URL(e);return`${t.pathname}${t.search}${t.hash}`}catch{return"/"}}function mZ(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 gZ({active:e}){const t=ct(),n=rt(),r=Wl(),o=L(c=>c.home),i=e.worktree.title,l=()=>{r!=null&&r.made&&(t({a:"new-project",v:{...Qk({mode:r.made==="git"?"init":"create",name:r.name,parent:hT(r.path,o)??r.path}),phase:"unmaking",repoId:r.id}}),t({a:"move-box",from:e.worktree.id,to:Al}),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(Kc,{active:e,greenfield:!0})}),children:d.jsx("p",{className:"form-title",children:r!=null&&r.made?d.jsx(De,{variant:"inline",onClick:l,...zt("Rename or move this project"),children:i}):i})})}function kZ({pending:e}){const t=ct(),n=rt(),r=!!e.error,o=()=>{n==null||n.send({t:"cancel-import",id:e.id}),t({a:"watch-import",id:null})},i=S.useRef(null);return S.useEffect(()=>{var l;return(l=i.current)==null?void 0:l.scrollTo({top:i.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})," 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:i,children:e.lines.length===0&&!r?d.jsx("span",{className:"live-text",children:"starting git"}):e.lines.map((l,c)=>d.jsx("div",{children:l},c))}),d.jsx("div",{className:"status-actions",children:d.jsx(De,{variant:"outline",size:"lg",onClick:o,children:r?"dismiss":"stop"})})]})}const wZ=150,yZ=/^[^\s@]+@[^\s@]+$/,vZ=14;function bZ({project:e}){var V;const t=ct(),n=rt(),r=L(J=>J.repos),o=L(J=>J.home),i=L(J=>J.folderDialog),l=L(J=>J.gitIdentity),c=L(J=>J.choosingFolder),u=L(J=>J.chosenFolder),h=L(J=>J.paths),[f,m]=S.useState({name:"",email:""}),[g,w]=S.useState(null),y=S.useRef(null),{mode:v,name:_,parent:x}=e,T=v==="clone",N=v==="init",j=e.phase==="editing",$=_.trim(),O=N||!$?null:Xc(_),I=!N&&$&&!O?fT(x,$):null,P=Yg(x,o),R=I!==null&&h.query===I&&((V=h.target)==null?void 0:V.exists)===!0,U=!l&&!T,F=!U||f.name.trim()!==""&&yZ.test(f.email.trim()),B=j?g?"the folder you chose is already a project: open it, or choose another":!N&&!$?"name the project first":O??(R?`${P} already has a folder called ${$}`:F?null:"git needs your name and email first"):null;S.useEffect(()=>{if(!I)return;const J=setTimeout(()=>n==null?void 0:n.send({t:"browse-path",path:I}),wZ);return()=>clearTimeout(J)},[I,n]),ft([e.phase],()=>{var J;e.phase==="editing"&&((J=y.current)==null||J.focus())}),ft([e.error],()=>{e.error&&t({a:"notice",id:Al,text:e.error})});const X={sock:n,dispatch:t},ae=()=>{B||!j||(t({a:"new-project-set",v:{phase:"creating"}}),lu(X,{t:"create-repo",mode:v,parent:x.trim(),name:$,...T&&e.url?{url:e.url}:{},...U?{identity:{name:f.name.trim(),email:f.email.trim()}}:{}}))},Y=J=>{const Z=r.find(ie=>ie.path===Ll(J,o));Z?t({a:"activate-repo",id:Z.id}):lu(X,{t:"register-repo",path:J})},ne=J=>{const Z=Yw(J);t({a:"new-project-set",v:{mode:"init",parent:Z.parent,name:Z.name}})},C=J=>{i?(t({a:"choosing-folder",v:J}),n==null||n.send({t:"choose-folder",start:x,purpose:J})):t(J==="location"?{a:"open",overlay:{kind:"choose-folder"}}:{a:"open",overlay:{kind:"projects",form:"disk"}})};ft([u==null?void 0:u.seq],()=>{var Z,ie;if(!c||!u)return;t({a:"choosing-folder",v:!1});const J=u.folder;if(!J){(Z=y.current)==null||Z.focus();return}if(c==="open"){J.kind==="project"?Y(J.path):U?ne(J.path):pT(X,J.path);return}if(w(J.kind==="project"?J.path:null),J.kind!=="project"){if(J.kind==="empty"&&!T){ne(J.path);return}t({a:"new-project-set",v:{mode:T?"clone":"create",parent:J.path}}),(ie=y.current)==null||ie.focus()}});const H=N?"the folder you chose becomes the project":g?null:R?`${P} already has a folder called ${$}`:O;return d.jsxs(ws,{anchor:"line",foot:d.jsx("div",{className:"composer view-foot",children:d.jsx(Kc,{active:null,project:{name:$,why:B,busy:!j,create:ae}})}),children:[T&&d.jsx("p",{className:"new-project-url",children:e.url}),d.jsxs("div",{className:"form-head",children:[N?d.jsx("p",{className:"form-title",children:_}):d.jsx(zo,{ref:y,bare:!0,font:"lead",className:"new-project-field",autoFocus:!0,spellCheck:!1,autoComplete:"off",value:_,placeholder:"Project name",disabled:!j,style:{width:`${Math.max(_.length+1,vZ)}ch`},onChange:J=>t({a:"new-project-set",v:{name:J.target.value}}),onKeyDown:J=>{J.key==="Enter"&&(J.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",...zt(x),children:P}),d.jsx(Ot,{icon:"folder",label:i?"Choose in Finder":"Choose a folder",className:"new-project-folder",on:c==="location",disabled:!j,onClick:()=>C("location")})]})]}),H&&d.jsx("p",{className:"hint",children:H}),g&&d.jsxs("p",{className:"hint",children:["the folder you chose is already a project:"," ",d.jsx(De,{variant:"inline",autoFocus:!0,onClick:()=>Y(g),children:"open it"}),", or choose another"]}),U&&d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"new-project-identity",children:[d.jsx(zo,{size:"md",font:"ui",rule:!0,value:f.name,placeholder:"Your name",autoComplete:"name",disabled:!j,onChange:J=>m({...f,name:J.target.value})}),d.jsx(zo,{size:"md",font:"ui",rule:!0,type:"email",value:f.email,placeholder:"Email",autoComplete:"email",disabled:!j,onChange:J=>m({...f,email:J.target.value})})]}),d.jsx("p",{className:"hint",children:"git labels the work you save with these, and asks only once"})]}),!T&&j&&d.jsx(De,{tone:"quiet",className:"new-project-open",onClick:()=>C("open"),children:"or open a folder you already have"})]})}function ul({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 xZ(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(`
270
- `)}function EZ(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(`
271
- `)}let SZ=1;const ng=(e,t,n=!1)=>({id:SZ++,name:e,cmd:t,shared:n}),_Z=[{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 NZ({repo:e,onClose:t}){const n=rt(),r=Gn(),o=L(Q=>Q.clientId),i=L(Q=>Q.rows.find(W=>{var ye;return Sn(W)&&W.id===((ye=Il(Q,e.id))==null?void 0:ye.id)})??null),l=L(Q=>{var W;return((W=Il(Q,e.id))==null?void 0:W.id)??null});S.useEffect(()=>{if(!t)return;const Q=W=>W.key==="Escape"&&t();return window.addEventListener("keydown",Q),()=>window.removeEventListener("keydown",Q)},[t]);const[c]=S.useState(()=>Object.keys(e.config.run).length>0),[u,h]=S.useState(()=>{const Q=Object.entries(e.config.run).map(([W,ye])=>ng(W,nE(ye),GC(ye)));return Q.length>0?Q:[ng("web","")]}),[f,m]=S.useState(()=>(e.config.setup??[]).join(`
272
- `)),[g,w]=S.useState(()=>(e.config.teardown??[]).join(`
273
- `)),[y,v]=S.useState(()=>e.config.check??""),[_,x]=S.useState(()=>bi(e.config).land),[T,N]=S.useState(()=>bi(e.config).automerge),[j,$]=S.useState(()=>bi(e.config).merge??"default"),[O,I]=S.useState(()=>XC(e.configFile)),P=QC(e.configFile,O),R=!!e.remote&&_==="pr",U=u.length>1,F=u.some(Q=>Q.name.trim()&&Q.cmd.trim()),X=!!i&&!t&&!c&&!F,ae=(Q,W)=>h(u.map((ye,_e)=>_e===Q?{...ye,...W}:ye)),Y=Q=>Q.split(`
274
- `).map(W=>W.trim()).filter(Boolean),ne=()=>Y(f),C=()=>Y(g),H=()=>{const{check:Q,land:W,teardown:ye,..._e}=e.config,ve=e.remote?_:ig,ce=j==="default"||ve!=="pr"&&j===ag?void 0:j,Se={...ve!==ig?{route:ve}:{},...ve==="pr"&&T?{automerge:!0}:{},...ce?{method:ce}:{}};return{..._e,setup:ne(),...C().length>0?{teardown:C()}:{},...y.trim()?{check:y.trim()}:{},...Object.keys(Se).length>0?{land:Se}:{}}},V=()=>{n==null||n.send({t:"confirm-config",repoId:e.id,config:{...H(),run:Object.fromEntries(u.filter(Q=>Q.name.trim()&&Q.cmd.trim()).map((Q,W)=>[Q.name.trim(),Q.shared&&W>0?{cmd:Q.cmd.trim(),from:"trunk"}:Q.cmd.trim()]))},kind:O}),t==null||t()},J=()=>{n==null||n.send({t:"confirm-config",repoId:e.id,config:{...H(),run:{}},kind:O}),t==null||t()},Z=()=>n==null?void 0:n.send({t:"create-worktree",clientId:o,repoId:e.id,prompt:EZ(e,P)}),ie=e.services,be=[f,g,...u.map(Q=>Q.cmd)].some(Q=>Q.includes("TOYON_WORKTREE"))||VC(e.config),ge=ie?[ie.envUrl?`the database at ${ie.envUrl.name} in ${ie.envUrl.file}`:null,ie.compose?`the stack in ${ie.compose}`:null].filter(Boolean).join(" and "):"",we=()=>ie&&(n==null?void 0:n.send({t:"create-worktree",clientId:o,repoId:e.id,prompt:xZ(e,P,ie)})),pe=(Q,W)=>d.jsxs("div",{className:"setup-proc",children:[U&&d.jsx(zo,{size:"md",rule:!0,className:"setup-name",value:Q.name,placeholder:"name",...zt("Process name, shown in the status bar"),onChange:ye=>ae(W,{name:ye.target.value})}),d.jsx(zo,{size:"md",rule:!0,className:"setup-cmd",value:Q.cmd,placeholder:"npm run dev",onChange:ye=>ae(W,{cmd:ye.target.value})}),U&&d.jsx(Ot,{icon:"close",label:"Remove",onClick:()=>h(u.filter((ye,_e)=>_e!==W))}),U&&W>0&&d.jsx(Uj,{className:"setup-shared",checked:Q.shared,onChange:ye=>ae(W,{shared:ye.target.checked}),tip:"Main runs it once for every worktree; a worktree whose changes touch it runs its own",children:"shared from main"})]},Q.id);return d.jsxs(ws,{children:[d.jsxs("p",{className:"form-title",children:["how does ",e.name," start?"]}),ie&&!be&&d.jsxs("p",{className:"hint setup-shared-note",children:["Worktrees will share ",ge,", migrations included."," ",d.jsx(De,{tone:"quiet",disabled:!i,onClick:we,children:"ask the agent to keep them apart"})]}),d.jsx(ul,{label:"install",hint:"once per new worktree; one command per line",children:d.jsx(nu,{size:"md",rule:!0,rows:Math.max(1,f.split(`
275
- `).length),value:f,placeholder:"bun install",onChange:Q=>m(Q.target.value)})}),d.jsx(ul,{label:"remove",hint:"once when a worktree goes, before its directory does; one command per line",children:d.jsx(nu,{size:"md",rule:!0,rows:Math.max(1,g.split(`
276
- `).length),value:g,placeholder:'dropdb --if-exists "app_$TOYON_WORKTREE"',onChange:Q=>w(Q.target.value)})}),d.jsx(ul,{label:"check",hint:"runs after each of the agent's turns; the work lands only when it passes",children:d.jsx(zo,{size:"md",rule:!0,value:y,placeholder:"bun run check",onChange:Q=>v(Q.target.value)})}),e.remote&&d.jsx(ul,{label:"land",hint:"where a worktree's finished work goes; one way per repo",children:d.jsxs("div",{className:"setup-land",children:[d.jsx(vi,{value:_,options:fA.map(Q=>({id:Q.id,label:Q.name,description:Q.description})),onChange:x,hint:"where the work goes",placeholder:"where work lands"}),R&&d.jsx(vi,{value:T?"github":"you",options:pA.map(Q=>({id:Q.id,label:Q.name,description:Q.description})),onChange:Q=>N(Q==="github"),hint:"who merges the pull request",placeholder:"who merges it"})]})}),d.jsx(ul,{label:"merge",hint:R?"how GitHub merges the pull request; only what the repo allows":"how the commits arrive on main",children:d.jsx(vi,{value:j==="default"&&!R?ag:j,options:[...R?[{id:"default",label:"what the repo allows",description:"the repo's allowed methods on GitHub: squash, else a merge commit, else rebase"}]:[],...hA.map(Q=>({id:Q.id,label:Q.name,description:Q.description}))],onChange:$,hint:"how the commits arrive on main",placeholder:"how the commits arrive"})}),d.jsx(ul,{label:"start",hint:d.jsxs(d.Fragment,{children:["must listen on ",d.jsx("code",{...zt("Toyon sets a different port for each worktree"),children:"$PORT"}),e.guess&&l&&d.jsxs(d.Fragment,{children:[" · from ",d.jsx(De,{mono:!0,tone:"quiet",...zt(`open ${e.guess} in the editor pane`),onClick:()=>ga(r,n,l,e.guess??"",1),children:e.guess})]})]}),children:u[0]&&pe(u[0],0)}),u.slice(1).map((Q,W)=>d.jsxs("div",{className:"form-row",children:[d.jsx("span",{className:"form-label"}),d.jsx("div",{className:"form-control",children:pe(Q,W+1)})]},Q.id)),d.jsxs("div",{className:"form-row",children:[d.jsx("span",{className:"form-label"}),d.jsxs(De,{tone:"quiet",onClick:()=>h([...u,ng("","")]),children:[d.jsx(_t,{name:"plus",className:"icon-inline"})," another process"]})]}),d.jsxs("div",{className:"form-knobs",children:[d.jsx(vi,{value:O,options:_Z,onChange:I,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:P}),t&&d.jsx(De,{onClick:t,children:"cancel"}),(!c||t)&&d.jsx(De,{...zt("This project has no dev server: chat, changes and the terminal work, the preview stays empty"),onClick:J,children:"no dev server"}),X&&i?d.jsx(De,{variant:"outline",size:"lg",disabled:i.agent!=="idle",...zt("The agent reads the repo and writes the settings file; the daemon picks it up as soon as it lands"),onClick:Z,children:"let the agent work it out"}):d.jsxs(De,{variant:"outline",size:"lg",disabled:!F,...t?zt("Restarts every worktree of this repo. Profiles and other keys in the file are kept."):{},onClick:V,children:[t?"save + restart":"start"," ",d.jsx(_t,{name:"forward",className:"icon-inline"})]})]})]})}function TZ(e){return`${Math.round(e.w)} × ${Math.round(e.h)}`}function jZ(e){return e.w>0&&e.h>0}function $Z(e,t,n){S.useEffect(()=>{if(!e||!t){n(null);return}const r=new ResizeObserver(o=>{var c;const i=(c=o[o.length-1])==null?void 0:c.contentRect;if(!i)return;const l={w:i.width,h:i.height};n(jZ(l)?TZ(l):null)});return r.observe(e),()=>{r.disconnect(),n(null)}},[e,t,n])}const CZ=1500,AZ={set:(e,t)=>setTimeout(e,t),clear:e=>clearTimeout(e)};class IZ{constructor(t,n,r=AZ){St(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=ub(r));const i=ph(n);if(!i){o.sent=null;return}if(i===o.sent){this.renamed(t,o);return}o.pending=i,o.timer=this.timers.set(()=>{o.timer=null,o.pending=null,o.sent=i,o.sentTitle=o.title,this.send(t,i,o.title)},CZ)}title(t,n){const r=this.frame(t);r.title=ub(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 RZ=Of(),OZ=2*6e4;function D1(e){e==null||e.setAttribute("src",e.src)}const MZ=8e3;function PZ(e,t){try{const n=new URL(e,t);return n.origin===new URL(t).origin?n.href:null}catch{return null}}function LZ({onRoot:e}){const t=S.useRef(null),n=S.useCallback(oe=>{t.current=oe,e(oe)},[e]),r=ct(),o=Gn(),i=rt(),l=S.useRef(i);l.current=i;const[c]=S.useState(()=>new IZ((oe,Le,Ye)=>{var $t,pt;($t=l.current)==null||$t.send({t:"visit",worktreeId:oe,path:Le,title:Ye}),wS((pt=o.getState().local[oe])==null?void 0:pt.pages)&&un.post(oe,{type:"links"})},(oe,Le,Ye)=>{var $t;return($t=l.current)==null?void 0:$t.send({t:"page-title",worktreeId:oe,path:Le,title:Ye})}));S.useEffect(()=>()=>c.dispose(),[c]);const u=s_(),h=Hl(),f=Ps(),m=L(oe=>oe.connected),g=L(oe=>oe.heard),w=L(oe=>oe.recalledAt!==null),y=L(oe=>oe.connectFailure),v=L(oe=>oe.remote),{host:_}=Ur(),x=mo(),T=ss(),N=L(oe=>oe.editor),j=a_(),$=xD(),O=L(oe=>oe.notesPage),I=vu(),P=L(oe=>oe.layout.term)&&!I,R=L(oe=>oe.focusTerm),U=S.useRef(!1),F=S.useRef(R),B=!U.current||R!==F.current;S.useEffect(()=>{U.current=P&&!!h,F.current=R});const X=bu(),ae=L(oe=>oe.layout.design)&&!I&&!X,Y=L(oe=>oe.reloadReq),ne=Eh(),C=S.useRef(ne);C.current=ne;const H=L(oe=>oe.zen),V=L(oe=>{var Le;return((Le=oe.dragFiles)==null?void 0:Le.at)==="centre"}),J=S.useRef(H);J.current=H;const Z=Rt(h,"log"),ie=L(oe=>oe.incompatible),be=SD(),ge=L(oe=>{var Le;return((Le=oe.overlay)==null?void 0:Le.kind)==="setup"?oe.repos.find(Ye=>Ye.id===oe.overlay.repoId)??null:null}),we=(f==null?void 0:f.worktree.empty)===!0,pe=Fo(f==null?void 0:f.agent),Q=be&&!we&&!pe?be:null,W=Q??ge,ye=L(oe=>oe.pending.find(Le=>Le.id===oe.activeImportId)??null),[_e,ve]=S.useState([]),ce=S.useMemo(()=>_e.map(oe=>oe.id),[_e]),Se=S.useRef(new Map),me=S.useRef(new Map),[Ue,Ie]=S.useState([]),We=S.useRef(new Set),mt=S.useRef(new Set),en=S.useRef(oe=>D1(Se.current.get(oe)));S.useEffect(()=>{un.post=(oe,Le)=>{var Ye,$t;if(Le.type==="reload"&&We.current.has(oe))return en.current(oe);($t=(Ye=Se.current.get(oe))==null?void 0:Ye.contentWindow)==null||$t.postMessage({__toyon:!0,...Le},me.current.get(oe)??"*")},un.broadcast=oe=>{var Le;for(const[Ye,$t]of Se.current)(Le=$t.contentWindow)==null||Le.postMessage({__toyon:!0,...oe},me.current.get(Ye)??"*")}},[]),S.useEffect(()=>{let oe=null;const Le=pt=>{pt.target instanceof HTMLElement&&pt.target.tagName!=="IFRAME"&&(oe=pt.target)},Ye=pt=>{pt.relatedTarget===null&&setTimeout(()=>{document.activeElement===document.body&&(oe=null)},0)},$t=pt=>{var yn,Tr,ir,Wt,Yr;if((yn=pt.data)!=null&&yn.__toyon)for(const[dt,Bn]of Se.current){if(Bn.contentWindow!==pt.source)continue;if(pt.origin!==me.current.get(dt))return;const st=qE(pt.data);if(!st)return;switch(st.type){case"key":window.dispatchEvent(new KeyboardEvent(st.up?"keyup":"keydown",{key:st.key,code:st.code,metaKey:st.meta,ctrlKey:!!st.ctrl,shiftKey:!!st.shift,altKey:!!st.alt}));break;case"hmr":r({a:"hmr",id:dt}),(Tr=l.current)==null||Tr.send({t:"page-loaded",worktreeId:dt});break;case"loaded":We.current.delete(dt),mt.current.add(dt),Ie(Te=>Te.includes(dt)?Te:[...Te,dt]),un.post(dt,s$(C.current)),un.post(dt,{type:"zen",on:J.current}),r({a:"hmr",id:dt}),r({a:"page",id:dt,url:st.url,title:st.title}),(ir=l.current)==null||ir.send({t:"page-loaded",worktreeId:dt}),c.note(dt,st.url,st.title);break;case"navigated":r({a:"page",id:dt,url:st.url,...st.title!==void 0?{title:st.title}:{}}),c.note(dt,st.url,st.title);break;case"title":r({a:"page",id:dt,title:st.title}),c.title(dt,st.title);break;case"links":r({a:"links",id:dt,links:st.links});break;case"page-error":{const Te=zL(st);Te&&((Wt=l.current)==null||Wt.send({t:"page-error",worktreeId:dt,message:Te}));break}case"picked":{const{type:Te,verb:qe,site:xt,...at}=st,fn=xt==="call"?{file:at.callFile,line:at.callLine}:{file:at.file,line:at.line};if(qe==="code"){r({a:"set-picking",v:!1});const Ft=(Yr=rn(o.getState(),dt))==null?void 0:Yr.worktree;fn.file?ga(o,i,dt,fS(fn.file,Ft==null?void 0:Ft.path),fn.line??1):i==null||i.send({t:"find-element",worktreeId:dt,seq:Lo(),element:at.element})}else sz(o,dt,at);break}case"pick-cancel":r({a:"set-picking",v:!1});break;case"drag-files":st.over?bw(o,o.getState().activeId?{at:"centre"}:null):I_(o);break;case"drop-files":P_(o,i,o.getState().activeId?{at:"centre"}:null,Mz(st.files));break;case"focus":st.gesture?oe=null:document.activeElement===Bn&&(oe!=null&&oe.isConnected)&&oe!==document.body&&oe.focus();break;case"highlight-miss":console.warn(`[toyon] highlight miss on ${st.path}: ${st.fileMatched} elements from this file, ${st.withSource} elements with source info on page, ranges=${JSON.stringify(st.ranges)}`);break}return}};return window.addEventListener("message",$t),document.addEventListener("focusin",Le),document.addEventListener("focusout",Ye),()=>{window.removeEventListener("message",$t),document.removeEventListener("focusin",Le),document.removeEventListener("focusout",Ye)}},[r,o,i,c]),S.useEffect(()=>{un.broadcast({type:"zen",on:H})},[H]);const Kt=S.useRef(new Map);ft([Y==null?void 0:Y.id,Y==null?void 0:Y.n],()=>{if(!Y)return;const{id:oe}=Y;clearTimeout(Kt.current.get(oe)),Kt.current.set(oe,setTimeout(()=>{Kt.current.delete(oe),un.post(oe,{type:"reload"})},1200))});const Be=cw(),Xt=Be&&!Sn(Be)?Be:null,ln=_a(),It=!!f&&f.procs.some(oe=>oe.status==="running"),Je=fw(),Vt=Je!==null&&Je===h&&It;S.useEffect(()=>{var oe;if(Je&&Vt&&!ce.includes(Je)){const Le=L1((oe=o.getState().local[Je])==null?void 0:oe.page.url);ve(Ye=>[...Ye,{id:Je,path:Le}])}},[Je,Vt,ce,o]);const tn=u.filter(oe=>Sn(oe)&&oe.procs.some(Le=>Le.status==="asleep")).map(oe=>oe.id).join(" ");S.useEffect(()=>{const oe=new Set(tn.split(" ").filter(Boolean));ce.some(Le=>oe.has(Le))&&ve(Le=>Le.filter(Ye=>!oe.has(Ye.id)))},[tn,ce]);const ht=ce.join(" ");S.useEffect(()=>{const oe=ht.split(" ").filter(Le=>Le&&Le!==Je).map(Le=>setTimeout(()=>ve(Ye=>Ye.filter($t=>$t.id!==Le)),OZ));return()=>{for(const Le of oe)clearTimeout(Le)}},[ht,Je]),S.useEffect(()=>{Ie(oe=>oe.every(Le=>ce.includes(Le))?oe:oe.filter(Le=>ce.includes(Le)))},[ce]);const gt=S.useMemo(()=>u.filter(Sn).flatMap(oe=>{const Le=_e.find($t=>$t.id===oe.id);if(!Le)return[];const Ye=dS(oe.worktree.id,oe.worktree.proxyPort,v,_);return[{id:oe.worktree.id,port:oe.worktree.proxyPort,title:oe.worktree.title,url:PZ(Le.path,Ye)??Ye}]}),[u,_e,v,_]),sn=Rg(x,v),kn=U_(x,gt,sn);en.current=oe=>{var Ye;const Le=L1((Ye=o.getState().local[oe])==null?void 0:Ye.page.url);if(_e.some($t=>$t.id===oe&&$t.path!==Le)){ve($t=>$t.map(pt=>pt.id===oe?{...pt,path:Le}:pt));return}sn?kn.renew(oe):D1(Se.current.get(oe))};const Pt=gt.filter(oe=>{var Le;return(Le=u.find(Ye=>Ye.id===oe.id))==null?void 0:Le.procs.some(Ye=>Ye.status==="running")}).map(oe=>oe.id).join(" ");ft([Pt],()=>{for(const oe of Pt.split(" "))We.current.has(oe)&&en.current(oe)});const Rn=L(oe=>oe.carryTo),[bt,ee]=S.useState(null),[ke,Xe]=S.useState(Je),Ge=S.useRef(null);ke!==Je&&(Xe(Je),ee(pZ({leaving:Ge.current,arriving:Je,carryTo:Rn,repoOf:oe=>{var Le;return((Le=u.find(Ye=>Ye.id===oe))==null?void 0:Le.repoId)??null}}))),S.useEffect(()=>{if(!bt)return;const oe=setTimeout(()=>ee(null),MZ);return()=>clearTimeout(oe)},[bt]);const Zt=Je!==null&&Ue.includes(Je),Bt=mZ({previewId:Je,painted:Zt,ready:Vt,carry:bt,mounted:ce}),mn=Bt!==null&&Bt!==Je;S.useEffect(()=>{Ge.current=Bt});const an=Bt!==null&&!W&&!ye&&!O&&!I&&!X,[xn,M]=S.useState(null),re=S.useCallback(oe=>r({a:"preview-size",text:oe}),[r]);$Z(xn,an,re);const[Ne,Ze]=xo(Ke.editorHeight,0,oe=>{const Le=Number(oe);return Number.isFinite(Le)&&Le>=120?Le:0}),[jt,Ut]=xo(Ke.designHeight,0,oe=>{const Le=Number(oe);return Number.isFinite(Le)&&Le>0?Le:0}),[Me,Pe]=xo(Ke.designFull,!1,oe=>oe===null?void 0:oe==="1"),[Ve,Lt]=xo(Ke.editorFull,!1,oe=>oe===null?void 0:oe==="1"),[qt,zn]=xo(Ke.termHeight,240,oe=>{const Le=Number(oe);return Number.isFinite(Le)&&Le>=140?Le:void 0}),et=L(oe=>oe.termTall);ft([et],()=>{const oe=t.current;et&&oe&&zn(Math.max(qt,Math.round(oe.clientHeight/2)))});const Ht=oe=>(Le,Ye)=>{const $t=Ye.parentElement,pt=t.current;if(!$t||!pt)return null;let yn=0;for(const ir of Array.from(pt.querySelectorAll(":scope > .pane")))ir!==$t&&!ir.classList.contains("full")&&(yn+=ir.offsetHeight);const Tr=Math.max(pt.clientHeight-yn-80,oe);return Math.min(Math.max($t.getBoundingClientRect().bottom-Le.clientY,oe),Tr)},On=_l(Ht(120),oe=>Ze(Math.round(oe))),dn=_l(Ht(160),oe=>Ut(Math.round(oe))),sr=_l(Ht(140),oe=>zn(Math.round(oe))),Fn=L(oe=>{var Le,Ye;return f&&_r(f.worktree)?((Ye=(Le=oe.rows.find($t=>{var pt;return $t.repoId===f.worktree.repoId&&((pt=$t.worktree)==null?void 0:pt.kind)==="worktree"}))==null?void 0:Le.worktree)==null?void 0:Ye.title)??null:null}),hr=B3({connected:m,heard:g,standing:w,connectFailure:y,hasToken:x.serving?RZ:!0,projectChord:Dt("project"),title:(f==null?void 0:f.worktree.title)??null,machine:x.serving?null:T.displayName(x.origin),needsSetup:!!be,busy:pe,treeEmpty:we,landsFrom:Fn});return d.jsxs("div",{className:"center-root",ref:n,children:[d.jsx("div",{className:He("center-area",V&&"drop-over"),style:{display:!(H&&!X)&&!ln&&!O&&(N&&Ve||ae&&Me)?"none":void 0},children:d.jsxs("div",{className:"frames-wrap",ref:M,children:[gt.map(oe=>d.jsx("iframe",{ref:Le=>{Le?(Se.current.set(oe.id,Le),me.current.set(oe.id,new URL(oe.url).origin)):(Se.current.delete(oe.id),me.current.delete(oe.id),We.current.delete(oe.id),mt.current.delete(oe.id))},onLoad:()=>{mt.current.delete(oe.id)?We.current.delete(oe.id):We.current.add(oe.id)},src:kn.urlOf(oe.id)??void 0,title:oe.title,style:{display:an&&oe.id===Bt?"block":"none"}},oe.id)),$?d.jsx(bZ,{project:$}):O?d.jsx(MK,{}):d.jsxs(d.Fragment,{children:[ye&&d.jsx(kZ,{pending:ye},ye.id),j&&f&&!ye&&d.jsx(gZ,{active:f},f.worktree.id),W&&!ye&&!j&&d.jsx(NZ,{repo:W,onClose:Q?void 0:()=>r({a:"close"})},`${W.id}:${JSON.stringify(W.config)}`),Xt&&!W&&!ye&&!ln&&d.jsx(Zc,{placement:"centre",found:Xt},Xt.id),ln&&!W&&!ye&&d.jsx(Zc,{placement:"centre",archived:ln},ln.id),!It&&!Xt&&!ln&&!W&&!ye&&!j&&ie&&d.jsx(eN,{foreign:x.serving?void 0:T.displayName(x.origin)}),!It&&!Xt&&!ln&&!W&&!ye&&!j&&!ie&&(hr!==null?d.jsx(ws,{wide:!0,children:d.jsx("p",{className:He("status-line",hr.live&&"live-text"),children:hr.text})}):X?d.jsx(Zc,{placement:"centre"}):mn?null:f&&d.jsx(fZ,{worktree:f,log:Z}))]})]})}),N&&d.jsx(Kj,{editor:N,height:Ve?"100%":Ne>0?Ne:"45%",full:Ve,onToggleFull:()=>Lt(!Ve),onDragStart:On}),ae&&h&&!ln&&!O&&d.jsx(DK,{worktreeId:h,height:Me?"100%":jt>0?jt:"55%",full:Me,onToggleFull:()=>Pe(!Me),onDragStart:dn},`design:${h}`),P&&h&&!ln&&!O&&d.jsx(cZ,{worktreeId:h,opened:B,height:qt,onDragStart:sr},`term:${h}`),d.jsx(Qj,{})]})}function DZ({width:e}){const t=L(r=>r.layout.chat),n=vu();return d.jsx(Zc,{placement:"dock",className:!t||n?"collapsed":void 0,width:e})}function zZ(e,t){const n=[];return e&&(n.push(h_(e)),n.push({id:"copy-url",label:"copy URL",onClick:()=>Yt(e)})),Dn([n,[{id:"reload",label:"reload preview",key:Dt("reload"),onClick:t.reload}]])}const FZ=520,rg=8;function BZ({winW:e,centre:t,leadRight:n,toolsLeft:r}){const o=t.right-t.left,i=Math.max(0,Math.min(FZ,Math.floor(e*.4),o-2*rg)),l=t.left+(o-i)/2,c=n+rg,u=r-rg-i,h=Math.max(Math.min(l,u),c);return{left:Math.round(h),width:i}}function UZ({center:e}){const t=eD(),n=e_(e),r=S.useRef(null);dD(r);const o=r3(),[i,l]=Cb(),[c,u]=Cb(),h=BZ({winW:t,centre:n,leadRight:l.right,toolsLeft:u.left}),f=ct(),m=rt(),g=Gn(),w=wn("bar"),y=Ps(),v=bu(),_=L(X=>X.zen)&&!v,x=L(X=>X.layout.changes),T=L(X=>X.layout.chat),N=vu(),j=L(X=>X.layout.design),$=L(X=>{var ae;return((ae=X.overlay)==null?void 0:ae.kind)==="keys"}),O=dj(),I=(y==null?void 0:y.worktree.id)??null,P=L(X=>X.archivedPage!==null||X.notesPage),R=!!y&&bh(y)&&!P,U=L(X=>X.chatSide)==="left",F=!N&&d.jsx(Ot,{icon:"branch",label:"Changes panel",hint:Dt("changes"),tone:"chrome",on:x,onClick:()=>f({a:"toggle-changes"})}),B=!N&&!v&&d.jsx(Ot,{icon:"chat",label:"Chat panel",hint:Dt("composer"),tone:"chrome",on:T,onClick:()=>f({a:"toggle-chat"})});return d.jsxs("div",{className:"top-bar",ref:r,"data-float-up":o||void 0,children:[_&&d.jsx("span",{className:"bar-zen-title",children:(y==null?void 0:y.worktree.title)??"Toyon"}),d.jsxs("span",{className:"bar-lead",ref:i,children:[U?B:F,d.jsx(HZ,{}),O&&d.jsx(Tu,{icon:"download","data-tip":"Install Toyon as an app (own window, dock icon)",onClick:()=>void O.prompt(),children:"install app"}),d.jsx(KZ,{}),d.jsx(ZZ,{}),d.jsx(qZ,{})]}),!v&&d.jsx(WZ,{worktreeId:I,repoId:(y==null?void 0:y.repoId)??null,ready:R,left:h.left,width:h.width}),d.jsx("span",{className:"bar-grow"}),d.jsxs("span",{className:"bar-tools",ref:c,children:[d.jsx(GZ,{}),d.jsx(Ot,{icon:"settings",label:"Settings & shortcuts",hint:Dt("keys"),tone:"chrome",on:$,"aria-controls":"keys-help","aria-expanded":$,onClick:()=>f({a:"toggle",overlay:{kind:"keys"}}),...w.contextMenu(()=>mT(g.getState(),{sock:m,dispatch:f}))}),!N&&!v&&d.jsx(Ot,{icon:"palette",label:"Design system",hint:Dt("design"),tone:"chrome",on:j,onClick:()=>f({a:"toggle-design"})}),U?F:B,!v&&d.jsx(Ot,{icon:"zen",className:"bar-zen",label:"Full-bleed preview",hint:Dt("zen"),tone:"chrome",on:_,onClick:()=>f({a:"toggle-zen"})})]})]})}function HZ(){const e=ct(),t=rt(),n=Wl(),r=L(f=>f.activeRepoId),o=L(f=>f.repos),i=wn("bar"),l=()=>Dn([[{id:"project",label:o.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?Dh(n,r,{sock:t,dispatch:e}):[]]),c=L(f=>{var m;return((m=f.overlay)==null?void 0:m.kind)==="projects"&&f.overlay.form==="pill"}),u=L(f=>f.heard),h=L(f=>f.newProject!==null);return d.jsxs("span",{className:"bar-project",children:[d.jsx(De,{tone:"chrome",className:"bar-pill",on:c,...zt(o.length>1?"Switch project":"Open a project",Dt("project")),onClick:()=>e({a:"toggle",overlay:{kind:"projects",form:"pill"}}),...i.contextMenu(l),children:d.jsx("span",{className:"bar-project-name",children:h?"new project":(n==null?void 0:n.name)??(u?"open project":"")})}),c&&d.jsx(my,{form:"pill"})]})}function WZ({worktreeId:e,repoId:t,ready:n,left:r,width:o}){const i=Rt(e,"page").url,l=ct(),c=L(w=>{var y;return((y=w.overlay)==null?void 0:y.kind)==="routes"}),u=L(w=>w.previewSize);ft([e,n],()=>{c&&l({a:"close"})});const f=wn("bar").contextMenu(()=>n?zZ(i,{reload:()=>e&&un.post(e,{type:"reload"})}):[]),m=L(w=>w.picking),g=fw();return d.jsxs("div",{className:"bar-center",style:{left:r,width:o},children:[d.jsx(Ot,{icon:"back",label:"Back",hint:Dt("back"),disabled:!n,onClick:()=>e&&un.post(e,{type:"back"}),...f}),d.jsx(Ot,{icon:"forward",label:"Forward",hint:Dt("forward"),disabled:!n,onClick:()=>e&&un.post(e,{type:"forward"}),...f}),d.jsx(Ot,{icon:"reload",label:"Reload preview",hint:Dt("reload"),disabled:!n,onClick:()=>e&&un.post(e,{type:"reload"}),...f}),d.jsxs("span",{className:"bar-route",children:[n&&e&&t?d.jsx(E7,{worktreeId:e,repoId:t,url:i,open:c},e):d.jsx(zo,{className:"bar-path",value:"",readOnly:!0,disabled:!0}),u&&d.jsx("span",{className:"bar-size",children:u})]}),d.jsx(Ot,{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&&eu(g,m,l,"code")})]})}function Tu({icon:e,busy:t,children:n,...r}){return d.jsxs(De,{disabled:t,...r,children:[!t&&d.jsx(_t,{name:e,className:"icon-inline"}),d.jsx("span",{className:He(t&&"live-text"),children:n})]})}function KZ(){const e=L(u=>u.self),t=L(u=>u.rebuilt),n=L(u=>u.repos),r=rt(),o=L(u=>{var h;return((h=u.update)==null?void 0:h.restarting)!=null}),i=Zj(e,n,t);if(!i||o)return null;const l=i.busy?"rebuilding":i.reload?"reload Toyon":i.build==="rebuild"?"rebuild Toyon":i.build??"restart Toyon",c=()=>{i.reload?window.location.reload():e&&(r==null||r.send(i.build?{t:"run-after-land",repoId:e.repoId}:{t:"restart-daemon"}))};return d.jsx(Tu,{icon:"reload",busy:i.busy,onClick:c,...zt(i.text,void 0,{detail:i.detail}),children:l})}function ZZ(){const e=L(o=>o.update),t=L(o=>o.managed.updates),n=rt(),r=R3(e);return!r||!t?null:d.jsx(Tu,{icon:"reload",busy:r.busy,onClick:()=>{r.retry&&(n==null||n.send({t:"update-now"}))},...zt(r.text),children:r.word})}function qZ(){const e=ct(),t=L(v4),n=L(l=>l.ranBefore),r=L(l=>l.newProject!==null);if(!t||!n||r)return null;const{word:o,text:i}=OK(n,t);return d.jsx(Tu,{icon:"book",onClick:()=>e({a:"open-release-notes"}),...zt(i),children:o})}function GZ(){const e=ct(),t=L(I4),n=L(i=>i.letIn),r=L(i=>{var l;return((l=i.overlay)==null?void 0:l.kind)==="devices"});if(!t)return null;const o=()=>e({a:"toggle",overlay:{kind:"devices"}});return n?d.jsx(Ot,{icon:"devices",label:"Your devices",tone:"chrome",on:r,"aria-expanded":r,onClick:o}):d.jsx(Tu,{icon:"devices","aria-expanded":r,onClick:o,...zt("Open this machine on your phone, and let it in"),children:"open on phone"})}function VZ(e,t,n){return t==="left"?n-e.left:e.right-n}const YZ="input, textarea, [contenteditable], .monaco-editor, .xterm, iframe";function XZ(){const e=Gn(),t=ct(),n=rt(),r=vu(),o=Na(),i=bu(),l=L(V=>V.zen)&&!i,c=_a(),u=L(V=>V.notesPage),h=!!dw()||!!c||u,f=L(V=>V.layout.changes)&&!r,m=L(V=>V.layout.chat)&&!r&&!i&&!h,g=L(V=>V.chatSide),w=L(V=>V.railOpen),[y,v]=xo(Ke.changesWidth,220,V=>V?Xd(Number(V),220):void 0),[_,x]=xo(Ke.chatWidth,380,V=>V?Xd(Number(V),380):void 0),[T,N]=xo(Ke.railWidth,280,V=>V?Xd(Number(V),280):void 0),j=(V,J,Z)=>{const ie=J.classList.contains("left")?"left":"right",be=ie==="left"?J.previousElementSibling:J.nextElementSibling;return be?Xd(VZ(be.getBoundingClientRect(),ie,V.clientX),Z):null},$=_l((V,J)=>j(V,J,220),v),O=_l((V,J)=>j(V,J,380),x),I=_l((V,J)=>j(V,J,280),N),[P,R]=S.useState(null),F=wn("app").contextMenu(()=>cT(e.getState(),{sock:n,dispatch:t})),B=d.jsx(NN,{width:y}),X=!i&&!h&&d.jsx(DZ,{width:_}),ae=!r&&d.jsx(t$,{width:T}),Y=V=>!r&&w&&d.jsx("div",{className:`dock-resize ${V}`,onPointerDown:I}),ne=g==="left",C=ne?{dock:X,open:m,drag:O}:{dock:B,open:f,drag:$},H=ne?{dock:B,open:f,drag:$}:{dock:X,open:m,drag:O};return d.jsxs("div",{className:He("app",l&&"zen"),"data-chat-side":g,"data-touch":o||void 0,"data-hover":!o||void 0,onContextMenu:V=>{V.defaultPrevented||V.target instanceof Element&&V.target.closest(YZ)||F.onContextMenu(V)},children:[d.jsx(W_,{}),d.jsx(G_,{}),d.jsx(UZ,{center:P}),d.jsxs("div",{className:"docks",children:[ne&&ae,ne&&Y("left"),C.dock,C.open&&d.jsx("div",{className:"dock-resize left",onPointerDown:C.drag}),d.jsx(LZ,{onRoot:R}),H.open&&d.jsx("div",{className:"dock-resize right",onPointerDown:H.drag}),H.dock,!ne&&Y("right"),!ne&&ae]})]})}function QZ(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 i=t.findIndex(u=>u.id===n);if(i<0)return null;const l=t[i+r];if(l)return{activate:l.id};const c=e[e.length-1];return r<0&&c?{activate:c.id}:null}const JZ=new Set(["design","chats"]),eq=new Set(["back","forward"]),tq=new Set(["project","commands","keys","zen"]);function nq(){const e=Gn(),t=rt();S.useEffect(()=>{const n=dK(f=>e.dispatch({a:"rail-peek",on:f})),r=n.end,o=f=>{e.getState().railOpen||n.press(f)},i=f=>n.keyup(f.key),l=f=>n.mods(f),c=()=>{var w,y;const f=e.getState(),g=((y=(w=document.activeElement)==null?void 0:w.closest("[data-pane]"))==null?void 0:y.dataset.pane)??(f.layout.term?"terminal":f.editor?"editor":f.layout.design?"design":null);g==="terminal"?e.dispatch({a:"toggle-terminal"}):g==="editor"?e.dispatch({a:"close-editor"}):g==="design"&&e.dispatch({a:"toggle-design"})},u=f=>{f.key!=="Escape"||!e.getState().choosingFolder||(f.stopImmediatePropagation(),t==null||t.send({t:"cancel-folder"}),e.dispatch({a:"choosing-folder",v:!1}))},h=f=>{var _,x,T,N;l(f),PC(f)&&!f.defaultPrevented&&f.preventDefault();const m=e.getState(),{dispatch:g}=e,w=j=>{const $=document.activeElement,O=!$||$===document.body||!!$.closest(".rail, .chat-input");g({a:"activate",id:j}),O&&g({a:"walked"})},y=eE(f,{guest:!!((_=document.activeElement)!=null&&_.closest(".xterm"))});if(!(m.zen&&!Do(m)&&!m.overlay&&!m.picking&&!(y&&MC.has(y.id))||(y==null?void 0:y.id)==="close"&&!Gk()||(x=document.activeElement)!=null&&x.closest(".monaco-editor")&&y&&JZ.has(y.id))&&!(y&&BC(y.id,document.activeElement))&&!(y&&eq.has(y.id)&&!(kl(m)&&Df(m)))&&!((y==null?void 0:y.id)==="reload"&&!bg(m))){if(y){const j=f.defaultPrevented;if(f.preventDefault(),m.newProject&&!tq.has(y.id))return;switch(y.id){case"worktree":{const $=DC(y.digit,m.visible.length),O=$===null?void 0:m.visible[$];O&&w(O.id);break}case"wt-prev":case"wt-next":{const $=QZ(m.visible,m.visibleDiscovered,m.activeId,y.id==="wt-next"?1:-1);$&&w($.activate),o(f);break}case"wt-unseen-prev":case"wt-unseen-next":{const $=Gw(m.visible,m.activeId,y.id==="wt-unseen-next"?1:-1);$&&w($.activate),o(f);break}case"mark-unread":m.activeId&&!m.draft&&m.visible.some($=>$.id===m.activeId)&&cN(t,g,m.activeId);break;case"wt-archive":{if(f.repeat||j)break;const $=m.draft||m.archivedPage?void 0:m.visible.find(O=>O.id===m.activeId);$&&uN(t,g).archive($);break}case"new":g({a:"open-draft"});break;case"project":g({a:"toggle",overlay:{kind:"projects",form:"center"}});break;case"quick-open":((T=m.overlay)==null?void 0:T.kind)==="quick-open"?g({a:"close"}):m.activeId&&g({a:"open",overlay:{kind:"quick-open"}});break;case"routes":((N=m.overlay)==null?void 0:N.kind)==="routes"?g({a:"close"}):Df(m)&&g({a:"open",overlay:{kind:"routes"}});break;case"reload":{const $=bg(m);if(!$)break;$.act==="frame"?un.post($.id,{type:"reload"}):t==null||t.send({t:"preview-start",worktreeId:$.id});break}case"back":case"forward":{const $=kl(m);$&&un.post($,{type:y.id});break}case"pick":case"inspect":{const $=kl(m);$&&eu($,m.picking,g,y.id==="pick"?"chat":"code");break}case"search":m.activeId&&g({a:"toggle",overlay:{kind:"search"}});break;case"refs":m.activeRepoId&&g({a:"toggle",overlay:{kind:"refs"}});break;case"chats":m.activeRepoId&&g({a:"toggle",overlay:{kind:"chats"}});break;case"commands":g({a:"toggle",overlay:{kind:"commands"}});break;case"zen":g({a:"toggle-zen"});break;case"close":!(m.zen&&!Do(m))&&!m.overlay&&c();break;case"changes":g(m.layout.changes&&(Ol(m)==="changes"||No(m)!==null)?{a:"toggle-changes"}:{a:"focus-changes",tab:"changes"});break;case"files":g(m.layout.changes&&Ol(m)==="files"?{a:"toggle-changes"}:{a:"focus-changes",tab:"files"});break;case"panel-tab-prev":case"panel-tab-next":if(vh(m))break;g(m.layout.changes?{a:"focus-changes",tab:y4(m,y.id==="panel-tab-next"?1:-1)}:{a:"focus-changes"});break;case"composer":g(NS(m));break;case"rail":g(m.railOpen?{a:"toggle-rail"}:{a:"focus-rail"});break;case"keys":g({a:"toggle",overlay:{kind:"keys"}});break;case"terminal":g(m.layout.term?{a:"toggle-terminal"}:{a:"focus-terminal"});break;case"design":g({a:"toggle-design"});break;case"term-tab":{const $=m.rows.find(R=>R.id===m.activeId);if(!$)break;const O=fo(m,m.activeId).termStream;if($.login&&O===Rs)break;const I=[Po,...$.login?[Rs]:[],...$.procs.map(R=>R.name)],P=I.indexOf(O);g({a:"term-stream",id:$.id,stream:I[(P+1)%I.length]??Po});break}}}else if(f.key==="Escape")if(m.newProject)m.newProject.phase==="editing"&&g({a:"close-new-project"});else if(m.picking){const j=kl(m);j&&un.post(j,{type:"pick-cancel"}),g({a:"set-picking",v:!1})}else m.notesPage?g({a:"close-release-notes"}):m.archivedPage?g({a:"close-archived"}):m.activeImportId?g({a:"watch-import",id:null}):c()}};return window.addEventListener("keydown",u,!0),window.addEventListener("keydown",h),window.addEventListener("keyup",i),window.addEventListener("pointermove",l),window.addEventListener("pointerdown",l),window.addEventListener("blur",r),()=>{window.removeEventListener("keydown",u,!0),window.removeEventListener("keydown",h),window.removeEventListener("keyup",i),window.removeEventListener("pointermove",l),window.removeEventListener("pointerdown",l),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&&un.post(o.activeId,{type:"pick-mods",alt:r.altKey,shift:r.shiftKey})};return window.addEventListener("keydown",n),window.addEventListener("keyup",n),()=>{window.removeEventListener("keydown",n),window.removeEventListener("keyup",n)}},[e])}const rq=3,oq=2e3,sq=200,iq=5e3;function aq(){const e=ct(),t=rt(),n=mo(),{storage:r}=n,o=Hl(),i=L(W=>W.activeRepoId),l=Ps(),c=cw(),u=L(W=>W.connected),h=L(W=>W.daylight),f=L(W=>{var ye;return((ye=W.daylight)==null?void 0:ye.until)??0}),m=_a(),g=L(W=>W.notesPage),w=L(W=>W.version),y=L(W=>W.railOpen),v=L(W=>W.chatSide),_=L(W=>W.layouts),x=L(W=>W.lastActive),T=L(W=>W.discoveredOpen),N=L(W=>W.archivedOpen),j=L(W=>W.committedShut),$=L(W=>W.turnOpen),O=L(W=>W.treeOpen),I=Eh(),P=L(W=>W.previewTheme!==null),R=L(W=>W.openUrl),U=s_();S.useEffect(()=>Pl.install(window),[]);const F=S.useRef([]),B=S.useCallback(W=>t==null?void 0:t.send({t:"subscribe",worktreeId:W,since:n.since(W)}),[t,n]);S.useEffect(()=>{if(!t||!u||!o)return;const W=[o,...F.current.filter(ye=>ye!==o)];for(const ye of W.splice(rq))t.send({t:"unsubscribe",worktreeId:ye});F.current.includes(o)||B(o),F.current=W},[o,u,t,B]),S.useEffect(()=>{if(!(!t||!u))for(const W of F.current)B(W)},[u,t,B]);const X=S.useRef(void 0);S.useEffect(()=>{if(!t||!u)return;let W;const ye=()=>{const ce=document.visibilityState==="visible"?o:null;t.send({t:"view",worktreeId:ce}),X.current=ce},_e=()=>{clearTimeout(W),W=setTimeout(ye,sq)};X.current===void 0||X.current===o||document.visibilityState!=="visible"?ye():_e();const ve=()=>document.visibilityState==="visible"?_e():ye();return document.addEventListener("visibilitychange",ve),()=>{clearTimeout(W),document.removeEventListener("visibilitychange",ve)}},[o,u,t]);const ae=(m==null?void 0:m.id)??null;S.useEffect(()=>{if(!(!t||!u||!ae))return B(ae),()=>t.send({t:"unsubscribe",worktreeId:ae})},[ae,u,t,B]),S.useEffect(()=>{const W=new Set(U.map(_e=>_e.id)),ye=F.current.filter(_e=>!W.has(_e));if(ye.length!==0&&(F.current=F.current.filter(_e=>W.has(_e)),!(!t||!u)))for(const _e of ye)t.send({t:"unsubscribe",worktreeId:_e})},[U,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 ne=!!(l!=null&&l.unseen),C=L(W=>W.unreadHold!==null&&W.unreadHold===W.activeId);S.useEffect(()=>{if(!t||!o||!ne||C)return;let W;const ye=()=>document.visibilityState==="visible"&&document.hasFocus(),_e=()=>{clearTimeout(W),ye()&&(W=setTimeout(()=>{ye()&&t.send({t:"seen",worktreeId:o})},oq))},ve=()=>clearTimeout(W);return _e(),window.addEventListener("focus",_e),window.addEventListener("blur",ve),()=>{ve(),window.removeEventListener("focus",_e),window.removeEventListener("blur",ve)}},[t,o,ne,C]);const H=S.useRef(0),V=L(W=>ew(W));S.useEffect(()=>{if(!t||!u||!i)return;const W=()=>{Date.now()-H.current<iq||(H.current=Date.now(),t.send({t:"refresh-git",repoId:i}),V&&V!==i&&t.send({t:"refresh-git",repoId:V}))};return window.addEventListener("focus",W),()=>window.removeEventListener("focus",W)},[t,u,i,V]);const J=L(W=>W.frame==="phone"&&W.screen==="home"?"surface1":"surface0");S.useEffect(()=>{try{sessionStorage.setItem(Ke.ground,J)}catch{}},[J]);const Z=L(W=>W.frame==="phone"),ie=L(W=>W.blackGround),be=S.useMemo(()=>Z&&ie?FP(I):I,[Z,ie,I]);S.useEffect(()=>{try{localStorage.setItem(Ke.blackGround,ie?"1":"0")}catch{}},[ie]),S.useEffect(()=>{o$(be,{remember:!P,ground:J,black:be!==I}),un.broadcast(s$(be))},[be,I,P,J]);const ge=S.useCallback(()=>{t==null||t.send({t:"zone",tz:Intl.DateTimeFormat().resolvedOptions().timeZone})},[t]);S.useEffect(()=>{if(!u)return;ge();const W=()=>{document.visibilityState==="visible"&&ge()};return document.addEventListener("visibilitychange",W),()=>document.removeEventListener("visibilitychange",W)},[u,ge]),S.useEffect(()=>{if(!u||f<=Date.now())return;const W=setTimeout(ge,f-Date.now()+1e3);return()=>clearTimeout(W)},[u,f,ge]),S.useEffect(()=>{h&&h.until>0&&IK(h)},[h]),S.useEffect(()=>{o&&r.set(Ke.active,o)},[o,r]),S.useEffect(()=>{w&&r.set(Ke.version,w)},[w,r]);const we=L(W=>W.frame==="phone"?W.screen!=="home":null);S.useEffect(()=>{we!==null&&r.session.set(Ke.phoneRow,we?"1":"0")},[we,r]),S.useEffect(()=>{i&&r.set(Ke.repo,i)},[i,r]),S.useEffect(()=>{try{localStorage.setItem(Ke.rail,y?"1":"0")}catch{}},[y]),S.useEffect(()=>{try{localStorage.setItem(Ke.chatSide,v)}catch{}},[v]),S.useEffect(()=>{try{localStorage.setItem(Ke.layouts,JSON.stringify(_))}catch{}},[_]),S.useEffect(()=>{r.set(Ke.lastActive,JSON.stringify(x))},[x,r]),S.useEffect(()=>{r.set(Ke.discoveredOpen,JSON.stringify(T))},[T,r]),S.useEffect(()=>{r.set(Ke.archivedOpen,JSON.stringify(N))},[N,r]),S.useEffect(()=>{r.set(Ke.committedShut,JSON.stringify(j))},[j,r]),S.useEffect(()=>{r.set(Ke.turnOpen,JSON.stringify($))},[$,r]),S.useEffect(()=>{r.set(Ke.treeOpen,JSON.stringify(O))},[O,r]),nq(),Fz();const pe=S.useRef(null);return S.useEffect(()=>{!R||pe.current===R||(pe.current=R,window.open(R,"_blank"),e({a:"opened-url"}))},[R,e]),L(W=>W.frame)==="phone"?d.jsx(NK,{}):d.jsx(XZ,{})}function lq({origin:e,machine:t,onToken:n}){const[r,o]=S.useState({kind:"asking"}),[i,l]=S.useState(0);return ft([i],()=>{const c=new AbortController;return o({kind:"asking"}),aS(e,c.signal,u=>o({kind:"waiting",word:u})).then(u=>{if(!c.signal.aborted){if(typeof u=="string"){o({kind:"failed",failure:u});return}o({kind:"in"}),n(u.token)}}),()=>c.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.":Yj(r.failure,e,"this device")}),r.kind==="failed"&&d.jsx("div",{className:"status-actions",children:d.jsx(De,{variant:"outline",onClick:()=>l(c=>c+1),children:"ask again"})})]})}const og="toyon-shared",cq="x-toyon-name";async function uq(e=globalThis.caches){var t;try{if(!e||!await e.has(og))return[];const n=await e.open(og),r=[];for(const o of await n.keys()){const i=await n.match(o);if(!i)continue;const l=decodeURIComponent(i.headers.get(cq)??"")||"shared",c=((t=(i.headers.get("content-type")??"").split(";")[0])==null?void 0:t.trim())??"";r.push(new File([await i.blob()],l,{type:c}))}return await e.delete(og),r}catch{return[]}}function z1(e,t=()=>!0){const n=()=>t()?Ta(e):null;return new Promise(r=>{const o=n();if(o)return r(o);const i=e.subscribe(()=>{const l=n();l&&(i(),r(l))})})}function dq(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 fq(e,t){const n=await uq(t);if(n.length===0)return;if(e.getState().frame!=="phone"){zf(e,await z1(e),n);return}e.dispatch({a:"screen",to:"home"}),e.dispatch({a:"sharing",v:dq(n)});const r=await z1(e,()=>e.getState().screen!=="home");e.dispatch({a:"sharing",v:null}),zf(e,r,n)}function hq(){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(_C(t.worktreeId,t.stream))??[])n(t)}}}const pq=2e3,mq=1500;function gq(e,t,n,r={}){const o=r.timers??{set:(O,I)=>setTimeout(O,I),clear:O=>clearTimeout(O)},i=r.now??(()=>Date.now()),l=r.win??(typeof window>"u"?null:window),c=new Map,u=O=>{let I=c.get(O);return I||(I=new a4,c.set(O,I)),I},h=new Map,f=new Map,m=O=>{var U;o.clear(f.get(O)),f.delete(O);const I=e.getState();if(O===""){if(!I.heard)return;const F=e4(I,i());if(!F)return;const B=i4(Object.fromEntries([...h].map(([X,ae])=>[X,{at:ae}])),I.rows);for(const X of B)h.delete(X),c.delete(X);t.putHello(n,F).then(()=>B.length?t.dropChats(n,B):void 0);return}const P=c.get(O);if(!P||!I.rows.some(F=>F.id===O))return;const R=i();h.set(O,R),t.putChat(n,O,P.snapshot((U=I.local[O])==null?void 0:U.draft,R))},g=O=>{f.has(O)||f.set(O,o.set(()=>m(O),pq))},w=()=>{for(const O of[...f.keys()])m(O)};let y=e.getState();const v=new Map,_=e.subscribe(()=>{var I;const O=e.getState();if(O.heard&&(!y.heard||O.rows!==y.rows||O.repos!==y.repos||O.trunks!==y.trunks||O.handed!==y.handed||O.visits!==y.visits)&&g(""),O.local!==y.local)for(const P of c.keys()){const R=((I=O.local[P])==null?void 0:I.draft)??"";(v.get(P)??"")!==R&&(v.set(P,R),g(P))}y=O}),x=()=>{var O;((O=l==null?void 0:l.document)==null?void 0:O.visibilityState)==="hidden"&&w()};l==null||l.addEventListener("visibilitychange",x),l==null||l.addEventListener("pagehide",w);const T=Promise.all([t.hello(n),t.chats(n)]);let N;const j=new Promise(O=>{N=o.set(()=>O(null),mq)});return{recalled:Promise.race([T,j]).then(O=>{if(o.clear(N),!O)return;const[I,P]=O;for(const[U,F]of Object.entries(P))h.set(U,F.at);if(!I||!bb(I)||e.getState().heard)return;const R={};for(const[U,F]of Object.entries(P))bb(F)&&(R[U]=F);try{e.dispatch({a:"recall",hello:I,chats:R})}catch(U){console.error("the last-known machine could not be recalled; dropping it",U),h.clear(),t.clear(n);return}for(const[U,F]of Object.entries(R))u(U).reset(F.events,F.seq,!1),v.set(U,F.draft??"")}).catch(O=>{console.error("the last-known machine could not be read",O)}),hear(O){var I;if(O.t==="backfill"){const P=u(O.worktreeId);g(O.worktreeId);const R=(((I=e.getState().local[O.worktreeId])==null?void 0:I.chat.length)??0)>0;if(O.after!==void 0&&O.after===P.since()&&R)return P.extend(O.events,O.last),O;if(P.reset(O.events,O.last,O.after===void 0),O.after===void 0)return O;const{after:U,...F}=O;return F}return O.t==="agent"&&(u(O.worktreeId).add(O.seq,O.event),g(O.worktreeId)),O},since:O=>{var I;return(I=c.get(O))==null?void 0:I.since()},forget(){for(const O of[...f.keys()])o.clear(f.get(O)),f.delete(O);c.clear(),h.clear(),t.clear(n)},dispose(){_(),l==null||l.removeEventListener("visibilitychange",x),l==null||l.removeEventListener("pagehide",w),w()}}}function kq(){const e=new Map,t=n=>{const r=ao.chats(n),o={};for(const[i,l]of e)i.startsWith(r)&&(o[i.slice(r.length)]=l);return o};return{hello:async n=>e.get(ao.hello(n))??null,putHello:async(n,r)=>void e.set(ao.hello(n),r),chats:async n=>t(n),putChat:async(n,r,o)=>void e.set(ao.chat(n,r),o),dropChats:async(n,r)=>{for(const o of r)e.delete(ao.chat(n,o))},clear:async n=>{e.delete(ao.hello(n));for(const r of[...e.keys()])r.startsWith(ao.chats(n))&&e.delete(r)}}}function h$(){if(typeof indexedDB>"u")return kq();let e=null;const t=()=>(e??(e=new Promise((i,l)=>{const c=indexedDB.open(rL,1);c.onupgradeneeded=()=>c.result.createObjectStore(_c),c.onsuccess=()=>i(c.result),c.onerror=()=>l(c.error),c.onblocked=()=>l(new Error("blocked"))}).catch(i=>{throw e=null,i})),e),n=async(i,l)=>{const c=(await t()).transaction(_c,i).objectStore(_c);return new Promise((u,h)=>{const f=l(c);f.onsuccess=()=>u(f.result),f.onerror=()=>h(f.error)})},r=i=>{const l=ao.chats(i);return IDBKeyRange.bound(l,`${l}￿`)},o=async(i,l)=>{try{return await i}catch{return l}};return{hello:i=>o(n("readonly",l=>l.get(ao.hello(i))),void 0).then(l=>l??null),putHello:(i,l)=>o(n("readwrite",c=>c.put(l,ao.hello(i))),void 0).then(()=>{}),chats:async i=>{const l=ao.chats(i),[c,u]=await o((async()=>{const f=(await t()).transaction(_c,"readonly").objectStore(_c),m=g=>new Promise((w,y)=>{g.onsuccess=()=>w(g.result),g.onerror=()=>y(g.error)});return Promise.all([m(f.getAllKeys(r(i))),m(f.getAll(r(i)))])})(),[[],[]]),h={};return c.forEach((f,m)=>{const g=u[m];typeof f=="string"&&g&&(h[f.slice(l.length)]=g)}),h},putChat:(i,l,c)=>o(n("readwrite",u=>u.put(c,ao.chat(i,l))),void 0).then(()=>{}),dropChats:async(i,l)=>{for(const c of l)await o(n("readwrite",u=>u.delete(ao.chat(i,c))),void 0)},clear:async i=>{await o(n("readwrite",l=>l.delete(ao.hello(i))),void 0),await o(n("readwrite",l=>l.delete(r(i))),void 0)}}}function wq(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 yq(e){const t={};try{const n=JSON.parse(e??"{}");if(!n||typeof n!="object")return t;for(const[r,o]of Object.entries(n))u4(o)&&(t[r]=o)}catch{}return t}function vq(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 uf(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 bq(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(i=>typeof i=="string")&&o.length>0&&(t[r]=o)}catch{}return t}const xq=400,Eq=2e3;function p$(){const e=new Map;return{another(t,n=0){return(e.get(t)??0)===n?!1:(e.set(t,n),!0)}}}function m$(e,t,n){const r=e.getState(),o=[];for(const[i,l]of t){if(l===n||r.local[i])continue;const c=ms(i);c&&c.clientId!==r.clientId||o.push(i)}return o}function Sq(e,t){const n=new Map,r=new Map,o=p$(),i=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}))},l=()=>{for(const u of[...r.keys()])i(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){i(m);continue}const w=r.get(m);if((w==null?void 0:w.text)===g.draft)continue;clearTimeout(w==null?void 0:w.timer);const y=(w==null?void 0:w.since)??Date.now(),v=Math.max(0,Math.min(xq,y+Eq-Date.now()));r.set(m,{text:g.draft,timer:setTimeout(i,v,m),since:y})}for(const m of m$(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",l),window.addEventListener("pagehide",l),{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",l),window.removeEventListener("pagehide",l)}}}function _q(e,t){const n=new Map,r=new Map,o=p$(),i=e.subscribe(()=>{const l=[];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=Xk(u.attachments),f=JSON.stringify(h),m=r.get(c)??"[]";m!==f&&(r.set(c,f),l.push({id:c,items:h,before:yS(JSON.parse(m))}))}for(const c of m$(e,r,"[]"))r.set(c,"[]"),l.push({id:c,items:[],before:[]});for(const c of QL(l))t.send({t:"set-attachments",boxId:c.id,items:c.items,clientId:e.getState().clientId})});return{hello(l){r.clear(),n.clear();for(const[c,u]of Object.entries(l))r.set(c,JSON.stringify(u))},heard(l,c){r.set(l,JSON.stringify(c))},dispose:i}}function Nq(e,t){return e.subscribe(()=>{for(const n of XL(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(Mc(o.outgoing.frame,n,o.draft,o.attachments)),e.dispatch({a:"sent-out",id:n}))}})}const F1="not sent: the page reloaded while an upload was on its way; attach it again and send";function B1(e,t,n){var l;const r=e.getState(),o=new Set([...Object.keys(n.drafts),...Object.keys(n.attachments)]),i=[];for(const c of o){const u=ms(c);if((u==null?void 0:u.clientId)!==r.clientId||(l=r.local[c])!=null&&l.outgoing)continue;const h=n.drafts[c]??"",f=n.attachments[c]??[],m=n.drafts[u.source]??"",g=[...f,...n.attachments[u.source]??[]],w=m||h,y=r.clientId;g.length&&t.send({t:"set-attachments",boxId:u.source,items:g,clientId:y}),w!==m&&t.send({t:"set-draft",boxId:u.source,text:w,clientId:y}),t.send({t:"set-attachments",boxId:c,items:[],clientId:y}),t.send({t:"set-draft",boxId:c,text:"",clientId:y}),delete n.drafts[c],delete n.attachments[c],w&&(n.drafts[u.source]=w),g.length&&(n.attachments[u.source]=g),i.push(u.source)}return i}function Tq(e,t){const n=(t.storage??oL)(e.origin),r=V4(f4({cached:t.cached,systemDark:t.systemDark,daylight:t.daylight,storedActive:n.get(Ke.active),storedPhoneRow:n.session.get(Ke.phoneRow)==="1",storedRepo:n.get(Ke.repo),storedVersion:n.get(Ke.version),storedRailOpen:df(Ke.rail)==="1",storedChatSide:df(Ke.chatSide)==="right"?"right":"left",storedBlackGround:df(Ke.blackGround)==="1",storedLayouts:yq(df(Ke.layouts)),storedLastActive:vq(n.get(Ke.lastActive)),storedDiscoveredOpen:uf(n.get(Ke.discoveredOpen)),storedArchivedOpen:uf(n.get(Ke.archivedOpen)),storedCommittedShut:uf(n.get(Ke.committedShut)),storedTurnOpen:uf(n.get(Ke.turnOpen)),storedTreeOpen:bq(n.get(Ke.treeOpen)),clientId:t.clientId,frame:t.frame,touch:t.touch})),o=hq(),i={version:null,protocol:null},l=u8(v=>r.dispatch({a:"server",msg:v}));let c,u,h;const f=gq(r,t.snapshots??h$(),e.origin);let m=[];const g=new SL(e,v=>{if(v.t==="hello"){if(i.protocol=v.protocol,e.serving){const{rebuilt:x,update:T}=r.getState(),N=x&&(T==null?void 0:T.restarting)!=null;if(i.version!==null&&(N||v.version!==i.version||v.protocol!==ua)){g.dispose(),t.reload();return}if(v.protocol!==ua){r.dispatch({a:"incompatible"}),g.dispose();return}}else if(v.protocol!==ua){r.dispatch({a:"incompatible"}),g.suspend();return}else r.getState().incompatible&&r.dispatch({a:"incompatible",v:!1});i.version=v.version;const _=new Set(g.sentWhileDown());if(_.size){const x=T=>Object.fromEntries(Object.entries(T).filter(([N])=>!_.has(N)));v.drafts=x(v.drafts),v.attachments=x(v.attachments)}m=B1(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(ZM(v)){o.deliver(v);return}if(qM(v)){if(v.t==="file-written"&&YD(v))return;h.receive(v);return}if(v.t==="loose-written"){fH(v);return}if(o6(v)){l6(r,g,v);return}if(v.t==="open-refused"){a6(r,v);return}l(f.hear(v));for(const _ of m.splice(0))r.dispatch({a:"notice",id:_,text:F1})}},(v,_)=>r.dispatch({a:"connected",v,failure:_}),{},{known:()=>U4(r.getState()),held:e.serving});ez(r,g.urls),h=new uH({store:r,send:v=>g.send(v),timers:{set:(v,_)=>setTimeout(v,_),clear:v=>clearTimeout(v)},win:window});const w=h.start();c=Sq(r,g),u=_q(r,g);const y=Nq(r,g);return{origin:e.origin,serving:e.serving,token:e.token,get name(){return r.getState().machine??wq(e.origin)},store:r,sock:g,files:h,terminals:o,storage:n,heard:i,recalled:f.recalled,forget:()=>f.forget(),boot(v){try{if((v==null?void 0:v.t)==="hello"&&v.protocol===ua){i.version??(i.version=v.version);const _=B1(r,g,v);u.hello(v.attachments),r.dispatch({a:"server",msg:v});for(const x of _)r.dispatch({a:"notice",id:x,text:F1})}}finally{g.resume()}},since:v=>{var _;return(_=r.getState().local[v])!=null&&_.chat.length?f.since(v):void 0},dispose(){g.dispose(),w(),c.dispose(),u.dispose(),y(),f.dispose()}}}function df(e){try{return localStorage.getItem(e)}catch{return null}}window.__toyonShell=!0;const g$=F_();g$&&(document.documentElement.dataset.framed="");iL(location.origin);const k$=TK();o$(k$);function jq(e,t){try{return e.getItem(t)}catch{return null}}function $q(){const e=jq(sessionStorage,Ke.client);if(e)return e;const t=Math.random().toString(36).slice(2,10);try{sessionStorage.setItem(Ke.client,t)}catch{}return t}const Cq={cached:k$,systemDark:$K(),daylight:AK(),clientId:$q(),frame:Ew(),touch:Wz(),reload:()=>window.location.reload(),snapshots:h$()},ks=OW({serving:{origin:location.origin,token:tS()},build:e=>Tq(e,Cq)});Kz({dispatch:e=>ks.broadcast(e)});RK(e=>ks.broadcast({a:"system-dark",v:e}));const w$=e=>g$?()=>{}:vK(e);let U1=w$(ks.active().store),H1=ks.active();ks.subscribe(()=>{const e=ks.active();e!==H1&&(H1=e,U1(),e.store.getState().frame==="phone"&&e.store.dispatch({a:"screen",to:"home"}),U1=w$(e.store))});window.addEventListener("vite:preloadError",O3);const Aq=Promise.all([(window.toyonBoot??Promise.resolve(null)).then(e=>{const t=e;ks.active().boot(t&&typeof t=="object"&&t.t==="hello"?t:null)}),ks.active().recalled]).catch(e=>{console.error("boot",e)});function Iq(e){nS(e),window.location.reload()}const Rq=vC.createRoot(document.getElementById("root"));Aq.then(()=>{var e;Z1.flushSync(()=>Rq.render(d.jsx(mC.StrictMode,{children:d.jsx(Sw,{children:Of()?d.jsx(X4,{machines:ks,children:d.jsx(aq,{})}):d.jsx(lq,{origin:location.origin,machine:location.host,onToken:Iq})})}))),document.documentElement.style.removeProperty("background"),document.documentElement.style.removeProperty("--boot-ink"),(e=document.getElementById("boot"))==null||e.remove(),Of()&&fq(ks.active().store)});"serviceWorker"in navigator&&navigator.serviceWorker.register("/sw.js").catch(()=>{});export{Ls as F,dk as _,ur as a,zk as b,Dq as c,ft as d,Fq as e,Pq as f,tE as g,GP as h,_C as i,d as j,W5 as k,Iw as l,eE as m,Mq as n,Lq as p,S as r,BP as s,wu as t,zq as u,hb as w};