toyon 0.11.0 → 0.13.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 (32) hide show
  1. package/README.md +1 -1
  2. package/dist/bridge.js +1 -1
  3. package/dist/cli.js +481 -2129
  4. package/dist/daemon.js +3384 -1769
  5. package/dist/helper-stub +0 -0
  6. package/dist/shell/assets/{Editor-Cs_OeWSx.js → Editor-CUcgZuoM.js} +3 -3
  7. package/dist/shell/assets/{XTerm-Dc6Bk52B.js → XTerm-V6sBDIe-.js} +1 -1
  8. package/dist/shell/assets/{cssMode-D8uDYrHJ.js → cssMode-CSyiAvIn.js} +1 -1
  9. package/dist/shell/assets/{freemarker2-DlU9uDzS.js → freemarker2-C4-FNK3V.js} +1 -1
  10. package/dist/shell/assets/{grammar-BSzyJU-q.js → grammar-DzHb7e7O.js} +1 -1
  11. package/dist/shell/assets/{handlebars-B66kGi_7.js → handlebars-DcjVaOCM.js} +1 -1
  12. package/dist/shell/assets/{html-D6juOeyd.js → html-Csl8cogA.js} +1 -1
  13. package/dist/shell/assets/{htmlMode-CbTT-4ZV.js → htmlMode-rewe9UaO.js} +1 -1
  14. package/dist/shell/assets/index-Bkn7zNFw.js +267 -0
  15. package/dist/shell/assets/index-iVaPr_If.css +1 -0
  16. package/dist/shell/assets/{javascript-CHwG4FvH.js → javascript--pKV-E-G.js} +1 -1
  17. package/dist/shell/assets/{jsonMode-DzTEiaKX.js → jsonMode-zPVc0E6l.js} +1 -1
  18. package/dist/shell/assets/{liquid-wddZX4zw.js → liquid-jZT5xQG-.js} +1 -1
  19. package/dist/shell/assets/{lspLanguageFeatures-BlqDZ6dO.js → lspLanguageFeatures-BuiqKs90.js} +1 -1
  20. package/dist/shell/assets/{mdx-Dlz2LIv9.js → mdx-DwnR-ia2.js} +1 -1
  21. package/dist/shell/assets/{python-DvkArqZY.js → python-DU3pl9Zu.js} +1 -1
  22. package/dist/shell/assets/{razor-bDLQ0jQf.js → razor-BzVUPqHs.js} +1 -1
  23. package/dist/shell/assets/{tsMode-B_NomV_y.js → tsMode-ONmZhHHZ.js} +1 -1
  24. package/dist/shell/assets/{xml-CBYJrQiV.js → xml-BXW7X3BT.js} +1 -1
  25. package/dist/shell/assets/{yaml-DnmVK8S2.js → yaml-DFE79ex1.js} +1 -1
  26. package/dist/shell/index.html +20 -37
  27. package/dist/shell/manifest.json +1 -1
  28. package/dist/shell/offline.html +219 -0
  29. package/dist/shell/sw.js +32 -3
  30. package/package.json +1 -1
  31. package/dist/shell/assets/index-B4KJ--q9.css +0 -1
  32. package/dist/shell/assets/index-Cj-6Xixu.js +0 -268
@@ -0,0 +1,267 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/Editor-CUcgZuoM.js","assets/grammar-DzHb7e7O.js","assets/Editor-CB2SckMT.css","assets/XTerm-V6sBDIe-.js","assets/XTerm-6GBZ9nXN.css"])))=>i.map(i=>d[i]);
2
+ var vj=Object.defineProperty;var bj=(e,t,n)=>t in e?vj(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Dt=(e,t,n)=>bj(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 Ux(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var vp={exports:{}},Zl={},bp={exports:{}},qt={};/**
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 uv;function xj(){if(uv)return qt;uv=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"),p=Symbol.for("react.lazy"),m=Symbol.iterator;function g(H){return H===null||typeof H!="object"?null:(H=m&&H[m]||H["@@iterator"],typeof H=="function"?H:null)}var y={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},w=Object.assign,b={};function E(H,se,ie){this.props=H,this.context=se,this.refs=b,this.updater=ie||y}E.prototype.isReactComponent={},E.prototype.setState=function(H,se){if(typeof H!="object"&&typeof H!="function"&&H!=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,H,se,"setState")},E.prototype.forceUpdate=function(H){this.updater.enqueueForceUpdate(this,H,"forceUpdate")};function _(){}_.prototype=E.prototype;function N(H,se,ie){this.props=H,this.context=se,this.refs=b,this.updater=ie||y}var T=N.prototype=new _;T.constructor=N,w(T,E.prototype),T.isPureReactComponent=!0;var R=Array.isArray,O=Object.prototype.hasOwnProperty,B={current:null},$={key:!0,ref:!0,__self:!0,__source:!0};function C(H,se,ie){var he,ge={},Ie=null,ke=null;if(se!=null)for(he in se.ref!==void 0&&(ke=se.ref),se.key!==void 0&&(Ie=""+se.key),se)O.call(se,he)&&!$.hasOwnProperty(he)&&(ge[he]=se[he]);var Q=arguments.length-2;if(Q===1)ge.children=ie;else if(1<Q){for(var we=Array(Q),te=0;te<Q;te++)we[te]=arguments[te+2];ge.children=we}if(H&&H.defaultProps)for(he in Q=H.defaultProps,Q)ge[he]===void 0&&(ge[he]=Q[he]);return{$$typeof:e,type:H,key:Ie,ref:ke,props:ge,_owner:B.current}}function j(H,se){return{$$typeof:e,type:H.type,key:se,ref:H.ref,props:H.props,_owner:H._owner}}function D(H){return typeof H=="object"&&H!==null&&H.$$typeof===e}function z(H){var se={"=":"=0",":":"=2"};return"$"+H.replace(/[=:]/g,function(ie){return se[ie]})}var X=/\/+/g;function ae(H,se){return typeof H=="object"&&H!==null&&H.key!=null?z(""+H.key):se.toString(36)}function A(H,se,ie,he,ge){var Ie=typeof H;(Ie==="undefined"||Ie==="boolean")&&(H=null);var ke=!1;if(H===null)ke=!0;else switch(Ie){case"string":case"number":ke=!0;break;case"object":switch(H.$$typeof){case e:case t:ke=!0}}if(ke)return ke=H,ge=ge(ke),H=he===""?"."+ae(ke,0):he,R(ge)?(ie="",H!=null&&(ie=H.replace(X,"$&/")+"/"),A(ge,se,ie,"",function(te){return te})):ge!=null&&(D(ge)&&(ge=j(ge,ie+(!ge.key||ke&&ke.key===ge.key?"":(""+ge.key).replace(X,"$&/")+"/")+H)),se.push(ge)),1;if(ke=0,he=he===""?".":he+":",R(H))for(var Q=0;Q<H.length;Q++){Ie=H[Q];var we=he+ae(Ie,Q);ke+=A(Ie,se,ie,we,ge)}else if(we=g(H),typeof we=="function")for(H=we.call(H),Q=0;!(Ie=H.next()).done;)Ie=Ie.value,we=he+ae(Ie,Q++),ke+=A(Ie,se,ie,we,ge);else if(Ie==="object")throw se=String(H),Error("Objects are not valid as a React child (found: "+(se==="[object Object]"?"object with keys {"+Object.keys(H).join(", ")+"}":se)+"). If you meant to render a collection of children, use an array instead.");return ke}function de(H,se,ie){if(H==null)return H;var he=[],ge=0;return A(H,he,"","",function(Ie){return se.call(ie,Ie,ge++)}),he}function ue(H){if(H._status===-1){var se=H._result;se=se(),se.then(function(ie){(H._status===0||H._status===-1)&&(H._status=1,H._result=ie)},function(ie){(H._status===0||H._status===-1)&&(H._status=2,H._result=ie)}),H._status===-1&&(H._status=0,H._result=se)}if(H._status===1)return H._result.default;throw H._result}var J={current:null},M={transition:null},oe={ReactCurrentDispatcher:J,ReactCurrentBatchConfig:M,ReactCurrentOwner:B};function ne(){throw Error("act(...) is not supported in production builds of React.")}return qt.Children={map:de,forEach:function(H,se,ie){de(H,function(){se.apply(this,arguments)},ie)},count:function(H){var se=0;return de(H,function(){se++}),se},toArray:function(H){return de(H,function(se){return se})||[]},only:function(H){if(!D(H))throw Error("React.Children.only expected to receive a single React element child.");return H}},qt.Component=E,qt.Fragment=n,qt.Profiler=o,qt.PureComponent=N,qt.StrictMode=r,qt.Suspense=u,qt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=oe,qt.act=ne,qt.cloneElement=function(H,se,ie){if(H==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+H+".");var he=w({},H.props),ge=H.key,Ie=H.ref,ke=H._owner;if(se!=null){if(se.ref!==void 0&&(Ie=se.ref,ke=B.current),se.key!==void 0&&(ge=""+se.key),H.type&&H.type.defaultProps)var Q=H.type.defaultProps;for(we in se)O.call(se,we)&&!$.hasOwnProperty(we)&&(he[we]=se[we]===void 0&&Q!==void 0?Q[we]:se[we])}var we=arguments.length-2;if(we===1)he.children=ie;else if(1<we){Q=Array(we);for(var te=0;te<we;te++)Q[te]=arguments[te+2];he.children=Q}return{$$typeof:e,type:H.type,key:ge,ref:Ie,props:he,_owner:ke}},qt.createContext=function(H){return H={$$typeof:l,_currentValue:H,_currentValue2:H,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},H.Provider={$$typeof:i,_context:H},H.Consumer=H},qt.createElement=C,qt.createFactory=function(H){var se=C.bind(null,H);return se.type=H,se},qt.createRef=function(){return{current:null}},qt.forwardRef=function(H){return{$$typeof:c,render:H}},qt.isValidElement=D,qt.lazy=function(H){return{$$typeof:p,_payload:{_status:-1,_result:H},_init:ue}},qt.memo=function(H,se){return{$$typeof:h,type:H,compare:se===void 0?null:se}},qt.startTransition=function(H){var se=M.transition;M.transition={};try{H()}finally{M.transition=se}},qt.unstable_act=ne,qt.useCallback=function(H,se){return J.current.useCallback(H,se)},qt.useContext=function(H){return J.current.useContext(H)},qt.useDebugValue=function(){},qt.useDeferredValue=function(H){return J.current.useDeferredValue(H)},qt.useEffect=function(H,se){return J.current.useEffect(H,se)},qt.useId=function(){return J.current.useId()},qt.useImperativeHandle=function(H,se,ie){return J.current.useImperativeHandle(H,se,ie)},qt.useInsertionEffect=function(H,se){return J.current.useInsertionEffect(H,se)},qt.useLayoutEffect=function(H,se){return J.current.useLayoutEffect(H,se)},qt.useMemo=function(H,se){return J.current.useMemo(H,se)},qt.useReducer=function(H,se,ie){return J.current.useReducer(H,se,ie)},qt.useRef=function(H){return J.current.useRef(H)},qt.useState=function(H){return J.current.useState(H)},qt.useSyncExternalStore=function(H,se,ie){return J.current.useSyncExternalStore(H,se,ie)},qt.useTransition=function(){return J.current.useTransition()},qt.version="18.3.1",qt}var dv;function pg(){return dv||(dv=1,bp.exports=xj()),bp.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 fv;function Ej(){if(fv)return Zl;fv=1;var e=pg(),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 p,m={},g=null,y=null;h!==void 0&&(g=""+h),u.key!==void 0&&(g=""+u.key),u.ref!==void 0&&(y=u.ref);for(p in u)r.call(u,p)&&!i.hasOwnProperty(p)&&(m[p]=u[p]);if(c&&c.defaultProps)for(p in u=c.defaultProps,u)m[p]===void 0&&(m[p]=u[p]);return{$$typeof:t,type:c,key:g,ref:y,props:m,_owner:o.current}}return Zl.Fragment=n,Zl.jsx=l,Zl.jsxs=l,Zl}var hv;function _j(){return hv||(hv=1,vp.exports=Ej()),vp.exports}var d=_j(),S=pg();const Sj=Ux(S);var xp={exports:{}},Yr={},Ep={exports:{}},_p={};/**
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 pv;function Nj(){return pv||(pv=1,(function(e){function t(M,oe){var ne=M.length;M.push(oe);e:for(;0<ne;){var H=ne-1>>>1,se=M[H];if(0<o(se,oe))M[H]=oe,M[ne]=se,ne=H;else break e}}function n(M){return M.length===0?null:M[0]}function r(M){if(M.length===0)return null;var oe=M[0],ne=M.pop();if(ne!==oe){M[0]=ne;e:for(var H=0,se=M.length,ie=se>>>1;H<ie;){var he=2*(H+1)-1,ge=M[he],Ie=he+1,ke=M[Ie];if(0>o(ge,ne))Ie<se&&0>o(ke,ge)?(M[H]=ke,M[Ie]=ne,H=Ie):(M[H]=ge,M[he]=ne,H=he);else if(Ie<se&&0>o(ke,ne))M[H]=ke,M[Ie]=ne,H=Ie;else break e}}return oe}function o(M,oe){var ne=M.sortIndex-oe.sortIndex;return ne!==0?ne:M.id-oe.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=[],p=1,m=null,g=3,y=!1,w=!1,b=!1,E=typeof setTimeout=="function"?setTimeout:null,_=typeof clearTimeout=="function"?clearTimeout:null,N=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function T(M){for(var oe=n(h);oe!==null;){if(oe.callback===null)r(h);else if(oe.startTime<=M)r(h),oe.sortIndex=oe.expirationTime,t(u,oe);else break;oe=n(h)}}function R(M){if(b=!1,T(M),!w)if(n(u)!==null)w=!0,ue(O);else{var oe=n(h);oe!==null&&J(R,oe.startTime-M)}}function O(M,oe){w=!1,b&&(b=!1,_(C),C=-1),y=!0;var ne=g;try{for(T(oe),m=n(u);m!==null&&(!(m.expirationTime>oe)||M&&!z());){var H=m.callback;if(typeof H=="function"){m.callback=null,g=m.priorityLevel;var se=H(m.expirationTime<=oe);oe=e.unstable_now(),typeof se=="function"?m.callback=se:m===n(u)&&r(u),T(oe)}else r(u);m=n(u)}if(m!==null)var ie=!0;else{var he=n(h);he!==null&&J(R,he.startTime-oe),ie=!1}return ie}finally{m=null,g=ne,y=!1}}var B=!1,$=null,C=-1,j=5,D=-1;function z(){return!(e.unstable_now()-D<j)}function X(){if($!==null){var M=e.unstable_now();D=M;var oe=!0;try{oe=$(!0,M)}finally{oe?ae():(B=!1,$=null)}}else B=!1}var ae;if(typeof N=="function")ae=function(){N(X)};else if(typeof MessageChannel<"u"){var A=new MessageChannel,de=A.port2;A.port1.onmessage=X,ae=function(){de.postMessage(null)}}else ae=function(){E(X,0)};function ue(M){$=M,B||(B=!0,ae())}function J(M,oe){C=E(function(){M(e.unstable_now())},oe)}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(M){M.callback=null},e.unstable_continueExecution=function(){w||y||(w=!0,ue(O))},e.unstable_forceFrameRate=function(M){0>M||125<M?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):j=0<M?Math.floor(1e3/M):5},e.unstable_getCurrentPriorityLevel=function(){return g},e.unstable_getFirstCallbackNode=function(){return n(u)},e.unstable_next=function(M){switch(g){case 1:case 2:case 3:var oe=3;break;default:oe=g}var ne=g;g=oe;try{return M()}finally{g=ne}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(M,oe){switch(M){case 1:case 2:case 3:case 4:case 5:break;default:M=3}var ne=g;g=M;try{return oe()}finally{g=ne}},e.unstable_scheduleCallback=function(M,oe,ne){var H=e.unstable_now();switch(typeof ne=="object"&&ne!==null?(ne=ne.delay,ne=typeof ne=="number"&&0<ne?H+ne:H):ne=H,M){case 1:var se=-1;break;case 2:se=250;break;case 5:se=1073741823;break;case 4:se=1e4;break;default:se=5e3}return se=ne+se,M={id:p++,callback:oe,priorityLevel:M,startTime:ne,expirationTime:se,sortIndex:-1},ne>H?(M.sortIndex=ne,t(h,M),n(u)===null&&M===n(h)&&(b?(_(C),C=-1):b=!0,J(R,ne-H))):(M.sortIndex=se,t(u,M),w||y||(w=!0,ue(O))),M},e.unstable_shouldYield=z,e.unstable_wrapCallback=function(M){var oe=g;return function(){var ne=g;g=oe;try{return M.apply(this,arguments)}finally{g=ne}}}})(_p)),_p}var mv;function Tj(){return mv||(mv=1,Ep.exports=Nj()),Ep.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 gv;function jj(){if(gv)return Yr;gv=1;var e=pg(),t=Tj();function n(s){for(var a="https://reactjs.org/docs/error-decoder.html?invariant="+s,f=1;f<arguments.length;f++)a+="&args[]="+encodeURIComponent(arguments[f]);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]*$/,p={},m={};function g(s){return u.call(m,s)?!0:u.call(p,s)?!1:h.test(s)?m[s]=!0:(p[s]=!0,!1)}function y(s,a,f,k){if(f!==null&&f.type===0)return!1;switch(typeof a){case"function":case"symbol":return!0;case"boolean":return k?!1:f!==null?!f.acceptsBooleans:(s=s.toLowerCase().slice(0,5),s!=="data-"&&s!=="aria-");default:return!1}}function w(s,a,f,k){if(a===null||typeof a>"u"||y(s,a,f,k))return!0;if(k)return!1;if(f!==null)switch(f.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 b(s,a,f,k,v,x,I){this.acceptsBooleans=a===2||a===3||a===4,this.attributeName=k,this.attributeNamespace=v,this.mustUseProperty=f,this.propertyName=s,this.type=a,this.sanitizeURL=x,this.removeEmptyString=I}var E={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(s){E[s]=new b(s,0,!1,s,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(s){var a=s[0];E[a]=new b(a,1,!1,s[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(s){E[s]=new b(s,2,!1,s.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(s){E[s]=new b(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){E[s]=new b(s,3,!1,s.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(s){E[s]=new b(s,3,!0,s,null,!1,!1)}),["capture","download"].forEach(function(s){E[s]=new b(s,4,!1,s,null,!1,!1)}),["cols","rows","size","span"].forEach(function(s){E[s]=new b(s,6,!1,s,null,!1,!1)}),["rowSpan","start"].forEach(function(s){E[s]=new b(s,5,!1,s.toLowerCase(),null,!1,!1)});var _=/[\-:]([a-z])/g;function N(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(_,N);E[a]=new b(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(_,N);E[a]=new b(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(_,N);E[a]=new b(a,1,!1,s,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(s){E[s]=new b(s,1,!1,s.toLowerCase(),null,!1,!1)}),E.xlinkHref=new b("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(s){E[s]=new b(s,1,!1,s.toLowerCase(),null,!0,!0)});function T(s,a,f,k){var v=E.hasOwnProperty(a)?E[a]:null;(v!==null?v.type!==0:k||!(2<a.length)||a[0]!=="o"&&a[0]!=="O"||a[1]!=="n"&&a[1]!=="N")&&(w(a,f,v,k)&&(f=null),k||v===null?g(a)&&(f===null?s.removeAttribute(a):s.setAttribute(a,""+f)):v.mustUseProperty?s[v.propertyName]=f===null?v.type===3?!1:"":f:(a=v.attributeName,k=v.attributeNamespace,f===null?s.removeAttribute(a):(v=v.type,f=v===3||v===4&&f===!0?"":""+f,k?s.setAttributeNS(k,a,f):s.setAttribute(a,f))))}var R=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,O=Symbol.for("react.element"),B=Symbol.for("react.portal"),$=Symbol.for("react.fragment"),C=Symbol.for("react.strict_mode"),j=Symbol.for("react.profiler"),D=Symbol.for("react.provider"),z=Symbol.for("react.context"),X=Symbol.for("react.forward_ref"),ae=Symbol.for("react.suspense"),A=Symbol.for("react.suspense_list"),de=Symbol.for("react.memo"),ue=Symbol.for("react.lazy"),J=Symbol.for("react.offscreen"),M=Symbol.iterator;function oe(s){return s===null||typeof s!="object"?null:(s=M&&s[M]||s["@@iterator"],typeof s=="function"?s:null)}var ne=Object.assign,H;function se(s){if(H===void 0)try{throw Error()}catch(f){var a=f.stack.trim().match(/\n( *(at )?)/);H=a&&a[1]||""}return`
35
+ `+H+s}var ie=!1;function he(s,a){if(!s||ie)return"";ie=!0;var f=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(fe){var k=fe}Reflect.construct(s,[],a)}else{try{a.call()}catch(fe){k=fe}s.call(a.prototype)}else{try{throw Error()}catch(fe){k=fe}s()}}catch(fe){if(fe&&k&&typeof fe.stack=="string"){for(var v=fe.stack.split(`
36
+ `),x=k.stack.split(`
37
+ `),I=v.length-1,U=x.length-1;1<=I&&0<=U&&v[I]!==x[U];)U--;for(;1<=I&&0<=U;I--,U--)if(v[I]!==x[U]){if(I!==1||U!==1)do if(I--,U--,0>U||v[I]!==x[U]){var Y=`
38
+ `+v[I].replace(" at new "," at ");return s.displayName&&Y.includes("<anonymous>")&&(Y=Y.replace("<anonymous>",s.displayName)),Y}while(1<=I&&0<=U);break}}}finally{ie=!1,Error.prepareStackTrace=f}return(s=s?s.displayName||s.name:"")?se(s):""}function ge(s){switch(s.tag){case 5:return se(s.type);case 16:return se("Lazy");case 13:return se("Suspense");case 19:return se("SuspenseList");case 0:case 2:case 15:return s=he(s.type,!1),s;case 11:return s=he(s.type.render,!1),s;case 1:return s=he(s.type,!0),s;default:return""}}function Ie(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 $:return"Fragment";case B:return"Portal";case j:return"Profiler";case C:return"StrictMode";case ae:return"Suspense";case A:return"SuspenseList"}if(typeof s=="object")switch(s.$$typeof){case z:return(s.displayName||"Context")+".Consumer";case D:return(s._context.displayName||"Context")+".Provider";case X:var a=s.render;return s=s.displayName,s||(s=a.displayName||a.name||"",s=s!==""?"ForwardRef("+s+")":"ForwardRef"),s;case de:return a=s.displayName||null,a!==null?a:Ie(s.type)||"Memo";case ue:a=s._payload,s=s._init;try{return Ie(s(a))}catch{}}return null}function ke(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 Ie(a);case 8:return a===C?"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 Q(s){switch(typeof s){case"boolean":case"number":case"string":case"undefined":return s;case"object":return s;default:return""}}function we(s){var a=s.type;return(s=s.nodeName)&&s.toLowerCase()==="input"&&(a==="checkbox"||a==="radio")}function te(s){var a=we(s)?"checked":"value",f=Object.getOwnPropertyDescriptor(s.constructor.prototype,a),k=""+s[a];if(!s.hasOwnProperty(a)&&typeof f<"u"&&typeof f.get=="function"&&typeof f.set=="function"){var v=f.get,x=f.set;return Object.defineProperty(s,a,{configurable:!0,get:function(){return v.call(this)},set:function(I){k=""+I,x.call(this,I)}}),Object.defineProperty(s,a,{enumerable:f.enumerable}),{getValue:function(){return k},setValue:function(I){k=""+I},stopTracking:function(){s._valueTracker=null,delete s[a]}}}}function Z(s){s._valueTracker||(s._valueTracker=te(s))}function je(s){if(!s)return!1;var a=s._valueTracker;if(!a)return!0;var f=a.getValue(),k="";return s&&(k=we(s)?s.checked?"true":"false":s.value),s=k,s!==f?(a.setValue(s),!0):!1}function He(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 Fe(s,a){var f=a.checked;return ne({},a,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:f??s._wrapperState.initialChecked})}function Pe(s,a){var f=a.defaultValue==null?"":a.defaultValue,k=a.checked!=null?a.checked:a.defaultChecked;f=Q(a.value!=null?a.value:f),s._wrapperState={initialChecked:k,initialValue:f,controlled:a.type==="checkbox"||a.type==="radio"?a.checked!=null:a.value!=null}}function We(s,a){a=a.checked,a!=null&&T(s,"checked",a,!1)}function Ht(s,a){We(s,a);var f=Q(a.value),k=a.type;if(f!=null)k==="number"?(f===0&&s.value===""||s.value!=f)&&(s.value=""+f):s.value!==""+f&&(s.value=""+f);else if(k==="submit"||k==="reset"){s.removeAttribute("value");return}a.hasOwnProperty("value")?vn(s,a.type,f):a.hasOwnProperty("defaultValue")&&vn(s,a.type,Q(a.defaultValue)),a.checked==null&&a.defaultChecked!=null&&(s.defaultChecked=!!a.defaultChecked)}function ut(s,a,f){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,f||a===s.value||(s.value=a),s.defaultValue=a}f=s.name,f!==""&&(s.name=""),s.defaultChecked=!!s._wrapperState.initialChecked,f!==""&&(s.name=f)}function vn(s,a,f){(a!=="number"||He(s.ownerDocument)!==s)&&(f==null?s.defaultValue=""+s._wrapperState.initialValue:s.defaultValue!==""+f&&(s.defaultValue=""+f))}var Jt=Array.isArray;function xt(s,a,f,k){if(s=s.options,a){a={};for(var v=0;v<f.length;v++)a["$"+f[v]]=!0;for(f=0;f<s.length;f++)v=a.hasOwnProperty("$"+s[f].value),s[f].selected!==v&&(s[f].selected=v),v&&k&&(s[f].defaultSelected=!0)}else{for(f=""+Q(f),a=null,v=0;v<s.length;v++){if(s[v].value===f){s[v].selected=!0,k&&(s[v].defaultSelected=!0);return}a!==null||s[v].disabled||(a=s[v])}a!==null&&(a.selected=!0)}}function kt(s,a){if(a.dangerouslySetInnerHTML!=null)throw Error(n(91));return ne({},a,{value:void 0,defaultValue:void 0,children:""+s._wrapperState.initialValue})}function ot(s,a){var f=a.value;if(f==null){if(f=a.children,a=a.defaultValue,f!=null){if(a!=null)throw Error(n(92));if(Jt(f)){if(1<f.length)throw Error(n(93));f=f[0]}a=f}a==null&&(a=""),f=a}s._wrapperState={initialValue:Q(f)}}function dt(s,a){var f=Q(a.value),k=Q(a.defaultValue);f!=null&&(f=""+f,f!==s.value&&(s.value=f),a.defaultValue==null&&s.defaultValue!==f&&(s.defaultValue=f)),k!=null&&(s.defaultValue=""+k)}function Tt(s){var a=s.textContent;a===s._wrapperState.initialValue&&a!==""&&a!==null&&(s.value=a)}function Et(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 dn(s,a){return s==null||s==="http://www.w3.org/1999/xhtml"?Et(a):s==="http://www.w3.org/2000/svg"&&a==="foreignObject"?"http://www.w3.org/1999/xhtml":s}var G,ve=(function(s){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(a,f,k,v){MSApp.execUnsafeLocalFunction(function(){return s(a,f,k,v)})}:s})(function(s,a){if(s.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in s)s.innerHTML=a;else{for(G=G||document.createElement("div"),G.innerHTML="<svg>"+a.valueOf().toString()+"</svg>",a=G.firstChild;s.firstChild;)s.removeChild(s.firstChild);for(;a.firstChild;)s.appendChild(a.firstChild)}});function tt(s,a){if(a){var f=s.firstChild;if(f&&f===s.lastChild&&f.nodeType===3){f.nodeValue=a;return}}s.textContent=a}var it={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},ft=["Webkit","ms","Moz","O"];Object.keys(it).forEach(function(s){ft.forEach(function(a){a=a+s.charAt(0).toUpperCase()+s.substring(1),it[a]=it[s]})});function Gt(s,a,f){return a==null||typeof a=="boolean"||a===""?"":f||typeof a!="number"||a===0||it.hasOwnProperty(s)&&it[s]?(""+a).trim():a+"px"}function Ft(s,a){s=s.style;for(var f in a)if(a.hasOwnProperty(f)){var k=f.indexOf("--")===0,v=Gt(f,a[f],k);f==="float"&&(f="cssFloat"),k?s.setProperty(f,v):s[f]=v}}var An=ne({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 qn(s,a){if(a){if(An[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 zt(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 bn=null;function ye(s){return s=s.target||s.srcElement||window,s.correspondingUseElement&&(s=s.correspondingUseElement),s.nodeType===3?s.parentNode:s}var Me=null,Bt=null,jt=null;function fn(s){if(s=Il(s)){if(typeof Me!="function")throw Error(n(280));var a=s.stateNode;a&&(a=hu(a),Me(s.stateNode,s.type,a))}}function K(s){Bt?jt?jt.push(s):jt=[s]:Bt=s}function pe(){if(Bt){var s=Bt,a=jt;if(jt=Bt=null,fn(s),a)for(s=0;s<a.length;s++)fn(a[s])}}function _e(s,a){return s(a)}function Xe(){}var qe=!1;function _t(s,a,f){if(qe)return s(a,f);qe=!0;try{return _e(s,a,f)}finally{qe=!1,(Bt!==null||jt!==null)&&(Xe(),pe())}}function Le(s,a){var f=s.stateNode;if(f===null)return null;var k=hu(f);if(k===null)return null;f=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(f&&typeof f!="function")throw Error(n(231,a,typeof f));return f}var $e=!1;if(c)try{var Ge={};Object.defineProperty(Ge,"passive",{get:function(){$e=!0}}),window.addEventListener("test",Ge,Ge),window.removeEventListener("test",Ge,Ge)}catch{$e=!1}function Wt(s,a,f,k,v,x,I,U,Y){var fe=Array.prototype.slice.call(arguments,3);try{a.apply(f,fe)}catch(Ae){this.onError(Ae)}}var Mt=!1,Tn=null,In=!1,yn=null,wr={onError:function(s){Mt=!0,Tn=s}};function gn(s,a,f,k,v,x,I,U,Y){Mt=!1,Tn=null,Wt.apply(wr,arguments)}function Nn(s,a,f,k,v,x,I,U,Y){if(gn.apply(this,arguments),Mt){if(Mt){var fe=Tn;Mt=!1,Tn=null}else throw Error(n(198));In||(In=!0,yn=fe)}}function ur(s){var a=s,f=s;if(s.alternate)for(;a.return;)a=a.return;else{s=a;do a=s,(a.flags&4098)!==0&&(f=a.return),s=a.return;while(s)}return a.tag===3?f:null}function nn(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 en(s){if(ur(s)!==s)throw Error(n(188))}function Kt(s){var a=s.alternate;if(!a){if(a=ur(s),a===null)throw Error(n(188));return a!==s?null:s}for(var f=s,k=a;;){var v=f.return;if(v===null)break;var x=v.alternate;if(x===null){if(k=v.return,k!==null){f=k;continue}break}if(v.child===x.child){for(x=v.child;x;){if(x===f)return en(v),s;if(x===k)return en(v),a;x=x.sibling}throw Error(n(188))}if(f.return!==k.return)f=v,k=x;else{for(var I=!1,U=v.child;U;){if(U===f){I=!0,f=v,k=x;break}if(U===k){I=!0,k=v,f=x;break}U=U.sibling}if(!I){for(U=x.child;U;){if(U===f){I=!0,f=x,k=v;break}if(U===k){I=!0,k=x,f=v;break}U=U.sibling}if(!I)throw Error(n(189))}}if(f.alternate!==k)throw Error(n(190))}if(f.tag!==3)throw Error(n(188));return f.stateNode.current===f?s:a}function V(s){return s=Kt(s),s!==null?Ee(s):null}function Ee(s){if(s.tag===5||s.tag===6)return s;for(s=s.child;s!==null;){var a=Ee(s);if(a!==null)return a;s=s.sibling}return null}var Ze=t.unstable_scheduleCallback,yt=t.unstable_cancelCallback,sn=t.unstable_shouldYield,ln=t.unstable_requestPaint,Vt=t.unstable_now,dr=t.unstable_getCurrentPriorityLevel,Mr=t.unstable_ImmediatePriority,Mn=t.unstable_UserBlockingPriority,Ot=t.unstable_NormalPriority,Ce=t.unstable_LowPriority,Te=t.unstable_IdlePriority,ht=null,pt=null;function Zt(s){if(pt&&typeof pt.onCommitFiberRoot=="function")try{pt.onCommitFiberRoot(ht,s,void 0,(s.current.flags&128)===128)}catch{}}var tn=Math.clz32?Math.clz32:Be,W=Math.log,me=Math.LN2;function Be(s){return s>>>=0,s===0?32:31-(W(s)/me|0)|0}var mt=64,Ct=4194304;function Yt(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 Ln(s,a){var f=s.pendingLanes;if(f===0)return 0;var k=0,v=s.suspendedLanes,x=s.pingedLanes,I=f&268435455;if(I!==0){var U=I&~v;U!==0?k=Yt(U):(x&=I,x!==0&&(k=Yt(x)))}else I=f&~v,I!==0?k=Yt(I):x!==0&&(k=Yt(x));if(k===0)return 0;if(a!==0&&a!==k&&(a&v)===0&&(v=k&-k,x=a&-a,v>=x||v===16&&(x&4194240)!==0))return a;if((k&4)!==0&&(k|=f&16),a=s.entangledLanes,a!==0)for(s=s.entanglements,a&=k;0<a;)f=31-tn(a),v=1<<f,k|=s[f],a&=~v;return k}function tr(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 jo(s,a){for(var f=s.suspendedLanes,k=s.pingedLanes,v=s.expirationTimes,x=s.pendingLanes;0<x;){var I=31-tn(x),U=1<<I,Y=v[I];Y===-1?((U&f)===0||(U&k)!==0)&&(v[I]=tr(U,a)):Y<=a&&(s.expiredLanes|=U),x&=~U}}function Sr(s){return s=s.pendingLanes&-1073741825,s!==0?s:s&1073741824?1073741824:0}function Cs(){var s=mt;return mt<<=1,(mt&4194240)===0&&(mt=64),s}function Lr(s){for(var a=[],f=0;31>f;f++)a.push(s);return a}function Pr(s,a,f){s.pendingLanes|=a,a!==536870912&&(s.suspendedLanes=0,s.pingedLanes=0),s=s.eventTimes,a=31-tn(a),s[a]=f}function yr(s,a){var f=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<f;){var v=31-tn(f),x=1<<v;a[v]=0,k[v]=-1,s[v]=-1,f&=~x}}function Co(s,a){var f=s.entangledLanes|=a;for(s=s.entanglements;f;){var k=31-tn(f),v=1<<k;v&a|s[k]&a&&(s[k]|=a),f&=~v}}var Je=0;function gt(s){return s&=-s,1<s?4<s?(s&268435455)!==0?16:536870912:4:1}var Ao,hn,rn,Dr,Yn,Se=!1,L=[],F=null,re=null,be=null,Re=new Map,Ke=new Map,At=[],pn="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 Gn(s,a){switch(s){case"focusin":case"focusout":F=null;break;case"dragenter":case"dragleave":re=null;break;case"mouseover":case"mouseout":be=null;break;case"pointerover":case"pointerout":Re.delete(a.pointerId);break;case"gotpointercapture":case"lostpointercapture":Ke.delete(a.pointerId)}}function Pn(s,a,f,k,v,x){return s===null||s.nativeEvent!==x?(s={blockedOn:a,domEventName:f,eventSystemFlags:k,nativeEvent:x,targetContainers:[v]},a!==null&&(a=Il(a),a!==null&&hn(a)),s):(s.eventSystemFlags|=k,a=s.targetContainers,v!==null&&a.indexOf(v)===-1&&a.push(v),s)}function vr(s,a,f,k,v){switch(a){case"focusin":return F=Pn(F,s,a,f,k,v),!0;case"dragenter":return re=Pn(re,s,a,f,k,v),!0;case"mouseover":return be=Pn(be,s,a,f,k,v),!0;case"pointerover":var x=v.pointerId;return Re.set(x,Pn(Re.get(x)||null,s,a,f,k,v)),!0;case"gotpointercapture":return x=v.pointerId,Ke.set(x,Pn(Ke.get(x)||null,s,a,f,k,v)),!0}return!1}function nr(s){var a=bi(s.target);if(a!==null){var f=ur(a);if(f!==null){if(a=f.tag,a===13){if(a=nn(f),a!==null){s.blockedOn=a,Yn(s.priority,function(){rn(f)});return}}else if(a===3&&f.stateNode.current.memoizedState.isDehydrated){s.blockedOn=f.tag===3?f.stateNode.containerInfo:null;return}}}s.blockedOn=null}function Ji(s){if(s.blockedOn!==null)return!1;for(var a=s.targetContainers;0<a.length;){var f=oa(s.domEventName,s.eventSystemFlags,a[0],s.nativeEvent);if(f===null){f=s.nativeEvent;var k=new f.constructor(f.type,f);bn=k,f.target.dispatchEvent(k),bn=null}else return a=Il(f),a!==null&&hn(a),s.blockedOn=f,!1;a.shift()}return!0}function ea(s,a,f){Ji(s)&&f.delete(a)}function ml(){Se=!1,F!==null&&Ji(F)&&(F=null),re!==null&&Ji(re)&&(re=null),be!==null&&Ji(be)&&(be=null),Re.forEach(ea),Ke.forEach(ea)}function Io(s,a){s.blockedOn===a&&(s.blockedOn=null,Se||(Se=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,ml)))}function ls(s){function a(v){return Io(v,s)}if(0<L.length){Io(L[0],s);for(var f=1;f<L.length;f++){var k=L[f];k.blockedOn===s&&(k.blockedOn=null)}}for(F!==null&&Io(F,s),re!==null&&Io(re,s),be!==null&&Io(be,s),Re.forEach(a),Ke.forEach(a),f=0;f<At.length;f++)k=At[f],k.blockedOn===s&&(k.blockedOn=null);for(;0<At.length&&(f=At[0],f.blockedOn===null);)nr(f),f.blockedOn===null&&At.shift()}var cs=R.ReactCurrentBatchConfig,ta=!0;function gl(s,a,f,k){var v=Je,x=cs.transition;cs.transition=null;try{Je=1,na(s,a,f,k)}finally{Je=v,cs.transition=x}}function Gf(s,a,f,k){var v=Je,x=cs.transition;cs.transition=null;try{Je=4,na(s,a,f,k)}finally{Je=v,cs.transition=x}}function na(s,a,f,k){if(ta){var v=oa(s,a,f,k);if(v===null)uh(s,a,k,ra,f),Gn(s,k);else if(vr(v,s,a,f,k))k.stopPropagation();else if(Gn(s,k),a&4&&-1<pn.indexOf(s)){for(;v!==null;){var x=Il(v);if(x!==null&&Ao(x),x=oa(s,a,f,k),x===null&&uh(s,a,k,ra,f),x===v)break;v=x}v!==null&&k.stopPropagation()}else uh(s,a,k,null,f)}}var ra=null;function oa(s,a,f,k){if(ra=null,s=ye(k),s=bi(s),s!==null)if(a=ur(s),a===null)s=null;else if(f=a.tag,f===13){if(s=nn(a),s!==null)return s;s=null}else if(f===3){if(a.stateNode.current.memoizedState.isDehydrated)return a.tag===3?a.stateNode.containerInfo:null;s=null}else a!==s&&(s=null);return ra=s,null}function Gc(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(dr()){case Mr:return 1;case Mn:return 4;case Ot:case Ce:return 16;case Te:return 536870912;default:return 16}default:return 16}}var jn=null,sa=null,mi=null;function ia(){if(mi)return mi;var s,a=sa,f=a.length,k,v="value"in jn?jn.value:jn.textContent,x=v.length;for(s=0;s<f&&a[s]===v[s];s++);var I=f-s;for(k=1;k<=I&&a[f-k]===v[x-k];k++);return mi=v.slice(s,1<k?1-k:void 0)}function As(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 us(){return!0}function Xn(){return!1}function fr(s){function a(f,k,v,x,I){this._reactName=f,this._targetInst=v,this.type=k,this.nativeEvent=x,this.target=I,this.currentTarget=null;for(var U in s)s.hasOwnProperty(U)&&(f=s[U],this[U]=f?f(x):x[U]);return this.isDefaultPrevented=(x.defaultPrevented!=null?x.defaultPrevented:x.returnValue===!1)?us:Xn,this.isPropagationStopped=Xn,this}return ne(a.prototype,{preventDefault:function(){this.defaultPrevented=!0;var f=this.nativeEvent;f&&(f.preventDefault?f.preventDefault():typeof f.returnValue!="unknown"&&(f.returnValue=!1),this.isDefaultPrevented=us)},stopPropagation:function(){var f=this.nativeEvent;f&&(f.stopPropagation?f.stopPropagation():typeof f.cancelBubble!="unknown"&&(f.cancelBubble=!0),this.isPropagationStopped=us)},persist:function(){},isPersistent:us}),a}var Vo={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(s){return s.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Is=fr(Vo),Yo=ne({},Vo,{view:0,detail:0}),Rs=fr(Yo),aa,gi,ds,ki=ne({},Yo,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:da,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!==ds&&(ds&&s.type==="mousemove"?(aa=s.screenX-ds.screenX,gi=s.screenY-ds.screenY):gi=aa=0,ds=s),aa)},movementY:function(s){return"movementY"in s?s.movementY:gi}}),Vf=fr(ki),Vc=ne({},ki,{dataTransfer:0}),la=fr(Vc),Yc=ne({},Yo,{relatedTarget:0}),ca=fr(Yc),Xc=ne({},Vo,{animationName:0,elapsedTime:0,pseudoElement:0}),br=fr(Xc),Yf=ne({},Vo,{clipboardData:function(s){return"clipboardData"in s?s.clipboardData:window.clipboardData}}),ua=fr(Yf),$s=ne({},Vo,{data:0}),Os=fr($s),kl={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Xf={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"},wl={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function Qf(s){var a=this.nativeEvent;return a.getModifierState?a.getModifierState(s):(s=wl[s])?!!a[s]:!1}function da(){return Qf}var Qc=ne({},Yo,{key:function(s){if(s.key){var a=kl[s.key]||s.key;if(a!=="Unidentified")return a}return s.type==="keypress"?(s=As(s),s===13?"Enter":String.fromCharCode(s)):s.type==="keydown"||s.type==="keyup"?Xf[s.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:da,charCode:function(s){return s.type==="keypress"?As(s):0},keyCode:function(s){return s.type==="keydown"||s.type==="keyup"?s.keyCode:0},which:function(s){return s.type==="keypress"?As(s):s.type==="keydown"||s.type==="keyup"?s.keyCode:0}}),Jc=fr(Qc),eu=ne({},ki,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),yl=fr(eu),wi=ne({},Yo,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:da}),tu=fr(wi),Jf=ne({},Vo,{propertyName:0,elapsedTime:0,pseudoElement:0}),eh=fr(Jf),nu=ne({},ki,{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}),fa=fr(nu),ru=[9,13,27,32],ha=c&&"CompositionEvent"in window,Ms=null;c&&"documentMode"in document&&(Ms=document.documentMode);var ou=c&&"TextEvent"in window&&!Ms,vl=c&&(!ha||Ms&&8<Ms&&11>=Ms),bl=" ",xl=!1;function El(s,a){switch(s){case"keyup":return ru.indexOf(a.keyCode)!==-1;case"keydown":return a.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function _l(s){return s=s.detail,typeof s=="object"&&"data"in s?s.data:null}var q=!1;function Ve(s,a){switch(s){case"compositionend":return _l(a);case"keypress":return a.which!==32?null:(xl=!0,bl);case"textInput":return s=a.data,s===bl&&xl?null:s;default:return null}}function Rt(s,a){if(q)return s==="compositionend"||!ha&&El(s,a)?(s=ia(),mi=sa=jn=null,q=!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 vl&&a.locale!=="ko"?null:a.data;default:return null}}var Xt={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 zr(s){var a=s&&s.nodeName&&s.nodeName.toLowerCase();return a==="input"?!!Xt[s.type]:a==="textarea"}function Qn(s,a,f,k){K(k),a=uu(a,"onChange"),0<a.length&&(f=new Is("onChange","change",null,f,k),s.push({event:f,listeners:a}))}var yi=null,vi=null;function su(s){Nw(s,0)}function iu(s){var a=wa(s);if(je(a))return s}function bT(s,a){if(s==="change")return a}var cw=!1;if(c){var th;if(c){var nh="oninput"in document;if(!nh){var uw=document.createElement("div");uw.setAttribute("oninput","return;"),nh=typeof uw.oninput=="function"}th=nh}else th=!1;cw=th&&(!document.documentMode||9<document.documentMode)}function dw(){yi&&(yi.detachEvent("onpropertychange",fw),vi=yi=null)}function fw(s){if(s.propertyName==="value"&&iu(vi)){var a=[];Qn(a,vi,s,ye(s)),_t(su,a)}}function xT(s,a,f){s==="focusin"?(dw(),yi=a,vi=f,yi.attachEvent("onpropertychange",fw)):s==="focusout"&&dw()}function ET(s){if(s==="selectionchange"||s==="keyup"||s==="keydown")return iu(vi)}function _T(s,a){if(s==="click")return iu(a)}function ST(s,a){if(s==="input"||s==="change")return iu(a)}function NT(s,a){return s===a&&(s!==0||1/s===1/a)||s!==s&&a!==a}var Ro=typeof Object.is=="function"?Object.is:NT;function Sl(s,a){if(Ro(s,a))return!0;if(typeof s!="object"||s===null||typeof a!="object"||a===null)return!1;var f=Object.keys(s),k=Object.keys(a);if(f.length!==k.length)return!1;for(k=0;k<f.length;k++){var v=f[k];if(!u.call(a,v)||!Ro(s[v],a[v]))return!1}return!0}function hw(s){for(;s&&s.firstChild;)s=s.firstChild;return s}function pw(s,a){var f=hw(s);s=0;for(var k;f;){if(f.nodeType===3){if(k=s+f.textContent.length,s<=a&&k>=a)return{node:f,offset:a-s};s=k}e:{for(;f;){if(f.nextSibling){f=f.nextSibling;break e}f=f.parentNode}f=void 0}f=hw(f)}}function mw(s,a){return s&&a?s===a?!0:s&&s.nodeType===3?!1:a&&a.nodeType===3?mw(s,a.parentNode):"contains"in s?s.contains(a):s.compareDocumentPosition?!!(s.compareDocumentPosition(a)&16):!1:!1}function gw(){for(var s=window,a=He();a instanceof s.HTMLIFrameElement;){try{var f=typeof a.contentWindow.location.href=="string"}catch{f=!1}if(f)s=a.contentWindow;else break;a=He(s.document)}return a}function rh(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 TT(s){var a=gw(),f=s.focusedElem,k=s.selectionRange;if(a!==f&&f&&f.ownerDocument&&mw(f.ownerDocument.documentElement,f)){if(k!==null&&rh(f)){if(a=k.start,s=k.end,s===void 0&&(s=a),"selectionStart"in f)f.selectionStart=a,f.selectionEnd=Math.min(s,f.value.length);else if(s=(a=f.ownerDocument||document)&&a.defaultView||window,s.getSelection){s=s.getSelection();var v=f.textContent.length,x=Math.min(k.start,v);k=k.end===void 0?x:Math.min(k.end,v),!s.extend&&x>k&&(v=k,k=x,x=v),v=pw(f,x);var I=pw(f,k);v&&I&&(s.rangeCount!==1||s.anchorNode!==v.node||s.anchorOffset!==v.offset||s.focusNode!==I.node||s.focusOffset!==I.offset)&&(a=a.createRange(),a.setStart(v.node,v.offset),s.removeAllRanges(),x>k?(s.addRange(a),s.extend(I.node,I.offset)):(a.setEnd(I.node,I.offset),s.addRange(a)))}}for(a=[],s=f;s=s.parentNode;)s.nodeType===1&&a.push({element:s,left:s.scrollLeft,top:s.scrollTop});for(typeof f.focus=="function"&&f.focus(),f=0;f<a.length;f++)s=a[f],s.element.scrollLeft=s.left,s.element.scrollTop=s.top}}var jT=c&&"documentMode"in document&&11>=document.documentMode,pa=null,oh=null,Nl=null,sh=!1;function kw(s,a,f){var k=f.window===f?f.document:f.nodeType===9?f:f.ownerDocument;sh||pa==null||pa!==He(k)||(k=pa,"selectionStart"in k&&rh(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}),Nl&&Sl(Nl,k)||(Nl=k,k=uu(oh,"onSelect"),0<k.length&&(a=new Is("onSelect","select",null,a,f),s.push({event:a,listeners:k}),a.target=pa)))}function au(s,a){var f={};return f[s.toLowerCase()]=a.toLowerCase(),f["Webkit"+s]="webkit"+a,f["Moz"+s]="moz"+a,f}var ma={animationend:au("Animation","AnimationEnd"),animationiteration:au("Animation","AnimationIteration"),animationstart:au("Animation","AnimationStart"),transitionend:au("Transition","TransitionEnd")},ih={},ww={};c&&(ww=document.createElement("div").style,"AnimationEvent"in window||(delete ma.animationend.animation,delete ma.animationiteration.animation,delete ma.animationstart.animation),"TransitionEvent"in window||delete ma.transitionend.transition);function lu(s){if(ih[s])return ih[s];if(!ma[s])return s;var a=ma[s],f;for(f in a)if(a.hasOwnProperty(f)&&f in ww)return ih[s]=a[f];return s}var yw=lu("animationend"),vw=lu("animationiteration"),bw=lu("animationstart"),xw=lu("transitionend"),Ew=new Map,_w="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 Ls(s,a){Ew.set(s,a),i(a,[s])}for(var ah=0;ah<_w.length;ah++){var lh=_w[ah],CT=lh.toLowerCase(),AT=lh[0].toUpperCase()+lh.slice(1);Ls(CT,"on"+AT)}Ls(yw,"onAnimationEnd"),Ls(vw,"onAnimationIteration"),Ls(bw,"onAnimationStart"),Ls("dblclick","onDoubleClick"),Ls("focusin","onFocus"),Ls("focusout","onBlur"),Ls(xw,"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 Tl="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(" "),IT=new Set("cancel close invalid load scroll toggle".split(" ").concat(Tl));function Sw(s,a,f){var k=s.type||"unknown-event";s.currentTarget=f,Nn(k,a,void 0,s),s.currentTarget=null}function Nw(s,a){a=(a&4)!==0;for(var f=0;f<s.length;f++){var k=s[f],v=k.event;k=k.listeners;e:{var x=void 0;if(a)for(var I=k.length-1;0<=I;I--){var U=k[I],Y=U.instance,fe=U.currentTarget;if(U=U.listener,Y!==x&&v.isPropagationStopped())break e;Sw(v,U,fe),x=Y}else for(I=0;I<k.length;I++){if(U=k[I],Y=U.instance,fe=U.currentTarget,U=U.listener,Y!==x&&v.isPropagationStopped())break e;Sw(v,U,fe),x=Y}}}if(In)throw s=yn,In=!1,yn=null,s}function Rn(s,a){var f=a[gh];f===void 0&&(f=a[gh]=new Set);var k=s+"__bubble";f.has(k)||(Tw(a,s,2,!1),f.add(k))}function ch(s,a,f){var k=0;a&&(k|=4),Tw(f,s,k,a)}var cu="_reactListening"+Math.random().toString(36).slice(2);function jl(s){if(!s[cu]){s[cu]=!0,r.forEach(function(f){f!=="selectionchange"&&(IT.has(f)||ch(f,!1,s),ch(f,!0,s))});var a=s.nodeType===9?s:s.ownerDocument;a===null||a[cu]||(a[cu]=!0,ch("selectionchange",!1,a))}}function Tw(s,a,f,k){switch(Gc(a)){case 1:var v=gl;break;case 4:v=Gf;break;default:v=na}f=v.bind(null,a,f,s),v=void 0,!$e||a!=="touchstart"&&a!=="touchmove"&&a!=="wheel"||(v=!0),k?v!==void 0?s.addEventListener(a,f,{capture:!0,passive:v}):s.addEventListener(a,f,!0):v!==void 0?s.addEventListener(a,f,{passive:v}):s.addEventListener(a,f,!1)}function uh(s,a,f,k,v){var x=k;if((a&1)===0&&(a&2)===0&&k!==null)e:for(;;){if(k===null)return;var I=k.tag;if(I===3||I===4){var U=k.stateNode.containerInfo;if(U===v||U.nodeType===8&&U.parentNode===v)break;if(I===4)for(I=k.return;I!==null;){var Y=I.tag;if((Y===3||Y===4)&&(Y=I.stateNode.containerInfo,Y===v||Y.nodeType===8&&Y.parentNode===v))return;I=I.return}for(;U!==null;){if(I=bi(U),I===null)return;if(Y=I.tag,Y===5||Y===6){k=x=I;continue e}U=U.parentNode}}k=k.return}_t(function(){var fe=x,Ae=ye(f),Oe=[];e:{var Ne=Ew.get(s);if(Ne!==void 0){var Ye=Is,nt=s;switch(s){case"keypress":if(As(f)===0)break e;case"keydown":case"keyup":Ye=Jc;break;case"focusin":nt="focus",Ye=ca;break;case"focusout":nt="blur",Ye=ca;break;case"beforeblur":case"afterblur":Ye=ca;break;case"click":if(f.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":Ye=Vf;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":Ye=la;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":Ye=tu;break;case yw:case vw:case bw:Ye=br;break;case xw:Ye=eh;break;case"scroll":Ye=Rs;break;case"wheel":Ye=fa;break;case"copy":case"cut":case"paste":Ye=ua;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":Ye=yl}var rt=(a&4)!==0,Jn=!rt&&s==="scroll",le=rt?Ne!==null?Ne+"Capture":null:Ne;rt=[];for(var ee=fe,ce;ee!==null;){ce=ee;var De=ce.stateNode;if(ce.tag===5&&De!==null&&(ce=De,le!==null&&(De=Le(ee,le),De!=null&&rt.push(Cl(ee,De,ce)))),Jn)break;ee=ee.return}0<rt.length&&(Ne=new Ye(Ne,nt,null,f,Ae),Oe.push({event:Ne,listeners:rt}))}}if((a&7)===0){e:{if(Ne=s==="mouseover"||s==="pointerover",Ye=s==="mouseout"||s==="pointerout",Ne&&f!==bn&&(nt=f.relatedTarget||f.fromElement)&&(bi(nt)||nt[fs]))break e;if((Ye||Ne)&&(Ne=Ae.window===Ae?Ae:(Ne=Ae.ownerDocument)?Ne.defaultView||Ne.parentWindow:window,Ye?(nt=f.relatedTarget||f.toElement,Ye=fe,nt=nt?bi(nt):null,nt!==null&&(Jn=ur(nt),nt!==Jn||nt.tag!==5&&nt.tag!==6)&&(nt=null)):(Ye=null,nt=fe),Ye!==nt)){if(rt=Vf,De="onMouseLeave",le="onMouseEnter",ee="mouse",(s==="pointerout"||s==="pointerover")&&(rt=yl,De="onPointerLeave",le="onPointerEnter",ee="pointer"),Jn=Ye==null?Ne:wa(Ye),ce=nt==null?Ne:wa(nt),Ne=new rt(De,ee+"leave",Ye,f,Ae),Ne.target=Jn,Ne.relatedTarget=ce,De=null,bi(Ae)===fe&&(rt=new rt(le,ee+"enter",nt,f,Ae),rt.target=ce,rt.relatedTarget=Jn,De=rt),Jn=De,Ye&&nt)t:{for(rt=Ye,le=nt,ee=0,ce=rt;ce;ce=ga(ce))ee++;for(ce=0,De=le;De;De=ga(De))ce++;for(;0<ee-ce;)rt=ga(rt),ee--;for(;0<ce-ee;)le=ga(le),ce--;for(;ee--;){if(rt===le||le!==null&&rt===le.alternate)break t;rt=ga(rt),le=ga(le)}rt=null}else rt=null;Ye!==null&&jw(Oe,Ne,Ye,rt,!1),nt!==null&&Jn!==null&&jw(Oe,Jn,nt,rt,!0)}}e:{if(Ne=fe?wa(fe):window,Ye=Ne.nodeName&&Ne.nodeName.toLowerCase(),Ye==="select"||Ye==="input"&&Ne.type==="file")var st=bT;else if(zr(Ne))if(cw)st=ST;else{st=ET;var vt=xT}else(Ye=Ne.nodeName)&&Ye.toLowerCase()==="input"&&(Ne.type==="checkbox"||Ne.type==="radio")&&(st=_T);if(st&&(st=st(s,fe))){Qn(Oe,st,f,Ae);break e}vt&&vt(s,Ne,fe),s==="focusout"&&(vt=Ne._wrapperState)&&vt.controlled&&Ne.type==="number"&&vn(Ne,"number",Ne.value)}switch(vt=fe?wa(fe):window,s){case"focusin":(zr(vt)||vt.contentEditable==="true")&&(pa=vt,oh=fe,Nl=null);break;case"focusout":Nl=oh=pa=null;break;case"mousedown":sh=!0;break;case"contextmenu":case"mouseup":case"dragend":sh=!1,kw(Oe,f,Ae);break;case"selectionchange":if(jT)break;case"keydown":case"keyup":kw(Oe,f,Ae)}var bt;if(ha)e:{switch(s){case"compositionstart":var $t="onCompositionStart";break e;case"compositionend":$t="onCompositionEnd";break e;case"compositionupdate":$t="onCompositionUpdate";break e}$t=void 0}else q?El(s,f)&&($t="onCompositionEnd"):s==="keydown"&&f.keyCode===229&&($t="onCompositionStart");$t&&(vl&&f.locale!=="ko"&&(q||$t!=="onCompositionStart"?$t==="onCompositionEnd"&&q&&(bt=ia()):(jn=Ae,sa="value"in jn?jn.value:jn.textContent,q=!0)),vt=uu(fe,$t),0<vt.length&&($t=new Os($t,s,null,f,Ae),Oe.push({event:$t,listeners:vt}),bt?$t.data=bt:(bt=_l(f),bt!==null&&($t.data=bt)))),(bt=ou?Ve(s,f):Rt(s,f))&&(fe=uu(fe,"onBeforeInput"),0<fe.length&&(Ae=new Os("onBeforeInput","beforeinput",null,f,Ae),Oe.push({event:Ae,listeners:fe}),Ae.data=bt))}Nw(Oe,a)})}function Cl(s,a,f){return{instance:s,listener:a,currentTarget:f}}function uu(s,a){for(var f=a+"Capture",k=[];s!==null;){var v=s,x=v.stateNode;v.tag===5&&x!==null&&(v=x,x=Le(s,f),x!=null&&k.unshift(Cl(s,x,v)),x=Le(s,a),x!=null&&k.push(Cl(s,x,v))),s=s.return}return k}function ga(s){if(s===null)return null;do s=s.return;while(s&&s.tag!==5);return s||null}function jw(s,a,f,k,v){for(var x=a._reactName,I=[];f!==null&&f!==k;){var U=f,Y=U.alternate,fe=U.stateNode;if(Y!==null&&Y===k)break;U.tag===5&&fe!==null&&(U=fe,v?(Y=Le(f,x),Y!=null&&I.unshift(Cl(f,Y,U))):v||(Y=Le(f,x),Y!=null&&I.push(Cl(f,Y,U)))),f=f.return}I.length!==0&&s.push({event:a,listeners:I})}var RT=/\r\n?/g,$T=/\u0000|\uFFFD/g;function Cw(s){return(typeof s=="string"?s:""+s).replace(RT,`
39
+ `).replace($T,"")}function du(s,a,f){if(a=Cw(a),Cw(s)!==a&&f)throw Error(n(425))}function fu(){}var dh=null,fh=null;function hh(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 ph=typeof setTimeout=="function"?setTimeout:void 0,OT=typeof clearTimeout=="function"?clearTimeout:void 0,Aw=typeof Promise=="function"?Promise:void 0,MT=typeof queueMicrotask=="function"?queueMicrotask:typeof Aw<"u"?function(s){return Aw.resolve(null).then(s).catch(LT)}:ph;function LT(s){setTimeout(function(){throw s})}function mh(s,a){var f=a,k=0;do{var v=f.nextSibling;if(s.removeChild(f),v&&v.nodeType===8)if(f=v.data,f==="/$"){if(k===0){s.removeChild(v),ls(a);return}k--}else f!=="$"&&f!=="$?"&&f!=="$!"||k++;f=v}while(f);ls(a)}function Ps(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 Iw(s){s=s.previousSibling;for(var a=0;s;){if(s.nodeType===8){var f=s.data;if(f==="$"||f==="$!"||f==="$?"){if(a===0)return s;a--}else f==="/$"&&a++}s=s.previousSibling}return null}var ka=Math.random().toString(36).slice(2),Xo="__reactFiber$"+ka,Al="__reactProps$"+ka,fs="__reactContainer$"+ka,gh="__reactEvents$"+ka,PT="__reactListeners$"+ka,DT="__reactHandles$"+ka;function bi(s){var a=s[Xo];if(a)return a;for(var f=s.parentNode;f;){if(a=f[fs]||f[Xo]){if(f=a.alternate,a.child!==null||f!==null&&f.child!==null)for(s=Iw(s);s!==null;){if(f=s[Xo])return f;s=Iw(s)}return a}s=f,f=s.parentNode}return null}function Il(s){return s=s[Xo]||s[fs],!s||s.tag!==5&&s.tag!==6&&s.tag!==13&&s.tag!==3?null:s}function wa(s){if(s.tag===5||s.tag===6)return s.stateNode;throw Error(n(33))}function hu(s){return s[Al]||null}var kh=[],ya=-1;function Ds(s){return{current:s}}function $n(s){0>ya||(s.current=kh[ya],kh[ya]=null,ya--)}function Cn(s,a){ya++,kh[ya]=s.current,s.current=a}var zs={},Nr=Ds(zs),Kr=Ds(!1),xi=zs;function va(s,a){var f=s.type.contextTypes;if(!f)return zs;var k=s.stateNode;if(k&&k.__reactInternalMemoizedUnmaskedChildContext===a)return k.__reactInternalMemoizedMaskedChildContext;var v={},x;for(x in f)v[x]=a[x];return k&&(s=s.stateNode,s.__reactInternalMemoizedUnmaskedChildContext=a,s.__reactInternalMemoizedMaskedChildContext=v),v}function Zr(s){return s=s.childContextTypes,s!=null}function pu(){$n(Kr),$n(Nr)}function Rw(s,a,f){if(Nr.current!==zs)throw Error(n(168));Cn(Nr,a),Cn(Kr,f)}function $w(s,a,f){var k=s.stateNode;if(a=a.childContextTypes,typeof k.getChildContext!="function")return f;k=k.getChildContext();for(var v in k)if(!(v in a))throw Error(n(108,ke(s)||"Unknown",v));return ne({},f,k)}function mu(s){return s=(s=s.stateNode)&&s.__reactInternalMemoizedMergedChildContext||zs,xi=Nr.current,Cn(Nr,s),Cn(Kr,Kr.current),!0}function Ow(s,a,f){var k=s.stateNode;if(!k)throw Error(n(169));f?(s=$w(s,a,xi),k.__reactInternalMemoizedMergedChildContext=s,$n(Kr),$n(Nr),Cn(Nr,s)):$n(Kr),Cn(Kr,f)}var hs=null,gu=!1,wh=!1;function Mw(s){hs===null?hs=[s]:hs.push(s)}function zT(s){gu=!0,Mw(s)}function Fs(){if(!wh&&hs!==null){wh=!0;var s=0,a=Je;try{var f=hs;for(Je=1;s<f.length;s++){var k=f[s];do k=k(!0);while(k!==null)}hs=null,gu=!1}catch(v){throw hs!==null&&(hs=hs.slice(s+1)),Ze(Mr,Fs),v}finally{Je=a,wh=!1}}return null}var ba=[],xa=0,ku=null,wu=0,po=[],mo=0,Ei=null,ps=1,ms="";function _i(s,a){ba[xa++]=wu,ba[xa++]=ku,ku=s,wu=a}function Lw(s,a,f){po[mo++]=ps,po[mo++]=ms,po[mo++]=Ei,Ei=s;var k=ps;s=ms;var v=32-tn(k)-1;k&=~(1<<v),f+=1;var x=32-tn(a)+v;if(30<x){var I=v-v%5;x=(k&(1<<I)-1).toString(32),k>>=I,v-=I,ps=1<<32-tn(a)+v|f<<v|k,ms=x+s}else ps=1<<x|f<<v|k,ms=s}function yh(s){s.return!==null&&(_i(s,1),Lw(s,1,0))}function vh(s){for(;s===ku;)ku=ba[--xa],ba[xa]=null,wu=ba[--xa],ba[xa]=null;for(;s===Ei;)Ei=po[--mo],po[mo]=null,ms=po[--mo],po[mo]=null,ps=po[--mo],po[mo]=null}var io=null,ao=null,Dn=!1,$o=null;function Pw(s,a){var f=yo(5,null,null,0);f.elementType="DELETED",f.stateNode=a,f.return=s,a=s.deletions,a===null?(s.deletions=[f],s.flags|=16):a.push(f)}function Dw(s,a){switch(s.tag){case 5:var f=s.type;return a=a.nodeType!==1||f.toLowerCase()!==a.nodeName.toLowerCase()?null:a,a!==null?(s.stateNode=a,io=s,ao=Ps(a.firstChild),!0):!1;case 6:return a=s.pendingProps===""||a.nodeType!==3?null:a,a!==null?(s.stateNode=a,io=s,ao=null,!0):!1;case 13:return a=a.nodeType!==8?null:a,a!==null?(f=Ei!==null?{id:ps,overflow:ms}:null,s.memoizedState={dehydrated:a,treeContext:f,retryLane:1073741824},f=yo(18,null,null,0),f.stateNode=a,f.return=s,s.child=f,io=s,ao=null,!0):!1;default:return!1}}function bh(s){return(s.mode&1)!==0&&(s.flags&128)===0}function xh(s){if(Dn){var a=ao;if(a){var f=a;if(!Dw(s,a)){if(bh(s))throw Error(n(418));a=Ps(f.nextSibling);var k=io;a&&Dw(s,a)?Pw(k,f):(s.flags=s.flags&-4097|2,Dn=!1,io=s)}}else{if(bh(s))throw Error(n(418));s.flags=s.flags&-4097|2,Dn=!1,io=s}}}function zw(s){for(s=s.return;s!==null&&s.tag!==5&&s.tag!==3&&s.tag!==13;)s=s.return;io=s}function yu(s){if(s!==io)return!1;if(!Dn)return zw(s),Dn=!0,!1;var a;if((a=s.tag!==3)&&!(a=s.tag!==5)&&(a=s.type,a=a!=="head"&&a!=="body"&&!hh(s.type,s.memoizedProps)),a&&(a=ao)){if(bh(s))throw Fw(),Error(n(418));for(;a;)Pw(s,a),a=Ps(a.nextSibling)}if(zw(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 f=s.data;if(f==="/$"){if(a===0){ao=Ps(s.nextSibling);break e}a--}else f!=="$"&&f!=="$!"&&f!=="$?"||a++}s=s.nextSibling}ao=null}}else ao=io?Ps(s.stateNode.nextSibling):null;return!0}function Fw(){for(var s=ao;s;)s=Ps(s.nextSibling)}function Ea(){ao=io=null,Dn=!1}function Eh(s){$o===null?$o=[s]:$o.push(s)}var FT=R.ReactCurrentBatchConfig;function Rl(s,a,f){if(s=f.ref,s!==null&&typeof s!="function"&&typeof s!="object"){if(f._owner){if(f=f._owner,f){if(f.tag!==1)throw Error(n(309));var k=f.stateNode}if(!k)throw Error(n(147,s));var v=k,x=""+s;return a!==null&&a.ref!==null&&typeof a.ref=="function"&&a.ref._stringRef===x?a.ref:(a=function(I){var U=v.refs;I===null?delete U[x]:U[x]=I},a._stringRef=x,a)}if(typeof s!="string")throw Error(n(284));if(!f._owner)throw Error(n(290,s))}return s}function vu(s,a){throw s=Object.prototype.toString.call(a),Error(n(31,s==="[object Object]"?"object with keys {"+Object.keys(a).join(", ")+"}":s))}function Bw(s){var a=s._init;return a(s._payload)}function Uw(s){function a(le,ee){if(s){var ce=le.deletions;ce===null?(le.deletions=[ee],le.flags|=16):ce.push(ee)}}function f(le,ee){if(!s)return null;for(;ee!==null;)a(le,ee),ee=ee.sibling;return null}function k(le,ee){for(le=new Map;ee!==null;)ee.key!==null?le.set(ee.key,ee):le.set(ee.index,ee),ee=ee.sibling;return le}function v(le,ee){return le=Gs(le,ee),le.index=0,le.sibling=null,le}function x(le,ee,ce){return le.index=ce,s?(ce=le.alternate,ce!==null?(ce=ce.index,ce<ee?(le.flags|=2,ee):ce):(le.flags|=2,ee)):(le.flags|=1048576,ee)}function I(le){return s&&le.alternate===null&&(le.flags|=2),le}function U(le,ee,ce,De){return ee===null||ee.tag!==6?(ee=pp(ce,le.mode,De),ee.return=le,ee):(ee=v(ee,ce),ee.return=le,ee)}function Y(le,ee,ce,De){var st=ce.type;return st===$?Ae(le,ee,ce.props.children,De,ce.key):ee!==null&&(ee.elementType===st||typeof st=="object"&&st!==null&&st.$$typeof===ue&&Bw(st)===ee.type)?(De=v(ee,ce.props),De.ref=Rl(le,ee,ce),De.return=le,De):(De=Wu(ce.type,ce.key,ce.props,null,le.mode,De),De.ref=Rl(le,ee,ce),De.return=le,De)}function fe(le,ee,ce,De){return ee===null||ee.tag!==4||ee.stateNode.containerInfo!==ce.containerInfo||ee.stateNode.implementation!==ce.implementation?(ee=mp(ce,le.mode,De),ee.return=le,ee):(ee=v(ee,ce.children||[]),ee.return=le,ee)}function Ae(le,ee,ce,De,st){return ee===null||ee.tag!==7?(ee=Ri(ce,le.mode,De,st),ee.return=le,ee):(ee=v(ee,ce),ee.return=le,ee)}function Oe(le,ee,ce){if(typeof ee=="string"&&ee!==""||typeof ee=="number")return ee=pp(""+ee,le.mode,ce),ee.return=le,ee;if(typeof ee=="object"&&ee!==null){switch(ee.$$typeof){case O:return ce=Wu(ee.type,ee.key,ee.props,null,le.mode,ce),ce.ref=Rl(le,null,ee),ce.return=le,ce;case B:return ee=mp(ee,le.mode,ce),ee.return=le,ee;case ue:var De=ee._init;return Oe(le,De(ee._payload),ce)}if(Jt(ee)||oe(ee))return ee=Ri(ee,le.mode,ce,null),ee.return=le,ee;vu(le,ee)}return null}function Ne(le,ee,ce,De){var st=ee!==null?ee.key:null;if(typeof ce=="string"&&ce!==""||typeof ce=="number")return st!==null?null:U(le,ee,""+ce,De);if(typeof ce=="object"&&ce!==null){switch(ce.$$typeof){case O:return ce.key===st?Y(le,ee,ce,De):null;case B:return ce.key===st?fe(le,ee,ce,De):null;case ue:return st=ce._init,Ne(le,ee,st(ce._payload),De)}if(Jt(ce)||oe(ce))return st!==null?null:Ae(le,ee,ce,De,null);vu(le,ce)}return null}function Ye(le,ee,ce,De,st){if(typeof De=="string"&&De!==""||typeof De=="number")return le=le.get(ce)||null,U(ee,le,""+De,st);if(typeof De=="object"&&De!==null){switch(De.$$typeof){case O:return le=le.get(De.key===null?ce:De.key)||null,Y(ee,le,De,st);case B:return le=le.get(De.key===null?ce:De.key)||null,fe(ee,le,De,st);case ue:var vt=De._init;return Ye(le,ee,ce,vt(De._payload),st)}if(Jt(De)||oe(De))return le=le.get(ce)||null,Ae(ee,le,De,st,null);vu(ee,De)}return null}function nt(le,ee,ce,De){for(var st=null,vt=null,bt=ee,$t=ee=0,mr=null;bt!==null&&$t<ce.length;$t++){bt.index>$t?(mr=bt,bt=null):mr=bt.sibling;var mn=Ne(le,bt,ce[$t],De);if(mn===null){bt===null&&(bt=mr);break}s&&bt&&mn.alternate===null&&a(le,bt),ee=x(mn,ee,$t),vt===null?st=mn:vt.sibling=mn,vt=mn,bt=mr}if($t===ce.length)return f(le,bt),Dn&&_i(le,$t),st;if(bt===null){for(;$t<ce.length;$t++)bt=Oe(le,ce[$t],De),bt!==null&&(ee=x(bt,ee,$t),vt===null?st=bt:vt.sibling=bt,vt=bt);return Dn&&_i(le,$t),st}for(bt=k(le,bt);$t<ce.length;$t++)mr=Ye(bt,le,$t,ce[$t],De),mr!==null&&(s&&mr.alternate!==null&&bt.delete(mr.key===null?$t:mr.key),ee=x(mr,ee,$t),vt===null?st=mr:vt.sibling=mr,vt=mr);return s&&bt.forEach(function(Vs){return a(le,Vs)}),Dn&&_i(le,$t),st}function rt(le,ee,ce,De){var st=oe(ce);if(typeof st!="function")throw Error(n(150));if(ce=st.call(ce),ce==null)throw Error(n(151));for(var vt=st=null,bt=ee,$t=ee=0,mr=null,mn=ce.next();bt!==null&&!mn.done;$t++,mn=ce.next()){bt.index>$t?(mr=bt,bt=null):mr=bt.sibling;var Vs=Ne(le,bt,mn.value,De);if(Vs===null){bt===null&&(bt=mr);break}s&&bt&&Vs.alternate===null&&a(le,bt),ee=x(Vs,ee,$t),vt===null?st=Vs:vt.sibling=Vs,vt=Vs,bt=mr}if(mn.done)return f(le,bt),Dn&&_i(le,$t),st;if(bt===null){for(;!mn.done;$t++,mn=ce.next())mn=Oe(le,mn.value,De),mn!==null&&(ee=x(mn,ee,$t),vt===null?st=mn:vt.sibling=mn,vt=mn);return Dn&&_i(le,$t),st}for(bt=k(le,bt);!mn.done;$t++,mn=ce.next())mn=Ye(bt,le,$t,mn.value,De),mn!==null&&(s&&mn.alternate!==null&&bt.delete(mn.key===null?$t:mn.key),ee=x(mn,ee,$t),vt===null?st=mn:vt.sibling=mn,vt=mn);return s&&bt.forEach(function(yj){return a(le,yj)}),Dn&&_i(le,$t),st}function Jn(le,ee,ce,De){if(typeof ce=="object"&&ce!==null&&ce.type===$&&ce.key===null&&(ce=ce.props.children),typeof ce=="object"&&ce!==null){switch(ce.$$typeof){case O:e:{for(var st=ce.key,vt=ee;vt!==null;){if(vt.key===st){if(st=ce.type,st===$){if(vt.tag===7){f(le,vt.sibling),ee=v(vt,ce.props.children),ee.return=le,le=ee;break e}}else if(vt.elementType===st||typeof st=="object"&&st!==null&&st.$$typeof===ue&&Bw(st)===vt.type){f(le,vt.sibling),ee=v(vt,ce.props),ee.ref=Rl(le,vt,ce),ee.return=le,le=ee;break e}f(le,vt);break}else a(le,vt);vt=vt.sibling}ce.type===$?(ee=Ri(ce.props.children,le.mode,De,ce.key),ee.return=le,le=ee):(De=Wu(ce.type,ce.key,ce.props,null,le.mode,De),De.ref=Rl(le,ee,ce),De.return=le,le=De)}return I(le);case B:e:{for(vt=ce.key;ee!==null;){if(ee.key===vt)if(ee.tag===4&&ee.stateNode.containerInfo===ce.containerInfo&&ee.stateNode.implementation===ce.implementation){f(le,ee.sibling),ee=v(ee,ce.children||[]),ee.return=le,le=ee;break e}else{f(le,ee);break}else a(le,ee);ee=ee.sibling}ee=mp(ce,le.mode,De),ee.return=le,le=ee}return I(le);case ue:return vt=ce._init,Jn(le,ee,vt(ce._payload),De)}if(Jt(ce))return nt(le,ee,ce,De);if(oe(ce))return rt(le,ee,ce,De);vu(le,ce)}return typeof ce=="string"&&ce!==""||typeof ce=="number"?(ce=""+ce,ee!==null&&ee.tag===6?(f(le,ee.sibling),ee=v(ee,ce),ee.return=le,le=ee):(f(le,ee),ee=pp(ce,le.mode,De),ee.return=le,le=ee),I(le)):f(le,ee)}return Jn}var _a=Uw(!0),Hw=Uw(!1),bu=Ds(null),xu=null,Sa=null,_h=null;function Sh(){_h=Sa=xu=null}function Nh(s){var a=bu.current;$n(bu),s._currentValue=a}function Th(s,a,f){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===f)break;s=s.return}}function Na(s,a){xu=s,_h=Sa=null,s=s.dependencies,s!==null&&s.firstContext!==null&&((s.lanes&a)!==0&&(qr=!0),s.firstContext=null)}function go(s){var a=s._currentValue;if(_h!==s)if(s={context:s,memoizedValue:a,next:null},Sa===null){if(xu===null)throw Error(n(308));Sa=s,xu.dependencies={lanes:0,firstContext:s}}else Sa=Sa.next=s;return a}var Si=null;function jh(s){Si===null?Si=[s]:Si.push(s)}function Ww(s,a,f,k){var v=a.interleaved;return v===null?(f.next=f,jh(a)):(f.next=v.next,v.next=f),a.interleaved=f,gs(s,k)}function gs(s,a){s.lanes|=a;var f=s.alternate;for(f!==null&&(f.lanes|=a),f=s,s=s.return;s!==null;)s.childLanes|=a,f=s.alternate,f!==null&&(f.childLanes|=a),f=s,s=s.return;return f.tag===3?f.stateNode:null}var Bs=!1;function Ch(s){s.updateQueue={baseState:s.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Kw(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 ks(s,a){return{eventTime:s,lane:a,tag:0,payload:null,callback:null,next:null}}function Us(s,a,f){var k=s.updateQueue;if(k===null)return null;if(k=k.shared,(cn&2)!==0){var v=k.pending;return v===null?a.next=a:(a.next=v.next,v.next=a),k.pending=a,gs(s,f)}return v=k.interleaved,v===null?(a.next=a,jh(k)):(a.next=v.next,v.next=a),k.interleaved=a,gs(s,f)}function Eu(s,a,f){if(a=a.updateQueue,a!==null&&(a=a.shared,(f&4194240)!==0)){var k=a.lanes;k&=s.pendingLanes,f|=k,a.lanes=f,Co(s,f)}}function Zw(s,a){var f=s.updateQueue,k=s.alternate;if(k!==null&&(k=k.updateQueue,f===k)){var v=null,x=null;if(f=f.firstBaseUpdate,f!==null){do{var I={eventTime:f.eventTime,lane:f.lane,tag:f.tag,payload:f.payload,callback:f.callback,next:null};x===null?v=x=I:x=x.next=I,f=f.next}while(f!==null);x===null?v=x=a:x=x.next=a}else v=x=a;f={baseState:k.baseState,firstBaseUpdate:v,lastBaseUpdate:x,shared:k.shared,effects:k.effects},s.updateQueue=f;return}s=f.lastBaseUpdate,s===null?f.firstBaseUpdate=a:s.next=a,f.lastBaseUpdate=a}function _u(s,a,f,k){var v=s.updateQueue;Bs=!1;var x=v.firstBaseUpdate,I=v.lastBaseUpdate,U=v.shared.pending;if(U!==null){v.shared.pending=null;var Y=U,fe=Y.next;Y.next=null,I===null?x=fe:I.next=fe,I=Y;var Ae=s.alternate;Ae!==null&&(Ae=Ae.updateQueue,U=Ae.lastBaseUpdate,U!==I&&(U===null?Ae.firstBaseUpdate=fe:U.next=fe,Ae.lastBaseUpdate=Y))}if(x!==null){var Oe=v.baseState;I=0,Ae=fe=Y=null,U=x;do{var Ne=U.lane,Ye=U.eventTime;if((k&Ne)===Ne){Ae!==null&&(Ae=Ae.next={eventTime:Ye,lane:0,tag:U.tag,payload:U.payload,callback:U.callback,next:null});e:{var nt=s,rt=U;switch(Ne=a,Ye=f,rt.tag){case 1:if(nt=rt.payload,typeof nt=="function"){Oe=nt.call(Ye,Oe,Ne);break e}Oe=nt;break e;case 3:nt.flags=nt.flags&-65537|128;case 0:if(nt=rt.payload,Ne=typeof nt=="function"?nt.call(Ye,Oe,Ne):nt,Ne==null)break e;Oe=ne({},Oe,Ne);break e;case 2:Bs=!0}}U.callback!==null&&U.lane!==0&&(s.flags|=64,Ne=v.effects,Ne===null?v.effects=[U]:Ne.push(U))}else Ye={eventTime:Ye,lane:Ne,tag:U.tag,payload:U.payload,callback:U.callback,next:null},Ae===null?(fe=Ae=Ye,Y=Oe):Ae=Ae.next=Ye,I|=Ne;if(U=U.next,U===null){if(U=v.shared.pending,U===null)break;Ne=U,U=Ne.next,Ne.next=null,v.lastBaseUpdate=Ne,v.shared.pending=null}}while(!0);if(Ae===null&&(Y=Oe),v.baseState=Y,v.firstBaseUpdate=fe,v.lastBaseUpdate=Ae,a=v.shared.interleaved,a!==null){v=a;do I|=v.lane,v=v.next;while(v!==a)}else x===null&&(v.shared.lanes=0);ji|=I,s.lanes=I,s.memoizedState=Oe}}function qw(s,a,f){if(s=a.effects,a.effects=null,s!==null)for(a=0;a<s.length;a++){var k=s[a],v=k.callback;if(v!==null){if(k.callback=null,k=f,typeof v!="function")throw Error(n(191,v));v.call(k)}}}var $l={},Qo=Ds($l),Ol=Ds($l),Ml=Ds($l);function Ni(s){if(s===$l)throw Error(n(174));return s}function Ah(s,a){switch(Cn(Ml,a),Cn(Ol,s),Cn(Qo,$l),s=a.nodeType,s){case 9:case 11:a=(a=a.documentElement)?a.namespaceURI:dn(null,"");break;default:s=s===8?a.parentNode:a,a=s.namespaceURI||null,s=s.tagName,a=dn(a,s)}$n(Qo),Cn(Qo,a)}function Ta(){$n(Qo),$n(Ol),$n(Ml)}function Gw(s){Ni(Ml.current);var a=Ni(Qo.current),f=dn(a,s.type);a!==f&&(Cn(Ol,s),Cn(Qo,f))}function Ih(s){Ol.current===s&&($n(Qo),$n(Ol))}var Un=Ds(0);function Su(s){for(var a=s;a!==null;){if(a.tag===13){var f=a.memoizedState;if(f!==null&&(f=f.dehydrated,f===null||f.data==="$?"||f.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 Rh=[];function $h(){for(var s=0;s<Rh.length;s++)Rh[s]._workInProgressVersionPrimary=null;Rh.length=0}var Nu=R.ReactCurrentDispatcher,Oh=R.ReactCurrentBatchConfig,Ti=0,Hn=null,ir=null,hr=null,Tu=!1,Ll=!1,Pl=0,BT=0;function Tr(){throw Error(n(321))}function Mh(s,a){if(a===null)return!1;for(var f=0;f<a.length&&f<s.length;f++)if(!Ro(s[f],a[f]))return!1;return!0}function Lh(s,a,f,k,v,x){if(Ti=x,Hn=a,a.memoizedState=null,a.updateQueue=null,a.lanes=0,Nu.current=s===null||s.memoizedState===null?KT:ZT,s=f(k,v),Ll){x=0;do{if(Ll=!1,Pl=0,25<=x)throw Error(n(301));x+=1,hr=ir=null,a.updateQueue=null,Nu.current=qT,s=f(k,v)}while(Ll)}if(Nu.current=Au,a=ir!==null&&ir.next!==null,Ti=0,hr=ir=Hn=null,Tu=!1,a)throw Error(n(300));return s}function Ph(){var s=Pl!==0;return Pl=0,s}function Jo(){var s={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return hr===null?Hn.memoizedState=hr=s:hr=hr.next=s,hr}function ko(){if(ir===null){var s=Hn.alternate;s=s!==null?s.memoizedState:null}else s=ir.next;var a=hr===null?Hn.memoizedState:hr.next;if(a!==null)hr=a,ir=s;else{if(s===null)throw Error(n(310));ir=s,s={memoizedState:ir.memoizedState,baseState:ir.baseState,baseQueue:ir.baseQueue,queue:ir.queue,next:null},hr===null?Hn.memoizedState=hr=s:hr=hr.next=s}return hr}function Dl(s,a){return typeof a=="function"?a(s):a}function Dh(s){var a=ko(),f=a.queue;if(f===null)throw Error(n(311));f.lastRenderedReducer=s;var k=ir,v=k.baseQueue,x=f.pending;if(x!==null){if(v!==null){var I=v.next;v.next=x.next,x.next=I}k.baseQueue=v=x,f.pending=null}if(v!==null){x=v.next,k=k.baseState;var U=I=null,Y=null,fe=x;do{var Ae=fe.lane;if((Ti&Ae)===Ae)Y!==null&&(Y=Y.next={lane:0,action:fe.action,hasEagerState:fe.hasEagerState,eagerState:fe.eagerState,next:null}),k=fe.hasEagerState?fe.eagerState:s(k,fe.action);else{var Oe={lane:Ae,action:fe.action,hasEagerState:fe.hasEagerState,eagerState:fe.eagerState,next:null};Y===null?(U=Y=Oe,I=k):Y=Y.next=Oe,Hn.lanes|=Ae,ji|=Ae}fe=fe.next}while(fe!==null&&fe!==x);Y===null?I=k:Y.next=U,Ro(k,a.memoizedState)||(qr=!0),a.memoizedState=k,a.baseState=I,a.baseQueue=Y,f.lastRenderedState=k}if(s=f.interleaved,s!==null){v=s;do x=v.lane,Hn.lanes|=x,ji|=x,v=v.next;while(v!==s)}else v===null&&(f.lanes=0);return[a.memoizedState,f.dispatch]}function zh(s){var a=ko(),f=a.queue;if(f===null)throw Error(n(311));f.lastRenderedReducer=s;var k=f.dispatch,v=f.pending,x=a.memoizedState;if(v!==null){f.pending=null;var I=v=v.next;do x=s(x,I.action),I=I.next;while(I!==v);Ro(x,a.memoizedState)||(qr=!0),a.memoizedState=x,a.baseQueue===null&&(a.baseState=x),f.lastRenderedState=x}return[x,k]}function Vw(){}function Yw(s,a){var f=Hn,k=ko(),v=a(),x=!Ro(k.memoizedState,v);if(x&&(k.memoizedState=v,qr=!0),k=k.queue,Fh(Jw.bind(null,f,k,s),[s]),k.getSnapshot!==a||x||hr!==null&&hr.memoizedState.tag&1){if(f.flags|=2048,zl(9,Qw.bind(null,f,k,v,a),void 0,null),pr===null)throw Error(n(349));(Ti&30)!==0||Xw(f,a,v)}return v}function Xw(s,a,f){s.flags|=16384,s={getSnapshot:a,value:f},a=Hn.updateQueue,a===null?(a={lastEffect:null,stores:null},Hn.updateQueue=a,a.stores=[s]):(f=a.stores,f===null?a.stores=[s]:f.push(s))}function Qw(s,a,f,k){a.value=f,a.getSnapshot=k,ey(a)&&ty(s)}function Jw(s,a,f){return f(function(){ey(a)&&ty(s)})}function ey(s){var a=s.getSnapshot;s=s.value;try{var f=a();return!Ro(s,f)}catch{return!0}}function ty(s){var a=gs(s,1);a!==null&&Po(a,s,1,-1)}function ny(s){var a=Jo();return typeof s=="function"&&(s=s()),a.memoizedState=a.baseState=s,s={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:Dl,lastRenderedState:s},a.queue=s,s=s.dispatch=WT.bind(null,Hn,s),[a.memoizedState,s]}function zl(s,a,f,k){return s={tag:s,create:a,destroy:f,deps:k,next:null},a=Hn.updateQueue,a===null?(a={lastEffect:null,stores:null},Hn.updateQueue=a,a.lastEffect=s.next=s):(f=a.lastEffect,f===null?a.lastEffect=s.next=s:(k=f.next,f.next=s,s.next=k,a.lastEffect=s)),s}function ry(){return ko().memoizedState}function ju(s,a,f,k){var v=Jo();Hn.flags|=s,v.memoizedState=zl(1|a,f,void 0,k===void 0?null:k)}function Cu(s,a,f,k){var v=ko();k=k===void 0?null:k;var x=void 0;if(ir!==null){var I=ir.memoizedState;if(x=I.destroy,k!==null&&Mh(k,I.deps)){v.memoizedState=zl(a,f,x,k);return}}Hn.flags|=s,v.memoizedState=zl(1|a,f,x,k)}function oy(s,a){return ju(8390656,8,s,a)}function Fh(s,a){return Cu(2048,8,s,a)}function sy(s,a){return Cu(4,2,s,a)}function iy(s,a){return Cu(4,4,s,a)}function ay(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 ly(s,a,f){return f=f!=null?f.concat([s]):null,Cu(4,4,ay.bind(null,a,s),f)}function Bh(){}function cy(s,a){var f=ko();a=a===void 0?null:a;var k=f.memoizedState;return k!==null&&a!==null&&Mh(a,k[1])?k[0]:(f.memoizedState=[s,a],s)}function uy(s,a){var f=ko();a=a===void 0?null:a;var k=f.memoizedState;return k!==null&&a!==null&&Mh(a,k[1])?k[0]:(s=s(),f.memoizedState=[s,a],s)}function dy(s,a,f){return(Ti&21)===0?(s.baseState&&(s.baseState=!1,qr=!0),s.memoizedState=f):(Ro(f,a)||(f=Cs(),Hn.lanes|=f,ji|=f,s.baseState=!0),a)}function UT(s,a){var f=Je;Je=f!==0&&4>f?f:4,s(!0);var k=Oh.transition;Oh.transition={};try{s(!1),a()}finally{Je=f,Oh.transition=k}}function fy(){return ko().memoizedState}function HT(s,a,f){var k=Zs(s);if(f={lane:k,action:f,hasEagerState:!1,eagerState:null,next:null},hy(s))py(a,f);else if(f=Ww(s,a,f,k),f!==null){var v=Br();Po(f,s,k,v),my(f,a,k)}}function WT(s,a,f){var k=Zs(s),v={lane:k,action:f,hasEagerState:!1,eagerState:null,next:null};if(hy(s))py(a,v);else{var x=s.alternate;if(s.lanes===0&&(x===null||x.lanes===0)&&(x=a.lastRenderedReducer,x!==null))try{var I=a.lastRenderedState,U=x(I,f);if(v.hasEagerState=!0,v.eagerState=U,Ro(U,I)){var Y=a.interleaved;Y===null?(v.next=v,jh(a)):(v.next=Y.next,Y.next=v),a.interleaved=v;return}}catch{}finally{}f=Ww(s,a,v,k),f!==null&&(v=Br(),Po(f,s,k,v),my(f,a,k))}}function hy(s){var a=s.alternate;return s===Hn||a!==null&&a===Hn}function py(s,a){Ll=Tu=!0;var f=s.pending;f===null?a.next=a:(a.next=f.next,f.next=a),s.pending=a}function my(s,a,f){if((f&4194240)!==0){var k=a.lanes;k&=s.pendingLanes,f|=k,a.lanes=f,Co(s,f)}}var Au={readContext:go,useCallback:Tr,useContext:Tr,useEffect:Tr,useImperativeHandle:Tr,useInsertionEffect:Tr,useLayoutEffect:Tr,useMemo:Tr,useReducer:Tr,useRef:Tr,useState:Tr,useDebugValue:Tr,useDeferredValue:Tr,useTransition:Tr,useMutableSource:Tr,useSyncExternalStore:Tr,useId:Tr,unstable_isNewReconciler:!1},KT={readContext:go,useCallback:function(s,a){return Jo().memoizedState=[s,a===void 0?null:a],s},useContext:go,useEffect:oy,useImperativeHandle:function(s,a,f){return f=f!=null?f.concat([s]):null,ju(4194308,4,ay.bind(null,a,s),f)},useLayoutEffect:function(s,a){return ju(4194308,4,s,a)},useInsertionEffect:function(s,a){return ju(4,2,s,a)},useMemo:function(s,a){var f=Jo();return a=a===void 0?null:a,s=s(),f.memoizedState=[s,a],s},useReducer:function(s,a,f){var k=Jo();return a=f!==void 0?f(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=HT.bind(null,Hn,s),[k.memoizedState,s]},useRef:function(s){var a=Jo();return s={current:s},a.memoizedState=s},useState:ny,useDebugValue:Bh,useDeferredValue:function(s){return Jo().memoizedState=s},useTransition:function(){var s=ny(!1),a=s[0];return s=UT.bind(null,s[1]),Jo().memoizedState=s,[a,s]},useMutableSource:function(){},useSyncExternalStore:function(s,a,f){var k=Hn,v=Jo();if(Dn){if(f===void 0)throw Error(n(407));f=f()}else{if(f=a(),pr===null)throw Error(n(349));(Ti&30)!==0||Xw(k,a,f)}v.memoizedState=f;var x={value:f,getSnapshot:a};return v.queue=x,oy(Jw.bind(null,k,x,s),[s]),k.flags|=2048,zl(9,Qw.bind(null,k,x,f,a),void 0,null),f},useId:function(){var s=Jo(),a=pr.identifierPrefix;if(Dn){var f=ms,k=ps;f=(k&~(1<<32-tn(k)-1)).toString(32)+f,a=":"+a+"R"+f,f=Pl++,0<f&&(a+="H"+f.toString(32)),a+=":"}else f=BT++,a=":"+a+"r"+f.toString(32)+":";return s.memoizedState=a},unstable_isNewReconciler:!1},ZT={readContext:go,useCallback:cy,useContext:go,useEffect:Fh,useImperativeHandle:ly,useInsertionEffect:sy,useLayoutEffect:iy,useMemo:uy,useReducer:Dh,useRef:ry,useState:function(){return Dh(Dl)},useDebugValue:Bh,useDeferredValue:function(s){var a=ko();return dy(a,ir.memoizedState,s)},useTransition:function(){var s=Dh(Dl)[0],a=ko().memoizedState;return[s,a]},useMutableSource:Vw,useSyncExternalStore:Yw,useId:fy,unstable_isNewReconciler:!1},qT={readContext:go,useCallback:cy,useContext:go,useEffect:Fh,useImperativeHandle:ly,useInsertionEffect:sy,useLayoutEffect:iy,useMemo:uy,useReducer:zh,useRef:ry,useState:function(){return zh(Dl)},useDebugValue:Bh,useDeferredValue:function(s){var a=ko();return ir===null?a.memoizedState=s:dy(a,ir.memoizedState,s)},useTransition:function(){var s=zh(Dl)[0],a=ko().memoizedState;return[s,a]},useMutableSource:Vw,useSyncExternalStore:Yw,useId:fy,unstable_isNewReconciler:!1};function Oo(s,a){if(s&&s.defaultProps){a=ne({},a),s=s.defaultProps;for(var f in s)a[f]===void 0&&(a[f]=s[f]);return a}return a}function Uh(s,a,f,k){a=s.memoizedState,f=f(k,a),f=f==null?a:ne({},a,f),s.memoizedState=f,s.lanes===0&&(s.updateQueue.baseState=f)}var Iu={isMounted:function(s){return(s=s._reactInternals)?ur(s)===s:!1},enqueueSetState:function(s,a,f){s=s._reactInternals;var k=Br(),v=Zs(s),x=ks(k,v);x.payload=a,f!=null&&(x.callback=f),a=Us(s,x,v),a!==null&&(Po(a,s,v,k),Eu(a,s,v))},enqueueReplaceState:function(s,a,f){s=s._reactInternals;var k=Br(),v=Zs(s),x=ks(k,v);x.tag=1,x.payload=a,f!=null&&(x.callback=f),a=Us(s,x,v),a!==null&&(Po(a,s,v,k),Eu(a,s,v))},enqueueForceUpdate:function(s,a){s=s._reactInternals;var f=Br(),k=Zs(s),v=ks(f,k);v.tag=2,a!=null&&(v.callback=a),a=Us(s,v,k),a!==null&&(Po(a,s,k,f),Eu(a,s,k))}};function gy(s,a,f,k,v,x,I){return s=s.stateNode,typeof s.shouldComponentUpdate=="function"?s.shouldComponentUpdate(k,x,I):a.prototype&&a.prototype.isPureReactComponent?!Sl(f,k)||!Sl(v,x):!0}function ky(s,a,f){var k=!1,v=zs,x=a.contextType;return typeof x=="object"&&x!==null?x=go(x):(v=Zr(a)?xi:Nr.current,k=a.contextTypes,x=(k=k!=null)?va(s,v):zs),a=new a(f,x),s.memoizedState=a.state!==null&&a.state!==void 0?a.state:null,a.updater=Iu,s.stateNode=a,a._reactInternals=s,k&&(s=s.stateNode,s.__reactInternalMemoizedUnmaskedChildContext=v,s.__reactInternalMemoizedMaskedChildContext=x),a}function wy(s,a,f,k){s=a.state,typeof a.componentWillReceiveProps=="function"&&a.componentWillReceiveProps(f,k),typeof a.UNSAFE_componentWillReceiveProps=="function"&&a.UNSAFE_componentWillReceiveProps(f,k),a.state!==s&&Iu.enqueueReplaceState(a,a.state,null)}function Hh(s,a,f,k){var v=s.stateNode;v.props=f,v.state=s.memoizedState,v.refs={},Ch(s);var x=a.contextType;typeof x=="object"&&x!==null?v.context=go(x):(x=Zr(a)?xi:Nr.current,v.context=va(s,x)),v.state=s.memoizedState,x=a.getDerivedStateFromProps,typeof x=="function"&&(Uh(s,a,x,f),v.state=s.memoizedState),typeof a.getDerivedStateFromProps=="function"||typeof v.getSnapshotBeforeUpdate=="function"||typeof v.UNSAFE_componentWillMount!="function"&&typeof v.componentWillMount!="function"||(a=v.state,typeof v.componentWillMount=="function"&&v.componentWillMount(),typeof v.UNSAFE_componentWillMount=="function"&&v.UNSAFE_componentWillMount(),a!==v.state&&Iu.enqueueReplaceState(v,v.state,null),_u(s,f,v,k),v.state=s.memoizedState),typeof v.componentDidMount=="function"&&(s.flags|=4194308)}function ja(s,a){try{var f="",k=a;do f+=ge(k),k=k.return;while(k);var v=f}catch(x){v=`
40
+ Error generating stack: `+x.message+`
41
+ `+x.stack}return{value:s,source:a,stack:v,digest:null}}function Wh(s,a,f){return{value:s,source:null,stack:f??null,digest:a??null}}function Kh(s,a){try{console.error(a.value)}catch(f){setTimeout(function(){throw f})}}var GT=typeof WeakMap=="function"?WeakMap:Map;function yy(s,a,f){f=ks(-1,f),f.tag=3,f.payload={element:null};var k=a.value;return f.callback=function(){Du||(Du=!0,ip=k),Kh(s,a)},f}function vy(s,a,f){f=ks(-1,f),f.tag=3;var k=s.type.getDerivedStateFromError;if(typeof k=="function"){var v=a.value;f.payload=function(){return k(v)},f.callback=function(){Kh(s,a)}}var x=s.stateNode;return x!==null&&typeof x.componentDidCatch=="function"&&(f.callback=function(){Kh(s,a),typeof k!="function"&&(Ws===null?Ws=new Set([this]):Ws.add(this));var I=a.stack;this.componentDidCatch(a.value,{componentStack:I!==null?I:""})}),f}function by(s,a,f){var k=s.pingCache;if(k===null){k=s.pingCache=new GT;var v=new Set;k.set(a,v)}else v=k.get(a),v===void 0&&(v=new Set,k.set(a,v));v.has(f)||(v.add(f),s=lj.bind(null,s,a,f),a.then(s,s))}function xy(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 Ey(s,a,f,k,v){return(s.mode&1)===0?(s===a?s.flags|=65536:(s.flags|=128,f.flags|=131072,f.flags&=-52805,f.tag===1&&(f.alternate===null?f.tag=17:(a=ks(-1,1),a.tag=2,Us(f,a,1))),f.lanes|=1),s):(s.flags|=65536,s.lanes=v,s)}var VT=R.ReactCurrentOwner,qr=!1;function Fr(s,a,f,k){a.child=s===null?Hw(a,null,f,k):_a(a,s.child,f,k)}function _y(s,a,f,k,v){f=f.render;var x=a.ref;return Na(a,v),k=Lh(s,a,f,k,x,v),f=Ph(),s!==null&&!qr?(a.updateQueue=s.updateQueue,a.flags&=-2053,s.lanes&=~v,ws(s,a,v)):(Dn&&f&&yh(a),a.flags|=1,Fr(s,a,k,v),a.child)}function Sy(s,a,f,k,v){if(s===null){var x=f.type;return typeof x=="function"&&!hp(x)&&x.defaultProps===void 0&&f.compare===null&&f.defaultProps===void 0?(a.tag=15,a.type=x,Ny(s,a,x,k,v)):(s=Wu(f.type,null,k,a,a.mode,v),s.ref=a.ref,s.return=a,a.child=s)}if(x=s.child,(s.lanes&v)===0){var I=x.memoizedProps;if(f=f.compare,f=f!==null?f:Sl,f(I,k)&&s.ref===a.ref)return ws(s,a,v)}return a.flags|=1,s=Gs(x,k),s.ref=a.ref,s.return=a,a.child=s}function Ny(s,a,f,k,v){if(s!==null){var x=s.memoizedProps;if(Sl(x,k)&&s.ref===a.ref)if(qr=!1,a.pendingProps=k=x,(s.lanes&v)!==0)(s.flags&131072)!==0&&(qr=!0);else return a.lanes=s.lanes,ws(s,a,v)}return Zh(s,a,f,k,v)}function Ty(s,a,f){var k=a.pendingProps,v=k.children,x=s!==null?s.memoizedState:null;if(k.mode==="hidden")if((a.mode&1)===0)a.memoizedState={baseLanes:0,cachePool:null,transitions:null},Cn(Aa,lo),lo|=f;else{if((f&1073741824)===0)return s=x!==null?x.baseLanes|f:f,a.lanes=a.childLanes=1073741824,a.memoizedState={baseLanes:s,cachePool:null,transitions:null},a.updateQueue=null,Cn(Aa,lo),lo|=s,null;a.memoizedState={baseLanes:0,cachePool:null,transitions:null},k=x!==null?x.baseLanes:f,Cn(Aa,lo),lo|=k}else x!==null?(k=x.baseLanes|f,a.memoizedState=null):k=f,Cn(Aa,lo),lo|=k;return Fr(s,a,v,f),a.child}function jy(s,a){var f=a.ref;(s===null&&f!==null||s!==null&&s.ref!==f)&&(a.flags|=512,a.flags|=2097152)}function Zh(s,a,f,k,v){var x=Zr(f)?xi:Nr.current;return x=va(a,x),Na(a,v),f=Lh(s,a,f,k,x,v),k=Ph(),s!==null&&!qr?(a.updateQueue=s.updateQueue,a.flags&=-2053,s.lanes&=~v,ws(s,a,v)):(Dn&&k&&yh(a),a.flags|=1,Fr(s,a,f,v),a.child)}function Cy(s,a,f,k,v){if(Zr(f)){var x=!0;mu(a)}else x=!1;if(Na(a,v),a.stateNode===null)$u(s,a),ky(a,f,k),Hh(a,f,k,v),k=!0;else if(s===null){var I=a.stateNode,U=a.memoizedProps;I.props=U;var Y=I.context,fe=f.contextType;typeof fe=="object"&&fe!==null?fe=go(fe):(fe=Zr(f)?xi:Nr.current,fe=va(a,fe));var Ae=f.getDerivedStateFromProps,Oe=typeof Ae=="function"||typeof I.getSnapshotBeforeUpdate=="function";Oe||typeof I.UNSAFE_componentWillReceiveProps!="function"&&typeof I.componentWillReceiveProps!="function"||(U!==k||Y!==fe)&&wy(a,I,k,fe),Bs=!1;var Ne=a.memoizedState;I.state=Ne,_u(a,k,I,v),Y=a.memoizedState,U!==k||Ne!==Y||Kr.current||Bs?(typeof Ae=="function"&&(Uh(a,f,Ae,k),Y=a.memoizedState),(U=Bs||gy(a,f,U,k,Ne,Y,fe))?(Oe||typeof I.UNSAFE_componentWillMount!="function"&&typeof I.componentWillMount!="function"||(typeof I.componentWillMount=="function"&&I.componentWillMount(),typeof I.UNSAFE_componentWillMount=="function"&&I.UNSAFE_componentWillMount()),typeof I.componentDidMount=="function"&&(a.flags|=4194308)):(typeof I.componentDidMount=="function"&&(a.flags|=4194308),a.memoizedProps=k,a.memoizedState=Y),I.props=k,I.state=Y,I.context=fe,k=U):(typeof I.componentDidMount=="function"&&(a.flags|=4194308),k=!1)}else{I=a.stateNode,Kw(s,a),U=a.memoizedProps,fe=a.type===a.elementType?U:Oo(a.type,U),I.props=fe,Oe=a.pendingProps,Ne=I.context,Y=f.contextType,typeof Y=="object"&&Y!==null?Y=go(Y):(Y=Zr(f)?xi:Nr.current,Y=va(a,Y));var Ye=f.getDerivedStateFromProps;(Ae=typeof Ye=="function"||typeof I.getSnapshotBeforeUpdate=="function")||typeof I.UNSAFE_componentWillReceiveProps!="function"&&typeof I.componentWillReceiveProps!="function"||(U!==Oe||Ne!==Y)&&wy(a,I,k,Y),Bs=!1,Ne=a.memoizedState,I.state=Ne,_u(a,k,I,v);var nt=a.memoizedState;U!==Oe||Ne!==nt||Kr.current||Bs?(typeof Ye=="function"&&(Uh(a,f,Ye,k),nt=a.memoizedState),(fe=Bs||gy(a,f,fe,k,Ne,nt,Y)||!1)?(Ae||typeof I.UNSAFE_componentWillUpdate!="function"&&typeof I.componentWillUpdate!="function"||(typeof I.componentWillUpdate=="function"&&I.componentWillUpdate(k,nt,Y),typeof I.UNSAFE_componentWillUpdate=="function"&&I.UNSAFE_componentWillUpdate(k,nt,Y)),typeof I.componentDidUpdate=="function"&&(a.flags|=4),typeof I.getSnapshotBeforeUpdate=="function"&&(a.flags|=1024)):(typeof I.componentDidUpdate!="function"||U===s.memoizedProps&&Ne===s.memoizedState||(a.flags|=4),typeof I.getSnapshotBeforeUpdate!="function"||U===s.memoizedProps&&Ne===s.memoizedState||(a.flags|=1024),a.memoizedProps=k,a.memoizedState=nt),I.props=k,I.state=nt,I.context=Y,k=fe):(typeof I.componentDidUpdate!="function"||U===s.memoizedProps&&Ne===s.memoizedState||(a.flags|=4),typeof I.getSnapshotBeforeUpdate!="function"||U===s.memoizedProps&&Ne===s.memoizedState||(a.flags|=1024),k=!1)}return qh(s,a,f,k,x,v)}function qh(s,a,f,k,v,x){jy(s,a);var I=(a.flags&128)!==0;if(!k&&!I)return v&&Ow(a,f,!1),ws(s,a,x);k=a.stateNode,VT.current=a;var U=I&&typeof f.getDerivedStateFromError!="function"?null:k.render();return a.flags|=1,s!==null&&I?(a.child=_a(a,s.child,null,x),a.child=_a(a,null,U,x)):Fr(s,a,U,x),a.memoizedState=k.state,v&&Ow(a,f,!0),a.child}function Ay(s){var a=s.stateNode;a.pendingContext?Rw(s,a.pendingContext,a.pendingContext!==a.context):a.context&&Rw(s,a.context,!1),Ah(s,a.containerInfo)}function Iy(s,a,f,k,v){return Ea(),Eh(v),a.flags|=256,Fr(s,a,f,k),a.child}var Gh={dehydrated:null,treeContext:null,retryLane:0};function Vh(s){return{baseLanes:s,cachePool:null,transitions:null}}function Ry(s,a,f){var k=a.pendingProps,v=Un.current,x=!1,I=(a.flags&128)!==0,U;if((U=I)||(U=s!==null&&s.memoizedState===null?!1:(v&2)!==0),U?(x=!0,a.flags&=-129):(s===null||s.memoizedState!==null)&&(v|=1),Cn(Un,v&1),s===null)return xh(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):(I=k.children,s=k.fallback,x?(k=a.mode,x=a.child,I={mode:"hidden",children:I},(k&1)===0&&x!==null?(x.childLanes=0,x.pendingProps=I):x=Ku(I,k,0,null),s=Ri(s,k,f,null),x.return=a,s.return=a,x.sibling=s,a.child=x,a.child.memoizedState=Vh(f),a.memoizedState=Gh,s):Yh(a,I));if(v=s.memoizedState,v!==null&&(U=v.dehydrated,U!==null))return YT(s,a,I,k,U,v,f);if(x){x=k.fallback,I=a.mode,v=s.child,U=v.sibling;var Y={mode:"hidden",children:k.children};return(I&1)===0&&a.child!==v?(k=a.child,k.childLanes=0,k.pendingProps=Y,a.deletions=null):(k=Gs(v,Y),k.subtreeFlags=v.subtreeFlags&14680064),U!==null?x=Gs(U,x):(x=Ri(x,I,f,null),x.flags|=2),x.return=a,k.return=a,k.sibling=x,a.child=k,k=x,x=a.child,I=s.child.memoizedState,I=I===null?Vh(f):{baseLanes:I.baseLanes|f,cachePool:null,transitions:I.transitions},x.memoizedState=I,x.childLanes=s.childLanes&~f,a.memoizedState=Gh,k}return x=s.child,s=x.sibling,k=Gs(x,{mode:"visible",children:k.children}),(a.mode&1)===0&&(k.lanes=f),k.return=a,k.sibling=null,s!==null&&(f=a.deletions,f===null?(a.deletions=[s],a.flags|=16):f.push(s)),a.child=k,a.memoizedState=null,k}function Yh(s,a){return a=Ku({mode:"visible",children:a},s.mode,0,null),a.return=s,s.child=a}function Ru(s,a,f,k){return k!==null&&Eh(k),_a(a,s.child,null,f),s=Yh(a,a.pendingProps.children),s.flags|=2,a.memoizedState=null,s}function YT(s,a,f,k,v,x,I){if(f)return a.flags&256?(a.flags&=-257,k=Wh(Error(n(422))),Ru(s,a,I,k)):a.memoizedState!==null?(a.child=s.child,a.flags|=128,null):(x=k.fallback,v=a.mode,k=Ku({mode:"visible",children:k.children},v,0,null),x=Ri(x,v,I,null),x.flags|=2,k.return=a,x.return=a,k.sibling=x,a.child=k,(a.mode&1)!==0&&_a(a,s.child,null,I),a.child.memoizedState=Vh(I),a.memoizedState=Gh,x);if((a.mode&1)===0)return Ru(s,a,I,null);if(v.data==="$!"){if(k=v.nextSibling&&v.nextSibling.dataset,k)var U=k.dgst;return k=U,x=Error(n(419)),k=Wh(x,k,void 0),Ru(s,a,I,k)}if(U=(I&s.childLanes)!==0,qr||U){if(k=pr,k!==null){switch(I&-I){case 4:v=2;break;case 16:v=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:v=32;break;case 536870912:v=268435456;break;default:v=0}v=(v&(k.suspendedLanes|I))!==0?0:v,v!==0&&v!==x.retryLane&&(x.retryLane=v,gs(s,v),Po(k,s,v,-1))}return fp(),k=Wh(Error(n(421))),Ru(s,a,I,k)}return v.data==="$?"?(a.flags|=128,a.child=s.child,a=cj.bind(null,s),v._reactRetry=a,null):(s=x.treeContext,ao=Ps(v.nextSibling),io=a,Dn=!0,$o=null,s!==null&&(po[mo++]=ps,po[mo++]=ms,po[mo++]=Ei,ps=s.id,ms=s.overflow,Ei=a),a=Yh(a,k.children),a.flags|=4096,a)}function $y(s,a,f){s.lanes|=a;var k=s.alternate;k!==null&&(k.lanes|=a),Th(s.return,a,f)}function Xh(s,a,f,k,v){var x=s.memoizedState;x===null?s.memoizedState={isBackwards:a,rendering:null,renderingStartTime:0,last:k,tail:f,tailMode:v}:(x.isBackwards=a,x.rendering=null,x.renderingStartTime=0,x.last=k,x.tail=f,x.tailMode=v)}function Oy(s,a,f){var k=a.pendingProps,v=k.revealOrder,x=k.tail;if(Fr(s,a,k.children,f),k=Un.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&&$y(s,f,a);else if(s.tag===19)$y(s,f,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(Cn(Un,k),(a.mode&1)===0)a.memoizedState=null;else switch(v){case"forwards":for(f=a.child,v=null;f!==null;)s=f.alternate,s!==null&&Su(s)===null&&(v=f),f=f.sibling;f=v,f===null?(v=a.child,a.child=null):(v=f.sibling,f.sibling=null),Xh(a,!1,v,f,x);break;case"backwards":for(f=null,v=a.child,a.child=null;v!==null;){if(s=v.alternate,s!==null&&Su(s)===null){a.child=v;break}s=v.sibling,v.sibling=f,f=v,v=s}Xh(a,!0,f,null,x);break;case"together":Xh(a,!1,null,null,void 0);break;default:a.memoizedState=null}return a.child}function $u(s,a){(a.mode&1)===0&&s!==null&&(s.alternate=null,a.alternate=null,a.flags|=2)}function ws(s,a,f){if(s!==null&&(a.dependencies=s.dependencies),ji|=a.lanes,(f&a.childLanes)===0)return null;if(s!==null&&a.child!==s.child)throw Error(n(153));if(a.child!==null){for(s=a.child,f=Gs(s,s.pendingProps),a.child=f,f.return=a;s.sibling!==null;)s=s.sibling,f=f.sibling=Gs(s,s.pendingProps),f.return=a;f.sibling=null}return a.child}function XT(s,a,f){switch(a.tag){case 3:Ay(a),Ea();break;case 5:Gw(a);break;case 1:Zr(a.type)&&mu(a);break;case 4:Ah(a,a.stateNode.containerInfo);break;case 10:var k=a.type._context,v=a.memoizedProps.value;Cn(bu,k._currentValue),k._currentValue=v;break;case 13:if(k=a.memoizedState,k!==null)return k.dehydrated!==null?(Cn(Un,Un.current&1),a.flags|=128,null):(f&a.child.childLanes)!==0?Ry(s,a,f):(Cn(Un,Un.current&1),s=ws(s,a,f),s!==null?s.sibling:null);Cn(Un,Un.current&1);break;case 19:if(k=(f&a.childLanes)!==0,(s.flags&128)!==0){if(k)return Oy(s,a,f);a.flags|=128}if(v=a.memoizedState,v!==null&&(v.rendering=null,v.tail=null,v.lastEffect=null),Cn(Un,Un.current),k)break;return null;case 22:case 23:return a.lanes=0,Ty(s,a,f)}return ws(s,a,f)}var My,Qh,Ly,Py;My=function(s,a){for(var f=a.child;f!==null;){if(f.tag===5||f.tag===6)s.appendChild(f.stateNode);else if(f.tag!==4&&f.child!==null){f.child.return=f,f=f.child;continue}if(f===a)break;for(;f.sibling===null;){if(f.return===null||f.return===a)return;f=f.return}f.sibling.return=f.return,f=f.sibling}},Qh=function(){},Ly=function(s,a,f,k){var v=s.memoizedProps;if(v!==k){s=a.stateNode,Ni(Qo.current);var x=null;switch(f){case"input":v=Fe(s,v),k=Fe(s,k),x=[];break;case"select":v=ne({},v,{value:void 0}),k=ne({},k,{value:void 0}),x=[];break;case"textarea":v=kt(s,v),k=kt(s,k),x=[];break;default:typeof v.onClick!="function"&&typeof k.onClick=="function"&&(s.onclick=fu)}qn(f,k);var I;f=null;for(fe in v)if(!k.hasOwnProperty(fe)&&v.hasOwnProperty(fe)&&v[fe]!=null)if(fe==="style"){var U=v[fe];for(I in U)U.hasOwnProperty(I)&&(f||(f={}),f[I]="")}else fe!=="dangerouslySetInnerHTML"&&fe!=="children"&&fe!=="suppressContentEditableWarning"&&fe!=="suppressHydrationWarning"&&fe!=="autoFocus"&&(o.hasOwnProperty(fe)?x||(x=[]):(x=x||[]).push(fe,null));for(fe in k){var Y=k[fe];if(U=v!=null?v[fe]:void 0,k.hasOwnProperty(fe)&&Y!==U&&(Y!=null||U!=null))if(fe==="style")if(U){for(I in U)!U.hasOwnProperty(I)||Y&&Y.hasOwnProperty(I)||(f||(f={}),f[I]="");for(I in Y)Y.hasOwnProperty(I)&&U[I]!==Y[I]&&(f||(f={}),f[I]=Y[I])}else f||(x||(x=[]),x.push(fe,f)),f=Y;else fe==="dangerouslySetInnerHTML"?(Y=Y?Y.__html:void 0,U=U?U.__html:void 0,Y!=null&&U!==Y&&(x=x||[]).push(fe,Y)):fe==="children"?typeof Y!="string"&&typeof Y!="number"||(x=x||[]).push(fe,""+Y):fe!=="suppressContentEditableWarning"&&fe!=="suppressHydrationWarning"&&(o.hasOwnProperty(fe)?(Y!=null&&fe==="onScroll"&&Rn("scroll",s),x||U===Y||(x=[])):(x=x||[]).push(fe,Y))}f&&(x=x||[]).push("style",f);var fe=x;(a.updateQueue=fe)&&(a.flags|=4)}},Py=function(s,a,f,k){f!==k&&(a.flags|=4)};function Fl(s,a){if(!Dn)switch(s.tailMode){case"hidden":a=s.tail;for(var f=null;a!==null;)a.alternate!==null&&(f=a),a=a.sibling;f===null?s.tail=null:f.sibling=null;break;case"collapsed":f=s.tail;for(var k=null;f!==null;)f.alternate!==null&&(k=f),f=f.sibling;k===null?a||s.tail===null?s.tail=null:s.tail.sibling=null:k.sibling=null}}function jr(s){var a=s.alternate!==null&&s.alternate.child===s.child,f=0,k=0;if(a)for(var v=s.child;v!==null;)f|=v.lanes|v.childLanes,k|=v.subtreeFlags&14680064,k|=v.flags&14680064,v.return=s,v=v.sibling;else for(v=s.child;v!==null;)f|=v.lanes|v.childLanes,k|=v.subtreeFlags,k|=v.flags,v.return=s,v=v.sibling;return s.subtreeFlags|=k,s.childLanes=f,a}function QT(s,a,f){var k=a.pendingProps;switch(vh(a),a.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return jr(a),null;case 1:return Zr(a.type)&&pu(),jr(a),null;case 3:return k=a.stateNode,Ta(),$n(Kr),$n(Nr),$h(),k.pendingContext&&(k.context=k.pendingContext,k.pendingContext=null),(s===null||s.child===null)&&(yu(a)?a.flags|=4:s===null||s.memoizedState.isDehydrated&&(a.flags&256)===0||(a.flags|=1024,$o!==null&&(cp($o),$o=null))),Qh(s,a),jr(a),null;case 5:Ih(a);var v=Ni(Ml.current);if(f=a.type,s!==null&&a.stateNode!=null)Ly(s,a,f,k,v),s.ref!==a.ref&&(a.flags|=512,a.flags|=2097152);else{if(!k){if(a.stateNode===null)throw Error(n(166));return jr(a),null}if(s=Ni(Qo.current),yu(a)){k=a.stateNode,f=a.type;var x=a.memoizedProps;switch(k[Xo]=a,k[Al]=x,s=(a.mode&1)!==0,f){case"dialog":Rn("cancel",k),Rn("close",k);break;case"iframe":case"object":case"embed":Rn("load",k);break;case"video":case"audio":for(v=0;v<Tl.length;v++)Rn(Tl[v],k);break;case"source":Rn("error",k);break;case"img":case"image":case"link":Rn("error",k),Rn("load",k);break;case"details":Rn("toggle",k);break;case"input":Pe(k,x),Rn("invalid",k);break;case"select":k._wrapperState={wasMultiple:!!x.multiple},Rn("invalid",k);break;case"textarea":ot(k,x),Rn("invalid",k)}qn(f,x),v=null;for(var I in x)if(x.hasOwnProperty(I)){var U=x[I];I==="children"?typeof U=="string"?k.textContent!==U&&(x.suppressHydrationWarning!==!0&&du(k.textContent,U,s),v=["children",U]):typeof U=="number"&&k.textContent!==""+U&&(x.suppressHydrationWarning!==!0&&du(k.textContent,U,s),v=["children",""+U]):o.hasOwnProperty(I)&&U!=null&&I==="onScroll"&&Rn("scroll",k)}switch(f){case"input":Z(k),ut(k,x,!0);break;case"textarea":Z(k),Tt(k);break;case"select":case"option":break;default:typeof x.onClick=="function"&&(k.onclick=fu)}k=v,a.updateQueue=k,k!==null&&(a.flags|=4)}else{I=v.nodeType===9?v:v.ownerDocument,s==="http://www.w3.org/1999/xhtml"&&(s=Et(f)),s==="http://www.w3.org/1999/xhtml"?f==="script"?(s=I.createElement("div"),s.innerHTML="<script><\/script>",s=s.removeChild(s.firstChild)):typeof k.is=="string"?s=I.createElement(f,{is:k.is}):(s=I.createElement(f),f==="select"&&(I=s,k.multiple?I.multiple=!0:k.size&&(I.size=k.size))):s=I.createElementNS(s,f),s[Xo]=a,s[Al]=k,My(s,a,!1,!1),a.stateNode=s;e:{switch(I=zt(f,k),f){case"dialog":Rn("cancel",s),Rn("close",s),v=k;break;case"iframe":case"object":case"embed":Rn("load",s),v=k;break;case"video":case"audio":for(v=0;v<Tl.length;v++)Rn(Tl[v],s);v=k;break;case"source":Rn("error",s),v=k;break;case"img":case"image":case"link":Rn("error",s),Rn("load",s),v=k;break;case"details":Rn("toggle",s),v=k;break;case"input":Pe(s,k),v=Fe(s,k),Rn("invalid",s);break;case"option":v=k;break;case"select":s._wrapperState={wasMultiple:!!k.multiple},v=ne({},k,{value:void 0}),Rn("invalid",s);break;case"textarea":ot(s,k),v=kt(s,k),Rn("invalid",s);break;default:v=k}qn(f,v),U=v;for(x in U)if(U.hasOwnProperty(x)){var Y=U[x];x==="style"?Ft(s,Y):x==="dangerouslySetInnerHTML"?(Y=Y?Y.__html:void 0,Y!=null&&ve(s,Y)):x==="children"?typeof Y=="string"?(f!=="textarea"||Y!=="")&&tt(s,Y):typeof Y=="number"&&tt(s,""+Y):x!=="suppressContentEditableWarning"&&x!=="suppressHydrationWarning"&&x!=="autoFocus"&&(o.hasOwnProperty(x)?Y!=null&&x==="onScroll"&&Rn("scroll",s):Y!=null&&T(s,x,Y,I))}switch(f){case"input":Z(s),ut(s,k,!1);break;case"textarea":Z(s),Tt(s);break;case"option":k.value!=null&&s.setAttribute("value",""+Q(k.value));break;case"select":s.multiple=!!k.multiple,x=k.value,x!=null?xt(s,!!k.multiple,x,!1):k.defaultValue!=null&&xt(s,!!k.multiple,k.defaultValue,!0);break;default:typeof v.onClick=="function"&&(s.onclick=fu)}switch(f){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 jr(a),null;case 6:if(s&&a.stateNode!=null)Py(s,a,s.memoizedProps,k);else{if(typeof k!="string"&&a.stateNode===null)throw Error(n(166));if(f=Ni(Ml.current),Ni(Qo.current),yu(a)){if(k=a.stateNode,f=a.memoizedProps,k[Xo]=a,(x=k.nodeValue!==f)&&(s=io,s!==null))switch(s.tag){case 3:du(k.nodeValue,f,(s.mode&1)!==0);break;case 5:s.memoizedProps.suppressHydrationWarning!==!0&&du(k.nodeValue,f,(s.mode&1)!==0)}x&&(a.flags|=4)}else k=(f.nodeType===9?f:f.ownerDocument).createTextNode(k),k[Xo]=a,a.stateNode=k}return jr(a),null;case 13:if($n(Un),k=a.memoizedState,s===null||s.memoizedState!==null&&s.memoizedState.dehydrated!==null){if(Dn&&ao!==null&&(a.mode&1)!==0&&(a.flags&128)===0)Fw(),Ea(),a.flags|=98560,x=!1;else if(x=yu(a),k!==null&&k.dehydrated!==null){if(s===null){if(!x)throw Error(n(318));if(x=a.memoizedState,x=x!==null?x.dehydrated:null,!x)throw Error(n(317));x[Xo]=a}else Ea(),(a.flags&128)===0&&(a.memoizedState=null),a.flags|=4;jr(a),x=!1}else $o!==null&&(cp($o),$o=null),x=!0;if(!x)return a.flags&65536?a:null}return(a.flags&128)!==0?(a.lanes=f,a):(k=k!==null,k!==(s!==null&&s.memoizedState!==null)&&k&&(a.child.flags|=8192,(a.mode&1)!==0&&(s===null||(Un.current&1)!==0?ar===0&&(ar=3):fp())),a.updateQueue!==null&&(a.flags|=4),jr(a),null);case 4:return Ta(),Qh(s,a),s===null&&jl(a.stateNode.containerInfo),jr(a),null;case 10:return Nh(a.type._context),jr(a),null;case 17:return Zr(a.type)&&pu(),jr(a),null;case 19:if($n(Un),x=a.memoizedState,x===null)return jr(a),null;if(k=(a.flags&128)!==0,I=x.rendering,I===null)if(k)Fl(x,!1);else{if(ar!==0||s!==null&&(s.flags&128)!==0)for(s=a.child;s!==null;){if(I=Su(s),I!==null){for(a.flags|=128,Fl(x,!1),k=I.updateQueue,k!==null&&(a.updateQueue=k,a.flags|=4),a.subtreeFlags=0,k=f,f=a.child;f!==null;)x=f,s=k,x.flags&=14680066,I=x.alternate,I===null?(x.childLanes=0,x.lanes=s,x.child=null,x.subtreeFlags=0,x.memoizedProps=null,x.memoizedState=null,x.updateQueue=null,x.dependencies=null,x.stateNode=null):(x.childLanes=I.childLanes,x.lanes=I.lanes,x.child=I.child,x.subtreeFlags=0,x.deletions=null,x.memoizedProps=I.memoizedProps,x.memoizedState=I.memoizedState,x.updateQueue=I.updateQueue,x.type=I.type,s=I.dependencies,x.dependencies=s===null?null:{lanes:s.lanes,firstContext:s.firstContext}),f=f.sibling;return Cn(Un,Un.current&1|2),a.child}s=s.sibling}x.tail!==null&&Vt()>Ia&&(a.flags|=128,k=!0,Fl(x,!1),a.lanes=4194304)}else{if(!k)if(s=Su(I),s!==null){if(a.flags|=128,k=!0,f=s.updateQueue,f!==null&&(a.updateQueue=f,a.flags|=4),Fl(x,!0),x.tail===null&&x.tailMode==="hidden"&&!I.alternate&&!Dn)return jr(a),null}else 2*Vt()-x.renderingStartTime>Ia&&f!==1073741824&&(a.flags|=128,k=!0,Fl(x,!1),a.lanes=4194304);x.isBackwards?(I.sibling=a.child,a.child=I):(f=x.last,f!==null?f.sibling=I:a.child=I,x.last=I)}return x.tail!==null?(a=x.tail,x.rendering=a,x.tail=a.sibling,x.renderingStartTime=Vt(),a.sibling=null,f=Un.current,Cn(Un,k?f&1|2:f&1),a):(jr(a),null);case 22:case 23:return dp(),k=a.memoizedState!==null,s!==null&&s.memoizedState!==null!==k&&(a.flags|=8192),k&&(a.mode&1)!==0?(lo&1073741824)!==0&&(jr(a),a.subtreeFlags&6&&(a.flags|=8192)):jr(a),null;case 24:return null;case 25:return null}throw Error(n(156,a.tag))}function JT(s,a){switch(vh(a),a.tag){case 1:return Zr(a.type)&&pu(),s=a.flags,s&65536?(a.flags=s&-65537|128,a):null;case 3:return Ta(),$n(Kr),$n(Nr),$h(),s=a.flags,(s&65536)!==0&&(s&128)===0?(a.flags=s&-65537|128,a):null;case 5:return Ih(a),null;case 13:if($n(Un),s=a.memoizedState,s!==null&&s.dehydrated!==null){if(a.alternate===null)throw Error(n(340));Ea()}return s=a.flags,s&65536?(a.flags=s&-65537|128,a):null;case 19:return $n(Un),null;case 4:return Ta(),null;case 10:return Nh(a.type._context),null;case 22:case 23:return dp(),null;case 24:return null;default:return null}}var Ou=!1,Cr=!1,ej=typeof WeakSet=="function"?WeakSet:Set,et=null;function Ca(s,a){var f=s.ref;if(f!==null)if(typeof f=="function")try{f(null)}catch(k){Vn(s,a,k)}else f.current=null}function Jh(s,a,f){try{f()}catch(k){Vn(s,a,k)}}var Dy=!1;function tj(s,a){if(dh=ta,s=gw(),rh(s)){if("selectionStart"in s)var f={start:s.selectionStart,end:s.selectionEnd};else e:{f=(f=s.ownerDocument)&&f.defaultView||window;var k=f.getSelection&&f.getSelection();if(k&&k.rangeCount!==0){f=k.anchorNode;var v=k.anchorOffset,x=k.focusNode;k=k.focusOffset;try{f.nodeType,x.nodeType}catch{f=null;break e}var I=0,U=-1,Y=-1,fe=0,Ae=0,Oe=s,Ne=null;t:for(;;){for(var Ye;Oe!==f||v!==0&&Oe.nodeType!==3||(U=I+v),Oe!==x||k!==0&&Oe.nodeType!==3||(Y=I+k),Oe.nodeType===3&&(I+=Oe.nodeValue.length),(Ye=Oe.firstChild)!==null;)Ne=Oe,Oe=Ye;for(;;){if(Oe===s)break t;if(Ne===f&&++fe===v&&(U=I),Ne===x&&++Ae===k&&(Y=I),(Ye=Oe.nextSibling)!==null)break;Oe=Ne,Ne=Oe.parentNode}Oe=Ye}f=U===-1||Y===-1?null:{start:U,end:Y}}else f=null}f=f||{start:0,end:0}}else f=null;for(fh={focusedElem:s,selectionRange:f},ta=!1,et=a;et!==null;)if(a=et,s=a.child,(a.subtreeFlags&1028)!==0&&s!==null)s.return=a,et=s;else for(;et!==null;){a=et;try{var nt=a.alternate;if((a.flags&1024)!==0)switch(a.tag){case 0:case 11:case 15:break;case 1:if(nt!==null){var rt=nt.memoizedProps,Jn=nt.memoizedState,le=a.stateNode,ee=le.getSnapshotBeforeUpdate(a.elementType===a.type?rt:Oo(a.type,rt),Jn);le.__reactInternalSnapshotBeforeUpdate=ee}break;case 3:var ce=a.stateNode.containerInfo;ce.nodeType===1?ce.textContent="":ce.nodeType===9&&ce.documentElement&&ce.removeChild(ce.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(n(163))}}catch(De){Vn(a,a.return,De)}if(s=a.sibling,s!==null){s.return=a.return,et=s;break}et=a.return}return nt=Dy,Dy=!1,nt}function Bl(s,a,f){var k=a.updateQueue;if(k=k!==null?k.lastEffect:null,k!==null){var v=k=k.next;do{if((v.tag&s)===s){var x=v.destroy;v.destroy=void 0,x!==void 0&&Jh(a,f,x)}v=v.next}while(v!==k)}}function Mu(s,a){if(a=a.updateQueue,a=a!==null?a.lastEffect:null,a!==null){var f=a=a.next;do{if((f.tag&s)===s){var k=f.create;f.destroy=k()}f=f.next}while(f!==a)}}function ep(s){var a=s.ref;if(a!==null){var f=s.stateNode;switch(s.tag){case 5:s=f;break;default:s=f}typeof a=="function"?a(s):a.current=s}}function zy(s){var a=s.alternate;a!==null&&(s.alternate=null,zy(a)),s.child=null,s.deletions=null,s.sibling=null,s.tag===5&&(a=s.stateNode,a!==null&&(delete a[Xo],delete a[Al],delete a[gh],delete a[PT],delete a[DT])),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 Fy(s){return s.tag===5||s.tag===3||s.tag===4}function By(s){e:for(;;){for(;s.sibling===null;){if(s.return===null||Fy(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 tp(s,a,f){var k=s.tag;if(k===5||k===6)s=s.stateNode,a?f.nodeType===8?f.parentNode.insertBefore(s,a):f.insertBefore(s,a):(f.nodeType===8?(a=f.parentNode,a.insertBefore(s,f)):(a=f,a.appendChild(s)),f=f._reactRootContainer,f!=null||a.onclick!==null||(a.onclick=fu));else if(k!==4&&(s=s.child,s!==null))for(tp(s,a,f),s=s.sibling;s!==null;)tp(s,a,f),s=s.sibling}function np(s,a,f){var k=s.tag;if(k===5||k===6)s=s.stateNode,a?f.insertBefore(s,a):f.appendChild(s);else if(k!==4&&(s=s.child,s!==null))for(np(s,a,f),s=s.sibling;s!==null;)np(s,a,f),s=s.sibling}var xr=null,Mo=!1;function Hs(s,a,f){for(f=f.child;f!==null;)Uy(s,a,f),f=f.sibling}function Uy(s,a,f){if(pt&&typeof pt.onCommitFiberUnmount=="function")try{pt.onCommitFiberUnmount(ht,f)}catch{}switch(f.tag){case 5:Cr||Ca(f,a);case 6:var k=xr,v=Mo;xr=null,Hs(s,a,f),xr=k,Mo=v,xr!==null&&(Mo?(s=xr,f=f.stateNode,s.nodeType===8?s.parentNode.removeChild(f):s.removeChild(f)):xr.removeChild(f.stateNode));break;case 18:xr!==null&&(Mo?(s=xr,f=f.stateNode,s.nodeType===8?mh(s.parentNode,f):s.nodeType===1&&mh(s,f),ls(s)):mh(xr,f.stateNode));break;case 4:k=xr,v=Mo,xr=f.stateNode.containerInfo,Mo=!0,Hs(s,a,f),xr=k,Mo=v;break;case 0:case 11:case 14:case 15:if(!Cr&&(k=f.updateQueue,k!==null&&(k=k.lastEffect,k!==null))){v=k=k.next;do{var x=v,I=x.destroy;x=x.tag,I!==void 0&&((x&2)!==0||(x&4)!==0)&&Jh(f,a,I),v=v.next}while(v!==k)}Hs(s,a,f);break;case 1:if(!Cr&&(Ca(f,a),k=f.stateNode,typeof k.componentWillUnmount=="function"))try{k.props=f.memoizedProps,k.state=f.memoizedState,k.componentWillUnmount()}catch(U){Vn(f,a,U)}Hs(s,a,f);break;case 21:Hs(s,a,f);break;case 22:f.mode&1?(Cr=(k=Cr)||f.memoizedState!==null,Hs(s,a,f),Cr=k):Hs(s,a,f);break;default:Hs(s,a,f)}}function Hy(s){var a=s.updateQueue;if(a!==null){s.updateQueue=null;var f=s.stateNode;f===null&&(f=s.stateNode=new ej),a.forEach(function(k){var v=uj.bind(null,s,k);f.has(k)||(f.add(k),k.then(v,v))})}}function Lo(s,a){var f=a.deletions;if(f!==null)for(var k=0;k<f.length;k++){var v=f[k];try{var x=s,I=a,U=I;e:for(;U!==null;){switch(U.tag){case 5:xr=U.stateNode,Mo=!1;break e;case 3:xr=U.stateNode.containerInfo,Mo=!0;break e;case 4:xr=U.stateNode.containerInfo,Mo=!0;break e}U=U.return}if(xr===null)throw Error(n(160));Uy(x,I,v),xr=null,Mo=!1;var Y=v.alternate;Y!==null&&(Y.return=null),v.return=null}catch(fe){Vn(v,a,fe)}}if(a.subtreeFlags&12854)for(a=a.child;a!==null;)Wy(a,s),a=a.sibling}function Wy(s,a){var f=s.alternate,k=s.flags;switch(s.tag){case 0:case 11:case 14:case 15:if(Lo(a,s),es(s),k&4){try{Bl(3,s,s.return),Mu(3,s)}catch(rt){Vn(s,s.return,rt)}try{Bl(5,s,s.return)}catch(rt){Vn(s,s.return,rt)}}break;case 1:Lo(a,s),es(s),k&512&&f!==null&&Ca(f,f.return);break;case 5:if(Lo(a,s),es(s),k&512&&f!==null&&Ca(f,f.return),s.flags&32){var v=s.stateNode;try{tt(v,"")}catch(rt){Vn(s,s.return,rt)}}if(k&4&&(v=s.stateNode,v!=null)){var x=s.memoizedProps,I=f!==null?f.memoizedProps:x,U=s.type,Y=s.updateQueue;if(s.updateQueue=null,Y!==null)try{U==="input"&&x.type==="radio"&&x.name!=null&&We(v,x),zt(U,I);var fe=zt(U,x);for(I=0;I<Y.length;I+=2){var Ae=Y[I],Oe=Y[I+1];Ae==="style"?Ft(v,Oe):Ae==="dangerouslySetInnerHTML"?ve(v,Oe):Ae==="children"?tt(v,Oe):T(v,Ae,Oe,fe)}switch(U){case"input":Ht(v,x);break;case"textarea":dt(v,x);break;case"select":var Ne=v._wrapperState.wasMultiple;v._wrapperState.wasMultiple=!!x.multiple;var Ye=x.value;Ye!=null?xt(v,!!x.multiple,Ye,!1):Ne!==!!x.multiple&&(x.defaultValue!=null?xt(v,!!x.multiple,x.defaultValue,!0):xt(v,!!x.multiple,x.multiple?[]:"",!1))}v[Al]=x}catch(rt){Vn(s,s.return,rt)}}break;case 6:if(Lo(a,s),es(s),k&4){if(s.stateNode===null)throw Error(n(162));v=s.stateNode,x=s.memoizedProps;try{v.nodeValue=x}catch(rt){Vn(s,s.return,rt)}}break;case 3:if(Lo(a,s),es(s),k&4&&f!==null&&f.memoizedState.isDehydrated)try{ls(a.containerInfo)}catch(rt){Vn(s,s.return,rt)}break;case 4:Lo(a,s),es(s);break;case 13:Lo(a,s),es(s),v=s.child,v.flags&8192&&(x=v.memoizedState!==null,v.stateNode.isHidden=x,!x||v.alternate!==null&&v.alternate.memoizedState!==null||(sp=Vt())),k&4&&Hy(s);break;case 22:if(Ae=f!==null&&f.memoizedState!==null,s.mode&1?(Cr=(fe=Cr)||Ae,Lo(a,s),Cr=fe):Lo(a,s),es(s),k&8192){if(fe=s.memoizedState!==null,(s.stateNode.isHidden=fe)&&!Ae&&(s.mode&1)!==0)for(et=s,Ae=s.child;Ae!==null;){for(Oe=et=Ae;et!==null;){switch(Ne=et,Ye=Ne.child,Ne.tag){case 0:case 11:case 14:case 15:Bl(4,Ne,Ne.return);break;case 1:Ca(Ne,Ne.return);var nt=Ne.stateNode;if(typeof nt.componentWillUnmount=="function"){k=Ne,f=Ne.return;try{a=k,nt.props=a.memoizedProps,nt.state=a.memoizedState,nt.componentWillUnmount()}catch(rt){Vn(k,f,rt)}}break;case 5:Ca(Ne,Ne.return);break;case 22:if(Ne.memoizedState!==null){qy(Oe);continue}}Ye!==null?(Ye.return=Ne,et=Ye):qy(Oe)}Ae=Ae.sibling}e:for(Ae=null,Oe=s;;){if(Oe.tag===5){if(Ae===null){Ae=Oe;try{v=Oe.stateNode,fe?(x=v.style,typeof x.setProperty=="function"?x.setProperty("display","none","important"):x.display="none"):(U=Oe.stateNode,Y=Oe.memoizedProps.style,I=Y!=null&&Y.hasOwnProperty("display")?Y.display:null,U.style.display=Gt("display",I))}catch(rt){Vn(s,s.return,rt)}}}else if(Oe.tag===6){if(Ae===null)try{Oe.stateNode.nodeValue=fe?"":Oe.memoizedProps}catch(rt){Vn(s,s.return,rt)}}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:Lo(a,s),es(s),k&4&&Hy(s);break;case 21:break;default:Lo(a,s),es(s)}}function es(s){var a=s.flags;if(a&2){try{e:{for(var f=s.return;f!==null;){if(Fy(f)){var k=f;break e}f=f.return}throw Error(n(160))}switch(k.tag){case 5:var v=k.stateNode;k.flags&32&&(tt(v,""),k.flags&=-33);var x=By(s);np(s,x,v);break;case 3:case 4:var I=k.stateNode.containerInfo,U=By(s);tp(s,U,I);break;default:throw Error(n(161))}}catch(Y){Vn(s,s.return,Y)}s.flags&=-3}a&4096&&(s.flags&=-4097)}function nj(s,a,f){et=s,Ky(s)}function Ky(s,a,f){for(var k=(s.mode&1)!==0;et!==null;){var v=et,x=v.child;if(v.tag===22&&k){var I=v.memoizedState!==null||Ou;if(!I){var U=v.alternate,Y=U!==null&&U.memoizedState!==null||Cr;U=Ou;var fe=Cr;if(Ou=I,(Cr=Y)&&!fe)for(et=v;et!==null;)I=et,Y=I.child,I.tag===22&&I.memoizedState!==null?Gy(v):Y!==null?(Y.return=I,et=Y):Gy(v);for(;x!==null;)et=x,Ky(x),x=x.sibling;et=v,Ou=U,Cr=fe}Zy(s)}else(v.subtreeFlags&8772)!==0&&x!==null?(x.return=v,et=x):Zy(s)}}function Zy(s){for(;et!==null;){var a=et;if((a.flags&8772)!==0){var f=a.alternate;try{if((a.flags&8772)!==0)switch(a.tag){case 0:case 11:case 15:Cr||Mu(5,a);break;case 1:var k=a.stateNode;if(a.flags&4&&!Cr)if(f===null)k.componentDidMount();else{var v=a.elementType===a.type?f.memoizedProps:Oo(a.type,f.memoizedProps);k.componentDidUpdate(v,f.memoizedState,k.__reactInternalSnapshotBeforeUpdate)}var x=a.updateQueue;x!==null&&qw(a,x,k);break;case 3:var I=a.updateQueue;if(I!==null){if(f=null,a.child!==null)switch(a.child.tag){case 5:f=a.child.stateNode;break;case 1:f=a.child.stateNode}qw(a,I,f)}break;case 5:var U=a.stateNode;if(f===null&&a.flags&4){f=U;var Y=a.memoizedProps;switch(a.type){case"button":case"input":case"select":case"textarea":Y.autoFocus&&f.focus();break;case"img":Y.src&&(f.src=Y.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(a.memoizedState===null){var fe=a.alternate;if(fe!==null){var Ae=fe.memoizedState;if(Ae!==null){var Oe=Ae.dehydrated;Oe!==null&&ls(Oe)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(n(163))}Cr||a.flags&512&&ep(a)}catch(Ne){Vn(a,a.return,Ne)}}if(a===s){et=null;break}if(f=a.sibling,f!==null){f.return=a.return,et=f;break}et=a.return}}function qy(s){for(;et!==null;){var a=et;if(a===s){et=null;break}var f=a.sibling;if(f!==null){f.return=a.return,et=f;break}et=a.return}}function Gy(s){for(;et!==null;){var a=et;try{switch(a.tag){case 0:case 11:case 15:var f=a.return;try{Mu(4,a)}catch(Y){Vn(a,f,Y)}break;case 1:var k=a.stateNode;if(typeof k.componentDidMount=="function"){var v=a.return;try{k.componentDidMount()}catch(Y){Vn(a,v,Y)}}var x=a.return;try{ep(a)}catch(Y){Vn(a,x,Y)}break;case 5:var I=a.return;try{ep(a)}catch(Y){Vn(a,I,Y)}}}catch(Y){Vn(a,a.return,Y)}if(a===s){et=null;break}var U=a.sibling;if(U!==null){U.return=a.return,et=U;break}et=a.return}}var rj=Math.ceil,Lu=R.ReactCurrentDispatcher,rp=R.ReactCurrentOwner,wo=R.ReactCurrentBatchConfig,cn=0,pr=null,rr=null,Er=0,lo=0,Aa=Ds(0),ar=0,Ul=null,ji=0,Pu=0,op=0,Hl=null,Gr=null,sp=0,Ia=1/0,ys=null,Du=!1,ip=null,Ws=null,zu=!1,Ks=null,Fu=0,Wl=0,ap=null,Bu=-1,Uu=0;function Br(){return(cn&6)!==0?Vt():Bu!==-1?Bu:Bu=Vt()}function Zs(s){return(s.mode&1)===0?1:(cn&2)!==0&&Er!==0?Er&-Er:FT.transition!==null?(Uu===0&&(Uu=Cs()),Uu):(s=Je,s!==0||(s=window.event,s=s===void 0?16:Gc(s.type)),s)}function Po(s,a,f,k){if(50<Wl)throw Wl=0,ap=null,Error(n(185));Pr(s,f,k),((cn&2)===0||s!==pr)&&(s===pr&&((cn&2)===0&&(Pu|=f),ar===4&&qs(s,Er)),Vr(s,k),f===1&&cn===0&&(a.mode&1)===0&&(Ia=Vt()+500,gu&&Fs()))}function Vr(s,a){var f=s.callbackNode;jo(s,a);var k=Ln(s,s===pr?Er:0);if(k===0)f!==null&&yt(f),s.callbackNode=null,s.callbackPriority=0;else if(a=k&-k,s.callbackPriority!==a){if(f!=null&&yt(f),a===1)s.tag===0?zT(Yy.bind(null,s)):Mw(Yy.bind(null,s)),MT(function(){(cn&6)===0&&Fs()}),f=null;else{switch(gt(k)){case 1:f=Mr;break;case 4:f=Mn;break;case 16:f=Ot;break;case 536870912:f=Te;break;default:f=Ot}f=ov(f,Vy.bind(null,s))}s.callbackPriority=a,s.callbackNode=f}}function Vy(s,a){if(Bu=-1,Uu=0,(cn&6)!==0)throw Error(n(327));var f=s.callbackNode;if(Ra()&&s.callbackNode!==f)return null;var k=Ln(s,s===pr?Er:0);if(k===0)return null;if((k&30)!==0||(k&s.expiredLanes)!==0||a)a=Hu(s,k);else{a=k;var v=cn;cn|=2;var x=Qy();(pr!==s||Er!==a)&&(ys=null,Ia=Vt()+500,Ai(s,a));do try{ij();break}catch(U){Xy(s,U)}while(!0);Sh(),Lu.current=x,cn=v,rr!==null?a=0:(pr=null,Er=0,a=ar)}if(a!==0){if(a===2&&(v=Sr(s),v!==0&&(k=v,a=lp(s,v))),a===1)throw f=Ul,Ai(s,0),qs(s,k),Vr(s,Vt()),f;if(a===6)qs(s,k);else{if(v=s.current.alternate,(k&30)===0&&!oj(v)&&(a=Hu(s,k),a===2&&(x=Sr(s),x!==0&&(k=x,a=lp(s,x))),a===1))throw f=Ul,Ai(s,0),qs(s,k),Vr(s,Vt()),f;switch(s.finishedWork=v,s.finishedLanes=k,a){case 0:case 1:throw Error(n(345));case 2:Ii(s,Gr,ys);break;case 3:if(qs(s,k),(k&130023424)===k&&(a=sp+500-Vt(),10<a)){if(Ln(s,0)!==0)break;if(v=s.suspendedLanes,(v&k)!==k){Br(),s.pingedLanes|=s.suspendedLanes&v;break}s.timeoutHandle=ph(Ii.bind(null,s,Gr,ys),a);break}Ii(s,Gr,ys);break;case 4:if(qs(s,k),(k&4194240)===k)break;for(a=s.eventTimes,v=-1;0<k;){var I=31-tn(k);x=1<<I,I=a[I],I>v&&(v=I),k&=~x}if(k=v,k=Vt()-k,k=(120>k?120:480>k?480:1080>k?1080:1920>k?1920:3e3>k?3e3:4320>k?4320:1960*rj(k/1960))-k,10<k){s.timeoutHandle=ph(Ii.bind(null,s,Gr,ys),k);break}Ii(s,Gr,ys);break;case 5:Ii(s,Gr,ys);break;default:throw Error(n(329))}}}return Vr(s,Vt()),s.callbackNode===f?Vy.bind(null,s):null}function lp(s,a){var f=Hl;return s.current.memoizedState.isDehydrated&&(Ai(s,a).flags|=256),s=Hu(s,a),s!==2&&(a=Gr,Gr=f,a!==null&&cp(a)),s}function cp(s){Gr===null?Gr=s:Gr.push.apply(Gr,s)}function oj(s){for(var a=s;;){if(a.flags&16384){var f=a.updateQueue;if(f!==null&&(f=f.stores,f!==null))for(var k=0;k<f.length;k++){var v=f[k],x=v.getSnapshot;v=v.value;try{if(!Ro(x(),v))return!1}catch{return!1}}}if(f=a.child,a.subtreeFlags&16384&&f!==null)f.return=a,a=f;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 qs(s,a){for(a&=~op,a&=~Pu,s.suspendedLanes|=a,s.pingedLanes&=~a,s=s.expirationTimes;0<a;){var f=31-tn(a),k=1<<f;s[f]=-1,a&=~k}}function Yy(s){if((cn&6)!==0)throw Error(n(327));Ra();var a=Ln(s,0);if((a&1)===0)return Vr(s,Vt()),null;var f=Hu(s,a);if(s.tag!==0&&f===2){var k=Sr(s);k!==0&&(a=k,f=lp(s,k))}if(f===1)throw f=Ul,Ai(s,0),qs(s,a),Vr(s,Vt()),f;if(f===6)throw Error(n(345));return s.finishedWork=s.current.alternate,s.finishedLanes=a,Ii(s,Gr,ys),Vr(s,Vt()),null}function up(s,a){var f=cn;cn|=1;try{return s(a)}finally{cn=f,cn===0&&(Ia=Vt()+500,gu&&Fs())}}function Ci(s){Ks!==null&&Ks.tag===0&&(cn&6)===0&&Ra();var a=cn;cn|=1;var f=wo.transition,k=Je;try{if(wo.transition=null,Je=1,s)return s()}finally{Je=k,wo.transition=f,cn=a,(cn&6)===0&&Fs()}}function dp(){lo=Aa.current,$n(Aa)}function Ai(s,a){s.finishedWork=null,s.finishedLanes=0;var f=s.timeoutHandle;if(f!==-1&&(s.timeoutHandle=-1,OT(f)),rr!==null)for(f=rr.return;f!==null;){var k=f;switch(vh(k),k.tag){case 1:k=k.type.childContextTypes,k!=null&&pu();break;case 3:Ta(),$n(Kr),$n(Nr),$h();break;case 5:Ih(k);break;case 4:Ta();break;case 13:$n(Un);break;case 19:$n(Un);break;case 10:Nh(k.type._context);break;case 22:case 23:dp()}f=f.return}if(pr=s,rr=s=Gs(s.current,null),Er=lo=a,ar=0,Ul=null,op=Pu=ji=0,Gr=Hl=null,Si!==null){for(a=0;a<Si.length;a++)if(f=Si[a],k=f.interleaved,k!==null){f.interleaved=null;var v=k.next,x=f.pending;if(x!==null){var I=x.next;x.next=v,k.next=I}f.pending=k}Si=null}return s}function Xy(s,a){do{var f=rr;try{if(Sh(),Nu.current=Au,Tu){for(var k=Hn.memoizedState;k!==null;){var v=k.queue;v!==null&&(v.pending=null),k=k.next}Tu=!1}if(Ti=0,hr=ir=Hn=null,Ll=!1,Pl=0,rp.current=null,f===null||f.return===null){ar=1,Ul=a,rr=null;break}e:{var x=s,I=f.return,U=f,Y=a;if(a=Er,U.flags|=32768,Y!==null&&typeof Y=="object"&&typeof Y.then=="function"){var fe=Y,Ae=U,Oe=Ae.tag;if((Ae.mode&1)===0&&(Oe===0||Oe===11||Oe===15)){var Ne=Ae.alternate;Ne?(Ae.updateQueue=Ne.updateQueue,Ae.memoizedState=Ne.memoizedState,Ae.lanes=Ne.lanes):(Ae.updateQueue=null,Ae.memoizedState=null)}var Ye=xy(I);if(Ye!==null){Ye.flags&=-257,Ey(Ye,I,U,x,a),Ye.mode&1&&by(x,fe,a),a=Ye,Y=fe;var nt=a.updateQueue;if(nt===null){var rt=new Set;rt.add(Y),a.updateQueue=rt}else nt.add(Y);break e}else{if((a&1)===0){by(x,fe,a),fp();break e}Y=Error(n(426))}}else if(Dn&&U.mode&1){var Jn=xy(I);if(Jn!==null){(Jn.flags&65536)===0&&(Jn.flags|=256),Ey(Jn,I,U,x,a),Eh(ja(Y,U));break e}}x=Y=ja(Y,U),ar!==4&&(ar=2),Hl===null?Hl=[x]:Hl.push(x),x=I;do{switch(x.tag){case 3:x.flags|=65536,a&=-a,x.lanes|=a;var le=yy(x,Y,a);Zw(x,le);break e;case 1:U=Y;var ee=x.type,ce=x.stateNode;if((x.flags&128)===0&&(typeof ee.getDerivedStateFromError=="function"||ce!==null&&typeof ce.componentDidCatch=="function"&&(Ws===null||!Ws.has(ce)))){x.flags|=65536,a&=-a,x.lanes|=a;var De=vy(x,U,a);Zw(x,De);break e}}x=x.return}while(x!==null)}ev(f)}catch(st){a=st,rr===f&&f!==null&&(rr=f=f.return);continue}break}while(!0)}function Qy(){var s=Lu.current;return Lu.current=Au,s===null?Au:s}function fp(){(ar===0||ar===3||ar===2)&&(ar=4),pr===null||(ji&268435455)===0&&(Pu&268435455)===0||qs(pr,Er)}function Hu(s,a){var f=cn;cn|=2;var k=Qy();(pr!==s||Er!==a)&&(ys=null,Ai(s,a));do try{sj();break}catch(v){Xy(s,v)}while(!0);if(Sh(),cn=f,Lu.current=k,rr!==null)throw Error(n(261));return pr=null,Er=0,ar}function sj(){for(;rr!==null;)Jy(rr)}function ij(){for(;rr!==null&&!sn();)Jy(rr)}function Jy(s){var a=rv(s.alternate,s,lo);s.memoizedProps=s.pendingProps,a===null?ev(s):rr=a,rp.current=null}function ev(s){var a=s;do{var f=a.alternate;if(s=a.return,(a.flags&32768)===0){if(f=QT(f,a,lo),f!==null){rr=f;return}}else{if(f=JT(f,a),f!==null){f.flags&=32767,rr=f;return}if(s!==null)s.flags|=32768,s.subtreeFlags=0,s.deletions=null;else{ar=6,rr=null;return}}if(a=a.sibling,a!==null){rr=a;return}rr=a=s}while(a!==null);ar===0&&(ar=5)}function Ii(s,a,f){var k=Je,v=wo.transition;try{wo.transition=null,Je=1,aj(s,a,f,k)}finally{wo.transition=v,Je=k}return null}function aj(s,a,f,k){do Ra();while(Ks!==null);if((cn&6)!==0)throw Error(n(327));f=s.finishedWork;var v=s.finishedLanes;if(f===null)return null;if(s.finishedWork=null,s.finishedLanes=0,f===s.current)throw Error(n(177));s.callbackNode=null,s.callbackPriority=0;var x=f.lanes|f.childLanes;if(yr(s,x),s===pr&&(rr=pr=null,Er=0),(f.subtreeFlags&2064)===0&&(f.flags&2064)===0||zu||(zu=!0,ov(Ot,function(){return Ra(),null})),x=(f.flags&15990)!==0,(f.subtreeFlags&15990)!==0||x){x=wo.transition,wo.transition=null;var I=Je;Je=1;var U=cn;cn|=4,rp.current=null,tj(s,f),Wy(f,s),TT(fh),ta=!!dh,fh=dh=null,s.current=f,nj(f),ln(),cn=U,Je=I,wo.transition=x}else s.current=f;if(zu&&(zu=!1,Ks=s,Fu=v),x=s.pendingLanes,x===0&&(Ws=null),Zt(f.stateNode),Vr(s,Vt()),a!==null)for(k=s.onRecoverableError,f=0;f<a.length;f++)v=a[f],k(v.value,{componentStack:v.stack,digest:v.digest});if(Du)throw Du=!1,s=ip,ip=null,s;return(Fu&1)!==0&&s.tag!==0&&Ra(),x=s.pendingLanes,(x&1)!==0?s===ap?Wl++:(Wl=0,ap=s):Wl=0,Fs(),null}function Ra(){if(Ks!==null){var s=gt(Fu),a=wo.transition,f=Je;try{if(wo.transition=null,Je=16>s?16:s,Ks===null)var k=!1;else{if(s=Ks,Ks=null,Fu=0,(cn&6)!==0)throw Error(n(331));var v=cn;for(cn|=4,et=s.current;et!==null;){var x=et,I=x.child;if((et.flags&16)!==0){var U=x.deletions;if(U!==null){for(var Y=0;Y<U.length;Y++){var fe=U[Y];for(et=fe;et!==null;){var Ae=et;switch(Ae.tag){case 0:case 11:case 15:Bl(8,Ae,x)}var Oe=Ae.child;if(Oe!==null)Oe.return=Ae,et=Oe;else for(;et!==null;){Ae=et;var Ne=Ae.sibling,Ye=Ae.return;if(zy(Ae),Ae===fe){et=null;break}if(Ne!==null){Ne.return=Ye,et=Ne;break}et=Ye}}}var nt=x.alternate;if(nt!==null){var rt=nt.child;if(rt!==null){nt.child=null;do{var Jn=rt.sibling;rt.sibling=null,rt=Jn}while(rt!==null)}}et=x}}if((x.subtreeFlags&2064)!==0&&I!==null)I.return=x,et=I;else e:for(;et!==null;){if(x=et,(x.flags&2048)!==0)switch(x.tag){case 0:case 11:case 15:Bl(9,x,x.return)}var le=x.sibling;if(le!==null){le.return=x.return,et=le;break e}et=x.return}}var ee=s.current;for(et=ee;et!==null;){I=et;var ce=I.child;if((I.subtreeFlags&2064)!==0&&ce!==null)ce.return=I,et=ce;else e:for(I=ee;et!==null;){if(U=et,(U.flags&2048)!==0)try{switch(U.tag){case 0:case 11:case 15:Mu(9,U)}}catch(st){Vn(U,U.return,st)}if(U===I){et=null;break e}var De=U.sibling;if(De!==null){De.return=U.return,et=De;break e}et=U.return}}if(cn=v,Fs(),pt&&typeof pt.onPostCommitFiberRoot=="function")try{pt.onPostCommitFiberRoot(ht,s)}catch{}k=!0}return k}finally{Je=f,wo.transition=a}}return!1}function tv(s,a,f){a=ja(f,a),a=yy(s,a,1),s=Us(s,a,1),a=Br(),s!==null&&(Pr(s,1,a),Vr(s,a))}function Vn(s,a,f){if(s.tag===3)tv(s,s,f);else for(;a!==null;){if(a.tag===3){tv(a,s,f);break}else if(a.tag===1){var k=a.stateNode;if(typeof a.type.getDerivedStateFromError=="function"||typeof k.componentDidCatch=="function"&&(Ws===null||!Ws.has(k))){s=ja(f,s),s=vy(a,s,1),a=Us(a,s,1),s=Br(),a!==null&&(Pr(a,1,s),Vr(a,s));break}}a=a.return}}function lj(s,a,f){var k=s.pingCache;k!==null&&k.delete(a),a=Br(),s.pingedLanes|=s.suspendedLanes&f,pr===s&&(Er&f)===f&&(ar===4||ar===3&&(Er&130023424)===Er&&500>Vt()-sp?Ai(s,0):op|=f),Vr(s,a)}function nv(s,a){a===0&&((s.mode&1)===0?a=1:(a=Ct,Ct<<=1,(Ct&130023424)===0&&(Ct=4194304)));var f=Br();s=gs(s,a),s!==null&&(Pr(s,a,f),Vr(s,f))}function cj(s){var a=s.memoizedState,f=0;a!==null&&(f=a.retryLane),nv(s,f)}function uj(s,a){var f=0;switch(s.tag){case 13:var k=s.stateNode,v=s.memoizedState;v!==null&&(f=v.retryLane);break;case 19:k=s.stateNode;break;default:throw Error(n(314))}k!==null&&k.delete(a),nv(s,f)}var rv;rv=function(s,a,f){if(s!==null)if(s.memoizedProps!==a.pendingProps||Kr.current)qr=!0;else{if((s.lanes&f)===0&&(a.flags&128)===0)return qr=!1,XT(s,a,f);qr=(s.flags&131072)!==0}else qr=!1,Dn&&(a.flags&1048576)!==0&&Lw(a,wu,a.index);switch(a.lanes=0,a.tag){case 2:var k=a.type;$u(s,a),s=a.pendingProps;var v=va(a,Nr.current);Na(a,f),v=Lh(null,a,k,s,v,f);var x=Ph();return a.flags|=1,typeof v=="object"&&v!==null&&typeof v.render=="function"&&v.$$typeof===void 0?(a.tag=1,a.memoizedState=null,a.updateQueue=null,Zr(k)?(x=!0,mu(a)):x=!1,a.memoizedState=v.state!==null&&v.state!==void 0?v.state:null,Ch(a),v.updater=Iu,a.stateNode=v,v._reactInternals=a,Hh(a,k,s,f),a=qh(null,a,k,!0,x,f)):(a.tag=0,Dn&&x&&yh(a),Fr(null,a,v,f),a=a.child),a;case 16:k=a.elementType;e:{switch($u(s,a),s=a.pendingProps,v=k._init,k=v(k._payload),a.type=k,v=a.tag=fj(k),s=Oo(k,s),v){case 0:a=Zh(null,a,k,s,f);break e;case 1:a=Cy(null,a,k,s,f);break e;case 11:a=_y(null,a,k,s,f);break e;case 14:a=Sy(null,a,k,Oo(k.type,s),f);break e}throw Error(n(306,k,""))}return a;case 0:return k=a.type,v=a.pendingProps,v=a.elementType===k?v:Oo(k,v),Zh(s,a,k,v,f);case 1:return k=a.type,v=a.pendingProps,v=a.elementType===k?v:Oo(k,v),Cy(s,a,k,v,f);case 3:e:{if(Ay(a),s===null)throw Error(n(387));k=a.pendingProps,x=a.memoizedState,v=x.element,Kw(s,a),_u(a,k,null,f);var I=a.memoizedState;if(k=I.element,x.isDehydrated)if(x={element:k,isDehydrated:!1,cache:I.cache,pendingSuspenseBoundaries:I.pendingSuspenseBoundaries,transitions:I.transitions},a.updateQueue.baseState=x,a.memoizedState=x,a.flags&256){v=ja(Error(n(423)),a),a=Iy(s,a,k,f,v);break e}else if(k!==v){v=ja(Error(n(424)),a),a=Iy(s,a,k,f,v);break e}else for(ao=Ps(a.stateNode.containerInfo.firstChild),io=a,Dn=!0,$o=null,f=Hw(a,null,k,f),a.child=f;f;)f.flags=f.flags&-3|4096,f=f.sibling;else{if(Ea(),k===v){a=ws(s,a,f);break e}Fr(s,a,k,f)}a=a.child}return a;case 5:return Gw(a),s===null&&xh(a),k=a.type,v=a.pendingProps,x=s!==null?s.memoizedProps:null,I=v.children,hh(k,v)?I=null:x!==null&&hh(k,x)&&(a.flags|=32),jy(s,a),Fr(s,a,I,f),a.child;case 6:return s===null&&xh(a),null;case 13:return Ry(s,a,f);case 4:return Ah(a,a.stateNode.containerInfo),k=a.pendingProps,s===null?a.child=_a(a,null,k,f):Fr(s,a,k,f),a.child;case 11:return k=a.type,v=a.pendingProps,v=a.elementType===k?v:Oo(k,v),_y(s,a,k,v,f);case 7:return Fr(s,a,a.pendingProps,f),a.child;case 8:return Fr(s,a,a.pendingProps.children,f),a.child;case 12:return Fr(s,a,a.pendingProps.children,f),a.child;case 10:e:{if(k=a.type._context,v=a.pendingProps,x=a.memoizedProps,I=v.value,Cn(bu,k._currentValue),k._currentValue=I,x!==null)if(Ro(x.value,I)){if(x.children===v.children&&!Kr.current){a=ws(s,a,f);break e}}else for(x=a.child,x!==null&&(x.return=a);x!==null;){var U=x.dependencies;if(U!==null){I=x.child;for(var Y=U.firstContext;Y!==null;){if(Y.context===k){if(x.tag===1){Y=ks(-1,f&-f),Y.tag=2;var fe=x.updateQueue;if(fe!==null){fe=fe.shared;var Ae=fe.pending;Ae===null?Y.next=Y:(Y.next=Ae.next,Ae.next=Y),fe.pending=Y}}x.lanes|=f,Y=x.alternate,Y!==null&&(Y.lanes|=f),Th(x.return,f,a),U.lanes|=f;break}Y=Y.next}}else if(x.tag===10)I=x.type===a.type?null:x.child;else if(x.tag===18){if(I=x.return,I===null)throw Error(n(341));I.lanes|=f,U=I.alternate,U!==null&&(U.lanes|=f),Th(I,f,a),I=x.sibling}else I=x.child;if(I!==null)I.return=x;else for(I=x;I!==null;){if(I===a){I=null;break}if(x=I.sibling,x!==null){x.return=I.return,I=x;break}I=I.return}x=I}Fr(s,a,v.children,f),a=a.child}return a;case 9:return v=a.type,k=a.pendingProps.children,Na(a,f),v=go(v),k=k(v),a.flags|=1,Fr(s,a,k,f),a.child;case 14:return k=a.type,v=Oo(k,a.pendingProps),v=Oo(k.type,v),Sy(s,a,k,v,f);case 15:return Ny(s,a,a.type,a.pendingProps,f);case 17:return k=a.type,v=a.pendingProps,v=a.elementType===k?v:Oo(k,v),$u(s,a),a.tag=1,Zr(k)?(s=!0,mu(a)):s=!1,Na(a,f),ky(a,k,v),Hh(a,k,v,f),qh(null,a,k,!0,s,f);case 19:return Oy(s,a,f);case 22:return Ty(s,a,f)}throw Error(n(156,a.tag))};function ov(s,a){return Ze(s,a)}function dj(s,a,f,k){this.tag=s,this.key=f,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 yo(s,a,f,k){return new dj(s,a,f,k)}function hp(s){return s=s.prototype,!(!s||!s.isReactComponent)}function fj(s){if(typeof s=="function")return hp(s)?1:0;if(s!=null){if(s=s.$$typeof,s===X)return 11;if(s===de)return 14}return 2}function Gs(s,a){var f=s.alternate;return f===null?(f=yo(s.tag,a,s.key,s.mode),f.elementType=s.elementType,f.type=s.type,f.stateNode=s.stateNode,f.alternate=s,s.alternate=f):(f.pendingProps=a,f.type=s.type,f.flags=0,f.subtreeFlags=0,f.deletions=null),f.flags=s.flags&14680064,f.childLanes=s.childLanes,f.lanes=s.lanes,f.child=s.child,f.memoizedProps=s.memoizedProps,f.memoizedState=s.memoizedState,f.updateQueue=s.updateQueue,a=s.dependencies,f.dependencies=a===null?null:{lanes:a.lanes,firstContext:a.firstContext},f.sibling=s.sibling,f.index=s.index,f.ref=s.ref,f}function Wu(s,a,f,k,v,x){var I=2;if(k=s,typeof s=="function")hp(s)&&(I=1);else if(typeof s=="string")I=5;else e:switch(s){case $:return Ri(f.children,v,x,a);case C:I=8,v|=8;break;case j:return s=yo(12,f,a,v|2),s.elementType=j,s.lanes=x,s;case ae:return s=yo(13,f,a,v),s.elementType=ae,s.lanes=x,s;case A:return s=yo(19,f,a,v),s.elementType=A,s.lanes=x,s;case J:return Ku(f,v,x,a);default:if(typeof s=="object"&&s!==null)switch(s.$$typeof){case D:I=10;break e;case z:I=9;break e;case X:I=11;break e;case de:I=14;break e;case ue:I=16,k=null;break e}throw Error(n(130,s==null?s:typeof s,""))}return a=yo(I,f,a,v),a.elementType=s,a.type=k,a.lanes=x,a}function Ri(s,a,f,k){return s=yo(7,s,k,a),s.lanes=f,s}function Ku(s,a,f,k){return s=yo(22,s,k,a),s.elementType=J,s.lanes=f,s.stateNode={isHidden:!1},s}function pp(s,a,f){return s=yo(6,s,null,a),s.lanes=f,s}function mp(s,a,f){return a=yo(4,s.children!==null?s.children:[],s.key,a),a.lanes=f,a.stateNode={containerInfo:s.containerInfo,pendingChildren:null,implementation:s.implementation},a}function hj(s,a,f,k,v){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=Lr(0),this.expirationTimes=Lr(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Lr(0),this.identifierPrefix=k,this.onRecoverableError=v,this.mutableSourceEagerHydrationData=null}function gp(s,a,f,k,v,x,I,U,Y){return s=new hj(s,a,f,U,Y),a===1?(a=1,x===!0&&(a|=8)):a=0,x=yo(3,null,null,a),s.current=x,x.stateNode=s,x.memoizedState={element:k,isDehydrated:f,cache:null,transitions:null,pendingSuspenseBoundaries:null},Ch(x),s}function pj(s,a,f){var k=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:B,key:k==null?null:""+k,children:s,containerInfo:a,implementation:f}}function sv(s){if(!s)return zs;s=s._reactInternals;e:{if(ur(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(Zr(a.type)){a=a.stateNode.__reactInternalMemoizedMergedChildContext;break e}}a=a.return}while(a!==null);throw Error(n(171))}if(s.tag===1){var f=s.type;if(Zr(f))return $w(s,f,a)}return a}function iv(s,a,f,k,v,x,I,U,Y){return s=gp(f,k,!0,s,v,x,I,U,Y),s.context=sv(null),f=s.current,k=Br(),v=Zs(f),x=ks(k,v),x.callback=a??null,Us(f,x,v),s.current.lanes=v,Pr(s,v,k),Vr(s,k),s}function Zu(s,a,f,k){var v=a.current,x=Br(),I=Zs(v);return f=sv(f),a.context===null?a.context=f:a.pendingContext=f,a=ks(x,I),a.payload={element:s},k=k===void 0?null:k,k!==null&&(a.callback=k),s=Us(v,a,I),s!==null&&(Po(s,v,I,x),Eu(s,v,I)),I}function qu(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 av(s,a){if(s=s.memoizedState,s!==null&&s.dehydrated!==null){var f=s.retryLane;s.retryLane=f!==0&&f<a?f:a}}function kp(s,a){av(s,a),(s=s.alternate)&&av(s,a)}function mj(){return null}var lv=typeof reportError=="function"?reportError:function(s){console.error(s)};function wp(s){this._internalRoot=s}Gu.prototype.render=wp.prototype.render=function(s){var a=this._internalRoot;if(a===null)throw Error(n(409));Zu(s,a,null,null)},Gu.prototype.unmount=wp.prototype.unmount=function(){var s=this._internalRoot;if(s!==null){this._internalRoot=null;var a=s.containerInfo;Ci(function(){Zu(null,s,null,null)}),a[fs]=null}};function Gu(s){this._internalRoot=s}Gu.prototype.unstable_scheduleHydration=function(s){if(s){var a=Dr();s={blockedOn:null,target:s,priority:a};for(var f=0;f<At.length&&a!==0&&a<At[f].priority;f++);At.splice(f,0,s),f===0&&nr(s)}};function yp(s){return!(!s||s.nodeType!==1&&s.nodeType!==9&&s.nodeType!==11)}function Vu(s){return!(!s||s.nodeType!==1&&s.nodeType!==9&&s.nodeType!==11&&(s.nodeType!==8||s.nodeValue!==" react-mount-point-unstable "))}function cv(){}function gj(s,a,f,k,v){if(v){if(typeof k=="function"){var x=k;k=function(){var fe=qu(I);x.call(fe)}}var I=iv(a,k,s,0,null,!1,!1,"",cv);return s._reactRootContainer=I,s[fs]=I.current,jl(s.nodeType===8?s.parentNode:s),Ci(),I}for(;v=s.lastChild;)s.removeChild(v);if(typeof k=="function"){var U=k;k=function(){var fe=qu(Y);U.call(fe)}}var Y=gp(s,0,!1,null,null,!1,!1,"",cv);return s._reactRootContainer=Y,s[fs]=Y.current,jl(s.nodeType===8?s.parentNode:s),Ci(function(){Zu(a,Y,f,k)}),Y}function Yu(s,a,f,k,v){var x=f._reactRootContainer;if(x){var I=x;if(typeof v=="function"){var U=v;v=function(){var Y=qu(I);U.call(Y)}}Zu(a,I,s,v)}else I=gj(f,a,s,v,k);return qu(I)}Ao=function(s){switch(s.tag){case 3:var a=s.stateNode;if(a.current.memoizedState.isDehydrated){var f=Yt(a.pendingLanes);f!==0&&(Co(a,f|1),Vr(a,Vt()),(cn&6)===0&&(Ia=Vt()+500,Fs()))}break;case 13:Ci(function(){var k=gs(s,1);if(k!==null){var v=Br();Po(k,s,1,v)}}),kp(s,1)}},hn=function(s){if(s.tag===13){var a=gs(s,134217728);if(a!==null){var f=Br();Po(a,s,134217728,f)}kp(s,134217728)}},rn=function(s){if(s.tag===13){var a=Zs(s),f=gs(s,a);if(f!==null){var k=Br();Po(f,s,a,k)}kp(s,a)}},Dr=function(){return Je},Yn=function(s,a){var f=Je;try{return Je=s,a()}finally{Je=f}},Me=function(s,a,f){switch(a){case"input":if(Ht(s,f),a=f.name,f.type==="radio"&&a!=null){for(f=s;f.parentNode;)f=f.parentNode;for(f=f.querySelectorAll("input[name="+JSON.stringify(""+a)+'][type="radio"]'),a=0;a<f.length;a++){var k=f[a];if(k!==s&&k.form===s.form){var v=hu(k);if(!v)throw Error(n(90));je(k),Ht(k,v)}}}break;case"textarea":dt(s,f);break;case"select":a=f.value,a!=null&&xt(s,!!f.multiple,a,!1)}},_e=up,Xe=Ci;var kj={usingClientEntryPoint:!1,Events:[Il,wa,hu,K,pe,up]},Kl={findFiberByHostInstance:bi,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},wj={bundleType:Kl.bundleType,version:Kl.version,rendererPackageName:Kl.rendererPackageName,rendererConfig:Kl.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:R.ReactCurrentDispatcher,findHostInstanceByFiber:function(s){return s=V(s),s===null?null:s.stateNode},findFiberByHostInstance:Kl.findFiberByHostInstance||mj,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 Xu=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Xu.isDisabled&&Xu.supportsFiber)try{ht=Xu.inject(wj),pt=Xu}catch{}}return Yr.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=kj,Yr.createPortal=function(s,a){var f=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!yp(a))throw Error(n(200));return pj(s,a,null,f)},Yr.createRoot=function(s,a){if(!yp(s))throw Error(n(299));var f=!1,k="",v=lv;return a!=null&&(a.unstable_strictMode===!0&&(f=!0),a.identifierPrefix!==void 0&&(k=a.identifierPrefix),a.onRecoverableError!==void 0&&(v=a.onRecoverableError)),a=gp(s,1,!1,null,null,f,!1,k,v),s[fs]=a.current,jl(s.nodeType===8?s.parentNode:s),new wp(a)},Yr.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=V(a),s=s===null?null:s.stateNode,s},Yr.flushSync=function(s){return Ci(s)},Yr.hydrate=function(s,a,f){if(!Vu(a))throw Error(n(200));return Yu(null,s,a,!0,f)},Yr.hydrateRoot=function(s,a,f){if(!yp(s))throw Error(n(405));var k=f!=null&&f.hydratedSources||null,v=!1,x="",I=lv;if(f!=null&&(f.unstable_strictMode===!0&&(v=!0),f.identifierPrefix!==void 0&&(x=f.identifierPrefix),f.onRecoverableError!==void 0&&(I=f.onRecoverableError)),a=iv(a,null,s,1,f??null,v,!1,x,I),s[fs]=a.current,jl(s),k)for(s=0;s<k.length;s++)f=k[s],v=f._getVersion,v=v(f._source),a.mutableSourceEagerHydrationData==null?a.mutableSourceEagerHydrationData=[f,v]:a.mutableSourceEagerHydrationData.push(f,v);return new Gu(a)},Yr.render=function(s,a,f){if(!Vu(a))throw Error(n(200));return Yu(null,s,a,!1,f)},Yr.unmountComponentAtNode=function(s){if(!Vu(s))throw Error(n(40));return s._reactRootContainer?(Ci(function(){Yu(null,null,s,!1,function(){s._reactRootContainer=null,s[fs]=null})}),!0):!1},Yr.unstable_batchedUpdates=up,Yr.unstable_renderSubtreeIntoContainer=function(s,a,f,k){if(!Vu(f))throw Error(n(200));if(s==null||s._reactInternals===void 0)throw Error(n(38));return Yu(s,a,f,!1,k)},Yr.version="18.3.1-next-f1338f8080-20240426",Yr}var kv;function Hx(){if(kv)return xp.exports;kv=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(),xp.exports=jj(),xp.exports}var Cj=Hx(),Qu={},wv;function Aj(){if(wv)return Qu;wv=1;var e=Hx();return Qu.createRoot=e.createRoot,Qu.hydrateRoot=e.hydrateRoot,Qu}var Ij=Aj();const si="shell",Wx="check",Rj="ToolSearch",mg="AskUserQuestion",Kx="preview",$j=new Set(["edit","delete","move","execute"]),Oj=new Set(["Edit","Write","MultiEdit","NotebookEdit","Bash"]);function gg(e){return e.kind?$j.has(e.kind):Oj.has(e.name)}const Mj=["read","edit","delete","move","search","execute","fetch"];function kg(e){return Mj.includes(e??"")}function Zx(e,t){return(kg(e.kind)||e.name===mg)&&uf(t)}function uf(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 Mc=[{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"}],Rd="auto";function Lj(e){return e.branch.startsWith("toyon/")}const vo="shell",Es="login";function Pj(e,t){return`${e}/${t}`}function Dj(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 zj=["use","always","off"];function qx(e){return e.find(t=>t.id==="default")}function Fj(e){const t=qx(e);if(t!=null&&t.description)return e.find(n=>n!==t&&n.name===t.description)}function xn(e){return e.worktree!==void 0}function Ki(e){return e.kind==="main"}function Lc(e){return e.kind==="spare"}function $r(e){return Lc(e)||Ki(e)}function wg(e){return e.kind==="worktree"}function Gx(e){return e.kind==="worktree"&&Lj(e)}function Di(e){var t;return e.kind==="worktree"&&((t=e.from)==null?void 0:t.kind)!=="pr"}function vd(e){return e.kind==="worktree"}function df(e){return!!e.branch&&!e.locked&&!(e.worktree&&$r(e.worktree))}const Ja=e=>{var t;return e.promptedAt??((t=e.lastTurn)==null?void 0:t.at)??e.createdAt},Bj=e=>$r(e)?0:1,Uj=e=>e.variant?`group:${e.variant.group}`:`row:${e.id}`;function Hj(e){const t=[],n=new Map;for(const r of e){const o=r.worktree,i=Uj(o),l=n.get(i);if(l){l.rows.push(r),l.at=Math.max(l.at,Ja(o));continue}const c={tier:Bj(o),at:Ja(o),rows:[r]};t.push(c),n.set(i,c)}return t.sort((r,o)=>r.tier-o.tier||o.at-r.at),t.flatMap(r=>r.rows.length>1?r.rows.sort((o,i)=>{var l,c;return(((l=o.worktree.variant)==null?void 0:l.index)??0)-(((c=i.worktree.variant)==null?void 0:c.index)??0)}):r.rows)}function yv(e,t){const n=new Map;for(const r of e)n.set(r.id,r.promptedAt??0);for(const r of t){if(!xn(r)||r.worktree.kind==="spare")continue;const o=r.worktree.repoId;n.set(o,Math.max(n.get(o)??0,Ja(r.worktree)))}return[...e].sort((r,o)=>(n.get(o.id)??0)-(n.get(r.id)??0))}const vv="not opened in ";function Wj(e){const t=e.lastIndexOf(vv);return t<0?{what:e}:{what:e.slice(0,t).replace(/,\s*$/,""),idle:e.slice(t+vv.length)}}const Vx={image:6,paste:4,file:8,pick:8},Kj={image:"image",paste:"paste",file:"file",pick:"element"},Zj={image:"Image",paste:"Pasted text"},Yx=(e,t)=>`${Zj[e]} ${t}`,yg=e=>`at most ${Vx[e]} ${Kj[e]}s per message`,qj=(e,t)=>e.filter(n=>n.kind===t).length,Gj=(e,t)=>Math.max(0,Vx[t]-qj(e,t));function dm(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 vg(e,t){const n={...t};return e.map(r=>[r,n[r.kind]++])}function lc(e,t){const n={...e};for(const r of t)n[r.kind]++;return n}function bg(e){return e>=1024*1024?`${(e/1024/1024).toFixed(1)} MB`:`${Math.max(1,Math.round(e/1024))} KB`}const Ka=e=>`card:${e}`,bd=[{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"}],Vj=new Set(["zen","close","back","forward"]);function Xx(e,{guest:t=!1}={}){var r,o;if(e.altKey){if(e.metaKey||e.ctrlKey)return null;const i=bd.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=bd.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 bd){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 Yj(e){return e.altKey||e.key.toLowerCase()!=="s"?!1:!!e.ctrlKey!==e.metaKey}function Qx(e){const t=bd.find(n=>n.id===e);if(!t)throw new Error(`unknown chord ${e}`);return t}function Xj(e,t){return e===t-1?"⌘9":e<8?`⌘${e+1}`:void 0}function Qj(e,t){return t===0?null:e===9?t-1:e-1<t?e-1:null}function Jj(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 eC(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 tC(e,t){const n=Qx(e);return!!n.textKeeps&&Jj(t)&&!(n.emptyGives&&eC(t))}const nC=["Find","Preview","Panels","Worktrees"],cc={"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"}},rC={ArrowUp:"↑",ArrowDown:"↓",ArrowLeft:"←",ArrowRight:"→",Backspace:"⌫",Tab:"Tab"};function oC(e,t={}){var c;const n=Qx(e),r=cc[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":rC[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 sC(e){return Object.keys(cc).filter(t=>cc[t].section===e&&!cc[t].hidden)}const bv={m:6e4,h:60*6e4};function iC(e){const[t,n]=aC(e);return`${t}${n.charAt(0)}`}function aC(e){const t=e/bv.h;if(t>=1&&Number.isInteger(t))return[t,"hour"];const n=e/bv.m;return n>=1&&Number.isInteger(n)?[n,"minute"]:n>=60?[Math.round(n),"minute"]:[Math.max(1,Math.round(e/1e3)),"second"]}const wc={folder:{shared:".toyon/settings.json",local:".toyon/settings.local.json"},root:{shared:"toyon.json",local:"toyon.local.json"}};function Jx(e){return typeof e=="string"?e:e.cmd}function lC(e){return typeof e!="string"&&e.from==="trunk"}function cC(e){return[...e.setup??[],...e.teardown??[],...Object.values(e.run).map(Jx),...Object.values(e.profiles??{}).flatMap(n=>Object.values(n.env??{}))].some(n=>n.includes("TOYON_WORKTREE"))}function uC(e){return e===wc.folder.local||e===wc.root.local}function dC(e){return uC(e)?"local":"shared"}function fC(e,t){return(Object.values(wc).find(r=>r.shared===e||r.local===e)??wc.folder)[t]}const hC=e=>`https://${e}/`;function pC(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 gC(n.origin)?n.origin:null}function mC(e){return e.toLowerCase().endsWith(".fly.dev")}function gC(e){let t;try{t=new URL(e)}catch{return!1}return t.origin!==e?!1:t.protocol==="https:"||t.protocol==="http:"&&xg(t.hostname)}const kC="toyon_grant";function xg(e){return e==="127.0.0.1"||e==="::1"||e==="[::1]"||e==="localhost"||e.endsWith(".localhost")}function wC(e,t,n){return e.replace("{id}",t).replace("{port}",String(n))}const yC=4401,vC=25e4;function bC(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(...xC(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 xC(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)>vC)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 EC=/[\p{L}\p{N}_$]+|\s+|[^\s\p{L}\p{N}_$]/gu;function xv(e){return e.match(EC)??[]}const _C=.4;function SC(e,t){if(e===t)return null;const n=bC(xv(e),xv(t));let r=0;for(const o of n)o.mark===" "&&(r+=o.value.length);return r<_C*Math.max(e.length,t.length)?null:{before:Ev(n,"-"),after:Ev(n,"+")}}function Ev(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 e1(n)}function _v(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(e1)}function e1(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 NC=[{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"}],TC=[{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"}],jC=[{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)"}],fm="merge",hm="merge";function Fi(e){var n,r,o;const t=((n=e.land)==null?void 0:n.route)??fm;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 ff(e){return e.base??e.defaultBranch}function CC(e){return e.base!==void 0&&e.base!==e.defaultBranch}function $d(e,t="main"){const n={merge:"merge into",squash:"squash onto",rebase:"rebase onto"}[e.merge??hm];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 open a PR that GitHub merges when its rules allow":"Commit, push the branch and open a PR"}}function t1(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 Sv(e,t="|"){return e.map(n=>o1(n)).join(t)}function pm(e,t){return typeof t=="bigint"?t.toString():t}function hf(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function AC(e){return e==null}function Eg(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function IC(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 ro(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function ui(...e){const t={};for(const n of e){const r=Object.getOwnPropertyDescriptors(n);Object.assign(t,r)}return Object.defineProperties({},t)}function RC(e){return JSON.stringify(e)}function $C(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const n1="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function yc(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const OC=hf(()=>{var e;if(qo.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(yc(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!(yc(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function r1(e){return vc(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}const MC=new Set(["string","number","symbol"]);function el(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function di(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 at(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 o1(e){return typeof e=="bigint"?e.toString()+"n":typeof e=="string"?`"${e}"`:`${e}`}function LC(e){return Object.keys(e).filter(t=>e[t]._zod.optin!==void 0&&e[t]._zod.optout==="optional")}const PC={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 DC(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=ui(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]&&ro(l,c,n.shape[c])}return ro(this,"shape",l),l},checks:[]});return di(e,i)}function zC(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=ui(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 ro(this,"shape",l),l},checks:[]});return di(e,i)}function FC(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=ui(e._zod.def,{get shape(){const i={...e._zod.def.shape,...t};return ro(this,"shape",i),i}});return di(e,o)}function BC(e,t){if(!vc(t))throw new Error("Invalid input to safeExtend: expected a plain object");const n=ui(e._zod.def,{get shape(){const r={...e._zod.def.shape,...t};return ro(this,"shape",r),r}});return di(e,n)}function UC(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=ui(e._zod.def,{get shape(){const i={...e._zod.def.shape,...t._zod.def.shape};return ro(this,"shape",i),i},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return di(e,n)}function Nv(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=ui(t._zod.def,{get shape(){const u=t._zod.def.shape,h={...u};if(n)for(const p of Reflect.ownKeys(n)){if(!Object.prototype.hasOwnProperty.call(u,p))throw new Error(`Unrecognized key: "${String(p)}"`);n[p]&&(h[p]=e?new e({type:"optional",innerType:u[p]}):u[p])}else for(const p of Reflect.ownKeys(u))h[p]=e?new e({type:"optional",innerType:u[p]}):u[p];return ro(this,"shape",h),h},checks:[]});return di(t,c)}function HC(e,t,n){const r=ui(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 ro(this,"shape",i),i}});return di(t,r)}function za(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 WC(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 pf(e,t){return t.map(n=>{var r;return(r=n).path??(r.path=[]),n.path.unshift(e),n})}function ql(e){return typeof e=="string"?e:e==null?void 0:e.message}function Tv(e,t,n){var r;for(let o=t;o<e.length;o++)(r=e[o]).schema??(r.schema=n)}function cl(e,t,n){var g,y,w,b,E,_,N,T,R,O;var r;const o=(y=(g=e.inst)==null?void 0:g._zod)==null?void 0:y.traits;o!=null&&o.has("$ZodType")&&(o.has("$ZodCheck")?(r=e).schema??(r.schema=e.inst):e.schema=e.inst);const i=e.schema!==e.inst?(b=(w=e.schema)==null?void 0:w._zod.def)==null?void 0:b.error:void 0,l=e.message?e.message:ql((N=(_=(E=e.inst)==null?void 0:E._zod.def)==null?void 0:_.error)==null?void 0:N.call(_,e))??ql(i==null?void 0:i(e))??ql((T=t==null?void 0:t.error)==null?void 0:T.call(t,e))??ql((R=n.customError)==null?void 0:R.call(n,e))??ql((O=n.localeError)==null?void 0:O.call(n,e))??"Invalid input",{inst:c,schema:u,continue:h,input:p,...m}=e;return m.path??(m.path=[]),m.message=l,t!=null&&t.reportInput&&(m.input=p),m}const KC=/[\uD800-\uDBFF]/;function _g(e){const t=e.length;if(!KC.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 Sg(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function ZC(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 bc(...e){const[t,n,r]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:r}:{...t}}function qC(e,t){for(const n in t){const r=Object.getOwnPropertyDescriptor(t,n);r.get?Object.defineProperty(e,n,{...r,enumerable:!1}):GC(e,n,r.value)}}function tl(e,t,n,r=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:r,value:n}),n}function s1(e,t,n){return tl(e,t,n,!1)}function GC(e,t,n){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?n:tl(this,t,n.bind(this))},set(r){tl(this,t,r)}})}function VC(e,t){const n=Object.getPrototypeOf(e);return t in n?void 0:n}let Sp,ei=!1;const YC={configurable:!0,get(){ei=!0}};function _n(e,t,n){const r=Object.getPrototypeOf(e._zod);if(t in r&&Sp!==e._zod){Sp=void 0;return}Sp=e._zod,Object.defineProperty(r,t,{configurable:!0,get(){Object.defineProperty(this,t,YC);const o=ei;ei=!1;try{const i=n(this);return ei?delete this[t]:Object.defineProperty(this,t,{configurable:!0,writable:!0,value:i}),ei=ei||o,i}catch(i){throw delete this[t],ei=ei||o,i}},set(o){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:o})}})}function XC(e,t,n,r){const o=VC(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 QC="~constantCatch";function JC(e){const t=()=>e;return t[QC]=!0,t}var jv;const Np={value:void 0,enumerable:!1};let Cv="captureStackTrace"in Error?Error:null;function eA(e){const t=Cv;if(t){const n=t.stackTraceLimit;if(typeof n=="number"){try{t.stackTraceLimit=0}catch{return Cv=null,new e}try{return new e}finally{t.stackTraceLimit=n}}}return new e}function xe(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,y){if(!g._zod){Np.value=new i(y);try{Object.defineProperty(g,"_zod",Np)}finally{Np.value=void 0}}if(g._zod.traits.has(e))return;if(g._zod.traits.add(e),t(g,y),c){const b=Object.getPrototypeOf(g),E=g._zod.constr.prototype;let _=b;for(;_&&_!==E;)_=Object.getPrototypeOf(_);const N=_??b;c.has(N)||(c.add(N),qC(N,l))}const w=m.prototype;for(const b in w)Object.prototype.hasOwnProperty.call(w,b)&&(b in g||(g[b]=w[b].bind(g)))}const h=(r==null?void 0:r.Parent)??Object;class p extends h{}Object.defineProperty(p,"name",{value:e});function m(g){var E;const y=r!=null&&r.Parent?eA(p):this;u(y,g);const w=y._zod.deferred;if(w){for(const _ of w)_();y._zod.deferred=void 0}const b=(E=globalThis.__zod_globalConfig)==null?void 0:E.postProcessor;return b&&b(y),y}return Object.defineProperty(m,"init",{value:u}),Object.defineProperty(m,Symbol.hasInstance,{value:g=>{var y,w;return r!=null&&r.Parent&&g instanceof r.Parent?!0:(w=(y=g==null?void 0:g._zod)==null?void 0:y.traits)==null?void 0:w.has(e)}}),Object.defineProperty(m,"name",{value:e}),m}class Za extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class i1 extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}(jv=globalThis).__zod_globalConfig??(jv.__zod_globalConfig={});const qo=globalThis.__zod_globalConfig;function fi(e){return e&&Object.assign(qo,e),qo}function tA(){const e=this._zod;return e.message??(e.message=JSON.stringify(e.def,pm,2)),e.message}function nA(e){this._zod.message=e}const rA={get:tA,set:nA,enumerable:!0,configurable:!0},Tp={value:void 0,enumerable:!1},jp={value:void 0,enumerable:!1},Av=new WeakSet([Object.prototype,Error.prototype]),a1=(e,t)=>{e.name="$ZodError",Tp.value=e._zod,Object.defineProperty(e,"_zod",Tp),jp.value=t,Object.defineProperty(e,"issues",jp),Tp.value=void 0,jp.value=void 0,Object.defineProperty(e,"message",rA);const n=Object.getPrototypeOf(e);Av.has(n)||(Av.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})}}))},l1=xe("$ZodError",a1),c1=xe("$ZodError",a1,void 0,{Parent:Error});function oA(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 sA(e,t=n=>n.message){const n={},r=[];for(const o of e.issues)o.path.length>0?oA(n,o.path[0],()=>[]).push(t(o)):r.push(t(o));return{formErrors:r,fieldErrors:n}}function iA(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 p=c[h],m=h===c.length-1;if(p==="_errors"){m&&u._errors.push(t(l)),h++;continue}Object.prototype.hasOwnProperty.call(u,p)||Object.defineProperty(u,p,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});const g=u[p];m&&g._errors.push(t(l)),u=g,h++}}}};return r(e),n}function mf(e,t){return{callee:(t==null?void 0:t.callee)??e,Err:t==null?void 0:t.Err}}const Ng=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 Za;if(c.issues.length){const u=new((i==null?void 0:i.Err)??e)(c.issues.map(h=>cl(h,l,fi())));throw n1(u,(i==null?void 0:i.callee)??t),u}return c.value};return t},Tg=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=>cl(h,l,fi())));throw n1(u,(i==null?void 0:i.callee)??t),u}return c.value};return t},gf=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 Za;return i.issues.length?{success:!1,error:new(e??l1)(i.issues.map(l=>cl(l,o,fi())))}:{success:!0,data:i.value}},aA=gf(c1),kf=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=>cl(l,o,fi())))}:{success:!0,data:i.value}},lA=kf(c1),cA=e=>{const t=Ng(e),n=(r,o,i,l)=>{const c=i?{...i,direction:"backward"}:{direction:"backward"};return t(r,o,c,mf(n,l))};return n},uA=e=>{const t=Ng(e),n=(r,o,i,l)=>t(r,o,i,mf(n,l));return n},dA=e=>{const t=Tg(e),n=async(r,o,i,l)=>{const c=i?{...i,direction:"backward"}:{direction:"backward"};return await t(r,o,c,mf(n,l))};return n},fA=e=>{const t=Tg(e),n=async(r,o,i,l)=>await t(r,o,i,mf(n,l));return n},hA=e=>(t,n,r)=>{const o=r?{...r,direction:"backward"}:{direction:"backward"};return gf(e)(t,n,o)},pA=e=>(t,n,r)=>gf(e)(t,n,r),mA=e=>async(t,n,r)=>{const o=r?{...r,direction:"backward"}:{direction:"backward"};return kf(e)(t,n,o)},gA=e=>async(t,n,r)=>kf(e)(t,n,r),kA=/^[cC][0-9a-z]{6,}$/,wA=/^[0-9a-z]+$/,yA=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,vA=/^[0-9a-vA-V]{20}$/,bA=/^[A-Za-z0-9]{27}$/,xA=/^[a-zA-Z0-9_-]{21}$/;function EA(e){return new RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}const _A=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,SA=/^([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})$/,Iv=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)$/,NA=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,TA="^[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$";function jA(){return new RegExp(TA,"u")}const CA=/^(?:(?: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])$/,AA=/^(([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}|:))$/,IA=/^((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])$/,RA=/^(([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])$/,$A=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,u1=/^[A-Za-z0-9_-]*$/,OA=/^https?$/,MA=/^\+[1-9]\d{6,14}$/,d1="(?:(?:\\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 LA(e){return new RegExp(`^${e}$`)}const PA=LA(d1);function mm(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 DA(e){return new RegExp(`^${mm(e)}$`)}function zA(e){const t=["Z"];e.offset&&t.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const n=`${mm({precision:e.precision,seconds:!0})}(?:${t.join("|")})`,r=e.local?`${n}|${mm({precision:e.precision})}`:n;return new RegExp(`^${d1}T(?:${r})$`)}const FA=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}$`)},BA=/^-?\d+$/,UA=/^-?\d+(?:\.\d+)?$/,HA=/^(?:true|false)$/i,WA=/^[^A-Z]*$/,KA=/^[^a-z]*$/,oo=xe("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),jg=e=>{const t=e.value;return!AC(t)&&t.length!==void 0},Od={number:"number",bigint:"bigint",object:"date"},f1=xe("$ZodCheckLessThan",(e,t)=>{oo.init(e,t);const n=Od[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:Od[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})}}),h1=xe("$ZodCheckGreaterThan",(e,t)=>{oo.init(e,t);const n=Od[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:Od[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})}}),ZA=xe("$ZodCheckMultipleOf",(e,t)=>{oo.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):IC(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})}}),qA=xe("$ZodCheckNumberFormat",(e,t)=>{var l;oo.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]=PC[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=BA)}),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})}}),GA=xe("$ZodCheckMaxLength",(e,t)=>{var n;oo.init(e,t),(n=e._zod.def).when??(n.when=jg),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?_g(o):i)<=t.maximum)return;const c=Sg(o);r.issues.push({origin:c,code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),VA=xe("$ZodCheckMinLength",(e,t)=>{var n;oo.init(e,t),(n=e._zod.def).when??(n.when=jg),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?_g(o):i)>=t.minimum)return;const c=Sg(o);r.issues.push({origin:c,code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),YA=xe("$ZodCheckLengthEquals",(e,t)=>{var n;oo.init(e,t),(n=e._zod.def).when??(n.when=jg),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?_g(o):i;if(l===t.length)return;const c=Sg(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})}}),wf=xe("$ZodCheckStringFormat",(e,t)=>{var n,r;oo.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=()=>{})}),XA=xe("$ZodCheckRegex",(e,t)=>{wf.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})}}),QA=xe("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=WA),wf.init(e,t)}),JA=xe("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=KA),wf.init(e,t)}),eI=xe("$ZodCheckIncludes",(e,t)=>{oo.init(e,t);const n=el(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})}}),tI=xe("$ZodCheckStartsWith",(e,t)=>{oo.init(e,t);const n=new RegExp(`^${el(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})}}),nI=xe("$ZodCheckEndsWith",(e,t)=>{oo.init(e,t);const n=new RegExp(`.*${el(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})}}),rI=xe("$ZodCheckOverwrite",(e,t)=>{oo.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});class oI{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 sI={major:4,minor:5,patch:4},Fn=xe("$ZodType",(e,t)=>{var i;var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=sI;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,p)=>{if(u.memo)return u;let m=za(u),g;for(const y of h){if(y._zod.def.when){if(WC(u)||!y._zod.def.when(u))continue}else if(m)continue;const w=u.issues.length,b=y._zod.check(u);if(b instanceof Promise&&(p==null?void 0:p.async)===!1)throw new Za;if(g||b instanceof Promise)g=(g??Promise.resolve()).then(async()=>{await b,u.issues.length!==w&&(Tv(u.issues,w,e),m||(m=za(u,w)))});else{if(u.issues.length===w)continue;Tv(u.issues,w,e),m||(m=za(u,w))}}return g?g.then(()=>u):u},c=(u,h,p)=>{if(za(u))return u.aborted=!0,u;const m=l(h,o,p);if(m instanceof Promise){if(p.async===!1)throw new Za;return m.then(g=>e._zod.parse(g,p))}return e._zod.parse(m,p)};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 p=e._zod.parse(u,h);if(p instanceof Promise){if(h.async===!1)throw new Za;return p.then(m=>l(m,o,h))}return l(p,o,h)}}},{get"~standard"(){return s1(this,"~standard",p1(this))},set"~standard"(e){tl(this,"~standard",e)}}),Rv=e=>{var t;return e.success?{value:e.data}:{issues:(t=e.error)==null?void 0:t.issues}};function p1(e){return{validate:t=>{try{return Rv(aA(e,t))}catch{return lA(e,t).then(Rv)}},vendor:"zod",version:1}}const Cg=xe("$ZodString",(e,t)=>{var n;Fn.init(e,t),e._zod.pattern=[...((n=e==null?void 0:e._zod.bag)==null?void 0:n.patterns)??[]].pop()??FA(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}}),Bn=xe("$ZodStringFormat",(e,t)=>{wf.init(e,t),Cg.init(e,t)}),iI=xe("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=SA),Bn.init(e,t)}),aI=xe("$ZodUUID",(e,t)=>{if(t.version){const r={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(r===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=Iv(r))}else t.pattern??(t.pattern=Iv());Bn.init(e,t)}),lI=xe("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=NA),Bn.init(e,t)}),m1=1,g1=2;function cI(e,t){var n;if(!t.normalize&&((n=t.protocol)==null?void 0:n.source)===OA.source&&!/^https?:\/\//i.test(e))return m1;try{return new URL(e)}catch{return g1}}const uI=/[\t\n\r]/g;function dI(e){return e.replace(uI,"")}function fI(e,t){return t.lastIndex=0,t.test(e.hostname)}function hI(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(":")?e.protocol.slice(0,-1):e.protocol)}const pI=xe("$ZodURL",(e,t)=>{Bn.init(e,t),e._zod.check=n=>{try{const r=n.value.trim(),o=cI(r,t);if(o===m1){n.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:n.value,inst:e,continue:!t.abort});return}if(o===g1){n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort});return}t.hostname&&!fI(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&&!hI(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:dI(r);return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),mI=xe("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=jA()),Bn.init(e,t)}),gI=xe("$ZodNanoID",(e,t)=>{if(t.length!==void 0&&(!Number.isInteger(t.length)||t.length<1))throw new Error(`Invalid nanoid length: ${t.length}`);t.pattern??(t.pattern=t.length===void 0?xA:EA(t.length)),Bn.init(e,t)}),kI=xe("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=kA),Bn.init(e,t)}),wI=xe("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=wA),Bn.init(e,t)}),yI=xe("$ZodULID",(e,t)=>{t.pattern??(t.pattern=yA),Bn.init(e,t)}),vI=xe("$ZodXID",(e,t)=>{t.pattern??(t.pattern=vA),Bn.init(e,t)}),bI=xe("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=bA),Bn.init(e,t)}),xI=xe("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=zA(t)),Bn.init(e,t),(t.local||t.precision===-1)&&(e._zod.bag.laxFormat=!0,e._zod.onattach.push(n=>{n._zod.bag.laxFormat=!0}))}),EI=xe("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=PA),Bn.init(e,t)}),_I=xe("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=DA(t)),Bn.init(e,t)}),SI=xe("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=_A),Bn.init(e,t)}),NI=xe("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=CA),Bn.init(e,t),e._zod.bag.format="ipv4"}),TI=/^[0-9a-fA-F:.]+$/;function k1(e){if(!TI.test(e))return!1;try{return new URL(`http://[${e}]`),!0}catch{return!1}}const jI=xe("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=AA),Bn.init(e,t),e._zod.bag.format="ipv6",e._zod.check=n=>{k1(n.value)||n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}}),CI=xe("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=IA),Bn.init(e,t)});function AI(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:k1(n)}const II=xe("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=RA),Bn.init(e,t),e._zod.check=n=>{AI(n.value)||n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}});function w1(e){if(e==="")return!0;if(/\s/.test(e)||e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const RI=xe("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=$A),Bn.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{w1(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});function $I(e){if(!u1.test(e))return!1;const t=e.replace(/[-_]/g,r=>r==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return w1(n)}const OI=xe("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=u1),Bn.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{$I(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),MI=xe("$ZodE164",(e,t)=>{t.pattern??(t.pattern=MA),Bn.init(e,t)});function LI(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 PI=xe("$ZodJWT",(e,t)=>{Bn.init(e,t),e._zod.check=n=>{LI(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),y1=xe("$ZodNumber",(e,t)=>{Fn.init(e,t),e._zod.pattern=e._zod.bag.pattern??UA,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}}),DI=xe("$ZodNumberFormat",(e,t)=>{qA.init(e,t),y1.init(e,t)}),zI=xe("$ZodBoolean",(e,t)=>{Fn.init(e,t),e._zod.pattern=HA,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}}),FI=xe("$ZodUnknown",(e,t)=>{Fn.init(e,t),e._zod.parse=n=>n}),BI=xe("$ZodNever",(e,t)=>{Fn.init(e,t),e._zod.parse=(n,r)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)});function $v(e,t,n){e.issues.length&&t.issues.push(...pf(n,e.issues)),t.value[n]=e.value}const UI=xe("$ZodArray",(e,t)=>{Fn.init(e,t);const n=qo.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(p=>$v(p,r,c))):$v(h,r,c)}return l.length?Promise.all(l).then(()=>r):r}});function Md(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(...pf(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 HI=[];function v1(e){var l,c,u,h;const t=Object.keys(e.shape),n=Object.getOwnPropertySymbols(e.shape),r=n.length?n:HI,o=r.length?[...t,...r]:t;for(const p of o)if(!((h=(u=(c=(l=e.shape)==null?void 0:l[p])==null?void 0:c._zod)==null?void 0:u.traits)!=null&&h.has("$ZodType")))throw new Error(`Invalid element at key "${String(p)}": expected a Zod schema`);const i=LC(e.shape);return{...e,allKeys:o,symbolKeys:r,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(i)}}function b1(e,t,n,r,o,i){const l=[],c=o.keySet,u=o.catchall._zod,h=u.def.type,p=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 y=u.run({value:t[g],issues:[]},r);y instanceof Promise?e.push(y.then(w=>Md(w,n,g,t,p,m))):Md(y,n,g,t,p,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 gm=new WeakMap,WI=xe("$ZodObject",(e,t)=>{Fn.init(e,t);const n=Object.getOwnPropertyDescriptor(t,"shape");if(!(n!=null&&n.get)){const u=t.shape;gm.set(t,u),Object.defineProperty(t,"shape",{get:()=>{const h={...u};return Object.defineProperty(t,"shape",{value:h}),gm.set(t,h),h}})}const r=hf(()=>v1(t));_n(e,"propValues",u=>{const h=u.def.shape,p={};for(const m in h){const g=h[m]._zod;if(g.values){Object.prototype.hasOwnProperty.call(p,m)||ro(p,m,new Set);for(const y of g.values)p[m].add(y);g.optin!==void 0&&p[m].add(void 0)}}return p});const o=yc,i=t.catchall;let l;const c=qo.memoizer;c==null||c.attach(e),e._zod.parse=(u,h)=>{l??(l=r.value);const p=u.value;if(!o(p))return u.issues.push({expected:"object",code:"invalid_type",input:p,inst:e}),u;u.value=c?c.alloc(e,u,{},h):{};const m=[],g=l.shape;for(const y of l.allKeys){if(y==="__proto__")continue;const w=g[y],b=w._zod.optin,E=w._zod.optout,_=w._zod.run({value:p[y],issues:[]},h);_ instanceof Promise?m.push(_.then(N=>Md(N,u,y,p,b,E))):Md(_,u,y,p,b,E)}return i?b1(m,p,u,h,r.value,e):m.length?Promise.all(m).then(()=>u):u}}),KI=xe("$ZodObjectJIT",(e,t)=>{WI.init(e,t);const n=e._zod.parse,r=hf(()=>v1(t)),o=qo.memoizer,i=y=>{var O,B;const w=r.value,b=w.symbolKeys,E=new oI(["payload","ctx"],{shape:y,inst:e,memo:o,syms:b}),_=$=>`shape[${$}]._zod.run({ value: input[${$}], issues: [] }, ctx)`,N=($,C)=>`
47
+ for (let i = 0; i < ${$}.issues.length; i++) {
48
+ const iss = ${$}.issues[i];
49
+ iss.path = iss.path ? [${C}, ...iss.path] : [${C}];
50
+ payload.issues.push(iss);
51
+ }`;E.write("const input = payload.value;");const T=Object.create(null);let R=0;for(const $ of w.allKeys)T[$]=`key_${R++}`;E.write(o?"const newResult = memo.alloc(inst, payload, {}, ctx);":"const newResult = {};");for(const $ of w.allKeys){if($==="__proto__")continue;const C=T[$],j=typeof $=="symbol"?`syms[${b.indexOf($)}]`:RC($),D=`${j} in input`,z=y[$],X=(O=z==null?void 0:z._zod)==null?void 0:O.optin,ae=X!==void 0,A=((B=z==null?void 0:z._zod)==null?void 0:B.optout)==="optional";if(E.write(`const ${C} = ${_(j)};`),ae&&A){const de=X==="optional"?`${C}_present`:`${C}.value !== undefined || ${C}_present`;E.write(`
52
+ const ${C}_present = ${D};
53
+ if (!${C}.issues.length || ${C}_present) {
54
+ if (${C}.issues.length) {${N(C,j)}
55
+ }
56
+
57
+ if (${de}) {
58
+ newResult[${j}] = ${C}.value;
59
+ }
60
+ }
61
+
62
+ `)}else ae?E.write(`
63
+ if (${C}.issues.length) {${N(C,j)}
64
+ }
65
+
66
+ if (${C}.value === undefined) {
67
+ if (${D}) {
68
+ newResult[${j}] = undefined;
69
+ }
70
+ } else {
71
+ newResult[${j}] = ${C}.value;
72
+ }
73
+
74
+ `):E.write(`
75
+ const ${C}_present = ${D};
76
+ if (${C}.issues.length) {${N(C,j)}
77
+ }
78
+ if (!${C}_present && !${C}.issues.length) {
79
+ payload.issues.push({
80
+ code: "invalid_type",
81
+ expected: "nonoptional",
82
+ input: undefined,
83
+ path: [${j}]
84
+ });
85
+ }
86
+
87
+ if (${C}_present) {
88
+ newResult[${j}] = ${C}.value;
89
+ }
90
+
91
+ `)}return E.write("payload.value = newResult;"),E.write("return payload;"),E.compile()};let l;const c=yc,u=!qo.jitless,p=u&&OC.value,m=t.catchall;let g;e._zod.parse=(y,w)=>{g??(g=r.value);const b=y.value;return c(b)?u&&p&&(w==null?void 0:w.async)===!1&&w.jitless!==!0?(l||(l=i(t.shape)),y=l(y,w),m?b1([],b,y,w,g,e):y):n(y,w):(y.issues.push({expected:"object",code:"invalid_type",input:b,inst:e}),y)}});function Ov(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=>!za(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=>cl(l,r,fi())))}),t)}const x1=xe("$ZodUnion",(e,t)=>{Fn.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=>Eg(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=>Ov(c,r,e,o)):Ov(l,r,e,o)}}),ZI=xe("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,x1.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)||ro(i,u,new Set);for(const p of h)i[u].add(p)}}return i}),t.options.forEach((o,i)=>{const l=gm.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=hf(()=>{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(!yc(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)}}),qI=xe("$ZodIntersection",(e,t)=>{Fn.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])=>Mv(n,u,h)):Mv(n,i,l)}});function km(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=km(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=km(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 Mv(e,t,n){const r=new Map;let o;const i=new Map,l=(h,p)=>{var g,y;let m;if(h.code==="unrecognized_keys"&&!((g=h.path)!=null&&g.length))o??(o=h),m=h.keys;else if(h.code==="invalid_key"&&h.origin==="record"&&((y=h.path)==null?void 0:y.length)===1){const w=String(h.path[0]);i.has(w)||i.set(w,h),m=[w]}else return!1;for(const w of m)r.has(w)||r.set(w,{}),r.get(w)[p]=!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(p=>o.keys.includes(p)):[];h.length&&e.issues.push({...o,keys:h});for(const p of c)!h.includes(p)&&i.has(p)&&e.issues.push(i.get(p))}const u=km(t.value,n.value);if(!u.valid){if(za(e))return e;throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(u.mergeErrorPath)}`)}return e.value=u.data,e}const GI=xe("$ZodTuple",(e,t)=>{Fn.init(e,t);const n=t.items,r=qo.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=Lv(n,"optin"),h=Lv(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 p=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(y=>{p[m]=y})):p[m]=g}if(t.rest){let m=n.length-1;const g=l.slice(n.length);for(const y of g){m++;const w=t.rest._zod.run({value:y,issues:[]},i);w instanceof Promise?c.push(w.then(b=>Pv(b,o,m))):Pv(w,o,m)}}return c.length?Promise.all(c).then(()=>Dv(p,o,n,l,h)):Dv(p,o,n,l,h)}});function Lv(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 Pv(e,t,n){e.issues.length&&t.issues.push(...pf(n,e.issues)),t.value[n]=e.value}function Dv(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(...pf(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 VI=xe("$ZodEnum",(e,t)=>{Fn.init(e,t);const n=t1(t.entries),r=new Set(n);e._zod.values=r;const o=n.filter(i=>MC.has(typeof i));e._zod.pattern=new RegExp(o.length?`^(${o.map(i=>el(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}}),YI=xe("$ZodLiteral",(e,t)=>{Fn.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"?el(r):r?el(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}}),XI=xe("$ZodTransform",(e,t)=>{var n;Fn.init(e,t),e._zod.optin="optional",(n=qo.memoizer)==null||n.guard(e),e._zod.parse=(r,o)=>{if(o.direction==="backward")throw new i1(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 Za;return r.value=i,r}});function zv(e,t){return e.value=t.issues.length?void 0:t.value,e}const E1=xe("$ZodOptional",(e,t)=>{Fn.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(`^(${Eg(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=>zv(n,i)):zv(n,o)}return t.innerType._zod.run(n,r)}}),QI=xe("$ZodExactOptional",(e,t)=>{E1.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)}),JI=xe("$ZodNullable",(e,t)=>{Fn.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(`^(${Eg(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)}),eR=xe("$ZodDefault",(e,t)=>{Fn.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=>Fv(i,t)):Fv(o,t)}});function Fv(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const tR=xe("$ZodPrefault",(e,t)=>{Fn.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))}),nR=xe("$ZodNonOptional",(e,t)=>{Fn.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=>Bv(i,e)):Bv(o,e)}});function Bv(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 Uv(e,t,n,r){return t.issues.length?(e.value=n.catchValue({...t,value:e.value,error:{issues:t.issues.map(o=>cl(o,r,fi()))},input:e.value}),e):(e.value=t.value,t.memo&&(e.memo=!0),e)}const rR=xe("$ZodCatch",(e,t)=>{Fn.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=>Uv(n,i,t,r)):Uv(n,o,t,r)}}),oR=xe("$ZodPipe",(e,t)=>{Fn.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=>Ju(l,t.in,r)):Ju(i,t.in,r)}const o=t.in._zod.run(n,r);return o instanceof Promise?o.then(i=>Ju(i,t.out,r)):Ju(o,t.out,r)}});function Ju(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 sR=xe("$ZodReadonly",(e,t)=>{Fn.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(Hv):Hv(o)}});function Hv(e){return e.memo||(e.value=Object.freeze(e.value)),e}const iR=xe("$ZodCustom",(e,t)=>{oo.init(e,t),Fn.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=>Wv(i,n,r,e));Wv(o,n,r,e)}});function Wv(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(bc(o))}}class aR extends Error{constructor(){super("Cannot parse a reference cycle that closes through a transform"),this.name="ZodCyclicError"}}const wm="~memo",Kv=[];function Cp(e){return e.map(t=>t.path?{...t,path:t.path.slice()}:{...t})}const Zv=new WeakMap;function _1(e,t){const n=Zv.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)&&_1(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 p of h)o(p)}}}return t.delete(e),Zv.set(e,r),r}function lR(e,t){let n=e.buckets.get(t);return n||(n=new Map,e.buckets.set(t,n)),n}let ed;const td=[],cR={alloc(e,t,n){const r=ed;if(!r)return n;ed=void 0;const o={value:n,issues:null};return r.set(t.value,o),td.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"&&dR(i,o.value))throw new aR;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=_1(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 p=u[wm];p||(p={buckets:new Map,backEdges:void 0},u[wm]=p);let m;r===u?m=o:(m=lR(p,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(...Cp(g.issues)):(c.memo=!0,p.backEdges??(p.backEdges=new Set),p.backEdges.add(g.value)),c;ed=m;const y=td.length,w=i(c,u);ed=void 0;const b=td.length>y?td.pop():void 0;return w instanceof Promise?w.then(E=>(b&&(b.issues=E.issues.length?Cp(E.issues):Kv),E)):(b&&(b.issues=w.issues.length?Cp(w.issues):Kv),w)};e._zod.parse=l,e._zod.run===i&&(e._zod.run=l)})}};function uR(){return cR}function dR(e,t){var r;const n=(r=e[wm])==null?void 0:r.backEdges;return n!==void 0&&t!==null&&typeof t=="object"&&n.has(t)}const fR=()=>{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=ZC(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 ${o1(i.values[0])}`:`Invalid option: expected one of ${Sv(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":""}: ${Sv(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 hR(){return{localeError:fR()}}var qv;class pR{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 mR(){return new pR}(qv=globalThis).__zod_globalRegistry??(qv.__zod_globalRegistry=mR());const ec=globalThis.__zod_globalRegistry;function gR(e,t){return new e({type:"string",...at(t)})}function kR(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...at(t)})}function wR(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...at(t)})}function yR(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...at(t)})}function vR(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...at(t)})}function bR(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...at(t)})}function xR(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...at(t)})}function ER(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...at(t)})}function _R(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...at(t)})}function SR(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...at(t)})}function NR(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...at(t)})}function TR(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...at(t)})}function jR(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...at(t)})}function CR(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...at(t)})}function AR(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...at(t)})}function IR(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...at(t)})}function RR(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...at(t)})}function $R(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...at(t)})}function OR(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...at(t)})}function MR(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...at(t)})}function LR(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...at(t)})}function PR(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...at(t)})}function DR(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...at(t)})}function zR(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...at(t)})}function FR(e,t){return new e({type:"string",format:"date",check:"string_format",...at(t)})}function BR(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...at(t)})}function UR(e,t){return new e({type:"string",format:"duration",check:"string_format",...at(t)})}function HR(e,t){return new e({type:"number",checks:[],...at(t)})}function WR(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...at(t)})}function KR(e,t){return new e({type:"boolean",...at(t)})}function ZR(e){return new e({type:"unknown"})}function qR(e,t){return new e({type:"never",...at(t)})}function Gv(e,t){return new f1({check:"less_than",...at(t),value:e,inclusive:!1})}function Ap(e,t){return new f1({check:"less_than",...at(t),value:e,inclusive:!0})}function Vv(e,t){return new h1({check:"greater_than",...at(t),value:e,inclusive:!1})}function Ip(e,t){return new h1({check:"greater_than",...at(t),value:e,inclusive:!0})}function Yv(e,t){return new ZA({check:"multiple_of",...at(t),value:e})}function S1(e,t){return new GA({check:"max_length",...at(t),maximum:e})}function Ld(e,t){return new VA({check:"min_length",...at(t),minimum:e})}function N1(e,t){return new YA({check:"length_equals",...at(t),length:e})}function GR(e,t){return new XA({check:"string_format",format:"regex",...at(t),pattern:e})}function VR(e){return new QA({check:"string_format",format:"lowercase",...at(e)})}function YR(e){return new JA({check:"string_format",format:"uppercase",...at(e)})}function XR(e,t){return new eI({check:"string_format",format:"includes",...at(t),includes:e})}function QR(e,t){return new tI({check:"string_format",format:"starts_with",...at(t),prefix:e})}function JR(e,t){return new nI({check:"string_format",format:"ends_with",...at(t),suffix:e})}function ul(e){return new rI({check:"overwrite",tx:e})}function e$(e){return ul(t=>t.normalize(e))}function t$(){return ul(e=>e.trim())}function n$(){return ul(e=>e.toLowerCase())}function r$(){return ul(e=>e.toUpperCase())}function o$(){return ul(e=>$C(e))}function s$(e,t,n){return new e({type:"array",element:t,...at(n)})}function i$(e,t,n){return new e({type:"custom",check:"custom",fn:t,...at(n)})}function a$(e,t){const n=l$(r=>(r.addIssue=o=>{if(typeof o=="string")r.issues.push(bc(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(bc(i))}},e(r.value,r)),t);return n}function l$(e,t){const n=new oo({check:"custom",...at(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)&&ro(e,r,n[r]);return e}function T1(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)??ec,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 ii(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 cr(e,t,n={path:[],schemaPath:[]}){var p,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=(p=e._zod).toJSONSchema)==null?void 0:m.call(p);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 w=l.schema,b=t.processors[o.type];if(!b)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${o.type}`);b(e,t,w,g)}const y=e._zod.parent;y&&(l.ref||(l.ref=y),cr(y,t,g),t.seen.get(y).isParent=!0)}const u=t.metadataRegistry.get(e);return u&&uc(l.schema,u),t.io==="input"&&Ur(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 Xv(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function j1(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 p of e.seen.entries()){const m=(l=e.metadataRegistry.get(p[0]))==null?void 0:l.id;if(m){const g=r.get(m);if(g&&g!==p[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,p[0])}}const o=p=>{var b;const m=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){const E=(b=e.external.registry.get(p[0]))==null?void 0:b.id,_=e.external.uri??(T=>T);if(E)return{ref:_(E)};const N=p[1].defId??p[1].schema.id??`schema${e.counter++}`;return p[1].defId=N,{defId:N,ref:`${_("__shared")}#/${m}/${Xv(N)}`}}const g="#",y=`${g}/${m}/`;if(p[1]===n&&!p[1].schema.id)return{ref:g};const w=p[1].schema.id??`__schema${e.counter++}`;return{defId:w,ref:y+Xv(w)}},i=p=>{if(p[1].schema.$ref)return;const m=p[1],{ref:g,defId:y}=o(p);m.def={...m.schema},y&&(m.defId=y);const w=m.schema;for(const b in w)delete w[b];w.$ref=g};if(e.cycles==="throw")for(const p of e.seen.entries()){const m=p[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 p of e.seen.entries()){const m=p[1];if(t===p[0]){i(p);continue}if(e.external){const y=(u=e.external.registry.get(p[0]))==null?void 0:u.id;if(t!==p[0]&&y){i(p);continue}}if((h=e.metadataRegistry.get(p[0]))==null?void 0:h.id){i(p);continue}if(m.cycle){i(p);continue}if(m.count>1&&e.reused==="ref"){i(p);continue}}e.external&&(e.sharedDefsExtractedFor=e.external)}function C1(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;C1(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 A1=new Set(["type","properties","required","additionalProperties"]),Qv=["oneOf","anyOf"];function Jv(e){const t=e.additionalProperties;return t===void 0||t===!1||typeof t!="object"||t===null?null:Object.keys(t).length?t:null}function ym(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(!A1.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 p of t){const m=((i=p.properties)==null?void 0:i[c])??Jv(p);m!=null&&(u.some(g=>JSON.stringify(g)===JSON.stringify(m))||u.push(m))}const h=u.length===1?u[0]:ym(u)??{allOf:u};ro(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=Jv(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 c$(e){const t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(const o of A1)if(o in e)return;const n=t.filter(o=>Qv.some(i=>Array.isArray(o[i])));let r=null;if(!n.length)r=ym(t);else{const o=n[0],i=Qv.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=>ym([...l,u]));if(c.some(u=>!u))return;r={[i]:c}}r&&(delete e.allOf,uc(e,r))}function I1(e,t){var c,u,h,p;const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=m=>{const g=e.seen.get(m);if(g.ref===null)return;const y=g.def??g.schema,w={...y},b=g.ref;if(g.ref=null,b){r(b);const _=e.seen.get(b),N=_.schema;if(N.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(y.allOf=y.allOf??[],y.allOf.push(N)):uc(y,N),uc(y,w),m._zod.parent===b)for(const R in y)R==="$ref"||R==="allOf"||R in w||delete y[R];if(N.$ref&&_.def)for(const R in y)R==="$ref"||R==="allOf"||R in _.def&&JSON.stringify(y[R])===JSON.stringify(_.def[R])&&delete y[R]}const E=m._zod.parent;if(E&&E!==b){r(E);const _=e.seen.get(E);if(_!=null&&_.schema.$ref&&(y.$ref=_.schema.$ref,_.def))for(const N in y)N==="$ref"||N==="allOf"||N in _.def&&JSON.stringify(y[N])===JSON.stringify(_.def[N])&&delete y[N]}e.override({zodSchema:m,jsonSchema:y,path:g.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(const m of[...e.seen.entries()].reverse())r(m[0]);if(e.target!=="openapi-3.0")for(const m of e.seen.entries())C1(m[1].def??m[1].schema);for(const m of e.deferred)m();if(e.intersections.length){const m=new Map;for(const g of e.seen.values())for(const y of[g.schema,g.def]){const w=y==null?void 0:y.allOf;if(!Array.isArray(w))continue;const b=m.get(w);b?b.push(y):m.set(w,[y])}for(const g of e.intersections)for(const y of m.get(g)??[])c$(y)}}const o={};if(e.target==="draft-2020-12"?o.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?o.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?o.$schema="http://json-schema.org/draft-04/schema#":e.target,(c=e.external)!=null&&c.uri){const m=(u=e.external.registry.get(t))==null?void 0:u.id;if(!m)throw new Error("Schema is missing an `id` property");o.$id=e.external.uri(m)}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=((p=e.external)==null?void 0:p.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,ro(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:Pd(t,"input",e.processors),output:Pd(t,"output",e.processors)}},enumerable:!1,writable:!1}),m}catch{throw new Error("Error converting schema to JSON.")}}function Ur(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 Ur(r.element,n);if(r.type==="set")return Ur(r.valueType,n);if(r.type==="lazy")return Ur(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 Ur(r.innerType,n);if(r.type==="intersection")return Ur(r.left,n)||Ur(r.right,n);if(r.type==="record"||r.type==="map")return Ur(r.keyType,n)||Ur(r.valueType,n);if(r.type==="pipe")return e._zod.traits.has("$ZodCodec")?!0:Ur(r.in,n)||Ur(r.out,n);if(r.type==="object"){for(const o in r.shape)if(Ur(r.shape[o],n))return!0;return!1}if(r.type==="union"){for(const o of r.options)if(Ur(o,n))return!0;return!1}if(r.type==="tuple"){for(const o of r.items)if(Ur(o,n))return!0;return!!(r.rest&&Ur(r.rest,n))}return!1}const u$=(e,t={})=>n=>{const r=T1({...n,processors:t});return cr(e,r),j1(r,e),I1(r,e)},Pd=(e,t,n={})=>r=>{const{libraryOptions:o,target:i}=r??{},l=T1({...o??{},target:i,io:t,processors:n});return cr(e,l),j1(l,e),I1(l,e)},d$={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},f$=(e,t,n,r)=>{const o=n;o.type="string";const{minimum:i,maximum:l,format:c,patterns:u,contentEncoding:h,laxFormat:p}=e._zod.bag;if(typeof i=="number"&&(o.minLength=i),typeof l=="number"&&(o.maxLength=l),c&&(o.format=d$[c]??c,o.format===""&&delete o.format,(c==="time"||p)&&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}))])}},h$=(e,t,n,r)=>{const o=n,{minimum:i,maximum:l,format:c,multipleOf:u,exclusiveMaximum:h,exclusiveMinimum:p}=e._zod.bag;typeof c=="string"&&c.includes("int")?o.type="integer":o.type="number";const m=typeof p=="number"&&p>=(i??Number.NEGATIVE_INFINITY),g=typeof h=="number"&&h<=(l??Number.POSITIVE_INFINITY),y=t.target==="draft-04"||t.target==="openapi-3.0";m?y?(o.minimum=p,o.exclusiveMinimum=!0):o.exclusiveMinimum=p:typeof i=="number"&&(o.minimum=i),g?y?(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):ii(e,t,o,r,`A multipleOf divisor of ${u} cannot be represented in JSON Schema`))},p$=(e,t,n,r)=>{n.type="boolean"},m$=(e,t,n,r)=>{n.not={}},g$=(e,t,n,r)=>{},k$=(e,t,n,r)=>{const o=e._zod.def,i=t1(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},w$=(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(ii(e,t,n,r,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof l=="bigint"){if(ii(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},y$=(e,t,n,r)=>{ii(e,t,n,r,"Custom types cannot be represented in JSON Schema")},v$=(e,t,n,r)=>{ii(e,t,n,r,"Transforms cannot be represented in JSON Schema")},b$=(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=cr(i.element,t,{...r,path:[...r.path,"items"]})};function Dd(e){const t=e._zod.def;return t.type==="pipe"&&t.in._zod.traits.has("$ZodTransform")?Dd(t.out):t.type==="catch"?Dd(t.innerType):e._zod.optin}const x$=(e,t,n,r)=>{var p;const o=n,i=e._zod.def,l=i.shape;if(Object.getOwnPropertySymbols(l).length&&ii(e,t,o,r,"Symbol keys cannot be represented in JSON Schema"))return;o.type="object",o.properties={};for(const m in l)ro(o.properties,m,cr(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"?Dd(g)===void 0:g._zod.optout===void 0}));h.size>0&&(o.required=Array.from(h)),((p=i.catchall)==null?void 0:p._zod.def.type)==="never"?o.additionalProperties=!1:i.catchall?i.catchall&&(o.additionalProperties=cr(i.catchall,t,{...r,path:[...r.path,"additionalProperties"]})):t.io==="output"&&(o.additionalProperties=!1)},E$=(e,t,n,r)=>{const o=e._zod.def,i=o.inclusive===!1,l=o.options.map((c,u)=>cr(c,t,{...r,path:[...r.path,i?"oneOf":"anyOf",u]}));i?n.oneOf=l:n.anyOf=l},_$=(e,t,n,r)=>{const o=e._zod.def,i=cr(o.left,t,{...r,path:[...r.path,"allOf",0]}),l=cr(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)},S$=(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((b,E)=>cr(b,t,{...r,path:[...r.path,l,E]})),h=i.rest?cr(i.rest,t,{...r,path:[...r.path,c,...t.target==="openapi-3.0"?[i.items.length]:[]]}):null;let p=i.items.length;for(;p>0;){const b=i.items[p-1];if(!(t.io==="input"?Dd(b)!==void 0:b._zod.optout==="optional"))break;p--}const m=i.items.length,g=!i.rest;t.target==="draft-2020-12"?(o.prefixItems=u,g?o.items=!1:h&&(o.items=h),p>0&&(o.minItems=p),g&&(o.maxItems=m)):t.target==="openapi-3.0"?(o.items={anyOf:u},h&&o.items.anyOf.push(h),p>0&&(o.minItems=p),g&&(o.maxItems=m)):(o.items=u,g?o.additionalItems=!1:h&&(o.additionalItems=h),p>0&&(o.minItems=p),g&&(o.maxItems=m));const{minimum:y,maximum:w}=e._zod.bag;typeof y=="number"&&(o.minItems=y),typeof w=="number"&&(o.maxItems=w)},N$=(e,t,n,r)=>{const o=e._zod.def,i=cr(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"}]},T$=(e,t,n,r)=>{const o=e._zod.def;cr(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType},Ag=Symbol();function R1(e,t,n,r,o){let i=!1;const l=JSON.stringify(e,(c,u)=>typeof u!="bigint"?u:(i=!0,null));return i?(ii(t,n,r,o,"BigInt defaults cannot be represented in JSON Schema"),Ag):JSON.parse(l)}const j$=(e,t,n,r)=>{const o=e._zod.def;cr(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType;const l=R1(o.defaultValue,e,t,n,r);l!==Ag&&(n.default=l)},C$=(e,t,n,r)=>{const o=e._zod.def;cr(o.innerType,t,r);const i=t.seen.get(e);if(i.ref=o.innerType,t.io!=="input")return;const l=R1(o.defaultValue,e,t,n,r);l!==Ag&&(n._prefault=l)},A$=(e,t,n,r)=>{const o=e._zod.def;cr(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType;let l;try{l=o.catchValue(void 0)}catch{ii(e,t,n,r,"Dynamic catch values are not supported in JSON Schema");return}n.default=l},I$=(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;cr(l,t,r);const c=t.seen.get(e);c.ref=l},R$=(e,t,n,r)=>{const o=e._zod.def;cr(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType,n.readOnly=!0},$1=(e,t,n,r)=>{const o=e._zod.def;cr(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType},e0=new WeakSet([Object.prototype,Error.prototype]);function nd(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 $$=(e,t)=>{l1.init(e,t),e.name="ZodError";const n=Object.getPrototypeOf(e);e0.has(n)||(e0.add(n),nd(n,"format",r=>o=>iA(r,o)),nd(n,"flatten",r=>o=>sA(r,o)),nd(n,"addIssue",r=>o=>{r.issues.push(o),r.message=JSON.stringify(r.issues,pm,2)}),nd(n,"addIssues",r=>o=>{r.issues.push(...o),r.message=JSON.stringify(r.issues,pm,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},To=xe("ZodError",$$,void 0,{Parent:Error}),O$=Ng(To),M$=Tg(To),L$=gf(To),P$=kf(To),D$=cA(To),z$=uA(To),F$=dA(To),B$=fA(To),U$=hA(To),H$=pA(To),W$=mA(To),K$=gA(To);function Z$(){qo.localeError||fi(hR())}function yf(){qo.memoizer||fi({memoizer:uR()})}const Wn=xe("ZodType",(e,t)=>(Z$(),Fn.init(e,t),e.def=t,e.type=t.type,e),{check(...e){const t=this.def;return this.clone(ui(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 di(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(WO(e,t))},superRefine(e,t){return this.check(KO(e,t))},overwrite(e){return this.check(ul(e))},optional(){return r0(this)},exactOptional(){return RO(this)},nullable(){return o0(this)},nullish(){return r0(o0(this))},nonoptional(e){return DO(this,e)},array(){return Ui(this)},or(e){return EO([this,e])},and(e){return TO(this,e)},transform(e){return s0(this,IO(e))},default(e){return MO(this,e)},prefault(e){return PO(this,e)},catch(e){return FO(this,e)},pipe(e){return s0(this,e)},readonly(){return HO(this)},describe(e){const t=this.clone();return ec.add(t,{description:e}),t},meta(...e){if(e.length===0)return ec.get(this);const t=this.clone();return ec.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 s1(this,"~standard",{...p1(this),jsonSchema:{input:Pd(this,"input"),output:Pd(this,"output")}})},set"~standard"(e){tl(this,"~standard",e)},parse:function e(t,n){return O$(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await M$(this,t,n,{callee:e})},safeParse(e,t){return L$(this,e,t)},async safeParseAsync(e,t){return P$(this,e,t)},get spa(){return this==null?void 0:this.safeParseAsync},set spa(e){tl(this,"spa",e)},encode:function e(t,n){return D$(this,t,n,{callee:e})},decode:function e(t,n){return z$(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await F$(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await B$(this,t,n,{callee:e})},safeEncode(e,t){return U$(this,e,t)},safeDecode(e,t){return H$(this,e,t)},async safeEncodeAsync(e,t){return W$(this,e,t)},async safeDecodeAsync(e,t){return K$(this,e,t)},toJSONSchema(e){return u$(this,{})(e)},get description(){var e;return(e=ec.get(this))==null?void 0:e.description},get _def(){return this._zod.def}}),O1=xe("_ZodString",(e,t)=>{Cg.init(e,t),Wn.init(e,t),e._zod.processJSONSchema=(r,o,i)=>f$(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(GR(...e))},includes(...e){return this.check(XR(...e))},startsWith(...e){return this.check(QR(...e))},endsWith(...e){return this.check(JR(...e))},min(...e){return this.check(Ld(...e))},max(...e){return this.check(S1(...e))},length(...e){return this.check(N1(...e))},nonempty(...e){return this.check(Ld(1,...e))},lowercase(e){return this.check(VR(e))},uppercase(e){return this.check(YR(e))},trim(){return this.check(t$())},normalize(...e){return this.check(e$(...e))},toLowerCase(){return this.check(n$())},toUpperCase(){return this.check(r$())},slugify(){return this.check(o$())}}),q$=xe("ZodString",(e,t)=>{Cg.init(e,t),O1.init(e,t)},{email(e){return this.check(kR(Q$,e))},url(e){return this.check(ER(eO,e))},jwt(e){return this.check(DR(mO,e))},emoji(e){return this.check(_R(tO,e))},guid(e){return this.check(wR(J$,e))},uuid(e){return this.check(yR(rd,e))},uuidv4(e){return this.check(vR(rd,e))},uuidv6(e){return this.check(bR(rd,e))},uuidv7(e){return this.check(xR(rd,e))},nanoid(e){return this.check(SR(nO,e))},cuid(e){return this.check(NR(rO,e))},cuid2(e){return this.check(TR(oO,e))},ulid(e){return this.check(jR(sO,e))},base64(e){return this.check(MR(fO,e))},base64url(e){return this.check(LR(hO,e))},xid(e){return this.check(CR(iO,e))},ksuid(e){return this.check(AR(aO,e))},ipv4(e){return this.check(IR(lO,e))},ipv6(e){return this.check(RR(cO,e))},cidrv4(e){return this.check($R(uO,e))},cidrv6(e){return this.check(OR(dO,e))},e164(e){return this.check(PR(pO,e))},datetime(e){return this.check(zR(G$,e))},date(e){return this.check(FR(V$,e))},time(e){return this.check(BR(Y$,e))},duration(e){return this.check(UR(X$,e))}});function Sn(e){return gR(q$,e)}const Kn=xe("ZodStringFormat",(e,t)=>{Bn.init(e,t),O1.init(e,t)}),G$=xe("ZodISODateTime",(e,t)=>{xI.init(e,t),Kn.init(e,t)}),V$=xe("ZodISODate",(e,t)=>{EI.init(e,t),Kn.init(e,t)}),Y$=xe("ZodISOTime",(e,t)=>{_I.init(e,t),Kn.init(e,t)}),X$=xe("ZodISODuration",(e,t)=>{SI.init(e,t),Kn.init(e,t)}),Q$=xe("ZodEmail",(e,t)=>{lI.init(e,t),Kn.init(e,t)}),J$=xe("ZodGUID",(e,t)=>{iI.init(e,t),Kn.init(e,t)}),rd=xe("ZodUUID",(e,t)=>{aI.init(e,t),Kn.init(e,t)}),eO=xe("ZodURL",(e,t)=>{pI.init(e,t),Kn.init(e,t)}),tO=xe("ZodEmoji",(e,t)=>{mI.init(e,t),Kn.init(e,t)}),nO=xe("ZodNanoID",(e,t)=>{gI.init(e,t),Kn.init(e,t)}),rO=xe("ZodCUID",(e,t)=>{kI.init(e,t),Kn.init(e,t)}),oO=xe("ZodCUID2",(e,t)=>{wI.init(e,t),Kn.init(e,t)}),sO=xe("ZodULID",(e,t)=>{yI.init(e,t),Kn.init(e,t)}),iO=xe("ZodXID",(e,t)=>{vI.init(e,t),Kn.init(e,t)}),aO=xe("ZodKSUID",(e,t)=>{bI.init(e,t),Kn.init(e,t)}),lO=xe("ZodIPv4",(e,t)=>{NI.init(e,t),Kn.init(e,t)}),cO=xe("ZodIPv6",(e,t)=>{jI.init(e,t),Kn.init(e,t)}),uO=xe("ZodCIDRv4",(e,t)=>{CI.init(e,t),Kn.init(e,t)}),dO=xe("ZodCIDRv6",(e,t)=>{II.init(e,t),Kn.init(e,t)}),fO=xe("ZodBase64",(e,t)=>{RI.init(e,t),Kn.init(e,t)}),hO=xe("ZodBase64URL",(e,t)=>{OI.init(e,t),Kn.init(e,t)}),pO=xe("ZodE164",(e,t)=>{MI.init(e,t),Kn.init(e,t)}),mO=xe("ZodJWT",(e,t)=>{PI.init(e,t),Kn.init(e,t)}),M1=xe("ZodNumber",(e,t)=>{y1.init(e,t),Wn.init(e,t),e._zod.processJSONSchema=(r,o,i)=>h$(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(Vv(e,t))},gte(e,t){return this.check(Ip(e,t))},min(e,t){return this.check(Ip(e,t))},lt(e,t){return this.check(Gv(e,t))},lte(e,t){return this.check(Ap(e,t))},max(e,t){return this.check(Ap(e,t))},int(e){return this.check(t0(e))},safe(e){return this.check(t0(e))},positive(e){return this.check(Vv(0,e))},nonnegative(e){return this.check(Ip(0,e))},negative(e){return this.check(Gv(0,e))},nonpositive(e){return this.check(Ap(0,e))},multipleOf(e,t){return this.check(Yv(e,t))},step(e,t){return this.check(Yv(e,t))},finite(){return this}});function Bi(e){return HR(M1,e)}const gO=xe("ZodNumberFormat",(e,t)=>{DI.init(e,t),M1.init(e,t)});function t0(e){return WR(gO,e)}const kO=xe("ZodBoolean",(e,t)=>{zI.init(e,t),Wn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>p$(e,n,r)});function Uo(e){return KR(kO,e)}const wO=xe("ZodUnknown",(e,t)=>{FI.init(e,t),Wn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>g$()});function n0(){return ZR(wO)}const yO=xe("ZodNever",(e,t)=>{BI.init(e,t),Wn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>m$(e,n,r)});function vO(e){return qR(yO,e)}const bO=xe("ZodArray",(e,t)=>{yf(),UI.init(e,t),Wn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>b$(e,n,r,o),e.element=t.element},{min(e,t){return this.check(Ld(e,t))},nonempty(e){return this.check(Ld(1,e))},max(e,t){return this.check(S1(e,t))},length(e,t){return this.check(N1(e,t))},unwrap(){return this.element}});function Ui(e,t){return s$(bO,e,t)}const xO=xe("ZodObject",(e,t)=>{yf(),KI.init(e,t),Wn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>x$(e,n,r,o),XC(e,"shape",n=>n._zod.def.shape,!1)},{keyof(){return dc(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:n0()})},loose(){return this.clone({...this._zod.def,catchall:n0()})},strict(){return this.clone({...this._zod.def,catchall:vO()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return FC(this,e)},safeExtend(e){return BC(this,e)},merge(e){return UC(this,e)},pick(e){return DC(this,e)},omit(e){return zC(this,e)},partial(...e){return Nv(Ig,this,e[0])},exactPartial(...e){return Nv(D1,this,e[0],"exactPartial")},required(...e){return HC(z1,this,e[0])}});function _r(e,t){const n={type:"object",shape:e??{},...at(t)};return new xO(n)}const L1=xe("ZodUnion",(e,t)=>{x1.init(e,t),Wn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>E$(e,n,r,o),e.options=t.options});function EO(e,t){return new L1({type:"union",options:e,...at(t)})}const _O=xe("ZodDiscriminatedUnion",(e,t)=>{L1.init(e,t),ZI.init(e,t)});function SO(e,t,n){return new _O({type:"union",options:t,discriminator:e,...at(n)})}const NO=xe("ZodIntersection",(e,t)=>{qI.init(e,t),Wn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>_$(e,n,r,o)});function TO(e,t){return new NO({type:"intersection",left:e,right:t})}const jO=xe("ZodTuple",(e,t)=>{yf(),GI.init(e,t),Wn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>S$(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 Ig({type:"optional",innerType:n}))})}});function P1(e,t,n){const r=t instanceof Fn,o=r?n:t,i=r?t:null;return new jO({type:"tuple",items:e,rest:i,...at(o)})}const vm=xe("ZodEnum",(e,t)=>{VI.init(e,t),Wn.init(e,t),e._zod.processJSONSchema=(r,o,i)=>k$(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 vm({...t,checks:[],...at(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 vm({...t,checks:[],...at(o),entries:i})}});function dc(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(r=>[r,r])):e;return new vm({type:"enum",entries:n,...at(t)})}const CO=xe("ZodLiteral",(e,t)=>{YI.init(e,t),Wn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>w$(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 Xr(e,t){return new CO({type:"literal",values:Array.isArray(e)?e:[e],...at(t)})}const AO=xe("ZodTransform",(e,t)=>{yf(),XI.init(e,t),Wn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>v$(e,n,r,o),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new i1(e.constructor.name);n.addIssue=i=>{if(typeof i=="string")n.issues.push(bc(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(bc(l))}};const o=t.transform(n.value,n);return o instanceof Promise?o.then(i=>(n.value=i,n)):(n.value=o,n)}});function IO(e){return new AO({type:"transform",transform:e})}const Ig=xe("ZodOptional",(e,t)=>{E1.init(e,t),Wn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>$1(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function r0(e){return new Ig({type:"optional",innerType:e})}const D1=xe("ZodExactOptional",(e,t)=>{QI.init(e,t),Wn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>$1(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function RO(e){return new D1({type:"optional",innerType:e})}const $O=xe("ZodNullable",(e,t)=>{JI.init(e,t),Wn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>N$(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function o0(e){return new $O({type:"nullable",innerType:e})}const OO=xe("ZodDefault",(e,t)=>{eR.init(e,t),Wn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>j$(e,n,r,o),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function MO(e,t){return new OO({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():r1(t)}})}const LO=xe("ZodPrefault",(e,t)=>{tR.init(e,t),Wn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>C$(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function PO(e,t){return new LO({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():r1(t)}})}const z1=xe("ZodNonOptional",(e,t)=>{nR.init(e,t),Wn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>T$(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function DO(e,t){return new z1({type:"nonoptional",innerType:e,...at(t)})}const zO=xe("ZodCatch",(e,t)=>{rR.init(e,t),Wn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>A$(e,n,r,o),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function FO(e,t){return new zO({type:"catch",innerType:e,catchValue:typeof t=="function"?t:JC(t)})}const BO=xe("ZodPipe",(e,t)=>{oR.init(e,t),Wn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>I$(e,n,r,o),e.in=t.in,e.out=t.out});function s0(e,t){return new BO({type:"pipe",in:e,out:t})}const UO=xe("ZodReadonly",(e,t)=>{sR.init(e,t),Wn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>R$(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function HO(e){return new UO({type:"readonly",innerType:e})}const F1=xe("ZodCustom",(e,t)=>{iR.init(e,t),Wn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>y$(e,n,r,o)});function WO(e,t={}){return i$(F1,e,t)}function KO(e,t){return a$(e,t)}function ZO(e,t={}){const n=new F1({type:"custom",check:"custom",fn:r=>r instanceof e,abort:!0,...at(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 qO=["off","tailscale","any"],GO={updates:!0,deploy:!0,remote:"any",agents:null,customAgents:!0,brandedListener:!0,planSignIn:!0};_r({updates:Uo().optional(),deploy:Uo().optional(),remote:dc(qO).optional(),agents:Ui(Sn()).optional(),customAgents:Uo().optional(),brandedListener:Uo().optional(),planSignIn:Uo().optional()});const VO={...GO,source:null,problem:null};function YO(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 Rp=6e3,i0=1500;function XO(e){if(e.length<=Rp)return e;const t=e.length-Rp;return`${e.slice(0,i0)}
94
+ [${t} characters cut here]
95
+ ${e.slice(e.length-(Rp-i0))}`}const od=105,QO=2e3,JO=1e3,e2=10,t2=2048,zd=5e6,n2=["image/png","image/jpeg","image/gif","image/webp"],a0=2576,$p=5*1024*1024,r2=1200,o2=10,s2=1e5,l0=100*1024*1024,i2="pasted-text.txt";function a2(e){return e.t==="term-data"||e.t==="term-snapshot"||e.t==="term-exit"}function l2(e){return e.t==="file-read"||e.t==="file-written"||e.t==="file-blame"}const c2=80;function Rg(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,c2)}}function B1(e){return e.length>=r2||e.split(`
97
+ `).length>=o2}function u2({startLine:e,endLine:t}){return e===t?`${e}`:`${e}-${t}`}function d2(e){return`${e.path.slice(e.path.lastIndexOf("/")+1)} (${u2(e)})`}const f2=/\u001B(?:\[[0-?]*[ -/]*[@-~]|\][^\u0007]*(?:\u0007|\u001B\\))/g;function h2(e){return e.replace(f2,"")}const U1="Projects";function p2(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":p2(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 m2=/^(?:https?|ssh|git|file):\/\/\S+$/i,H1=/^[\w.-]+@[\w.-]+:\S+$/;function g2(e){const t=e.trim();if(!m2.test(t)&&!H1.test(t))return null;const n=k2(t);return n&&!xc(n)?{url:t,name:n}:null}function k2(e){var o;const t=((o=e.split(/[?#]/)[0])==null?void 0:o.replace(/\/+$/,""))??"";return((H1.test(t)?t.split(":")[1]??"":t).split("/").pop()??"").replace(/\.git$/i,"")}const w2=_r({component:Sn().nullable(),file:Sn().nullable(),line:Bi().nullable(),callFile:Sn().nullable().default(null),callLine:Bi().nullable().default(null),tag:Sn(),selector:Sn()}),y2=_r({tag:Sn().max(40),id:Sn().max(200),classes:Ui(Sn().max(120)).max(16),text:Sn().max(200),attrs:Ui(P1([Sn().max(40),Sn().max(200)])).max(12)}),v2=P1([Bi(),Bi()]),b2=w2.extend({classes:Sn(),text:Sn(),html:Sn(),route:Sn(),element:y2}),x2=SO("type",[_r({type:Xr("loaded"),url:Sn(),title:Sn()}),_r({type:Xr("navigated"),url:Sn(),title:Sn().optional()}),_r({type:Xr("traversed"),dir:dc(["back","forward"]).optional()}),_r({type:Xr("title"),title:Sn()}),_r({type:Xr("links"),links:Ui(_r({path:Sn().max(2048),text:Sn().max(120)})).max(200)}),_r({type:Xr("hmr")}),_r({type:Xr("page-error"),message:Sn(),source:Sn().optional(),line:Bi().optional()}),b2.extend({type:Xr("picked"),verb:dc(["chat","code"]).default("chat"),site:dc(["call","source"]).default("source")}),_r({type:Xr("pick-cancel")}),_r({type:Xr("highlight-miss"),path:Sn(),fileMatched:Bi(),withSource:Bi(),ranges:Ui(v2).nullable()}),_r({type:Xr("drag-files")}),_r({type:Xr("drop-files"),files:Ui(ZO(File))}),_r({type:Xr("focus"),gesture:Uo()}),_r({type:Xr("key"),key:Sn(),code:Sn().optional(),meta:Uo(),ctrl:Uo().optional(),shift:Uo().optional(),alt:Uo().optional(),up:Uo().optional()})]);function W1(e){const t=x2.safeParse(e);return t.success?t.data:null}const E2=/["“”]([^"“”]*)["“”]?|(\S+)/g;function K1(e){const t=new Set;for(const n of e.matchAll(E2)){const r=(n[1]??n[2]??"").replace(/\s+/g," ").trim().toLowerCase();r&&t.add(r)}return[...t]}const _2="now",S2="http://preview.invalid",N2=200;function c0(e){const t=e==null?void 0:e.replace(/\s+/g," ").trim().slice(0,N2).trim();return t||void 0}function vf(e){let t;try{t=new URL(e,S2)}catch{return null}if(t.pathname.startsWith("/__toyon"))return null;const n=u0(t.pathname)||"/",r=t.hash.startsWith("#/")?u0(t.hash.split("?")[0]??""):"";return r.length>1?`${n}${r}`:n}const u0=e=>e.replace(/\/+$/,""),T2={static:4,mixed:3.5,param:3,optional:2,"optional-static":2,splat:1},Fd=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");function Z1(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 p=e.slice(c,h.index);p&&(i.push({text:p}),l+=Fd(p)),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+=Fd(u)),i.some(h=>"name"in h))return{kind:"mixed",pattern:l,parts:i}}return{kind:"static",text:e}}function j2(e){const t=e.split("/").filter(Boolean).map(Z1);if(t.every(r=>r.kind==="static"))return null;let n="";for(const r of t)r.kind==="static"?n+=`/${Fd(r.text)}`:r.kind==="optional-static"?n+=`(?:/${Fd(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+T2[o.kind],0),statics:t.filter(r=>r.kind==="static").length}}function C2(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 bf(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(Z1))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 Pc={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"}},q1={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"}},A2={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"}},I2={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"}},R2={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"}},$2={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"}},O2={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"}},M2={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"}},L2={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"}},P2={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"}},D2={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"}},z2={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"}},F2={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"}},B2={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"}},U2={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"}},H2={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"}},W2={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"}},K2={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"}},Z2={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"}},q2=[L2,P2,D2,z2,F2,B2,U2,H2,W2,K2,Z2],xd=[Pc,q1,A2,I2,R2,$2,O2,M2,...q2],G2={mode:"dark",light:q1.id,dark:Pc.id},V2=["surface0","surface1","surface2","element0","element1","border0","border1","text0","text1","text2","red","orange","yellow","green","aqua","blue","purple","diffAdd","diffDel"];function Y2(e){return`--${e.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`)}`}function d0(e){const t=Y1(e);return t>.008856?116*t**(1/3)-16:903.3*t}function G1(e,t){const n=d0(e)+t,r=Zi(e);if(!r)return e;let o=0,i=2;for(let l=0;l<24;l++){const c=(o+i)/2,u=nl(Math.min(255,r[0]*c),Math.min(255,r[1]*c),Math.min(255,r[2]*c));d0(u)<n?o=c:i=c}return nl(Math.min(255,r[0]*o),Math.min(255,r[1]*o),Math.min(255,r[2]*o))}function X2(e){return G1(e.colors.surface1,-4)}function Q2(e){return G1(e.colors.surface0,-4)}function f0(e){return aM(e,.55)}function J2(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 eM(e){const t={};for(const n of V2)t[Y2(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(J2(e)))t[`--syntax-${n}`]=r;return t["--accent"]=$g(e),t["--fault"]=tM(e),t["--sunken"]=X2(e),t["--sunken-floor"]=Q2(e),t["--scrim"]=iM(e.colors.surface0,.7),t["--shadow"]=e.kind==="dark"?"#00000066":"#0000002e",t["--diff-add-word"]=f0(e.colors.diffAdd),t["--diff-del-word"]=f0(e.colors.diffDel),t}function $g(e){return V1(e.accent??"")??e.colors.orange}function tM(e){return $g(e)===V1(e.colors.orange)?e.colors.red:e.colors.orange}function nM(e){return e==="system"||e==="daylight"}function Og(e,t){return e.mode==="system"?t.system?"dark":"light":e.mode==="daylight"?t.daylight?"dark":"light":e.mode}function xf(e,t,n){const r=Og(e,n);return t.find(o=>o.id===e[r])??xd.find(o=>o.kind===r)??Pc}function rM(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 oM(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=rM(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 sM(e,t){const n={...e};return t.dark&&(n.dark=t.dark.id),t.light&&(n.light=t.light.id),!nM(n.mode)&&!t[n.mode]&&(n.mode=t.dark?"dark":"light"),n}function Zi(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 V1(e){const t=Zi(e);return t?nl(t[0],t[1],t[2],t[3]):null}function nl(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 iM(e,t){const n=Zi(e);return n?nl(n[0],n[1],n[2],t):e}function aM(e,t){const n=Zi(e);return n?nl(n[0],n[1],n[2],Math.min(1,n[3]*t)):e}function MH(e,t){const n=Zi(e),r=Zi(t);if(!n||!r)return e;const o=n[3];return nl(n[0]*o+r[0]*(1-o),n[1]*o+r[1]*(1-o),n[2]*o+r[2]*(1-o))}function Y1(e){const t=Zi(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 lM(e){return Y1(e)>.179?"#1d2021":"#fbf1c7"}function bm(e){if(e===null||e==="")return"the npm registry";try{return new URL(e).host}catch{return e}}function cM(e,t){const n=h0(e),r=h0(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 h0(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 uM=[[/\.(png|jpe?g|gif|webp|avif|bmp|ico)$/i,"image"]];function dM(e){var t;return((t=uM.find(([n])=>n.test(e)))==null?void 0:t[1])??null}const fM=[[/\.(md|markdown)$/i,"markdown"],[/\.html?$/i,"html"]];function Ef(e){var t;return((t=fM.find(([n])=>n.test(e)))==null?void 0:t[1])??null}const Qe={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",designHeight:"toyon-dsh",designFull:"toyon-dsfull",termHeight:"toyon-th",rail:"toyon-rail",railWidth:"toyon-rail-w",chatSide:"toyon-chat-side",clipboardOffer:"toyon-clipboard-offer",layouts:"toyon-layouts",client:"toyon-client",ground:"toyon-ground",profilePrefix:"toyon-profile-",modePrefix:"toyon-mode-",modelPrefix:"toyon-model-",effortPrefix:"toyon-effort-"},hM=[Qe.active,Qe.repo,Qe.lastActive,Qe.discoveredOpen,Qe.archivedOpen,Qe.committedShut,Qe.turnOpen,Qe.treeOpen,Qe.profilePrefix,Qe.modePrefix,Qe.modelPrefix,Qe.effortPrefix,Qe.phoneRow],pM=[Qe.profilePrefix,Qe.modePrefix,Qe.modelPrefix,Qe.effortPrefix],Ed=(e,t)=>`${e}@${t}`;function mM(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(Ed(c,e)))??null}catch{return null}},set(c,u){try{l==null||l.setItem(Ed(c,e),u)}catch{}},remove(c){try{l==null||l.removeItem(Ed(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 X1(l).filter(u=>u.endsWith(`@${e}`)))try{l==null||l.removeItem(c)}catch{}}}}function X1(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 gM="orch-";function kM(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=Qe[i],c=gM+l.slice(6);p0(r,c,l)}for(const[r,o]of[[t,hM.filter(i=>i!==Qe.phoneRow)],[n,[Qe.phoneRow]]]){const i=X1(r).filter(l=>!l.includes("@"));for(const l of o){const c=pM.includes(l)?i.filter(u=>u.startsWith(l)):i.filter(u=>u===l);for(const u of c)p0(r,u,Ed(u,e))}}}function p0(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 Q1(){const e=location.hash.match(/token=([a-f0-9]+)/);if(e!=null&&e[1])return J1(e[1]),e[1];try{return localStorage.getItem(Qe.token)??sessionStorage.getItem(Qe.token)??""}catch{return""}}function J1(e){try{localStorage.setItem(Qe.token,e)}catch{}}function Mg(){return Q1()!==""}function Lg(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}`,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?`&${_2}`:""}`,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`}}const Dc=e=>({authorization:`Bearer ${e.token}`});async function wM(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",Dc(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 yM(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 eE(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 vM(e,t){try{const n=await fetch(t,{headers:Dc(e)});return n.ok?await n.json():null}catch{return null}}async function _f(e,t,n,r){try{const o=await fetch(t,{method:"POST",headers:{...Dc(e),"content-type":"application/json"},body:JSON.stringify(n)});return o.ok?null:await o.text()||`refused (${o.status})`}catch{return r}}const bM=e=>vM(e,e.tailnet),xM=e=>_f(e,e.remote,{tailscale:!0},"Toyon is not answering; try again once it is back."),EM=e=>_f(e,e.remote,{off:!0},"Toyon is not answering; try again once it is back.");async function tE(e,t,n){try{const r=await fetch(t,{method:"POST",headers:{...Dc(e),"content-type":"application/json"},body:JSON.stringify(n)});return r.ok?await r.json():null}catch{return null}}const nE="Toyon is not answering; try again once it is back.",_M=async e=>{const t=await tE(e,e.tailscale,{up:!0});return t===null?nE:t.refused},SM=async e=>await tE(e,e.tailscale,{login:!0})??{why:nE},NM=(e,t,n)=>_f(e,e.machines,{origin:t,token:n},"Toyon here is not answering; the machine is not listed yet."),TM=(e,t,n)=>_f(e,e.knockAnswer(t),{letIn:n},"Toyon is not answering");async function rE(e){try{const t=await fetch(e.previewGrant,{method:"POST",headers:Dc(e)});return t.ok?await t.json():null}catch{return null}}const jM=2e3;async function oE(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,jM))}return"gone"}async function xm(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 CM=1e3,AM=3e4,IM=1500,RM=5e3,m0=50,$M=e=>e.t==="chat"||e.t==="create-worktree"||e.t==="restore-worktree"||e.t==="batch-worktrees";class OM{constructor(t,n,r,o=RM){Dt(this,"ws",null);Dt(this,"queue",[]);Dt(this,"closed",!1);Dt(this,"attempt",0);Dt(this,"timer",null);Dt(this,"downAt",null);Dt(this,"downCode",0);Dt(this,"sayTimer",null);Dt(this,"sentDown",new Set);Dt(this,"urls");Dt(this,"suspended",!1);Dt(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.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.connectDeadline=o,this.urls=Lg(t.origin,t.token),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===yC)return"unauthorized";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+IM-Date.now()))}connect(){if(this.closed||this.suspended)return;const t=new WebSocket(this.urls.ws);this.ws=t;let n=!1;const r=setTimeout(()=>{t.readyState===WebSocket.CONNECTING&&t.close()},this.connectDeadline);t.onmessage=o=>{if(!n){n=!0,clearTimeout(r),this.attempt=0,this.downAt=null,this.sayTimer&&clearTimeout(this.sayTimer),this.sayTimer=null,this.onStatus(!0);for(const i of this.queue)t.send(i.raw);this.queue=[]}try{this.onMsg(JSON.parse(o.data))}catch{}},t.onclose=o=>{if(clearTimeout(r),this.ws!==t||(this.onStatus(!1),this.closed||this.suspended))return;this.say(o.code);const i=Math.min(AM,CM*2**this.attempt++);this.timer=setTimeout(()=>this.connect(),i/2+Math.random()*(i/2))},t.onerror=()=>t.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)),$M(t)&&t.boxId&&this.sentDown.add(t.boxId),this.queue.push({key:r,raw:n}),this.queue.length>m0&&this.queue.splice(0,this.queue.length-m0)}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 Em(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 Pg(e,t,n){const r=h=>e.map((p,m)=>h(p)&&p.id!==t?m:-1).filter(p=>p>=0),i=[()=>r(h=>h.agent==="waiting"),()=>r(h=>!!h.unseen),()=>r(h=>h.agent==="working")].reduce((h,p)=>h.length>0?h:p(),[]),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 Dg(e,t,n){const r=Pg(e,t,n);if(r)return r;const o=e[0];return o&&o.id!==t?{activate:o.id}:null}function MM(e,t,n){const r=[Em(e,t),...n.map(o=>Em(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 LM(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=Pg(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=Dg(e,t,1);return o&&{origin:null,activate:o.activate}}function zg(e){return e==="cancelled"||e==="expired"}function sE(e){const t=e.findLast(n=>n.kind==="ask"||n.kind==="user");return(t==null?void 0:t.kind)!=="ask"||t.ask.kind!=="question"?null:zg(t.outcome)?t:null}function PM(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 DM(e){return e.map(()=>({selected:[]}))}function g0(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 Bd(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 k0(e,t,n,r){return e.map((o,i)=>i!==t?o:{selected:n&&!r?[]:o.selected,note:o.note??""})}function _d(e,t){const n=e[t];return n&&n.note!==void 0&&!n.note.trim()?Bd(e,t,void 0):e}function zM(e){return e?e.options.length+(e.note?1:0):0}function FM(e,t){return!!(e!=null&&e.note)&&t===e.options.length}function iE(e,t){return!!e&&e.note!==void 0&&(t||e.selected.length===0)}function qa(e){var t;return!!e&&(e.selected.length>0||!!((t=e.note)!=null&&t.trim()))}function sd(e,t){return e.every((n,r)=>!n.required||qa(t[r]))}function BM(e,t){var o;const n=((t==null?void 0:t.selected)??[]).map(i=>{var l;return Bg(((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 UM(e,t){var o;const n=((t==null?void 0:t.selected)??[]).map(i=>{var l;return Bg(((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 Fg(e,t){return e.map((n,r)=>{const o=BM(n,t==null?void 0:t[r]);return e.length>1&&n.header?`${n.header} · ${o}`:o})}function HM(e){return e.outcome!=="answered"||e.ask.kind!=="question"?null:{message:e.ask.message,questions:e.ask.questions,answers:e.answers}}function WM(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 Fa(e,t){if(!e)return 0;if(iE(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 KM(e,t,n){return Math.max(0,Math.min(n-1,e+t))}function ZM(e,t,n){const r=e.length;for(let o=1;o<=r;o++){const i=(n+o)%r;if(!qa(t[i]))return i}return-1}function fc(e){return e.length>1?e.length:-1}function qM(e){return e.length+(fc(e)===-1?0:1)}function w0(e,t,n){const r=ZM(e,t,n);if(r!==-1)return{current:r,cursor:Fa(e[r],t[r]),send:!1};const o=fc(e);return o!==-1?{current:o,cursor:0,send:!1}:{current:n,cursor:Fa(e[n],t[n]),send:!0}}const aE=/\s*\(recommended\)\s*$/i;function GM(e){return aE.test(e)}function Bg(e){return e.replace(aE,"")}const VM={skipped:"you skipped this",cancelled:"the turn was stopped before you answered",expired:"Toyon restarted before you answered"};function Sd(e,t,n,r){return n!==null&&r===n.host?`${wC(n.previews,e,t)}/`:r.endsWith(".localhost")?`http://w${e}.${r}:${t}/`:xg(r)?`http://${r==="localhost"?"127.0.0.1":r}:${t}/`:`https://${r}:${t}/`}function y0(e){return e.ranges.map(([t,n])=>[t+e.offset,n+e.offset])}function lE(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 v0(e){var r;const t=(r=e.source)==null?void 0:r.replace(/[?#].*$/,""),n=t?` (${lE(t)}:${e.line??"?"})`:"";return`${e.message}${n}`.slice(0,QO)}function id(e,t){return!Number.isFinite(e)||e<=0?t:Math.min(Math.max(e,170),Math.floor(window.innerWidth*.5))}function zc(e){return e.agent==="working"||e.agent==="waiting"}function ai(e){var t,n,r;return e.agent==="waiting"?"waiting":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 YM={waiting:"Waiting for you",working:"Agent working",failed:"Agent failed",landed:"Landed",crashed:"Crashed",running:"Running",starting:"Starting",asleep:"Asleep",idle:"Idle"};function Ug(e,t=!1){const n=ai(e);return n==="idle"&&t?"Not set up":YM[n]}const XM={starting:"Starting",running:"Running",unreachable:"Not answering",crashed:"Crashed",stopped:"Stopped",asleep:"Asleep"};function QM(e){return XM[e]}function cE(e,t){return t&&ai(e)!=="waiting"?t:null}const JM={land:"Landing",commit:"Committing","sync-main":"Syncing with main","pull-main":"Pulling"};function Hg(e){return JM[e]}function uE(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 eL(e){const t=e.lastIndexOf("/");return t<0?{name:e,dir:""}:{name:e.slice(t+1),dir:e.slice(0,t)}}const dE=new Intl.Collator(void 0,{numeric:!0,sensitivity:"base"}).compare;function Ud(e){const t=[];for(let n=e.indexOf("/");n!==-1;n=e.indexOf("/",n+1))t.push(e.slice(0,n));return t}function fE(e){const t=new Set;for(const n of e)for(const r of Ud(n))t.add(r);return[...t].sort(dE)}function Wg(e){return e.includes("A")||e==="??"?"added":e.includes("D")?"deleted":""}function Kg(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 tL=/Firefox\//.test(navigator.userAgent);function Sf(){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 nL=/Chrome\//.test(navigator.userAgent)&&Sf(),Lt=e=>oC(e,{firefox:tL,pwa:nL});function Zg(e){return e.component?`<${e.component} />`:`<${e.tag}>`}function _m(e,t){return e.worktree&&$r(e.worktree)&&t?t.defaultBranch:e.name}function qg(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 to(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 Ga(e){const t=Math.max(0,Math.floor(e));return t<100?`${t}s`:`${Math.floor(t/60)}m ${t%60}s`}function rL(e,t,n,r){var l;if(!t)return null;const o=e.filter(xn).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 oL=200;function sL(e,t){const n=new Map(e.map(r=>[r.path,r]));for(const r of t){if(n.size>=oL)break;const o=vf(r.path);o&&!n.has(o)&&n.set(o,{path:o,text:r.text})}return n.size===e.length?e:[...n.values()]}function hE(e){return e!==void 0&&!e.routes.some(t=>!t.endpoint)}const li=e=>"uploading"in e&&e.uploading===!0;function Ec(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 Gg=e=>e.filter(t=>!li(t)).map(Ec);let iL=0;function Sm(e,t){const n=new Map(t.filter(o=>!li(o)).map(o=>[JSON.stringify(Ec(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${++iL}`;return o.kind==="paste"?{...o,key:c,...Rg(o.text)}:{...o,key:c}}),...t.filter(li)]}const Nm="out:",aL=(e,t,n)=>`${Nm}${e}:${t}:${n}`;function os(e){if(!e.startsWith(Nm))return null;const t=e.slice(Nm.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 tc(e,t,n,r){const o=r.length?Gg(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 lL(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(li)){n.add(o.log);continue}r.push(o.id)}return r}const pE=e=>e.flatMap(t=>"upload"in t&&t.upload?[t.upload]:[]);function cL(e){const t=n=>pE(n.items).some(r=>!n.before.includes(r));return[...e.filter(t),...e.filter(n=>!t(n))]}const Nd=["files","changes","history"],uL=e=>Nd.includes(e),mE=e=>!!(e!=null&&e.carry)&&!e.batch&&e.variants===1,Fc=e=>(e==null?void 0:e.worktree.id)??null,rl="new-project",Yi=Object.freeze({chat:[],log:[],queue:[],page:{},turn:{edits:!1,hmr:!1},changedRanges:{},commitFiles:{},search:null,design:null,draft:"",attachments:[],commands:[],termStream:vo}),Vg=e=>({...e,phase:"editing",repoId:null}),b0=()=>Vg({mode:"create",name:"",parent:`~/${U1}`}),dL=Object.freeze({changes:!1,changesTab:"files",chat:!0,term:!1,design:!1});function fL(e){if(!e||typeof e!="object")return!1;const t=e;return typeof t.changes=="boolean"&&uL(t.changesTab)&&typeof t.chat=="boolean"&&typeof t.term=="boolean"&&typeof t.design=="boolean"}function Qr(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 Yg(e,t){return{...e,layout:t,changesAuto:!1}}const qi=e=>Ef(e)?"preview":"file",hL=(e,t)=>e===t||!!e&&!!t&&e.at===t.at&&(e.at!=="tree"||t.at!=="tree"||e.worktreeId===t.worktreeId&&e.dir===t.dir),Gl=(e,t)=>e.worktreeId===t.worktreeId&&e.path===t.path&&e.ref===t.ref&&e.since===t.since;function gE(e,t,n,r){var i;if(!r.fiber)return r;const o=(i=_o(e,t).changedRanges[n])==null?void 0:i.offset;return o===void 0?r:{n:r.n-o}}function pL(e){const t=e.cached??Pc,n={connected:!1,connectFailure:null,repos:[],rows:[],activeRepoId:null,visible:[],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,local:{},editor:null,openUrl:null,reloadReq:null,renders:[],dragFiles:null,picking:!1,overlay:null,paletteReturn:null,incompatible:!1,layout:dL,focusChanges:0,editCommit:0,focusChat:0,walked:0,railOpen:e.storedRailOpen??!1,chatSide:e.storedChatSide??"left",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,changesAuto:!0,zen:!1,focusTerm:0,termRun:null,termTall:0,previewSize:null,themes:xd.some(o=>o.id===t.id)?xd:[...xd,t],themePrefs:{...G2,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:VO,letIn:!1,knocks:[],tailscale:null,handed:[],gitIdentity:!0,self:null,rebuilt:!1,update:null,updateCheck:null,version:"",install:"none",registry:null,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?Yg(n,r):n}function kE(e){var t;return{system:e.systemDark,daylight:((t=e.daylight)==null?void 0:t.dark)??e.systemDark}}function mL(e){return e.previewTheme??xf(e.themePrefs,e.themes,kE(e))}function _o(e,t){return t&&e.local[t]||Yi}function So(e,t){return t&&e.rows.find(n=>n.id===t)||null}function kn(e,t){const n=So(e,t);return n&&xn(n)?n:null}function wE(e){var o;const t=kn(e,e.activeId);if(!t||!Ki(t.worktree)||t.agent!=="idle"||!((o=ol(e,t.repoId))!=null&&o.empty))return!1;const n=hi(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&&_o(e,t.id).chat.length===0}function Nf(e){return e.newProject!==null||wE(e)}function gL(e){return e.incompatible||Nf(e)}function kL(e){return(!e.needsSetup||!!e.assumed)&&Object.keys(e.config.run).length===0}function Hd(e){return!!(e!=null&&e.needsSetup)&&!e.assumed}function Xg(e){const t=e.archivedPage?null:So(e,e.activeId);return(t==null?void 0:t.repoId)??e.activeRepoId}function xo(e){const t=hi(e,Xg(e));return!!t&&kL(t)}function yE(e){return e.layout.chat&&!xo(e)&&!e.archivedPage&&!xE(e)?{a:"toggle-chat"}:{a:"focus-chat"}}function Fo(e){return xo(e)?e:Qr(e,{chat:!0})}function hi(e,t){return t&&e.repos.find(n=>n.id===t)||null}function vE(e,t){if(!t)return null;const n=e.rows.filter(xn).filter(r=>r.repoId===t);return n.find(r=>Lc(r.worktree))??n.find(r=>Ki(r.worktree))??null}function ol(e,t){return t&&e.trunks[t]||null}function nc(e){return xo(e)||e.archivedPage?null:e.activeId}function Qg(e){return e.procs.some(t=>t.status==="running"||t.status==="starting")}function Wd(e){if(e.archivedPage)return null;const t=kn(e,e.activeId);return t&&Qg(t)?{worktreeId:t.worktree.id,repoId:t.repoId}:null}function Jg(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&&xn(o)&&o.repoId===t?o:null}function Tf(e,t,n){return e.repoId===t||Jg(e,t,n)!==null}function bE(e,t){return t.length?e.filter(n=>!t.includes(n.id)):e}function wL(e,t,n){const r=bE(e,n).filter(xn);return Hj(t?r.filter(o=>Tf(o,t,r)):r)}function yL(e,t){const n=e.filter(r=>!xn(r));return t?n.filter(r=>r.repoId===t):n}function Va(e,t,n=e.rows){var c;const r=n.filter(xn),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=>Lc(u.worktree))??l.find(u=>Ki(u.worktree))??l[0])==null?void 0:c.id)??null}function x0(e,t){const n=Object.entries(e),r=n.filter(([o])=>!t(o));return r.length===n.length?e:Object.fromEntries(r)}function E0(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)||TE({trunks:n},l))&&(r[l]=c);const o=Object.keys(r);return o.length===Object.keys(e).length&&o.every(l=>vL(e[l],r[l]))?e:r}const vL=(e,t)=>!!e&&!!t&&e.op===t.op&&e.step===t.step&&e.sent===t.sent;function Ba(e,t){var p;const n=So(e,t),o=!!n&&xn(n)&&!!e.activeRepoId&&Tf(n,e.activeRepoId,e.rows)?e.activeRepoId:(n==null?void 0:n.repoId)??e.activeRepoId,i=n&&xn(n)?{...e.lastActive,[n.repoId]:n.id}:e.lastActive,l=e.activeId!==t?e.activeId:null,c=l?e.local[l]:void 0,u=c&&((p=c.mark)==null?void 0:p.by)==="reveal"?Ua(c,"reveal"):null,h=l&&u?{...e.local,[l]:u}:e.local;return{...e,activeId:t,activeRepoId:o,lastActive:i,editor:null,archivedPage:null,local:h}}function sl(e){return No(e)?"history":e.layout.changesTab}function bL(e,t){const n=sl(e);if(No(e))return n;const r=Nd.length;return Nd[(Nd.indexOf(n)+t+r)%r]??"changes"}function xE(e){if(e.archivedPage)return null;const t=So(e,e.activeId);return t&&!xn(t)?t:null}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 Ua(e,t){var o;if(((o=e.mark)==null?void 0:o.by)!==t)return e;const{mark:n,...r}=e;return r}const EE=e=>e.kind==="theme"||e.kind==="appearance"||e.kind==="keep-awake"||e.kind==="agent"||e.kind==="agent-page"||e.kind==="choose-folder"||e.kind==="handoff";let xL=0;function _c(e){if(!e.sending)return e;const{sending:t,...n}=e;return n}function EL(e,t){var n;return!t||((n=e.local[t])==null?void 0:n.restoring)===void 0?e:wt(e,t,({restoring:r,...o})=>o)}function _L(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]=_c(r[o]);return{...e,local:r}}function SL(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]??Yi,u=c.chat.some(h=>h.kind==="user")?{}:i;o={...o,[n]:_c(o[n]),[r]:{...c,sending:u}}}for(const c of t){const u=o[c.id];u!=null&&u.sending&&!u.sending.message&&(c.agent==="working"||c.agent==="waiting")&&(o={...o,[c.id]:_c(u)})}return o}function wt(e,t,n){return{...e,local:{...e.local,[t]:n(e.local[t]??Yi)}}}function _0(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 NL(e,t){const n=t.type==="agent-question"||t.type==="agent-permission"||t.type==="handoff-proposed",r=t.type==="agent-ask-end"||t.type==="handoff"||t.type==="handoff-declined"?t.id:null;if(!n&&!r)return e;const o=t.type==="agent-ask-end"&&zg(t.outcome),{card:i,cardParked:l,askRevived:c,...u}=e;return{...u,...i&&!n&&(i.id!==r||o)?{card:i}:{},...l&&!n&&l!==r?{cardParked:l}:{},...c&&!n?{askRevived:c}:{}}}function TL(e,t,n){return wt(e,t,r=>({...r,chat:[...r.chat,n],chatAt:Date.now()}))}function _E(e,t,n){return TL(Fo(e),t,{kind:"error",text:n})}function Tm(e,t){const n=Fc(kn(e,e.activeId));return n?wt(Fo(e),n,r=>({...r,notice:t})):e}function S0(e,t,n){return kn(e,t)?_E(e,t,n):Tm(e,n)}function jL(e,t){const n=e.paletteReturn;return!t||!n?{overlay:null,paletteReturn:null}:{overlay:{kind:n.mode},paletteReturn:n}}function CL(e){const t=e.activeRepoId;if(!t)return e;const n=e.layouts[t];return n?Yg(e,n):e.frame==="desk"?{...e,layouts:{...e.layouts,[t]:e.layout}}:e}function AL(e){return e.a==="server"&&e.msg.t==="git-status"}function IL(e){return{variants:1,batch:!1,agent:e.defaultAgent}}function RL(e){const t=kn(e,e.activeId);return!!t&&$r(t.worktree)&&!e.archivedPage&&!Nf(e)?e.draft?e:{...e,draft:IL(e)}:e.draft?{...e,draft:null}:e}function SE(e){var r;const t=e.archivedPage,n=t!==null&&((r=e.editor)==null?void 0:r.worktreeId)===t&&kn(e,t)===null;return{...e,archivedPage:null,...n?{editor:null}:{}}}function $L(e){const t=e.activeRepoId;if(!t)return e;const n=kn(e,e.activeId);return!n||n.repoId===t||Tf(n,t,bE(e.rows,e.archiving))?e:Ba(e,Va(e,t))}function N0(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?ri(o,{a:"open",overlay:{kind:"devices"}}):o}const OL=e=>{var t;return e.frame==="desk"&&(e.remote!==null||((t=e.tailscale)==null?void 0:t.state)==="ready")};function ri(e,t){let n=RL($L(ML(e,t)));return n.unreadHold!==null&&n.activeId!==n.unreadHold&&(n={...n,unreadHold:null}),n.archivedPage!==null&&(No(n)===null||kn(n,n.archivedPage)!==null)&&(n=SE(n)),n.activeRepoId!==e.activeRepoId?n=CL(n):n.frame==="desk"&&n.activeRepoId&&!AL(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:{...n,visible:wL(n.rows,n.activeRepoId,n.archiving),visibleDiscovered:yL(n.rows,n.activeRepoId)}}function ML(e,t){var n,r,o,i,l,c,u,h,p,m,g,y;switch(t.a){case"connected":return{...e,connected:t.v,connectFailure:t.v?null:t.failure===void 0?e.connectFailure:t.failure};case"activate":return{...Ba(e,t.id),carryTo:null,screen:t.id?"chat":"home"};case"open-draft":{if(Nf(e))return e;const w=((n=vE(e,e.activeRepoId))==null?void 0:n.id)??null;return w?Fo({...Ba(e,w),carryTo:w,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-variants":return e.draft?{...e,draft:{...e.draft,variants:t.n}}:e;case"draft-batch":return e.draft?{...e,draft:{...e.draft,batch: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!e.activeRepoId||!((r=e.archived[e.activeRepoId])!=null&&r.some(w=>w.id===t.id))?e:{...e,archivedPage:t.id,editor:null,screen:"chat"};case"close-archived":return e.archivedPage?SE(e):e;case"restoring":return wt(e,t.id,w=>({...w,restoring:t.text}));case"sending":return wt(e,t.id,w=>({...w,sending:{message:t.message}}));case"sent-box":return wt(e,t.id,({notice:w,...b})=>({...Ua(b,"walk"),draft:"",attachments:[],sent:(b.sent??0)+1}));case"answered":return wt(e,t.id,w=>({...w,sent:(w.sent??0)+1}));case"hold-send":{const w=e.local[t.id];if(!w)return e;const b=aL(e.clientId,++xL,t.id),E={...Yi,draft:t.text,attachments:w.attachments,outgoing:{frame:t.frame,log:t.log}},_=wt(e,t.id,({notice:N,...T})=>({...Ua(T,"walk"),draft:"",attachments:[]}));return{..._,local:{..._.local,[b]:E},outbox:[...e.outbox,{id:b,log:t.log,kinds:w.attachments.map(N=>N.kind)}]}}case"sent-out":{const w=e.local[t.id],b=w==null?void 0:w.outgoing;if(!w||!b)return e;const{[t.id]:E,..._}=e.local,N={...e,local:_,outbox:e.outbox.filter(C=>C.id!==t.id)},T=w.draft,R=w.attachments.length?Gg(w.attachments):void 0,O=C=>({...C,sent:(C.sent??0)+1});if(b.frame.t==="restore-worktree"||b.frame.t==="adopt-worktree")return wt(N,b.log,C=>({...O(C),restoring:T}));if(b.frame.t==="agent-answer")return wt(N,b.log,O);const B=(o=So(e,b.log))==null?void 0:o.agent,$=b.frame.t==="chat"&&(B==="working"||B==="waiting");return wt(N,b.log,C=>$?O(C):{...O(C),sending:{message:{text:T,attachments:R}}})}case"unsend":{const w=e.local[t.id],b=(i=os(t.id))==null?void 0:i.source;if(!(w!=null&&w.outgoing)||!b)return e;const{[t.id]:E,..._}=e.local,N={...e,local:_,outbox:e.outbox.filter(T=>T.id!==t.id)};return wt(Fo(N),b,T=>({...T,draft:T.draft||w.draft,attachments:[...w.attachments,...T.attachments],...t.notice?{notice:t.notice}:{}}))}case"drop-out":{if(!((l=e.local[t.id])!=null&&l.outgoing))return e;const{[t.id]:w,...b}=e.local;return{...e,local:b,outbox:e.outbox.filter(E=>E.id!==t.id)}}case"archive-worktrees":{const w=t.ids.filter(j=>!e.archiving.includes(j)&&kn(e,j));if(w.length===0)return e;const b={...e,archiving:[...e.archiving,...w]};if(!e.activeId||!w.includes(e.activeId))return b;const E=e.visible.filter(j=>j.id===e.activeId||!b.archiving.includes(j.id)),_=E.findIndex(j=>j.id===e.activeId),N=j=>j.id!==e.activeId&&wg(j.worktree)&&!!j.worktree.landed&&j.agent==="idle",T=j=>{var D;return(D=E.find((z,X)=>X>_&&j(z))??E.find(j))==null?void 0:D.id},R=T(j=>j.id!==e.activeId&&j.agent==="waiting"),O=T(N),B=(c=Pg(E,e.activeId,1))==null?void 0:c.activate,$=(u=E.map((j,D)=>({id:j.id,i:D,far:Math.abs(D-_),up:!$r(j.worktree)&&ai(j)==="running"})).filter(j=>j.up&&j.far>0).sort((j,D)=>j.far-D.far||D.i-j.i)[0])==null?void 0:u.id,C=Ba(b,R??O??B??$??Va(b,e.activeRepoId));return e.frame==="phone"?{...C,screen:"home"}:C}case"shipping":return e.shipping[t.id]||!(So(e,t.id)||TE(e,t.id))?e:{...e,shipping:{...e.shipping,[t.id]:{op:t.op,sent:!0}}};case"activate-repo":{if(!hi(e,t.id))return e;const w=e.newProject?{...e,newProject:null}:e;if(t.id===e.activeRepoId)return w;const b=Va(w,t.id);return{...Ba(w,b),carryTo:null,activeRepoId:t.id,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};case"new-project-set":{if(!e.newProject)return e;const w="name"in t.v||"parent"in t.v||"url"in t.v||"mode"in t.v,{error:b,...E}=e.newProject;return{...e,newProject:{...w?E: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 w=t.v,b=e.editor,E=b&&Gl(b,w)?b:null,_=w.line&&gE(e,w.worktreeId,w.path,w.line);return{...e,editor:{worktreeId:w.worktreeId,path:w.path,...w.ref?{ref:w.ref}:{},...w.since?{since:w.since}:{},view:w.view??(E==null?void 0:E.view)??null,seq:w.seq,disk:(E==null?void 0:E.disk)??null,..._?{line:_}:{},focus:w.focus,conflict:(E==null?void 0:E.conflict)??null,blame:(E==null?void 0:E.blame)??null}}}case"open-loose":{const w=t.v,b={before:w.text,after:w.text,version:null,writable:w.source.kind!=="bytes"&&!w.tooLarge&&!w.binary,binary:w.binary,tooLarge:w.tooLarge};return{...e,editor:{worktreeId:w.worktreeId,path:w.name,view:qi(w.name),seq:w.seq,disk:b,focus:!0,conflict:null,blame:null,loose:{source:w.source}}}}case"editor-read":{const w=e.editor;if(!w||w.loose||!Gl(w,t.file))return e;const b=t.disk;if(!b){const N=_E(e,w.worktreeId,t.error??`could not read ${w.path}`);return w.disk?N:{...N,editor:null}}const E=qi(w.path),_=b.before===""?w.view&&w.view!=="diff"?w.view:E:w.view??(b.before===b.after?E:"diff");return{...e,editor:{...w,view:_,disk:b}}}case"editor-conflict":{const w=e.editor;return w&&!w.loose&&Gl(w,t.file)?{...e,editor:{...w,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 w=e.editor;if(!w||!Gl(w,t.file))return e;const b=w.loose&&w.disk?{...w.disk,writable:!1}:w.disk;return{...e,editor:{...w,refused:t.message,disk:b}}}case"editor-blame":{const w=e.editor;return w&&!w.loose&&Gl(w,t.file)?{...e,editor:{...w,blame:t.blame}}:e}case"notice":return wt(Fo(e),((h=os(t.id))==null?void 0:h.source)??t.id,w=>({...w,notice:t.text}));case"link-refused":return wt(e,t.id,({refusedLink:w,...b})=>t.v?{...b,refusedLink:t.v}:b);case"card-draft":return wt(e,t.id,w=>({...w,card:t.card}));case"card-park":return wt(e,t.id,w=>({...w,cardParked:t.cardId}));case"card-unpark":return wt(e,t.id,({cardParked:w,...b})=>b);case"ask-revive":return wt(e,t.id,({askRevived:w,...b})=>t.askId?{...b,askRevived:t.askId}:b);case"opened-url":return e.openUrl?{...e,openUrl:null}:e;case"set-draft":return wt(e,t.id,w=>{const{notice:b,...E}=Ua(w,"walk");return{...E,draft:t.text,...b!==void 0&&t.text===""?{notice:b}:{}}});case"move-box":return NE(e,t.from,t.to);case"walk":return wt(e,t.id,w=>({...Ua(w,"walk"),draft:t.text,...t.walk?{mark:{by:"walk",at:t.walk.at,from:t.walk.from}}:{}}));case"reveal":return wt(Fo(e),t.id,w=>{var b;return{...w,mark:{by:"reveal",seq:t.seq,n:((b=w.mark)==null?void 0:b.by)==="reveal"?w.mark.n+1:1}}});case"attach":return wt(Fo(e),t.id,({notice:w,...b})=>({...b,attachments:[...b.attachments,...t.items]}));case"upload-progress":return(p=e.local[t.id])!=null&&p.attachments.some(w=>w.key===t.key&&li(w))?wt(e,t.id,w=>({...w,attachments:w.attachments.map(b=>b.key===t.key?{...b,progress:t.progress}:b)})):e;case"attached":return(m=e.local[t.id])!=null&&m.attachments.some(w=>w.key===t.key)?wt(e,t.id,w=>({...w,attachments:w.attachments.map(b=>b.key===t.key?t.item:b)})):e;case"detach":{const w=wt(e,t.id,({notice:b,...E})=>({...E,attachments:E.attachments.filter(_=>_.key!==t.key)}));return(g=e.local[t.id])!=null&&g.outgoing?ri(w,{a:"unsend",id:t.id}):w}case"clear-attachments":return wt(e,t.id,({notice:w,...b})=>b.attachments.length?{...b,attachments:[]}:b);case"hmr":return wt(e,t.id,w=>({...w,turn:{...w.turn,hmr:!0}}));case"page":return wt(e,t.id,w=>({...w,page:{url:t.url??w.page.url,title:t.title??w.page.title}}));case"render-done":return e.renders.some(w=>w.id===t.id)?{...e,renders:e.renders.filter(w=>w.id!==t.id)}:e;case"links":return wt(e,t.id,w=>{const b=sL(w.links??[],t.links);return b===w.links?w:{...w,links:b}});case"drag-files":return hL(e.dragFiles,t.v)?e:{...e,dragFiles: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:EE(t.overlay)?e.paletteReturn:null};case"choosing-folder":return{...e,choosingFolder:t.v};case"close":return{...e,previewTheme:null,...jL(e,t.back)};case"toggle":return((y=e.overlay)==null?void 0:y.kind)===t.overlay.kind?ri(e,{a:"close"}):ri(e,{a:"open",overlay:t.overlay});case"palette-return":return{...e,paletteReturn:t.v};case"toggle-changes":return{...Qr(e,{changes:!e.layout.changes}),changesAuto:!1};case"focus-changes":return{...Qr(e,{changes:!0,changesTab:t.tab&&!No(e)?t.tab:e.layout.changesTab}),changesAuto:!1,focusChanges:e.focusChanges+1};case"changes-tab":return Qr(e,{changesTab:t.v});case"edit-commit":return{...Qr(e,{changes:!0}),changesAuto:!1,editCommit:e.editCommit+1};case"toggle-chat":return xo(e)?e:Qr(e,{chat:!e.layout.chat});case"focus-chat":return{...Fo(e),focusChat:e.focusChat+1};case"walked":return{...e,walked:e.walked+1};case"show-chat":return Fo(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"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"?Qr(e,{changesTab:"changes"}):e,screen:t.to,editor:null};case"frame":{if(e.frame===t.v)return e;const w={...e,frame:t.v};if(t.v!=="desk"||!w.activeRepoId)return w;const b=w.layouts[w.activeRepoId];return b?Yg(w,b):w}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"rail-peek":return e.railPeek===t.on?e:{...e,railPeek:t.on};case"toggle-discovered":{const w=e.activeRepoId;return w?{...e,discoveredOpen:{...e.discoveredOpen,[w]:!e.discoveredOpen[w]}}:e}case"toggle-archived":{const w=e.activeRepoId;return w?{...e,archivedOpen:{...e.archivedOpen,[w]:!e.archivedOpen[w]}}:e}case"toggle-committed":{const w=e.activeRepoId;return w?{...e,committedShut:{...e.committedShut,[w]:!e.committedShut[w]}}:e}case"toggle-turn":{const w=e.activeRepoId;return w?{...e,turnOpen:{...e.turnOpen,[w]:!e.turnOpen[w]}}:e}case"tree-folder":{const w=e.treeOpen[t.worktreeId]??[];if(w.includes(t.path)===t.open)return e;const b=t.open?[...w,t.path]:w.filter(_=>_!==t.path),E={...e.treeOpen};return b.length>0?E[t.worktreeId]=b:delete E[t.worktreeId],{...e,treeOpen:E}}case"tree-reveal":{const w=e.treeOpen[t.worktreeId]??[],b=[];for(let N=t.path.indexOf("/");N!==-1;N=t.path.indexOf("/",N+1))b.push(t.path.slice(0,N));b.push(t.path);const E=b.filter(N=>!w.includes(N)),_=E.length?{...e.treeOpen,[t.worktreeId]:[...w,...E]}:e.treeOpen;return{...Qr(e,{changes:!0,changesTab:"files"}),changesAuto:!1,focusChanges:e.focusChanges+1,treeOpen:_,treeReveal:{worktreeId:t.worktreeId,path:t.path}}}case"files-asked":return wt(e,t.worktreeId,w=>({...w,filesFor:t.key}));case"toggle-zen":return xo(e)?e:{...e,zen:!e.zen};case"toggle-terminal":return Qr(e,{term:!e.layout.term});case"focus-terminal":return{...Qr(e,{term:!0}),focusTerm:e.focusTerm+1};case"toggle-design":return xo(e)?e:Qr(e,{design:!e.layout.design});case"term-stream":return wt({...Qr(e,{term:!0}),termTall:t.tall?e.termTall+1:e.termTall},t.id,w=>({...w,termStream:t.stream}));case"term-run":return wt({...Qr(e,{term:!0}),focusTerm:e.focusTerm+1,termRun:{id:t.id,command:t.command}},t.id,w=>({...w,termStream:vo}));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 FL(e,t.msg)}}function T0(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 j0(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 LL(e,t,n){var o;let r=e;for(const i of n){if(!((o=i.worktree)!=null&&o.landed)||t.some(c=>{var u;return c.id===i.id&&((u=c.worktree)==null?void 0:u.landed)}))continue;const l=r[i.id];!(l!=null&&l.git)||l.git.files.length===0||(r===e&&(r={...e}),r[i.id]={...l,git:{...l.git,files:[]}})}return r}function PL(e,t){let n=e;for(const[r,o]of Object.entries(t)){const i=n[r];i!=null&&i.draft||os(r)||(n===e&&(n={...e}),n[r]={...i??Yi,draft:o})}return n}function DL(e,t){let n=e;for(const[r,o]of Object.entries(t)){const i=n[r];i!=null&&i.attachments.length||os(r)||(n===e&&(n={...e}),n[r]={...i??Yi,attachments:Sm(o,[])})}return n}function zL(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 $i(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 C0(e){const t=e.newProject;if((t==null?void 0:t.phase)!=="creating"||!t.repoId)return e;const n=vE(e,t.repoId);if(!n)return e;const r=_o(e,rl);return!r.draft.trim()&&r.attachments.length===0?{...e,newProject:null}:{...NE(e,rl,n.id),newProject:null,autoSend:n.id}}function NE(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 TE(e,t){return Object.values(e.trunks).some(n=>n.id===t)}function FL(e,t){var n,r,o,i,l,c,u,h,p,m,g,y,w,b,E;switch(t.t){case"hello":{const _=C=>!!C&&t.rows.some(j=>j.id===C),N=C=>!!C&&t.repos.some(j=>j.id===C),T=N(e.activeRepoId)?e.activeRepoId:N(e.storedRepo)?e.storedRepo:null,R=_(e.activeId)?e.activeId:_(e.storedActive)?e.storedActive:Va(e,T,t.rows),O=t.rows.find(C=>C.id===R),B=!!T&&!!O&&xn(O)&&Tf(O,T,t.rows),$={...e,heard:!0,repos:t.repos,rows:t.rows,activeId:R,activeRepoId:B?T:(O==null?void 0:O.repoId)??T??((n=t.repos[0])==null?void 0:n.id)??null,trunks:t.trunks,archiving:e.archiving.length?[]:e.archiving,shipping:E0({},t.rows,t.trunks),local:j0(DL(PL(e.local,t.drafts),t.attachments),t.rows,e.archivedPage),lastActive:zL(e.lastActive,t.rows),treeOpen:T0(e.treeOpen,t.rows),discoveredOpen:$i(e.discoveredOpen,t.repos),archivedOpen:$i(e.archivedOpen,t.repos),committedShut:$i(e.committedShut,t.repos),turnOpen:$i(e.turnOpen,t.repos),refs:$i(e.refs,t.repos),chats:$i(e.chats,t.repos),archived:$i(e.archived,t.repos),themes:t.themes??e.themes,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??(t.repos.length===0&&t.rows.length===0&&t.pending.length===0?b0():null),pending:t.pending,visits:t.visits,self:t.self,update:t.update,updateCheck:e.updateCheck==="asking"?null:e.updateCheck,version:t.version,install:t.install,registry:t.registry,activeImportId:t.pending.some(C=>C.id===e.activeImportId)?e.activeImportId:null};return N0($,t.knocks,t.letIn)}case"self":{const _=((r=e.self)==null?void 0:r.building)===!0&&e.self.rebuild&&!((o=t.self)!=null&&o.building);return{...e,self:t.self,rebuilt:e.rebuilt||_&&((i=t.self)==null?void 0:i.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 N0(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}};case"render":return{...e,renders:[...e.renders,{worktreeId:t.worktreeId,id:t.id,path:t.path}]};case"themes":return{...e,themes:t.themes,themePrefs:t.prefs};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:_,...N}=t;return{...e,agentConfigs:{...e.agentConfigs,[N.agent]:N}}}case"pending-repos":{const _=new Set(e.pending.map(B=>B.id)),N=t.pending.find(B=>!_.has(B.id)),T=N&&e.pendingOpen?N.id:e.activeImportId,R=t.pending.some(B=>B.id===T),O=t.pending.some(B=>B.id===T&&B.error);return{...e,pending:t.pending,activeImportId:R?T:null,pendingOpen:O?!1:e.pendingOpen,newProject:N&&e.pendingOpen&&((l=e.newProject)==null?void 0:l.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:(((c=e.chosenFolder)==null?void 0:c.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}}};case"archived":return{...e,archived:{...e.archived,[t.repoId]:t.items}};case"draft":return t.clientId===e.clientId||os(t.boxId)?e:wt(e,t.boxId,_=>{var N;return _.draft===t.text||((N=_.mark)==null?void 0:N.by)==="walk"?_:{..._,draft:t.text}});case"attachments":return t.clientId===e.clientId||os(t.boxId)?e:wt(e,t.boxId,_=>({..._,attachments:Sm(t.items,_.attachments)}));case"repos":{const _=new Set(e.repos.map($=>$.id)),N=t.repos.find($=>!_.has($.id));let T=e.activeRepoId,R=e.pendingOpen,O=e.newProject;N&&(R||!T)?(T=N.id,R=!1,O&&O.phase!=="unmaking"&&(O={...O,phase:"creating",repoId:N.id})):t.repos.some($=>$.id===T)||(T=((u=t.repos[0])==null?void 0:u.id)??null),(O==null?void 0:O.phase)==="unmaking"&&!t.repos.some($=>$.id===(O==null?void 0:O.repoId))&&(O={...O,phase:"editing",repoId:null}),t.repos.length===0&&!O&&(O=b0());const B=e.gitIdentity||t.repos.some($=>$.made&&!_.has($.id));return T===e.activeRepoId?{...e,repos:t.repos,pendingOpen:R,newProject:O,gitIdentity:B}:C0({...e,repos:t.repos,pendingOpen:R,newProject:O,gitIdentity:B,activeRepoId:T,activeId:Va(e,T),editor:null})}case"worktrees":{let _=e.activeId;(!_||!t.rows.some($=>$.id===_))&&(_=Va(e,e.activeRepoId,t.rows));const N=new Set(e.rows.map($=>$.id)),T=$=>{var C;return((C=$.worktree)==null?void 0:C.kind)==="worktree"&&$.worktree.createdBy===e.clientId},R=t.rows.find($=>!N.has($.id)&&T($)),O=!!_&&e.rows.some($=>{var C;return $.id===_&&((C=$.worktree)==null?void 0:C.kind)==="spare"})&&t.rows.some($=>$.id===_&&T($));R&&e.rows.length>0&&!O&&(_=R.id);const B=e.archiving.filter($=>t.rows.some(C=>C.id===$));return C0({...Ba({...e,rows:t.rows,trunks:t.trunks,archiving:B.length===e.archiving.length?e.archiving:B,shipping:E0(e.shipping,t.rows,t.trunks),local:SL(LL(j0(e.local,t.rows,e.archivedPage),e.rows,t.rows),t.rows,e.activeId,_===(R==null?void 0:R.id)?R.id:void 0),treeOpen:T0(e.treeOpen,t.rows)},_),editor:_===e.activeId?e.editor:null,...R&&_===R.id?{carryTo:R.id}:{},..._===e.activeId?{activeRepoId:e.activeRepoId}:{},archivedPage:R?null:e.archivedPage})}case"proc":{const _=e.rows.map(N=>N.id===t.worktreeId?{...N,procs:BL(N.procs,t.proc)}:N);return{...e,rows:_}}case"log":return wt(e,t.worktreeId,_=>({..._,log:Dj(_.log.slice(-400),t.proc,t.line,t.retract)}));case"agent":{const _=t.event,N=t.worktreeId;let T=wt(e,N,R=>{const O=I0(R.chat,_,t.seq),$=_.type==="tool-start"||_.type==="tool-end"||_.type==="turn-end"||_.type==="agent-error"||_.type==="tool-update"&&_.background?_0(O,R.running):R.running;let C=R.turn;_.type==="turn-start"?C={edits:!1,hmr:!1}:_.type==="tool-start"&&gg(_)&&(C={...C,edits:!0});const j=_.type==="session-info"&&_.model?_.model:R.model,D=_.type==="session-info"&&_.effort?_.effort:R.effort,z=_.type==="usage"?{...A0(_),heard:Date.now()}:R.usage,{restoring:X,...ae}=R,A=e.rows.find(oe=>oe.id===N),de=(A==null?void 0:A.agent)==="working"||(A==null?void 0:A.agent)==="waiting",ue=ae.sending?de?_c(ae):{...ae,sending:{}}:ae,J=_.type==="turn-end"||_.type==="agent-error",M=NL(_.type==="user-message"?ue:J?_c(R):R,_);return{..._.type==="user-message"?Ua(M,"reveal"):M,chat:O,...O!==R.chat?{chatAt:Date.now()}:{},...$!==R.running?{running:$}:{},turn:C,...j!==R.model?{model:j}:{},...D!==R.effort?{effort:D}:{},...z!==R.usage?{usage:z}:{}}});if(_.type==="agent-ask-end"&&!zg(_.outcome)&&((h=T.local[Ka(_.id)])!=null&&h.attachments.length)&&(T=wt(T,Ka(_.id),R=>({...R,attachments:[]}))),_.type==="user-message"){const R=sE(((p=e.local[N])==null?void 0:p.chat)??[]),O=R?Ka(R.id):null,B=O?((m=T.local[O])==null?void 0:m.attachments)??[]:[];O&&B.length&&(T=wt(T,O,$=>({...$,attachments:[]})),T=wt(T,N,$=>({...$,attachments:[...$.attachments,...B]})))}if(_.type==="turn-end"){const R=T.local[N].turn;R.edits&&!R.hmr&&(T={...T,reloadReq:{id:N,n:(((g=T.reloadReq)==null?void 0:g.n)??0)+1}})}return(_.type==="agent-question"||_.type==="agent-permission"||_.type==="handoff-proposed")&&N===e.activeId&&(T=Fo(T)),T}case"backfill":{let _=[],N;for(const{seq:R,event:O}of t.events)_=I0(_,O,R),O.type==="usage"&&(N=A0(O));const T=R=>!R||t.events.some(({event:O})=>O.type==="user-message"&&O.text===R);return wt(e,t.worktreeId,({restoring:R,sending:O,...B})=>({...B,...O&&!(O.message&&T(O.message.text))?{sending:O}:{},chat:_,chatAt:Date.now(),running:_0(_,B.running),log:t.log??B.log,...N?{usage:N}:{},...R!==void 0&&!T(R)?{restoring:R}:{}}))}case"git-status":{let _=e.layout.changes,N=e.changesAuto;e.changesAuto&&t.worktreeId===e.activeId&&!_&&(t.files.length>0||(((y=t.committed)==null?void 0:y.length)??0)>0)&&(_=!0,N=!1);const T=t.worktreeId===e.archivedPage?No(e):null;T&&(t.files.length>0||(((w=t.committed)==null?void 0:w.length)??0)>0||T.landed)&&(_=!0);const R=wt(e,t.worktreeId,O=>({...O,git:{files:t.files,committed:t.committed,turn:t.turn,ahead:t.ahead,behind:t.behind,unpushed:t.unpushed,head:t.head},changedRanges:{}}));return{...Qr(R,{changes:_}),changesAuto:N}}case"changed-ranges":{const _=wt(e,t.worktreeId,T=>({...T,changedRanges:{...T.changedRanges,[t.path]:{ranges:t.ranges,offset:t.lineOffset}}})),N=_.editor;return!((b=N==null?void 0:N.line)!=null&&b.fiber)||N.worktreeId!==t.worktreeId||N.path!==t.path?_:{..._,editor:{...N,line:gE(_,N.worktreeId,N.path,N.line)}}}case"shipped":{const _=t.worktreeId,N={...e,shipping:x0(e.shipping,T=>{var R;return T===_&&((R=e.shipping[T])==null?void 0:R.sent)===!0}),openUrl:t.ok&&t.url?t.url:e.openUrl};return!t.ok&&!t.asked?_?S0(N,_,t.message):Tm(N,t.message):N}case"files":return wt(e,t.worktreeId,_=>({..._,files:t.paths,submodules:t.submodules,ignored:t.ignored}));case"search-results":return wt(e,t.worktreeId,_=>({..._,search:{query:t.query,hits:t.hits,truncated:t.truncated}}));case"element-sources":{if(e.editor&&e.editor.seq>t.seq)return e;const[_]=t.hits;if(!_)return wt(e,t.worktreeId,T=>({...T,notice:"nothing in the source matches this element"}));if(!t.sure)return ri(e,{a:"open",overlay:{kind:"element-sources",worktreeId:t.worktreeId,hits:t.hits}});const N=ri(e,{a:"open-file",v:{worktreeId:t.worktreeId,path:_.path,view:"file",line:{n:_.line},focus:!0,seq:t.seq}});return N.layout.changes?N:ri(N,{a:"toggle-changes"})}case"design-index":return wt(e,t.worktreeId,_=>({..._,design:t.index}));case"routes":return wt(e,t.worktreeId,_=>({..._,pages:{routes:t.routes,unseen:t.unseen}}));case"queue":return wt(e,t.worktreeId,_=>({..._,queue:t.items}));case"agent-commands":return wt(e,t.worktreeId,_=>({..._,commands:t.commands}));case"git-log":return wt(e,t.worktreeId,_=>({..._,commits:t.commits}));case"git-commit":return wt(e,t.worktreeId,_=>({..._,commitFiles:{..._.commitFiles,[t.sha]:t.files}}));case"error":{const _=t.worktreeId,N=e.newProject,T=(N==null?void 0:N.phase)==="creating"&&!N.repoId,R={..._L(EL(e,_),_),archiving:_?e.archiving.includes(_)?e.archiving.filter(O=>O!==_):e.archiving:e.archiving.length?[]:e.archiving,shipping:x0(e.shipping,O=>!_||O===_),newProject:T?{...N,phase:"editing",error:t.message}:(N==null?void 0:N.phase)==="unmaking"?null:N,pendingOpen:T?!1:e.pendingOpen,updateCheck:!_&&e.updateCheck==="asking"?null:e.updateCheck};return T?R:_?S0(R,_,t.message):Tm(R,t.message)}case"unsent":return wt(Fo(e),((E=os(t.boxId))==null?void 0:E.source)??t.boxId,({restoring:_,sending:N,...T})=>({...T,draft:T.draft||t.text,attachments:[...Sm(t.items,[]),...T.attachments],notice:t.message}));default:return e}}function BL(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 A0(e){return{used:e.used,size:e.size,...e.cost!==void 0?{cost:e.cost}:{}}}function UL(e,t){const n=t.trim();return n!==""&&(e.trim()===n||e.trim().endsWith(`: ${n}`))}function I0(e,t,n){var i,l;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"text-delta":{const c=t.messageId?{messageId:t.messageId}:{};if((r==null?void 0:r.kind)==="assistant")return[...e.slice(0,-1),{...r,text:r.text+t.text,...c}];const u=t.messageId===void 0?-1:HL(e,t.messageId);if(u!==-1){const h=e.slice(),p=h[u];return h[u]={...p,text:p.text+t.text},h}return[...e,{kind:"assistant",text:t.text,...o,...c}]}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 c=e.findLastIndex(p=>p.kind==="tool"&&p.id===t.toolId);if(c===-1)return e;const u=e.slice(),h=u[c];return u[c]={...h,...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}:{}},u}case"tool-delta":{const c=e.findLastIndex(p=>p.kind==="tool"&&p.id===t.toolId);if(c===-1)return e;const u=e.slice(),h=u[c];return u[c]={...h,output:(h.output??"")+t.text},u}case"tool-end":{const c=e.findLastIndex(p=>p.kind==="tool"&&p.id===t.toolId);if(c===-1)return e;const u=e.slice(),h=u[c];return u[c]={...h,output:t.output,isError:t.isError,...(l=t.images)!=null&&l.length?{images:t.images}:{},...t.detached?{detached:!0}:{},...t.fixable?{fixable:t.fixable}:{},done:!0},u}case"agent-error":{const c=R0(e);return(r==null?void 0:r.kind)==="assistant"&&UL(t.message,r.text)?[...c.slice(0,-1),{kind:"error",text:t.message,...o}]:[...c,{kind:"error",text:t.message,...o}]}case"page-error":return[...e,{kind:"page-error",errors:t.errors,...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,archiveIds:t.archiveIds,...t.mark?{mark:t.mark}:{},ts:t.ts}];case"handoff-proposed":return[...e,{kind:"handoff",id:t.id,repo:t.repo,message:t.message,...t.title?{title:t.title}:{},by:t.by,mode:t.mode,state:"proposed",ts:t.ts}];case"handoff":{const c=e.findLastIndex(p=>p.kind==="handoff"&&p.id===t.id&&p.state==="proposed");if(c===-1)return[...e,{kind:"handoff",id:t.id,repo:{id:t.repoId,name:t.repoName,path:""},message:"",title:t.title,by:"agent",mode:Rd,state:"continued",worktreeId:t.worktreeId,ts:t.ts}];const u=e.slice(),h=u[c];return u[c]={...h,state:"continued",worktreeId:t.worktreeId,title:t.title},u}case"handoff-declined":{const c=e.findLastIndex(p=>p.kind==="handoff"&&p.id===t.id&&p.state==="proposed");if(c===-1)return e;const u=e.slice(),h=u[c];return u[c]={...h,state:"declined",...t.reason?{reason:t.reason}:{}},u}case"handoff-landed":return[...e,{kind:"handoff-landed",worktreeId:t.worktreeId,repoName:t.repoName,title:t.title,...t.url?{url:t.url}:{},ts:t.ts}];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}:{},done:!1}];case"agent-auth-ok":return e.some(c=>c.kind==="auth"&&!c.done)?e.map(c=>c.kind==="auth"&&!c.done?{...c,done:!0}:c):e;case"agent-question":return $0(e,t.toolId,{kind:"ask",id:t.id,ask:{kind:"question",message:t.message,questions:t.questions}});case"agent-permission":{const c={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}:{},choices:t.choices}},u=e.findLast(h=>h.kind==="tool"&&h.id===t.toolId);return(u==null?void 0:u.kind)!=="tool"||t.plan||u.toolKind==="switch_mode"?$0(e,t.toolId,c):[...e,{...c,toolId:u.id}]}case"agent-ask-end":{const c=e.findLastIndex(p=>p.kind==="ask"&&p.id===t.id&&!p.outcome);if(c===-1)return e;const u=e[c];if(u.toolId&&WL(u,t.choiceId))return[...e.slice(0,c),...e.slice(c+1)];const h=e.slice();return h[c]={...h[c],outcome:t.outcome,...t.answers?{answers:t.answers}:{},...t.choiceId?{choiceId:t.choiceId}:{}},h}case"turn-end":{const c=R0(e);return t.stopReason==="interrupted"?[...c,{kind:"stopped",...o}]:c}default:return e}}function R0(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 HL(e,t){var o;let n=e.length-1;for(;n>=0&&((o=e[n])==null?void 0:o.kind)==="user";)n--;const r=e[n];return(r==null?void 0:r.kind)==="assistant"&&r.messageId===t?n:-1}function WL(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 $0(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 KL(e){let t=e;const n=new Set;return{getState:()=>t,dispatch(r){const o=ri(t,r);if(o!==t){t=o;for(const i of n)i()}},subscribe(r){return n.add(r),()=>n.delete(r)}}}const jE=S.createContext(null),ek=S.createContext(null),CE=S.createContext(null);function ZL({store:e,sock:t,files:n,children:r}){return d.jsx(jE.Provider,{value:e,children:d.jsx(ek.Provider,{value:t,children:d.jsx(CE.Provider,{value:n,children:r})})})}const AE=S.createContext(null),IE=S.createContext(null);function qL({machines:e,children:t}){const n=S.useSyncExternalStore(e.subscribe,e.active);return d.jsx(AE.Provider,{value:e,children:d.jsx(IE.Provider,{value:n,children:d.jsx(ZL,{store:n.store,sock:n.sock,files:n.files,children:d.jsx(S.Fragment,{children:t},n.origin)})})})}function Go(){const e=S.useContext(AE);if(!e)throw new Error("useMachines outside <MachinesProvider>");return e}function so(){const e=S.useContext(IE);if(!e)throw new Error("useMachine outside <MachinesProvider>");return e}function tk(){const e=Go();return S.useSyncExternalStore(e.subscribe,e.list)}function Pa(e,t){return S.useSyncExternalStore(e.store.subscribe,()=>t(e.store.getState()))}const jm=(e,t)=>e.length===t.length&&e.every((n,r)=>n===t[r]);function RE(){const e=Go(),t=so(),n=tk(),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&&jm(h.names,c)&&jm(h.repos,u))return h.value;const p=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:p},p},[r,e]);return S.useSyncExternalStore(i,l)}function $E(){const e=so(),t=tk(),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 p=h.store.getState();return p.connected&&!p.incompatible?p.rows:O0}),c=r.current;if(c&&c.others===n&&jm(c.rows,l))return c.value;const u=n.map((h,p)=>({origin:h.origin,rows:(l[p]??O0).filter(xn)}));return r.current={others:n,rows:l,value:u},u},[n]);return S.useSyncExternalStore(o,i)}const O0=[];function LH(){return so().terminals}function Zn(){const e=S.useContext(jE);if(!e)throw new Error("useStore outside <StoreProvider>");return e}function P(e){const t=Zn();return S.useSyncExternalStore(t.subscribe,()=>e(t.getState()))}function nk(){const e=P(n=>n.systemDark),t=P(n=>{var r;return(r=n.daylight)==null?void 0:r.dark});return{system:e,daylight:t??e}}function lt(){return Zn().dispatch}function ct(){return S.useContext(ek)}function Wr(){const e=S.useContext(ek);return(e==null?void 0:e.urls)??Lg(location.origin,"")}function OE(){return S.useContext(CE)}function GL(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 bo(e,t,n,r=VL){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 VL={get:e=>localStorage.getItem(e),set:(e,t)=>localStorage.setItem(e,t)};function Ya(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 ME(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 rk(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 ok=1500;function il(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 YL(){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 XL(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=i.bottom-o.bottom;if(l<=0)return;const c=parseFloat(getComputedStyle(r).paddingTop)||0;r.scrollTop+=Math.min(l,Math.max(0,i.top-o.top-c))}),n=>{t.current=n}}const Td=40,QL=1200,JL=150,eP=new Set(["ArrowUp","ArrowDown","PageUp","PageDown","Home","End"," "]);function LE(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,p]=S.useState(!1),[m,g]=S.useState(null),y=S.useCallback(R=>{n.current=R,e.current&&(e.current.style.overflowAnchor=R?"none":"")},[e]),w=S.useRef(null),b=S.useRef(null);St([t],()=>{n.current||p(!0)});const E=S.useCallback(()=>{const R=e.current;R&&(y(R.scrollHeight-R.scrollTop-R.clientHeight<Td),l(!n.current),u(R.scrollTop>=Td),n.current&&p(!1))},[e,y]),_=S.useCallback(R=>{R!==0&&(g(R<0?"up":"down"),b.current&&clearTimeout(b.current),b.current=setTimeout(()=>g(null),QL))},[]),N=S.useCallback(()=>{const R=e.current;R&&(R.scrollTop=R.scrollHeight,y(!0),l(!1),p(!1))},[e,y]),T=S.useCallback(()=>{const R=e.current;R&&(r.current=performance.now(),R.scrollTop=0)},[e]);return S.useEffect(()=>{const R=e.current;if(!R)return;y(n.current);const O=()=>o.current||performance.now()-r.current<JL,B=()=>{n.current&&!O()?u(R.scrollTop>=Td):E()};R.addEventListener("scroll",B,{passive:!0});const $=()=>{r.current=performance.now()},C=J=>{$(),_(J.deltaY)},j=J=>{var M;$(),w.current=((M=J.touches[0])==null?void 0:M.clientY)??null},D=J=>{var oe;$();const M=(oe=J.touches[0])==null?void 0:oe.clientY;M===void 0||w.current===null||(_(w.current-M),w.current=M)},z=()=>{o.current=!0},X=()=>{o.current=!1},ae=J=>{if(!eP.has(J.key))return;const M=J.target;(M===document.body||M instanceof Node&&R.contains(M))&&$()};R.addEventListener("wheel",C,{passive:!0}),R.addEventListener("touchstart",j,{passive:!0}),R.addEventListener("touchmove",D,{passive:!0}),R.addEventListener("pointerdown",z,{passive:!0}),window.addEventListener("pointerup",X,{passive:!0}),window.addEventListener("pointercancel",X,{passive:!0}),document.addEventListener("keydown",ae);const A=()=>{R.scrollTop=R.scrollHeight},de=new ResizeObserver(()=>{n.current&&A()});de.observe(R);for(const J of R.children)de.observe(J);const ue=new MutationObserver(J=>{for(const M of J){for(const oe of M.addedNodes)oe instanceof Element&&de.observe(oe);for(const oe of M.removedNodes)oe instanceof Element&&de.unobserve(oe)}n.current&&A()});return ue.observe(R,{childList:!0}),()=>{R.removeEventListener("scroll",B),R.removeEventListener("wheel",C),R.removeEventListener("touchstart",j),R.removeEventListener("touchmove",D),R.removeEventListener("pointerdown",z),window.removeEventListener("pointerup",X),window.removeEventListener("pointercancel",X),document.removeEventListener("keydown",ae),ue.disconnect(),de.disconnect(),b.current&&clearTimeout(b.current)}},[e,E,_,y]),{offEnd:i,offStart:c,away:h,moving:m,pinned:()=>n.current,jump:N,start:T,read:E}}function M0(e,t,n){const r=document.createRange();return r.selectNodeContents(e),r.setEnd(t,n),r.toString().length}function L0(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 PE(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)?M0(n,r.anchorNode,r.anchorOffset):null,l=r&&r.rangeCount>0&&o(r.focusNode)?M0(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]]:L0(n,i),[p,m]=l===null?[c[2],c[3]]:L0(n,l);u&&p&&r.setBaseAndExtent(u,h,p,m)},[e,t])}function St(e,t){const n=S.useRef(t);n.current=t,S.useEffect(()=>n.current(),e)}function DE(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 p=u.getBoundingClientRect(),m=u.offsetWidth/p.width;l=u.offsetLeft+(l-p.left)*m,c=u.offsetLeft+(c-p.left)*m}const h={left:Math.round(l),right:Math.round(c)};n(p=>p.left===h.left&&p.right===h.right?p:h)};r();const o=new ResizeObserver(r);return o.observe(e),window.addEventListener("resize",r),()=>{o.disconnect(),window.removeEventListener("resize",r)}},[e]),t}function P0(){const[e,t]=S.useState(null);return[t,DE(e)]}function PH(e){e.ctrlKey&&e.stopPropagation()}function tP(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 nP(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 rP(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 oP(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 dl=()=>P(e=>e.activeId),zE=()=>ME(!P(e=>e.connected),900),Ss=()=>P(e=>kn(e,e.activeId)),sk=()=>P(e=>So(e,e.activeId)),FE=()=>P(e=>e.rows),ik=()=>P(e=>e.visible),sP=()=>P(e=>e.visibleDiscovered),iP=()=>P(e=>e.activeRepoId?e.discoveredOpen[e.activeRepoId]??!1:!1),D0=[],aP=()=>P(e=>e.activeRepoId?e.archived[e.activeRepoId]??D0:D0),lP=()=>P(e=>e.activeRepoId?e.archivedOpen[e.activeRepoId]??!1:!1),cP=()=>P(e=>!(e.activeRepoId&&e.committedShut[e.activeRepoId])),uP=()=>P(e=>!!(e.activeRepoId&&e.turnOpen[e.activeRepoId])),Xi=()=>P(No),ak=()=>P(xE),dP=()=>P(e=>hi(e,e.activeRepoId)),fl=()=>P(e=>hi(e,Xg(e))),BE=e=>P(t=>_o(t,e)),It=(e,t)=>P(n=>_o(n,e)[t]),fP=()=>P(e=>e.overlay),jf=()=>P(mL),UE=()=>P(wE),Bc=()=>P(gL),Uc=()=>P(xo),hP=()=>P(e=>e.newProject),pi=()=>P(e=>e.touch),pP=()=>P(e=>e.draft),lk=()=>P(nc),mP=()=>P(e=>{const t=So(e,e.activeId),n=t?e.repos.find(r=>r.id===t.repoId):null;return Hd(n)?n:null});function gP(e){return e.image?{kind:"image",blob:e.image,sig:`image:${e.image.type}:${e.image.size}`}:e.text&&B1(e.text)?{kind:"text",text:e.text,sig:`text:${e.text}`}:null}function kP(){try{return localStorage.getItem(Qe.clipboardOffer)==="1"}catch{return!1}}let _s={access:"none",on:typeof localStorage<"u"&&kP(),offer:null},Cm="";const Am=new Set;function Cf(e){_s={..._s,...e};for(const t of Am)t()}async function wP(){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 gP({image:e,text:t})}async function Af({taken:e=!1,asking:t=!1}={}){if(!_s.on||!(_s.access==="granted"||t&&_s.access==="prompt"))return;let n;try{n=await wP()}catch{return}e&&(Cm=(n==null?void 0:n.sig)??""),Cf({offer:n&&n.sig!==Cm?n:null})}const yP=()=>void Af();let z0=!1;function vP(){var e,t;z0||(z0=!0,!(!((e=navigator.clipboard)!=null&&e.read)||!((t=navigator.permissions)!=null&&t.query))&&navigator.permissions.query({name:"clipboard-read"}).then(n=>{const r=()=>{Cf({access:n.state,...n.state==="denied"?{offer:null}:{}})};n.onchange=r,r(),window.addEventListener("focus",yP),document.hasFocus()&&Af()},()=>{}))}function bP(e){return Am.add(e),vP(),()=>{Am.delete(e)}}const xP=()=>_s;function EP(e){try{localStorage.setItem(Qe.clipboardOffer,e?"1":"0")}catch{}Cf({on:e,offer:null}),e&&Af({asking:!0})}function HE(){_s.offer&&(Cm=_s.offer.sig),Cf({offer:null})}const _P=()=>void Af({taken:!0});function SP(){return S.useSyncExternalStore(bP,()=>_s.offer)}const WE="application/x-toyon-source";function DH(e){const t=e.endColumn===1&&e.endLineNumber>e.startLineNumber?e.endLineNumber-1:e.endLineNumber;return{startLine:e.startLineNumber,endLine:t}}function NP(e,t){e.setData(WE,JSON.stringify(t))}const F0=e=>typeof e=="number"&&Number.isInteger(e)&&e>=1;function TP(e,t){const n=e.getData(WE);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!F0(o)||!F0(i)||i<o?null:{path:r.path,startLine:o,endLine:i,...typeof l=="string"?{ref:l}:{}}}const KE=e=>({left:e.x,top:e.y,right:e.x,bottom:e.y});function jP(e,t){return t.matchWidth===void 0?void 0:Math.max(0,e.right-e.left+t.matchWidth)}const CP=new Set(["top","bottom"]),Op={top:"bottom",bottom:"top",left:"right",right:"left"};function Mp(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 B0(e,t,n,r,o){return n==="top"||n==="left"?e>=o:e+t<=r-o}function Lp(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 U0(e,t,n,r,o){return n==="start"?e+t<=r-o:e>=o}const H0=(e,t,n,r)=>n||!r?e:t,W0=(e,t,n,r)=>Math.max(r,Math.min(e,n-r-t));function AP(e,t,n,r){const{offset:o=0,alignOffset:i=0,cover:l=!1,flip:c="none",margin:u=8}=r,h=CP.has(r.side),p=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 E=Mp(p.a,p.size,g,o,l),_=Mp(p.a,p.size,Op[g],o,l);g=H0(g,Op[g],B0(E,p.size,g,p.limit,u),B0(_,p.size,Op[g],p.limit,u))}let y=r.align??"center";if((c==="align"||c==="both")&&y!=="center"){const E=y==="start"?"end":"start",_=Lp(m.a,m.size,y,i),N=Lp(m.a,m.size,E,i);y=H0(y,E,U0(_,m.size,y,m.limit,u),U0(N,m.size,E,m.limit,u))}const w=W0(Mp(p.a,p.size,g,o,l),p.size,p.limit,u),b=W0(Lp(m.a,m.size,y,i),m.size,m.limit,u);return h?{x:b,y:w,side:g,align:y}:{x:w,y:b,side:g,align:y}}function IP(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 ZE={sep:!0},ss=e=>!("sep"in e);function If(e){const t=[];for(const n of e)(ss(n)||t.length>0&&ss(t[t.length-1]))&&t.push(n);for(;t.length>0&&!ss(t[t.length-1]);)t.pop();return t}const zn=e=>If(e.flatMap((t,n)=>n?[ZE,...t]:t));let $a=null,RP=0;const Im=new Set,K0=()=>{for(const e of Im)e()},no={get:()=>$a,subscribe(e){return Im.add(e),()=>{Im.delete(e)}},open(e){const t=If(e.items);if(t.length===0)return no.close();$a={...e,items:t,id:++RP},K0()},close(){$a&&($a=null,K0())},toggle(e){$a&&$a.target===e.target?no.close():no.open(e)}};function ck(){return S.useSyncExternalStore(no.subscribe,no.get)}function qE(e){const t=e.nativeEvent;return t&&"pointerType"in t?t.pointerType==="":e.clientX===0&&e.clientY===0}function $P(e,t){return qE(e)?{anchor:(t.querySelector('[data-state~="cursor"]')??t).getBoundingClientRect()}:{at:{x:e.clientX,y:e.clientY}}}function OP(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:KE(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=If(t(qE(r)?"keyboard":"pointer",r.target));if(o.length===0)return;r.preventDefault(),r.stopPropagation();const i=r.currentTarget;no.open({items:o,owner:e,key:n,target:i,...$P(r,i)})}}},dropdown(t,n="left",r){return{"aria-haspopup":"menu",onClick:o=>{o.stopPropagation();const i=o.currentTarget;no.toggle({items:t(),owner:e,key:r,target:i,toggles:!0,anchor:i.getBoundingClientRect(),align:n})}}},openUnder(t,n,r){no.open({items:n(),owner:e,key:r,target:t,toggles:!0,anchor:t.getBoundingClientRect(),align:"left"})}}),[e])}const GE=e=>({id:"open-out",label:Sf()?"open in the browser":"open in a new tab",onClick:()=>window.open(e,"_blank")}),on=e=>{var t;return void((t=navigator.clipboard)==null?void 0:t.writeText(e).catch(()=>{}))};function VE(e,t){const n=navigator.clipboard;if(n){if(typeof ClipboardItem>"u"||!n.write){e==="text/plain"&&t.then(r=>r.text()).then(on,()=>{});return}n.write([new ClipboardItem({[e]:t})]).catch(()=>{})}}const MP=e=>VE("text/plain",fetch(e).then(t=>t.blob())),LP=e=>VE("image/png",PP(e));async function PP(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()}}const DP=[{label:"Zed",scheme:"zed"},{label:"VS Code",scheme:"vscode"},{label:"Cursor",scheme:"cursor"}];function uk(e){return xg(e)}function as(e){return(e==null?void 0:e.urls.host)??(typeof location=="object"?location.hostname:"127.0.0.1")}function Gi(e,t,n){if(!uk(n))return[];const r=DP.map(o=>({id:`open:${o.scheme}`,label:`open in ${o.label}`,onClick:()=>{window.location.href=`${o.scheme}://file${e}`}}));return r.push(...Rf(t,n)),r}function Rf(e,t){return!e||!uk(t)?[]:[{id:"reveal",label:"reveal in Finder",onClick:e}]}function zP(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??""}
98
+ ${n.sort().join(`
99
+ `)}`}function $f(e,t,{sock:n,dispatch:r}){var l,c;if(!n)return;const o=t.local[e]??Yi,i=zP((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 FP=["diff","file","preview"],YE=(e,t)=>FP.filter(n=>!(n==="preview"&&!Ef(e))&&!(n==="diff"&&t));let BP=0;const Ko=()=>++BP;function er({dispatch:e},{focus:t=!0,...n}){e({a:"open-file",v:{...n,focus:t,seq:Ko()}})}const Rm=new Map;function XE(e,t,n=""){const{sock:r}=e;if(!r)return Promise.resolve("not connected to the daemon");const o=Ko();return new Promise(i=>{Rm.set(o,l=>{l.ok?(er(e,{...t,view:qi(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 UP(e){const t=Rm.get(e.seq);return t?(Rm.delete(e.seq),t(e),!0):!1}function HP({dispatch:e},t){e({a:"tree-reveal",...t})}function xs(e,t,{discard:n=!1,ref:r,since:o,showing:i,added:l=!1,kept:c=!1,select:u},h){const{sock:p,dispatch:m}=h,g=YE(t,l).filter(N=>N!==i).map(N=>({id:`view:${N}`,label:`view ${N}`,onClick:()=>i?m({a:"editor-view",v:N}):er(h,{worktreeId:e.id,path:t,view:N,ref:r,since:o})})),y=`${e.dir}/${t}`,w=c?[]:Gi(y,()=>p==null?void 0:p.send({t:"reveal",worktreeId:e.id,path:t}),as(p));return zn([g,[{id:"copy-path",label:"copy path",onClick:()=>on(y)}],w,u?[{id:"select",label:"select…",onClick:()=>u(t)}]:[],n?[{id:"discard",label:"discard changes…",danger:!0,onClick:()=>{window.confirm(QE([t]))&&(p==null||p.send({t:"discard-files",worktreeId:e.id,paths:[t]}))}}]:[]])}function QE(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(`
100
+ `);return`Discard uncommitted changes to ${e.length} files?
101
+
102
+ ${r}`}const ho=(e,t,n)=>e.dispatch({a:"notice",id:t,text:n});function Of(e,t,n){var o;const r=Gj(((o=e.getState().local[t])==null?void 0:o.attachments)??[],n);return r===0&&ho(e,t,yg(n)),r}const WP=1e3,KP=1e4,JE=new WeakMap;function ZP(e,t){JE.set(e,t)}async function e_(e,t,n,r){var w,b;const{local:o,...i}=n;e.dispatch({a:"attach",id:t,items:[{...n,upload:"",uploading:!0}]});const l=()=>{var E;return(E=Object.entries(e.getState().local).find(([,_])=>_.attachments.some(N=>N.key===n.key)))==null?void 0:E[0]},c=JE.get(e);let u=-1;const h=E=>{const _=Math.min(99,Math.floor(E*100)),N=l();_===u||N===void 0||(u=_,e.dispatch({a:"upload-progress",id:N,key:n.key,progress:_}))},p=()=>(u=-1,c?wM(c,n.kind,r,h):Promise.resolve(null));let m=await p();const g=m===null;g&&ho(e,l()??t,`${n.name}: Toyon is not answering; it attaches once it is back`);for(let E=WP;m===null&&l()!==void 0;E=Math.min(E*2,KP))await new Promise(_=>setTimeout(_,E)),l()!==void 0&&(m=await p());const y=l();if(!(m===null||y===void 0))if(typeof m=="string")e.dispatch({a:"detach",id:y,key:n.key}),ho(e,y,`${n.name}: ${m}`);else{const E=i.kind==="file"?{...i,...m}:{...i,upload:m.upload,bytes:m.bytes};e.dispatch({a:"attached",id:y,key:n.key,item:E});const _=(b=e.getState().local[((w=os(y))==null?void 0:w.source)??y])==null?void 0:b.notice;g&&(_!=null&&_.startsWith(`${n.name}: Toyon is not answering`))&&ho(e,y,"")}o&&URL.revokeObjectURL(o)}function dk(e,t,n){if(!t||n.length===0)return;const r=Of(e,t,"file");if(r!==0){for(const o of n.slice(0,r)){const i=o.name||"file";if(o.size>l0){ho(e,t,`${i}: larger than ${bg(l0)}`);continue}const l={kind:"file",key:crypto.randomUUID(),upload:"",name:i,bytes:o.size,text:!1};e_(e,t,l,o)}n.length>r&&ho(e,t,`kept ${r} of ${n.length}: ${yg("file")}`)}}function fk(e,t,n,r={}){if(!t)return;const o=h2(r.source?n.replace(/\r?\n$/,""):n);if(o.length>s2)return r.source?ho(e,t,"that paste is too large; save it in the worktree and reference it with @path"):dk(e,t,[new File([o],i2,{type:"text/plain"})]);Of(e,t,"paste")!==0&&e.dispatch({a:"attach",id:t,items:[{kind:"paste",key:crypto.randomUUID(),text:o,...r,...Rg(o)}]})}function t_(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 Z0(e,t){var i;const n=e.getState(),r=kn(n,n.activeId),o=Fc(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 y;if(u.kind!=="paste")return!1;if(!("source"in t))return u.name===t.name&&u.text===t.text;const{path:h,startLine:p,endLine:m,ref:g}=t.source;return((y=u.source)==null?void 0:y.path)===h&&u.source.startLine===p&&u.source.endLine===m&&u.source.ref===g})||fk(e,o,t.text,l)}e.dispatch(t?{a:"focus-chat"}:yE(n))}function Mf(e,t){return t!==e.activeId?null:Fc(kn(e,t))}const hk=(e,t)=>`@${e}${t?"/":""}`;function pk(e,t,n){var c;const r=e.getState(),o=Mf(r,t);if(!o)return;const i=((c=r.local[o])==null?void 0:c.draft)??"",l=i===""||/\s$/.test(i)?"":" ";e.dispatch({a:"set-draft",id:o,text:`${i}${l}${n}`}),e.dispatch({a:"focus-chat"})}function n_(e,t,n,r){pk(e,t,`${hk(n,r)} `)}function qP(e,t,n){n.length!==0&&pk(e,t,`${n.map(r=>hk(r,!1)).join(" ")} `)}function q0(e,t,n){pk(e,t,n)}function GP(e,t){return kn(e,t)?t:null}function VP(e,t){var r;const n=(r=kn(e,t))==null?void 0:r.worktree;return n?[n.path]:[]}function G0(e,t){if(!e)return e;const n=t.find(r=>e.startsWith(`${r}/`));return n?e.slice(n.length+1):e}function YP(e,t,n){var g;e.dispatch({a:"set-picking",v:!1});const r=e.getState(),o=GP(r,t);if(!o)return;const{classes:i,route:l,element:c,...u}=n,h=VP(r,t),p={...u,file:G0(u.file,h),callFile:G0(u.callFile,h)};!(((g=r.local[o])==null?void 0:g.attachments)??[]).some(y=>y.kind==="pick"&&y.selector===p.selector)&&Of(e,o,"pick")>0&&e.dispatch({a:"attach",id:o,items:[{kind:"pick",key:crypto.randomUUID(),...p}]}),e.dispatch({a:"focus-chat"})}function XP(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 p=u.lastIndexOf("/"),m={path:u,name:u.slice(p+1),kind:"folder",children:[],ignored:!1};return i(p===-1?"":u.slice(0,p)).children.push(m),o.set(u,m),m},l=(u,h,p=!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:p})};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=p=>p.kind==="file"?1:0;u.children.sort((p,m)=>h(p)-h(m)||dE(p.name,m.name));for(const p of u.children)p.kind==="folder"&&c(p)};return c(r),r.children}function QP(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 r_=e=>{const t=e.lastIndexOf("/");return t===-1?"":e.slice(0,t)};function JP(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 e4(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 Ud(o))n.add(i)}return{files:t,folders:n}}function mk(e){const t=e.findLast(n=>n.kind==="ask"&&!n.outcome||n.kind==="handoff"&&n.state==="proposed");return(t==null?void 0:t.kind)==="ask"||(t==null?void 0:t.kind)==="handoff"?t:null}function t4(e){const t=e?mk(e.chat):null;return(t==null?void 0:t.kind)!=="ask"||t.ask.kind!=="question"||(e==null?void 0:e.cardParked)===t.id?null:Ka(t.id)}function V0(e){return e.kind==="ask"?PM(e):`Continue in ${e.repo.name}?`}function n4(e,t,n,r){const o=n?r==null?void 0:r.trim():void 0;return{t:"handoff-answer",worktreeId:t,id:e.id,go:n,...o?{note:o}:{}}}function r4(e,t,n){const r=e.trim();if(!r)return{pick:!0};if(t.length<2)return{error:"open another project first"};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.filter(m=>m.name.toLowerCase()===c),h=u.length>0?u:t.filter(m=>m.name.toLowerCase().startsWith(c));if(h.length===0)return{error:`no open project named "${i}"`};if(h.length>1)return{error:`"${i}" names more than one project`};const p=h[0];return p.id===n?{error:`this worktree is already in ${p.name}`}:{repo:p,...l?{text:l}:{}}}const o_=new Set(n2),o4=/^image\.[a-z0-9]+$/i,s4=e=>o4.test(e.name),i4=(e,t)=>e===t||e.name===t.name&&e.size===t.size&&e.type===t.type&&e.lastModified===t.lastModified;function a4(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=>i4(l,i))||n.push(i);const r=n.filter(i=>!s4(i));if(r.length>0)return r;const o=n.find(i=>o_.has(i.type))??n[0];return o?[o]:[]}function l4(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 c4(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 u4(e){try{return await createImageBitmap(e)}catch{throw new Error(`${e.name||"image"}: not a readable image`)}}function Y0(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 d4(e){const t=await u4(e);try{const n=Math.max(t.width,t.height);let r=e,o=e.type,i=t.width,l=t.height;if(!o_.has(o)||n>a0||e.size>$p){const c=o==="image/jpeg"?"image/jpeg":"image/png";let u=Math.min(1,a0/n);for(r=await Y0(t,u,c);r.size>$p&&u>.1;)u*=.7,r=await Y0(t,u,c);if(r.size>$p)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},f4=80,h4=2e3;let is=null,$m;const s_=(e,t)=>{clearTimeout($m),$m=setTimeout(()=>kk(e),t)};function gk(e,t){is??(is={refused:!1}),e.dispatch({a:"drag-files",v:is.refused?null:t}),s_(e,h4)}function p4(e){is&&s_(e,f4)}function kk(e){clearTimeout($m),is=null,e.dispatch({a:"drag-files",v:null})}function m4(e){is&&(is.refused=!0,e.dispatch({a:"drag-files",v:null}))}const i_="application/x-toyon-path";let zi=null;function g4(e){zi=e}function a_(e){zi=null,is&&kk(e)}const X0=e=>zi!==null&&Array.from(e.dataTransfer.types).includes(i_);function k4(e){return{onDragOver:t=>{if(!X0(t)||!zi)return;t.preventDefault();const n=Mf(e.getState(),zi.worktreeId)!==null;t.dataTransfer.dropEffect=n?"copy":"none",n&&gk(e,{at:"chat"})},onDrop:t=>{if(!X0(t)||!zi)return;t.preventDefault();const{worktreeId:n,path:r,folder:o}=zi;a_(e),n_(e,n,r,o)}}}let w4=0;function y4(e){const{blob:t,...n}=e;return{kind:"image",key:`img${++w4}`,...n,upload:"",bytes:t.size,local:URL.createObjectURL(t)}}async function Lf(e,t,n){var l;if(!t||n.length===0)return;const r=Of(e,t,"image");if(r===0)return;const o=await Promise.allSettled(n.slice(0,r).map(d4));for(const c of o)c.status==="fulfilled"&&e_(e,t,y4(c.value),c.value.blob);const i=o.find(c=>c.status==="rejected");i?ho(e,t,String(((l=i.reason)==null?void 0:l.message)??i.reason)):n.length>r&&ho(e,t,`kept ${r} of ${n.length}: ${yg("image")}`)}function v4(e,t,n){n.kind==="image"?Lf(e,t,[new File([n.blob],"image.png",{type:n.blob.type})]):fk(e,t,n.text),HE()}function l_(e,t,n){const r=o=>o.type.startsWith("image/");Lf(e,t,n.filter(r)),dk(e,t,n.filter(o=>!r(o)))}function c_(e,t,{images:n=!1}={}){const r=document.createElement("input");r.type="file",r.multiple=!0,n&&(r.accept="image/*"),r.onchange=()=>l_(e,t,Array.from(r.files??[])),r.click()}function Hc(e){const t=e.getState();if(t.newProject)return rl;const n=kn(t,t.activeId);return t4(n?t.local[n.worktree.id]:void 0)??Fc(n)}function b4(e,t){const n=Hc(e);l_(e,n,t.filter(o=>!o.folder).map(o=>o.file));const r=t.find(o=>o.folder);n&&r&&ho(e,n,`${r.file.name}: a folder cannot be attached; drop its files`)}const Om=Promise.resolve(null);function x4(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))??Om;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:Om});return t}const E4=e=>e.map(t=>({file:t,handle:Om}));async function u_(e){const t=zd*4;if(e.size>t)return{text:"",tooLarge:!0};const n=await c4(e,t);return n===null?null:n.length>zd?{text:"",tooLarge:!0}:{text:n,tooLarge:!1}}async function _4(e,t){const n=Hc(e),r=e.getState().activeId,o=p=>n&&ho(e,n,p),i=t.filter(p=>p.file.type.startsWith("image/")).map(p=>p.file);i.length&&Lf(e,n,i);const l=t.filter(p=>!p.file.type.startsWith("image/")),c=l[0];if(!c||!r)return;const u=await u_(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:Ko()}}),l.length>1&&o(`opened ${c.file.name}; one file opens at a time`)}async function S4(e,t,n,r){const o=Mf(e.getState(),n.worktreeId)??Hc(e),i=c=>o&&ho(e,o,c),l={sock:t,dispatch:c=>e.dispatch(c)};for(const{file:c}of r){const u=await u_(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,p=await XE(l,{worktreeId:n.worktreeId,path:h},u.text);p&&i(`${c.name}: ${p}`)}}function N4(e){const t=Hc(e);t&&ho(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 d_(e,t,n,r){const o=(is==null?void 0:is.refused)??!1;kk(e),!(o||r.length===0)&&(n?n.at==="chat"||n.at==="centre"&&e.getState().newProject?b4(e,r):n.at==="centre"?_4(e,r):S4(e,t,n,r):N4(e))}const Q0=e=>!!e&&Array.from(e.types).includes("Files");function J0(e,t){var l;const n=t instanceof Element?t:t instanceof Node?t.parentElement:null;if(!n)return null;if((l=hc.el)!=null&&l.contains(n))return Hc(e)?{at:"chat"}:null;const r=n.closest(".tree"),o=r==null?void 0:r.dataset.worktree;if(r&&o){const c=n.closest("[data-path]"),u=c==null?void 0:c.dataset.kind;if(u==="submodule")return null;const h=(c==null?void 0:c.dataset.path)??"";return{at:"tree",worktreeId:o,dir:u==="file"?r_(h):h}}if(!n.closest(".center-root")||n.closest('[data-pane="terminal"], [data-pane="design"]'))return null;const i=e.getState();return i.activeId||i.newProject?{at:"centre"}:null}function T4(){const e=Zn(),t=ct();S.useEffect(()=>{const n=l=>{l.defaultPrevented||!Q0(l.dataTransfer)||(l.preventDefault(),gk(e,J0(e,l.target)),l.dataTransfer&&(l.dataTransfer.dropEffect=e.getState().dragFiles?"copy":"none"))},r=l=>{l.defaultPrevented||!Q0(l.dataTransfer)||(l.preventDefault(),d_(e,t,J0(e,l.target),x4(l.dataTransfer)))},o=()=>p4(e),i=l=>{l.key==="Escape"&&m4(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 f_(e,t){const n=Zn(),r=S.useRef(!1);return{onPaste:c=>{_P();const u=a4(c.clipboardData);if(u.length>0)return c.preventDefault(),void Lf(n,e,u);const h=l4(c.clipboardData);if(h.length>0)return c.preventDefault(),dk(n,e,h);if(r.current)return;const p=c.clipboardData.getData("text/plain"),m=p.trim()?TP(c.clipboardData,t):null;!(m&&p.includes(`
103
+ `))&&!B1(p)||(c.preventDefault(),fk(n,e,p,m?{source:m}:{}))},onPasteKey:c=>{r.current=(c.metaKey||c.ctrlKey)&&c.shiftKey&&c.key.toLowerCase()==="v"},onPasteKeyUp:()=>{r.current=!1}}}const h_=(e,t)=>`${e}${e.includes("?")?"&":"?"}${kC}=${encodeURIComponent(t)}`,Mm=(e,t)=>!e.serving&&t!==null,j4=3e3;function p_(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,p)=>{i.current.has(h)||(i.current.add(h),rE(e.sock.urls).then(m=>{if(i.current.delete(h),!!l.current.some(y=>y.id===h&&y.url===p)){if(!m){c.current.set(h,setTimeout(()=>{c.current.delete(h),l.current.some(y=>y.id===h&&y.url===p)&&u(h,p)},j4));return}o(y=>new Map(y).set(h,{url:p,src:h_(p,m.code)}))}}))},[e]);return S.useEffect(()=>{const h=c.current;return()=>{for(const p of h.values())clearTimeout(p);h.clear()}},[]),S.useEffect(()=>{var p;if(!n)return;for(const m of t)((p=r.get(m.id))==null?void 0:p.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 p,m;return n?((p=r.get(h))==null?void 0:p.src)??null:((m=t.find(g=>g.id===h))==null?void 0:m.url)??null},renew:h=>{const p=t.find(m=>m.id===h);!p||!n||(o(m=>{const g=new Map(m);return g.delete(h),g}),u(h,p.url))}}}function C4(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}]),p_(e,r.current,n).urlOf("one")}function A4(e,t,n){if(!n){window.open(t,"_blank");return}const r=window.open("","_blank");rE(e.sock.urls).then(o=>{const i=o?h_(t,o.code):t;r?r.location.href=i:window.open(i,"_blank")})}function Ue(...e){return e.filter(Boolean).join(" ")}const I4={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",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",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",land:"M8 2.1a1.3 1.3 0 1 0 0 2.6 1.3 1.3 0 1 0 0-2.6z M8 4.7v5.4 M5.4 7.6 8 10.2l2.6-2.6 M3 13h10",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 Nt({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:I4[e]})})}function al({size:e="inline",variant:t="ring",className:n}){return d.jsx("span",{className:Ue("spinner",e==="dot"&&"spinner-dot",t==="squares"&&"spinner-squares",n),"aria-hidden":"true",children:t==="squares"&&d.jsxs(d.Fragment,{children:[d.jsx("span",{}),d.jsx("span",{}),d.jsx("span",{}),d.jsx("span",{})]})})}const R4='button, a[href], input, textarea, select, summary, label, [role="button"], [role="menuitem"]';function eb(e){var n;const t=e;return((n=t==null?void 0:t.closest)==null?void 0:n.call(t,R4))??t??null}function $4(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 O4(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 M4(e,t){const n=new Set;for(const r of e)if($4(r,t))for(let o=r;o;o=o.parent)n.add(o);return e.filter(r=>!n.has(r)&&r.dismiss).reverse()}const L4=e=>{setTimeout(e,0)};function P4({schedule:e=L4}={}){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:O4(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=b=>{var N;const E=b.target,_=E?M4(t,E):[];for(const T of _)(N=T.dismiss)==null||N.call(T,"outside");r=_.length>0&&b.pointerType==="touch",r&&b.preventDefault(),n=eb(b.target)},p=()=>e(()=>n=null),m=()=>{r=!1,p()},g=b=>{if(r){r=!1,b.preventDefault(),b.stopPropagation();return}n||(n=eb(b.target),p())},y=b=>{var _;const E=t[t.length-1];(_=E==null?void 0:E.onKey)==null||_.call(E,b)},w=()=>e(()=>{var b;((b=u.activeElement)==null?void 0:b.tagName)==="IFRAME"&&l("frame")});return u.addEventListener("pointerdown",h,!0),u.addEventListener("pointerup",p,!0),u.addEventListener("pointercancel",m,!0),u.addEventListener("click",g,!0),c.addEventListener("keydown",y,!0),c.addEventListener("blur",w),()=>{u.removeEventListener("pointerdown",h,!0),u.removeEventListener("pointerup",p,!0),u.removeEventListener("pointercancel",m,!0),u.removeEventListener("click",g,!0),c.removeEventListener("keydown",y,!0),c.removeEventListener("blur",w)}}}}const Kd=P4(),Pp=typeof HTMLElement<"u"&&"showPopover"in HTMLElement.prototype,tb=e=>(e==null?void 0:e.getBoundingClientRect())??null;function D4(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 Ns({className:e,anchor:t,placement:n,coverBy:r,track:o=t==="parent",raiseKey:i,onDismiss:l,onKey:c,onBack:u,trigger:h,from:p,boxRef:m,handle:g,children:y,...w}){const b=S.useRef(null),E=S.useRef({anchor:t,placement:n,coverBy:r,onDismiss:l,onKey:c,onBack:u,trigger:h,from:p});E.current={anchor:t,placement:n,coverBy:r,onDismiss:l,onKey:c,onBack:u,trigger:h,from:p};const _=S.useCallback(()=>{const T=b.current,{anchor:R,placement:O,coverBy:B}=E.current;if(!T||!R||!O)return;const $=R==="parent"?tb(T.parentElement):R();if(!$)return;const C=jP($,O);C!==void 0&&(T.style.width=`${C}px`);for(let j=0;j<2;j++){const D=B?D4(T,B,T.dataset.side??"",T.dataset.align??""):null,z=AP($,{w:T.offsetWidth,h:T.offsetHeight},{w:window.innerWidth,h:window.innerHeight},D?{...O,...D}:O);T.style.left=`${z.x}px`,T.style.top=`${z.y}px`;const X=T.dataset.side!==z.side||T.dataset.align!==z.align;if(T.dataset.side=z.side,T.dataset.align=z.align,!X)break}},[]);S.useImperativeHandle(g,()=>({update:_}),[_]),S.useLayoutEffect(()=>{const T=b.current;if(!T)return;m&&(m.current=T),Pp&&(T.popover="manual",T.matches(":popover-open")||T.showPopover());const{onDismiss:R,onKey:O,onBack:B,trigger:$,from:C}=E.current,j=R||O?Kd.register({box:T,trigger:$,from:C,dismiss:R?D=>{var z,X;return(X=(z=E.current).onDismiss)==null?void 0:X.call(z,D)}:void 0,onKey:O?D=>{var z,X;return(X=(z=E.current).onKey)==null?void 0:X.call(z,D)}:void 0,back:B?()=>{var D,z;return(z=(D=E.current).onBack)==null?void 0:z.call(D)}:void 0}):null;return()=>{j&&Kd.unregister(j),m&&(m.current=null),Pp&&T.isConnected&&T.matches(":popover-open")&&T.hidePopover()}},[m]),S.useLayoutEffect(_),S.useLayoutEffect(()=>{if(!o)return;let T=0,R="";const O=()=>{const B=b.current,{anchor:$}=E.current,C=B&&$?$==="parent"?tb(B.parentElement):$():null;if(B&&C){const j=`${C.left},${C.top},${C.right},${C.bottom},${B.offsetWidth},${B.offsetHeight},${window.innerWidth},${window.innerHeight}`;j!==R&&(R=j,_())}T=requestAnimationFrame(O)};return T=requestAnimationFrame(O),()=>cancelAnimationFrame(T)},[o,_]);const N=S.useRef(!0);return St([i],()=>{if(N.current){N.current=!1;return}const T=b.current;!Pp||!(T!=null&&T.matches(":popover-open"))||(T.hidePopover(),T.showPopover(),_())}),d.jsx("div",{ref:b,className:Ue("float",e),...w,children:y})}const z4=/^[⌘⇧⌥⌃]+/;function Zo({k:e,chip:t=!1,className:n}){var l;const r=(l=e.match(z4))==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 Ut(e,t,{placement:n,detail:r,card:o,dot:i,name:l,aside:c,also:u}={}){const h=l?`${e}: ${l}`:e,p=(Array.isArray(r)?r:[r]).filter(g=>!!g),m=[h,...p,...c??[]].join(", ");return{"data-tip":e,"data-tip-key":t,"data-tip-placement":n,"data-tip-detail":p.length?p.join(`
104
+ `):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(`
105
+ `):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 F4=120,B4=600,U4=150,nb=6,H4=18,Dp=8;function rb(e){const t=e.dataset.tipPlacement;return t==="follow"||t==="top"||t==="bottom"||t==="left"||t==="right"?t:"bottom"}function W4(e){return e==="follow"?{side:"bottom",align:"start",offset:H4,alignOffset:-12,flip:"both",margin:Dp}:e==="left"||e==="right"?{side:e,align:"start",offset:nb,flip:"both",margin:Dp}:{side:e,align:"center",offset:nb,flip:"side",margin:Dp}}function K4(e,t){return e.placement==="follow"?KE(t):e.el.getBoundingClientRect()}function m_(){var u;const[e,t]=S.useState(null),n=S.useRef(null),r=S.useRef(null),o=S.useRef({x:0,y:0}),i=pi();if(S.useEffect(()=>{if(i)return;let h=0,p=0,m=null,g=!1,y=0;const w=()=>{window.clearTimeout(h),window.clearTimeout(p)},b=()=>{w(),g&&(y=Date.now()),g=!1,m=null,t(null)},E=(C,j)=>{var z,X;const D=C.dataset.tip;if(!D)return b();w(),g=!0,t({el:C,text:D,key:C.dataset.tipKey,detail:(z=C.dataset.tipDetail)==null?void 0:z.split(`
106
+ `),card:C.dataset.tipCard!==void 0,dot:C.dataset.tipDot,name:C.dataset.tipName,aside:(X=C.dataset.tipAside)==null?void 0:X.split(`
107
+ `),also:C.dataset.tipAlso&&C.dataset.tipAlsoKey?{text:C.dataset.tipAlso,key:C.dataset.tipAlsoKey}:void 0,placement:j})},_=C=>{const j=C.target;return j instanceof Element?j.closest("[data-tip]"):null},N=C=>{o.current={x:C.clientX,y:C.clientY};const j=_(C);if(j===m)return;if(w(),m=j,!j){g&&(p=window.setTimeout(b,U4));return}const D=rb(j);if(g||Date.now()-y<B4)return E(j,D);h=window.setTimeout(()=>E(j,D),F4)},T=C=>{C.relatedTarget||b()},R=C=>{const j=_(C);if(j!=null&&j.matches(":focus-visible")){w(),m=j;const D=rb(j);E(j,D==="follow"?"bottom":D)}},O=()=>b(),B=C=>{C.key!=="Shift"&&C.key!=="Control"&&C.key!=="Alt"&&C.key!=="Meta"&&b()},$=C=>{m&&C.target instanceof Node&&C.target.contains(m)&&b()};return document.addEventListener("mouseover",N),document.addEventListener("mouseout",T),document.addEventListener("mousedown",b),document.addEventListener("keydown",B),document.addEventListener("scroll",$,!0),document.addEventListener("focusin",R),document.addEventListener("focusout",O),window.addEventListener("blur",b),()=>{w(),document.removeEventListener("mouseover",N),document.removeEventListener("mouseout",T),document.removeEventListener("mousedown",b),document.removeEventListener("keydown",B),document.removeEventListener("scroll",$,!0),document.removeEventListener("focusin",R),document.removeEventListener("focusout",O),window.removeEventListener("blur",b)}},[i]),S.useLayoutEffect(()=>{e&&!e.el.isConnected&&t(null)},[e]),S.useEffect(()=>{if((e==null?void 0:e.placement)!=="follow")return;const h=p=>{var m;o.current={x:p.clientX,y:p.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(al,{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(Zo,{k:e.key,className:"tooltip-key"})]});return d.jsxs(Ns,{className:Ue("tooltip",e.card&&"tooltip-card"),role:"tooltip",boxRef:n,handle:r,anchor:()=>K4(e,o.current),placement:W4(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(Zo,{k:e.key,className:"tooltip-key"}):d.jsx("span",{}),d.jsx("span",{className:"tooltip-also",children:e.also.text}),d.jsx(Zo,{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,p)=>d.jsx("div",{className:"tooltip-detail",children:h},p)),e.aside&&d.jsx("div",{className:"tooltip-foot",children:e.aside.map(h=>d.jsx("span",{children:h},h))})]})}const Z4={sm:"",md:"btn-md",lg:"btn-lg"},q4={ghost:"",outline:"btn-outline",field:"btn-outline btn-field",inline:"btn-inline"},g_={primary:"tone-primary",quiet:"tone-quiet",danger:"tone-danger",strong:"tone-strong",chrome:"tone-chrome"};function ze({variant:e="ghost",size:t="sm",tone:n,on:r,mono:o,busy:i,className:l,type:c="button",disabled:u,children:h,...p}){const m=Ue("btn",q4[e],Z4[t],n&&g_[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,...p,children:[i&&d.jsx(al,{}),h]})}function Pt({icon:e,label:t,hint:n,detail:r,also:o,silent:i,badge:l,tone:c,on:u,className:h,type:p="button",...m}){const g=Ue("btn-icon",c&&g_[c],u&&"on",h),y=Ut(t,n,{detail:r,also:o});return d.jsxs("button",{className:g,type:p,...i?{"aria-label":y["aria-label"]}:y,...m,children:[typeof e=="string"?d.jsx(Nt,{name:e}):e,l]})}function Wc(e,t,n){return n===0?0:(e+t+n)%n}function ob(e,t,n){return e>=0?Wc(e,t,n):n===0?-1:t>0?0:n-1}function k_(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 zp(e,t){return e&&e.length>t.length&&e.toLowerCase().startsWith(t.toLowerCase())?e.slice(t.length):null}function G4(e,t){if(e==null)return null;if(typeof e=="string"){const o=zp(e,t);return o?{text:o,accept:o,params:[]}:null}const n=zp(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:zp(e.accept,t),params:r}}function w_(e){const{results:t,keyOf:n,q:r,onPick:o,listRef:i,onActive:l,onSide:c,completionOf:u,narrowTo:h,setQ:p,tabPicks:m,onIdlePick:g}=e,[y,w]=S.useState(()=>{var B;return e.idle?-1:Math.max(0,((B=e.initialIndex)==null?void 0:B.call(e,t))??0)}),b=y>=0&&t[y]?n(t[y]):null,E=S.useRef(l);E.current=l,St([b],()=>{var B,$,C;($=(B=i.current)==null?void 0:B.querySelector('.picker-item[data-state~="cursor"]'))==null||$.scrollIntoView({block:"nearest"}),(C=E.current)==null||C.call(E,y>=0?t[y]??null:null)});const _=y<0?-1:Math.min(y,Math.max(0,t.length-1)),N=_>=0?t[_]??null:null,T=N?G4(u==null?void 0:u(N,r),r):null,R=B=>{const $=h==null?void 0:h(B,r);if($==null)return o(B,r);p==null||p($),w(0)};return{index:_,active:N,ghost:T,setIndex:w,pick:R,onKeyDown:B=>{if(B.key==="ArrowDown")B.preventDefault(),w(ob(_,1,t.length));else if(B.key==="ArrowUp")B.preventDefault(),w(ob(_,-1,t.length));else if((B.key==="ArrowLeft"||B.key==="ArrowRight")&&c&&N)B.preventDefault(),c(N,B.key==="ArrowLeft"?-1:1);else if(B.key==="Tab"&&(T!=null&&T.accept))B.preventDefault(),p==null||p(r+T.accept),w(0);else if(B.key==="Tab"&&m&&N)B.preventDefault(),R(N);else if(B.key==="Enter"&&N)B.preventDefault(),R(N);else if(B.key==="Enter"&&_<0&&g)B.preventDefault(),g(r);else return!1;return!0}}}function gr(e){const t=Object.keys(e).filter(n=>e[n]);return t.length>0?t.join(" "):void 0}const V4=new Set(["Shift","Meta","Control","Alt","CapsLock","Fn"]);function y_(){const e=ck(),t=Zn();return S.useEffect(()=>{if(!e)return;const n=()=>{e.target.isConnected||no.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(Y4,{spec:e},e.id):null}function Y4({spec:e}){const t=e.items,n=t.filter(ss),[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,y;{const w=()=>no.close(),{idx:b,items:E}=i.current;if(V4.has(m.key))return;if(m.key==="ArrowDown"||m.key==="ArrowUp"){m.preventDefault(),m.stopPropagation();const _=m.key==="ArrowDown"?1:-1;o(IP(E,b,_));return}if((m.key==="Enter"||m.key===" ")&&b>=0&&E[b]&&!E[b].disabled){m.preventDefault(),m.stopPropagation(),E[b].onClick(),w();return}if(m.key==="Escape"){m.stopPropagation(),w();return}if(m.key.length===1&&!m.metaKey&&!m.ctrlKey&&!m.altKey){m.preventDefault(),m.stopPropagation();const _=Array.from(((g=l.current)==null?void 0:g.querySelectorAll(".menu-label"))??[],T=>T.textContent??""),N=k_(_,b,m.key);N>=0&&!((y=E[N])!=null&&y.disabled)&&o(N);return}w()}};S.useEffect(()=>{const m=()=>no.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}=OP(e),p=n.some(m=>m.checked);return d.jsx(Ns,{className:"menu",role:"menu",boxRef:l,anchor:()=>u,placement:h,track:!1,from:e.target,trigger:e.toggles?e.target:null,onDismiss:()=>no.close(),onKey:c,onContextMenu:m=>m.preventDefault(),children:t.map((m,g)=>{if(!ss(m))return d.jsx("hr",{className:"menu-sep"},`sep-${g}`);const y=n.indexOf(m);return d.jsx(X4,{item:m,gutter:p,cursor:y===r,onEnter:()=>o(y)},m.id)})})}function X4({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:Ue("row row-keyed",e.danger&&"danger",i!==void 0&&"row-tall",o&&"disabled"),"data-state":gr({cursor:n,checked:e.checked}),onMouseMove:o||n?void 0:r,onClick:()=>{o||(e.onClick(),no.close())},children:[t&&d.jsx("span",{className:"menu-check",children:e.checked&&d.jsx(Nt,{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(Zo,{k:e.key,className:"menu-key row-dim"})]})}function Pf({items:e,current:t,onPick:n,fill:r,font:o,segmented:i,quiet:l,end:c,label:u,owner:h}){const p=wn(h),m=S.useRef(null),g=Math.max(0,e.findIndex(w=>w.id===t)),y=w=>{var _,N;if(w.key!=="ArrowLeft"&&w.key!=="ArrowRight")return;w.preventDefault();const b=e.findIndex(T=>T.id===t),E=e[Wc(b,w.key==="ArrowRight"?1:-1,e.length)];E&&(n(E.id),(N=(_=m.current)==null?void 0:_.querySelectorAll('[role="tab"]')[e.indexOf(E)])==null||N.focus())};return d.jsxs("div",{className:Ue("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:y,style:i?{"--tabs-at":g,"--tabs-count":e.length}:void 0,children:e.map(w=>{const b=w.id===t;return d.jsxs("div",{className:Ue("tab",b&&!!w.trail&&"tab-trailed",w.fit&&"tab-fit",w.far&&"tab-far"),"data-state":gr({current:b}),...w.menu?p.contextMenu(w.menu):{},children:[d.jsxs("button",{type:"button",className:"tab-btn",role:"tab","aria-selected":b,tabIndex:b?0:-1,onClick:()=>n(w.id),...w.tip,...w.ariaLabel?{"aria-label":w.ariaLabel}:{},children:[w.lead,w.label]}),b&&w.trail&&d.jsx("span",{className:"tab-trail",children:w.trail})]},w.id)})}),c&&d.jsx("span",{className:"tabs-end",children:c})]})}function Ts({anchor:e="top",wide:t,foot:n,children:r}){const o=d.jsx("div",{className:Ue("view",e==="line"&&"view-anchored",t&&"view-wide"),children:r});return n?d.jsxs("div",{className:"view-stack",children:[o,n]}):o}const v_=e=>`Toyon restarts once ${e.join(", ")} ${e.length===1?"finishes":"finish"}`,Q4=(e,t)=>[...e,...t.filter(n=>!e.includes(n))];function J4(e,t,n){const r=[...t];return[...e.map(i=>{const l=r.indexOf(i);return l===-1?{name:i,dot:"idle",note:"finished"}:(r.splice(l,1),{name:i,dot:"working",note:null})}),...n.map(i=>({name:i,dot:"waiting",note:"asking you"}))]}function eD(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 tD(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:v_(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 Lm=!1;function nD(){Lm=!0}function Sc({title:e,body:t,action:n,pane:r,children:o}){return d.jsxs("div",{className:Ue("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 sb={title:"Toyon was updated",body:"This page is still running the old build. Reload to pick up the new one."};class wk extends S.Component{constructor(){super(...arguments);Dt(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(Sc,{pane:this.props.pane,title:Lm?sb.title:"Toyon hit an error",body:Lm?sb.body:n.message||String(n),action:d.jsx(ze,{variant:"outline",onClick:()=>window.location.reload(),children:"reload"})}):this.props.children}}const Pm={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.`},rD=1e3,ib={held:[],asking:[],seen:[]};async function ab(e,t,n){for(;;){await new Promise(i=>setTimeout(i,rD));const[r,o]=await Promise.all([xm(e),eE(e)]);if(r!==null&&r!==t)break;n(o??{waiting:[],asking:[]})}window.location.reload()}function b_({foreign:e}={}){return e?d.jsx(oD,{name:e}):d.jsx(sD,{})}function oD({name:e}){const t=Go(),n=t.list()[0];return d.jsx(Sc,{title:`Toyon on ${e} was updated`,body:Pm.foreign(e),action:n&&d.jsxs(ze,{variant:"outline",onClick:()=>t.activate(n.origin),children:["back to ",t.displayName(n.origin)]})})}function sD(){const e=Wr(),[t,n]=S.useState(!0),[r,o]=S.useState(null),[i,l]=S.useState(ib),c=S.useRef(null),u=S.useCallback(g=>l(y=>({held:g.waiting,asking:g.asking,seen:Q4(y.seen,g.waiting)})),[]),h=S.useCallback(async g=>{n(!0),o(null);const y=c.current??{pid:await xm(e)},w=await yM(e,g);if(w){n(c.current!==null),o(w);return}g&&l(ib),!c.current&&(c.current=y,ab(e,y.pid,u))},[u,e]);S.useEffect(()=>{let g=!0;return(async()=>{const[y,w]=await Promise.all([xm(e),eE(e)]);if(!(!g||c.current)){if(w===null){h(!1);return}c.current={pid:y},u(w),ab(e,y,u)}})(),()=>{g=!1}},[u,h,e]);const p=t&&i.held.length>0,m=p?J4(i.seen,i.held,i.asking):[];return d.jsx(Sc,{title:Pm.title,body:r??(p?eD(i.held.length,i.seen.length):Pm.waiting),action:p?d.jsx(ze,{variant:"outline",onClick:()=>void h(!0),children:"restart now"}):d.jsx(ze,{variant:"outline",busy:t,onClick:()=>void h(!1),children:"restart"}),children:m.length>0&&d.jsx("ul",{className:"crash-list",children:m.map((g,y)=>d.jsxs("li",{className:Ue("crash-row",g.dot!=="working"&&"row-dim"),children:[d.jsx("span",{className:Ue("dot",g.dot)}),d.jsx("span",{className:"crash-row-name",children:g.name}),g.note&&d.jsx("span",{className:"crash-row-note",children:g.note})]},y))})})}const lb={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"},iD={probing:e=>`connecting to ${e}…`,down:e=>`Toyon on ${e} is not answering.
108
+ 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.
109
+ a proxy, VPN or browser extension is the usual cause`,unauthorized:e=>`this page's token for ${e} is not the one running there.
110
+ forget ${e} here and pair it again`},aD="no access token for this address.\nrun `toyon` in your repo, or open the full URL\n(with #token=…) printed in ~/.toyon/daemon.log";function x_(e){return!e.connected&&(!e.heard||e.connectFailure)?e.machine?iD[e.connectFailure??"probing"](e.machine):e.hasToken?lb[e.connectFailure??"probing"]??lb.probing:aD:e.title===null?e.heard?`nothing open yet.
111
+ press ${e.projectChord} to open a project, or type a name there to start a new one`:"":null}function lD(e){const t=x_(e);return t!==null?t:e.needsSetup&&e.busy?`building in ${e.title}; the preview appears once it starts`:e.needsSetup&&e.treeEmpty?`${e.title} is empty so far; say what to build`:e.treeEmpty&&e.landsFrom?`nothing runs on main until ${e.landsFrom} lands`:null}const an={post:(e,t)=>{},broadcast:e=>{}};function Nc(e,t,n,r){const o=t===r;an.post(e,o?{type:"pick-cancel"}:{type:"pick-start",verb:r}),n({a:"set-picking",v:o?!1:r})}function E_(e){return[{id:"copy-sha",label:`copy ${e.short}`,onClick:()=>on(e.sha)},{id:"copy-subject",label:"copy subject",onClick:()=>on(e.subject)}]}function Df(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}function zf(e){return e!=null&&e.config.profiles?Object.keys(e.config.profiles):[]}function __(e,t){const n=zf(t);if(n.length!==0)return e.profile&&n.includes(e.profile)?e.profile:t==null?void 0:t.config.defaultProfile}const cD=e=>$d(Fi((e==null?void 0:e.config)??{}),e==null?void 0:e.defaultBranch).toLowerCase();function oi(e,t,n){t({a:"shipping",id:n.worktreeId,op:n.t}),e==null||e.send(n)}const S_=e=>e.dirty===void 0||e.ahead===void 0||e.dirty>0||e.ahead>0;function Hi(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 N_(e,t,n){t({a:"hold-unread",id:n}),e==null||e.send({t:"mark-unread",worktreeId:n})}function yk(e,t){return{rename(n){if(!Gx(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()}))},pickVariant(n){const r=n.worktree.variant;if(!r)return;const o=r.of-1;window.confirm(`Keep "${n.worktree.title}" and archive ${o} sibling variant(s)? Their directories and branches go; their chats and changes are kept.`)&&(e==null||e.send({t:"pick-variant",worktreeId:n.worktree.id}))},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?
112
+
113
+ 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(!wg(n.worktree))return;if(!S_(n))return Hi(e,t,[n.worktree.id]);window.confirm(`Archive worktree "${n.worktree.title}"?
114
+
115
+ 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.`)&&Hi(e,t,[n.worktree.id])}}}function T_(e,t,n,{sock:r,dispatch:o},i){var B,$;const l=e.worktree.id,c=yk(r,o),u=[],h=[],p=[],m=[],g=[],y=[],w=[],b=[];zc(e)&&u.push({id:"stop",label:"stop agent",onClick:()=>r==null?void 0:r.send({t:"stop-agent",worktreeId:l})});const E=!n.shipping[l],_=n.frame==="phone";((e.dirty??0)>0||(e.ahead??0)>0||!_&&!n.layout.changes)&&h.push({id:"changes",label:`view changes${(e.dirty??0)>0?` (${e.dirty})`:""}`,onClick:()=>{o({a:"activate",id:l}),_?o({a:"screen",to:"changes"}):n.layout.changes||o({a:"toggle-changes"})}}),_||h.push({id:"terminal",label:"open terminal",onClick:()=>{o({a:"activate",id:l}),o({a:"focus-terminal"})}}),h.push(...Rf(()=>r==null?void 0:r.send({t:"reveal",worktreeId:l}),i.hostname)),_||p.push({id:"copy-path",label:"copy path",onClick:()=>on(e.path)}),p.push({id:"copy-branch",label:"copy branch name",onClick:()=>on(e.worktree.branch)});const{transcript:N,sessionId:T}=e;!_&&N&&!$r(e.worktree)&&p.push({id:"copy-transcript",label:"copy transcript path",onClick:()=>on(N)}),!_&&T&&p.push({id:"copy-session",label:"copy session id",onClick:()=>on(T)});const R=__(e.worktree,t);for(const C of Lc(e.worktree)?[]:zf(t))m.push({id:`profile:${C}`,label:`run with ${C}`,checked:C===R,onClick:()=>c.setProfile(e,C)});if(!Ki(e.worktree)&&((B=e.borrowed)!=null&&B.length)&&m.push({id:"own-procs",label:`run ${e.borrowed.join(", ")} here`,detail:"on main now",onClick:()=>c.ownProcs(e)}),!Ki(e.worktree)&&(($=e.worktree.owns)!=null&&$.length)&&m.push({id:"share-procs",label:`use main's ${e.worktree.owns.join(", ")}…`,detail:"runs here now",danger:!0,onClick:()=>c.shareProcs(e)}),Gx(e.worktree)&&g.push({id:"rename",label:"rename…",onClick:()=>c.rename(e)}),e.worktree.variant&&g.push({id:"keep",label:"keep this variant…",onClick:()=>c.pickVariant(e)}),i.graft&&vd(e.worktree)){const C=i.graft;g.push({id:"graft",label:"graft with…",onClick:()=>C(l)})}g.push({id:"unread",label:"mark as unread",key:Lt("mark-unread"),disabled:e.unseen?"already unread":void 0,onClick:()=>N_(r,o,l)});const O=E?void 0:"waiting on the one in progress";if(e.syncQueued)y.push({id:"sync",label:"call off the sync from main",onClick:()=>r==null?void 0:r.send({t:"unqueue-sync",worktreeId:l})});else if(df(e)&&(e.behind??0)>0){const C=(e.agent==="working"||e.agent==="waiting")&&(e.dirty??0)>0;y.push({id:"sync",label:`sync from main${C?" after the turn":""} (${e.behind} behind)`,disabled:O,onClick:()=>oi(r,o,{t:"sync-main",worktreeId:l})})}return Di(e.worktree)&&y.push({id:"land",label:"land",detail:cD(t),disabled:O,onClick:()=>oi(r,o,{t:"land",worktreeId:l})}),e.worktree.kind==="worktree"&&w.push({id:"handoff",label:"continue in another project…",sub:!0,disabled:n.repos.length<2?"open another project first":void 0,onClick:()=>o({a:"open",overlay:{kind:"handoff",worktreeId:l}})}),wg(e.worktree)&&b.push({id:"archive",label:S_(e)?"archive…":"archive",key:Lt("wt-archive"),danger:!0,onClick:()=>c.archive(e)}),zn([u,h,p,m,g,y,w,b])}function uD(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 df(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(...Rf(()=>n==null?void 0:n.send({t:"reveal",worktreeId:e.id}),o)),zn([c,i,l?[]:[{id:"copy-path",label:"copy path",onClick:()=>on(e.path)}]])}const dD={sm:"",md:"field-md",lg:"field-lg"};function j_({size:e="sm",font:t,bare:n,rule:r,className:o}){const i=t??(e==="lg"?"ui":"mono");return Ue("field",dD[e],i==="ui"&&"field-ui",i==="lead"&&"field-lead",n&&"field-bare",r&&"field-rule",o)}const Eo=S.forwardRef(function({size:t,font:n,bare:r,rule:o,className:i,...l},c){return d.jsx("input",{ref:c,className:j_({size:t,font:n,bare:r,rule:o,className:i}),...l})}),Tc=S.forwardRef(function({size:t,font:n,bare:r,rule:o,className:i,...l},c){return d.jsx("textarea",{ref:c,className:j_({size:t,font:n,bare:r,rule:o,className:i}),...l})});function fD(e,t){const n=t??0;return n===0?null:`${n} behind ${e}`}function C_(e){const t=new Date(e);return`${String(t.getHours()).padStart(2,"0")}:${String(t.getMinutes()).padStart(2,"0")}`}function A_(e,t){if(t.fetchFailed)return`could not reach origin${t.fetchedAt?` since ${C_(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 hD(e){return e.stale!=="diverged"}const Hr=e=>/[.!?…]$/.test(e)?e:`${e}.`,cb=160;function vk(e){const t=e.replace(/\s+/g," ").trim();if(t.length<=cb)return t;const n=t.slice(0,cb);return`${n.slice(0,Math.max(n.lastIndexOf(" "),1)).trimEnd()}…`}function I_(e){return e.subjects.length?vk(e.subjects.join("; ")):void 0}function bk(e){const t=I_(e);if(t)return e.pr===void 0?t:vk(`PR #${e.pr}: ${t}`)}function xk(e,t=3){const n=[];for(const l of e??[]){const c=bk(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?Hr(c):`${Ek(Bo(to(l)))}: ${Hr(c)}`);return o>0?[`${o} earlier landing${o===1?"":"s"}.`,...i]:i}function vs(e){const t=`PR #${e.number}`;if(e.state==="merged")return`${t} merged.`;if(e.state==="closed")return`${t} was closed without merging.`;if(e.automerge){const n=e.review==="review_required"?"it is approved and checks pass":"checks pass";return`${t} open; GitHub merges it when ${n}.`}return e.mergeable===!1?`${t} open; it conflicts with main.`:e.review==="changes_requested"?`${t} open; changes requested.`:e.checks==="fail"?`${t} open; checks failed.`:e.checks==="pending"?`${t} open; checks running.`:e.review==="review_required"?`${t} open; waiting on review.`:e.review==="approved"?`${t} approved${e.checks==="pass"?", checks pass":""}.`:`${t} open and ready to merge.`}function R_(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 Ek=e=>`${e.charAt(0).toUpperCase()}${e.slice(1)}`;function _k(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 $_(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, then write":"Write"} the recap and the commit message.`}function pD(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 ad(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(`
116
+ `).find(c=>c.trim()))==null?void 0:i.trim();return`Check failed${l?`: ${Hr(l)}`:"."}`}return _k(e,t,n)==="unasked"?pD(r):null}function ub(e,t){const n=mD(e,t);return n?Hr(Ek(n)):""}function mD(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 O_=e=>/^[A-Z][a-z]+(\s|$)/.test(e)?`${e.charAt(0).toLowerCase()}${e.slice(1)}`:e;function gD(e,t){const n=t??0;return n>0?`${n} behind ${e}; land takes it in first.`:""}function kD(e){return e>0?Hr(Ek(`${e} ${e===1?"file":"files"} changed`)):""}function wD(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: ${Hr(O_(e.why))}`:null}function ld(e){return Hr(e)}const Bo=e=>e==="now"?"just now":`${e} ago`;function yD(e,t,n){switch(e){case"asking":return`Waiting on you${n==="now"?"":` for ${n}`}${t.ask?`: ${Hr(t.ask)}`:"."}`;case"failed":return t.auth?`Stopped ${Bo(n)}: not logged in.`:t.error?`Failed ${Bo(n)}: ${Hr(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 Sk(e){var n;const t=(n=e.recap)==null?void 0:n.text;return t?Hr(t):yD(e.end,e.facts,to(e.at))}function vD(e){var n;const t=(n=e.recap)==null?void 0:n.text;return t?`Last stop, ${Bo(to(e.at))}: ${Hr(O_(t))}`:void 0}function jc(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 Nk(e){return(e==null?void 0:e.status)==="running"||(e==null?void 0:e.status)==="detached"}function M_(e){const t=e&&e.status!=="terminated"?e.since:void 0,n=rk(t,ok);return t!==void 0&&n===t?e:void 0}function L_(e,t){const n=e.stage?[e.stage]:[];switch(e.status){case"queued":return[...n,"queued"];case"running":return[...n,`${Ga(t)} of ${iC(e.timeoutMs)}`];case"detached":return[...n,Ga(t),"detached"];case"terminated":return[e.why??"stopped"]}}function Dm(e,t,n){return[e,...L_(t,n)].join(" · ")}const P_={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 D_(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 bD({active:e,ahead:t,behind:n,unpushed:r,dirty:o}){var Jt,xt,kt;const i=ct(),l=lt(),c=wn("changes"),u=xn(e)?e.worktree:null,h=e.id,p=P(ot=>{var dt;return(dt=ot.shipping[h])==null?void 0:dt.op}),m=P(ot=>{var dt;return(dt=ot.shipping[h])==null?void 0:dt.step}),g=rk(m,ok),y=jc(e,"commit"),w=jc(e,"check"),b=p?y:w,E=M_(b),_=il(Nk(E)?E==null?void 0:E.since:void 0),[N,T]=S.useState("");St([h],()=>T(""));const R=S.useRef(null),O=(Jt=u==null?void 0:u.landing)!=null&&Jt.subject?u.landing.body?`${u.landing.subject}
117
+
118
+ ${u.landing.body}`:u.landing.subject:null,B=()=>{N===""&&O&&T(O);const ot=R.current;ot&&(ot.focus(),requestAnimationFrame(()=>ot.setSelectionRange(ot.value.length,ot.value.length)))},$=P(ot=>ot.editCommit);St([$],()=>{$&&B()});const C=N.trim()||void 0,j=P(ot=>{var dt;return!!((dt=ot.agents.find(Tt=>Tt.id===((u==null?void 0:u.agent)??ot.defaultAgent)))!=null&&dt.quick)}),D=u==null?void 0:u.landing,z=C?null:_k(D,o?1:0,j),X=(D==null?void 0:D.check)==="pending",ae=!!(D!=null&&D.stale),A=()=>{p||i==null||i.send({t:"judge",worktreeId:h})},de=()=>{p||!C&&!O||(oi(i,l,{t:"commit",worktreeId:h,message:C??O??""}),T(""))},ue=()=>{p||oi(i,l,{t:"land",worktreeId:h,...C?{message:C}:{}})},J=((xt=u==null?void 0:u.landing)==null?void 0:xt.check)==="fail",M=u==null?void 0:u.pr,oe=(M==null?void 0:M.state)==="open",ne=oe&&(o||r>0),H=X||ae||!!z,se=!!u&&Di(u)&&(o||t>0)&&!J&&!oe&&!H,ie=!!u&&ne&&!J&&!H,he=!!u&&Di(u)&&!X&&(ae||z==="unwritten"||z==="unanswered")&&e.agent!=="working"&&e.agent!=="waiting",ge=P(ot=>ot.repos.find(dt=>dt.id===e.repoId)??null),Ie=$d(Fi((ge==null?void 0:ge.config)??{}),ge==null?void 0:ge.defaultBranch),ke=ge?ff(ge):"main",Q=df(e)?fD(ke,n):null,we=e.agent==="working"||e.agent==="waiting",te=o&&!u?"commit or discard the changes here first":void 0,Z=!!e.syncQueued,je=Z?"Runs once the turn ends, the uncommitted changes kept. Press again to call it off":o&&we?`Merge ${ke} into this worktree once the turn ends, uncommitted changes kept`:`Merge ${ke} into this worktree${o?", uncommitted changes kept":""}`,He=oe&&!ne&&R_(M),Fe=se?"land":ie?"update":He?"merge":(M==null?void 0:M.state)==="merged"?"pull":"land",We=p==="commit"?g??"commit":p==="land"?g?`${Fe}: ${g}`:Fe:null,Ht=b?E?L_(E,_).join(" · "):null:X&&!p?"writing the message":null,ut=E&&(E.status==="running"||E.status==="detached")?E:null,vn=ut&&d.jsx(Pt,{icon:"stop",tone:"danger",label:D_(ut.kind),onClick:()=>i==null?void 0:i.send({t:"run-stop",worktreeId:h,kind:ut.kind})});return d.jsxs("div",{className:"composer commit-box",children:[u&&o&&d.jsx("div",{className:"composer-field",children:d.jsx(Tc,{size:"lg",bare:!0,ref:R,value:N,onChange:ot=>T(ot.target.value),onKeyDown:ot=>{ot.key==="Enter"&&(ot.metaKey||ot.ctrlKey)?(ot.preventDefault(),de()):ot.key==="Tab"&&!ot.shiftKey&&N===""&&O&&(ot.preventDefault(),B())},placeholder:O??(z==="unanswered"?"no message yet: the model did not answer. Check again, or write one here":z==="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(Nt,{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 ${ke}`,children:[t," ahead"]}),(u==null?void 0:u.landed)&&d.jsxs("span",{className:"badge-landed","data-tip":`Merged into ${ke}`,children:[d.jsx(Nt,{name:"check",className:"icon-inline"})," landed"]})]}),d.jsxs("span",{className:"commit-acts",children:[We?d.jsx("span",{className:"live-text",children:We}):d.jsxs(d.Fragment,{children:[u&&o&&d.jsx(ze,{disabled:!C&&!O||!!p,onClick:de,...Ut(O&&!C?"Commit with the suggested message":"git add -A && git commit","⌘⏎"),children:"commit"}),u&&se&&d.jsx(ze,{tone:"primary",disabled:!!p,"data-tip":Ie,onClick:ue,children:"land"}),he&&d.jsx(ze,{tone:"primary",disabled:!!p,"data-tip":$_(D,!!((kt=ge==null?void 0:ge.config.check)!=null&&kt.trim()),z),onClick:A,children:"check"}),X&&d.jsx("span",{className:"live-text",children:"check"}),ie&&M&&d.jsx(ze,{tone:"primary",disabled:!!p,"data-tip":`Commit, take ${ke} in and push the branch; PR #${M.number} takes the new commits`,onClick:ue,children:"update"}),He&&d.jsx(ze,{tone:"primary",disabled:!!p,"data-tip":"Merge the PR now, by the method the repo allows",onClick:ue,children:"merge"})]}),M&&d.jsxs(ze,{"data-tip":`Open PR #${M.number} on GitHub`,onClick:()=>window.open(M.url,"_blank"),...c.contextMenu(()=>[{id:"open-pr",label:"open on GitHub",onClick:()=>window.open(M.url,"_blank")},{id:"copy-link",label:"copy link",onClick:()=>on(M.url)}]),children:["view ",d.jsx(Nt,{name:"external",className:"icon-inline"})]})]})]}),(Q||Ht)&&d.jsxs("div",{className:"composer-notes",children:[Ht&&d.jsxs("div",{className:"hint composer-note","data-tip":E?P_[E.status]:void 0,children:[d.jsx("span",{children:Ht}),vn]}),Q&&d.jsxs("div",{className:"hint composer-note",children:[d.jsx("span",{children:Q}),p==="sync-main"?d.jsx("span",{className:"live-text",children:g?`sync: ${g}`:"sync"}):d.jsx(ze,{variant:"outline",on:Z,disabled:!!p||!!te,"data-tip":te??je,onClick:()=>Z?i==null?void 0:i.send({t:"unqueue-sync",worktreeId:h}):oi(i,l,{t:"sync-main",worktreeId:h}),children:Z?"sync after the turn":"sync"})]})]})]})}const xD=S.memo(function({c:t,id:n,selected:r,onToggle:o}){const i=wn("changes");return d.jsxs("button",{className:"row row-sm log-row row-edge",id:n,"data-state":gr({current:r,cursor:r}),role:"option","aria-selected":r,tabIndex:-1,onClick:()=>o(t.sha),...i.contextMenu(()=>E_(t)),"data-tip":`${t.subject}
119
+ ${t.short} · ${t.author}`,"data-tip-placement":"follow",children:[d.jsx("span",{className:"subject",children:t.subject}),d.jsx("span",{className:"at row-dim",children:to(t.at)})]})});function ED(e,t){const n=So(e,t);if(!n||!xn(n))return"take this worktree over to change files here";if(Ki(n.worktree))return"start a worktree to change files"}function z_(e,t,n,r){return{id:"new-file",label:"new file…",disabled:ED(e.getState(),t),onClick:()=>r(n)}}function _D(e,t,n,r){const{worktreeId:o,dir:i,path:l,folder:c,newIn:u}=e,h=Mf(t.getState(),o)?void 0:"take this worktree over to talk to an agent here",p=hk(l,c),m=[...c?[]:[{id:"open",label:"open",onClick:()=>er(n,{worktreeId:o,path:l,view:qi(l)})}],{id:"add-to-chat",label:"add to chat",disabled:h,onClick:()=>n_(t,o,l,c)}],g=[z_(t,o,u,r),{id:"ask-rename",label:"ask the agent to rename…",disabled:h,onClick:()=>q0(t,o,`Rename ${p} to `)},{id:"ask-delete",label:"ask the agent to delete…",disabled:h,onClick:()=>q0(t,o,`Delete ${p} and update whatever still uses it`)}],y=[...Rf(()=>{var w;return(w=n.sock)==null?void 0:w.send({t:"reveal",worktreeId:o,path:l})},as(n.sock)),{id:"copy-path",label:"copy path",onClick:()=>on(`${i}/${l}`)},{id:"copy-relative-path",label:"copy relative path",onClick:()=>on(l)}];return zn([m,y,g])}function SD(e,t,n,r){return zn([[z_(t,e.worktreeId,"",r)],Gi(e.dir,()=>{var o;return(o=n.sock)==null?void 0:o.send({t:"reveal",worktreeId:e.worktreeId})},as(n.sock))])}const cd=[],ND=[],db=new Set,fb=e=>`tree-row-${e}`;function TD({worktreeId:e,dir:t,openPath:n,openRef:r,rootRef:o}){const i=Zn(),l=ct(),c=lt(),u=It(e,"files"),h=It(e,"submodules"),p=It(e,"ignored"),m=It(e,"git"),g=(m==null?void 0:m.files)??ND;St([e,m,l],()=>$f(e,i.getState(),{sock:l,dispatch:c}));const y=P(te=>{var Z;return((Z=te.dragFiles)==null?void 0:Z.at)==="tree"&&te.dragFiles.worktreeId===e?te.dragFiles.dir:null}),w=P(te=>te.treeOpen[e]??cd),b=S.useMemo(()=>new Set(w),[w]),[E,_]=S.useState(db);St([e,n,r],()=>_(n&&!r?new Set(Ud(n).filter(te=>!b.has(te))):db));const N=S.useCallback(te=>b.has(te)||E.has(te),[b,E]),T=S.useCallback(te=>{const Z=b.has(te)||E.has(te);if(Z&&E.has(te)){const je=new Set(E);je.delete(te),_(je)}c({a:"tree-folder",worktreeId:e,path:te,open:!Z})},[b,E,e,c]),R=S.useMemo(()=>XP(u??cd,h??cd,p??cd),[u,h,p]),O=S.useMemo(()=>QP(R,N),[R,N]),B=S.useMemo(()=>e4(g),[g]),$=P(te=>te.treeReveal),C=$&&$.worktreeId===e?$:null,[j,D]=S.useState(()=>(C==null?void 0:C.path)??null),[z,X]=S.useState({worktreeId:e,linked:C});(z.worktreeId!==e||z.linked!==C)&&(X({worktreeId:e,linked:C}),D((C==null?void 0:C.path)??null));const[ae,A]=S.useState(!1),de=S.useMemo(()=>{if(j===null)return-1;const te=O.findIndex(Z=>Z.path===j);if(te>=0)return te;for(const Z of Ud(j).reverse()){const je=O.findIndex(He=>He.path===Z);if(je>=0)return je}return-1},[O,j]);St([de,ae],()=>{var te,Z;ae&&((Z=(te=o.current)==null?void 0:te.querySelector('[data-state~="cursor"]'))==null||Z.scrollIntoView({block:"nearest"}))});const ue=S.useCallback((te,Z)=>er({dispatch:c},{worktreeId:e,path:te,view:qi(te),focus:Z}),[e,l,c]),J=S.useCallback(te=>{D(te.path),te.kind==="folder"?T(te.path):te.kind==="file"&&ue(te.path,!1)},[T,ue]),M=te=>{var He;if(te.metaKey||te.ctrlKey||te.altKey)return;const Z=O[de],je=Fe=>{const Pe=O[Fe];Pe&&(D(Pe.path),Pe.kind==="file"&&ue(Pe.path,!1))};switch(te.key){case"ArrowDown":case"ArrowUp":te.preventDefault(),je(de<0?0:Wc(de,te.key==="ArrowDown"?1:-1,O.length));return;case" ":te.preventDefault(),(Z==null?void 0:Z.kind)==="file"?ue(Z.path,!1):(Z==null?void 0:Z.kind)==="folder"&&T(Z.path);return;case"Enter":te.preventDefault(),(Z==null?void 0:Z.kind)==="file"?ue(Z.path,!0):(Z==null?void 0:Z.kind)==="folder"&&T(Z.path);return;case"ArrowRight":case"ArrowLeft":{te.preventDefault();const Fe=O.map(We=>We.kind==="folder"?{depth:We.depth,open:We.open}:{depth:We.depth}),Pe=Df(Fe,de,te.key);(Pe==null?void 0:Pe.do)==="to"?je(Pe.at):Pe&&Z&&T(Z.path);return}case"Escape":te.stopPropagation(),n!==null?c({a:"close-editor"}):(He=document.activeElement)==null||He.blur();return}if(te.key.length===1){const Fe=k_(O.map(Pe=>Pe.name),de,te.key);Fe>=0&&(te.preventDefault(),je(Fe))}},[oe,ne]=S.useState(null),H=S.useRef(0),se=S.useCallback(te=>{te&&!N(te)&&T(te),H.current++,ne({dir:te,error:null,busy:!1})},[N,T]),ie=S.useCallback(()=>{H.current++,ne(null)},[]),he=S.useCallback(te=>{if(!oe||oe.busy)return;const Z=JP(oe.dir,te);if("error"in Z){ne({...oe,error:Z.error});return}const je=++H.current;ne({...oe,error:null,busy:!0}),XE({sock:l,dispatch:c},{worktreeId:e,path:Z.path}).then(He=>{He===null&&D(Z.path),je===H.current&&ne(He===null?null:{...oe,error:He,busy:!1})})},[oe,e,l,c]),ge=wn("tree"),Ie=S.useCallback(te=>_D({worktreeId:e,dir:t,path:te.path,folder:te.kind!=="file",newIn:te.kind==="folder"||te.kind==="ignored"?te.path:r_(te.path)},i,{sock:l,dispatch:c},se),[e,t,i,l,c,se]),ke=S.useCallback((te,Z)=>{te.kind==="file"&&an.post(e,Z?{type:"highlight-file",path:te.path,ranges:null}:{type:"highlight-clear"})},[e]),Q=S.useCallback((te,Z)=>{Z.dataTransfer.setData(i_,te.path),Z.dataTransfer.setData("text/plain",te.path),Z.dataTransfer.effectAllowed="copy",g4({worktreeId:e,path:te.path,folder:te.kind!=="file"})},[e]),we=S.useCallback(()=>a_(i),[i]);return d.jsx("div",{className:Ue("tree",y===""&&"drop-over"),role:"tree","aria-label":"files","data-worktree":e,"aria-activedescendant":ae&&de>=0?fb(de):void 0,tabIndex:0,ref:o,onKeyDown:M,onFocus:()=>{var te;A(!0),j===null&&D(n&&O.some(Z=>Z.path===n)?n:((te=O[0])==null?void 0:te.path)??null)},onBlur:te=>!te.currentTarget.contains(te.relatedTarget)&&A(!1),onMouseDown:te=>{if(te.button!==0)return;const Z=te.target.closest("[data-path]");(Z==null?void 0:Z.dataset.path)!==void 0&&D(Z.dataset.path)},...ge.contextMenu(te=>{const Z=O[de];return te==="keyboard"&&Z?Ie(Z):SD({worktreeId:e,dir:t},i,{sock:l},se)}),children:u===void 0?d.jsx("div",{className:"empty",children:"listing files…"}):O.length===0&&!oe?d.jsx("div",{className:"empty",children:"no files"}):jD(O.map((te,Z)=>d.jsx(AD,{row:te,id:fb(Z),status:B.files.get(te.path),changedInside:te.kind!=="file"&&B.folders.has(te.path),current:ae?Z===de:!r&&te.path===n,cursor:ae&&Z===de,dropOver:y===te.path,onPress:J,menu:Ie,onHover:ke,onDragStart:Q,onDragEnd:we},te.path)),oe&&(()=>{var Z;const te=oe.dir===""?-1:O.findIndex(je=>je.path===oe.dir);return{at:te,node:d.jsx(CD,{depth:te>=0?(((Z=O[te])==null?void 0:Z.depth)??0)+1:0,error:oe.error,onSubmit:he,onCancel:ie},"new-file")}})())})}function jD(e,t){return t?[...e.slice(0,t.at+1),t.node,...e.slice(t.at+1)]:e}function CD({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(Eo,{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 AD=S.memo(function({row:t,id:n,status:r,changedInside:o,current:i,cursor:l,dropOver:c,onPress:u,menu:h,onHover:p,onDragStart:m,onDragEnd:g}){const y=wn("tree"),w=t.kind==="submodule",b=w?"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:Ue("row row-sm tree-row row-rails row-edge",c&&"drop-over"),"data-state":gr({current:i,cursor:l}),"data-kind":t.kind,"data-path":t.path,style:{"--tree-depth":t.depth},draggable:!w,onDragStart:E=>m(t,E),onDragEnd:g,onClick:()=>u(t),onMouseEnter:()=>p(t,!0),onMouseLeave:()=>p(t,!1),...y.contextMenu(()=>h(t)),...b?Ut(b):{},children:[d.jsx("span",{className:"tree-caret row-dim",children:t.kind==="folder"&&d.jsx(Nt,{name:"caret",className:Ue("icon-inline disc-caret",!t.open&&"shut")})}),d.jsx("span",{className:Ue("tree-name",(w||t.ignored)&&"row-dim"),children:t.name}),r?d.jsx("span",{className:`xy ${Wg(r.xy)}`,children:Kg(r.xy)}):o&&d.jsx("span",{className:"dot tree-changed"})]})});function F_({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 ud=S.memo(function({f:t,id:n,active:r,selected:o,checking:i=!1,checked:l=!1,onOpen:c,onCheck:u,menu:h,onHover:p}){const m=wn("changes"),{name:g,dir:y}=eL(t.path);return d.jsxs("button",{className:"row row-sm git-file row-edge",id:n,"data-state":gr({current:r,cursor:o,checked:l}),role:"option","aria-selected":o,tabIndex:-1,onClick:w=>u&&(i||w.shiftKey)?u(t.path):c(t.path),...m.contextMenu(()=>h(t.path)),onMouseEnter:()=>p(t.path,!0),onMouseLeave:()=>p(t.path,!1),children:[i&&d.jsx("input",{type:"checkbox",className:"changes-check",checked:l,readOnly:!0,tabIndex:-1}),d.jsx("span",{className:`xy ${Wg(t.xy)}`,children:Kg(t.xy)}),d.jsxs("span",{className:"path","data-tip":y?t.path:void 0,children:[d.jsx("span",{className:"name",children:g}),y&&d.jsx("span",{className:"dir row-dim",children:y})]}),d.jsx(F_,{f:t})]})}),ID={added:"A",changed:"M",removed:"D"},RD={added:"added",changed:"",removed:"deleted"},$D=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":gr({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 ${RD[i.change]}`,children:ID[i.change]}),d.jsx("span",{className:"name",children:i.name})]},l))}),hb=new Set(["test","tests","__tests__","spec","e2e","__snapshots__","__mocks__","fixtures","testdata"]),OD=/([._-]tests?\.[^.]+$)|([._]specs?\.[^.]+$)|(^tests?[._-])|(^conftest\.py$)|(\.snap$)|([a-z0-9](Tests?|Spec)\.[^.]+$)/;function Zd(e){const t=(e.endsWith("/")?e.slice(0,-1):e).split("/"),n=t.pop()??"";return e.endsWith("/")&&hb.has(n.toLowerCase())?!0:t.some(r=>hb.has(r.toLowerCase()))||OD.test(n)}function dd(e){const t=e.filter(n=>!Zd(n.path));return t.length===0||t.length===e.length?{files:e,source:t.length}:{files:[...t,...e.filter(n=>Zd(n.path))],source:t.length}}const zm="(?<q>[\"'`])(?<name>(?:\\\\.|(?!\\k<q>).)*)\\k<q>",pb={tests:[new RegExp(`^\\s*(?:test|it)(?:\\.(?!each\\b)\\w+)*(?:\\.each\\(.*\\))?\\(\\s*${zm}`)],groups:[new RegExp(`^\\s*describe(?:\\.(?!each\\b)\\w+)*(?:\\.each\\(.*\\))?\\(\\s*${zm}`)]},MD={js:pb,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*${zm}`),/^\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*\(/,...pb.tests]}},LD={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"},PD=3,DD=/^\s*(?:[)}\]]|end\b)/,Fp=e=>e.length-e.trimStart().length;function mb(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 gb(e,t){const n=t.split(`
120
+ `),r=[],o=[];let i=Number.NEGATIVE_INFINITY;return n.forEach((l,c)=>{var g,y,w;if(l.trim()==="")return;const u=Fp(l);for(;o.length>0&&(((g=o.at(-1))==null?void 0:g.indent)??0)>=u;)o.pop();(y=e.mark)!=null&&y.test(l)&&(i=c);const p=!e.mark||c-i<=PD?mb(l,e.tests):null,m=p??mb(l,e.groups);if(m!==null){if(p!==null){i=Number.NEGATIVE_INFINITY;let b=c+1;for(;b<n.length&&(((w=n[b])==null?void 0:w.trim())===""||Fp(n[b]??"")>u);)b++;b<n.length&&Fp(n[b]??"")===u&&DD.test(n[b]??"")&&b++;const E=n.slice(c,b).map(_=>_.trim()).join(`
121
+ `).trim();r.push({group:o.map(_=>_.name),name:m,line:c,end:b,body:E})}o.push({indent:u,name:m})}}),r}function kb(e){const t=new Map;for(const n of e){const r=[...n.group,n.name].join(`
122
+ `);let o=0;for(;t.has(`${r}
123
+ ${o}`);)o++;t.set(`${r}
124
+ ${o}`,n)}return t}function zD(e,t,n){const r=MD[LD[e.slice(e.lastIndexOf(".")+1).toLowerCase()]??""];if(!r)return[];const o=kb(gb(r,t)),i=kb(gb(r,n)),l=[];for(const[p,m]of i){const g=o.get(p);(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(`
125
+ `).length;let u=1;for(const[p,m]of o){const g=i.get(p);g?u=Math.min(g.end+1,c):l.push({name:m.name,group:m.group,change:"removed",line:u})}const h=p=>p.change==="removed"?0:1;return l.sort((p,m)=>p.line-m.line||h(p)-h(m))}const fd=[];function FD(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=to(r.at);return`${o}, last commit ${i==="now"?"just now":`${i} ago`}`}const wb='[role="option"]:not([data-sub])',yb=[];function B_({width:e,placement:t="dock"}){const n=t==="screen",r=ct(),o=lt(),i=Zn(),l=dl(),c=Xi(),u=(c==null?void 0:c.id)??l,h=Ss(),p=P(W=>W.layout.changes),m=Bc(),g=P(W=>W.focusChanges),y=It(u,"git"),w=P(W=>W.editor&&W.editor.worktreeId===u?W.editor.path:null),b=P(W=>W.editor&&W.editor.worktreeId===u?W.editor.ref??null:null),E=P(W=>W.editor&&W.editor.worktreeId===u?W.editor.since??null:null),_=(y==null?void 0:y.files)??fd,N=(y==null?void 0:y.committed)??fd,{files:T,source:R}=S.useMemo(()=>dd(_),[_]),O=N.length>0,B=cP(),{files:$,source:C}=S.useMemo(()=>dd(B?N:fd),[N,B]),j=y==null?void 0:y.turn,D=j==null?void 0:j.base,z=uP(),{files:X,source:ae}=S.useMemo(()=>dd(j&&z?j.files:fd),[j,z]),A=T.length,de=T.length+X.length,ue=P(W=>W.editor&&W.editor.worktreeId===u?W.editor.disk:null),J=S.useMemo(()=>w!==null&&ue&&Zd(w)?zD(w,ue.before,ue.after):yb,[w,ue]),[M,oe]=S.useState(!1);St([w,b,E],()=>oe(!1));const ne=R>0?T.length-R:0,H=C>0?$.length-C:0,se=ae>0?X.length-ae:0,ie=T.length===0,he=S.useMemo(()=>{if(T.length===0)return;const W=T.reduce((Ct,Yt)=>Ct+(Yt.add??0),0),me=T.reduce((Ct,Yt)=>Ct+(Yt.del??0),0),Be=[W>0&&`+${W}`,me>0&&`−${me}`].filter(Boolean).join(" "),mt=`${T.length} uncommitted ${T.length===1?"file":"files"}`;return Be?`${mt}, ${Be}`:mt},[T]),ge=!!y&&ie&&!O,Ie=P(sl),ke=c!==null||Ie==="changes",Q=c!==null||Ie==="history",we=S.useCallback(W=>o({a:"changes-tab",v:W}),[o]),te=S.useRef(Ie);te.current=Ie;const Z=S.useRef(null),je=sk(),He=P(W=>{const me=hi(W,je==null?void 0:je.repoId);return me?ff(me):"main"}),Fe=It(u,"commits"),Pe=It(u,"commitFiles"),[We,Ht]=S.useState(null),ut=S.useRef(null);ut.current=We;const vn=S.useRef(null),Jt=It(u,"changedRanges"),xt=S.useCallback((W,me)=>{if(!u||c)return;if(!me){vn.current=null,an.post(u,{type:"highlight-clear"});return}vn.current=W;const Be=Jt[W];Be?an.post(u,{type:"highlight-file",path:W,ranges:y0(Be)}):r==null||r.send({t:"changed-ranges",worktreeId:u,path:W})},[u,c,Jt,r]);S.useEffect(()=>{const W=vn.current;if(!W||!u)return;const me=Jt[W];me&&an.post(u,{type:"highlight-file",path:W,ranges:y0(me)})},[Jt,u]);const kt=c&&T.length>0?(y==null?void 0:y.head)??null:null,ot=S.useCallback((W,me=!1,Be)=>u&&er({dispatch:o},{worktreeId:u,path:W,focus:me,ref:kt??void 0,since:Be}),[u,kt,r,o]),dt=S.useMemo(()=>c?T:[...T,...X,...$],[c,T,X,$]),Tt=S.useMemo(()=>{const W=[];for(const me of Fe??[])if(W.push({commit:me}),me.sha===We)for(const Be of dd(Pe[me.sha]??[]).files)W.push({commit:me,file:Be});return W},[Fe,We,Pe]),Et=S.useMemo(()=>Tt.filter(W=>!W.file&&W.commit.ahead).length,[Tt]),dn=S.useMemo(()=>Tt.findIndex(W=>!W.file&&!W.commit.ahead),[Tt]),G=c?dt.length:0,ve=(ke?dt.length:0)+(Q?Tt.length:0),tt=S.useMemo(()=>{const W=new Map;if(!c||T.length===0&&Tt.every(Be=>Be.commit.landedAt))return W;let me;return Tt.forEach((Be,mt)=>{const Ct=!!Be.commit.landedAt;Ct!==me&&(me=Ct,W.set(mt,Ct?"landed":"not landed"))}),W},[c,T,Tt]),it=S.useRef(null),[{row:ft,at:Gt},Ft]=S.useReducer((W,me)=>typeof me=="number"?{row:me,at:-1}:me,{row:0,at:-1}),[An,qn]=S.useState(!1),zt=(W,me)=>An?Nn(W):me,bn=W=>`changes-row-${W}`,[ye,Me]=S.useState(!1),[Bt,jt]=S.useState([]),fn=S.useCallback(()=>{Me(!1),jt([])},[]),K=S.useCallback(W=>{Me(!0),jt(me=>me.includes(W)?me.filter(Be=>Be!==W):[...me,W])},[]),pe=S.useMemo(()=>T.filter(W=>Bt.includes(W.path)).map(W=>W.path),[T,Bt]);St([T],()=>jt(W=>{const me=W.filter(Be=>T.some(mt=>mt.path===Be));return me.length===W.length?W:me})),St([ye],()=>{if(!ye)return;const W=me=>me.key==="Escape"&&fn();return window.addEventListener("keydown",W),()=>window.removeEventListener("keydown",W)}),St([u,Ie],()=>{Ft(0),fn()});const _e=y==null?void 0:y.head,Xe=S.useRef("");S.useEffect(()=>{if(!(Q||ge)||!u)return;const W=`${u}:${_e??""}`;Xe.current!==W&&(Xe.current=W,r==null||r.send({t:"git-log",worktreeId:u}))},[Q,ge,u,_e,r]);const qe=S.useCallback(W=>{Ht(me=>me===W?null:W),u&&!Pe[W]&&(r==null||r.send({t:"git-commit",worktreeId:u,sha:W}))},[u,Pe,r]);St([ft,Gt,An],()=>{var W,me;An&&((me=(W=it.current)==null?void 0:W.querySelector('[data-state~="cursor"]'))==null||me.scrollIntoView({block:"nearest"}))});const _t=S.useRef(-1),Le=W=>W>=A&&W<de?D:void 0,$e=W=>{var me;return((me=dt[W])==null?void 0:me.path)===w&&(E??void 0)===Le(W)&&(W<A?b===kt:!b)};_t.current=ke?dt.findIndex((W,me)=>$e(me)):-1,S.useEffect(()=>{if(!g)return;const W=te.current==="files";_t.current>=0&&Ft(_t.current);const me=requestAnimationFrame(()=>{var Be;return(Be=(W?Z:it).current)==null?void 0:Be.focus()});return()=>cancelAnimationFrame(me)},[g]);const Ge=S.useCallback((W,me=!1)=>{const Be=dt[W];Be&&(Ft(W),ot(Be.path,me,W>=A&&W<de?D:void 0),xt(Be.path,!0))},[dt,ot,xt,A,de,D]),Wt=S.useCallback((W,me=!1)=>{const Be=ut.current;u&&Be&&er({dispatch:o},{worktreeId:u,path:W,ref:Be,focus:me})},[u,r,o]),Mt=S.useCallback(W=>{const me=Tt[W-G];me&&(Ft(W),me.file&&Wt(me.file.path))},[Tt,G,Wt]),Tn=S.useCallback(W=>{const me=Tt[W-G];me&&(Ft(W),me.file?Wt(me.file.path,!0):qe(me.commit.sha))},[Tt,G,Wt,qe]),In=W=>Q&&W>=G,yn=W=>{if(w===null)return!1;if(ke&&W<dt.length)return $e(W);const me=In(W)?Tt[W-G]:void 0;return!!(me!=null&&me.file)&&b===me.commit.sha&&me.file.path===w},wr=W=>yn(W)&&!M?J:yb,gn=Gt<wr(ft).length?Gt:-1,Nn=W=>An&&ft===W&&gn<0,ur=()=>{var me,Be;const W=[];for(let mt=0;mt<ve;mt++){const Ct=In(mt)?Tt[mt-G]:void 0,Yt=Ct?(me=Ct.file)==null?void 0:me.path:(Be=dt[mt])==null?void 0:Be.path,Ln=Ct!=null&&Ct.file?1:0,tr=wr(mt);Ct&&!Ct.file?W.push({row:mt,at:-1,depth:Ln,open:Ct.commit.sha===We}):Yt!==void 0&&Zd(Yt)?W.push({row:mt,at:-1,depth:Ln,open:tr.length>0}):W.push({row:mt,at:-1,depth:Ln});for(let jo=0;jo<tr.length;jo++)W.push({row:mt,at:jo,depth:Ln+1})}return W},nn=(W,me=!1)=>{const Be=J[W];!Be||!u||w===null||er({dispatch:o},{worktreeId:u,path:w,ref:b??void 0,since:E??void 0,line:{n:Be.line},focus:me})},en=W=>wr(W).length>0&&d.jsx($D,{tests:J,id:bn(W),cursor:An&&ft===W?gn:-1,onPick:me=>{Ft({row:W,at:me}),nn(me)}}),Kt=W=>{var me;if(ye&&W.key==="Escape")W.preventDefault(),W.stopPropagation(),fn();else if(ye&&W.key===" "){W.preventDefault();const Be=ke&&ft<T.length?T[ft]:void 0;Be&&K(Be.path)}else if(W.key==="ArrowDown"&&gn+1<wr(ft).length)W.preventDefault(),Ft({row:ft,at:gn+1}),nn(gn+1);else if(W.key==="ArrowUp"&&gn>=0)W.preventDefault(),gn===0?Ft(ft):(Ft({row:ft,at:gn-1}),nn(gn-1));else if(W.key==="Enter"&&gn>=0)W.preventDefault(),nn(gn,!0);else if(W.key==="ArrowDown"||W.key==="ArrowUp"){W.preventDefault();const Be=Wc(ft,W.key==="ArrowDown"?1:-1,ve);In(Be)?Mt(Be):Ge(Be)}else if(W.key==="Enter")W.preventDefault(),In(ft)?Tn(ft):Ge(ft,!0);else if(W.key==="ArrowRight"||W.key==="ArrowLeft"){W.preventDefault();const Be=ur(),mt=Df(Be,Be.findIndex(Ln=>Ln.row===ft&&Ln.at===gn),W.key),Ct=mt&&Be[mt.at];if(!mt||!Ct)return;const Yt=In(Ct.row)?Tt[Ct.row-G]:void 0;mt.do==="to"?Ct.at>=0?(Ft({row:Ct.row,at:Ct.at}),nn(Ct.at)):Yt!=null&&Yt.file&&Ct.row>ft?Mt(Ct.row):Ft(Ct.row):Yt&&!Yt.file?qe(Yt.commit.sha):mt.do==="close"?oe(!0):yn(Ct.row)?oe(!1):Yt!=null&&Yt.file?Mt(Ct.row):Ge(Ct.row)}else W.key==="Escape"&&(W.stopPropagation(),w!==null?o({a:"close-editor"}):(me=document.activeElement)==null||me.blur())},V=c?c.id:h==null?void 0:h.worktree.id,Ee=c?c.path:h?h.worktree.path:"",Ze=c!==null,yt=S.useCallback(W=>V?xs({id:V,dir:Ee},W,{discard:!Ze,kept:Ze,ref:kt??void 0,select:Ze?void 0:K},{sock:r,dispatch:o}):[],[V,Ee,Ze,kt,K,r,o]),sn=S.useCallback(W=>V?xs({id:V,dir:Ee},W,{kept:Ze},{sock:r,dispatch:o}):[],[V,Ee,Ze,r,o]),ln=S.useCallback(W=>V?xs({id:V,dir:Ee},W,{kept:Ze,since:D},{sock:r,dispatch:o}):[],[V,Ee,Ze,D,r,o]),Vt=S.useCallback(W=>V?xs({id:V,dir:Ee},W,{ref:ut.current??void 0,kept:Ze},{sock:r,dispatch:o}):[],[V,Ee,Ze,r,o]),dr=wn("changes"),Mr=()=>{if(ke&&ft<dt.length){const me=dt[ft];return me?(ft<A?yt:ft<de?ln:sn)(me.path):[]}const W=In(ft)?Tt[ft-G]:void 0;return W?W.file?Vt(W.file.path):E_(W.commit):[]},Mn=(W,me)=>{const Be=dt.findIndex((mt,Ct)=>Ct>=W&&mt.path===me);Ft(Be),$e(Be)&&J.length>0?oe(mt=>!mt):ot(me,!1,Le(Be))},Ot=S.useRef(Mn);Ot.current=Mn;const Ce=S.useCallback(W=>Ot.current(0,W),[]),Te=S.useCallback(W=>Ot.current(A,W),[A]),ht=S.useCallback(W=>Ot.current(de,W),[de]),pt=S.useCallback(W=>{Ft(G+Tt.findIndex(me=>!me.file&&me.commit.sha===W)),qe(W)},[Tt,G,qe]),Zt=S.useCallback(W=>{Ft(G+Tt.findIndex(me=>{var Be;return((Be=me.file)==null?void 0:Be.path)===W})),W===w&&b===ut.current&&J.length>0?oe(me=>!me):Wt(W)},[Tt,G,Wt,w,b,J]),tn=S.useCallback(()=>{},[]);return d.jsxs("div",{className:Ue("changes-dock",n&&"changes-screen",!n&&(!p||m)&&"collapsed"),style:n?void 0:{width:e},children:[!c&&d.jsx(Pf,{fill:!n,quiet:n,owner:"changes-tabs",label:"changes panel",items:[{id:"files",label:d.jsx(Nt,{name:"folder",className:"icon-inline"}),fit:!0,ariaLabel:"files",tip:Ut("files",Lt("files"))},{id:"changes",label:"changes",tip:Ut("changes",Lt("changes"),{detail:he})},{id:"history",label:"history"}],current:Ie,onPick:we}),Ie==="files"&&u?d.jsx(TD,{worktreeId:u,dir:h?h.worktree.path:(je==null?void 0:je.path)??"",openPath:w,openRef:b,rootRef:Z}):d.jsxs("div",{className:Ue("changes-list",Q&&"history"),role:"listbox","aria-label":c?"kept work":Q?"commits":"changed files","aria-activedescendant":An&&ft>=0&&ft<ve?gn<0?bn(ft):`${bn(ft)}-t${gn}`:void 0,tabIndex:0,ref:it,onKeyDown:Kt,onFocus:()=>qn(!0),onMouseDown:W=>{var mt;if(W.button!==0)return;W.preventDefault();const me=W.target.closest(wb),Be=me?Array.from(W.currentTarget.querySelectorAll(wb)).indexOf(me):-1;Be>=0&&Ft(Be),(mt=it.current)==null||mt.focus()},onBlur:W=>!W.currentTarget.contains(W.relatedTarget)&&qn(!1),...dr.contextMenu(W=>W==="keyboard"?Mr():[]),children:[ke&&T.length>0&&d.jsxs(d.Fragment,{children:[(O||c)&&d.jsx("div",{className:"section-title section-row",children:"uncommitted"}),T.map((W,me)=>d.jsxs(S.Fragment,{children:[ne>0&&me===R&&d.jsx("div",{className:"section-title changes-sub",children:"tests"}),d.jsx(ud,{f:W,id:bn(me),active:zt(me,yn(me)),selected:Nn(me),checking:ye,checked:Bt.includes(W.path),onOpen:Ce,onCheck:Ze?void 0:K,menu:yt,onHover:xt}),en(me)]},`${W.xy}:${W.path}`))]}),ke&&!c&&j&&d.jsxs(d.Fragment,{children:[d.jsxs("button",{type:"button",className:"section-title section-row section-fold","aria-expanded":z,"data-tip":"What changed since your last message","data-tip-placement":"follow",onClick:()=>o({a:"toggle-turn"}),onKeyDown:W=>(W.key==="Enter"||W.key===" ")&&W.stopPropagation(),children:["last turn",d.jsx(Nt,{name:"caret",className:Ue("icon-inline disc-caret",!z&&"shut")})]}),X.map((W,me)=>d.jsxs(S.Fragment,{children:[se>0&&me===ae&&d.jsx("div",{className:"section-title changes-sub",children:"tests"}),d.jsx(ud,{f:W,id:bn(A+me),active:zt(A+me,yn(A+me)),selected:Nn(A+me),onOpen:Te,menu:ln,onHover:xt}),en(A+me)]},`t-${W.path}`))]}),ke&&!c&&O&&d.jsxs(d.Fragment,{children:[d.jsxs("button",{type:"button",className:"section-title section-row section-fold","aria-expanded":B,"data-tip":`Committed on this branch, not yet on ${He}`,"data-tip-placement":"follow",onClick:()=>o({a:"toggle-committed"}),onKeyDown:W=>(W.key==="Enter"||W.key===" ")&&W.stopPropagation(),children:["committed",d.jsx(Nt,{name:"caret",className:Ue("icon-inline disc-caret",!B&&"shut")})]}),$.map((W,me)=>d.jsxs(S.Fragment,{children:[H>0&&me===C&&d.jsx("div",{className:"section-title changes-sub",children:"tests"}),d.jsx(ud,{f:W,id:bn(de+me),active:zt(de+me,yn(de+me)),selected:Nn(de+me),onOpen:ht,menu:sn,onHover:xt}),en(de+me)]},`c-${W.path}`))]}),ke&&!c&&ge&&d.jsx("div",{className:"empty",children:FD(He,!!je&&df(je),(y==null?void 0:y.behind)??0,Fe==null?void 0:Fe[0])}),Q&&Tt.map((W,me)=>d.jsxs(S.Fragment,{children:[c&&tt.has(me)&&d.jsx("div",{className:"section-title section-row",children:tt.get(me)}),!c&&Et>0&&me===0&&d.jsx("div",{className:"section-title section-row",children:"on this branch"}),!c&&Et>0&&me===dn&&d.jsx("div",{className:"section-title section-row",children:He}),W.file?d.jsxs(d.Fragment,{children:[d.jsx(ud,{f:W.file,id:bn(G+me),active:zt(G+me,yn(G+me)),selected:Nn(G+me),onOpen:Zt,menu:Vt,onHover:tn}),en(G+me)]}):d.jsx(xD,{c:W.commit,id:bn(G+me),selected:Nn(G+me),onToggle:pt})]},W.file?`${W.commit.sha}:${W.file.path}`:W.commit.sha)),Q&&Fe===void 0&&d.jsx("div",{className:"empty",children:"reading history…"}),Q&&(Fe==null?void 0:Fe.length)===0&&T.length===0&&d.jsx("div",{className:"empty",children:"no commits yet"})]}),ye&&d.jsxs("div",{className:"changes-pick",children:[d.jsxs(ze,{size:"md",tone:"danger",disabled:pe.length===0,"data-tip":"Throw away the uncommitted changes to every checked file",onClick:()=>{!V||pe.length===0||window.confirm(QE(pe))&&(r==null||r.send({t:"discard-files",worktreeId:V,paths:pe}),fn())},children:["discard ",pe.length,"…"]}),d.jsx(ze,{size:"md",disabled:pe.length===0,"data-tip":"Name every checked file in the chat",onClick:()=>{V&&qP(i,V,pe),fn()},children:"add to chat"}),d.jsx(Pt,{icon:"close",label:"Cancel",hint:"esc",onClick:fn})]}),je&&!c&&d.jsx(bD,{active:je,ahead:(y==null?void 0:y.ahead)??0,behind:(y==null?void 0:y.behind)??0,unpushed:(y==null?void 0:y.unpushed)??je.unpushed??0,dirty:!ie})]})}function BD(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 vb(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 Kc(e){return e>0&&e<.005?"<$0.01":`$${e.toFixed(2)}`}function UD(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 HD(e){if(!(e<.5))return e<.8?"worth compacting between tasks":"compact before the next task"}const U_=["five_hour","seven_day"],WD={five_hour:"the 5-hour window",seven_day:"the week"},KD={five_hour:"5-hour",seven_day:"this week"};function H_(e,t){return U_.flatMap(n=>{const r=e.windows[n];return r&&r.resetsAt>t?[{key:n,used:r.used,resetsAt:r.resetsAt}]:[]})}function ZD(e,t){return Math.min(1,Math.max(0,...H_(e,t).map(n=>n.used)))}const qD=e=>`${Math.round(100*e)}%`;function bb(e,t){const n=H_(e,t).map(r=>`${qD(r.used)} of ${WD[r.key]}`);return n.length?n.join(", "):"plan windows reset"}function GD(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 VD(e,t,n=r=>GD(r,t)){return U_.flatMap(r=>{const o=e.windows[r];if(!o)return[];const i=KD[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 YD(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 W_(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(Kc(e.cost)),t.push(to(e.archivedAt)),t.filter(Boolean).join(" · ")}function K_({sock:e,dispatch:t},n,r){e==null||e.send({t:"restore-worktree",archiveId:n,clientId:r}),t({a:"restoring",id:n,text:""})}function jd(e,t,{sock:n,dispatch:r}){const o=[{id:"restore",label:"restore",disabled:e.restorable?void 0:"its commits were not kept",onClick:()=>{K_({sock:n,dispatch:r},e.id,t.clientId),r({a:"close"})}}],i=[{id:"copy-branch",label:"copy branch name",onClick:()=>on(e.branch)}],{sessionId:l}=e;return t.frame!=="phone"&&(i.push({id:"copy-transcript",label:"copy transcript path",onClick:()=>on(e.transcript)}),l&&i.push({id:"copy-session",label:"copy session id",onClick:()=>on(l)})),zn([o,i,[{id:"delete",label:"delete for good…",danger:!0,onClick:()=>{window.confirm(`Delete "${e.title}" for good?
126
+
127
+ Its chat, attachments and kept commits are deleted, and it can no longer be restored.`)&&(n==null||n.send({t:"delete-archived",archiveId:e.id}))}}]])}const XD=new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"});function Z_(e){const[t,n]=S.useState(()=>Date.now());return S.useEffect(()=>{const r=setInterval(()=>n(Date.now()),6e4);return()=>clearInterval(r)},[]),`${qg(t-e)} ago`}function eo({icon:e,word:t,tone:n,at:r,below:o,children:i,...l}){const c=r!==void 0?{"data-tip":`${t} ${XD.format(r)}`,"data-tip-placement":"follow"}:null;return d.jsxs("div",{...c,...l,className:"daemon-row row-edge","data-tone":n,children:[d.jsxs("div",{className:"daemon-head",children:[d.jsxs("span",{className:"daemon-tag",children:[d.jsx(Nt,{name:e,className:"icon-inline"}),t]}),i]}),o]})}function QD({item:e}){const t=ct(),n=lt(),r=P(p=>p.clientId),o=It(e.id,"restoring"),i=e.uncommitted?"its chat, commits and uncommitted changes":"its chat and commits",l=e.cost!==void 0?`; the session cost ${Kc(e.cost)}`:"",c=e.restorable?`Toyon kept ${i}${l}. A message sent below restores it first.`:`Its commits were not kept, so there is nothing to restore${l}; its row's menu on the rail can delete it for good.`,u=Z_(e.archivedAt),h=xk(e.lands);return d.jsxs(eo,{icon:"archive",word:"archived",tone:"quiet",at:e.archivedAt,below:d.jsxs(d.Fragment,{children:[h.map((p,m)=>d.jsx("div",{className:"daemon-below row-dim",children:p},m)),d.jsx("div",{className:"daemon-below row-dim",children:c})]}),children:[d.jsxs("span",{className:"daemon-text",children:[u,e.landed?", after it was merged into main":""]}),e.restorable&&o===void 0&&d.jsx(ze,{variant:"inline",tone:"strong",onClick:()=>K_({sock:t,dispatch:n},e.id,r),children:"restore"})]})}function Wi(e,t,n,r,o){const{layout:i}=e.getState();er({dispatch:e.dispatch},{worktreeId:n,path:r,view:"file",line:{n:o,fiber:!0}}),i.changes||e.dispatch({a:"toggle-changes"})}function JD(e){let t=0;return e.map(n=>{const r={start:t,len:n};return t+=n,r})}function ez(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 xb(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 tz(e,t){return{from:xb(e,t.start,!1),to:xb(e,t.end,!0)}}function Eb(e,t){if(e.length===0)return-1;const n=e.findIndex(r=>r.start>=t);return n===-1?0:n}function nz(e,t,n){return t===0?-1:(e+n+t)%t}function Tk(e){return e.key==="f"&&(e.metaKey||e.ctrlKey)&&!e.altKey&&!e.shiftKey}function rz({label:e,query:t,onQuery:n,seed:r,seq:o,status:i,none:l,onStep:c,onClose:u}){const h=S.useRef(null);return St([o],()=>{var p,m;r&&n(r),(p=h.current)==null||p.focus(),(m=h.current)==null||m.select()}),d.jsxs("div",{className:"find",children:[d.jsx(Eo,{ref:h,autoFocus:!0,value:t,onChange:p=>n(p.target.value),placeholder:"find…","aria-label":e,className:"find-field",spellCheck:!1,onKeyDown:p=>{if(p.key==="Escape"){p.preventDefault(),p.stopPropagation(),u();return}if(p.key==="Enter"){p.preventDefault(),c(p.shiftKey?-1:1);return}if(Tk(p)){p.preventDefault(),p.stopPropagation(),p.currentTarget.select();return}p.key.toLowerCase()==="g"&&(p.metaKey||p.ctrlKey)&&!p.altKey&&(p.preventDefault(),p.stopPropagation(),c(p.shiftKey?-1:1))}}),d.jsx("span",{className:"find-count","aria-live":"polite",children:i}),d.jsx(Pt,{icon:"caret",label:"Previous match",hint:"⇧↩",className:"find-prev",disabled:l,onClick:()=>c(-1)}),d.jsx(Pt,{icon:"caret",label:"Next match",hint:"↩",disabled:l,onClick:()=>c(1)}),d.jsx(Pt,{icon:"close",label:"Close",hint:"esc",onClick:u})]})}const q_="find",G_="find-current",V_=typeof CSS<"u"&&"highlights"in CSS;function oz(e){const t=e.parentElement;return t?typeof t.checkVisibility=="function"?t.checkVisibility():!0:!1}function sz(e){const t=document.createTreeWalker(e,NodeFilter.SHOW_TEXT),n=[];for(let r=t.nextNode();r;r=t.nextNode()){const o=r;o.data.length>0&&oz(o)&&n.push(o)}return n}const Fm={matches:[],ranges:[]};function iz(e,t){if(!t)return Fm;const n=sz(e),r=ez(n.map(l=>l.data).join(""),t),o=JD(n.map(l=>l.data.length)),i=r.map(l=>{const{from:c,to:u}=tz(o,l),h=document.createRange();return h.setStart(n[c.i],c.at),h.setEnd(n[u.i],u.at),h});return{matches:r,ranges:i}}function az(e,t){V_&&(CSS.highlights.set(q_,new Highlight(...e.filter((n,r)=>r!==t))),CSS.highlights.set(G_,new Highlight(...e[t]?[e[t]]:[])))}function lz(){V_&&(CSS.highlights.delete(q_),CSS.highlights.delete(G_))}function cz(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 _b=48;function uz(e,t){const n=t.getBoundingClientRect(),r=e.getBoundingClientRect();n.top>=r.top+_b&&n.bottom<=r.bottom-_b||(e.scrollTop+=n.top-r.top-r.height/3)}function Y_({root:e,body:t,seed:n,seq:r,onClose:o,onReveal:i}){const[l,c]=S.useState(n),[u,h]=S.useState(Fm),[p,m]=S.useState(-1),g=S.useRef({found:Fm,at:-1}),y=S.useRef(""),w=S.useRef(!1),[b,E]=S.useState(0);S.useLayoutEffect(()=>{const R=t.current;if(!R)return;let O=0;const B=new MutationObserver(()=>{O||(O=requestAnimationFrame(()=>{O=0,E($=>$+1)}))});return B.observe(R,{childList:!0,characterData:!0,subtree:!0,attributes:!0}),()=>{B.disconnect(),O&&cancelAnimationFrame(O)}},[t]),S.useLayoutEffect(()=>{const R=t.current;if(!R)return;const O=iz(R,l),B=l!==y.current;y.current=l,B&&(w.current=!0);const{found:$,at:C}=g.current;let j;B?$.matches[C]?j=Eb(O.matches,$.matches[C].start):j=e.current?cz(O.ranges,e.current):Eb(O.matches,0):j=Math.min(C,O.matches.length-1),g.current={found:O,at:j},h(O),m(j)},[l,b]),S.useLayoutEffect(()=>{az(u.ranges,p);const R=u.ranges[p];R&&(w.current&&e.current&&(uz(e.current,R),i==null||i()),w.current=!1)},[u,p,e,i]),S.useLayoutEffect(()=>lz,[]);const _=u.matches.length,N=R=>{if(_===0)return;w.current=!0;const O=nz(g.current.at,_,R);g.current={...g.current,at:O},m(O)},T=()=>o(u.ranges[p]??null);return d.jsx(rz,{label:"find in this document",query:l,onQuery:c,seed:n,seq:r,status:l?_===0?"no matches":`${p+1}/${_}`:"",none:_===0,onStep:N,onClose:T})}function X_(e){return e.key==="a"&&(e.metaKey||e.ctrlKey)&&!e.altKey&&!e.shiftKey}function Q_(e,t,n,r){S.useEffect(()=>{let o=!1;const i=c=>{o=!!e.current&&c.target instanceof Node&&e.current.contains(c.target)},l=c=>{const u=e.current;if(!u||c.defaultPrevented||!t(c))return;const h=document.activeElement;!(h&&h!==document.body?u.contains(h):o)&&!(r!=null&&r(h))||(c.preventDefault(),n(u,c))};return window.addEventListener("pointerdown",i,!0),window.addEventListener("keydown",l),()=>{window.removeEventListener("pointerdown",i,!0),window.removeEventListener("keydown",l)}},[e,t,n,r])}function dz(e){Q_(e,X_,J_)}function Bm(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 J_(e){const t=document.createRange();t.selectNodeContents(e);const n=window.getSelection();n&&(n.removeAllRanges(),n.addRange(t))}const eS=({open:e,remove:t})=>[e?[{id:"open",label:"open full size",onClick:e}]:[],t?[{id:"remove",label:"remove",onClick:t}]:[]];function Cc(e,t={}){return zn([[{id:"copy-image",label:"copy image",onClick:()=>LP(e)}],...eS(t)])}function tS(e,t={}){const{text:n,href:r}=e;return zn([n!==void 0?[{id:"copy-text",label:"copy text",onClick:()=>on(n)}]:r?[{id:"copy-text",label:"copy text",onClick:()=>MP(r)}]:[],...eS(t)])}function fz(e){return[GE(e),{id:"copy-link",label:"copy link",onClick:()=>on(e)}]}function Um(e){return e?[{id:"copy-code",label:"copy code",onClick:()=>on(e)}]:[]}function Oi(e,t,{dispatch:n,sock:r},o={}){const i=o.link,l=(i==null?void 0:i.kind)==="file"&&t?()=>r==null?void 0:r.send({t:"reveal",worktreeId:t,path:i.file.path}):void 0,c=i?i.kind==="file"?qd(i.file.path,o.dir??null,l,as(r)):i.kind==="path"||i.kind==="outside"?qd(i.path,o.dir??null,void 0,as(r)):[fz(i.href)]:[],u=[{id:"copy",label:"copy message",onClick:()=>on(e.text)}],h=[];return e.kind==="user"&&t&&h.push({id:"draft",label:"edit in composer",onClick:()=>{const p=e.seq;if(p===void 0||!r)return n({a:"set-draft",id:t,text:e.text});n({a:"set-draft",id:t,text:""}),r.send({t:"redraft",worktreeId:t,seq:p})}}),zn([Um(o.code),...c,u,h])}function qd(e,t,n,r){const o=e.startsWith("/")?e:t?`${t}/${e}`:null;return[o?Gi(o,n,r):[],[{id:"copy-path",label:"copy path",onClick:()=>on(e)}]]}function nS(e,t,n,r){return zn(qd(e,t,n,r))}function hz(e,t){const n=e.callFile??e.file,r=n?qd(n,t.dir??null,void 0,t.host):[],o=t.remove?[{id:"remove",label:"remove",onClick:t.remove}]:[];return zn([...r,o])}const Sb=8,pz=.7,mz=100,gz=400,kz=260,wz=80,yz=220;function Nb({dx:e,dy:t}){return Math.abs(e)<Sb&&Math.abs(t)<Sb?null:Math.abs(t)>Math.abs(e)?"away":"other"}function vz(e,t){const n=e.filter(i=>t-i.t<=mz),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 bz=e=>Math.abs(e)>=pz;function xz(e,t){return Math.min(yz,Math.max(wz,e/Math.abs(t)))}function Ez(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=(b,E,_)=>{_!==void 0&&o.style.setProperty("--swipe-ms",`${_}ms`),o.dataset.swipe!==E&&(o.dataset.swipe=E,o.offsetWidth),o.style.setProperty("--swipe-y",`${b}px`),o.style.setProperty("--swipe-fade",`${Math.min(1,Math.abs(b)/(window.innerHeight/2))}`)},p=()=>{o.style.removeProperty("--swipe-y"),o.style.removeProperty("--swipe-fade"),o.style.removeProperty("--swipe-ms"),delete o.dataset.swipe},m=()=>{const b=l;i=null,l=!1,c=[],b&&(h(0,"settle"),u=window.setTimeout(p,kz))},g=b=>{var N;const E=b.touches[0],_=b.target;if(b.touches.length!==1||!E||(((N=window.visualViewport)==null?void 0:N.scale)??1)>1.01)return m();o.dataset.swipe==="leave"||!(_===o||_!=null&&_.closest(t))||(window.clearTimeout(u),i={x:E.clientX,y:E.clientY,at:b.timeStamp},c=[{y:E.clientY,t:b.timeStamp}])},y=b=>{const E=b.touches[0];if(!i||!E)return;const _=E.clientX-i.x,N=E.clientY-i.y;if(!l){const T=Nb({dx:_,dy:N});if(T==="other"&&(i=null),T!=="away")return;l=!0}b.preventDefault(),c.push({y:E.clientY,t:b.timeStamp}),c.length>16&&c.shift(),h(N,"drag")},w=b=>{const E=b.changedTouches[0];if(!i||!E)return;const _=E.clientY-i.y,N=b.timeStamp-i.at;if(!l&&N<gz&&b.target!==o&&Nb({dx:E.clientX-i.x,dy:_})===null){b.preventDefault(),i=null,r.current();return}const R=vz(c,b.timeStamp);if(!l||!bz(R))return m();i=null,l=!1,c=[];const O=Math.sign(R)*window.innerHeight,B=xz(Math.abs(O-_),R);h(O,"leave",B),u=window.setTimeout(()=>r.current(),B)};return o.addEventListener("touchstart",g,{passive:!0}),o.addEventListener("touchmove",y,{passive:!1}),o.addEventListener("touchend",w),o.addEventListener("touchcancel",m),()=>{window.clearTimeout(u),o.removeEventListener("touchstart",g),o.removeEventListener("touchmove",y),o.removeEventListener("touchend",w),o.removeEventListener("touchcancel",m)}},[e,t])}function jk({owner:e,onClose:t,menu:n,children:r}){const o=wn(e),i=S.useRef(null);return Ez(i,"img",t),d.jsxs(Ns,{className:"attach-full scrim",boxRef:i,onDismiss:t,onKey:l=>{l.key==="Escape"&&(l.stopPropagation(),t())},onClick:l=>{l.target===l.currentTarget&&t()},...n&&o.contextMenu(n),children:[r,d.jsx(Pt,{icon:"close",label:"Close",tone:"quiet",onClick:t})]})}function _z({item:e}){if(!e.outcome)return null;const t=VM[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"})]})}const Sz=e=>e.t==="open-path"||e.t==="open-loose",Ha=new Map,Nz=16;function Tz({sock:e,dispatch:t},n,r){const o=Ko();Ha.set(o,{worktreeId:n,href:r.href});for(const i of Ha.keys()){if(Ha.size<=Nz)break;Ha.delete(i)}t({a:"link-refused",id:n,v:null}),e==null||e.send({t:"open-by-path",path:r.path,seq:o})}function jz(e,t){const n=Ha.get(t.seq);n&&(Ha.delete(t.seq),e.dispatch({a:"link-refused",id:n.worktreeId,v:{href:n.href,message:t.message}}))}function Cz(e,t,n){var i;const r=e.getState();if(n.t==="open-path"){const l={dispatch:u=>e.dispatch(u)};if(So(r,n.worktreeId)){r.activeId!==n.worktreeId&&e.dispatch({a:"activate",id:n.worktreeId}),er(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=So(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})}er(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:Ko()}})}function Ck(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 rS=e=>e.slice(0,Math.max(0,e.lastIndexOf("/")));function oS(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(p=>p===".."))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 sS(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 Az(e){return e.length<2||!e.startsWith("/")||e.startsWith("//")||/\s/.test(e)?null:e}function Ak(e,t){const n=e.closest("a, code[data-path]");if(!n)return null;const r=n.getAttribute("data-path");if(r)return{kind:"path",path:r};const o=n.getAttribute("href");if(!o)return null;const i=t?oS(t,o):null;if(i)return{kind:"file",file:i};const l=sS(o);return l?{kind:"outside",href:o,...l}:{kind:"out",href:o}}function Ik(e,t,n,r){const o=Ak(e.target,t);if((o==null?void 0:o.kind)==="outside"&&n){e.preventDefault(),Tz(r,n,o);return}if((o==null?void 0:o.kind)!=="file"||!n)return;const i=o.file;if(e.preventDefault(),i.folder){HP(r,{worktreeId:n,path:i.path});return}er(r,{worktreeId:n,path:i.path,...i.line?{line:{n:i.line}}:{}})}const Iz=150,Rz=e=>({side:e,align:"center",offset:12,flip:"side",margin:8});function iS({chip:e,className:t,children:n}){const[r,o]=S.useState(!1),i=P(c=>c.chatSide);S.useEffect(()=>{const c=e.current;if(!c)return;let u=0;const h=()=>{window.clearTimeout(u),o(!1)},p=()=>{window.clearTimeout(u),u=window.setTimeout(()=>o(!0),Iz)};return c.addEventListener("mouseenter",p),c.addEventListener("mouseleave",h),c.addEventListener("mousedown",h),()=>{window.clearTimeout(u),c.removeEventListener("mouseenter",p),c.removeEventListener("mouseleave",h),c.removeEventListener("mousedown",h)}},[e]);const l=()=>{var p;const c=e.current;if(!c)return null;const u=c.getBoundingClientRect(),h=((p=c.closest(".chat-log"))==null?void 0:p.getBoundingClientRect())??u;return{left:h.left,right:h.right,top:u.top,bottom:u.bottom}};return r?d.jsx(Ns,{className:Ue("chip-peek",t),anchor:l,placement:Rz(i==="left"?"right":"left"),track:!0,children:n}):null}function Rk({className:e,label:t,tip:n,peek:r,full:o,menu:i,removeLabel:l,onRemove:c}){const u=S.useRef(null),[h,p]=S.useState(!1),m=wn("chat"),g=o!==void 0;return d.jsxs("div",{ref:u,className:Ue("pick-chip row row-sm",e),"data-tip":g?"Open full size":n,"data-tip-placement":"follow",...m.contextMenu(()=>i({open:g?()=>p(!0):void 0,remove:c})),children:[g?d.jsx("button",{type:"button",className:"chip-link",onClick:()=>p(!0),children:t}):t,c&&d.jsx(Pt,{icon:"close",label:l,tone:"quiet",onClick:c}),g&&r!==void 0&&d.jsx(iS,{chip:u,children:r}),h&&g&&d.jsx(jk,{owner:"chat",onClose:()=>p(!1),menu:()=>i(),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 Tb(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 $z(e){if(Array.isArray(e))return e}function Oz(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(p){h=!0,o=p}finally{try{if(!u&&n.return!=null&&(l=n.return(),Object(l)!==l))return}finally{if(h)throw o}}return c}}function Mz(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
128
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Lz(e,t){return $z(e)||Oz(e,t)||Pz(e,t)||Mz()}function Pz(e,t){if(e){if(typeof e=="string")return Tb(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)?Tb(e,t):void 0}}const aS=Object.entries,jb=Object.setPrototypeOf,Dz=Object.isFrozen,zz=Object.getPrototypeOf,Fz=Object.getOwnPropertyDescriptor;let lr=Object.freeze,kr=Object.seal,Da=Object.create,lS=typeof Reflect<"u"&&Reflect,Hm=lS.apply,Wm=lS.construct;lr||(lr=function(t){return t});kr||(kr=function(t){return t});Hm||(Hm=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)});Wm||(Wm=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 Li=sr(Array.prototype.forEach),Bz=sr(Array.prototype.lastIndexOf),Cb=sr(Array.prototype.pop),Vl=sr(Array.prototype.push),Uz=sr(Array.prototype.splice),Xa=Array.isArray,rc=sr(String.prototype.toLowerCase),Bp=sr(String.prototype.toString),Ab=sr(String.prototype.match),Yl=sr(String.prototype.replace),Ib=sr(String.prototype.indexOf),Hz=sr(String.prototype.trim),Wz=sr(Number.prototype.toString),Kz=sr(Boolean.prototype.toString),Rb=typeof BigInt>"u"?null:sr(BigInt.prototype.toString),$b=typeof Symbol>"u"?null:sr(Symbol.prototype.toString),Jr=sr(Object.prototype.hasOwnProperty),Xl=sr(Object.prototype.toString),Ar=sr(RegExp.prototype.test),Mi=Zz(TypeError);function sr(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 Hm(e,t,r)}}function Zz(e){return function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return Wm(e,n)}}function un(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:rc;if(jb&&jb(e,null),!Xa(t))return e;let r=t.length;for(;r--;){let o=t[r];if(typeof o=="string"){const i=n(o);i!==o&&(Dz(t)||(t[r]=i),o=i)}e[o]=!0}return e}function qz(e){for(let t=0;t<e.length;t++)Jr(e,t)||(e[t]=null);return e}function uo(e){const t=Da(null);for(const r of aS(e)){var n=Lz(r,2);const o=n[0],i=n[1];Jr(e,o)&&(Xa(i)?t[o]=qz(i):i&&typeof i=="object"&&i.constructor===Object?t[o]=uo(i):t[o]=i)}return t}function Gz(e){switch(typeof e){case"string":return e;case"number":return Wz(e);case"boolean":return Kz(e);case"bigint":return Rb?Rb(e):"0";case"symbol":return $b?$b(e):"Symbol()";case"undefined":return Xl(e);case"function":case"object":{if(e===null)return Xl(e);const t=e,n=zo(t,"toString");if(typeof n=="function"){const r=n(t);return typeof r=="string"?r:Xl(r)}return Xl(e)}default:return Xl(e)}}function zo(e,t){for(;e!==null;){const r=Fz(e,t);if(r){if(r.get)return sr(r.get);if(typeof r.value=="function")return sr(r.value)}e=zz(e)}function n(){return null}return n}function Vz(e){try{return Ar(e,""),!0}catch{return!1}}const Ob=lr(["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"]),Up=lr(["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"]),Hp=lr(["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"]),Yz=lr(["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"]),Wp=lr(["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"]),Xz=lr(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),Mb=lr(["#text"]),Lb=lr(["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"]),Kp=lr(["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"]),Pb=lr(["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"]),hd=lr(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),Qz=kr(/{{[\w\W]*|^[\w\W]*}}/g),Jz=kr(/<%[\w\W]*|^[\w\W]*%>/g),e3=kr(/\${[\w\W]*/g),t3=kr(/^data-[\-\w.\u00B7-\uFFFF]+$/),n3=kr(/^aria-[\-\w]+$/),Db=kr(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),r3=kr(/^(?:\w+script|data):/i),o3=kr(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),s3=kr(/^html$/i),i3=kr(/^[a-z][.\w]*(-[.\w]+)+$/i),zb=kr(/<[/\w!]/g),Fb=kr(/<[/\w]/g),a3=kr(/<\/no(script|embed|frames)/i),l3=kr(/\/>/i),co={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},cS=["style","script","xmp","iframe","noembed","noframes","plaintext","noscript"],c3=lr(un({},cS)),u3=(function(){const e={};return Li(cS,t=>{e[t]=kr(new RegExp("</"+t+"(?=[\\t\\n\\f\\r />])","i"))}),lr(e)})(),d3=function(){return typeof window>"u"?null:window},f3=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}},Bb=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},Ys=function(t,n,r,o){return Jr(t,n)&&Xa(t[n])?un(o.base?uo(o.base):{},t[n],o.transform):r},Zp=function(t,n,r){const o=Jr(t,n)?t[n]:void 0;return o&&typeof o=="object"?uo(o):r()};function uS(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:d3();const t=Se=>uS(Se);if(t.version="3.4.14",t.removed=[],!e||!e.document||e.document.nodeType!==co.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 p=e.DOMParser,m=e.trustedTypes,g=c.prototype,y=zo(g,"cloneNode"),w=zo(g,"remove"),b=zo(g,"nextSibling"),E=zo(g,"childNodes"),_=zo(g,"parentNode"),N=zo(g,"shadowRoot"),T=zo(g,"attributes"),R=l&&l.prototype?zo(l.prototype,"nodeType"):null,O=l&&l.prototype?zo(l.prototype,"nodeName"):null,B=l&&l.prototype?zo(l.prototype,"ownerDocument"):null,$=function(L){return R?R(L):L.nodeType},C=function(L){return O?O(L):L.nodeName};if(typeof i=="function"){const Se=n.createElement("template");Se.content&&Se.content.ownerDocument&&(n=Se.content.ownerDocument)}let j,D="",z,X=!1,ae=0;const A=function(){if(ae>0)throw Mi('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.')},de=function(L){A(),ae++;try{return j.createHTML(L)}finally{ae--}},ue=function(L){A(),ae++;try{return j.createScriptURL(L)}finally{ae--}},J=function(){return X||(z=f3(m,o),X=!0),z},M=n,oe=M.implementation,ne=M.createNodeIterator,H=M.createDocumentFragment,se=M.getElementsByTagName,ie=r.importNode;let he=Bb();t.isSupported=typeof aS=="function"&&typeof _=="function"&&oe&&oe.createHTMLDocument!==void 0;const ge=Qz,Ie=Jz,ke=e3,Q=t3,we=n3,te=r3,Z=o3,je=i3;let He=Db,Fe=null;const Pe=un({},[...Ob,...Up,...Hp,...Wp,...Mb]);let We=null;const Ht=un({},[...Lb,...Kp,...Pb,...hd]);let ut=Object.seal(Da(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}})),vn=null,Jt=null;const xt=Object.seal(Da(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let kt=!0,ot=!0,dt=!1,Tt=!0,Et=!1,dn=!0,G=!1,ve=!1,tt=null,it=null,ft=!1,Gt=!1,Ft=!1,An=!1,qn=!0,zt=!1;const bn="user-content-";let ye=!0,Me=!1,Bt={},jt=null;const fn=un({},["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 K=null;const pe=un({},["audio","video","img","source","image","track"]);let _e=null;const Xe=un({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),qe="http://www.w3.org/1998/Math/MathML",_t="http://www.w3.org/2000/svg",Le="http://www.w3.org/1999/xhtml";let $e=Le,Ge=!1,Wt=null;const Mt=un({},[qe,_t,Le],Bp),Tn=lr(["mi","mo","mn","ms","mtext"]);let In=un({},Tn);const yn=lr(["annotation-xml"]);let wr=un({},yn);const gn=un({},["title","style","font","a","script"]);let Nn=null;const ur=["application/xhtml+xml","text/html"],nn="text/html";let en=null,Kt=null;const V=n.createElement("form"),Ee=function(L){return L instanceof RegExp||L instanceof Function},Ze=function(){let L=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(Kt&&Kt===L)return;(!L||typeof L!="object")&&(L={}),L=uo(L),Nn=ur.indexOf(L.PARSER_MEDIA_TYPE)===-1?nn:L.PARSER_MEDIA_TYPE,en=Nn==="application/xhtml+xml"?Bp:rc,Fe=Ys(L,"ALLOWED_TAGS",Pe,{transform:en}),We=Ys(L,"ALLOWED_ATTR",Ht,{transform:en}),Wt=Ys(L,"ALLOWED_NAMESPACES",Mt,{transform:Bp}),_e=Ys(L,"ADD_URI_SAFE_ATTR",Xe,{transform:en,base:Xe}),K=Ys(L,"ADD_DATA_URI_TAGS",pe,{transform:en,base:pe}),jt=Ys(L,"FORBID_CONTENTS",fn,{transform:en}),vn=Ys(L,"FORBID_TAGS",uo({}),{transform:en}),Jt=Ys(L,"FORBID_ATTR",uo({}),{transform:en}),Bt=Jr(L,"USE_PROFILES")?L.USE_PROFILES&&typeof L.USE_PROFILES=="object"?uo(L.USE_PROFILES):L.USE_PROFILES:!1,kt=L.ALLOW_ARIA_ATTR!==!1,ot=L.ALLOW_DATA_ATTR!==!1,dt=L.ALLOW_UNKNOWN_PROTOCOLS||!1,Tt=L.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Et=L.SAFE_FOR_TEMPLATES||!1,dn=L.SAFE_FOR_XML!==!1,G=L.WHOLE_DOCUMENT||!1,Gt=L.RETURN_DOM||!1,Ft=L.RETURN_DOM_FRAGMENT||!1,An=L.RETURN_TRUSTED_TYPE||!1,ft=L.FORCE_BODY||!1,qn=L.SANITIZE_DOM!==!1,zt=L.SANITIZE_NAMED_PROPS||!1,ye=L.KEEP_CONTENT!==!1,Me=L.IN_PLACE||!1,He=Vz(L.ALLOWED_URI_REGEXP)?L.ALLOWED_URI_REGEXP:Db,$e=typeof L.NAMESPACE=="string"?L.NAMESPACE:Le,In=Zp(L,"MATHML_TEXT_INTEGRATION_POINTS",()=>un({},Tn)),wr=Zp(L,"HTML_INTEGRATION_POINTS",()=>un({},yn));const F=Zp(L,"CUSTOM_ELEMENT_HANDLING",()=>Da(null));if(ut=Da(null),Jr(F,"tagNameCheck")&&Ee(F.tagNameCheck)&&(ut.tagNameCheck=F.tagNameCheck),Jr(F,"attributeNameCheck")&&Ee(F.attributeNameCheck)&&(ut.attributeNameCheck=F.attributeNameCheck),Jr(F,"allowCustomizedBuiltInElements")&&typeof F.allowCustomizedBuiltInElements=="boolean"&&(ut.allowCustomizedBuiltInElements=F.allowCustomizedBuiltInElements),kr(ut),Et&&(ot=!1),Ft&&(Gt=!0),Bt&&(Fe=un({},Mb),We=Da(null),Bt.html===!0&&(un(Fe,Ob),un(We,Lb)),Bt.svg===!0&&(un(Fe,Up),un(We,Kp),un(We,hd)),Bt.svgFilters===!0&&(un(Fe,Hp),un(We,Kp),un(We,hd)),Bt.mathMl===!0&&(un(Fe,Wp),un(We,Pb),un(We,hd))),xt.tagCheck=null,xt.attributeCheck=null,Jr(L,"ADD_TAGS")&&(typeof L.ADD_TAGS=="function"?xt.tagCheck=L.ADD_TAGS:Xa(L.ADD_TAGS)&&(Fe===Pe&&(Fe=uo(Fe)),un(Fe,L.ADD_TAGS,en))),Jr(L,"ADD_ATTR")&&(typeof L.ADD_ATTR=="function"?xt.attributeCheck=L.ADD_ATTR:Xa(L.ADD_ATTR)&&(We===Ht&&(We=uo(We)),un(We,L.ADD_ATTR,en))),Jr(L,"ADD_FORBID_CONTENTS")&&Xa(L.ADD_FORBID_CONTENTS)&&(jt===fn&&(jt=uo(jt)),un(jt,L.ADD_FORBID_CONTENTS,en)),ye&&(Fe["#text"]=!0),G&&un(Fe,["html","head","body"]),Fe.table&&(un(Fe,["tbody"]),delete vn.tbody),L.TRUSTED_TYPES_POLICY){if(typeof L.TRUSTED_TYPES_POLICY.createHTML!="function")throw Mi('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof L.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw Mi('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');const re=j;j=L.TRUSTED_TYPES_POLICY;try{D=de("")}catch(be){throw j=re,be}}else L.TRUSTED_TYPES_POLICY===null?(j=void 0,D=""):(j===void 0&&(j=J()),j&&typeof D=="string"&&(D=de("")));lr&&lr(L),Kt=L},yt=un({},[...Up,...Hp,...Yz]),sn=un({},[...Wp,...Xz]),ln=function(L,F,re){return F.namespaceURI===Le?L==="svg":F.namespaceURI===qe?L==="svg"&&(re==="annotation-xml"||In[re]):!!yt[L]},Vt=function(L,F,re){return F.namespaceURI===Le?L==="math":F.namespaceURI===_t?L==="math"&&wr[re]:!!sn[L]},dr=function(L,F,re){return F.namespaceURI===_t&&!wr[re]||F.namespaceURI===qe&&!In[re]?!1:!sn[L]&&(gn[L]||!yt[L])},Mr=function(L){let F=_(L);(!F||!F.tagName)&&(F={namespaceURI:$e,tagName:"template"});const re=rc(L.tagName),be=rc(F.tagName);return Wt[L.namespaceURI]?L.namespaceURI===_t?ln(re,F,be):L.namespaceURI===qe?Vt(re,F,be):L.namespaceURI===Le?dr(re,F,be):!!(Nn==="application/xhtml+xml"&&Wt[L.namespaceURI]):!1},Mn=function(L){Vl(t.removed,{element:L});try{_(L).removeChild(L)}catch{if(w(L),!_(L))throw Mi("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},Ot=function(L,F,re){try{L.removeAttributeNode(F)}catch{try{L.removeAttribute(re)}catch{}}},Ce=function(L){pt(L);const F=E(L);if(F){const be=[];Li(F,Re=>{Vl(be,Re)}),Li(be,Re=>{try{w(Re)}catch{}})}const re=T(L);if(re)for(let be=re.length-1;be>=0;--be){const Re=re[be],Ke=Re&&Re.name;typeof Ke=="string"&&Ot(L,Re,Ke)}},Te=function(L,F,re){if(!re)try{re=F.getAttributeNode(L)}catch{re=null}Vl(t.removed,{attribute:re||null,from:F});try{re?F.removeAttributeNode(re):F.removeAttribute(L)}catch{try{F.removeAttribute(L)}catch{}}if(L==="is")if(Gt||Ft)try{Mn(F)}catch{}else try{F.setAttribute(L,"")}catch{}},ht=function(L){const F=T(L);if(F)for(let re=F.length-1;re>=0;--re){const be=F[re],Re=be&&be.name;typeof Re!="string"||We[en(Re)]||Ot(L,be,Re)}},pt=function(L){const F=[L];for(;F.length>0;){const re=F.pop();$(re)===co.element&&ht(re);const Re=E(re);if(Re)for(let Ke=Re.length-1;Ke>=0;--Ke)F.push(Re[Ke])}},Zt=function(L,F){return dn?L==="patchsrc"?!0:L==="for"&&F!=="label"&&F!=="output":!1},tn=function(L){if(!dn)return;const F=[L];for(;F.length>0;){const re=F.pop(),be=$(re);if(be===co.processingInstruction||be===co.comment&&Ar(Fb,re.data)){try{w(re)}catch{}continue}if(be===co.element){const Ke=re,At=en(C(re));try{Ke.hasAttribute&&Ke.hasAttribute("patchsrc")&&Ke.removeAttribute("patchsrc"),Ke.hasAttribute&&Ke.hasAttribute("for")&&Zt("for",At)&&Ke.removeAttribute("for")}catch{}}const Re=E(re);if(Re)for(let Ke=Re.length-1;Ke>=0;--Ke)F.push(Re[Ke])}},W=function(L){let F=null,re=null;if(ft)L="<remove></remove>"+L;else{const Ke=Ab(L,/^[\r\n\t ]+/);re=Ke&&Ke[0]}Nn==="application/xhtml+xml"&&$e===Le&&(L='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+L+"</body></html>");const be=j?de(L):L;if($e===Le)try{F=new p().parseFromString(be,Nn)}catch{}if(!F||!F.documentElement){F=oe.createDocument($e,"template",null);try{F.documentElement.innerHTML=Ge?D:be}catch{}}const Re=F.body||F.documentElement;return L&&re&&Re.insertBefore(n.createTextNode(re),Re.childNodes[0]||null),$e===Le?se.call(F,G?"html":"body")[0]:G?F.documentElement:Re},me=function(L){const F=B?B(L):L.ownerDocument;return ne.call(F||L,L,u.SHOW_ELEMENT|u.SHOW_COMMENT|u.SHOW_TEXT|u.SHOW_PROCESSING_INSTRUCTION|u.SHOW_CDATA_SECTION,null)},Be=function(L){return L=Yl(L,ge," "),L=Yl(L,Ie," "),L=Yl(L,ke," "),L},mt=function(L){var F;L.normalize();const re=B?B(L):L.ownerDocument,be=ne.call(re||L,L,u.SHOW_TEXT|u.SHOW_COMMENT|u.SHOW_CDATA_SECTION|u.SHOW_PROCESSING_INSTRUCTION,null);let Re=be.nextNode();for(;Re;)Re.data=Be(Re.data),Re=be.nextNode();const Ke=(F=L.querySelectorAll)===null||F===void 0?void 0:F.call(L,"template");Ke&&Li(Ke,At=>{Yt(At.content)&&mt(At.content)})},Ct=function(L){const F=O?O(L):null;return typeof F!="string"||en(F)!=="form"?!1:typeof L.nodeName!="string"||typeof L.textContent!="string"||typeof L.removeChild!="function"||L.attributes!==T(L)||typeof L.removeAttribute!="function"||typeof L.setAttribute!="function"||typeof L.namespaceURI!="string"||typeof L.insertBefore!="function"||typeof L.hasChildNodes!="function"||L.nodeType!==R(L)||L.childNodes!==E(L)},Yt=function(L){if(!R||typeof L!="object"||L===null)return!1;try{return R(L)===co.documentFragment}catch{return!1}},Ln=function(L){if(!R||typeof L!="object"||L===null)return!1;try{return typeof R(L)=="number"}catch{return!1}};function tr(Se,L,F){Se.length!==0&&Li(Se,re=>{re.call(t,L,F,Kt)})}const jo=function(L,F){return!!(dn&&L.hasChildNodes()&&!Ln(L.firstElementChild)&&Ar(zb,L.textContent)&&Ar(zb,L.innerHTML)||dn&&L.namespaceURI===Le&&c3[F]&&(Ln(L.firstElementChild)||typeof L.textContent=="string"&&Ar(u3[F],L.textContent))||L.nodeType===co.processingInstruction||dn&&L.nodeType===co.comment&&Ar(Fb,L.data))},Sr=function(L,F){if(L instanceof RegExp)return Ar(L,F);if(L instanceof Function){for(var re=arguments.length,be=new Array(re>2?re-2:0),Re=2;Re<re;Re++)be[Re-2]=arguments[Re];return!!L(F,...be)}return!1},Cs=function(L,F,re){if(!vn[F]&&gt(F)&&Sr(ut.tagNameCheck,F))return!1;if(ye&&!jt[F]){const be=_(L),Re=E(L);if(Re&&be){const Ke=Re.length;for(let At=Ke-1;At>=0;--At){const pn=L===re?y(Re[At],!0):Re[At];be.insertBefore(pn,b(L))}}}return Mn(L),!0},Lr=function(L,F,re,be){return L.length===0?F:F===re||F===be?uo(F):F},Pr=function(L,F){return L===F||_(L)!==null?!1:(Me&&pt(L),!0)},yr=function(L,F){if(tr(he.beforeSanitizeElements,L,null),Pr(L,F))return!0;if(Ct(L))return Mn(L),!0;const re=en(C(L));if(Fe=Lr(he.uponSanitizeElement,Fe,Pe,tt),tr(he.uponSanitizeElement,L,{tagName:re,allowedTags:Fe}),Pr(L,F))return!0;if(jo(L,re))return Mn(L),!0;if(vn[re]||!(xt.tagCheck instanceof Function&&xt.tagCheck(re))&&!Fe[re]){const Re=Cs(L,re,F);return Re===!1&&tr(he.afterSanitizeElements,L,null),Re}if($(L)===co.element&&!Mr(L)||(re==="noscript"||re==="noembed"||re==="noframes")&&Ar(a3,L.innerHTML))return Mn(L),!0;if(Et&&L.nodeType===co.text){const Re=Be(L.textContent);L.textContent!==Re&&(Vl(t.removed,{element:L.cloneNode()}),L.textContent=Re)}return tr(he.afterSanitizeElements,L,null),!1},Co=function(L,F,re){if(Jt[F]||Zt(F,L)||qn&&(F==="id"||F==="name")&&(re in n||re in V))return!1;const be=We[F]||xt.attributeCheck instanceof Function&&xt.attributeCheck(F,L);return ot&&Ar(Q,F)||kt&&Ar(we,F)?!0:be?_e[F]||Ar(He,Yl(re,Z,""))||(F==="src"||F==="xlink:href"||F==="href")&&L!=="script"&&Ib(re,"data:")===0&&K[L]||dt&&!Ar(te,Yl(re,Z,""))?!0:!re:gt(L)&&Sr(ut.tagNameCheck,L)&&Sr(ut.attributeNameCheck,F,L)||F==="is"&&ut.allowCustomizedBuiltInElements&&Sr(ut.tagNameCheck,re)},Je=un({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),gt=function(L){return!Je[rc(L)]&&Ar(je,L)},Ao=function(L,F,re,be){if(j&&typeof m=="object"&&typeof m.getAttributeType=="function"&&!re)switch(m.getAttributeType(L,F)){case"TrustedHTML":return de(be);case"TrustedScriptURL":return ue(be)}return be},hn=function(L,F,re,be){try{re?L.setAttributeNS(re,F,be):L.setAttribute(F,be),Ct(L)?Mn(L):Cb(t.removed)}catch{Te(F,L)}},rn=function(L){tr(he.beforeSanitizeAttributes,L,null);const F=L.attributes;if(!F||Ct(L))return;We=Lr(he.uponSanitizeAttribute,We,Ht,it);const re={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:We,forceKeepAttr:void 0};let be=F.length;const Re=en(L.nodeName);for(;be--;){const Ke=F[be],At=Ke.name,pn=Ke.namespaceURI,Gn=Ke.value,Pn=en(At),vr=Gn;let nr=At==="value"?vr:Hz(vr);if(re.attrName=Pn,re.attrValue=nr,re.keepAttr=!0,re.forceKeepAttr=void 0,tr(he.uponSanitizeAttribute,L,re),nr=re.attrValue,zt&&(Pn==="id"||Pn==="name")&&Ib(nr,bn)!==0&&(Te(At,L,Ke),nr=bn+nr),dn&&Ar(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,nr)){Te(At,L,Ke);continue}if(Pn==="attributename"&&Ab(nr,"href")){Te(At,L,Ke);continue}if(!re.forceKeepAttr){if(!re.keepAttr){Te(At,L,Ke);continue}if(!Tt&&Ar(l3,nr)){Te(At,L,Ke);continue}if(Et&&(nr=Be(nr)),!Co(Re,Pn,nr)){Te(At,L,Ke);continue}nr=Ao(Re,Pn,pn,nr),nr!==vr&&hn(L,At,pn,nr)}}tr(he.afterSanitizeAttributes,L,null)},Dr=function(L){let F=null;const re=me(L);for(tr(he.beforeSanitizeShadowDOM,L,null);F=re.nextNode();)if(tr(he.uponSanitizeShadowNode,F,null),yr(F,L),rn(F),Yt(F.content)&&Dr(F.content),$(F)===co.element){const be=N(F);Yt(be)&&(Yn(be),Dr(be))}tr(he.afterSanitizeShadowDOM,L,null)},Yn=function(L){const F=[{node:L,shadow:null}];for(;F.length>0;){const re=F.pop();if(re.shadow){Dr(re.shadow);continue}const be=re.node,Ke=$(be)===co.element,At=E(be);if(At)for(let pn=At.length-1;pn>=0;--pn)F.push({node:At[pn],shadow:null});if(Ke){const pn=O?O(be):null;if(typeof pn=="string"&&en(pn)==="template"){const Gn=be.content;Yt(Gn)&&F.push({node:Gn,shadow:null})}}if(Ke){const pn=N(be);Yt(pn)&&F.push({node:null,shadow:pn},{node:pn,shadow:null})}}};return t.sanitize=function(Se){let L=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},F=null,re=null,be=null,Re=null;if(Ge=!Se,Ge&&(Se="<!-->"),typeof Se!="string"&&!Ln(Se)&&(Se=Gz(Se),typeof Se!="string"))throw Mi("dirty is not a string, aborting");if(!t.isSupported)return Se;ve?(Fe=tt,We=it):Ze(L),(he.uponSanitizeElement.length>0||he.uponSanitizeAttribute.length>0)&&(Fe=uo(Fe)),he.uponSanitizeAttribute.length>0&&(We=uo(We)),t.removed=[];const Ke=Me&&typeof Se!="string"&&Ln(Se);if(Ke){tn(Se);const Gn=C(Se);if(typeof Gn=="string"){const Pn=en(Gn);if(!Fe[Pn]||vn[Pn])throw Ce(Se),Mi("root node is forbidden and cannot be sanitized in-place")}if(Ct(Se))throw Ce(Se),Mi("root node is clobbered and cannot be sanitized in-place");try{Yn(Se)}catch(Pn){throw Ce(Se),Pn}}else if(Ln(Se))F=W("<!---->"),re=F.ownerDocument.importNode(Se,!0),re.nodeType===co.element&&re.nodeName==="BODY"||re.nodeName==="HTML"?F=re:F.appendChild(re),Yn(re);else{if(!Gt&&!Et&&!G&&Se.indexOf("<")===-1)return j&&An?de(Se):Se;if(F=W(Se),!F)return Gt?null:An?D:""}F&&ft&&Mn(F.firstChild);const At=Ke?Se:F;try{const Gn=me(At);for(;be=Gn.nextNode();)yr(be,At),rn(be),Yt(be.content)&&Dr(be.content)}catch(Gn){throw Ke&&(Ce(Se),Li(t.removed,Pn=>{Pn.element&&pt(Pn.element)})),Gn}if(Ke)return Li(t.removed,Gn=>{Gn.element&&pt(Gn.element)}),Et&&mt(Se),Se;if(Gt){if(Et&&mt(F),Ft)for(Re=H.call(F.ownerDocument);F.firstChild;)Re.appendChild(F.firstChild);else Re=F;return(We.shadowroot||We.shadowrootmode)&&(Re=ie.call(r,Re,!0)),Re}let pn=G?F.outerHTML:F.innerHTML;return G&&Fe["!doctype"]&&F.ownerDocument&&F.ownerDocument.doctype&&F.ownerDocument.doctype.name&&Ar(s3,F.ownerDocument.doctype.name)&&(pn="<!DOCTYPE "+F.ownerDocument.doctype.name+`>
129
+ `+pn),Et&&(pn=Be(pn)),j&&An?de(pn):pn},t.setConfig=function(){let Se=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Ze(Se),ve=!0,tt=Fe,it=We},t.clearConfig=function(){Kt=null,ve=!1,tt=null,it=null,j=z,D=""},t.isValidAttribute=function(Se,L,F){Kt||Ze({});const re=en(Se),be=en(L);return Co(re,be,F)},t.addHook=function(Se,L){typeof L=="function"&&Jr(he,Se)&&Vl(he[Se],L)},t.removeHook=function(Se,L){if(Jr(he,Se)){if(L!==void 0){const F=Bz(he[Se],L);return F===-1?void 0:Uz(he[Se],F,1)[0]}return Cb(he[Se])}},t.removeHooks=function(Se){Jr(he,Se)&&(he[Se]=[])},t.removeAllHooks=function(){he=Bb()},t}var h3=uS();function $k(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var Qi=$k();function dS(e){Qi=e}var Pi={exec:()=>null};function Oa(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 Qt(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(Rr.caret,"$1"),n=n.replace(o,l),r},getRegex:()=>new RegExp(n,t)};return r}var p3=((e="")=>{try{return!!new RegExp("(?<=1)(?<!1)"+e)}catch{return!1}})(),Rr={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:Oa(e=>new RegExp(`^ {0,${e}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`)),hrRegex:Oa(e=>new RegExp(`^ {0,${e}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`)),fencesBeginRegex:Oa(e=>new RegExp(`^ {0,${e}}(?:\`\`\`|~~~)`)),headingBeginRegex:Oa(e=>new RegExp(`^ {0,${e}}#`)),htmlBeginRegex:Oa(e=>new RegExp(`^ {0,${e}}<(?:[a-z].*>|!--)`,"i")),blockquoteBeginRegex:Oa(e=>new RegExp(`^ {0,${e}}>`))},m3=/^(?:[ \t]*(?:\n|$))+/,g3=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,k3=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Zc=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,w3=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,Ok=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,fS=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,hS=Qt(fS).replace(/bull/g,Ok).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(),y3=Qt(fS).replace(/bull/g,Ok).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(),Mk=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table|[ \t]+\n)[^\n]+)*)/,v3=/^[^\n]+/,Lk=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,b3=Qt(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Lk).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),x3=Qt(/^(bull)([ \t][^\n]*?)?(?:\n|$)/).replace(/bull/g,Ok).getRegex(),Ff="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",Pk=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,E3=Qt("^ {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",Pk).replace("tag",Ff).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),pS=e=>Qt(Mk).replace("hr",Zc).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",Ff).getRegex(),_3=pS(/ {0,3}(?:[*+-]|1[.)])[ \t]+[^ \t\n]/),S3=pS(/ {0,3}(?:[*+-]|\d{1,9}[.)])(?:[ \t]|\n|$)/),N3=Qt(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",S3).getRegex(),Dk={blockquote:N3,code:g3,def:b3,fences:k3,heading:w3,hr:Zc,html:E3,lheading:hS,list:x3,newline:m3,paragraph:_3,table:Pi,text:v3},Ub=Qt("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",Zc).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",Ff).getRegex(),T3={...Dk,lheading:y3,table:Ub,paragraph:Qt(Mk).replace("hr",Zc).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",Ub).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",Ff).getRegex()},j3={...Dk,html:Qt(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Pk).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:Pi,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:Qt(Mk).replace("hr",Zc).replace("heading",` *#{1,6} *[^
130
+ ]`).replace("lheading",hS).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},C3=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,A3=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,mS=/^( {2,}|\\)\n(?!\s*$)/,I3=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,js=/[\p{P}\p{S}]/u,hl=/[\s\p{P}\p{S}]/u,qc=/[^\s\p{P}\p{S}]/u,R3=Qt(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,hl).getRegex(),$3=/[\p{Pi}\p{Ps}"']/u,gS=/(?!~)[\p{P}\p{S}]/u,O3=/(?!~)[\s\p{P}\p{S}]/u,M3=/(?:[^\s\p{P}\p{S}]|~)/u,L3=Qt(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",p3?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),kS=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,P3=Qt(kS,"u").replace(/punct/g,js).getRegex(),D3=Qt(kS,"u").replace(/punct/g,gS).getRegex(),z3=/^(?:\*+(?:((?!\*)(?!openQuote)punct)|([^\s*]))?)|^_+(?:((?!_)(?!openQuote)punct)|([^\s_]))?/,F3=Qt(z3,"u").replace(/openQuote/g,$3).replace(/punct/g,js).getRegex(),wS="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",B3=Qt(wS,"gu").replace(/notPunctSpace/g,qc).replace(/punctSpace/g,hl).replace(/punct/g,js).getRegex(),U3=Qt(wS,"gu").replace(/notPunctSpace/g,M3).replace(/punctSpace/g,O3).replace(/punct/g,gS).getRegex(),H3="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)[\\s](\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|(?:(?!\\*)punct|notPunctSpace)(\\*+)(?!\\*)(?=notPunctSpace)",W3=Qt(H3,"gu").replace(/notPunctSpace/g,qc).replace(/punctSpace/g,hl).replace(/punct/g,js).getRegex(),K3=Qt("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,qc).replace(/punctSpace/g,hl).replace(/punct/g,js).getRegex(),Z3="^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)[\\s](_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)|(?:(?!_)punct|notPunctSpace)(_+)(?!_)(?=notPunctSpace)",q3=Qt(Z3,"gu").replace(/notPunctSpace/g,qc).replace(/punctSpace/g,hl).replace(/punct/g,js).getRegex(),G3=Qt(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,js).getRegex(),V3="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",Y3=Qt(V3,"gu").replace(/notPunctSpace/g,qc).replace(/punctSpace/g,hl).replace(/punct/g,js).getRegex(),X3=Qt(/\\(punct)/,"gu").replace(/punct/g,js).getRegex(),Q3=Qt(/^<(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(),J3=Qt(Pk).replace("(?:-->|$)","-->").getRegex(),e5=Qt("^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",J3).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),Gd=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,t5=Qt(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",Gd).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]+|(?=\))/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),yS=Qt(/^!?\[(label)\]\[(ref)\]/).replace("label",Gd).replace("ref",Lk).getRegex(),vS=Qt(/^!?\[(ref)\](?:\[\])?/).replace("ref",Lk).getRegex(),n5=Qt("reflink|nolink(?!\\()","g").replace("reflink",yS).replace("nolink",vS).getRegex(),Hb=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,zk={_backpedal:Pi,anyPunctuation:X3,autolink:Q3,blockSkip:L3,br:mS,code:A3,del:Pi,delLDelim:Pi,delRDelim:Pi,emStrongLDelim:P3,emStrongRDelimAst:B3,emStrongRDelimUnd:K3,escape:C3,link:t5,nolink:vS,punctuation:R3,reflink:yS,reflinkSearch:n5,tag:e5,text:I3,url:Pi},r5={...zk,emStrongLDelim:F3,emStrongRDelimAst:W3,emStrongRDelimUnd:q3,link:Qt(/^!?\[(label)\]\((.*?)\)/).replace("label",Gd).getRegex(),reflink:Qt(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",Gd).getRegex()},Km={...zk,emStrongRDelimAst:U3,emStrongLDelim:D3,delLDelim:G3,delRDelim:Y3,url:Qt(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",Hb).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:Qt(/^(`+|~+|[^`~])(?:(?=[`~])|(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",Hb).getRegex()},o5={...Km,br:Qt(mS).replace("{2,}","*").getRegex(),text:Qt(Km.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},pd={normal:Dk,gfm:T3,pedantic:j3},Ql={normal:zk,gfm:Km,breaks:o5,pedantic:r5},s5={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},Wb=e=>s5[e];function ts(e,t){if(t){if(Rr.escapeTest.test(e))return e.replace(Rr.escapeReplace,Wb)}else if(Rr.escapeTestNoEncode.test(e))return e.replace(Rr.escapeReplaceNoEncode,Wb);return e}function Kb(e){try{e=encodeURI(e).replace(Rr.percentDecode,"%")}catch{return null}return e}function Zb(e,t){var i;let n=e.replace(Rr.findPipe,(l,c,u)=>{let h=!1,p=c;for(;--p>=0&&u[p]==="\\";)h=!h;return h?"|":" |"}),r=n.split(Rr.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(Rr.slashPipe,"|");return r}function Xs(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 qb(e){let t=e.split(`
131
+ `),n=t.length-1;for(;n>=0&&Rr.blankLine.test(t[n]);)n--;return t.length-n<=2?e:t.slice(0,n+1).join(`
132
+ `)}function i5(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 a5(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 Gb(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,p=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=p;return}r.state.linkEmitted=!0}return{type:u?"image":"link",raw:n,href:i,title:l,text:c,tokens:m}}function l5(e,t,n){let r=e.match(n.other.indentCodeCompensation);if(r===null)return t;let o=r[1];return t.split(`
133
+ `).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(`
134
+ `)}var Vd=class{constructor(e){Dt(this,"options");Dt(this,"rules");Dt(this,"lexer");this.options=e||Qi}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]:qb(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=l5(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=Xs(n,"#");(this.options.pedantic||!r||this.rules.other.endingSpaceChar.test(r))&&(n=r.trim())}return{type:"heading",raw:Xs(t[0],`
135
+ `),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:Xs(t[0],`
136
+ `)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let n=Xs(t[0],`
137
+ `).split(`
138
+ `),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(`
139
+ `),p=h.replace(this.rules.other.blockquoteSetextReplace,`
140
+ $1`).replace(this.rules.other.blockquoteSetextReplace2,"");r=r?`${r}
141
+ ${h}`:h,o=o?`${o}
142
+ ${p}`:p;let m=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(p,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 y=g,w=n.join(`
143
+ `),b=y.raw+`
144
+ `+w.replace(this.rules.other.blockquoteSetextReplace2,""),E=this.blockquote(b);i[i.length-1]=E,r=`${r}
145
+ ${w}`,o=o.substring(0,o.length-y.text.length)+E.text;break}else if((g==null?void 0:g.type)==="list"){let y=g,w=y.raw+`
146
+ `+n.join(`
147
+ `),b=this.list(w);i[i.length-1]=b,r=r.substring(0,r.length-g.raw.length)+b.raw,o=o.substring(0,o.length-y.raw.length)+b.raw,n=w.substring(i.at(-1).raw.length).split(`
148
+ `);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="",p="";if(!(t=i.exec(e))||this.rules.block.hr.test(e))break;h=t[0],e=e.substring(h.length);let m=a5(t[2].split(`
149
+ `,1)[0],t[1].length),g=e.split(`
150
+ `,1)[0],y=!m.trim(),w=0;if(this.options.pedantic?(w=2,p=m.trimStart()):y?w=t[1].length+1:(w=m.search(this.rules.other.nonSpaceChar),w=w>4?1:w,p=m.slice(w),w+=t[1].length),y&&this.rules.other.blankLine.test(g)&&(h+=g+`
151
+ `,e=e.substring(g.length+1),u=!0),!u){let b=this.rules.other.nextBulletRegex(w),E=this.rules.other.hrRegex(w),_=this.rules.other.fencesBeginRegex(w),N=this.rules.other.headingBeginRegex(w),T=this.rules.other.htmlBeginRegex(w),R=this.rules.other.blockquoteBeginRegex(w);for(;e;){let O=e.split(`
152
+ `,1)[0],B;if(g=O,this.options.pedantic?(g=g.replace(this.rules.other.listReplaceNesting," "),B=g):B=g.replace(this.rules.other.tabCharGlobal," "),_.test(g)||N.test(g)||T.test(g)||R.test(g)||b.test(g)||E.test(g))break;if(B.search(this.rules.other.nonSpaceChar)>=w||!g.trim())p+=`
153
+ `+B.slice(w);else{if(y||m.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||_.test(m)||N.test(m)||E.test(m))break;p+=`
154
+ `+g}y=!g.trim(),h+=O+`
155
+ `,e=e.substring(O.length+1),m=B.slice(w)}}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(p),loose:!1,text:p,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"),p=h.length>0&&h.some(m=>this.rules.other.anyLine.test(m.raw));o.loose=p}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 p=this.rules.other.listTaskCheckbox.exec(u.raw);if(p){let m={type:"checkbox",raw:p[0]+" ",checked:p[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=qb(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:Xs(t[0],`
156
+ `),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=Zb(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(`
157
+ `):[],i={type:"table",raw:Xs(t[0],`
158
+ `),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(Zb(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:Xs(t[0],`
159
+ `),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)===`
160
+ `?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=Xs(n.slice(0,-1),"\\");if((n.length-i.length)%2===0)return}else{let i=i5(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)),Gb(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 Gb(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],p=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(p)break}if(c-=l,c>0)continue;l=Math.min(l,l+c+u);let g=[...r[0]][0].length,y=e.slice(0,o+r.index+g+l);if(Math.min(o,l)%2){let b=y.slice(1,-1);return{type:"em",raw:y,text:b,tokens:this.lexer.inlineTokens(b)}}let w=y.slice(2,-2);return{type:"strong",raw:y,text:w,tokens:this.lexer.inlineTokens(w)}}}}codespan(e){let t=this.rules.inline.code.exec(e);if(t){let n=t[2].replace(this.rules.other.newLineCharGlobal," "),r=this.rules.other.nonSpaceChar.test(n),o=this.rules.other.startingSpaceChar.test(n)&&this.rules.other.endingSpaceChar.test(n);return r&&o&&(n=n.substring(1,n.length-1)),{type:"codespan",raw:t[0],text:n}}}br(e){let t=this.rules.inline.br.exec(e);if(t)return{type:"br",raw:t[0]}}del(e,t,n=""){let r=this.rules.inline.delLDelim.exec(e);if(r&&(!r[1]||!n||this.rules.inline.punctuation.exec(n))){let o=[...r[0]].length-1,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,p=e.slice(0,o+r.index+h+l),m=p.slice(o,-o);return{type:"del",raw:p,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}}}},Ho=class Zm{constructor(t){Dt(this,"tokens");Dt(this,"options");Dt(this,"state");Dt(this,"inlineQueue");Dt(this,"tokenizer");this.tokens=[],this.tokens.links=Object.create(null),this.options=t||Qi,this.options.tokenizer=this.options.tokenizer||new Vd,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:Rr,block:pd.normal,inline:Ql.normal};this.options.pedantic?(n.block=pd.pedantic,n.inline=Ql.pedantic):this.options.gfm&&(n.block=pd.gfm,this.options.breaks?n.inline=Ql.breaks:n.inline=Ql.gfm),this.tokenizer.rules=n}static get rules(){return{block:pd,inline:Ql}}static lex(t,n){return new Zm(n).lex(t)}static lexInline(t,n){return new Zm(n).inlineTokens(t)}lex(t){t=t.replace(Rr.carriageReturn,`
161
+ `),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(Rr.tabCharGlobal," ").replace(Rr.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(p=>(u=p.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 p=n.at(-1);u.raw.length===1&&p!==void 0?p.raw+=`
162
+ `:n.push(u);continue}if(u=this.tokenizer.code(t)){t=t.substring(u.raw.length);let p=n.at(-1);(p==null?void 0:p.type)==="paragraph"||(p==null?void 0:p.type)==="text"?(p.raw+=(p.raw.endsWith(`
163
+ `)?"":`
164
+ `)+u.raw,p.text+=`
165
+ `+u.text,this.inlineQueue.at(-1).src=p.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 p=n.at(-1);(p==null?void 0:p.type)==="paragraph"||(p==null?void 0:p.type)==="text"?(p.raw+=(p.raw.endsWith(`
166
+ `)?"":`
167
+ `)+u.raw,p.text+=`
168
+ `+u.raw,this.inlineQueue.at(-1).src=p.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 p=1/0,m=t.slice(1),g;this.options.extensions.startBlock.forEach(y=>{g=y.call({lexer:this},m),typeof g=="number"&&g>=0&&(p=Math.min(p,g))}),p<1/0&&p>=0&&(h=t.substring(0,p+1))}if(this.state.top&&(u=this.tokenizer.paragraph(h))){let p=n.at(-1);r&&(p==null?void 0:p.type)==="paragraph"?(p.raw+=(p.raw.endsWith(`
169
+ `)?"":`
170
+ `)+u.raw,p.text+=`
171
+ `+u.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=p.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 p=n.at(-1);(p==null?void 0:p.type)==="text"?(p.raw+=(p.raw.endsWith(`
172
+ `)?"":`
173
+ `)+u.raw,p.text+=`
174
+ `+u.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=p.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,p,m;this.tokenizer.lexer=this;let r=t;if(this.tokens.links&&t.includes("[")){let g=this.tokenizer.rules.inline.reflinkSearch,y=w=>{let b=w.lastIndexOf("[");if(!Object.hasOwn(this.tokens.links,w.slice(b+1,-1)))return w;if(b>1&&w.charAt(0)!=="!"){let E=w.slice(1,b-1);if(this.linkInText(E))return"["+E.replace(g,y)+"]["+"a".repeat(w.length-b-2)+"]"}return"["+"a".repeat(w.length-2)+"]"};r=r.replace(g,y)}r=r.replace(this.tokenizer.rules.inline.anyPunctuation,g=>"+".repeat(g.length)),r=r.replace(this.tokenizer.rules.inline.blockSkip,(g,y,w)=>{let b=w?w.length:0;return g.slice(0,b)+"["+"a".repeat(g.length-b-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((p=(h=this.options.extensions)==null?void 0:h.inline)!=null&&p.some(w=>(g=w.call({lexer:this},t,n))?(t=t.substring(g.raw.length),n.push(g),!0):!1))continue;if(g=this.tokenizer.escape(t)){t=t.substring(g.raw.length),n.push(g);continue}if(g=this.tokenizer.tag(t)){t=t.substring(g.raw.length),n.push(g);continue}if(g=this.tokenizer.link(t)){t=t.substring(g.raw.length),n.push(g);continue}if(g=this.tokenizer.reflink(t,this.tokens.links)){t=t.substring(g.raw.length);let w=n.at(-1);g.type==="text"&&(w==null?void 0:w.type)==="text"?(w.raw+=g.raw,w.text+=g.text):n.push(g);continue}if(g=this.tokenizer.emStrong(t,r,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 y=t;if((m=this.options.extensions)!=null&&m.startInline){let w=1/0,b=t.slice(1),E;this.options.extensions.startInline.forEach(_=>{E=_.call({lexer:this},b),typeof E=="number"&&E>=0&&(w=Math.min(w,E))}),w<1/0&&w>=0&&(y=t.substring(0,w+1))}if(g=this.tokenizer.inlineText(y)){t=t.substring(g.raw.length),g.raw.slice(-1)!=="_"&&(i=g.raw.slice(-1)),o=!0;let w=n.at(-1);(w==null?void 0:w.type)==="text"?(w.raw+=g.raw,w.text+=g.text):n.push(g);continue}if(t){this.infiniteLoopError(t.charCodeAt(0));break}}return n}infiniteLoopError(t){let n="Infinite loop on byte: "+t;if(this.options.silent)console.error(n);else throw new Error(n)}},Yd=class{constructor(e){Dt(this,"options");Dt(this,"parser");this.options=e||Qi}space(e){return""}code({text:e,lang:t,escaped:n}){var i;let r=(i=(t||"").match(Rr.notSpaceStart))==null?void 0:i[0],o=e.replace(Rr.endingNewline,"")+`
175
+ `;return r?'<pre><code class="language-'+ts(r)+'">'+(n?o:ts(o,!0))+`</code></pre>
176
+ `:"<pre><code>"+(n?o:ts(o,!0))+`</code></pre>
177
+ `}blockquote({tokens:e}){return`<blockquote>
178
+ ${this.parser.parse(e)}</blockquote>
179
+ `}html({text:e}){return e}def(e){return""}heading({tokens:e,depth:t}){return`<h${t}>${this.parser.parseInline(e)}</h${t}>
180
+ `}hr(e){return`<hr>
181
+ `}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+`>
182
+ `+r+"</"+o+`>
183
+ `}listitem(e){return`<li>${this.parser.parse(e.tokens)}</li>
184
+ `}checkbox({checked:e}){return"<input "+(e?'checked="" ':"")+'disabled="" type="checkbox"> '}paragraph({tokens:e}){return`<p>${this.parser.parseInline(e)}</p>
185
+ `}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>
186
+ <thead>
187
+ `+t+`</thead>
188
+ `+r+`</table>
189
+ `}tablerow({text:e}){return`<tr>
190
+ ${e}</tr>
191
+ `}tablecell(e){let t=this.parser.parseInline(e.tokens),n=e.header?"th":"td";return(e.align?`<${n} align="${e.align}">`:`<${n}>`)+t+`</${n}>
192
+ `}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>${ts(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=Kb(e);if(o===null)return r;e=o;let i='<a href="'+e+'"';return t&&(i+=' title="'+ts(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=Kb(e);if(o===null)return ts(n);e=o;let i=`<img src="${e}" alt="${ts(n)}"`;return t&&(i+=` title="${ts(t)}"`),i+=">",i}text(e){return"tokens"in e&&e.tokens?this.parser.parseInline(e.tokens):"escaped"in e&&e.escaped?e.text:ts(e.text)}},Fk=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}},Wo=class qm{constructor(t){Dt(this,"options");Dt(this,"renderer");Dt(this,"textRenderer");this.options=t||Qi,this.options.renderer=this.options.renderer||new Yd,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Fk}static parse(t,n){return new qm(n).parse(t)}static parseInline(t,n){return new qm(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}},yd,oc=(yd=class{constructor(e){Dt(this,"options");Dt(this,"block");this.options=e||Qi}preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(e=this.block){return e?Ho.lex:Ho.lexInline}provideParser(e=this.block){return e?Wo.parse:Wo.parseInline}},Dt(yd,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens","emStrongMask"])),Dt(yd,"passThroughHooksRespectAsync",new Set(["preprocess","postprocess","processAllTokens"])),yd),c5=class{constructor(...e){Dt(this,"defaults",$k());Dt(this,"options",this.setOptions);Dt(this,"parse",this.parseMarkdown(!0));Dt(this,"parseInline",this.parseMarkdown(!1));Dt(this,"Parser",Wo);Dt(this,"Renderer",Yd);Dt(this,"TextRenderer",Fk);Dt(this,"Lexer",Ho);Dt(this,"Tokenizer",Vd);Dt(this,"Hooks",oc);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 Yd(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 p=c.apply(o,h);return p===!1&&(p=u.apply(o,h)),p||""}}r.renderer=o}if(n.tokenizer){let o=this.defaults.tokenizer||new Vd(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 p=c.apply(o,h);return p===!1&&(p=u.apply(o,h)),p}}r.tokenizer=o}if(n.hooks){let o=this.defaults.hooks||new oc;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];oc.passThroughHooks.has(i)?o[l]=h=>{if(this.defaults.async&&oc.passThroughHooksRespectAsync.has(i))return(async()=>{let m=await c.call(o,h);return u.call(o,m)})();let p=c.call(o,h);return u.call(o,p)}: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 p=c.apply(o,h);return p===!1&&(p=u.apply(o,h)),p}}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 Ho.lex(e,t??this.defaults)}parser(e,t){return Wo.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?Ho.lex:Ho.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?Wo.parse:Wo.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?Ho.lex:Ho.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?Wo.parse:Wo.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+=`
193
+ Please report this to https://github.com/markedjs/marked.`,e){let r="<p>An error occurred:</p><pre>"+ts(n.message+"",!0)+"</pre>";return t?Promise.resolve(r):r}if(t)return Promise.reject(n);throw n}}},Vi=new c5;function En(e,t){return Vi.parse(e,t)}En.options=En.setOptions=function(e){return Vi.setOptions(e),En.defaults=Vi.defaults,dS(En.defaults),En};En.getDefaults=$k;En.defaults=Qi;function u5(...e){return Vi.use(...e),En.defaults=Vi.defaults,dS(En.defaults),En}En.use=u5;En.walkTokens=function(e,t){return Vi.walkTokens(e,t)};En.parseInline=Vi.parseInline;En.Parser=Wo;En.parser=Wo.parse;En.Renderer=Yd;En.TextRenderer=Fk;En.Lexer=Ho;En.lexer=Ho.lex;En.Tokenizer=Vd;En.Hooks=oc;En.parse=En;En.options;En.setOptions;En.walkTokens;En.parseInline;Wo.parse;Ho.lex;const Xd=100,d5=e=>e.type==="text-delta"||e.type==="thinking-delta"||e.type==="tool-delta";function f5(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 h5={now:()=>performance.now(),after:(e,t)=>void setTimeout(t,e)};function p5(e,t=h5){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"&&d5(l.event)){const c={...l,event:{...l.event}},u=t.now();if(n.length===0&&u-o>=Xd){o=u,e(c);return}const h=n[n.length-1];h&&f5(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+Xd-u),i));return}i(),e(l)}}const bS="#toyon-link-pending",m5=/!?\[([^[\]\n]*)(?:\]\(([^()\s]*))?$/;function g5(e){const t=e.lastIndexOf(`
194
+ `)+1,n=e.slice(t),r=m5.exec(n);return!r||k5(e.slice(0,t))||w5(n.slice(0,r.index))?e:`${e.slice(0,t)}${n.slice(0,r.index)}[${r[1]}](${bS})`}function k5(e){let t=!1;for(const n of e.split(`
195
+ `))/^\s*(```|~~~)/.test(n)&&(t=!t);return t}function w5(e){let t=0;for(const n of e)n==="`"&&t++;return t%2===1}const qp="__[a-z][a-z0-9_]*[a-z0-9]__",y5=new RegExp(`^(?:${qp}\\.)+${qp}|^${qp}(?=\\.\\w|\\(|["'])`),v5={name:"dunder",level:"inline",start:e=>e.indexOf("__"),tokenizer(e){const t=y5.exec(e);if(t)return{type:"dunder",raw:t[0],text:t[0]}},renderer:e=>e.text};function b5(e){if(e.header.some(n=>n.text.trim()))return!1;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>
196
+ <tbody>${t}</tbody></table>
197
+ `}function x5(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:/'/},p={match:/\\'/},m={begin:/\$?\(\(/,end:/\)\)/,contains:[{begin:/\d+#[0-9a-f]+/,className:"number"},e.NUMBER_MODE,n]},g=["fish","bash","zsh","sh","csh","ksh","tcsh","dash","scsh"],y=e.SHEBANG({binary:`(${g.join("|")})`,relevance:10}),w={className:"function",begin:/\w[\w\d_]*\s*\(\s*\)\s*\{/,returnBegin:!0,contains:[e.inherit(e.TITLE_MODE,{begin:/\w[\w\d_]*/})],relevance:0},b=["if","then","else","elif","fi","time","for","while","until","in","do","done","case","esac","coproc","function","select"],E=["true","false"],_={match:/(\/[a-z._-]+)+/},N=["break","cd","continue","eval","exec","exit","export","getopts","hash","pwd","readonly","return","shift","test","times","trap","umask","unset"],T=["alias","bind","builtin","caller","command","declare","echo","enable","help","let","local","logout","mapfile","printf","read","readarray","source","sudo","type","typeset","ulimit","unalias"],R=["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"],O=["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:b,literal:E,built_in:[...N,...T,"set","shopt",...R,...O]},contains:[y,e.SHEBANG(),w,m,i,l,_,c,u,h,p,n]}}const E5=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_-]*/}}),_5=["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"],S5=["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"],N5=[..._5,...S5],T5=["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(),j5=["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(),C5=["after","backdrop","before","cue","cue-region","first-letter","first-line","grammar-error","marker","part","placeholder","selection","slotted","spelling-error"].sort().reverse(),A5=["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 I5(e){const t=e.regex,n=E5(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:":("+j5.join("|")+")"},{begin:":(:)?("+C5.join("|")+")"}]},n.CSS_VARIABLE,{className:"attribute",begin:"\\b("+A5.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:T5.join(" ")},contains:[{begin:/[a-z-]+(?=:)/,className:"attribute"},...c,n.CSS_NUMBER_MODE]}]},{className:"selector-tag",begin:"\\b("+N5.join("|")+")\\b"}]}}function R5(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 $5(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=/"(\\"|[^"])*"/,p=/'[^']*'/,m=t.either(u,h,p),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 Vb="[A-Za-z$_][0-9A-Za-z$_]*",O5=["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"],M5=["true","false","null","undefined","NaN","Infinity"],xS=["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"],ES=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],_S=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],L5=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","self","global"],P5=[].concat(_S,xS,ES);function D5(e){const t=e.regex,n=(M,{after:oe})=>{const ne="</"+M[0].slice(1);return M.input.indexOf(ne,oe)!==-1},r=Vb,o={begin:"<>",end:"</>"},i=/<[A-Za-z0-9\\._:-]+\s*\/>/,l={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(M,oe)=>{const ne=M[0].length+M.index,H=M.input[ne];if(H==="<"||H===","){oe.ignoreMatch();return}H===">"&&(n(M,{after:ne})||oe.ignoreMatch());let se;const ie=M.input.substring(ne);if(se=ie.match(/^\s*=/)){oe.ignoreMatch();return}if((se=ie.match(/^\s+extends\s+/))&&se.index===0){oe.ignoreMatch();return}}},c={$pattern:Vb,keyword:O5,literal:M5,built_in:P5,"variable.language":L5},u="[0-9](_?[0-9])*",h=`\\.(${u})`,p="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",m={className:"number",variants:[{begin:`(\\b(${p})((${h})|\\.)?|(${h}))[eE][+-]?(${u})\\b`},{begin:`\\b(${p})\\b((${h})\\b|\\.)?|(${h})\\b`},{begin:"\\b(0|[1-9](_?[0-9])*)n\\b"},{begin:"\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*n?\\b"},{begin:"\\b0[bB][0-1](_?[0-1])*n?\\b"},{begin:"\\b0[oO][0-7](_?[0-7])*n?\\b"},{begin:"\\b0[0-7]+n?\\b"}],relevance:0},g={className:"subst",begin:"\\$\\{",end:"\\}",keywords:c,contains:[]},y={begin:".?html`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,g],subLanguage:"xml"}},w={begin:".?css`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,g],subLanguage:"css"}},b={begin:".?gql`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,g],subLanguage:"graphql"}},E={className:"string",begin:"`",end:"`",contains:[e.BACKSLASH_ESCAPE,g]},N={className:"comment",variants:[e.COMMENT(/\/\*\*(?!\/)/,"\\*/",{relevance:0,contains:[{begin:"(?=@[A-Za-z]+)",relevance:0,contains:[{className:"doctag",begin:"@[A-Za-z]+"},{className:"type",begin:"\\{",end:"\\}",excludeEnd:!0,excludeBegin:!0,relevance:0},{className:"variable",begin:r+"(?=\\s*(-)|$)",endsParent:!0,relevance:0},{begin:/(?=[^\n])\s/,relevance:0}]}]}),e.C_BLOCK_COMMENT_MODE,e.C_LINE_COMMENT_MODE]},T=[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,y,w,b,E,{match:/\$\d+/},m];g.contains=T.concat({begin:/\{/,end:/\}/,keywords:c,contains:["self"].concat(T)});const R=[].concat(N,g.contains),O=R.concat([{begin:/(\s*)\(/,end:/\)/,keywords:c,contains:["self"].concat(R)}]),B={className:"params",begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:c,contains:O},$={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"}}]},C={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:{_:[...xS,...ES]}},j={label:"use_strict",className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},D={variants:[{match:[/function/,/\s+/,r,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:"keyword",3:"title.function"},label:"func.def",contains:[B],illegal:/%/},z={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"};function X(M){return t.concat("(?!",M.join("|"),")")}const ae={match:t.concat(/\b/,X([..._S,"super","import","await"].map(M=>`${M}\\s*\\(`)),r,t.lookahead(/\s*\(/)),className:"title.function",relevance:0},A={begin:t.concat(/\./,t.lookahead(t.concat(r,/(?![0-9A-Za-z$_(])/))),end:r,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},de={match:[/get|set/,/\s+/,r,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},B]},ue="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+e.UNDERSCORE_IDENT_RE+")\\s*=>",J={match:[/const|var|let/,/\s+/,r,/\s*/,/=\s*/,/(async\s*)?/,t.lookahead(ue)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[B]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:c,exports:{PARAMS_CONTAINS:O,CLASS_REFERENCE:C},illegal:/#(?![$_A-Za-z])/,contains:[e.SHEBANG({label:"shebang",binary:"node",relevance:5}),j,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,y,w,b,E,N,{match:/\$\d+/},m,C,{scope:"attr",match:r+t.lookahead(":"),relevance:0},J,{begin:"("+e.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",relevance:0,contains:[N,e.REGEXP_MODE,{className:"function",begin:ue,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:O}]}]},{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"]}]}]},D,{beginKeywords:"while if switch catch for"},{begin:"\\b(?!function)"+e.UNDERSCORE_IDENT_RE+"\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",returnBegin:!0,label:"func.def",contains:[B,e.inherit(e.TITLE_MODE,{begin:r,className:"title.function"})]},{match:/\.\.\./,relevance:0},A,{match:"\\$"+r,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[B]},ae,z,$,de,{match:/\$[(.]/}]}}const z5="([-+]?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)|NaN|[-+]?Infinity",F5={scope:"number",match:z5,relevance:0};function B5(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,F5,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE],illegal:"\\S"}}function U5(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}/}]},p={className:"emphasis",contains:[],variants:[{begin:/\*(?![*\s])/,end:/\*/},{begin:/_(?![_\s])/,end:/_/,relevance:0}]},m=e.inherit(h,{contains:[]}),g=e.inherit(p,{contains:[]});h.contains.push(g),p.contains.push(m);let y=[n,u];return[h,p,m,g].forEach(_=>{_.contains=_.contains.concat(y)}),y=y.concat(h,p),{name:"Markdown",aliases:["md","mkdown","mkd"],contains:[{className:"section",variants:[{begin:"^#{1,6}",end:"$",contains:y},{begin:"(?=^.+?\\n[=-]{2,}$)",contains:[{begin:"^[=-]*$"},{begin:"^",end:"\\n",contains:y}]}]},n,i,r,h,p,{className:"quote",begin:"^>\\s+",contains:y,end:"$"},o,u,l,{scope:"literal",match:/&([a-zA-Z0-9]+|#[0-9]{1,7}|#[Xx][0-9a-fA-F]{1,6});/}]}}function H5(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:/#/},p={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,p,h]},{begin:/([fFtT][rR]|[rR][fFtT]|[fFtT])"""/,end:/"""/,contains:[e.BACKSLASH_ESCAPE,u,p,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,p,h]},{begin:/([fFtT][rR]|[rR][fFtT]|[fFtT])"/,end:/"/,contains:[e.BACKSLASH_ESCAPE,p,h]},e.APOS_STRING_MODE,e.QUOTE_STRING_MODE]},g="[0-9](_?[0-9])*",y=`(\\b(${g}))?\\.(${g})|\\b(${g})\\.`,w=`\\b|${r.join("|")}`,b={className:"number",relevance:0,variants:[{begin:`(\\b(${g})|(${y}))[eE][+-]?(${g})[jJ]?(?=${w})`},{begin:`(${y})[jJ]?`},{begin:`\\b([1-9](_?[0-9])*|0+(_?0)*)[lLjJ]?(?=${w})`},{begin:`\\b0[bB](_?[01])+[lL]?(?=${w})`},{begin:`\\b0[oO](_?[0-7])+[lL]?(?=${w})`},{begin:`\\b0[xX](_?[0-9a-fA-F])+[lL]?(?=${w})`},{begin:`\\b(${g})[jJ](?=${w})`}]},E={className:"comment",begin:t.lookahead(/# type:/),end:/$/,keywords:c,contains:[{begin:/# type:/},{begin:/#/,end:/\b\B/,endsWithParent:!0}]},_={className:"params",variants:[{className:"",begin:/\(\s*\)/,skip:!0},{begin:/\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:c,contains:["self",u,b,m,e.HASH_COMMENT_MODE]}]};return h.contains=[m,b,u],{name:"Python",aliases:["py","gyp","ipython"],unicodeRegex:!0,keywords:c,illegal:/(<\/|\?)|=>/,contains:[u,b,{scope:"variable.language",match:/\bself\b/},{beginKeywords:"if",relevance:0},{match:/\bor\b/,scope:"keyword"},m,E,e.HASH_COMMENT_MODE,{match:[/\bdef/,/\s+/,n],scope:{1:"keyword",3:"title.function"},contains:[_]},{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:[b,_,m]}]}}function W5(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!"],p=["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:p,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:p}},{scope:"punctuation",begin:"->"},i]}}const Qd="[A-Za-z$_][0-9A-Za-z$_]*",SS=["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"],NS=["true","false","null","undefined","NaN","Infinity"],TS=["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"],jS=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],CS=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],AS=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","self","global"],IS=[].concat(CS,TS,jS);function K5(e){const t=e.regex,n=(M,{after:oe})=>{const ne="</"+M[0].slice(1);return M.input.indexOf(ne,oe)!==-1},r=Qd,o={begin:"<>",end:"</>"},i=/<[A-Za-z0-9\\._:-]+\s*\/>/,l={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(M,oe)=>{const ne=M[0].length+M.index,H=M.input[ne];if(H==="<"||H===","){oe.ignoreMatch();return}H===">"&&(n(M,{after:ne})||oe.ignoreMatch());let se;const ie=M.input.substring(ne);if(se=ie.match(/^\s*=/)){oe.ignoreMatch();return}if((se=ie.match(/^\s+extends\s+/))&&se.index===0){oe.ignoreMatch();return}}},c={$pattern:Qd,keyword:SS,literal:NS,built_in:IS,"variable.language":AS},u="[0-9](_?[0-9])*",h=`\\.(${u})`,p="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",m={className:"number",variants:[{begin:`(\\b(${p})((${h})|\\.)?|(${h}))[eE][+-]?(${u})\\b`},{begin:`\\b(${p})\\b((${h})\\b|\\.)?|(${h})\\b`},{begin:"\\b(0|[1-9](_?[0-9])*)n\\b"},{begin:"\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*n?\\b"},{begin:"\\b0[bB][0-1](_?[0-1])*n?\\b"},{begin:"\\b0[oO][0-7](_?[0-7])*n?\\b"},{begin:"\\b0[0-7]+n?\\b"}],relevance:0},g={className:"subst",begin:"\\$\\{",end:"\\}",keywords:c,contains:[]},y={begin:".?html`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,g],subLanguage:"xml"}},w={begin:".?css`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,g],subLanguage:"css"}},b={begin:".?gql`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,g],subLanguage:"graphql"}},E={className:"string",begin:"`",end:"`",contains:[e.BACKSLASH_ESCAPE,g]},N={className:"comment",variants:[e.COMMENT(/\/\*\*(?!\/)/,"\\*/",{relevance:0,contains:[{begin:"(?=@[A-Za-z]+)",relevance:0,contains:[{className:"doctag",begin:"@[A-Za-z]+"},{className:"type",begin:"\\{",end:"\\}",excludeEnd:!0,excludeBegin:!0,relevance:0},{className:"variable",begin:r+"(?=\\s*(-)|$)",endsParent:!0,relevance:0},{begin:/(?=[^\n])\s/,relevance:0}]}]}),e.C_BLOCK_COMMENT_MODE,e.C_LINE_COMMENT_MODE]},T=[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,y,w,b,E,{match:/\$\d+/},m];g.contains=T.concat({begin:/\{/,end:/\}/,keywords:c,contains:["self"].concat(T)});const R=[].concat(N,g.contains),O=R.concat([{begin:/(\s*)\(/,end:/\)/,keywords:c,contains:["self"].concat(R)}]),B={className:"params",begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:c,contains:O},$={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"}}]},C={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:{_:[...TS,...jS]}},j={label:"use_strict",className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},D={variants:[{match:[/function/,/\s+/,r,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:"keyword",3:"title.function"},label:"func.def",contains:[B],illegal:/%/},z={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"};function X(M){return t.concat("(?!",M.join("|"),")")}const ae={match:t.concat(/\b/,X([...CS,"super","import","await"].map(M=>`${M}\\s*\\(`)),r,t.lookahead(/\s*\(/)),className:"title.function",relevance:0},A={begin:t.concat(/\./,t.lookahead(t.concat(r,/(?![0-9A-Za-z$_(])/))),end:r,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},de={match:[/get|set/,/\s+/,r,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},B]},ue="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+e.UNDERSCORE_IDENT_RE+")\\s*=>",J={match:[/const|var|let/,/\s+/,r,/\s*/,/=\s*/,/(async\s*)?/,t.lookahead(ue)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[B]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:c,exports:{PARAMS_CONTAINS:O,CLASS_REFERENCE:C},illegal:/#(?![$_A-Za-z])/,contains:[e.SHEBANG({label:"shebang",binary:"node",relevance:5}),j,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,y,w,b,E,N,{match:/\$\d+/},m,C,{scope:"attr",match:r+t.lookahead(":"),relevance:0},J,{begin:"("+e.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",relevance:0,contains:[N,e.REGEXP_MODE,{className:"function",begin:ue,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:O}]}]},{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"]}]}]},D,{beginKeywords:"while if switch catch for"},{begin:"\\b(?!function)"+e.UNDERSCORE_IDENT_RE+"\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",returnBegin:!0,label:"func.def",contains:[B,e.inherit(e.TITLE_MODE,{begin:r,className:"title.function"})]},{match:/\.\.\./,relevance:0},A,{match:"\\$"+r,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[B]},ae,z,$,de,{match:/\$[(.]/}]}}function Z5(e){const t=e.regex,n=K5(e),r=Qd,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:Qd,keyword:SS.concat(u),literal:NS,built_in:IS.concat(o),"variable.language":AS},p={className:"meta",begin:"@"+r},m=(b,E,_)=>{const N=b.contains.findIndex(T=>T.label===E);if(N===-1)throw new Error("can not find mode to replace");b.contains.splice(N,1,_)};Object.assign(n.keywords,h),n.exports.PARAMS_CONTAINS.push(p);const g=n.contains.find(b=>b.scope==="attr"),y=Object.assign({},g,{match:t.concat(r,t.lookahead(/\s*\?:/))});n.exports.PARAMS_CONTAINS.push([n.exports.CLASS_REFERENCE,g,y]),n.contains=n.contains.concat([p,i,l,y]),m(n,"shebang",e.SHEBANG()),m(n,"use_strict",c);const w=n.contains.find(b=>b.label==="func.def");return w.relevance=0,Object.assign(n,{name:"TypeScript",aliases:["ts","tsx","mts","cts"]}),n}function q5(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 G5(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"},y={end:",",endsWithParent:!0,excludeEnd:!0,keywords:t,relevance:0},w={begin:/\{/,end:/\}/,contains:[y],illegal:"\\n",relevance:0},b={begin:"\\[",end:"\\]",contains:[y],illegal:"\\n",relevance:0},E=[r,{className:"meta",begin:"^---\\s*$",relevance:10},{className:"string",begin:"[\\|>]([1-9]?[+-])?[ ]*\\n( +)[^ ][^\\n]*\\n(\\2[^\\n]+\\n?)*"},{begin:"<%[%=-]?",end:"[%-]?%>",subLanguage:"ruby",excludeBegin:!0,excludeEnd:!0,relevance:0},{className:"type",begin:"!\\w+!"+n},{className:"type",begin:"!<"+n+">"},{className:"type",begin:"!"+n},{className:"type",begin:"!!"+n},{className:"meta",begin:"&"+e.UNDERSCORE_IDENT_RE+"$"},{className:"meta",begin:"\\*"+e.UNDERSCORE_IDENT_RE+"$"},{className:"bullet",begin:"-(?=[ ]|$)",relevance:0},e.HASH_COMMENT_MODE,{beginKeywords:t,keywords:{literal:t}},g,{className:"number",begin:e.C_NUMBER_RE+"\\b",relevance:0},w,b,i,l],_=[...E];return _.pop(),_.push(c),y.contains=_,{name:"YAML",case_insensitive:!0,aliases:["yml"],contains:E}}var Gp,Yb;function V5(){if(Yb)return Gp;Yb=1;function e(K){return K instanceof Map?K.clear=K.delete=K.set=function(){throw new Error("map is read-only")}:K instanceof Set&&(K.add=K.clear=K.delete=function(){throw new Error("set is read-only")}),Object.freeze(K),Object.getOwnPropertyNames(K).forEach(pe=>{const _e=K[pe],Xe=typeof _e;(Xe==="object"||Xe==="function")&&!Object.isFrozen(_e)&&e(_e)}),K}class t{constructor(pe){pe.data===void 0&&(pe.data={}),this.data=pe.data,this.isMatchIgnored=!1}ignoreMatch(){this.isMatchIgnored=!0}}function n(K){return K.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#x27;")}function r(K,...pe){const _e=Object.create(null);for(const Xe in K)_e[Xe]=K[Xe];return pe.forEach(function(Xe){for(const qe in Xe)_e[qe]=Xe[qe]}),_e}const o="</span>",i=K=>!!K.scope,l=(K,{prefix:pe})=>{if(K.startsWith("language:"))return K.replace("language:","language-");if(K.includes(".")){const _e=K.split(".");return[`${pe}${_e.shift()}`,..._e.map((Xe,qe)=>`${Xe}${"_".repeat(qe+1)}`)].join(" ")}return`${pe}${K}`};class c{constructor(pe,_e){this.buffer="",this.classPrefix=_e.classPrefix,pe.walk(this)}addText(pe){this.buffer+=n(pe)}openNode(pe){if(!i(pe))return;const _e=l(pe.scope,{prefix:this.classPrefix});this.span(_e)}closeNode(pe){i(pe)&&(this.buffer+=o)}value(){return this.buffer}span(pe){this.buffer+=`<span class="${pe}">`}}const u=(K={})=>{const pe={children:[]};return Object.assign(pe,K),pe};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(pe){this.top.children.push(pe)}openNode(pe){const _e=u({scope:pe});this.add(_e),this.stack.push(_e)}closeNode(){if(this.stack.length>1)return this.stack.pop()}closeAllNodes(){for(;this.closeNode(););}toJSON(){return JSON.stringify(this.rootNode,null,4)}walk(pe){return this.constructor._walk(pe,this.rootNode)}static _walk(pe,_e){return typeof _e=="string"?pe.addText(_e):_e.children&&(pe.openNode(_e),_e.children.forEach(Xe=>this._walk(pe,Xe)),pe.closeNode(_e)),pe}static _collapse(pe){typeof pe!="string"&&pe.children&&(pe.children.every(_e=>typeof _e=="string")?pe.children=[pe.children.join("")]:pe.children.forEach(_e=>{h._collapse(_e)}))}}class p extends h{constructor(pe){super(),this.options=pe}addText(pe){pe!==""&&this.add(pe)}startScope(pe){this.openNode(pe)}endScope(){this.closeNode()}__addSublanguage(pe,_e){const Xe=pe.root;_e&&(Xe.scope=`language:${_e}`),this.add(Xe)}toHTML(){return new c(this,this.options).value()}finalize(){return this.closeAllNodes(),!0}}function m(K){return K?typeof K=="string"?K:K.source:null}function g(K){return b("(?=",K,")")}function y(K){return b("(?:",K,")*")}function w(K){return b("(?:",K,")?")}function b(...K){return K.map(_e=>m(_e)).join("")}function E(K){const pe=K[K.length-1];return typeof pe=="object"&&pe.constructor===Object?(K.splice(K.length-1,1),pe):{}}function _(...K){return"("+(E(K).capture?"":"?:")+K.map(Xe=>m(Xe)).join("|")+")"}function N(K){return new RegExp(K.toString()+"|").exec("").length-1}function T(K,pe){const _e=K&&K.exec(pe);return _e&&_e.index===0}const R=/\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)|\\./;function O(K,{joinWith:pe}){let _e=0;return K.map(Xe=>{_e+=1;const qe=_e;let _t=m(Xe),Le="";for(;_t.length>0;){const $e=R.exec(_t);if(!$e){Le+=_t;break}Le+=_t.substring(0,$e.index),_t=_t.substring($e.index+$e[0].length),$e[0][0]==="\\"&&$e[1]?Le+="\\"+String(Number($e[1])+qe):(Le+=$e[0],$e[0]==="("&&_e++)}return Le}).map(Xe=>`(${Xe})`).join(pe)}const B=/\b\B/,$="[a-zA-Z]\\w*",C="[a-zA-Z_]\\w*",j="\\b\\d+(\\.\\d+)?",D="(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)",z="\\b(0b[01]+)",X="!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~",ae=(K={})=>{const pe=/^#![ ]*\//;return K.binary&&(K.begin=b(pe,/.*\b/,K.binary,/\b.*/)),r({scope:"meta",begin:pe,end:/$/,relevance:0,"on:begin":(_e,Xe)=>{_e.index!==0&&Xe.ignoreMatch()}},K)},A={begin:"\\\\[\\s\\S]",relevance:0},de={scope:"string",begin:"'",end:"'",illegal:"\\n",contains:[A]},ue={scope:"string",begin:'"',end:'"',illegal:"\\n",contains:[A]},J={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/},M=function(K,pe,_e={}){const Xe=r({scope:"comment",begin:K,end:pe,contains:[]},_e);Xe.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 qe=_("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 Xe.contains.push({begin:b(/[ ]+/,"(",qe,/[.]?[:]?([.][ ]|[ ])/,"){3}")}),Xe},oe=M("//","$"),ne=M("/\\*","\\*/"),H=M("#","$"),se={scope:"number",begin:j,relevance:0},ie={scope:"number",begin:D,relevance:0},he={scope:"number",begin:z,relevance:0},ge={scope:"regexp",begin:/\/(?=[^/\n]*\/)/,end:/\/[gimuy]*/,contains:[A,{begin:/\[/,end:/\]/,relevance:0,contains:[A]}]},Ie={scope:"title",begin:$,relevance:0},ke={scope:"title",begin:C,relevance:0},Q={begin:"\\.\\s*"+C,relevance:0};var te=Object.freeze({__proto__:null,APOS_STRING_MODE:de,BACKSLASH_ESCAPE:A,BINARY_NUMBER_MODE:he,BINARY_NUMBER_RE:z,COMMENT:M,C_BLOCK_COMMENT_MODE:ne,C_LINE_COMMENT_MODE:oe,C_NUMBER_MODE:ie,C_NUMBER_RE:D,END_SAME_AS_BEGIN:function(K){return Object.assign(K,{"on:begin":(pe,_e)=>{_e.data._beginMatch=pe[1]},"on:end":(pe,_e)=>{_e.data._beginMatch!==pe[1]&&_e.ignoreMatch()}})},HASH_COMMENT_MODE:H,IDENT_RE:$,MATCH_NOTHING_RE:B,METHOD_GUARD:Q,NUMBER_MODE:se,NUMBER_RE:j,PHRASAL_WORDS_MODE:J,QUOTE_STRING_MODE:ue,REGEXP_MODE:ge,RE_STARTERS_RE:X,SHEBANG:ae,TITLE_MODE:Ie,UNDERSCORE_IDENT_RE:C,UNDERSCORE_TITLE_MODE:ke});function Z(K,pe){K.input[K.index-1]==="."&&pe.ignoreMatch()}function je(K,pe){K.className!==void 0&&(K.scope=K.className,delete K.className)}function He(K,pe){pe&&K.beginKeywords&&(K.begin="\\b("+K.beginKeywords.split(" ").join("|")+")(?!\\.)(?=\\b|\\s)",K.__beforeBegin=Z,K.keywords=K.keywords||K.beginKeywords,delete K.beginKeywords,K.relevance===void 0&&(K.relevance=0))}function Fe(K,pe){Array.isArray(K.illegal)&&(K.illegal=_(...K.illegal))}function Pe(K,pe){if(K.match){if(K.begin||K.end)throw new Error("begin & end are not supported with match");K.begin=K.match,delete K.match}}function We(K,pe){K.relevance===void 0&&(K.relevance=1)}const Ht=(K,pe)=>{if(!K.beforeMatch)return;if(K.starts)throw new Error("beforeMatch cannot be used with starts");const _e=Object.assign({},K);Object.keys(K).forEach(Xe=>{delete K[Xe]}),K.keywords=_e.keywords,K.begin=b(_e.beforeMatch,g(_e.begin)),K.starts={relevance:0,contains:[Object.assign(_e,{endsParent:!0})]},K.relevance=0,delete _e.beforeMatch},ut=["of","and","for","in","not","or","if","then","parent","list","value"],vn="keyword";function Jt(K,pe,_e=vn){const Xe=Object.create(null);return typeof K=="string"?qe(_e,K.split(" ")):Array.isArray(K)?qe(_e,K):Object.keys(K).forEach(function(_t){Object.assign(Xe,Jt(K[_t],pe,_t))}),Xe;function qe(_t,Le){pe&&(Le=Le.map($e=>$e.toLowerCase())),Le.forEach(function($e){const Ge=$e.split("|");Xe[Ge[0]]=[_t,xt(Ge[0],Ge[1])]})}}function xt(K,pe){return pe?Number(pe):kt(K)?0:1}function kt(K){return ut.includes(K.toLowerCase())}const ot={},dt=K=>{console.error(K)},Tt=(K,...pe)=>{console.log(`WARN: ${K}`,...pe)},Et=(K,pe)=>{ot[`${K}/${pe}`]||(console.log(`Deprecated as of ${K}. ${pe}`),ot[`${K}/${pe}`]=!0)},dn=new Error;function G(K,pe,{key:_e}){let Xe=0;const qe=K[_e],_t={},Le={};for(let $e=1;$e<=pe.length;$e++)Le[$e+Xe]=qe[$e],_t[$e+Xe]=!0,Xe+=N(pe[$e-1]);K[_e]=Le,K[_e]._emit=_t,K[_e]._multi=!0}function ve(K){if(Array.isArray(K.begin)){if(K.skip||K.excludeBegin||K.returnBegin)throw dt("skip, excludeBegin, returnBegin not compatible with beginScope: {}"),dn;if(typeof K.beginScope!="object"||K.beginScope===null)throw dt("beginScope must be object"),dn;G(K,K.begin,{key:"beginScope"}),K.begin=O(K.begin,{joinWith:""})}}function tt(K){if(Array.isArray(K.end)){if(K.skip||K.excludeEnd||K.returnEnd)throw dt("skip, excludeEnd, returnEnd not compatible with endScope: {}"),dn;if(typeof K.endScope!="object"||K.endScope===null)throw dt("endScope must be object"),dn;G(K,K.end,{key:"endScope"}),K.end=O(K.end,{joinWith:""})}}function it(K){K.scope&&typeof K.scope=="object"&&K.scope!==null&&(K.beginScope=K.scope,delete K.scope)}function ft(K){it(K),typeof K.beginScope=="string"&&(K.beginScope={_wrap:K.beginScope}),typeof K.endScope=="string"&&(K.endScope={_wrap:K.endScope}),ve(K),tt(K)}function Gt(K){function pe(Le,$e){return new RegExp(m(Le),"m"+(K.case_insensitive?"i":"")+(K.unicodeRegex?"u":"")+($e?"g":""))}class _e{constructor(){this.matchIndexes={},this.regexes=[],this.matchAt=1,this.position=0}addRule($e,Ge){Ge.position=this.position++,this.matchIndexes[this.matchAt]=Ge,this.regexes.push([Ge,$e]),this.matchAt+=N($e)+1}compile(){this.regexes.length===0&&(this.exec=()=>null);const $e=this.regexes.map(Ge=>Ge[1]);this.matcherRe=pe(O($e,{joinWith:"|"}),!0),this.lastIndex=0}exec($e){this.matcherRe.lastIndex=this.lastIndex;const Ge=this.matcherRe.exec($e);if(!Ge)return null;const Wt=Ge.findIndex((Tn,In)=>In>0&&Tn!==void 0),Mt=this.matchIndexes[Wt];return Ge.splice(0,Wt),Object.assign(Ge,Mt)}}class Xe{constructor(){this.rules=[],this.multiRegexes=[],this.count=0,this.lastIndex=0,this.regexIndex=0}getMatcher($e){if(this.multiRegexes[$e])return this.multiRegexes[$e];const Ge=new _e;return this.rules.slice($e).forEach(([Wt,Mt])=>Ge.addRule(Wt,Mt)),Ge.compile(),this.multiRegexes[$e]=Ge,Ge}resumingScanAtSamePosition(){return this.regexIndex!==0}considerAll(){this.regexIndex=0}addRule($e,Ge){this.rules.push([$e,Ge]),Ge.type==="begin"&&this.count++}exec($e){const Ge=this.getMatcher(this.regexIndex);Ge.lastIndex=this.lastIndex;let Wt=Ge.exec($e);if(this.resumingScanAtSamePosition()&&!(Wt&&Wt.index===this.lastIndex)){const Mt=this.getMatcher(0);Mt.lastIndex=this.lastIndex+1,Wt=Mt.exec($e)}return Wt&&(this.regexIndex+=Wt.position+1,this.regexIndex===this.count&&this.considerAll()),Wt}}function qe(Le){const $e=new Xe;return Le.contains.forEach(Ge=>$e.addRule(Ge.begin,{rule:Ge,type:"begin"})),Le.terminatorEnd&&$e.addRule(Le.terminatorEnd,{type:"end"}),Le.illegal&&$e.addRule(Le.illegal,{type:"illegal"}),$e}function _t(Le,$e){const Ge=Le;if(Le.isCompiled)return Ge;[je,Pe,ft,Ht].forEach(Mt=>Mt(Le,$e)),K.compilerExtensions.forEach(Mt=>Mt(Le,$e)),Le.__beforeBegin=null,[He,Fe,We].forEach(Mt=>Mt(Le,$e)),Le.isCompiled=!0;let Wt=null;return typeof Le.keywords=="object"&&Le.keywords.$pattern&&(Le.keywords=Object.assign({},Le.keywords),Wt=Le.keywords.$pattern,delete Le.keywords.$pattern),Wt=Wt||/\w+/,Le.keywords&&(Le.keywords=Jt(Le.keywords,K.case_insensitive)),Ge.keywordPatternRe=pe(Wt,!0),$e&&(Le.begin||(Le.begin=/\B|\b/),Ge.beginRe=pe(Ge.begin),!Le.end&&!Le.endsWithParent&&(Le.end=/\B|\b/),Le.end&&(Ge.endRe=pe(Ge.end)),Ge.terminatorEnd=m(Ge.end)||"",Le.endsWithParent&&$e.terminatorEnd&&(Ge.terminatorEnd+=(Le.end?"|":"")+$e.terminatorEnd)),Le.illegal&&(Ge.illegalRe=pe(Le.illegal)),Le.contains||(Le.contains=[]),Le.contains=[].concat(...Le.contains.map(function(Mt){return An(Mt==="self"?Le:Mt)})),Le.contains.forEach(function(Mt){_t(Mt,Ge)}),Le.starts&&_t(Le.starts,$e),Ge.matcher=qe(Ge),Ge}if(K.compilerExtensions||(K.compilerExtensions=[]),K.contains&&K.contains.includes("self"))throw new Error("ERR: contains `self` is not supported at the top-level of a language. See documentation.");return K.classNameAliases=r(K.classNameAliases||{}),_t(K)}function Ft(K){return K?K.endsWithParent||Ft(K.starts):!1}function An(K){return K.variants&&!K.cachedVariants&&(K.cachedVariants=K.variants.map(function(pe){return r(K,{variants:null},pe)})),K.cachedVariants?K.cachedVariants:Ft(K)?r(K,{starts:K.starts?r(K.starts):null}):Object.isFrozen(K)?r(K):K}var qn="11.11.2";class zt extends Error{constructor(pe,_e){super(pe),this.name="HTMLInjectionError",this.html=_e}}const bn=n,ye=r,Me=Symbol("nomatch"),Bt=7,jt=function(K){const pe=Object.create(null),_e=Object.create(null),Xe=[];let qe=!0;const _t="Could not find the language '{}', did you forget to load/include a language module?",Le={disableAutodetect:!0,name:"Plain text",contains:[]};let $e={ignoreUnescapedHTML:!1,throwUnescapedHTML:!1,noHighlightRe:/^(no-?highlight)$/i,languageDetectRe:/\blang(?:uage)?-([\w-]+)\b/i,classPrefix:"hljs-",cssSelector:"pre code",languages:null,__emitter:p};function Ge(Ce){return $e.noHighlightRe.test(Ce)}function Wt(Ce){let Te=Ce.className+" ";Te+=Ce.parentNode?Ce.parentNode.className:"";const ht=$e.languageDetectRe.exec(Te);if(ht){const pt=yt(ht[1]);return pt||(Tt(_t.replace("{}",ht[1])),Tt("Falling back to no-highlight mode for this block.",Ce)),pt?ht[1]:"no-highlight"}return Te.split(/\s+/).find(pt=>Ge(pt)||yt(pt))}function Mt(Ce,Te,ht){let pt="",Zt="";typeof Te=="object"?(pt=Ce,ht=Te.ignoreIllegals,Zt=Te.language):(Et("10.7.0","highlight(lang, code, ...args) has been deprecated."),Et("10.7.0",`Please use highlight(code, options) instead.
198
+ https://github.com/highlightjs/highlight.js/issues/2277`),Zt=Ce,pt=Te),ht===void 0&&(ht=!0);const tn={code:pt,language:Zt};Mn("before:highlight",tn);const W=tn.result?tn.result:Tn(tn.language,tn.code,ht);return W.code=tn.code,Mn("after:highlight",W),W}function Tn(Ce,Te,ht,pt){const Zt=Object.create(null);function tn(F,re){return F.keywords[re]}function W(){if(!gt.keywords){hn.addText(rn);return}let F=0;gt.keywordPatternRe.lastIndex=0;let re=gt.keywordPatternRe.exec(rn),be="";for(;re;){be+=rn.substring(F,re.index);const Re=yr.case_insensitive?re[0].toLowerCase():re[0],Ke=tn(gt,Re);if(Ke){const[At,pn]=Ke;if(hn.addText(be),be="",Zt[Re]=(Zt[Re]||0)+1,Zt[Re]<=Bt&&(Dr+=pn),At.startsWith("_"))be+=re[0];else{const Gn=yr.classNameAliases[At]||At;mt(re[0],Gn)}}else be+=re[0];F=gt.keywordPatternRe.lastIndex,re=gt.keywordPatternRe.exec(rn)}be+=rn.substring(F),hn.addText(be)}function me(){if(rn==="")return;let F=null;if(typeof gt.subLanguage=="string"){if(!pe[gt.subLanguage]){hn.addText(rn);return}F=Tn(gt.subLanguage,rn,!0,Ao[gt.subLanguage]),Ao[gt.subLanguage]=F._top}else F=yn(rn,gt.subLanguage.length?gt.subLanguage:null);gt.relevance>0&&(Dr+=F.relevance),hn.__addSublanguage(F._emitter,F.language)}function Be(){gt.subLanguage!=null?me():W(),rn=""}function mt(F,re){F!==""&&(hn.startScope(re),hn.addText(F),hn.endScope())}function Ct(F,re){let be=1;const Re=re.length-1;for(;be<=Re;){if(!F._emit[be]){be++;continue}const Ke=yr.classNameAliases[F[be]]||F[be],At=re[be];Ke?mt(At,Ke):(rn=At,W(),rn=""),be++}}function Yt(F,re){return F.scope&&typeof F.scope=="string"&&hn.openNode(yr.classNameAliases[F.scope]||F.scope),F.beginScope&&(F.beginScope._wrap?(mt(rn,yr.classNameAliases[F.beginScope._wrap]||F.beginScope._wrap),rn=""):F.beginScope._multi&&(Ct(F.beginScope,re),rn="")),gt=Object.create(F,{parent:{value:gt}}),gt}function Ln(F,re,be){let Re=T(F.endRe,be);if(Re){if(F["on:end"]){const Ke=new t(F);F["on:end"](re,Ke),Ke.isMatchIgnored&&(Re=!1)}if(Re){for(;F.endsParent&&F.parent;)F=F.parent;return F}}if(F.endsWithParent)return Ln(F.parent,re,be)}function tr(F){return gt.matcher.regexIndex===0?(rn+=F[0],1):(L=!0,0)}function jo(F){const re=F[0],be=F.rule,Re=new t(be),Ke=[be.__beforeBegin,be["on:begin"]];for(const At of Ke)if(At&&(At(F,Re),Re.isMatchIgnored))return tr(re);return be.skip?rn+=re:(be.excludeBegin&&(rn+=re),Be(),!be.returnBegin&&!be.excludeBegin&&(rn=re)),Yt(be,F),be.returnBegin?0:re.length}function Sr(F){const re=F[0],be=Te.substring(F.index),Re=Ln(gt,F,be);if(!Re)return Me;const Ke=gt;gt.endScope&&gt.endScope._wrap?(Be(),mt(re,gt.endScope._wrap)):gt.endScope&&gt.endScope._multi?(Be(),Ct(gt.endScope,F)):Ke.skip?rn+=re:(Ke.returnEnd||Ke.excludeEnd||(rn+=re),Be(),Ke.excludeEnd&&(rn=re));do gt.scope&&hn.closeNode(),!gt.skip&&!gt.subLanguage&&(Dr+=gt.relevance),gt=gt.parent;while(gt!==Re.parent);return Re.starts&&Yt(Re.starts,F),Ke.returnEnd?0:re.length}function Cs(){const F=[];for(let re=gt;re!==yr;re=re.parent)re.scope&&F.unshift(re.scope);F.forEach(re=>hn.openNode(re))}let Lr={};function Pr(F,re){const be=re&&re[0];if(rn+=F,be==null)return Be(),0;if(Lr.type==="begin"&&re.type==="end"&&Lr.index===re.index&&be===""){if(rn+=Te.slice(re.index,re.index+1),!qe){const Re=new Error(`0 width match regex (${Ce})`);throw Re.languageName=Ce,Re.badRule=Lr.rule,Re}return 1}if(Lr=re,re.type==="begin")return jo(re);if(re.type==="illegal"&&!ht){const Re=new Error('Illegal lexeme "'+be+'" for mode "'+(gt.scope||"<unnamed>")+'"');throw Re.mode=gt,Re}else if(re.type==="end"){const Re=Sr(re);if(Re!==Me)return Re}if(re.type==="illegal"&&be==="")return re.index===Te.length||(rn+=`
199
+ `),1;if(Se>1e5&&Se>re.index*3)throw new Error("potential infinite loop, way more iterations than matches");return rn+=be,be.length}const yr=yt(Ce);if(!yr)throw dt(_t.replace("{}",Ce)),new Error('Unknown language: "'+Ce+'"');const Co=Gt(yr);let Je="",gt=pt||Co;const Ao={},hn=new $e.__emitter($e);Cs();let rn="",Dr=0,Yn=0,Se=0,L=!1;try{if(yr.__emitTokens)yr.__emitTokens(Te,hn);else{for(gt.matcher.considerAll();;){Se++,L?L=!1:gt.matcher.considerAll(),gt.matcher.lastIndex=Yn;const F=gt.matcher.exec(Te);if(!F)break;const re=Te.substring(Yn,F.index),be=Pr(re,F);Yn=F.index+be}Pr(Te.substring(Yn))}return hn.finalize(),Je=hn.toHTML(),{language:Ce,value:Je,relevance:Dr,illegal:!1,_emitter:hn,_top:gt}}catch(F){if(F.message&&F.message.includes("Illegal"))return{language:Ce,value:bn(Te),illegal:!0,relevance:0,_illegalBy:{message:F.message,index:Yn,context:Te.slice(Yn-100,Yn+100),mode:F.mode,resultSoFar:Je},_emitter:hn};if(qe)return{language:Ce,value:bn(Te),illegal:!1,relevance:0,errorRaised:F,_emitter:hn,_top:gt};throw F}}function In(Ce){const Te={value:bn(Ce),illegal:!1,relevance:0,_top:Le,_emitter:new $e.__emitter($e)};return Te._emitter.addText(Ce),Te}function yn(Ce,Te){Te=Te||$e.languages||Object.keys(pe);const ht=In(Ce),pt=Te.filter(yt).filter(ln).map(Be=>Tn(Be,Ce,!1));pt.unshift(ht);const Zt=pt.sort((Be,mt)=>{if(Be.relevance!==mt.relevance)return mt.relevance-Be.relevance;if(Be.language&&mt.language){if(yt(Be.language).supersetOf===mt.language)return 1;if(yt(mt.language).supersetOf===Be.language)return-1}return 0}),[tn,W]=Zt,me=tn;return me.secondBest=W,me}function wr(Ce,Te,ht){const pt=Te&&_e[Te]||ht;Ce.classList.add("hljs"),Ce.classList.add(`language-${pt}`)}function gn(Ce){let Te=null;const ht=Wt(Ce);if(Ge(ht))return;if(Mn("before:highlightElement",{el:Ce,language:ht}),Ce.dataset.highlighted){console.log("Element previously highlighted. To highlight again, first unset `dataset.highlighted`.",Ce);return}if(Ce.children.length>0&&($e.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(Ce)),$e.throwUnescapedHTML))throw new zt("One of your code blocks includes unescaped HTML.",Ce.innerHTML);Te=Ce;const pt=Te.textContent,Zt=ht?Mt(pt,{language:ht,ignoreIllegals:!0}):yn(pt);Ce.innerHTML=Zt.value,Ce.dataset.highlighted="yes",wr(Ce,ht,Zt.language),Ce.result={language:Zt.language,re:Zt.relevance,relevance:Zt.relevance},Zt.secondBest&&(Ce.secondBest={language:Zt.secondBest.language,relevance:Zt.secondBest.relevance}),Mn("after:highlightElement",{el:Ce,result:Zt,text:pt})}function Nn(Ce){$e=ye($e,Ce)}const ur=()=>{Kt(),Et("10.6.0","initHighlighting() deprecated. Use highlightAll() now.")};function nn(){Kt(),Et("10.6.0","initHighlightingOnLoad() deprecated. Use highlightAll() now.")}let en=!1;function Kt(){function Ce(){Kt()}if(document.readyState==="loading"){en||window.addEventListener("DOMContentLoaded",Ce,!1),en=!0;return}document.querySelectorAll($e.cssSelector).forEach(gn)}function V(Ce,Te){let ht=null;try{ht=Te(K)}catch(pt){if(dt("Language definition for '{}' could not be registered.".replace("{}",Ce)),qe)dt(pt);else throw pt;ht=Le}ht.name||(ht.name=Ce),pe[Ce]=ht,ht.rawDefinition=Te.bind(null,K),ht.aliases&&sn(ht.aliases,{languageName:Ce})}function Ee(Ce){delete pe[Ce];for(const Te of Object.keys(_e))_e[Te]===Ce&&delete _e[Te]}function Ze(){return Object.keys(pe)}function yt(Ce){return Ce=(Ce||"").toLowerCase(),pe[Ce]||pe[_e[Ce]]}function sn(Ce,{languageName:Te}){typeof Ce=="string"&&(Ce=[Ce]),Ce.forEach(ht=>{_e[ht.toLowerCase()]=Te})}function ln(Ce){const Te=yt(Ce);return Te&&!Te.disableAutodetect}function Vt(Ce){Ce["before:highlightBlock"]&&!Ce["before:highlightElement"]&&(Ce["before:highlightElement"]=Te=>{Ce["before:highlightBlock"](Object.assign({block:Te.el},Te))}),Ce["after:highlightBlock"]&&!Ce["after:highlightElement"]&&(Ce["after:highlightElement"]=Te=>{Ce["after:highlightBlock"](Object.assign({block:Te.el},Te))})}function dr(Ce){Vt(Ce),Xe.push(Ce)}function Mr(Ce){const Te=Xe.indexOf(Ce);Te!==-1&&Xe.splice(Te,1)}function Mn(Ce,Te){const ht=Ce;Xe.forEach(function(pt){pt[ht]&&pt[ht](Te)})}function Ot(Ce){return Et("10.7.0","highlightBlock will be removed entirely in v12.0"),Et("10.7.0","Please use highlightElement now."),gn(Ce)}Object.assign(K,{highlight:Mt,highlightAuto:yn,highlightAll:Kt,highlightElement:gn,highlightBlock:Ot,configure:Nn,initHighlighting:ur,initHighlightingOnLoad:nn,registerLanguage:V,unregisterLanguage:Ee,listLanguages:Ze,getLanguage:yt,registerAliases:sn,autoDetection:ln,inherit:ye,addPlugin:dr,removePlugin:Mr}),K.debugMode=function(){qe=!1},K.safeMode=function(){qe=!0},K.versionString=qn,K.regex={concat:b,lookahead:g,either:_,optional:w,anyNumberOfTimes:y};for(const Ce in te)typeof te[Ce]=="object"&&e(te[Ce]);return Object.assign(K,te),K},fn=jt({});return fn.newInstance=()=>jt({}),Gp=fn,fn.HighlightJS=fn,fn.default=fn,Gp}var Y5=V5();const X5=Ux(Y5),Xb={},Q5="hljs-";function J5(e){const t=X5.newInstance();return e&&i(e),{highlight:n,highlightAuto:r,listLanguages:o,register:i,registerAlias:l,registered:c};function n(u,h,p){const m=p||Xb,g=typeof m.prefix=="string"?m.prefix:Q5;if(!t.getLanguage(u))throw new Error("Unknown language: `"+u+"` is not registered");t.configure({__emitter:e6,classPrefix:g});const y=t.highlight(h,{ignoreIllegals:!0,language:u});if(y.errorRaised)throw new Error("Could not highlight with `Highlight.js`",{cause:y.errorRaised});const w=y._emitter.root,b=w.data;return b.language=y.language,b.relevance=y.relevance,w}function r(u,h){const m=(h||Xb).subset||o();let g=-1,y=0,w;for(;++g<m.length;){const b=m[g];if(!t.getLanguage(b))continue;const E=n(b,u,h);E.data&&E.data.relevance!==void 0&&E.data.relevance>y&&(y=E.data.relevance,w=E)}return w||{type:"root",children:[],data:{language:void 0,relevance:y}}}function o(){return t.listLanguages()}function i(u,h){if(typeof u=="string")t.registerLanguage(u,h);else{let p;for(p in u)Object.hasOwn(u,p)&&t.registerLanguage(p,u[p])}}function l(u,h){if(typeof u=="string")t.registerAliases(typeof h=="string"?h:[...h],{languageName:u});else{let p;for(p in u)if(Object.hasOwn(u,p)){const m=u[p];t.registerAliases(typeof m=="string"?m:[...m],{languageName:p})}}}function c(u){return!!t.getLanguage(u)}}class e6{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 RS=J5({bash:x5,css:I5,go:R5,ini:$5,javascript:D5,json:B5,markdown:U5,python:H5,rust:W5,typescript:Z5,xml:q5,yaml:G5}),Qb={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 Bk(e,t){const n=e&&(Qb[e]??(RS.registered(e)?e:null));if(n)return n;const r=t.lastIndexOf("."),o=r<0?"":t.slice(r+1).toLowerCase();return(o?Qb[o]:null)??null}const t6=/^(?:diff --git a\/\S+ b\/(\S+)|\+\+\+ (?:b\/)?(\S+))$/gm;function n6(e){const t=new Set;for(const n of e.matchAll(t6)){const r=n[1]??n[2]??"";r&&r!=="/dev/null"&&t.add(r)}return t.size===1?[...t][0]:""}const r6={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 $S(e,t){const n=[[]],r=(i,l)=>{const c=i.split(`
200
+ `);for(const[u,h]of c.entries()){if(u>0&&n.push([]),!h)continue;const p=n[n.length-1],m=p[p.length-1];m&&m.scope===l?m.text+=h:p.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,o6(c)??l)};try{o(RS.highlight(t,e).children,"")}catch{return e.split(`
201
+ `).map(i=>i?[{text:i,scope:""}]:[])}return n}function o6(e){var r;const t=((r=e.properties)==null?void 0:r.className)??[];let n=null;for(const o of t){const i=r6[o.startsWith("hljs-")?o.slice(5):o];i&&(n=i)}return n}const Jb=/^\d+\t/;function Uk(e,t){if(!t)return[];const n=e.split(`
202
+ `),r=Jb.test(n[0]??""),o=r?n.map(l=>{var c;return((c=Jb.exec(l))==null?void 0:c[0])??""}):[],i=r?n.map((l,c)=>l.slice(o[c].length)).join(`
203
+ `):e;return $S(i,t).map((l,c)=>{const u=l.map(p=>({text:p.text,changed:!1,scope:p.scope})),h=o[c];return h?[{text:h,changed:!1,scope:""},...u]:u})}function s6(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"||(i6(e,o,i,t,n),o=i+1)}}return e.map((o,i)=>a6(o.spans,n[i],o.text))}function i6(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(`
204
+ `),p=$S(h,r);for(const[m,g]of u.entries())(c==="add"||((l=e[g])==null?void 0:l.kind)==="del")&&(o[g]=p[m])}}function a6(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 p=o[l],m=i[c],g=Math.min(p.text.length-u,m.text.length-h);if(g>0){const y={text:p.text.slice(u,u+g),changed:p.changed,scope:m.scope},w=r[r.length-1];w&&w.changed===y.changed&&w.scope===y.scope?w.text+=y.text:r.push(y)}u+=g,h+=g,u>=p.text.length&&(l++,u=0),h>=m.text.length&&(c++,h=0)}return r}En.use({extensions:[v5],renderer:{code({text:e,lang:t}){const n=Bk((t??"").trim().toLowerCase().split(/\s+/)[0]??"","");return n?`<pre><code>${Uk(e,n).map(o=>o.map(i=>i.scope?`<span class="sy-${i.scope}">${ex(i.text)}</span>`:ex(i.text)).join("")).join(`
205
+ `)}</code></pre>
206
+ `:!1},table:b5}});const ex=e=>e.replace(/[&<>]/g,t=>t==="&"?"&amp;":t==="<"?"&lt;":"&gt;"),OS=h3(window);let bs=null;OS.addHook("afterSanitizeAttributes",e=>{const t=e.tagName==="A"?e.getAttribute("href")??"":"";if(t===bS){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=bs!=null&&bs.fileRoot?oS(bs.fileRoot,t):null,r=n?null:sS(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=Az(e.textContent??"");i&&e.setAttribute("data-path",i)}const o=bs==null?void 0:bs.base;if(e.tagName==="IMG"&&o){const i=Ck(o.dir,e.getAttribute("src")??"");i&&e.setAttribute("src",o.urls.worktreeFile(o.worktreeId,i,o.version))}});function Qa(e,t){bs=t??null;const n=t!=null&&t.streaming?g5(e):e;try{return OS.sanitize(En.parse(n,{async:!1}))}finally{bs=null}}function Hk(e,t){var m,g,y,w;const[n,r]=S.useState(()=>Qa(e,t)),o=S.useRef(0),i=(m=t==null?void 0:t.base)==null?void 0:m.worktreeId,l=(g=t==null?void 0:t.base)==null?void 0:g.dir,c=(y=t==null?void 0:t.base)==null?void 0:y.version,u=(w=t==null?void 0:t.base)==null?void 0:w.urls,h=t==null?void 0:t.fileRoot,p=t==null?void 0:t.streaming;return S.useEffect(()=>{const b=i!==void 0&&l!==void 0&&u!==void 0?{worktreeId:i,dir:l,version:c??null,urls:u}:void 0,E=b||h||p?{base:b,fileRoot:h,streaming:p}:void 0,_=performance.now()-o.current;if(_>=Xd){o.current=performance.now(),r(Qa(e,E));return}const N=setTimeout(()=>{o.current=performance.now(),r(Qa(e,E))},Xd-_);return()=>clearTimeout(N)},[e,i,l,c,u,h,p]),n}const l6=/^ {0,3}(`{3,}|~{3,})/,c6=/^#{1,6} \S/,u6=/^\s*(?:[-*+]|\d+[.)]) \S/,d6=/^> ?\S/,f6=/^\s*\|?\s*:?-{3,}:?\s*(?:\|\s*:?-{3,}:?\s*)+\|?\s*$/,h6=/\[[^\]\n]+\]\((?:https?:|\.{0,2}\/|#)[^)\s]*\)/,p6=/\*\*[^\s*][^*\n]*\*\*/;function m6(e){var i,l;const t=e.split(`
207
+ `),n=new Set;let r=null,o=0;for(let c=0;c<t.length;c++){const u=t[c],h=(i=l6.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}c6.test(u)&&!((l=t[c+1])!=null&&l.trim())&&n.add("heading"),u6.test(u)&&++o===2&&n.add("list"),d6.test(u)&&n.add("quote"),f6.test(u)&&n.add("table"),h6.test(u)&&n.add("link"),p6.test(u)&&n.add("bold")}return n.size}function g6(e,t){if(t)return Ef(t)==="markdown"?"rendered":"plain";const n=m6(e);return n>=2?"rendered":n===1?"source":"plain"}function Wk({n:e,name:t,source:n,lines:r,chars:o,preview:i,text:l,href:c,onRemove:u,className:h=""}){const p=(n==null?void 0:n.path)??t??"",m=p.includes("/")?p.slice(0,p.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(" · "),y=d.jsxs(d.Fragment,{children:[d.jsx(Nt,{name:"text",className:"icon-inline"}),d.jsxs("span",{className:"pick-target",children:[d.jsx("b",{children:t?t.slice(t.lastIndexOf("/")+1):n?d2(n):Yx("paste",e)}),g&&d.jsxs("span",{className:"pick-file row-dim",children:[" · ",g]})]})]}),w=l!==void 0||c!==void 0;return d.jsx(Rk,{className:Ue("paste-chip",h),label:y,tip:i||void 0,peek:w?d.jsx(PS,{text:l,href:c}):void 0,full:w?d.jsx(LS,{text:l,href:c,path:p||void 0}):void 0,menu:b=>tS({text:l,href:c},b),removeLabel:"Remove attachment",onRemove:u})}function MS(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 LS({text:e,href:t,path:n}){const{text:r,failed:o}=MS(e,t),i=S.useMemo(()=>r?g6(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(ze,{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(Nt,{name:u?"text":"book",className:"icon-inline"})," ",u?"text":"preview"]})}),u?d.jsx(k6,{text:r}):d.jsx("pre",{className:"paste-doc-body paste-text",children:r})]})}function k6({text:e}){const t=S.useMemo(()=>Qa(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 w6=2e4;function PS({text:e,href:t}){const{text:n}=MS(e,t);return n?d.jsx("pre",{className:"paste-peek paste-text",children:n.slice(0,w6)}):null}function Kk({name:e,bytes:t,href:n,uploading:r,progress:o,onRemove:i,className:l=""}){return d.jsx(Rk,{className:Ue("file-chip",l),label:d.jsxs(d.Fragment,{children:[d.jsx(Nt,{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:[" ","· ",bg(t),o!==void 0?d.jsxs(d.Fragment,{children:[" ","· ",d.jsxs("span",{className:"pick-progress",children:[o,"%"]})]}):r&&" · uploading"]})]})]}),tip:e,peek:n?d.jsx(PS,{href:n}):void 0,full:n?d.jsx(LS,{href:n,path:e}):void 0,menu:c=>tS({href:n},c),removeLabel:"Remove attachment",onRemove:i})}function DS(e){return e.replace(/^([\t ]*)\*\*(\S(?:[^\n]*\S)?)\*\*([\t ]*)$/gm,"$1$2$3")}const zS=120,y6=/^\*\*(\S(?:[^\n]*\S)?)\*\*$/;function FS(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=y6.exec(i))==null?void 0:n[1])==null?void 0:r.replace(/`/g,""))??"";if(!l||l.length>zS)return[];t.push(l)}return t}function BS(e){const t=FS(e);if(t.length)return t.at(-1);const n=DS(e).trim().replace(/`/g,"");return n&&!n.includes(`
208
+ `)&&n.length<=zS?n:""}const v6={read:"read",edit:"edit",delete:"delete",move:"move",search:"search",execute:"run",think:"think",fetch:"fetch",switch_mode:"mode",other:"tool"},tx={read:"book",edit:"edit",delete:"trash",move:"move",search:"search",execute:"run",think:"bulb",fetch:"globe",switch_mode:"swap",other:"dot"},US="Skill",Vp=new Map([[mg,"chat"],["Monitor","clock"],["TaskOutput","terminal"],[US,"layers"],[Kx,"globe"]]);function b6(e){if(e.name!==US)return"";const t=fo(e,"skill").trim();if(!t)return"";const n=fo(e,"args").trim();return n?`/${t} ${n}`:`/${t}`}const Gm={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"},x6=/(^|\s)(-[A-Za-z]*[iI]|--in-place)/,nx=String.raw`(?:"[^"]*"|'[^']*'|[^\s;&|]+)`,rx=new RegExp(String.raw`^\s*(?:(?:cd|echo)\s+${nx}\s*(?:&&|;)|mkdir(?:\s+${nx})+\s*(?:&&|;)|(?:export\s+)?[A-Za-z_]\w*=(?:"[^"]*"|'[^']*'|[^\s;&|()\`]*)\s*(?:&&|;|(?=\s)))\s*`),E6=/^python[\d.]*$/,_6=new RegExp(`open\\([^)]*,\\s*["'][wax]|(?<!std(?:out|err))\\.write\\(|\\.write_text\\(`);function HS(e){let t=e;for(let n=t.replace(rx,"");n!==t;n=t.replace(rx,""))t=n;return t}const S6=new RegExp("(?<![0-9&])>{1,2}\\s*(?!\\/dev\\/null|&)[^\\s&>]"),WS=/&&|;|\n|\|/;function N6(e){return e.split(WS).some(t=>/^\s*(?:\S*\/)?sed\s/.test(t)&&x6.test(t))}function T6(e){return e.split(/&&|;|\n/).map(t=>HS(t).trim().split(/\s+/)[0]??"").filter(Boolean).every(t=>Gm[t.slice(t.lastIndexOf("/")+1)]==="trash")}function j6(e){const t=HS(e).trim(),n=t.split(/\s+/)[0]??"",r=n.slice(n.lastIndexOf("/")+1),o=r==="sed"?N6(e)?void 0:"book":Gm[r];if(o==="book"||o==="search"){const i=t.split(WS)[0]??"";if(S6.test(i))return r==="cat"&&i.includes("<<")?"edit":void 0}if(!(o==="trash"&&!T6(t)))return o||(E6.test(r)?t.includes("<<")&&_6.test(t)?"edit":void 0:Gm[r])}function fo(e,t){const n=e.input,r=n?n[t]:void 0;return typeof r=="string"?r:""}const C6=/^(?:\/(?:usr\/)?bin\/)?(?:ba|z|da)?sh\s+(?:-[a-zA-Z]+\s+)*(?:'([^']*)'|"((?:[^"\\]|\\.)*)")\s*$/;function KS(e){const t=C6.exec(e.trim());return t?t[1]!==void 0?t[1]:(t[2]??"").replace(/\\(["\\$`])/g,"$1"):e}const A6="Guardian Review";function ZS(e){return e.toolKind==="think"&&e.title===A6}function I6(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 Ac(e,t=[]){const n=KS(fo(e,"command")),o=qS(e)||n||fo(e,"path")||fo(e,"pattern")||b6(e)||(e.title&&e.title!==e.name?e.title:""),i=Zk(fo(e,"description")||o,t),l=e.toolKind&&e.toolKind in tx?e.toolKind:"other",c=v6[l],u=e.name===mg,h=(l!=="other"||Vp.has(e.name))&&e.name!==Rj,p=i&&(h||e.name===e.title||e.name===si||e.name===Wx)&&e.name!==Kx?"":e.name,m=p&&p.toLowerCase()!==c?p:i?"":c,g=(l==="execute"||l==="other")&&n?j6(n):void 0;return{label:u?"ask":c,name:m,icon:Vp.get(e.name)??Vp.get(e.title??"")??g??tx[l],hint:i===m?"":i,command:n&&n!==i?n:""}}const R6=/^Async agent launched/m;function $6(e){if(!e.subagent)return!1;const t=e.input;return!!e.detached||(t==null?void 0:t.run_in_background)===!0||!!e.output&&R6.test(e.output)}const O6={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 M6(e){const t=e.toolKind;return e.subagent?fo(e,"prompt")?"":"writing the brief":!uf(e.input)||!Zx({name:e.name,kind:t},e.input)?"":kg(t)?O6[t]:"writing the question"}function Vm(e,t){const n=GS(t),r=n[0],o=fo(e,"description");return o&&r&&!r.code&&r.text===o?n.slice(1):n}function Bf(e){return qS(e)||fo(e,"path")}function L6(e){return fo(e,"description")}function qS(e){return fo(e,"file_path")||fo(e,"filepath")||fo(e,"filePath")||P6(e)}function P6(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 Zk(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 D6=/^(`{3,})([\w+#.-]*)\s*$/;function GS(e){var c;const t=[];let n=[],r="",o=!1,i=0;const l=()=>{const u=n.join(`
209
+ `).replace(/^\n+|\n+$/g,"");u.trim()&&t.push({code:o,diff:z6(u,r),lang:o?r:"",text:u}),n=[]};for(const u of e.split(`
210
+ `)){const h=D6.exec(u),p=((c=h==null?void 0:h[1])==null?void 0:c.length)??0;if(!h||o&&(p<i||h[2])){n.push(u);continue}l(),o=!o,i=o?p:0,r=o?(h[2]??"").toLowerCase():""}return l(),t}function z6(e,t){return t==="diff"||t==="patch"||/^diff --git /m.test(e)||/^@@ .*@@/m.test(e)?!0:/^--- /m.test(e)&&/^[+-]/m.test(e)}const F6=/^(diff --git |index [0-9a-f]+\.\.|new file mode |deleted file mode |similarity index |rename (from|to) |Binary files )/;function B6(e){const t=[];for(const n of e.split(`
211
+ `)){const r=H6(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 U6(t),t}function U6(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),p=u.length>0&&h.length>0?SC(u.map(m=>m.text).join(`
212
+ `),h.map(m=>m.text).join(`
213
+ `)):null;p&&(ox(u,_v(p.before)),ox(h,_v(p.after)));for(const m of[...u,...h])m.spans??(m.spans=[]);i=c}}function ox(e,t){if(t.length===e.length)for(const[n,r]of e.entries())r.spans=t[n]}function H6(e){return e.startsWith("@@")?"hunk":e.startsWith("+++")||e.startsWith("---")||F6.test(e)?"meta":e.startsWith("+")?"add":e.startsWith("-")?"del":""}function W6(e){const t=e.tools.at(-1);return t.done||t.parentToolId?!1:t.name===si?!t.background:!!t.background}const VS=new Set(["read","edit","fetch"]);function YS(e,t){if(e.isError||!e.toolKind||!VS.has(e.toolKind)||kg(e.toolKind)&&uf(e.input))return"";const{hint:n}=Ac(e,t);return n?`${e.parentToolId??""}
214
+ ${e.toolKind}
215
+ ${e.name}
216
+ ${n}`:""}function sx(e,t,n){if(!t||!("tools"in t)||e.done||e.isError||!e.toolKind||!VS.has(e.toolKind))return!1;const r=t.tools[0];return r.toolKind===e.toolKind&&r.name===e.name&&r.parentToolId===e.parentToolId&&YS(r,n)!==""}function XS(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 K6(e){return e.done&&!e.output&&!e.isError&&Zx({name:e.name,kind:e.toolKind},e.input)}function Z6(e,t){const n=XS(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(K6(c))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=YS(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&&sx(c,g,t)?g.next=c:m.push({at:l,tools:[c]}),h.key=u,h.entry.end=l;continue}const p=r.at(-1);if(u&&u===i&&p&&"tools"in p){p.tools.push(c);continue}if(!u&&sx(c,p,t)){p.next=c;continue}i=u,r.push({at:l,tools:[c]})}return r}function q6(e){return e.reduce((t,n)=>t+n.tools.length,0)}function G6(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];l.kind==="user"&&(o=!1),!(l.kind!=="tool"||!l.subagent)&&(l.isError?t.delete(l.id):l.done?$6(l)?o&&!n.has(l.id)&&t.add(l.id):t.delete(l.id):t.add(l.id))}return t}function V6(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&&W6(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 Y6(e){const t=XS(e);return e.some(n=>n.kind==="tool"&&!n.done&&!n.parentToolId&&!n.background&&(!t.has(n.id)||uf(n.input)))}function QS(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===si)return;const u=gg({name:c.name,kind:c.toolKind});(o||r&&u)&&n.add(l),r=!0,o||(o=u)}),n}function X6(e){return e.findIndex(t=>!t.tools.at(-1).done)}function qk(e,t){return e.length===t.length&&e.every((n,r)=>n===t[r])}function JS(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)&&qk(n.tools,t[r].tools)})}function Q6(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&&J6(c,i)?c:i;return u!==e[l]&&(r=!1),u});return r?e:o}function J6(e,t){return"spawn"in e?"spawn"in t&&e.spawn===t.spawn&&e.end===t.end&&JS(e.run,t.run):"tools"in e?"tools"in t&&e.next===t.next&&qk(e.tools,t.tools):"item"in t&&e.item===t.item}function eF(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"&&!ZS(r))return t;continue}if(n.item.kind==="thinking"){if(!n.item.text.trim())continue;return BS(n.item.text)?-1:t}if(tF(n.item))return-1}}return-1}function tF(e){return e.kind==="assistant"?!!e.text.trim():e.kind==="ask"?e.ask.kind==="question"||!!e.outcome:!0}function nF(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 rF({item:e}){const t=lt(),n=P(r=>kn(r,e.worktreeId)!==null);return e.state==="proposed"?null:e.state==="declined"?d.jsx(eo,{icon:"close",word:"not continued",tone:"quiet",at:e.ts,below:e.reason?d.jsx("div",{className:"daemon-below row-dim",children:e.reason}):void 0,children:d.jsxs("span",{className:"daemon-text",children:["in ",e.repo.name]})}):d.jsx(eo,{icon:"spawn",word:"continued",tone:"accent",at:e.ts,children:d.jsxs("span",{className:"daemon-text",children:["in ",e.repo.name,":"," ",d.jsx(ze,{variant:"inline",tone:"strong",disabled:!n,onClick:()=>e.worktreeId&&t({a:"activate",id:e.worktreeId}),children:e.title??e.repo.name})]})})}function oF({item:e}){return d.jsxs(eo,{icon:"check",word:"landed",tone:"aqua",at:e.ts,children:[d.jsxs("span",{className:"daemon-text",children:[e.title," in ",e.repoName]}),e.url&&d.jsx(ze,{variant:"inline",tone:"strong",onClick:()=>window.open(e.url,"_blank"),children:"view PR"})]})}function Gk({src:e,n:t,name:n,width:r,height:o,bytes:i,uploading:l,progress:c,onRemove:u,className:h=""}){return d.jsx(Rk,{className:Ue("image-chip",h),label:d.jsxs(d.Fragment,{children:[d.jsx("img",{className:"image-thumb",src:e,alt:n,width:40,height:40}),d.jsxs("span",{className:"pick-target",children:[d.jsx("b",{children:Yx("image",t)}),d.jsxs("span",{className:"pick-file row-dim",children:[" ","· ",n," · ",r,"×",o," · ",bg(i),c!==void 0?d.jsxs(d.Fragment,{children:[" ","· ",d.jsxs("span",{className:"pick-progress",children:[c,"%"]})]}):l&&" · uploading"]})]})]}),peek:d.jsx("img",{src:e,alt:n,style:{aspectRatio:`${r} / ${o}`}}),full:d.jsx("img",{src:e,alt:n}),menu:p=>Cc(e,p),removeLabel:"Remove image",onRemove:u})}function sF({img:e,src:t}){return d.jsx(Gk,{className:"in-chat",src:t,...e})}function eN(e,{sock:t,dispatch:n}){var m,g;const r=y=>y?"hide":"show",o=e.repos.some(y=>y.id===e.activeRepoId),i=(m=kn(e,e.activeId))==null?void 0:m.worktree.id,l=[];o&&(l.push({id:"new",label:"new worktree…",key:Lt("new"),onClick:()=>n({a:"open-draft"})}),l.push({id:"refs",label:"open a branch or PR…",key:Lt("refs"),onClick:()=>n({a:"open",overlay:{kind:"refs"}})})),i&&(l.push({id:"jump",label:"jump to file…",key:Lt("quick-open"),onClick:()=>n({a:"open",overlay:{kind:"quick-open"}})}),l.push({id:"search",label:"search in files…",key:Lt("search"),onClick:()=>n({a:"open",overlay:{kind:"search"}})})),Wd(e)&&l.push({id:"routes",label:"go to page…",key:Lt("routes"),onClick:()=>n({a:"open",overlay:{kind:"routes"}})}),o&&l.push({id:"chats",label:"search chats…",key:Lt("chats"),onClick:()=>n({a:"open",overlay:{kind:"chats"}})});const c=Dg(e.visible,e.activeId,1);c&&l.push({id:"wt-unseen-next",label:"next that needs you",key:Lt("wt-unseen-next"),onClick:()=>n({a:"activate",id:c.activate})}),l.push({id:"project",label:e.repos.length>1?"switch project…":"open project…",key:Lt("project"),onClick:()=>n({a:"open",overlay:{kind:"projects",form:"center"}})});const u=[{id:"changes",label:`${r(e.layout.changes)} changes panel`,key:Lt("changes"),onClick:()=>n({a:"toggle-changes"})},{id:"files",label:`${r(e.layout.changes&&sl(e)==="files")} files`,key:Lt("files"),onClick:()=>n(e.layout.changes&&sl(e)==="files"?{a:"toggle-changes"}:{a:"focus-changes",tab:"files"})},{id:"chat",label:`${r(e.layout.chat)} chat panel`,key:Lt("composer"),onClick:()=>n({a:"toggle-chat"})},{id:"terminal",label:`${r(e.layout.term)} terminal`,key:Lt("terminal"),onClick:()=>n({a:"toggle-terminal"})},{id:"rail",label:`${r(e.railOpen)} worktree panel`,key:Lt("rail"),onClick:()=>n({a:"toggle-rail"})},{id:"design",label:`${r(e.layout.design)} design system`,key:Lt("design"),onClick:()=>n({a:"toggle-design"})},{id:"zen",label:"full-bleed preview",key:Lt("zen"),onClick:()=>n({a:"toggle-zen"})}],h=[{id:"commands",label:"command palette",key:Lt("commands"),onClick:()=>n({a:"open",overlay:{kind:"commands"}})},{id:"keys",label:"settings & shortcuts",key:Lt("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 p=xo(e)?new Set(["chat","design","zen"]):null;return zn([l,p?u.filter(y=>!p.has(y.id)):u,h])}function Ym(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}?
217
+
218
+ 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 zn([o,i])}function Vk(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 tN(e,{sock:t}){return[{id:"restart:shell",label:"restart shell",onClick:()=>t==null?void 0:t.send({t:"term-restart",worktreeId:e,stream:vo})}]}function iF(e,t,n,r){return zn([[...e.flatMap(o=>Vk(o,t,r)),...tN(t,r)],[{id:"terminal",label:`${n?"hide":"show"} terminal`,onClick:()=>r.dispatch({a:"toggle-terminal"})}]])}const Uf=e=>/^(~|\/|\.\.?\/)/.test(e.trim());function Yk(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 aF(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,p]of[...l].sort(([m],[g])=>m.localeCompare(g)))(p>u||p===u&&h===i)&&(c=h,u=p);return c?nN(c,n):`~/${U1}`}function nN(e,t){return t&&(e===t||e.startsWith(`${t}/`))?`~${e.slice(t.length)}`:e}function rN(e,t){return`${e.replace(/\/+$/,"")}/${t.trim()}`}function lF(e){const t=e.query.trim(),n=()=>e.entries.map(l=>({kind:"dir",entry:l}));if(!Uf(t)){const l=e.repos.filter(g=>ns(t,g.name,g.path)).map(g=>({kind:"repo",repo:g})),c=e.pending.filter(g=>ns(t,g.name,g.url)).map(g=>({kind:"pending",pending:g})),u=[...l,...c],h=(e.others??[]).flatMap(g=>g.repos.length===0?ns(t,g.name)?[{kind:"machine",machine:g}]:[]:g.repos.filter(y=>ns(t,y.name,y.path,g.name)).map(y=>({kind:"repo",repo:y,machine:g})));if(!t)return[...u,{kind:"new"},{kind:"disk"},{kind:"add-machine"},...h];const p=g2(t);if(p)return u.length>0?u:[{kind:"clone",url:p.url,name:p.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}=Yk(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 oN(e,t){const n=ll(e,t).replace(/\/+$/,"");return n.startsWith("/")?nN(n.slice(0,n.lastIndexOf("/"))||"/",t):null}function Xm(e,t){const n=ll(e,t).replace(/\/+$/,"");return n.slice(n.lastIndexOf("/")+1)||"/"}function cF(e){const t=e.query.trim(),n=t.lastIndexOf("/"),r=n<0?"":t.slice(0,n)||"/",o=ll(r,e.home);if(!Uf(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(p=>{if(p.isRepo)return!1;const m=ll(p.path,e.home);return(m.slice(0,m.lastIndexOf("/"))||"/")===o&&p.name.toLowerCase().startsWith(i)}),h=oN(r,e.home);return[...c?[{kind:"here",path:r}]:[],...h?[{kind:"up",path:h}]:[],...u.map(p=>({kind:"dir",entry:p}))]}function Ic({sock:e,dispatch:t},n){t({a:"open-repo"}),e==null||e.send(n)}function sN(e,t){const{parent:n,name:r}=Yk(t);Ic(e,{t:"create-repo",mode:"init",parent:n,name:r})}function uF(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 Hf(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}?
219
+
220
+ 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 zn([o,i])}const Jd={dark:"dark",light:"light",system:"follow system",daylight:"follow daylight"},ef={use:"while in use",always:"always",off:"off"};function dF(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 iN(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=xP();return zn([[{id:"theme",label:"theme…",detail:xf(r,e.themes,kE(e)).name,sub:!0,onClick:()=>n({a:"open",overlay:{kind:"theme",slot:"theme"}})},{id:"appearance",topic:"theme",label:"light or dark…",detail:Jd[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"})},...i.access==="none"?[]:[{id:"clipboard-offer",label:"offer what is copied",detail:i.access==="denied"?"blocked in site settings":i.on?"on":"off",onClick:()=>EP(!i.on)}]],...e.keepAwake===null?[]:[[{id:"keep-awake",label:"keep awake…",detail:ef[e.keepAwake],sub:!0,onClick:()=>n({a:"open",overlay:{kind:"keep-awake"}})}]],[{id:"theme-import",topic:"theme",label:"import a VS Code theme…",onClick:()=>dF((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 fF(e,t,n,r,o,i={machines:[],switchTo:()=>{},forget:()=>{}}){const l=[],c=(g,y,w,b,E)=>l.push({id:g,label:y,hint:b,run:w,sub:E}),u=(g,y)=>{for(const w of g){if(!ss(w)||w.disabled!==void 0||w.checked)continue;const b=w.key??(typeof w.detail=="string"?w.detail:void 0),E=y?`${y.scope}:${w.id}`:w.id,_=w.topic?`${w.topic}: ${w.label}`:w.label;c(E,y?`${_} · ${y.name}`:_,w.onClick,b,w.sub)}},h={sock:n,dispatch:t},p=r,m=p==null?void 0:p.worktree.id;if(u(eN(e,h).filter(g=>!ss(g)||g.id!=="commands")),o&&u(Hf(o,o.id,h),{scope:"project",name:o.name}),m&&!xo(e)&&(c("pick",e.picking==="chat"?"cancel element picker":"pick an element for the chat",()=>Nc(m,e.picking,t,"chat"),Lt("pick")),c("inspect",e.picking==="code"?"cancel element picker":"pick an element to open its code",()=>Nc(m,e.picking,t,"code"),Lt("inspect")),c("reload","reload preview",()=>an.post(m,{type:"reload"}))),u(iN(e,h)),p&&m){const g=e.repos.find(y=>y.id===p.worktree.repoId)??null;u(T_(p,g,e,h,{hostname:e.hostname}),{scope:"wt",name:_m(p,g)});for(const y of p.procs)u(Vk(y,m,h))}e.visible.forEach((g,y)=>{var _;if(g.worktree.id===m)return;const w=g.worktree.variant,E=e.activeRepoId&&Jg(g,e.activeRepoId,e.rows)?` in ${((_=e.repos.find(N=>N.id===g.repoId))==null?void 0:_.name)??g.repoId}`:"";c(`go:${g.worktree.id}`,`switch to ${_m(g,o)}${w?` (v${w.index}/${w.of})`:""}${E}`,()=>t({a:"activate",id:g.worktree.id}),Xj(y,e.visible.length))});for(const g of e.repos)g.id!==(o==null?void 0:o.id)&&c(`repo:${g.id}`,`switch to project ${g.name}`,()=>t({a:"activate-repo",id:g.id}));for(const g of i.machines){for(const y of g.repos)c(`machine:${g.origin}:${y.id}`,`switch to project ${y.name} on ${g.name}`,()=>i.switchTo(g.origin,y.id));c(`forget-machine:${g.origin}`,`forget ${g.name}`,()=>i.forget(g.origin))}return l}function aN(){const e=lt(),t=ct(),{host:n}=Wr(),r=Go(),o=RE(),i=P(A=>A.picking),l=P(A=>A.layout),c=P(A=>A.chatSide),u=P(A=>A.keepAwake),h=P(A=>A.railOpen),p=P(A=>A.themePrefs),m=P(A=>A.themes),g=P(A=>A.systemDark),y=P(A=>A.daylight),w=P(A=>A.rows),b=P(A=>A.visible),E=P(A=>A.activeId),_=P(A=>A.activeRepoId),N=P(A=>A.repos),T=P(A=>A.agents),R=P(A=>A.defaultAgent),O=P(A=>A.shipping),B=P(A=>A.remote),$=P(A=>A.managed),C=P(A=>A.frame),j=P(A=>A.self),D=P(A=>A.archivedPage),z=P(A=>A.archived),X=P(A=>A.knocks),ae=P(A=>A.tailscale);return S.useMemo(()=>{const A={picking:i,layout:l,chatSide:c,keepAwake:u,railOpen:h,themePrefs:p,themes:m,systemDark:g,daylight:y,rows:w,visible:b,activeId:E,activeRepoId:_,repos:N,agents:T,defaultAgent:R,shipping:O,frame:C,self:j,archivedPage:D,archived:z,knocks:X,hostname:n},de={machines:o,switchTo:(ue,J)=>{var M;(M=r.get(ue))==null||M.store.dispatch({a:"activate-repo",id:J}),r.activate(ue)},forget:ue=>{const J=Ym(r,ue).find(M=>ss(M)&&M.id.startsWith("forget-machine:"));J&&ss(J)&&J.onClick()}};return fF(A,e,t,kn(A,E),hi(A,_),de)},[i,l,c,u,h,p,m,g,y,w,b,E,_,N,T,R,O,B,$,C,j,D,z,X,ae,e,t,n,r,o])}function lN(e,t){const n=t.trim().toLowerCase();if(!n)return e;const r=[];for(const o of e){const i=Qm(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 Qm(e,t){const n=Xk(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+(cN(e,l)?3:0),i=l;return r+Math.max(0,40-e.length/4)}const cN=(e,t)=>t===0||/[\s:\-–—·/.(]/.test(e[t-1]);function Xk(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(cN(n,c)){l=c;break}if(l===-1)return null;r.push(l),o=l+1}return r}const ns=(e,...t)=>{const n=e.trim().toLowerCase();return!n||t.some(r=>r==null?void 0:r.toLowerCase().includes(n))},hF=/^[^\s]*$/;function ix(e,t){if(e.startsWith("!"))return null;if(e.startsWith("/")){const i=e.indexOf(" "),l=i===-1?e.length:i;if(!(e.indexOf("/",1)!==-1&&e.indexOf("/",1)<l)&&t<=l)return{kind:"command",query:e.slice(1,t),from:0,to:l}}const n=e.lastIndexOf("@",Math.max(0,t-1));if(n===-1||n>=t||n>0&&!/\s/.test(e[n-1]??""))return null;const r=e.slice(n+1,t);if(!hF.test(r))return null;let o=t;for(;o<e.length&&!/\s/.test(e[o]??"");)o++;return{kind:"file",query:r,from:n,to:o}}const pF={files:new Set,folders:new Set},ax=new WeakMap;function mF(e){if(!e)return pF;let t=ax.get(e);return t||(t={files:new Set(e),folders:new Set(fE(e))},ax.set(e,t)),t}const gF=/(^|\s)(@\S+)/g,kF=/[.,;:!?)\]}'"]$/;function lx(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(/\/+$/,"");return n&&t.folders.has(n)?{kind:"folder",text:`@${e}`,path:n}:null}function wF(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(gF)){const l=i.index+(i[1]??"").length;let c=(i[2]??"").slice(1),u=lx(c,t);for(;!u&&kF.test(c);)c=c.slice(0,-1),u=c?lx(c,t):null;u&&(o(e.slice(r,l)),n.push(u),r=l+u.text.length)}return o(e.slice(r)),n}function yF(e,t,n){return{text:e.slice(0,t.from)+n+e.slice(t.to),caret:t.from+n.length}}function vF(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=>Qm(i.name,n));return o.length>0?o:r(i=>Qm(i.description,n))}const bF=/(^|\s)@\S/;function uN({text:e,worktreeId:t,root:n,inField:r}){const o=Zn(),i=ct(),l=P(p=>{var m;return t?(m=p.local[t])==null?void 0:m.files:void 0}),c=mF(l),u=S.useMemo(()=>wF(e,c),[e,c]),h=l===void 0&&t&&bF.test(e)?t:null;return S.useEffect(()=>{h&&$f(h,o.getState(),{sock:i,dispatch:o.dispatch})},[h,o,i]),d.jsx(d.Fragment,{children:u.map((p,m)=>{if(p.kind==="text")return p.text;if(p.kind==="changes"){const b=Ut("this worktree's uncommitted files",void 0,{placement:"follow"});return d.jsx("span",{className:"chat-mention","data-changes":"",...b,children:p.text},m)}if(!n||!t)return p.text;const g=p.kind==="folder",y=`${n}/${p.path}${g?"/":""}`,w=Ut(g?`${p.path}/`:p.path,void 0,{placement:"follow"});return d.jsx("a",{className:"chat-mention",href:y,tabIndex:r?-1:void 0,...w,children:p.text},m)})})}function dN(e,t,n,r){if(e.target.closest("[data-changes]")){n&&r.dispatch({a:"focus-changes",tab:"changes"});return}Ik(e,t,n,r)}function xF(e){return e.length<2||!e.every(t=>{var n;return t.length===1&&((n=t[0])==null?void 0:n.diff)})?null:_F(e.map(t=>t[0].text))}const EF=/^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@/;function _F(e,t=3){let n=[];for(const r of e){const o=SF(r);if(!o)return null;const i=NF(n,o);if(!i)return null;n=i}return n.some(r=>r.kind!=="same")?TF(n,t):null}function SF(e){const t=[];let n=null;for(const r of e.split(`
221
+ `)){const o=EF.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 NF(e,t){const n=[];let r=0,o=0,i=0,l=0;const c=p=>{p.kind==="same"?o=p.a-p.c:p.kind==="add"?o-=1:o+=1},u=()=>{for(;r<e.length&&e[r].kind==="del";)n.push(e[r]),c(e[r]),r++},h=p=>{for(let m=p;m<e.length;m++){const g=e[m];if(g.kind!=="del")return g.c}return Number.POSITIVE_INFINITY};for(const p of t){if(p.oldStart<=l)return null;for(;r<e.length;){const y=e[r];if((y.kind==="del"?h(r):y.c)>=p.oldStart)break;n.push(y.kind==="del"?y:{...y,c:y.c+i}),c(y),r++}let m=p.oldStart,g=p.newStart;for(const y of p.ops){if(u(),y.mark==="+"){n.push({kind:"add",c:g,text:y.text}),g++;continue}const w=e[r],b=w&&w.kind!=="del"&&w.c===m?w:void 0;if(b){if(b.text!==y.text)return null;r++,c(b),y.mark===" "?n.push({...b,c:g}):b.kind==="same"&&n.push({kind:"del",a:b.a,text:b.text})}else y.mark===" "?n.push({kind:"same",a:m+o,c:g,text:y.text}):n.push({kind:"del",a:m+o,text:y.text});y.mark===" "&&g++,m++}i=g-m,l=m-1}for(;r<e.length;r++){const p=e[r];n.push(p.kind==="del"?p:{...p,c:p.c+i})}return n}function TF(e,t){const n=[];for(const r of CF(e))for(const[o,i]of AF(r.rows,t)){const l=jF(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"),p=l.find(m=>m.kind!=="del");n.push(`@@ -${h?h.a:r.oldAt[o]},${c} +${p?p.c:r.newAt[o]},${u} @@`,...l.map(m=>`${m.kind==="add"?"+":m.kind==="del"?"-":" "}${m.text}`))}return n.join(`
222
+ `)}function jF(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 CF(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 AF(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 Jm({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 Qk({pick:e,dir:t,worktreeId:n,tipText:r,onHover:o,onOpen:i,onRemove:l,className:c=""}){const u=e.callFile,h=e.file,p=u?{path:u,line:e.callLine}:h?{path:h,line:e.line}:null,m=u&&h?{path:h,line:e.line}:null,g=(T,R)=>`${T}${R?`:${R}`:""}`,y=T=>T.split("/").pop()??T,w=(T,R,O,B)=>i?d.jsx("button",{className:"pick-open","data-tip":B,onClick:()=>i(T,R??1),children:O}):O,b=wn("chat"),{host:E}=Wr(),_=S.useRef(null),N=l?()=>{o==null||o(!1),l()}:void 0;return d.jsxs("div",{ref:_,className:Ue("pick-chip row row-sm",c),"data-tip":r,onMouseEnter:()=>o==null?void 0:o(!0),onMouseLeave:()=>o==null?void 0:o(!1),...b.contextMenu(()=>hz(e,{dir:t,remove:N,host:E})),children:[d.jsxs("span",{className:"pick-target",children:[d.jsx(Nt,{name:"pick",className:"icon-inline"})," ",Zg(e),p&&d.jsxs("span",{className:"pick-file row-dim",children:[" ","· ",w(p.path,p.line,g(y(p.path),p.line),`Open ${g(p.path,p.line)}`)]}),m&&d.jsxs("span",{className:"pick-file row-dim",children:[" ","·"," ",w(m.path,m.line,g(m.path.split("/").pop()??m.path,m.line),`Open the component: ${g(m.path,m.line)}`)]})]}),N&&d.jsx(Pt,{icon:"close",label:"Remove attachment",tone:"quiet",onClick:N}),n&&(p==null?void 0:p.line)&&d.jsx(iS,{chip:_,children:d.jsx($F,{worktreeId:n,path:p.path,line:p.line})})]})}const IF=6,RF=16;function $F({worktreeId:e,path:t,line:n}){const r=OE(),o=ct(),i=P(m=>{var g;return((g=No(m))==null?void 0:g.id)===e}),l=P(m=>{var g;return i?0:(g=_o(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(`
223
+ `),g=n-l,y=Math.max(1,g-IF),w=Math.min(m.length,g+RF);if(y>w)return null;const b=m.slice(y-1,w);return{from:y,at:g,slice:b,painted:Uk(b.join(`
224
+ `),Bk("",t))}},[c,l,n,t]);if(!h)return null;const p=String(h.from+h.slice.length-1).length;return d.jsx("pre",{className:"pick-peek",children:h.slice.map((m,g)=>{const y=h.from+g,w=h.painted[g];return d.jsxs("span",{className:"pick-peek-line","data-state":y===h.at?"current":void 0,children:[d.jsx("span",{className:"pick-peek-n",children:String(y).padStart(p)}),w!=null&&w.length?d.jsx(Jm,{pieces:w}):m||" "]},y)})})}function OF(e){return e.startsWith("!")?e.slice(1).trim():null}function Wf(e){if(e.kind!=="tool"||e.name!==si&&e.name!==Wx)return null;const t=e.input;return typeof(t==null?void 0:t.command)=="string"?t.command:null}function MF(e){return e.length>0&&e.every(t=>t.kind==="tool"&&t.name===si&&Wf(t)!==null&&!t.input.landing&&t.done&&!t.isError)}function LF(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(o.kind==="user")break;if(o.kind!=="tool"||!o.done||n.has(o.id))continue;const i=Wf(o);if(i===null)continue;const l=GS(o.output??"").map(u=>u.text).join(`
225
+ `),c=XO(l);t.unshift(`$ ${i}${c?`
226
+ ${c}`:""}`)}if(t.length!==0)return`Shell commands the user ran since their last message, and what each printed:
227
+ ${t.join(`
228
+ `)}`}function PF(e,t,n,r,o){const{sock:i}=r,l=e[0];if(!l)return[];const c=[],u=Zk(Bf(l),t);if(u&&!u.startsWith("/")&&n){const w=l.toolKind==="edit"?"diff":"file";c.push({id:"open-diff",label:`open ${w}`,onClick:()=>er(r,{worktreeId:n.id,path:u,view:w})}),c.push(...Gi(`${n.dir}/${u}`,()=>i==null?void 0:i.send({t:"reveal",worktreeId:n.id,path:u}),as(i)))}else u.startsWith("/")&&c.push(...Gi(u,void 0,as(i)),{id:"copy-path",label:"copy path",onClick:()=>on(u)});const h=[],p=Ac(l,t).command,m=L6(l);m&&m!==p&&h.push({id:"copy-description",label:"copy description",onClick:()=>on(m)}),p&&h.push({id:"copy-command",label:"copy command",onClick:()=>on(p)});const g=e.map(w=>w.output??"").filter(Boolean).join(`
229
+ `);g&&h.push({id:"copy-output",label:"copy output",onClick:()=>on(g)});const y=o.leaf?[]:[{id:"fold",label:o.open?"collapse":"expand",onClick:o.toggle}];return zn([c,h,y])}const fN=e=>e.replace(/\n$/,""),DF=1500,cx=4;function hN(e){return e.closest(".md pre, .card-code pre")}function eg(e){const t=hN(e);return t?fN(t.textContent??""):null}function zF(e,t){const n=e.getBoundingClientRect(),r=t.getBoundingClientRect();return{pre:t,top:r.top-n.top+e.scrollTop+cx,right:n.left+e.clientLeft+e.clientWidth-r.right+cx}}function Jk(e){const[t,n]=S.useState(null),[r,o]=S.useState(null);if(S.useEffect(()=>{const h=e.current;if(!h)return;const p=g=>{if(!(g.target instanceof Element)||g.target.closest(".code-copy"))return;const y=hN(g.target);n(y&&h.contains(y)?zF(h,y):null)},m=()=>n(null);return h.addEventListener("pointerover",p),h.addEventListener("pointerleave",m),()=>{h.removeEventListener("pointerover",p),h.removeEventListener("pointerleave",m)}},[e]),S.useEffect(()=>{if(!r)return;const h=setTimeout(()=>o(null),DF);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(Pt,{className:"code-copy",style:{top:l,right:c},icon:u?"check":"copy",label:u?"Copied":"Copy code",onClick:()=>{on(fN(i.textContent??"")),o(i)}})}function Yp({text:e,menu:t,marked:n,worktreeId:r,fileRoot:o,streaming:i}){const l=Hk(e,{fileRoot:o,streaming:i}),c=ct(),u=lt(),h=wn("chat"),p=S.useRef(null);PE(p,l);const m=P(w=>{var b;return r?(b=w.local[r])==null?void 0:b.refusedLink:void 0});St([l,m],()=>{var b;const w=p.current;if(w)for(const E of w.querySelectorAll("a.file-link")){const _=m!==void 0&&E.getAttribute("href")===m.href;E.classList.toggle("file-link-refused",_),_?((b=E.dataset).tipWas??(b.tipWas=E.dataset.tip??""),E.dataset.tip=m.message,E.dataset.tipPlacement="bottom",E.dispatchEvent(new MouseEvent("mouseover",{bubbles:!0}))):E.dataset.tipWas!==void 0&&(E.dataset.tip=E.dataset.tipWas,E.dataset.tipPlacement="follow",delete E.dataset.tipWas)}});const g=S.useRef(null),y=Jk(g);return d.jsxs("div",{ref:g,className:"msg-assistant md row-edge","data-state":gr({cursor:n}),...h.contextMenu((w,b)=>t(Ak(b,o),eg(b))),onClick:w=>Ik(w,o,r,{sock:c,dispatch:u}),children:[d.jsx("div",{ref:p}),y]})}const Xp=40;function pN(e,t){return e.map(n=>{const r=Bk(n.lang,t||(n.diff?n6(n.text):""));if(n.diff){const o=B6(n.text);return{...n,lines:o,painted:s6(o,r)}}return{...n,lines:[],painted:n.code?Uk(n.text,r):[]}})}function mN({blocks:e,path:t,worktreeId:n}){ct();const r=lt();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,Xp).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(Jm,{pieces:o.painted[c]}):l.text||" "},c)}),o.lines.length>Xp&&d.jsxs("button",{type:"button",className:"dl more",disabled:!t||!n,"data-tip":t&&n?"Open this file's diff":void 0,onClick:()=>n&&er({dispatch:r},{worktreeId:n,path:t,view:"diff"}),children:[o.lines.length-Xp," 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?`
230
+ `:null,d.jsx(Jm,{pieces:l})]},c)):o.text},i):d.jsx("p",{className:"tool-note",children:o.text},i))})}function FF({image:e,worktreeId:t}){const n=Wr().attachment(t,e.file),[r,o]=S.useState(!1),i=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:()=>o(!0),...i.contextMenu(()=>Cc(n,{open:()=>o(!0)})),children:d.jsx("img",{src:n,alt:e.file})}),r&&d.jsx(jk,{owner:"chat",onClose:()=>o(!1),menu:()=>Cc(n),children:d.jsx("img",{src:n,alt:e.file})})]})}const BF=S.memo(function({item:t,roots:n,worktreeId:r}){const o=S.useMemo(()=>pN(Vm(t,t.output??""),Bf(t)),[t]),i=Ac(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(mN,{blocks:o,path:gN(t,n),worktreeId:r}),l.length>0&&r&&d.jsx("div",{className:"tool-out",children:l.map(c=>d.jsx(FF,{image:c,worktreeId:r},c.file))})]})});function gN(e,t){const n=Zk(Bf(e),t??[]);return n.startsWith("/")?"":n}const UF=S.memo(function({text:t,item:n,roots:r,worktreeId:o}){const i=Bf(n),l=S.useMemo(()=>pN([{code:!0,diff:!0,lang:"diff",text:t}],i),[t,i]);return d.jsx("div",{className:"tool-part",children:d.jsx(mN,{blocks:l,path:gN(n,r),worktreeId:o})})});function tg({className:e,state:t,auto:n,leaf:r,growing:o,label:i,summary:l,menu:c,children:u}){const[h,p]=S.useState(null),m=S.useRef(null),g=S.useRef(null),y=LE(g),w=XL(".chat-log"),b=!r&&(h??n),E=()=>{r||(b||w(m.current),p(!b))},_=wn("chat");return d.jsxs("details",{ref:m,className:Ue(e,r&&"leaf"),"data-state":t,open:b,onToggle:N=>{if(!N.currentTarget.open||o)return;const T=g.current;T&&(T.scrollTop=0,y.read())},..._.contextMenu((N,T)=>c({open:b,leaf:!!r,toggle:E},T)),tabIndex:-1,onPointerDown:()=>{var N;return(N=m.current)==null?void 0:N.focus({preventScroll:!0})},onKeyDown:N=>{if((N.key==="ArrowLeft"||N.key==="ArrowRight")&&!r){if(N.shiftKey||N.altKey||N.metaKey||N.ctrlKey)return;Df([{depth:0,open:b}],0,N.key)&&E();return}N.key!=="Escape"||!b||(N.stopPropagation(),p(!1))},children:[d.jsx("summary",{"aria-label":i,tabIndex:r?-1:void 0,onClick:N=>{N.preventDefault(),E()},children:l}),d.jsx("div",{className:"tool-body",ref:g,children:u})]})}const HF=S.memo(function({item:t,open:n,streaming:r,worktreeId:o,fileRoot:i}){const l=FS(t.text),c=l.slice(0,-1),u=Hk(l.length?c.join(`
231
+
232
+ `):DS(t.text),i?{fileRoot:i}:void 0),h=ct(),p=lt(),m=r?"Thinking":"Thought",g=S.useRef(null);PE(g,u);const y=S.useRef(null),w=Jk(y),b=d.jsx("div",{className:"tool-part",children:d.jsxs("div",{ref:y,className:"tool-out thought-out md",onClick:_=>Ik(_,i,o,{sock:h,dispatch:p}),children:[d.jsx("div",{ref:g}),w]})}),E=l.at(-1)??(r?"":BS(t.text));if(E){const _=c.length===0;return d.jsx(tg,{className:"tool-row",auto:!1,leaf:_,growing:r,label:E,menu:(N,T)=>zn([Um(eg(T)),[{id:"copy",label:"copy thought",onClick:()=>on(t.text)}],..._?[]:[[{id:"fold",label:N.open?"collapse":"expand",onClick:N.toggle}]]]),summary:d.jsxs(d.Fragment,{children:[d.jsx(Nt,{name:"bulb",className:"tool-icon"}),d.jsx("span",{className:Ue("tool-hint thought-line",r&&"live-text"),children:E})]}),children:_?null:b})}return d.jsx(tg,{className:"tool-row",auto:!!n,growing:r,label:m,menu:(_,N)=>zn([Um(eg(N)),[{id:"copy",label:"copy thought",onClick:()=>on(t.text)}],[{id:"fold",label:_.open?"collapse":"expand",onClick:_.toggle}]]),summary:d.jsxs(d.Fragment,{children:[d.jsx(Nt,{name:"bulb",className:"tool-icon"}),d.jsx("span",{className:Ue("tool-name",r&&"live-text"),children:m})]}),children:b})}),sc=6,WF={land:"the land",commit:"the commit","sync-main":"the sync","pull-main":"the pull"},md=S.memo(function e({tools:t,run:n,next:r,live:o,working:i,since:l,queued:c,roots:u,worktreeId:h,marked:p}){const m=t[0],g=S.useMemo(()=>xF(t.map(he=>Vm(he,he.output??""))),[t]),y=t.at(-1)??m,w=!y.done,b=w&&!!y.background,_=(w||!!r)&&!c||!!i,N=w&&!!c,T=il(w||i?l:void 0),R=n?X6(n):-1,O=S.useMemo(()=>n?QS(n,!0):void 0,[n]),B=!!o,$=Ac(m,u),C=w?M6(m):"",{label:j,icon:D}=$,z=ZS(m),X=C?"":z?"Guardian":$.name,ae=C&&m.subagent?$.hint:"",A=ae||C||(z?I6(m.output??""):$.hint),de=!(n&&n.length>0)&&!g&&t.every(he=>{var ge;return!Ac(he,u).command&&Vm(he,he.output??"").length===0&&!((ge=he.images)!=null&&ge.length)}),ue=n?q6(n):0,J=MF(t),M=[j,A].filter(Boolean).join(" ")+(b?", in the background":"")+(N?", queued":"")+(J?", done":""),oe=C?"":n?`${ue} ${ue===1?"call":"calls"}`:t.length>1?`×${t.length}`:"",ne=Zn(),H=ct(),se=P(he=>{var ge;return h?(ge=he.shipping[h])==null?void 0:ge.op:void 0}),ie=w&&m.name===si&&h?{worktreeId:h,toolId:y.id}:null;return d.jsxs(tg,{className:Ue("tool-row",t.some(he=>he.isError)&&"error",m.parentToolId&&"nested",n&&"spawn",N&&"queued"),state:gr({cursor:p}),auto:B,leaf:de,growing:_,label:n&&oe?`${M}, ${oe}`:t.length>1?`${M}, ${t.length} calls`:M,menu:he=>{const ge=kn(ne.getState(),h),Ie=ge?{id:ge.worktree.id,dir:ge.worktree.path}:null;return PF(t,u??[],Ie,{sock:H,dispatch:ne.dispatch},he)},summary:d.jsxs(d.Fragment,{children:[d.jsx(Nt,{name:n?"spawn":D,className:"tool-icon"}),X&&d.jsx("span",{className:Ue("tool-name",_&&!A&&"live-text"),children:X}),C&&!ae?d.jsx("span",{className:"tool-writing","data-tip":A,children:d.jsx(al,{variant:"squares"})}):A&&d.jsx("span",{className:Ue("tool-hint",_&&"live-text"),children:A}),b&&d.jsx("span",{className:"tool-status",children:"in the background"}),N&&d.jsx("span",{className:"tool-status",children:"queued"}),J&&d.jsx(Nt,{name:"check",className:"tool-done"}),T>=sc&&d.jsx("span",{className:Ue("tool-age",R>=0&&"tool-age-folded"),children:Ga(T)}),oe&&d.jsx("span",{className:"tool-count",children:oe}),ae&&d.jsx("span",{className:"tool-writing","data-tip":C,children:d.jsx(al,{variant:"squares"})}),ie&&d.jsx(Pt,{icon:"stop",className:"tool-stop",label:se?`Stop ${WF[se]}: this step is killed, and what it printed so far stays`:b?"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:he=>{he.preventDefault(),he.stopPropagation(),H==null||H.send({t:"exec-stop",...ie})}})]}),children:[n&&n.length>0&&d.jsx("div",{className:"spawn-run",children:n.map((he,ge)=>d.jsx(e,{tools:he.tools,next:he.next,since:ge===R?l:void 0,queued:O==null?void 0:O.has(ge),roots:u,worktreeId:h},he.at))}),g?d.jsx(UF,{text:g,item:m,roots:u,worktreeId:h}):t.map(he=>d.jsx(BF,{item:he,roots:u,worktreeId:h},he.id))]})},(e,t)=>e.live===t.live&&e.working===t.working&&e.since===t.since&&e.queued===t.queued&&e.next===t.next&&e.roots===t.roots&&e.worktreeId===t.worktreeId&&e.marked===t.marked&&qk(e.tools,t.tools)&&JS(e.run,t.run));function KF({item:e}){const t=ct(),n=lt(),r=P(w=>w.activeId),o=P(w=>w.layout.term),i=P(w=>{var b;return((b=w.rows.find(E=>E.id===w.activeId))==null?void 0:b.login)??!1}),l=P(w=>w.managed.problem),[c,u]=S.useState(""),[h,p]=S.useState(null),m=S.useRef(!1);if(St([i],()=>{i&&m.current&&r&&n({a:"term-stream",id:r,stream:Es,tall:!0})}),St([e.done],()=>{e.done&&m.current&&o&&n({a:"toggle-terminal"}),m.current=!1}),!r)return null;const g=(w,b)=>{t==null||t.send({t:"agent-auth",worktreeId:r,methodId:w,...b?{apiKey:b}:{}})},y=e.methods.find(w=>w.id===h);return d.jsxs("div",{className:`auth-card ${e.done?"done":""}`,children:[d.jsx("div",{className:"auth-title",children:e.done?`${e.agentName} is logged in`: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(w=>w.needsKey?d.jsx(ze,{variant:"outline",on:h===w.id,"data-tip":w.description,onClick:()=>p(h===w.id?null:w.id),children:w.name},w.id):d.jsx(ze,{variant:"outline","data-tip":w.kind==="terminal"?"opens in the terminal pane":w.description,onClick:()=>{g(w.id),w.kind==="terminal"&&(m.current=!0)},children:w.name},w.id)),d.jsx(ze,{variant:"outline","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:"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.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:w=>{w.preventDefault(),c.trim()&&(g(y.id,c.trim()),u(""),p(null))},children:[d.jsx(Eo,{type:"password",autoFocus:!0,placeholder:`${y.name} for ${e.agentName}`,value:c,onChange:w=>u(w.target.value)}),d.jsx(ze,{type:"submit",children:"use key"})]})]})}const ZF=S.memo(function({item:t,worktreeId:n,onPickHover:r,marked:o,streaming:i}){const l=Zn(),c=ct(),u=Wr(),h=wn("chat"),p={sock:c,dispatch:l.dispatch},m=()=>{const y=kn(l.getState(),n);return y?y.worktree.path:null},g=()=>{var y;return(y=kn(l.getState(),n))==null?void 0:y.worktree.path};switch(t.kind){case"user":{const y=g();return d.jsxs("div",{className:"msg-user row-edge","data-state":gr({cursor:o}),...h.contextMenu((w,b)=>Oi(t,n??null,p,{link:Ak(b,y),dir:m()})),onClick:w=>dN(w,y,n,p),children:[t.attachments&&n&&d.jsx("div",{className:"msg-attachments",children:t.attachments.map(w=>w.kind==="image"?d.jsx(sF,{img:w,src:u.attachment(n,w.file)},`${w.kind}-${w.n}`):w.kind==="file"?d.jsx(Kk,{className:"in-chat",name:w.name,bytes:w.bytes,href:w.text?u.attachment(n,w.file):void 0},`${w.kind}-${w.n}`):w.kind==="paste"?d.jsx(Wk,{className:"in-chat",n:w.n,name:w.name,source:w.source,lines:w.lines,chars:w.chars,preview:w.preview,href:u.attachment(n,w.file)},`${w.kind}-${w.n}`):d.jsx(Qk,{pick:w,dir:m(),className:"in-chat",tipText:"Hover to highlight on the page",onHover:b=>r==null?void 0:r(w,b),worktreeId:n,onOpen:(b,E)=>Wi(l,c,n,b,E)},`${w.kind}-${w.n}`))}),d.jsx(uN,{text:t.text,worktreeId:n,root:y})]})}case"assistant":return d.jsx(Yp,{text:t.text,menu:(y,w)=>Oi(t,n??null,p,{link:y,code:w,dir:m()}),marked:o,worktreeId:n,fileRoot:g(),streaming:i});case"error":return d.jsx("div",{className:"msg-assistant msg-error",...h.contextMenu(()=>Oi(t,n??null,p)),children:t.text});case"auth":return d.jsx(KF,{item:t});case"ask":{const y=HM(t);if(y){const _=Fg(y.questions,y.answers).join(`
233
+ `),N={kind:"assistant",text:_};return d.jsxs(d.Fragment,{children:[d.jsx(Yp,{text:y.message,menu:(T,R)=>Oi({kind:"assistant",text:y.message},n??null,p,{link:T,code:R,dir:m()}),worktreeId:n,fileRoot:g()}),d.jsx("div",{className:"msg-user",...h.contextMenu(()=>Oi(N,n??null,p)),children:_})]})}const w=WM(t);if(!w)return d.jsx(_z,{item:t});const b=w.file,E={kind:"assistant",text:w.choice};return d.jsxs(d.Fragment,{children:[b?d.jsx(eo,{icon:"file",word:"plan",tone:"quiet",children:d.jsx("span",{className:"daemon-text",children:d.jsx(ze,{variant:"inline",tone:"strong",mono:!0,onClick:()=>n&&er(p,{worktreeId:n,path:b,view:"preview"}),children:b})})}):w.text&&d.jsx(Yp,{text:w.text,menu:(_,N)=>Oi({kind:"assistant",text:w.text},n??null,p,{link:_,code:N,dir:m()}),worktreeId:n,fileRoot:g()}),d.jsx("div",{className:"msg-user",...h.contextMenu(()=>Oi(E,n??null,p)),children:w.choice})]})}case"blocked":return d.jsxs(eo,{icon:"lock",word:"blocked",tone:"red",below:d.jsx("div",{className:"daemon-below row-dim",children:t.reason}),...h.contextMenu(()=>nS(t.path,m(),void 0,as(p.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.jsxs(eo,{icon:"layers",word:"grafted",tone:"accent","data-tip":`what follows was said in ${t.title} before it was merged in here`,"data-tip-placement":"follow",children:[d.jsx("span",{className:"tool-name",children:t.title}),d.jsx("span",{className:"tool-hint",children:t.branch})]});case"asked":return d.jsx(eo,{icon:"send",word:"asked",tone:"quiet",children:d.jsx("span",{className:"daemon-text",children:t.why})});case"stopped":return d.jsx(eo,{icon:"stop",word:"stopped",tone:"quiet"});case"page-error":return d.jsx(eo,{icon:"globe",word:"preview threw",tone:"quiet",below:t.errors.map(y=>d.jsx("code",{className:"daemon-text",children:y},y))});case"landed":return d.jsx(GF,{item:t});case"handoff":return d.jsx(rF,{item:t});case"handoff-landed":return d.jsx(oF,{item:t});case"restored":return d.jsx(qF,{item:t});case"adopted":return d.jsx(eo,{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 qF({item:e}){return d.jsx(eo,{icon:"reload",word:"restored",tone:"quiet",at:e.ts,children:d.jsxs("span",{className:"daemon-text",children:["after ",qg(e.ts-e.archivedAt)," in the archive, back on ",e.branch,e.uncommitted?" with its uncommitted changes":""]})})}function GF({item:e}){const t=ct(),n=lt(),r=P(l=>e.archiveIds.filter(c=>kn(l,c)!==null).length),o=Z_(e.ts),i=e.mark&&bk(e.mark);return d.jsxs(eo,{icon:"check",word:"landed",tone:"aqua",at:e.ts,below:i?d.jsx("div",{className:"daemon-below row-dim",children:Hr(i)}):void 0,children:[d.jsxs("span",{className:"daemon-text",children:[e.text,", ",o]}),r>0&&d.jsx(ze,{variant:"inline",tone:"strong",onClick:()=>Hi(t,n,e.archiveIds),children:r>1?`archive ${r} worktrees`:"archive the other worktree"})]})}const kN=e=>e===""||e==="!";function ux(e,t){const n=new Set,r=[];for(let o=e.length-1;o>=0;o--){const i=e[o],l=Wf(i),c=l!==null?`!${l}`:i.kind==="user"&&!t?i.text:null;c===null||!c.trim()||n.has(c)||(n.add(c),r.push({text:c,at:o}))}return r}function VF(e,t,n,r){if(!t){if(r!=="up"&&r!=="first"||!kN(n))return null;const c=ux(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=ux(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 YF(e,t,n,r){const o=new Map;return{rows:t.map((l,c)=>{const u=n(l,c),h=e.get(l.at),p=h&&h.row.kind===u.kind&&XF(h.row.props,u.props)?h.el:r(l,u);return o.set(l.at,{row:u,el:p}),p}),cache:o}}function XF(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 dx={get current(){return hc.el}};function ng({items:e,next:t,worktreeId:n,dir:r,onOpen:o}){const i=Wr();return d.jsx("div",{className:"msg-attachments",children:vg(e,t).map(([l,c])=>l.kind==="image"?d.jsx(Gk,{className:"in-chat",src:"local"in l&&l.local||i.upload(l.upload),n:c,name:l.name,width:l.width,height:l.height,bytes:l.bytes,progress:"progress"in l?l.progress:void 0},`image-${c}`):l.kind==="file"?d.jsx(Kk,{className:"in-chat",name:l.name,bytes:l.bytes,href:l.text&&l.upload?i.upload(l.upload):void 0,progress:"progress"in l?l.progress:void 0},`file-${c}`):l.kind==="paste"?d.jsx(Wk,{className:"in-chat",n:c,name:l.name,source:l.source,...Rg(l.text),text:l.text},`paste-${c}`):d.jsx(Qk,{className:"in-chat",pick:l,dir:r,worktreeId:n,onOpen:o},`pick-${c}`))})}function QF({entry:e,next:t,worktreeId:n,dir:r,onOpen:o}){const i=lt(),l=It(e.id,"draft"),c=It(e.id,"attachments");return d.jsxs("div",{className:"msg-user queued-msg",children:[d.jsxs("span",{className:"queued-tag",children:[d.jsx(Nt,{name:"clock",className:"icon-inline"}),d.jsx("span",{className:"queued-word",children:"uploading"})]}),d.jsxs("div",{className:"queued-text",children:[c.length>0&&d.jsx(ng,{items:c,next:t,worktreeId:n,dir:r,onOpen:o}),l]}),d.jsxs("span",{className:"queued-actions",children:[d.jsx(Pt,{icon:"edit",label:"Edit: puts it back in the input",onClick:()=>i({a:"unsend",id:e.id})}),d.jsx(Pt,{icon:"close",label:"Remove: it is not sent",onClick:()=>i({a:"drop-out",id:e.id})})]})]})}const JF=new Set,e8=90;function Qp({active:e,archived:t,found:n,lead:r,tail:o}){var bn;const i=ct(),l=Zn(),c=lt(),u=P(ye=>ye.frame==="phone"),h=(e==null?void 0:e.worktree.id)??(t==null?void 0:t.id)??(n==null?void 0:n.id)??null,p=It(h,"chat"),m=It(h,"queue"),g=It(h,"restoring"),y=It(h,"sending"),w=S.useMemo(()=>dm(p.map(ye=>ye.kind==="user"?ye.attachments:void 0)),[p]),b=S.useMemo(()=>{let ye=w;return m.map(Me=>{const Bt=ye;return ye=lc(ye,Me.attachments??[]),Bt})},[m,w]),E=P(ye=>ye.outbox),_=S.useMemo(()=>{let ye=m.reduce((Me,Bt)=>lc(Me,Bt.attachments??[]),w);return E.filter(Me=>Me.log===h).map(Me=>{const Bt=ye;return ye=lc(ye,Me.kinds.map(jt=>({kind:jt}))),{entry:Me,next:Bt}})},[E,h,m,w]),N=y!=null&&y.message?m.findIndex(ye=>{var Me;return ye.text===((Me=y.message)==null?void 0:Me.text)}):-1,T=S.useRef(null);dz(T);const[R,O]=S.useState(null),B=S.useCallback(()=>{const ye=(T.current&&Bm(T.current))??"";O(Me=>({seed:ye||(Me==null?void 0:Me.seed)||"",seq:((Me==null?void 0:Me.seq)??0)+1}))},[]),$=S.useCallback(ye=>!(ye!=null&&ye.closest("[data-pane]"))&&!l.getState().overlay,[l]);Q_(dx,Tk,B,$);const C=ye=>{if(O(null),ye){const Me=window.getSelection();Me==null||Me.removeAllRanges(),Me==null||Me.addRange(ye)}},j=LE(T,p);St([h],()=>j.jump());const D=j.offStart&&j.moving==="up",z=j.offEnd&&(j.moving==="down"||j.away),X=ye=>ye.preventDefault(),ae=(D||z)&&d.jsxs("div",{className:Ue("jump",j.away&&"jump-news"),children:[D&&d.jsx("button",{className:"jump-up",onMouseDown:X,onClick:j.start,"data-tip":"Jump to start",children:d.jsx(Nt,{name:"caret-up",className:"icon-inline"})}),z&&d.jsxs("button",{className:"jump-down",onMouseDown:X,onClick:j.jump,"data-tip":"Jump to latest",children:[d.jsx(Nt,{name:"caret",className:"icon-inline"}),j.away&&" new messages"]})]});S.useEffect(()=>{const ye=T.current;if(!u||!j.offEnd||!ye){c({a:"reading",on:!1});return}const Me=()=>{var jt,fn;const Bt=((fn=(jt=dx.current)==null?void 0:jt.querySelector(":scope > .chat-input"))==null?void 0:fn.offsetHeight)??0;ye.scrollHeight-ye.scrollTop-ye.clientHeight<=Bt+Td+e8||(c({a:"reading",on:!0}),ye.removeEventListener("scroll",Me))};return Me(),ye.addEventListener("scroll",Me,{passive:!0}),()=>ye.removeEventListener("scroll",Me)},[u,j.offEnd,c]),S.useEffect(()=>()=>c({a:"reading",on:!1}),[c]);const A=It(h,"mark"),de=(A==null?void 0:A.by)==="walk"?A.at:void 0,ue=S.useRef(null),J=()=>{const ye=T.current,Me=ye==null?void 0:ye.querySelector(':scope > [data-state~="cursor"]');if(!ye||!Me)return;const Bt=parseFloat(getComputedStyle(ye).paddingTop)||0;ye.scrollTop+=Me.getBoundingClientRect().top-ye.getBoundingClientRect().top-Bt,j.read()};St([de],()=>{const ye=T.current;if(ye){if(de===void 0){const Me=ue.current;if(ue.current=null,!Me||!kN(_o(l.getState(),h).draft))return;Me.bottom?j.jump():(ye.scrollTop=Me.top,j.read());return}ue.current??(ue.current={bottom:j.pinned(),top:ye.scrollTop}),J()}});const M=It(h,"sent");St([M],()=>{M&&j.jump()});const oe=_.length,ne=S.useRef(oe);St([oe],()=>{oe>ne.current&&j.jump(),ne.current=oe});const H=(A==null?void 0:A.by)==="reveal"?A:void 0,se=S.useMemo(()=>H?nF(p,H.seq):-1,[p,H]),ie=de??(se>=0?se:void 0);St([H==null?void 0:H.n,se],()=>{se>=0&&J()});const he=S.useCallback((ye,Me)=>{h&&(Me?an.post(h,{type:"highlight-selector",selector:ye.selector,label:Zg(ye)}):an.post(h,{type:"highlight-clear"}))},[h]),ge=!!e&&zc(e),Ie=It(h,"cardParked"),ke=S.useMemo(()=>{const ye=mk(p);return!!ye&&Ie!==ye.id},[p,Ie]),Q=e==null?void 0:e.worktree,we=(Q==null?void 0:Q.path)??(t==null?void 0:t.path)??(n==null?void 0:n.path),te=S.useMemo(()=>we?[we]:[],[we]),Z=S.useMemo(()=>Z6(p,te),[p,te]),je=S.useMemo(()=>ge?G6(p):JF,[ge,p]),He=S.useMemo(()=>V6(Z,je),[Z,je]),Fe=He.floating,Pe=S.useRef([]),We=S.useMemo(()=>(Pe.current=Q6(Pe.current,He.flow),Pe.current),[He]),Ht=(e==null?void 0:e.agent)==="working",ut=Ht||(e==null?void 0:e.agent)==="waiting",vn=S.useMemo(()=>ut?eF(We):-1,[ut,We]),Jt=We.at(-1),xt=Ht&&Jt&&"item"in Jt&&(Jt.item.kind==="thinking"||Jt.item.kind==="assistant")?We.length-1:-1,kt=(bn=Z.findLast(ye=>{var Me;return"tools"in ye&&((Me=ye.tools[0])==null?void 0:Me.name)===si}))==null?void 0:bn.at,ot=It(h,"chatAt"),dt=il(ge?ot:void 0),Tt=It(h,"usage"),Et=(Tt==null?void 0:Tt.heard)!==void 0&&ot!==void 0&&Tt.heard>ot?Tt.heard:void 0,dn=il(ge?Et:void 0),G=Y6(p),ve=Fe.length>0,tt=xt>=0||G||ve,it=S.useMemo(()=>QS(We),[We]),ft=It(h,"running"),Gt=ye=>ft&&ye.tools.some(Me=>Me.id===ft.id)?ft.at:void 0,Ft=e==null?void 0:e.worktree.path,An=(ye,Me)=>"spawn"in ye?{kind:"tool",props:{tools:[ye.spawn],run:ye.run,roots:te,worktreeId:h}}:"tools"in ye?{kind:"tool",props:{tools:ye.tools,next:ye.next,live:Me===vn||ye.at===kt,since:Gt(ye),queued:it.has(Me),roots:te,worktreeId:h,marked:ye.at===ie}}:ye.item.kind==="thinking"?{kind:"thought",props:{item:ye.item,open:Me===vn,streaming:Me===xt,worktreeId:h,fileRoot:Ft}}:{kind:"item",props:{item:ye.item,worktreeId:h,onPickHover:he,marked:ye.at===ie,streaming:Ht&&Me===We.length-1}},qn=S.useRef(new Map),zt=YF(qn.current,We,An,(ye,Me)=>Me.kind==="tool"?d.jsx(md,{...Me.props},ye.at):Me.kind==="thought"?d.jsx(HF,{...Me.props},ye.at):d.jsx(ZF,{...Me.props},ye.at));return qn.current=zt.cache,d.jsxs("div",{className:"chat-wrap",children:[d.jsxs("div",{className:"chat-log",ref:T,children:[r,zt.rows,Fe.map(ye=>{var Me;return"spawn"in ye?d.jsx(md,{tools:[ye.spawn],run:ye.run,working:!0,since:ot,roots:te,worktreeId:h},ye.at):((Me=ye.tools[0])==null?void 0:Me.name)===si?d.jsx(md,{tools:ye.tools,live:ye.at===kt,since:Gt(ye),roots:te,worktreeId:h,marked:ye.at===ie},ye.at):d.jsx(md,{tools:ye.tools,since:ot,roots:te,worktreeId:h},ye.at)}),h&&(y==null?void 0:y.message)&&d.jsxs("div",{className:"msg-user",children:[y.message.attachments&&d.jsx(ng,{items:y.message.attachments,next:w,worktreeId:h,dir:(e==null?void 0:e.worktree.path)??null,onOpen:(ye,Me)=>Wi(l,i,h,ye,Me)}),y.message.text]}),e&&(y||ge&&!(e.agent==="waiting"&&ke)&&!G&&!ve&&!(tt&&dt<sc))&&d.jsx("div",{className:"working-row",children:e.agent==="waiting"?"waiting for your answer…":tt?dt>=sc&&d.jsxs("span",{children:["quiet for",d.jsx("span",{className:"working-num",children:Ga(dt)})]}):d.jsxs("span",{className:"working-mark",children:[d.jsx(al,{variant:"squares"}),Et!==void 0?dn>=sc&&d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"working-word",children:"thinking"}),d.jsx("span",{className:"working-num",children:Ga(dn)})]}):dt>=sc&&d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"working-word",children:"waiting for the model"}),d.jsx("span",{className:"working-num",children:Ga(dt)})]})]})}),h&&m.map((ye,Me)=>Me===N?null:d.jsxs("div",{className:"msg-user queued-msg",children:[d.jsxs("span",{className:"queued-tag",children:[d.jsx(Nt,{name:"clock",className:"icon-inline"}),d.jsx("span",{className:"queued-word",children:"queued"})]}),d.jsxs("div",{className:"queued-text",children:[ye.attachments&&d.jsx(ng,{items:ye.attachments,next:b[Me]??w,worktreeId:h,dir:(e==null?void 0:e.worktree.path)??null,onOpen:(Bt,jt)=>Wi(l,i,h,Bt,jt)}),ye.text]}),d.jsxs("span",{className:"queued-actions",children:[d.jsx(Pt,{icon:"edit",label:"Edit: removes from queue, puts it back in the input",onClick:()=>t_(l,i,h,Me)}),d.jsx(Pt,{icon:"close",label:"Remove from queue",onClick:()=>i==null?void 0:i.send({t:"unqueue",worktreeId:h,index:Me})})]})]},`q-${Me}`)),h&&_.map(({entry:ye,next:Me})=>d.jsx(QF,{entry:ye,next:Me,worktreeId:h,dir:(e==null?void 0:e.worktree.path)??null,onOpen:(Bt,jt)=>Wi(l,i,h,Bt,jt)},ye.id)),o,g!==void 0&&d.jsxs("div",{className:"msg-user queued-msg",children:[d.jsxs("span",{className:"queued-tag",children:[d.jsx(Nt,{name:"clock",className:"icon-inline"}),d.jsx("span",{className:"queued-word",children:n?"taking over":"restoring"})]}),g&&d.jsx("span",{className:"queued-text",children:g})]})]}),R&&d.jsx(Y_,{root:T,body:T,seed:R.seed,seq:R.seq,onClose:C,onReveal:j.read}),ae]})}function wN({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(Zo,{k:r}),o]},r)),t&&d.jsx("span",{className:"key-note",children:t})]})}const t8={side:"top",align:"start",offset:4,alignOffset:-10,matchWidth:-20,flip:"side",margin:8};function n8({results:e,keyOf:t,row:n,rowClass:r,nav:o,listRef:i,empty:l,note:c}){return d.jsxs(Ns,{className:"inline-picker",anchor:"parent",placement:t8,children:[d.jsxs("div",{className:"picker-list",ref:i,children:[e.map((u,h)=>d.jsx("button",{className:Ue("picker-item",r==null?void 0:r(u)),"data-state":gr({cursor:h===o.index}),onMouseMove:()=>h!==o.index&&o.setIndex(h),onMouseDown:p=>p.preventDefault(),onClick:()=>o.pick(u),children:n(u,h===o.index)},t(u))),e.length===0&&d.jsx("div",{className:"empty",children:l})]}),d.jsx(wN,{hints:[["↑↓","moves"],["tab","inserts"],["esc","dismisses"]],note:c})]})}const fx=e=>Math.max(0,Math.min(1,Number.isFinite(e)?e:0));function r8({fraction:e,level:t,className:n}){const o=2*Math.PI*5.5,i=fx(e),l=S.useId(),c=3.5,u=2*c*fx(t);return d.jsxs("svg",{className:Ue("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 o8(e,t=wc.folder.shared){return`New project: ${e}. The repository is empty apart from a root commit. Pick the mainstream stack for what the message describes, and say which in your first sentence; if the message names a stack, that wins. Scaffold it in this directory, write its .gitignore before installing anything, make it start on $PORT, and write ${t}.`}const rs="";function s8(e){var h;const t=a8(e.name);if(t){const p=[t.qualifier,e.description||e.name].filter(Boolean).join(" · ");return{label:t.label,version:t.version,description:p}}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 i8=/(?:^|[./])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 a8(e){const t=e.match(i8),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 yN(e,t,n,r){const o=qx(e),i=Fj(e),l=w=>i&&w===(o==null?void 0:o.id)?i.id:w,c=l(t||n||(o==null?void 0:o.id)||rs),u=l(t||(o==null?void 0:o.id)||rs),h=i?e.filter(w=>w!==o):e,p=h.some(w=>w.id===c),m=h.map(w=>({c:w,words:s8(w)})),g=w=>[w.label,w.version].filter(Boolean).join(" "),y=[...o?[]:[{id:rs,label:r.label,description:r.description}],...m.map(({c:w,words:b})=>{const E=m.filter(N=>g(N.words)===g(b)).length===1?b:void 0,_=E?E.description:w.description;return{id:w.id,label:E?E.label:w.name,...E!=null&&E.version?{suffix:E.version}:{},...E!=null&&E.version&&m.some(N=>N.c!==w&&N.words.label===E.label)?{chip:g(E)}:{},description:w===i?["recommended",_].filter(Boolean).join(" · "):_}}),...c&&!p?[{id:c,label:c}]:[]];if(c!==u){const w=y.find(_=>_.id===c),b=y.findIndex(_=>_.id===u),E=y[b];if(E){const _=(w==null?void 0:w.chip)??(w==null?void 0:w.label)??c;y[b]={...E,description:[`${_} now`,E.description].filter(Boolean).join(" · ")}}}return{rows:y,shown:c,picked:u}}const Jl=(e,t)=>`${e} ${t}`;function l8(e){const t=e.indexOf(" ");return t<0?{agent:e,model:rs}:{agent:e.slice(0,t),model:e.slice(t+1)}}function c8(e,t,n){const r=e.length>1;let o=Jl(t,n);return{rows:e.flatMap(l=>{var p;const c=l.short??l.name,u=l.id===t;if(!l.available||!((p=l.models)!=null&&p.length))return u&&(o=Jl(l.id,rs)),[{id:Jl(l.id,rs),label:c,description:l.available?"its own default model; the rest are listed once it has run":l.reason??"not installed",disabled:!l.available}];const h=yN(l.models,u?n:rs,void 0,{label:`${c} default`,description:`whatever ${l.name} runs when nothing is asked for`});return u&&(o=Jl(l.id,h.shown)),h.rows.map(m=>({...m,id:Jl(l.id,m.id),...r&&m.id!==rs?{prefix:c}:{}}))}),shown:o}}function Kf({anchored:e=!1,...t}){return e?d.jsx(u8,{...t,anchored:e===!0?{}:e}):d.jsx(d8,{...t})}function u8({onClose:e,onEscape:t,boxClass:n="",bare:r=!1,anchored:o,coverBy:i,id:l,children:c}){const{onKey:u,back:h}=vN(t);return d.jsx(Ns,{className:Ue(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 d8({onClose:e,onEscape:t,boxClass:n="",bare:r=!1,id:o,children:i}){const{onKey:l,back:c}=vN(t);return d.jsx(Ns,{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:Ue(r?"":"overlay-box",n),children:i})})}function vN(e){const t=Zn(),n=()=>{if(e)return e(),!0;const o=t.getState();return!o.overlay||o.choosingFolder?!1:(t.dispatch({a:"close",back:EE(o.overlay)}),!0)};return{onKey:o=>{o.key==="Escape"&&n()&&o.stopPropagation()},back:n}}function f8({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 Or({items:e,filter:t,keyOf:n,row:r,rowClass:o,rowTitle:i,onPick:l,onBack:c,onActive:u,onSide:h,onTab:p,onQuery:m,completionOf:g,narrowTo:y,placeholder:w,initialQuery:b="",initialIndex:E,selectOnMount:_=!1,idleWhen:N,onIdlePick:T,anchored:R=!1,onEscape:O,lead:B,trailing:$,empty:C="no matches",footer:j,keys:D,rowMenu:z,groupOf:X,groupHead:ae,headAlone:A=!1}){const de=wn("picker"),[ue,J]=S.useState(b),M=S.useMemo(()=>t(e,ue),[e,ue,t]),oe=S.useRef(null),ne=pi(),H=GL(_,!ne);S.useEffect(()=>{if(!m)return;const Z=setTimeout(()=>m(ue),150);return()=>clearTimeout(Z)},[ue,m]);const se=w_({results:M,keyOf:n,q:ue,onPick:l,listRef:oe,onActive:u,onSide:h,completionOf:g,narrowTo:y,setQ:J,initialIndex:E,idle:(N==null?void 0:N(b))??!1,onIdlePick:T}),{index:ie,ghost:he}=se,ge=typeof D=="function"?D(se.active,ue):D,Ie=[];ge!=null&&ge.nav&&Ie.push(["↑↓",ge.nav]),ge!=null&&ge.side&&h&&Ie.push(["←→",ge.side]),ge!=null&&ge.complete&&(he!=null&&he.accept)&&Ie.push(["tab",ge.complete]),ge!=null&&ge.tab&&p&&Ie.push(["tab",ge.tab]),ge!=null&&ge.pick&&Ie.push(["enter",ge.pick]),ge!=null&&ge.back&&Ie.push(["esc",ge.back]);const ke=d.jsxs("div",{className:"picker-input",onMouseDown:Z=>{var je;Z.target.closest("input")||(Z.preventDefault(),(je=H.current)==null||je.focus())},children:[B,d.jsxs("div",{className:"picker-caret",children:[d.jsx(Eo,{font:"mono",bare:!0,ref:H,value:ue,onChange:Z=>{J(Z.target.value),se.setIndex(N!=null&&N(Z.target.value)?-1:0)},onKeyDown:Z=>{var je;if(z&&se.active&&(Z.key==="ContextMenu"||Z.key==="F10"&&Z.shiftKey)){const He=(je=oe.current)==null?void 0:je.querySelector('[data-state~="cursor"]');if(He){Z.preventDefault(),Z.stopPropagation(),no.open({items:z(se.active),owner:"picker",target:He,anchor:He.getBoundingClientRect()});return}}se.onKeyDown(Z)||!p||Z.key!=="Tab"||Z.shiftKey||(Z.preventDefault(),p())},placeholder:w}),he&&d.jsxs("div",{className:"picker-ghost","aria-hidden":"true",children:[d.jsx("span",{className:"picker-typed",children:ue}),f8(he)]})]}),$]}),Q=new Map;if(X)for(const Z of M)Q.set(X(Z),(Q.get(X(Z))??0)+1);const we=d.jsxs("div",{className:"picker-list",ref:oe,children:[M.map((Z,je)=>{const He=X==null?void 0:X(Z),Fe=He!==void 0&&(A||Q.size>1)&&(je===0||(X==null?void 0:X(M[je-1]))!==He)?d.jsx("div",{className:"picker-group",children:(ae==null?void 0:ae(He,Q.get(He)??0))??He}):null;return d.jsxs(S.Fragment,{children:[Fe,d.jsx("button",{className:Ue("picker-item",o==null?void 0:o(Z)),"data-state":gr({cursor:je===ie}),title:i==null?void 0:i(Z),onMouseMove:()=>je!==ie&&se.setIndex(je),onClick:()=>{var Pe;se.pick(Z),(Pe=H.current)==null||Pe.focus()},...de.contextMenu(()=>(z==null?void 0:z(Z))??[]),children:r(Z,je===ie,ue)})]},n(Z))}),M.length===0&&d.jsx("div",{className:"empty",children:typeof C=="function"?C(ue):C}),j==null?void 0:j(ue,M)]}),te=Ie.length>0&&d.jsx(wN,{hints:Ie});return d.jsxs(Kf,{onClose:c,onEscape:O,boxClass:"picker",anchored:R,coverBy:B?".picker-input > *:first-child":$?".picker-input > *:last-child":void 0,children:[ke,we,te]})}function ni({value:e,reads:t,options:n,onChange:r,placeholder:o,hint:i,className:l,onClose:c}){const[u,h]=S.useState(!1),p=()=>{h(!1),c==null||c()},m=t??e,g=n.find(w=>w.id===m),y=(g==null?void 0:g.chip)??(g==null?void 0:g.label)??m;return d.jsxs("span",{className:"chip-picker",children:[d.jsx(ze,{variant:"ghost",tone:"chrome",mono:!0,on:u,className:Ue("chip-picker-btn",l),...Ut(i),onClick:()=>u?p():h(!0),children:y}),u&&d.jsx(Or,{anchored:{flip:"both",margin:0},onEscape:p,items:n,filter:(w,b)=>{const E=b.trim().toLowerCase().split(/\s+/).filter(Boolean);return w.filter(_=>{const N=`${_.prefix??""} ${_.label??_.id} ${_.suffix??""} ${_.id}`.toLowerCase();return E.every(T=>N.includes(T))})},keyOf:w=>w.id,initialIndex:w=>Math.max(0,w.findIndex(b=>b.id===e)),lead:d.jsx(ze,{tone:"chrome",mono:!0,on:!0,className:"chip-picker-lead",onClick:p,children:y}),placeholder:o,rowClass:()=>"picker-row",row:w=>d.jsxs(d.Fragment,{children:[w.id===e&&d.jsx("span",{className:"row-current","aria-hidden":"true"}),d.jsxs("span",{className:Ue("chip-option",w.disabled&&"chip-option-off"),"aria-disabled":w.disabled,children:[d.jsxs("span",{className:"chip-option-name",children:[w.prefix?`${w.prefix} `:null,w.label??w.id,w.suffix?d.jsx("span",{className:"chip-option-suffix",children:` ${w.suffix}`}):null]}),w.description&&d.jsx("span",{className:"chip-option-desc row-dim",children:w.description})]})]}),onPick:w=>{w.disabled||(r(w.id),p())},onBack:p})]})}function bN({choices:e,value:t,current:n,what:r,defaultLabel:o,defaultDescription:i,placeholder:l,className:c,onChange:u,onClose:h}){const{rows:p,shown:m,picked:g}=S.useMemo(()=>yN(e,t,n,{label:o,description:i}),[e,t,n,o,i]);if(e.length===0)return null;const y=p.find(b=>b.id===m),w=(y==null?void 0:y.chip)??(y==null?void 0:y.label)??m;return d.jsx(ni,{value:g,reads:m,options:p,onChange:u,onClose:h,className:c,hint:t?`asked for ${w}; click to change`:`${w}, the agent's choice; click to pick ${r}`,placeholder:l})}function h8(e){const[t,n]=bo(Qe.effortPrefix+(e??""),rs,r=>r??"",so().storage);return[t,n]}function hx({efforts:e,value:t,current:n,onChange:r,onClose:o}){return d.jsx(bN,{choices:e,value:t,current:n,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:r,onClose:o})}function p8(e){const[t,n]=bo(Qe.modePrefix+((e==null?void 0:e.id)??""),Rd,r=>Mc.some(o=>o.id===r)?r:Rd,so().storage);return[t,n]}const m8=e=>{var t;return((t=Mc.find(n=>n.id===e))==null?void 0:t.description)??""};function px({value:e,onChange:t,onClose:n}){return d.jsx(ni,{value:e,options:Mc.map(r=>({id:r.id,label:r.name,description:r.description})),onChange:t,onClose:n,className:Ue("mode-chip",e!=="auto"&&"mode-held"),hint:`${e}: ${m8(e)}. Click to change`,placeholder:"what the agent may do without asking"})}function g8(e){const[t,n]=bo(Qe.modelPrefix+(e??""),rs,r=>r??"",so().storage);return[t,n]}function k8(e,t,n){e.set(Qe.modelPrefix+t,n)}function mx({models:e,value:t,current:n,onChange:r,onClose:o}){return d.jsx(bN,{choices:e,value:t,current:n,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:r,onClose:o})}function w8({agents:e,agent:t,model:n,onChange:r,onClose:o}){const{rows:i,shown:l}=S.useMemo(()=>c8(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(ni,{value:l,options:i,onChange:h=>{const p=l8(h);r(p.agent,p.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 xN(e){const t=zf(e),[n,r]=bo(Qe.profilePrefix+((e==null?void 0:e.id)??""),(e==null?void 0:e.config.defaultProfile)??"",i=>i??void 0,so().storage);return[t.length===0?void 0:t.includes(n)?n:e==null?void 0:e.config.defaultProfile,r]}function y8({repo:e,value:t,onChange:n,onClose:r}){const o=zf(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)??[],p=h.length>0?`runs ${h.join(", ")}`:"runs nothing";return u===(e==null?void 0:e.config.defaultProfile)?`${p}; the default in ${l}`:p};return d.jsx(ni,{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 Rc(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 v8({c:e,query:t}){const n=t.trim();return d.jsxs(d.Fragment,{children:[d.jsxs("span",{className:"picker-name",children:["/",Rc(e.name,n?Xk(e.name,n):null,0)]}),d.jsx("span",{className:"picker-desc row-dim",children:e.description})]})}function On({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 b8(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 x8=/ \| | - | \u2013 | \u2014 | \u00b7 |: /,E8=/^(\d+|[0-9a-f]{8}-[0-9a-f-]{27}|[0-9a-f]{12,})$/i,_8=/^[[:$*{]|\[/;function S8(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(x8).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 ew(e){const t=e.split(/[/#]/).filter(Boolean);for(let n=t.length-1;n>=0;n--){let r=t[n];try{r=decodeURIComponent(r)}catch{}if(E8.test(r)||_8.test(r))continue;const o=r.replace(/[-_.]+/g," ").trim();if(o)return o[0].toUpperCase()+o.slice(1)}return"Home"}const Jp=8,N8=3,T8=50,j8=3;function C8(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?j2(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:S8(e),links:new Map(n.map(l=>[l.path,l.text]))}}function EN(e){if(!e)return"/";try{const t=new URL(e);return t.pathname+t.search+t.hash}catch{return"/"}}function A8(e){const t=e.trim();return/^[/?#]/.test(t)?t:`/${t}`}function I8(e,t){const n=/^[/?#]/.test(t)?e:e.replace(/^\//,"");return t&&n.toLowerCase().startsWith(t.toLowerCase())?n:null}const _N=e=>/^\[\[?\.\.\.|^\*$|^\$$/.test(e),ic=e=>_N(e)||/[[:$*{]/.test(e)&&!/^[^[{:$*]+\?$/.test(e),R8=e=>bf(`/${e}`).text.slice(1),tw=e=>e.split("/").filter(Boolean);function nw(e,t){const n=t.startsWith("/"),r=t.replace(/^\//,"").split("/"),o=tw(e);let i="";const l=[],c=m=>{const g=R8(m);l.push([i.length,i.length+g.length]),i+=g};for(let m=0;m<r.length;m++){const g=r[m],y=o[m];if(y===void 0)return null;if(m<r.length-1){if(_N(y))return{show:t,accept:t};if(ic(y)){if(!g)return null}else if(g.toLowerCase()!==y.toLowerCase())return null;i+=`${ic(y)?g:y}/`;continue}if(ic(y))g?i+=g:c(y);else{if(!y.toLowerCase().startsWith(g.toLowerCase()))return null;i+=y}}for(const m of o.slice(r.length))i+="/",ic(m)?c(m):i+=m;const u=n?1:0,h=(n?"/":"")+i,p=l[0];return{show:h,accept:p?h.slice(0,p[0]+u):h,params:l.map(([m,g])=>[m+u,g+u])}}function $8(e,t){const n=nw(e,t);return n?n.accept.length>t.length?n.accept:t:bf(e).literal}function SN(e,t){if(e.kind==="go")return null;if(e.template){const n=nw(e.path,t);return n&&n.show.length>t.length?n:null}return I8(e.path,t)}const O8=e=>e.trim().replace(/^\//,"").toLowerCase();function NN(e,t){for(let n=0;n<e.length;n++)if("/-_.#".includes(e[n])&&e.startsWith(t,n+1))return!0;return!1}function M8(e,t,n){const r=e.replace(/^\//,"").toLowerCase(),o=t.toLowerCase();return r===n?100:r.startsWith(n)?80:NN(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 L8(e,t){const{text:n,literal:r}=bf(e);return r.replace(/^\//,"").toLowerCase().startsWith(t)?80:nw(e,t)?70:NN(n.replace(/^\//,"").toLowerCase(),t)?60:0}function P8(e,t){const n=tw(e).findIndex(ic);return n>=0&&t.split("/").length>n}function pc(e,t,n){var c;const r=e.statics.get(t),o=r?null:C2(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)||ew(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 TN(e,t){const n=e.unseen[t.file];return{kind:"page",path:t.path,title:ew(t.path),template:!0,visited:!1,file:t.file,...n?{badge:n}:{},rank:Number.POSITIVE_INFINITY,group:t.path,score:0}}function Cd({rank:e,group:t,score:n,...r}){return r}const tf=e=>tw(e).length,nf=e=>e.badge==="new"?0:e.badge==="changed"?1:2;function D8(e,t){const n=new Set,r=[];e.history.forEach((p,m)=>{if(p.path===t)return;const g=pc(e,p.path,m);n.has(g.group)||(n.add(g.group),r.push(g))});const o=new Set(r.map(p=>p.path)),i=r.filter(p=>p.badge);for(const[p,m]of e.statics)e.unseen[m.file]&&p!==t&&!o.has(p)&&i.push(pc(e,p,Number.POSITIVE_INFINITY));for(const p of e.templateRoutes.values())e.unseen[p.file]&&!n.has(p.path)&&i.push(TN(e,p));i.sort((p,m)=>nf(p)-nf(m)||p.rank-m.rank);const l=r.filter(p=>!p.badge),c=i.slice(0,Jp-Math.min(N8,l.length));for(const p of l)c.length<Jp&&c.push(p);const u=new Set(c.map(p=>p.path)),h=[...e.statics.keys(),...[...e.links.keys()].filter(p=>!e.statics.has(p))].filter(p=>p!==t&&!u.has(p)&&!o.has(p)).sort((p,m)=>tf(p)-tf(m)||(p<m?-1:p>m?1:0));for(const p of h){if(c.length>=Jp)break;c.push(pc(e,p,Number.POSITIVE_INFINITY))}return c.map(Cd)}function z8(e,t,n){const r=O8(t),o=A8(t),i=new Map;e.history.forEach((y,w)=>{y.path!==n&&i.set(y.path,pc(e,y.path,w))});for(const y of[...e.statics.keys(),...e.links.keys()])y!==n&&!i.has(y)&&i.set(y,pc(e,y,Number.POSITIVE_INFINITY));const l=[];for(const y of i.values()){const w=M8(y.path,y.title,r);w>0&&l.push({...y,score:w})}let c=null;for(const y of e.templates){const w=e.templateRoutes.get(y.path);if(!c&&!e.statics.has(o)&&y.re.test(o)){c=w;continue}const b=L8(y.path,r);b>=60&&l.push({...TN(e,w),score:b})}l.sort((y,w)=>w.score-y.score||y.rank-w.rank||nf(y)-nf(w)||tf(y.path)-tf(w.path)||(y.path<w.path?-1:y.path>w.path?1:0));const u=new Map,h=[];for(const y of l){if(!y.template&&y.group!==y.path){const w=u.get(y.group)??0;if(w>=j8&&!P8(y.group,r))continue;u.set(y.group,w+1)}if(h.push(y),h.length>=T8)break}if(h.some(y=>y.score===100))return h.map(Cd);const p={kind:"go",path:o,title:ew((c==null?void 0:c.path)??o)},m=h[0];return!c&&m!==void 0&&m.score>=80&&F8(m.path,r)?[...h.map(Cd),p]:[p,...h.map(Cd)]}function F8(e,t){const n=e.replace(/^\//,"").toLowerCase().slice(t.length);return!t.endsWith("/")&&n.length>0&&!/^[/?#]/.test(n)}function jN(e,{query:t,current:n,here:r}){return t===n||t.trim()===""?D8(e,r):z8(e,t,r)}const B8=[],U8=[];function CN(e,t){const n=P(i=>(t?i.visits[t]:void 0)??B8),r=It(e,"pages"),o=It(e,"links");return St([e],()=>{hE(r)&&an.post(e,{type:"links"})}),S.useMemo(()=>C8(n,r,o),[n,r,o])}function H8({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}=bf(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 AN({row:e}){return d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"picker-label",children:e.title}),d.jsx(H8,{row:e}),e.kind==="go"?d.jsx("span",{className:"picker-hint row-dim",children:"as typed"}):e.badge?d.jsx("span",{className:e.badge==="new"?"badge-new":"badge-changed",children:e.badge}):null]})}const IN=e=>e.kind==="page"&&e.file?e.file:e.path,RN=(e,t)=>e.kind==="page"&&e.template?$8(e.path,t):null,$N=e=>e.kind==="page"&&e.template?"fills in the parameter":"goes there";function ON(e,t,n){return e.kind!=="page"?[]:If([...e.file&&t.dir?xs({id:t.worktreeId,dir:t.dir},e.file,{},n):[],ZE,...e.visited?b8(t.repoId,e.path,n):[]])}function W8({worktreeId:e,repoId:t,url:n}){const r=lt(),o=ct(),i=P(g=>{const y=kn(g,e);return y?y.worktree.path:null}),l=CN(e,t),c=EN(n),u=n?vf(n):null,h=S.useCallback((g,y)=>jN(l,{query:y,current:c,here:u}),[l,c,u]),p=S.useCallback(g=>g===c||g.trim()==="",[c]),m=()=>r({a:"close"});return d.jsx(Or,{anchored:{matchWidth:0},items:U8,filter:h,initialQuery:c,selectOnMount:!0,idleWhen:p,onIdlePick:()=>{an.post(e,{type:"reload"}),m()},keyOf:g=>`${g.kind}:${g.path}`,rowClass:()=>"picker-row",rowTitle:IN,completionOf:(g,y)=>p(y)?null:SN(g,y),narrowTo:RN,onPick:g=>{an.post(e,{type:"navigate",path:g.path}),m()},onBack:m,rowMenu:g=>ON(g,{worktreeId:e,repoId:t,dir:i},{sock:o,dispatch:r}),placeholder:"type a path",keys:g=>({complete:"completes the path",pick:g?$N(g):"reloads",back:"closes"}),empty:"no pages yet; type a path",row:g=>d.jsx(AN,{row:g})})}function MN(e,t){const n=t.trim();return d.jsx(On,{label:Rc(e.label,n?Xk(e.label,n):null,0),hint:e.hint&&d.jsx(Zo,{k:e.hint})})}function LN({anchored:e,trailing:t}){const n=lt(),r=aN(),o=P(i=>{var l;return((l=i.paletteReturn)==null?void 0:l.mode)==="commands"?i.paletteReturn.q:""});return d.jsx(Or,{anchored:e,trailing:t,items:r,filter:lN,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)=>MN(i,c)})}function PN(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 gx(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 DN(e,t,n,r=50){const o=PN(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)||gx(m.path,g.path)),p=o.filter(m=>!m.status).sort((m,g)=>gx(m.path,g.path));return{rows:[...h,...p].slice(0,r),changed:Math.min(h.length,r)}}const l=FN(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 zN(e,t){const n=e.toLowerCase(),r=kx(n,t);return r<=0?0:kx(n.slice(n.lastIndexOf("/")+1),t)>0?r+10:r}function FN(e,t){const n=[];for(const r of e){const o=zN(r.path,t);o>0&&n.push({row:r,score:r.status?o+4:o})}return n}function K8(e,t,n,r,o){const i=r.trim().toLowerCase();if(!i)return DN(e,n,r,o).rows.map(u=>({kind:"file",path:u.path,status:u.status}));const l=FN(PN(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=zN(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 Z8(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 kx(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 q8(e){const t=e.lastIndexOf("/");return t===-1?[e,""]:[e.slice(t+1),e.slice(0,t+1)]}const wx=[],G8=[],V8=[];function Y8({worktreeId:e}){var b;const t=lt(),n=ct(),r=Zn();St([e,n],()=>$f(e,r.getState(),{sock:n,dispatch:t}));const o=BE(e),i=o.files??G8,l=((b=o.git)==null?void 0:b.files)??V8,c=aN(),u=P(E=>{var _;return((_=E.paletteReturn)==null?void 0:_.mode)==="quick-open"?E.paletteReturn.q:""}),h=P(E=>{var N;const _=(N=kn(E,e))==null?void 0:N.worktree;return _?_.path:null}),p=P(E=>{var _;return((_=kn(E,e))==null?void 0:_.repoId)??null}),m=P(E=>{var _;return((_=Wd(E))==null?void 0:_.worktreeId)===e}),g=CN(e,p),y=o.page.url?vf(o.page.url):null,w=S.useCallback((E,_)=>_.startsWith(">")?lN(c,_.slice(1)).map(N=>({kind:"cmd",c:N})):_.startsWith("/")?m?jN(g,{query:_,current:"/",here:y}).map(N=>({kind:"page",page:N})):wx:DN(i,l,_).rows.map(N=>({kind:"file",path:N.path,status:N.status})),[c,i,l,m,g,y]);return d.jsx(Or,{items:wx,filter:w,keyOf:E=>E.kind==="cmd"?`c:${E.c.id}`:E.kind==="page"?`p:${E.page.kind}:${E.page.path}`:`f:${E.path}`,rowClass:E=>E.kind==="file"?"qo-file":"picker-row",rowTitle:E=>E.kind==="page"?IN(E.page):void 0,completionOf:(E,_)=>E.kind==="page"?SN(E.page,_):null,narrowTo:(E,_)=>E.kind==="page"?RN(E.page,_):null,onPick:(E,_)=>{E.kind==="cmd"?(E.c.sub?t({a:"palette-return",v:{mode:"quick-open",q:_}}):t({a:"close"}),E.c.run()):E.kind==="page"?(an.post(e,{type:"navigate",path:E.page.path}),t({a:"close"})):(er({dispatch:t},{worktreeId:e,path:E.path,view:qi(E.path)}),t({a:"close"}))},onBack:()=>t({a:"close"}),rowMenu:E=>E.kind==="file"&&h?xs({id:e,dir:h},E.path,{},{sock:n,dispatch:t}):E.kind==="page"&&p?ON(E.page,{worktreeId:e,repoId:p,dir:h},{sock:n,dispatch:t}):[],placeholder:"jump to file · type > for commands, / for pages",keys:(E,_)=>_.startsWith("/")?{complete:"completes the path",pick:(E==null?void 0:E.kind)==="page"?$N(E.page):void 0,back:"closes"}:{pick:"opens",back:"closes"},initialQuery:u,empty:E=>E.startsWith(">")?"no matching command":E.startsWith("/")?m?"no pages yet; type a path":"no preview running":"no matches",row:(E,_,N)=>E.kind==="cmd"?MN(E.c,N.slice(1)):E.kind==="page"?d.jsx(AN,{row:E.page}):rg(E.path,E.status,N,{gutter:l.length>0})})}function rg(e,t,n,{folder:r=!1,gutter:o=!0}={}){const[i,l]=q8(e),c=n.trim()?Z8(e,n.trim()):null;return d.jsxs(d.Fragment,{children:[o&&d.jsx("span",{className:`xy ${t?Wg(t.xy):""}`,children:t?Kg(t.xy):""}),d.jsxs("span",{className:"name",children:[Rc(i,c,l.length),r&&"/"]}),d.jsx("span",{className:"dir row-dim",children:l&&d.jsxs(d.Fragment,{children:["‎",Rc(l,c,0),"‎"]})}),t&&d.jsx(F_,{f:t})]})}function Ma({icon:e,verb:t,tip:n,onPress:r,onDismiss:o,children:i}){return d.jsxs("div",{className:"composer-offer",children:[d.jsx(Nt,{name:e,className:"icon-inline"}),d.jsxs("span",{className:"composer-offer-line",children:[d.jsx(ze,{variant:"inline",tone:"strong","data-tip":n,onClick:r,children:t})," ",i]}),o&&d.jsx(Pt,{icon:"close",tone:"quiet",className:"composer-offer-close",label:"Not this one",onClick:o})]})}function BN({item:e,n:t,onRemove:n}){const r=Wr();return e.kind==="image"?d.jsx(Gk,{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(Kk,{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(Wk,{n:t,name:e.name,source:e.source,lines:e.lines,chars:e.chars,preview:e.preview,text:e.text,onRemove:n})}const yx=8,X8=104,Q8=.25,UN=220;function J8({dx:e,dy:t}){return Math.abs(e)<yx&&Math.abs(t)<yx?null:Math.abs(e)>Math.abs(t)&&e<0?"slide":"other"}function e9(e,t,n=X8){const r=Math.max(0,-e),o=t*n,i=Math.min(t,Math.floor(r/n)),l=r<=o?r:o+(r-o)*Q8;return{step:i,x:-l}}function HN(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=0,h=0;const p=(N,T,R)=>{N.el.dataset.slide!==R&&(N.el.dataset.slide=R,N.el.offsetWidth),N.el.style.setProperty("--slide-x",`${T}px`)},m=N=>{N.el.style.removeProperty("--slide-x"),delete N.el.dataset.slide},g=()=>{const N=o,T=l,R=c;o=null,i=null,l=!1,c=0,!(!N||!T)&&(p(N,0,"settle"),R>0&&n.current.onPick(N.key,R),u=window.setTimeout(()=>{m(N),n.current.onSlide(null)},UN))};let y=null;const w=N=>{if(!N.isPrimary||N.pointerType==="mouse"&&N.button!==0)return g();const T=N.target instanceof Element?n.current.rowOf(N.target):null;!T||T.el.dataset.slide||(window.clearTimeout(u),o=T,y=N.pointerId,i={x:N.clientX,y:N.clientY})},b=N=>{var $;const T=o;if(!T||!i||N.pointerId!==y)return;const R=N.clientX-i.x,O=N.clientY-i.y;if(!l){const C=J8({dx:R,dy:O});if(C==="other"&&(o=null,i=null,y=null),C!=="slide")return;l=!0;try{T.el.setPointerCapture(N.pointerId)}catch{}n.current.onSlide({key:T.key,step:0})}const B=e9(R,T.rungs,T.rung);p(T,B.x,"drag"),B.step!==c&&(c=B.step,n.current.onSlide({key:T.key,step:c}),c>0&&(($=navigator.vibrate)==null||$.call(navigator,8)))},E=N=>{N.pointerId===y&&(l&&(h=N.timeStamp+400),y=null,g())},_=N=>{N.timeStamp>=h||(N.preventDefault(),N.stopPropagation())};return r.addEventListener("pointerdown",w),r.addEventListener("pointermove",b),r.addEventListener("pointerup",E),r.addEventListener("pointercancel",E),r.addEventListener("click",_,!0),()=>{window.clearTimeout(u),r.removeEventListener("pointerdown",w),r.removeEventListener("pointermove",b),r.removeEventListener("pointerup",E),r.removeEventListener("pointercancel",E),r.removeEventListener("click",_,!0)}},[e])}function rf({rows:e,cursor:t,onCursor:n,onPick:r,onHint:o,hover:i=!1}){const l=pi(),c=S.useRef(null),[u,h]=S.useState(null),p=l&&!!o;HN(c,{rowOf:g=>{if(!p||g.closest("textarea"))return null;const y=g.closest(".slide"),w=y==null?void 0:y.dataset.row,b=w===void 0?void 0:e[Number(w)];return y&&w!==void 0&&(b!=null&&b.hint)&&!b.field?{el:y,key:w,rungs:1,rung:120}:null},onSlide:h,onPick:g=>o==null?void 0:o(Number(g))});const m=g=>{var y;g.target instanceof HTMLTextAreaElement||(g.preventDefault(),(y=g.currentTarget.querySelector("textarea"))==null||y.focus())};return d.jsx("div",{className:Ue("choices",i&&"choices-hover",l&&"choices-touch"),ref:c,children:e.map((g,y)=>{const w=!l&&t===y,b=gr({cursor:w,checked:g.checked}),E=g.tone==="deny"&&"choice-deny",_=()=>n&&t!==y&&n(y),N=R=>{var $;if(!p)return R;const O=(u==null?void 0:u.key)===String(y)?u.step:null,B=O!==null&&O>0&&(($=g.hint)==null?void 0:$.on)!==!1;return d.jsxs("div",{className:"slide","data-row":y,children:[R,O!==null&&g.hint&&d.jsxs("span",{className:"slide-verb","data-rung":B?"hint":void 0,"aria-hidden":"true",children:[d.jsx("span",{className:"slide-word",children:g.hint.label}),d.jsx(Nt,{name:g.hint.icon})]})]},y)},T=d.jsxs(d.Fragment,{children:[!l&&d.jsx(Zo,{k:String(y+1),className:"choice-num row-dim"}),d.jsx("span",{className:"choice-label",children:g.label}),!l&&g.hint&&d.jsxs("span",{className:Ue("choice-hint row-dim",w&&g.hint.on!==!1&&"on"),children:[d.jsx(Zo,{k:g.hint.k})," ",g.hint.label]}),g.description&&d.jsx("span",{className:"choice-desc",children:g.description})]});return g.field?N(d.jsxs("div",{className:Ue("picker-item choice row-edge",E),"data-state":b,onMouseMove:_,onMouseDown:m,children:[T,d.jsx(Tc,{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:R=>{var O;return(O=g.field)==null?void 0:O.onChange(R.target.value)}})]},y)):N(d.jsx("button",{type:"button",className:Ue("picker-item choice row-edge",E),"data-state":b,disabled:g.disabled,onMouseMove:_,onClick:()=>r(y),children:T},y))})})}function t9(e){return Ad(e.key)&&(e.metaKey||e.ctrlKey)&&!e.altKey?!1:e.metaKey||e.ctrlKey||e.altKey}const n9=e=>e.length===1&&e>="1"&&e<="9",Ad=e=>e==="Enter"||e==="NumpadEnter";function r9(e,t,n){const r=Ad(e.key)&&(e.metaKey||e.ctrlKey);return t?e.key==="Escape"||e.key==="Tab"&&!e.shiftKey?{kind:"field-leave"}:r?{kind:"submit"}:Ad(e.key)&&!e.shiftKey?{kind:"field-enter"}:{kind:"typing"}:t9(e)?{kind:"chord"}:e.key==="Escape"?{kind:"escape"}:r?{kind:"submit"}:Ad(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:Wc(n.cursor,e.key==="ArrowUp"?-1:1,n.count)}:n9(e.key)&&Number(e.key)<=n.count?{kind:"pick",at:Number(e.key)-1,by:"digit"}:null}function rw(e,t){var o,i,l,c;const n=e.target instanceof HTMLTextAreaElement,r=r9(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 o9(e){return!e||e===document.body?!1:e.closest(".monaco-editor, .xterm")?!0:(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement)&&!e.closest(".chat-input")}function s9(e,t){St([t],()=>{const o=requestAnimationFrame(()=>{var i;o9(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 ow({root:e,id:t,onKeyDown:n,onKeyUp:r,onPaste:o,children:i}){const l=s9(e,t);return d.jsx("div",{ref:e,className:"card",tabIndex:-1,onKeyDown:n,onKeyUp:r,onPaste:o,onBlur:l,children:i})}function of({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 sf(e){const t=S.useRef(null),n=Jk(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:e.still?void 0:t,className:Ue("card-band card-code",e.still&&"card-still"),children:[d.jsx("pre",{children:e.code}),!e.still&&n]})}function i9({children:e}){return d.jsx("div",{className:"card-foot",children:e})}const a9=[{selected:[]}],em=0,l9=2;function c9({item:e,worktreeId:t,rootRef:n}){var $;const r=ct(),o=lt(),i=It(t,"card"),l=(i==null?void 0:i.id)===e.id?i.draft:a9,c=($=l[0])==null?void 0:$.note,u=c!==void 0,h=C=>o({a:"card-draft",id:t,card:{id:e.id,draft:C,current:0}}),p=S.useRef(null),[m,g]=S.useState(em),[y,w]=S.useState(!1),b=S.useMemo(()=>Qa(e.message),[e.message]),E=C=>{y||!r||(r.send(n4(e,t,C,c)),C&&w(!0),o({a:"answered",id:t}))},_=()=>{u||h(Bd(l,0,"")),g(em),requestAnimationFrame(()=>{var C;return(C=p.current)==null?void 0:C.focus()})},N=C=>E(C===em),T=()=>o({a:"card-park",id:t,cardId:e.id}),R=()=>{var j;const C=_d(l,0);C!==l&&h(C),(j=n.current)==null||j.focus()},O=C=>{rw(C,{count:l9,cursor:m,onCursor:g,onPick:N,onEscape:T,onFieldEnter:()=>E(!0),onFieldLeave:R})||C.key==="n"&&(C.preventDefault(),_())},B=[{label:"go",hint:{k:"n",label:"add context",icon:"edit",on:!u},checked:u,field:u?{ref:p,value:c??"",placeholder:"a note for the agent there, sent with go",enterKeyHint:"send",onChange:C=>h(Bd(l,0,C))}:void 0,description:y?"starting":void 0,disabled:y},{label:"not now",tone:"deny",disabled:y}];return d.jsxs(ow,{root:n,id:e.id,onKeyDown:O,children:[d.jsxs(of,{sub:d.jsxs(d.Fragment,{children:["Starts a worktree in ",e.repo.path,", in ",e.mode," mode",e.mode==="auto"?", which runs without asking":"",". Nothing has started yet."," ",e.by==="agent"?"Proposed by this worktree's agent.":"You asked for this."]}),children:["Continue in ",e.repo.name,"?"]}),d.jsx(sf,{html:b}),d.jsx(rf,{rows:B,cursor:m,onCursor:g,onPick:N})]})}function u9(e,t){if(t.queued>0||t.sending||t.card)return null;const n=e.at(-1);if(!n)return null;const r=e.filter(c=>c.kind!=="page-error"),o=r.at(-1);if(o&&(o.kind==="stopped"||o.kind==="error")){if(o.seq===void 0)return null;const c=`${o.kind}:${o.seq}`;return t.dismissed.has(c)?null:o.kind==="stopped"?{verb:"continue",key:c,after:"stop"}:{verb:"continue",key:c,after:"error",...f9(r)?{again:!0}:{}}}const i=d9(e,t.dismissed);if(i!==void 0)return i;if(n.kind!=="tool"||!n.done||!n.fixable||t.dismissed.has(n.id)||e.some(c=>c.kind==="asked"&&c.toolId===n.id))return null;const l=Wf(n);return l===null?null:{verb:"fix",key:n.id,toolId:n.id,command:l}}function d9(e,t){let n=0,r;for(let i=e.length-1;i>=0;i--){const l=e[i];if(l.kind==="page-error")r??(r=l.seq),n+=l.errors.length;else{if(l.kind==="user"||l.kind==="asked")break;if(l.kind==="tool"&&gg({name:l.name,kind:l.toolKind}))break}}if(n===0)return;if(r===void 0)return null;const o=`page:${r}`;return t.has(o)?null:{verb:"fix",key:o,page:{errors:n}}}function f9(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 og=new Set;const sg=new Set;function h9(e){return sg.add(e),()=>{sg.delete(e)}}function tm(e){og=new Set(og).add(e);for(const t of sg)t()}function p9(){return S.useSyncExternalStore(h9,()=>og)}const m9=e=>Mc.some(t=>t.id===e);function g9(e){return[...Mc.map(t=>({name:t.id,description:t.description,hint:"[<description>]"})),{name:"check",description:"run the repo's check here and write the recap and the commit message",hint:"[<note for the commit message>]"},{name:"land",description:e},{name:"archive",description:"archive this worktree once its work has landed"},{name:"handoff",description:"continue this work in another project; Toyon starts a worktree there with your message",hint:"<project> [<message>]"}]}function WN(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 k9(e,t){const n=WN(e,t);return[...n.yours,...n.own,...n.rest]}function vx(e,t){const n=WN(e,t);return{rows:[...n.yours,...n.own],more:n.rest.length}}function w9(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 y9({item:e,ask:t,worktreeId:n,rootRef:r}){const o=ct(),i=lt(),l=P(w=>w.activeId),[c,u]=S.useState(0),h=t.plan,p=S.useMemo(()=>t.detail&&!h?Qa(t.detail):"",[t.detail,h]),m=()=>{h&&l===n&&er({dispatch:i},{worktreeId:n,path:h,view:"preview",focus:!1})};St([e.id,h],m);const g=w=>{const b=t.choices[w];b&&(o==null||o.send({t:"agent-decide",worktreeId:n,askId:e.id,choiceId:b.id}),i({a:"answered",id:n}))},y=w=>{rw(w,{count:t.choices.length,cursor:c,onCursor:u,onPick:g,onEscape:()=>i({a:"card-park",id:n,cardId:e.id})})};return d.jsxs(ow,{root:r,id:e.id,onKeyDown:y,children:[d.jsx(of,{children:t.title}),t.command&&d.jsx(sf,{code:KS(t.command)}),p&&d.jsx(sf,{html:p}),d.jsx(rf,{rows:t.choices.map(w=>({label:w.name,tone:w.kind.startsWith("reject")?"deny":void 0})),cursor:c,onCursor:u,onPick:g})]})}function v9({item:e,ask:t,worktreeId:n,rootRef:r,numbers:o,onScreen:i,onAnswer:l}){const c=ct(),u=lt(),h=Zn(),p=P(Q=>Q.clientId),m=pi(),{message:g,questions:y}=t,w=Ka(e.id),b=It(w,"attachments"),E=f_(w,n),_=It(n,"card"),N=S.useMemo(()=>(_==null?void 0:_.id)===e.id?_:{id:e.id,draft:DM(y),current:0},[_,e.id,y]),{draft:T,current:R}=N,O=R===fc(y),B=y[R],$=T[R],C=!!(B!=null&&B.multi),[j,D]=S.useState(()=>Fa(B,$)),z=S.useRef(null);S.useEffect(()=>{const Q=window.visualViewport;if(!Q)return;const we=()=>{z.current&&z.current===document.activeElement&&z.current.scrollIntoView({block:"nearest"})};return Q.addEventListener("resize",we),()=>Q.removeEventListener("resize",we)},[]);const X=(Q,we)=>u({a:"card-draft",id:n,card:{id:e.id,draft:Q,current:we}}),ae=Q=>{if(l){Q&&l(Q);return}const we=Q?b:[],te={t:"agent-answer",worktreeId:n,askId:e.id,...Q?{answers:Q}:{}};we.some(li)?u({a:"hold-send",id:w,log:n,text:Fg(y,Q).join(`
234
+ `),frame:te}):(c==null||c.send({...te,...we.length?{attachments:we.map(Ec),boxId:w,clientId:p}:{}}),we.length&&u({a:"clear-attachments",id:w})),u({a:"answered",id:n})},A=()=>u(l?{a:"ask-revive",id:n}:{a:"card-park",id:n,cardId:e.id}),de=()=>{sd(y,T)&&ae(T)},ue=Q=>{D(Fa(y[Q],T[Q])),X(T,Q)},J=Q=>{B!=null&&B.note&&(X(k0(T,R,Q,C),R),requestAnimationFrame(()=>{var we;return(we=z.current)==null?void 0:we.focus()}))},M=Q=>{if(!(B!=null&&B.note))return;const we=B.options[Q];if(D(Q),!we||C)return J(!we);X(k0(g0(T,R,we.value,!1),R,!1,!1),R),requestAnimationFrame(()=>{var te;return(te=z.current)==null?void 0:te.focus()})},oe=()=>M(j),ne=Q=>{if(FM(B,Q))return D(Q),J(!0);const we=B==null?void 0:B.options[Q];if(!B||!we)return;const te=g0(_d(T,R),R,we.value,C);if(C){D(Q),X(te,R);return}const Z=w0(y,te,R);D(Z.cursor),X(te,Z.current),Z.send&&sd(y,te)&&ae(te)},H=()=>{var we;const Q=_d(T,R);Q!==T&&(X(Q,R),D(Fa(B,Q[R]))),(we=r.current)==null||we.focus()},se=()=>{var te;const Q=_d(T,R);if((te=r.current)==null||te.focus(),!qa(Q[R])){Q!==T&&(X(Q,R),D(Fa(B,Q[R])));return}const we=w0(y,Q,R);D(we.cursor),X(Q,we.current),we.send&&sd(y,Q)&&ae(Q)},ie=Q=>{if(E.onPasteKey(Q),!rw(Q,{count:O?y.length:zM(B),cursor:O?void 0:j,spacePicks:C,onCursor:D,onPick:we=>O?ue(we):ne(we),onSubmit:de,onEscape:A,onFieldEnter:se,onFieldLeave:H})){if(Q.key==="ArrowLeft"||Q.key==="ArrowRight"||Q.key==="Tab"){Q.preventDefault();const we=Q.key==="ArrowLeft"||Q.key==="Tab"&&Q.shiftKey;return ue(KM(R,we?-1:1,qM(y)))}if(Q.key==="n"&&(B!=null&&B.note))return Q.preventDefault(),oe();if(Q.key==="s"&&!l)return Q.preventDefault(),ae()}},he=Q=>y.length===1&&!Q.multi,ge=(Q,we)=>d.jsxs(i9,{children:[(!Q||!he(Q)||m&&(we==null?void 0:we.note)!==void 0)&&d.jsx(ze,{variant:"outline",size:"md",disabled:!sd(y,T),onClick:de,children:"send"}),(Q==null?void 0:Q.note)&&we&&we.selected.length>0&&we.note===void 0&&d.jsxs(ze,{tone:"quiet",size:"md",onClick:()=>J(!1),children:[d.jsx(Zo,{k:"n",chip:!0}),"add a note"]}),!l&&d.jsxs(ze,{tone:"quiet",size:"md",onClick:()=>ae(),children:[d.jsx(Zo,{k:"s",chip:!0}),"skip"]}),d.jsx(Pt,{className:"card-attach",icon:"attach",tone:"chrome",label:i?"Attach a picture":"Attach a picture or a file",onClick:()=>c_(h,w,{images:i})})]}),Ie=b.length>0&&d.jsx("div",{className:"card-chips",children:vg(b,o).map(([Q,we])=>{const te=()=>u({a:"detach",id:w,key:Q.key});return Q.kind==="pick"?null:d.jsx(BN,{item:Q,n:we,onRemove:te},Q.key)})}),ke=(Q,we)=>{const te=we===R,Z=T[we],je=iE(Z,!!Q.multi),He=te?Q.options[j]:void 0,Fe=We=>({ref:te?z:void 0,value:(Z==null?void 0:Z.note)??"",placeholder:We,enterKeyHint:fc(y)===-1?"send":"next",onChange:Ht=>X(Bd(T,we,Ht),we)}),Pe=Q.options.map(We=>{const Ht=!!(Z!=null&&Z.selected.includes(We.value));return{label:d.jsxs(d.Fragment,{children:[Bg(We.label),GM(We.label)&&d.jsx("span",{className:"badge-recommended",children:"recommended"})]}),description:We.description,hint:Q.note&&!Q.multi?{k:"n",label:"add a note",icon:"edit",on:(Z==null?void 0:Z.note)===void 0}:void 0,checked:Ht,field:Ht&&!je&&(Z==null?void 0:Z.note)!==void 0?Fe("a note for the agent, sent with your pick"):void 0}});return Q.note&&Pe.push({label:Q.note.label,description:je?void 0:"your own answer",checked:je,field:je?Fe("your own answer"):void 0}),d.jsxs("div",{className:Ue("card-page",!te&&"card-page-off"),children:[d.jsx(of,{children:Q.text||g}),te&&Ie,d.jsx(rf,{rows:Pe,cursor:te?j:void 0,onCursor:D,onPick:We=>{var Ht;ne(We),(Ht=r.current)==null||Ht.focus()},onHint:M}),(He==null?void 0:He.preview)&&d.jsx(sf,{code:He.preview,still:!0}),ge(Q,Z)]},Q.id)};return d.jsxs(ow,{root:r,id:e.id,onKeyDown:ie,onKeyUp:E.onPasteKeyUp,onPaste:E.onPaste,children:[y.length>1&&d.jsx("div",{className:"card-tabs",children:d.jsx(Pf,{label:"questions",owner:"ask",items:[...y.map((Q,we)=>({id:String(we),label:Q.header||`question ${we+1}`,lead:d.jsx("span",{className:Ue("dot card-step",qa(T[we])&&"answered")})})),{id:String(y.length),label:"send",far:!0}],current:String(R),onPick:Q=>{var we;ue(Number(Q)),(we=r.current)==null||we.focus()}})}),d.jsxs("div",{className:"card-pages",children:[y.map(ke),fc(y)!==-1&&d.jsxs("div",{className:Ue("card-page",!O&&"card-page-off"),children:[d.jsx(of,{children:"Send these answers?"}),O&&Ie,d.jsx(rf,{hover:!0,rows:y.map((Q,we)=>{const te=qa(T[we])?UM(Q,T[we]):void 0;return{label:d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"row-dim",children:Q.header||`question ${we+1}`})," ",d.jsx("span",{className:Ue(!te&&"row-dim"),children:te?te.pick:"no answer yet"})]}),description:te==null?void 0:te.note}}),onPick:Q=>{var we;ue(Q),(we=r.current)==null||we.focus()}}),ge()]})]})]})}const b9={side:"top",align:"start",offset:6,flip:"both",margin:8},x9=5*6e4;function E9({usage:e,limits:t,auth:n,now:r,onClose:o}){const i=t?VD(t,r):[],l=i.length?BD(n):void 0,c=t&&r-t.at>x9?qg(r-t.at):null,u=(e==null?void 0:e.cost)!==void 0?` · ${Kc(e.cost)}`:"";return d.jsxs(Ns,{className:"usage-panel",anchor:"parent",placement:b9,onDismiss:o,onKey:h=>{h.key==="Escape"&&(h.stopPropagation(),o())},children:[e&&d.jsx(bx,{name:"context",used:e.used/e.size,sub:`${vb(e.used)} of ${vb(e.size)}${u}`}),l&&d.jsx("div",{className:"usage-who section-title",children:l}),i.map(h=>d.jsx(bx,{name:h.name,used:h.used,sub:h.sub},h.key)),c&&d.jsxs("div",{className:"usage-stale hint",children:["read ",c," ago"]})]})}function bx({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})]})}const xx=[],_9=[],S9=new Set(["ArrowLeft","ArrowRight","Home","End","PageUp","PageDown"]),N9=150,Ex=e=>({kind:"cmd",c:e});function T9(e,t,n,r){return e==="command"?r?n===0?"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":"listing files…"}function j9(e){return e.kind==="cmd"?`/${e.c.name} `:e.kind==="folder"?`@${e.path}/ `:e.kind==="changes"?"@changes ":`@${e.path} `}function mc({active:e,draft:t,archived:n,found:r,project:o,greenfield:i,placement:l="dock"}){var ru,ha,Ms,ou,vl,bl,xl,El,_l;const c=l==="screen",u=lt(),h=ct(),{storage:p}=so(),m=Zn(),g=!!t,y=(e==null?void 0:e.worktree.id)??null,w=e==null?void 0:e.worktree.repoId,b=o?rl:n?n.id:r?r.id:Fc(e),E=!!n||!!r,_=n?n.restorable:!!r&&!r.locked,N=It(b,"draft"),T=It(b,"attachments"),R=It(b,"notice"),O=((ru=e==null?void 0:e.worktree.owns)==null?void 0:ru.join(", "))??"",B=S.useRef({id:y,owns:O});St([y,O],()=>{const q=B.current;B.current={id:y,owns:O},!(q.id!==y||q.owns===O||!O||!b||n)&&u({a:"notice",id:b,text:`Running its own ${O} here now: this branch changed it.`})});const $=It(b,"mark"),C=($==null?void 0:$.by)==="walk"?$:void 0,j=It(y,"chat"),D=It(y,"queue"),z=S.useMemo(()=>y&&!g?mk(j):null,[y,g,j]),X=It(y,"cardParked"),ae=It(y,"sending"),A=S.useMemo(()=>y&&!g&&!ae?sE(j):null,[y,g,ae,j]),de=It(y,"askRevived"),ue=!z&&A&&de===A.id?A:null,J=z&&X!==z.id?z:ue,M=ue?Ka(ue.id):null,oe=It(M,"attachments"),ne=z?X===z.id?z:null:A&&!ue?A:null,H=S.useRef(null),se=pi(),ie=lk(),he=It(ie,"page"),ge=Uc(),{onPaste:Ie,onPasteKey:ke,onPasteKeyUp:Q}=f_(b,y),we=SP(),te=p9(),Z=S.useMemo(()=>y&&!g?u9(j,{queued:D.length,sending:!!ae,card:!!(J||ne),dismissed:te}):null,[y,g,j,D.length,ae,J,ne,te]),je=q=>b&&u({a:"set-draft",id:b,text:q}),He=P(q=>q.clientId),Fe=P(q=>q.repos),Pe=P(q=>q.repos.find(Ve=>Ve.id===(e==null?void 0:e.worktree.repoId))??null),We=P(q=>q.defaultAgent),Ht=P(q=>q.agentChosen),ut=g||!!i||!!o,vn=!ut&&!!e&&!e.worktree.agent,Jt=ut||vn,xt=(t==null?void 0:t.agent)??We,kt=P(q=>q.agents.find(Ve=>Ve.id===(Jt?xt:e==null?void 0:e.worktree.agent))),ot=!!(kt!=null&&kt.quick),dt=(kt==null?void 0:kt.models)??xx,Tt=(kt==null?void 0:kt.efforts)??xx,[Et,dn]=g8(xt),[G,ve]=h8(xt),tt=P(q=>q.agents),it=(q,Ve)=>{if(q===xt){dn(Ve);return}k8(p,q,Ve),g?u({a:"draft-agent",id:q}):h==null||h.send({t:"set-default-agent",agent:q})},ft=It(y,"model"),Gt=It(y,"effort"),Ft=It(y,"usage")??(e==null?void 0:e.usage),[An]=xN(Pe),qn=(t==null?void 0:t.profile)??An,[zt,bn]=p8(Pe),ye=(e==null?void 0:e.worktree.mode)??Rd,Me=P(q=>q.picking),Bt=P(q=>q.layout.term),jt=uE((e==null?void 0:e.procs)??[]),fn=wn("composer"),K=It(y,"files"),pe=S.useMemo(()=>fE(K??_9),[K]),_e=It(y,"git"),Xe=(_e==null?void 0:_e.files.length)??(e==null?void 0:e.dirty)??0,qe=(_e==null?void 0:_e.unpushed)??(e==null?void 0:e.unpushed)??0,_t=P(q=>{var Ve;return y?(Ve=q.shipping[y])==null?void 0:Ve.op:void 0}),Le=P(q=>{var Ve;return y?(Ve=q.shipping[y])==null?void 0:Ve.step:void 0}),$e=P(q=>ol(q,w)),Ge=P(q=>{var Ve;return $e?(Ve=q.shipping[$e.id])==null?void 0:Ve.op:void 0}),Wt=$e&&Pe&&ut?A_(Pe.defaultBranch,$e):null,Mt=P(q=>g?rL(q.rows,w,xt,We):y),Tn=It(Mt,"commands"),In=Tn.some(q=>q.name==="compact"),yn=(e==null?void 0:e.agent)==="working"||(e==null?void 0:e.agent)==="waiting",wr=yn&&!!y&&!g,gn=e==null?void 0:e.worktree.lastTurn,Nn=!N.trim()&&T.length===0,ur=!g&&!i&&Nn&&!yn?gn:void 0,nn=!g&&!i&&e&&Di(e.worktree)?e.worktree.landing:void 0,en=!!(nn!=null&&nn.ready)&&!nn.stale&&!ad(nn,Xe,ot,kt==null?void 0:kt.name),Kt=Nn&&(!yn||en)?nn:void 0,V=Xe>0&&!!(Kt!=null&&Kt.subject),Ee=Xe||(((ha=_e==null?void 0:_e.committed)==null?void 0:ha.length)??0),Ze=!g&&!i&&Nn&&!yn&&!!e,yt=!!(e!=null&&e.worktree.landed)&&Xe===0,sn=Ze&&yt,ln=Ze&&!sn?e.worktree.pr:void 0,Vt=!yt&&((Ms=e==null?void 0:e.worktree.pr)==null?void 0:Ms.state)==="open"?e.worktree.pr:void 0,dr=!!Vt&&(Xe>0||qe>0),Mr=((ou=e==null?void 0:e.worktree.pr)==null?void 0:ou.state)==="closed",Mn=Fi((Pe==null?void 0:Pe.config)??{}),Ot=S.useMemo(()=>g9($d(Fi((Pe==null?void 0:Pe.config)??{}),Pe==null?void 0:Pe.defaultBranch)),[Pe]),Ce=()=>y&&(h==null?void 0:h.send({t:"chat",worktreeId:y,text:"/compact"})),Te=ut?"nothing to compact until the first reply":In?yn?"wait for the turn to end":void 0:"this agent offers no compact command",ht=In&&Ft?HD(Ft.used/Ft.size):void 0,pt=kt==null?void 0:kt.limits,Zt=ut?void 0:Ft,tn=(!!y||ut)&&!!(Zt||pt),W=Date.now(),[me,Be]=S.useState(!1),mt=S.useRef(0),Ct=()=>{window.clearTimeout(mt.current),Be(!1)};St([y],Ct);const Yt=ck(),Ln=(Yt==null?void 0:Yt.owner)==="composer"&&Yt.key==="usage",tr=()=>[{id:"compact",label:"compact the context",detail:Te||!Ft?void 0:UD(Ft.used/Ft.size),disabled:Te,onClick:Ce}],[jo,Sr]=S.useState(0),[Cs,Lr]=S.useState(null),[Pr,yr]=S.useState(null),Co=S.useRef(null),Je=b&&!E&&!o?ix(N,jo):null,gt=Je!==null&&Je.from!==Cs&&!C,Ao=Je==null?void 0:Je.kind,hn=Je==null?void 0:Je.query,rn=S.useMemo(()=>{if(hn===void 0)return[];if(Ao==="command")return hn.trim()?vF(k9(Ot,Tn),hn).slice(0,8).map(Ex):vx(Ot,Tn).rows.map(Ex);const q=[],Ve=(_e==null?void 0:_e.files.length)??0;return Ve>0&&"changes".startsWith(hn.toLowerCase())&&q.push({kind:"changes",n:Ve}),q.push(...K8(K??[],pe,(_e==null?void 0:_e.files)??[],hn,8)),q},[Ao,hn,K,pe,_e,Tn,Ot]),Dr=Ao==="command"&&hn!==void 0&&!hn.trim()?vx(Ot,Tn).more:0,Yn=S.useRef(null),Se=S.useRef(null),L=()=>{var q;return(q=H.current??Yn.current)==null?void 0:q.focus()},F=L;St([i?e==null?void 0:e.worktree.id:null],()=>{if(!i)return;const q=requestAnimationFrame(()=>{var Rt;const Ve=document.activeElement;(!Ve||Ve===document.body)&&((Rt=Yn.current)==null||Rt.focus())});return()=>cancelAnimationFrame(q)});const re=P(q=>q.focusChat),be=S.useRef(re),Re=!!UE();St([re],()=>{if(re===be.current||(be.current=re,Re!==!!i))return;const q=requestAnimationFrame(L);return()=>cancelAnimationFrame(q)});const Ke=J==null?void 0:J.id,At=S.useRef({id:y,cardUpId:Ke});St([y,Ke],()=>{const q=At.current;if(At.current={id:y,cardUpId:Ke},Ke||!q.cardUpId||q.id!==y||Re!==!!i||se&&!ne)return;const Ve=requestAnimationFrame(()=>{var Xt;const Rt=document.activeElement;(!Rt||Rt===document.body)&&((Xt=Yn.current)==null||Xt.focus())});return()=>cancelAnimationFrame(Ve)});const pn=P(q=>q.walked),Gn=S.useRef(pn);St([pn],()=>{if(pn===Gn.current||(Gn.current=pn,Re!==!!i))return;const q=requestAnimationFrame(()=>{const Ve=document.activeElement;(!Ve||Ve===document.body||Ve.closest(".rail"))&&L()});return()=>cancelAnimationFrame(q)});const Pn=w_({results:rn,keyOf:q=>q.kind==="cmd"?`c:${q.c.name}`:q.kind==="changes"?"changes":`f:${q.path}`,q:(Je==null?void 0:Je.query)??"",listRef:Co,tabPicks:!0,onPick:q=>{if(!Je)return;const{text:Ve,caret:Rt}=yF(N,Je,j9(q));je(Ve),Lr(Je.from),yr(q.kind==="cmd"&&q.c.hint?{name:q.c.name,hint:q.c.hint}:null),requestAnimationFrame(()=>{const Xt=Yn.current;Xt&&(Xt.focus(),Xt.setSelectionRange(Rt,Rt),Sr(Rt))})}}),vr=y||E?OF(N):null,nr=Pr&&N===`/${Pr.name} `?Pr.hint:null,Ji=vr===""&&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,ea=nr??Ji,ml=(e==null?void 0:e.worktree.title)??"untitled",Io=(vl=gn==null?void 0:gn.recap)==null?void 0:vl.text,ls=()=>{y&&oi(h,u,{t:"land",worktreeId:y})},cs=q=>{y&&(h==null||h.send({t:"judge",worktreeId:y,...q?{note:q}:{}}))},ta=!!((bl=Pe==null?void 0:Pe.config.check)!=null&&bl.trim()),gl=_k(nn,Xe,ot),Gf=Ze&&!_t&&!ut&&Di(e.worktree)&&!yt&&!Mr&&Ee>0&&(!nn||!!nn.stale||gl==="unanswered"),na="Archive this worktree when you are done here; the rail's archived section brings it back with its chat.",ra=dr?"update":"land",oa=Pe?ff(Pe):"main",Gc=dr&&Vt?`Commit, take ${oa} in and push the branch; PR #${Vt.number} takes the new commits.`:`${$d(Mn,Pe==null?void 0:Pe.defaultBranch)}.`,jn=y?sn?{word:"archive",line:((xl=e==null?void 0:e.worktree.pr)==null?void 0:xl.state)==="merged"?vs(e.worktree.pr):`landed on ${(Pe==null?void 0:Pe.defaultBranch)??"main"}.`,tip:na,run:()=>Hi(h,u,[y])}:(ln==null?void 0:ln.state)==="open"&&!dr?R_(ln)?{word:"merge",line:ld(Io??vs(ln)),tip:`${vs(ln)} Merge the PR now, by the method the repo allows.`,run:ls,ships:!0}:{word:"view",line:ld(Io??vs(ln)),tip:`${vs(ln)} Open the PR on GitHub.`,run:()=>window.open(ln.url,"_blank")}:(ln==null?void 0:ln.state)==="closed"?{word:"archive",line:vs(ln),tip:`${vs(ln)} ${na}`,run:()=>Hi(h,u,[y])}:Gf?{word:"check",line:(nn==null?void 0:nn.subject)??ld(Io??kD(Ee)),tip:$_(nn,ta,gl),run:cs}:Kt!=null&&Kt.ready&&!ad(Kt,Xe,ot,kt==null?void 0:kt.name)?{word:ra,line:Kt.subject??ld(Io??(ub(Kt,Ee)||"ready")),tip:[ub(Kt,Ee),gD(oa,e==null?void 0:e.behind),Gc,Kt.subject&&Xe>0?"Tab from the word edits the message first.":""].filter(Boolean).join(" "),run:ls,ships:!0}:null:null,sa=(El=e==null?void 0:e.worktree.lands)==null?void 0:El.at(-1),mi=sa&&I_(sa),ia=((jn==null?void 0:jn.word)==="land"||(jn==null?void 0:jn.word)==="update"||(jn==null?void 0:jn.word)==="check")&&Kt?wD(Kt,gl):(jn==null?void 0:jn.word)==="archive"&&mi?Hr(mi):null,As=S.useRef(null);_t!=="land"&&(As.current=y&&(jn!=null&&jn.ships)?{id:y,verb:jn,under:ia}:null);const us=_t==="land"&&Nn&&((_l=As.current)==null?void 0:_l.id)===y?As.current:null,Xn=us?us.verb:jn,fr=!!(Xn!=null&&Xn.ships)&&_t==="land",Vo=rk(Le,ok),Is=jc(e,"commit"),Yo=jc(e,"check"),Rs=M_(fr?Is:Yo),aa=il(Nk(Rs)?Rs==null?void 0:Rs.since:void 0),gi=Kt?Kt.check==="pending"&&Yo&&Rs===Yo?Dm("Checking the work",Yo,aa):ad(Kt,Xe,ot,kt==null?void 0:kt.name):null,ds=Xn&&fr?Vo?`${Xn.word}: ${Vo}`:`${Xn.word} ${Xn.line}`:null,ki=ds&&Is&&Rs===Is?Dm(ds,Is,aa):ds,Vc=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?Xn?"":gi||(ln?vs(ln):ur?Sk(ur):i?`describe ${ml}…`:ut?"describe a change":c?`message agent on ${ml}`:`message agent on ${ml}; / for a command, ! for a shell command`):"no worktree selected",la=N!==""||ea||!e?null:fr?Vo?null:us?us.under:ia:Xn?ia:ln||gi?Io??(Kt==null?void 0:Kt.subject)??null:null,Yc=S.useRef(!1);S.useEffect(()=>{const q=gt&&!Yc.current;Yc.current=gt,q&&((Je==null?void 0:Je.kind)==="file"&&y?$f(y,m.getState(),{sock:h,dispatch:u}):(Je==null?void 0:Je.kind)==="command"&&Mt&&Tn.length===0&&(h==null||h.send({t:"list-commands",worktreeId:Mt})))},[gt,Je==null?void 0:Je.kind,Tn.length,y,Mt,h,m,u]);const ca=()=>{if(!e)return;const q=[],Ve=he;if(Ve.url)try{const zr=new URL(Ve.url);q.push(`current route: ${zr.pathname}${zr.search}`)}catch{}Ve.title&&q.push(`page title: ${Ve.title}`);const Rt=[];i&&Rt.push(o8(e.worktree.title,Pe==null?void 0:Pe.configFile)),q.length>0&&Rt.push(`What the user is looking at right now:
235
+ ${q.join(`
236
+ `)}`);const Xt=LF(j);return Xt&&Rt.push(Xt),Rt.length>0?Rt:void 0},Xc=q=>{ut?bn(q):y&&q!==ye&&(h==null||h.send({t:"set-worktree-mode",worktreeId:y,mode:q}))},br=q=>b&&u({a:"notice",id:b,text:q}),Yf=(q,Ve="")=>{if(!e||!y)return;if(q==="handoff"){if(ut)return br("a new worktree has nothing to continue yet");const Xt=r4(Ve,Fe,e.worktree.repoId);"pick"in Xt?u({a:"open",overlay:{kind:"handoff",worktreeId:y}}):"error"in Xt?br(Xt.error):h==null||h.send({t:"handoff-ask",worktreeId:y,repoId:Xt.repo.id,...Xt.text?{text:Xt.text}:{}});return}if(q==="archive"){yt||Mr?Hi(h,u,[y]):br("archive is for a landed worktree; this one has not landed");return}if(q==="check"){ut||!Di(e.worktree)?br("nothing to check from here"):yn?br("wait for the turn to end"):Ee===0?br("nothing to check: no changes here"):cs(Ve||void 0);return}const Rt=nn?ad(nn,Xe,ot,kt==null?void 0:kt.name):null;ut||!Di(e.worktree)?br("nothing to land from here"):yt?br(`already landed on ${(Pe==null?void 0:Pe.defaultBranch)??"main"}`):Rt?br(Rt):yn&&(!nn||nn.stale)?br("wait for the turn to end"):nn!=null&&nn.stale?br("the work changed since this was checked; check again first"):ls()},ua=T.some(li),$s=()=>{b&&(h==null||h.send({t:"set-draft",boxId:b,text:N,clientId:He}))},Os=(q,Ve,Rt,Xt)=>u({a:"hold-send",id:q,log:Ve,text:Rt,frame:Xt}),kl=()=>{if(!b)return;if(o){if(o.busy)return;if(o.why)return br(o.why);(xt!==We||!Ht)&&(h==null||h.send({t:"set-default-agent",agent:xt})),$s(),o.create();return}if(Nn)return;if(n){if(!n.restorable)return;if(vr!==null){br("nothing runs here until it is restored");return}const Qn={t:"restore-worktree",archiveId:n.id,clientId:He};if(ua)return Os(b,b,N.trim(),Qn);$s(),h==null||h.send(tc(Qn,b,N.trim(),T)),u({a:"restoring",id:b,text:N.trim()}),u({a:"sent-box",id:b});return}if(r){if(r.locked)return;if(vr!==null){br("nothing runs here until Toyon takes it over; its menu on the rail opens a shell");return}const Qn={t:"adopt-worktree",worktreeId:r.id,clientId:He};if(ua)return Os(b,b,N.trim(),Qn);$s(),h==null||h.send(tc(Qn,b,N.trim(),T)),u({a:"restoring",id:b,text:N.trim()}),u({a:"sent-box",id:b});return}if(!e||!y)return;if(vr!==null){vr&&g?u({a:"term-run",id:y,command:vr}):vr&&(h==null||h.send({t:"exec",worktreeId:y,command:vr})),je("");return}const q=w9(N,Ot),Ve=q&&m9(q.name)?q.name:void 0;if(q&&!Ve){Yf(q.name,q.args),je("");return}if(Ve&&!(q!=null&&q.args)){Xc(Ve),je("");return}if(t!=null&&t.batch&&T.length){br("a batch takes no attachments; remove them or turn batch off");return}const Rt=q?q.args:N.trim(),Xt=ca(),zr=T.length?T.map(Ec):void 0;if(Ve&&Xc(Ve),ut){const Qn=Lc(e.worktree)?{worktreeId:y}:{},yi={clientId:He,repoId:e.worktree.repoId,context:Xt,agent:xt,profile:qn,mode:Ve??zt,...Et?{model:Et}:{},...G?{effort:G}:{},...mE(t)?{carry:!0}:{}};if((xt!==We||!Ht)&&(h==null||h.send({t:"set-default-agent",agent:xt})),t!=null&&t.batch)$s(),h==null||h.send({t:"batch-worktrees",repoId:e.worktree.repoId,prompt:Rt,agent:xt,...Et?{model:Et}:{},...G?{effort:G}:{},boxId:b}),u({a:"sent-box",id:b});else{const vi=t&&t.variants>1?{variants:t.variants}:{},su={t:"create-worktree",...yi,...Qn,...vi};ua?Os(b,b,Rt,su):($s(),h==null||h.send(tc(su,b,Rt,T)),u({a:"sending",id:b,message:{text:Rt,attachments:zr}}),u({a:"sent-box",id:b}))}}else{vn&&(h==null||h.send({t:"set-worktree-model",worktreeId:y,model:Et}),h==null||h.send({t:"set-worktree-effort",worktreeId:y,effort:G}));const Qn={t:"chat",worktreeId:y,clientId:He,context:Xt};ua?Os(b,y,Rt,Qn):($s(),h==null||h.send(tc(Qn,b,Rt,T)),yn||u({a:"sending",id:y,message:{text:Rt,attachments:zr}}),u({a:"sent-box",id:b}))}i&&u({a:"show-chat"})},Xf=q=>{if(!y||(ue==null?void 0:ue.ask.kind)!=="question")return;if(!q.some(qa))return u({a:"ask-revive",id:y});const Ve=Fg(ue.ask.questions,q).join(`
237
+ `),Rt={t:"chat",worktreeId:y,clientId:He,context:ca()};if(M&&oe.some(li))Os(M,y,Ve,Rt);else{const Xt=oe.length?oe.map(Ec):void 0,zr=Xt&&M?{attachments:Xt,boxId:M}:{};h==null||h.send({...Rt,text:Ve,...zr}),Xt&&M&&u({a:"clear-attachments",id:M}),u({a:"sending",id:y,message:{text:Ve,attachments:Xt}})}u({a:"answered",id:y}),u({a:"ask-revive",id:y})},wl=P(q=>q.autoSend);St([wl,y],()=>{!wl||wl!==y||Nn||Re!==!!i||(u({a:"auto-sent"}),kl())});const Qf=()=>{const q=T[T.length-1];return!b||!q?!1:(u({a:"detach",id:b,key:q.key}),!0)},da=q=>{b&&(u({a:"walk",id:b,walk:q.walk,text:q.text}),requestAnimationFrame(()=>{var Ve;(Ve=Yn.current)==null||Ve.setSelectionRange(q.text.length,q.text.length),Sr(q.text.length)}))},Qc=()=>{b&&C&&u({a:"walk",id:b,walk:null,text:N})},Jc=ut?[]:j.map(q=>q.kind==="user"?q.attachments:void 0),eu=ut?[]:D.flatMap(q=>q.attachments??[]),yl=e?e.worktree.path:null,wi=e==null?void 0:e.worktree.plan,tu=wr&&!J,Jf=P(q=>q.reading),[eh,nu]=S.useState(!1),fa=c&&Jf&&!ne&&(J?!eh:Nn&&!we);return St([fa],()=>{if(fa||!J)return;const q=requestAnimationFrame(()=>{var Ve;document.activeElement===document.body&&((Ve=H.current)==null||Ve.focus())});return()=>cancelAnimationFrame(q)}),d.jsxs("div",{className:Ue("composer chat-input",tu&&"stopping",fa&&"lean"),onFocus:q=>nu(q.target instanceof HTMLTextAreaElement),onBlur:()=>nu(!1),children:[wi&&e&&d.jsxs("div",{className:"composer-plan",...fn.contextMenu(()=>nS(wi,yl,()=>h==null?void 0:h.send({t:"reveal",worktreeId:e.worktree.id,path:wi}),as(h))),children:[d.jsx(Nt,{name:"text",className:"icon-inline"}),d.jsx(ze,{variant:"inline",className:"composer-plan-path","data-tip":"Read the plan in the editor pane",onClick:()=>er({dispatch:u},{worktreeId:e.worktree.id,path:wi,view:"preview"}),children:wi})]}),ne&&y&&d.jsx(Ma,{icon:"chat",verb:"answer",tip:"Bring the question back into the box",onPress:()=>{u(ne.kind==="ask"&&ne.outcome?{a:"ask-revive",id:y,askId:ne.id}:{a:"card-unpark",id:y}),u({a:"focus-chat"})},children:V0(ne)}),(Z==null?void 0:Z.verb)==="fix"&&"toolId"in Z&&y&&d.jsxs(Ma,{icon:"run",verb:Z.verb,tip:"Send the agent what it printed and ask for a fix",onPress:()=>h==null?void 0:h.send({t:"fix",worktreeId:y,toolId:Z.toolId}),onDismiss:()=>tm(Z.key),children:["what failed in ",d.jsx("code",{children:Z.command})]}),(Z==null?void 0:Z.verb)==="fix"&&"page"in Z&&y&&d.jsx(Ma,{icon:"run",verb:Z.verb,tip:"Send the agent what the preview threw and ask for a fix",onPress:()=>h==null?void 0:h.send({t:"fix-page",worktreeId:y}),onDismiss:()=>tm(Z.key),children:"what the preview threw"}),(Z==null?void 0:Z.verb)==="continue"&&y&&d.jsx(Ma,{icon:"send",verb:Z.verb,tip:Z.after==="stop"?"Send the agent on from where its turn stopped":Z.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:y}),onDismiss:()=>tm(Z.key),children:Z.after==="stop"?"where it stopped":Z.again?"after the same error again":"after the error"}),we&&b&&!J&&(e||_||o)&&d.jsx(Ma,{icon:"copy",verb:"attach",tip:"Attach it, as a paste would",onPress:()=>{v4(m,b,we),L()},onDismiss:HE,children:we.kind==="image"?"the image you copied":`the text you copied, ${we.text.split(`
238
+ `).length} lines`}),b&&!J&&vg(T,lc(dm(Jc),eu)).map(([q,Ve])=>{const Rt=()=>u({a:"detach",id:b,key:q.key});return q.kind!=="pick"?d.jsx(BN,{item:q,n:Ve,onRemove:Rt},q.key):d.jsx(Qk,{pick:q,dir:yl,tipText:q.html,onHover:Xt=>ie&&an.post(ie,Xt?{type:"highlight-selector",selector:q.selector,label:Zg(q)}:{type:"highlight-clear"}),worktreeId:y,onOpen:(Xt,zr)=>y&&Wi(m,h,y,Xt,zr),onRemove:Rt},q.key)}),gt&&Je&&d.jsx(n8,{results:rn,keyOf:q=>q.kind==="cmd"?`c:${q.c.name}`:q.kind==="changes"?"changes":q.kind==="folder"?`d:${q.path}`:`f:${q.path}`,rowClass:q=>q.kind==="file"||q.kind==="folder"?"qo-file":q.kind==="changes"?"picker-row":"picker-row picker-cmd",nav:Pn,listRef:Co,empty:T9(Je.kind,K,Tn.length,Mt!==null),note:Dr>0?`type to find ${Dr} more`:void 0,row:q=>{const Ve=((_e==null?void 0:_e.files.length)??0)>0;return q.kind==="file"?rg(q.path,q.status,Je.query,{gutter:Ve}):q.kind==="folder"?rg(q.path,void 0,Je.query,{folder:!0,gutter:Ve}):q.kind==="changes"?d.jsx(On,{label:"@changes",hint:`${q.n} uncommitted ${q.n===1?"file":"files"}`}):d.jsx(v8,{c:q.c,query:Je.query})}}),J&&fa&&y&&d.jsx(Ma,{icon:"chat",verb:"answer",tip:"Back to the question",onPress:()=>u({a:"answered",id:y}),children:V0(J)}),J&&y?J.kind==="handoff"?d.jsx(c9,{item:J,worktreeId:y,rootRef:H},J.id):J.ask.kind==="question"?d.jsx(v9,{item:J,ask:J.ask,worktreeId:y,rootRef:H,numbers:lc(dm(Jc),eu),onScreen:c,onAnswer:ue?Xf:void 0},J.id):d.jsx(y9,{item:J,ask:J.ask,worktreeId:y,rootRef:H},J.id):d.jsxs("div",{className:Ue("composer-field",vr!==null&&"shell",C&&"recalled"),children:[d.jsx(Tc,{size:"lg",bare:!0,font:vr!==null?"mono":"ui",ref:Yn,value:N,onChange:q=>{var Qn;const Ve=q.target.value,Rt=q.target.selectionStart??Ve.length;je(Ve),Sr(Rt),Pn.setIndex(0);const{inputType:Xt}=q.nativeEvent;Lr(Xt==="insertFromPaste"||Xt==="insertFromDrop"?((Qn=ix(Ve,Rt))==null?void 0:Qn.from)??null:null)},onKeyUp:q=>{Q(),Sr(q.currentTarget.selectionStart??0)},onClick:q=>{Sr(q.currentTarget.selectionStart??0),Qc()},onPaste:Ie,onScroll:q=>{Se.current&&(Se.current.scrollTop=q.currentTarget.scrollTop)},onKeyDown:q=>{var Ve;if(ke(q),!q.nativeEvent.isComposing){if(gt){if(q.key==="Escape"){q.preventDefault(),q.stopPropagation(),Lr((Je==null?void 0:Je.from)??null);return}if(Pn.onKeyDown(q))return}if((q.key==="ArrowUp"||q.key==="ArrowDown")&&!q.altKey&&!q.ctrlKey){const Rt=q.key==="ArrowUp",Xt=D.at(-1);if(Rt&&!q.metaKey&&!C&&N===""&&y&&!g&&Xt!==void 0){q.preventDefault(),t_(m,h,y,D.length-1);return}const zr=q.metaKey?Rt?"first":"box":Rt?"up":"down",Qn=y?VF(j,C??null,N,zr):null;if(Qn){q.preventDefault(),(Qn.walk!==C||Qn.text!==N)&&da(Qn);return}}if(C&&q.key==="Escape"){q.preventDefault(),q.stopPropagation(),da({walk:null,text:C.from});return}if(q.key==="Escape"&&yn&&y&&!g){q.preventDefault(),q.stopPropagation(),h==null||h.send({t:"stop-agent",worktreeId:y});return}if(C&&S9.has(q.key)&&Qc(),q.key==="Tab"&&!q.shiftKey&&N===""){const Rt=(Ve=q.currentTarget.closest(".composer"))==null?void 0:Ve.querySelector(".composer-verb");if(Rt&&!Rt.disabled){q.preventDefault(),Rt.focus();return}if(V){q.preventDefault(),u({a:"edit-commit"});return}}q.key==="Enter"&&(se?q.metaKey||q.ctrlKey:!q.shiftKey)?(q.preventDefault(),kl()):q.key==="Backspace"&&N===""&&Qf()&&q.preventDefault()}},placeholder:la||Xn?"":Vc,disabled:o?o.busy:!e&&!_}),ea&&d.jsxs("div",{className:"composer-ghost","aria-hidden":"true",children:[d.jsx("span",{className:"picker-typed",children:N}),ea]}),y&&vr===null&&N.includes("@")&&d.jsx("div",{ref:Se,className:"composer-ghost composer-marks","aria-hidden":"true",onClick:q=>dN(q,e==null?void 0:e.worktree.path,y,{sock:h,dispatch:u}),children:d.jsx(uN,{text:N,worktreeId:y,root:e==null?void 0:e.worktree.path,inField:!0})}),(la||Xn)&&d.jsxs("div",{className:"composer-ghost","aria-hidden":Xn?void 0:"true",children:[d.jsx("span",{className:Ue("composer-placeholder",fr&&"live-text"),children:ki||(Xn?d.jsxs(d.Fragment,{children:[d.jsx(ze,{variant:"inline",tone:"strong",className:"composer-verb",disabled:!!Xn.ships&&!!_t,...Ut(Xn.tip,void 0,{placement:"top"}),onClick:Xn.run,onKeyDown:q=>{q.key==="Tab"&&!q.shiftKey&&V&&(q.preventDefault(),u({a:"edit-commit"}))},children:Xn.word})," ",d.jsx("span",{className:"composer-verb-line",children:Xn.line})]}):Vc)}),la&&d.jsxs(d.Fragment,{children:[`
239
+ `,d.jsx("span",{className:"composer-subline",children:la})]})]}),tu&&d.jsx(Pt,{icon:"stop",tone:"danger",className:"composer-stop",label:`Stop the agent (context up to here is kept${D.length?"; queued messages go next":""})`,hint:"esc",onClick:()=>y&&(h==null?void 0:h.send({t:"stop-agent",worktreeId:y}))})]}),R&&d.jsx("div",{className:"hint composer-notice",role:"status",children:R}),!J&&d.jsxs("div",{className:"hint composer-knobs",children:[d.jsxs("span",{className:"spawn-left",children:[Jt?tt.length>1?d.jsx(w8,{agents:tt,agent:xt,model:Et,onChange:it,onClose:F}):d.jsx(mx,{models:dt,value:Et,onChange:dn,onClose:F}):e&&d.jsx(mx,{models:dt,value:e.worktree.model??"",current:ft,onChange:q=>h==null?void 0:h.send({t:"set-worktree-model",worktreeId:e.worktree.id,model:q}),onClose:F}),Jt?d.jsx(hx,{efforts:Tt,value:G,onChange:ve,onClose:F}):e&&d.jsx(hx,{efforts:Tt,value:e.worktree.effort??"",current:Gt,onChange:q=>h==null?void 0:h.send({t:"set-worktree-effort",worktreeId:e.worktree.id,effort:q}),onClose:F}),ut?!o&&d.jsx(px,{value:zt,onChange:bn,onClose:F}):e&&d.jsx(px,{value:ye,onChange:q=>h==null?void 0:h.send({t:"set-worktree-mode",worktreeId:e.worktree.id,mode:q}),onClose:F}),tn&&d.jsxs("span",{className:"usage-knob",onMouseEnter:()=>{Ln||(window.clearTimeout(mt.current),mt.current=window.setTimeout(()=>Be(!0),N9))},onMouseLeave:()=>{window.clearTimeout(mt.current),Be(!1)},children:[d.jsx(Pt,{icon:d.jsx(r8,{fraction:Zt?Zt.used/Zt.size:0,level:pt?ZD(pt,W):void 0}),tone:"chrome",on:Ln,silent:!0,label:Zt?`${Math.round(100*Zt.used/Zt.size)}% of context`:pt?bb(pt,W):"",detail:[...Zt&&pt?[bb(pt,W)]:[],...ht?[ht]:[]],...fn.dropdown(tr,"left","usage"),...fn.contextMenu(tr,"usage")}),me&&d.jsx(E9,{usage:Zt,limits:pt,auth:kt==null?void 0:kt.auth,now:W,onClose:Ct})]})]}),d.jsxs("span",{className:"spawn-tools",children:[b&&(e||_||o)&&d.jsx(Pt,{icon:"attach",tone:"chrome",label:c?"Attach a picture":"Attach a picture or a file, or drop one here",onClick:()=>c_(m,b,{images:c})}),!i&&!E&&!c&&!o&&d.jsx(Pt,{icon:"terminal",tone:"chrome",on:Bt,className:"composer-term",disabled:!e,label:jt?jt.tip:"Terminal",hint:Lt("terminal"),badge:jt&&d.jsx("span",{className:"composer-term-dot"}),onClick:()=>{u(jt&&!Bt&&y?{a:"term-stream",id:y,stream:jt.stream}:{a:"toggle-terminal"})},...fn.contextMenu(()=>e&&y?iF(e.procs,y,Bt,{sock:h,dispatch:m.dispatch}):[])}),!i&&!ge&&!E&&!c&&!o&&d.jsx(Pt,{icon:"pick",label:"Pick an element on the page to attach",hint:Lt("pick"),on:Me==="chat",disabled:!ie,onClick:()=>ie&&Nc(ie,Me,u,"chat")}),se&&b&&(e||_||o)&&d.jsx(Pt,{icon:"send",tone:"primary",label:o?"Create the project":"Send",disabled:o?o.busy:Nn,onMouseDown:q=>q.preventDefault(),onClick:kl})]})]}),Wt&&$e&&d.jsx("div",{className:"composer-notes",children:d.jsxs("div",{className:"hint composer-note",children:[d.jsx("span",{children:Wt}),hD($e)&&d.jsx(ze,{variant:"outline",busy:Ge==="pull-main",disabled:!!Ge,"data-tip":"Fast-forward main to origin",onClick:()=>oi(h,u,{t:"pull-main",worktreeId:$e.id}),children:"pull"})]})})]})}function KN({children:e,className:t,tip:n,...r}){return d.jsxs("label",{className:Ue("check",t),"data-tip":n,children:[d.jsx("input",{type:"checkbox",className:"check-box",...r}),d.jsx("span",{children:e})]})}const C9=[1,2,3];function A9({draft:e,lead:t}){const n=lt(),r=P(c=>hi(c,t==null?void 0:t.repoId)),[o]=xN(r),i=P(c=>{var u;return((u=ol(c,t==null?void 0:t.repoId))==null?void 0:u.dirty)??0}),l=!e.batch&&e.variants===1;return d.jsxs("div",{className:"draft-intro",children:[d.jsxs("div",{className:"draft-row hint",children:[d.jsx(ze,{variant:"ghost",tone:"chrome",on:e.batch,"data-tip":"An agent splits the prompt into a worktree per task",onClick:()=>n({a:"draft-batch",v:!e.batch}),children:"batch"}),d.jsxs("span",{className:"draft-variants",children:[C9.map(c=>d.jsx(ze,{variant:"ghost",on:e.variants===c,disabled:e.batch,onClick:()=>n({a:"draft-variants",n:c}),children:c},c)),d.jsx("span",{"data-tip":"Run the same prompt in N parallel worktrees, keep the best",children:"variants"})]}),d.jsx("span",{className:"draft-runs",children:d.jsx(y8,{repo:r,value:e.profile??o,onChange:c=>n({a:"draft-profile",profile:c})})})]}),t&&r&&i>0&&d.jsx("div",{className:"draft-notes",children:d.jsxs(KN,{className:"hint draft-note",checked:mE(e),disabled:!l,tip:l?`Move the ${i} uncommitted ${i===1?"file":"files"} into the new worktree, leaving ${r.defaultBranch} clean`:"One set of changes can only go into one worktree",onChange:c=>n({a:"draft-carry",v:c.currentTarget.checked}),children:[d.jsxs("span",{className:"badge-dirty",children:["~",i]})," on ",r.defaultBranch," come along"]})})]})}function I9({row:e}){const t=ct(),n=P(l=>l.clientId),r=P(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(eo,{icon:e.locked?"lock":"branch",word:e.locked?"held":"discovered",tone:"quiet",below:d.jsx("div",{className:"daemon-below row-dim",children: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(ze,{variant:"inline",tone:"strong",onClick:()=>t==null?void 0:t.send({t:"adopt-worktree",worktreeId:e.id,clientId:n}),children:"take over"})]})}function gc({placement:e,className:t,width:n,archived:r,found:o}){const i=lt(),l=Ss(),c=pP(),u=It(l==null?void 0:l.worktree.id,"sending"),h=fl(),p=e==="centre"&&!r&&(h!=null&&h.assumed)?h:null,m=P(w=>{var b;return((b=w.dragFiles)==null?void 0:b.at)==="chat"}),g=Zn(),y=S.useMemo(()=>k4(g),[g]);return d.jsxs("div",{className:Ue(e==="dock"?"chat-dock":e==="centre"?"chat-centre":"chat-screen",t,m&&"drop-over"),style:n===void 0?void 0:{width:n},...y,ref:w=>{var b;w?hc.el=w:(b=hc.el)!=null&&b.isConnected||(hc.el=null)},children:[r?d.jsx(Qp,{active:null,archived:r,tail:d.jsx(QD,{item:r})}):o?d.jsx(Qp,{active:null,found:o,tail:d.jsx(I9,{row:o})}):d.jsx(Qp,{active:l,lead:p&&d.jsxs("p",{className:"hint chat-centre-note",children:[p.name," has ",d.jsx("code",{children:p.assumed})," and no dev server, so it is chat only for now."," ",d.jsx(ze,{variant:"inline",onClick:()=>i({a:"open",overlay:{kind:"setup",repoId:p.id}}),children:"add a dev server"})]})}),!r&&!o&&c&&!u&&d.jsx(A9,{draft:c,lead:l}),r?d.jsx(mc,{active:null,archived:r,placement:e}):o?d.jsx(mc,{active:null,found:o,placement:e}):d.jsx(mc,{active:l,draft:c,placement:e})]})}const R9="modulepreload",$9=function(e){return"/"+e},_x={},ig=function(t,n,r){let o=Promise.resolve();if(n&&n.length>0){let l=function(h){return Promise.all(h.map(p=>Promise.resolve(p).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=$9(h),h in _x)return;_x[h]=!0;const p=h.endsWith(".css"),m=p?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${h}"]${m}`))return;const g=document.createElement("link");if(g.rel=p?"stylesheet":R9,p||(g.as="script"),g.crossOrigin="",g.href=h,u&&g.setAttribute("nonce",u),document.head.appendChild(g),p)return new Promise((y,w)=>{g.addEventListener("load",y),g.addEventListener("error",()=>w(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)})},sw=800;function O9(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 Do=e=>`${e.worktreeId}
240
+ ${e.ref??""}
241
+ ${e.since??""}
242
+ ${e.path}`;class M9{constructor(t){Dt(this,"files",new Map);Dt(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(Do(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(Do(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=Ko();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=Do(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(Do(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(Do(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;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||Do(o)!==Do(r))&&this.closed(Do(o)),r&&(!o||o.seq!==r.seq)&&this.opened(r),!t.connected&&n.connected)for(const c of this.files.values())c.reread=!0,this.next(c);else r&&o&&o.seq===r.seq&&_o(t,r.worktreeId).git!==_o(n,r.worktreeId).git&&this.refresh(Do(r))}opened(t){const n=Do(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=Ko();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=Ko();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(Do(t.file))}read(t,n){var g,y;const{file:r}=t;if(n.error){t.open&&this.d.store.dispatch({a:"editor-read",file:r,disk:null,error:n.error});return}const{before:o,after: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 p={after:t.buffer?t.buffer.normalize(i):i,version:l};if(!t.base){t.base={text:p.after,version:l};return}const m=((g=t.buffer)==null?void 0:g.text())??t.pending??t.base.text;switch(O9(t.base,m,t.pending,p)){case"same":break;case"adopt":t.base={text:p.after,version:l};break;case"apply":(y=t.buffer)==null||y.replace(p.after),t.base={text:p.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,p);return}this.setConflict(t,null)}askBlame(t,n){const r=Ko();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)},sw))}saveNow(t){const n=this.files.get(t);if(!(n!=null&&n.buffer))return;this.cancelTimer(n);const r=n.buffer.text();r.length>zd||(n.pending=r,this.next(n))}cancelTimer(t){t.timer!==void 0&&(this.d.timers.clear(t.timer),t.timer=void 0)}}const ZN={attach:()=>{},edited:()=>{},saveNow:()=>{}},L9=e=>({timers:{set:(t,n)=>setTimeout(t,n),clear:t=>clearTimeout(t)},win:typeof window>"u"?null:window,send:e}),ag=new Map;function P9(e){const t=ag.get(e.seq);return t?(ag.delete(e.seq),t(e),!0):!1}function D9(e,t,n,r){if(e.kind==="bytes")return ZN;if(e.kind==="grant")return z9(e,t,n,r);const o=e.handle;let i=null,l,c=null,u=Promise.resolve(),h=!1;const p=()=>(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}`))},y=async E=>{if(!await p())return g();const _=await o.createWritable();await _.write(E),await _.close()},w=()=>{if(!i||h)return;m();const E=i.text();u=u.then(()=>y(E)).catch(g)},b=()=>{l!==void 0&&w()};return{attach(E){var _,N;if(E){i=E,(_=r.win)==null||_.addEventListener("pagehide",b);return}l!==void 0&&w(),i=null,(N=r.win)==null||N.removeEventListener("pagehide",b)},edited(){!i||h||(p().then(E=>{E||g()}),m(),l=r.timers.set(w,sw))},saveNow:w}}function z9(e,t,n,r){let o=null,i,l=e.version,c=!1,u=null,h=!1;const p=()=>{i!==void 0&&r.timers.clear(i),i=void 0},m=b=>{h||(h=!0,p(),u=null,n(b))},g=b=>{if(!r.send)return;const E=Ko();c=!0,ag.set(E,_=>{if(c=!1,_.ok?l=_.version:_.reason==="changed"?m(`read-only: ${t} changed on disk; open it again to edit`):m(_.message??`not saved: ${t}`),u!==null&&!h){const N=u;u=null,g(N)}}),r.send({t:"write-loose",id:e.id,content:b,base:l,seq:E})},y=()=>{if(!o||h)return;p();const b=o.text();b.length>zd||(c?u=b:g(b))},w=()=>{i!==void 0&&y()};return{attach(b){var E,_;if(b){o=b,(E=r.win)==null||E.addEventListener("pagehide",w);return}i!==void 0&&y(),o=null,(_=r.win)==null||_.removeEventListener("pagehide",w)},edited(){!o||h||(p(),i=r.timers.set(y,sw))},saveNow:y}}function iw({kind:e,className:t,height:n,resizable:r=!0,onDragStart:o,title:i,tabs:l,actions:c,menu:u,full:h,onToggleFull:p,onClose:m,closeHint:g="esc",children:y}){const w=wn("pane"),b=p&&d.jsxs(ze,{variant:"outline",tone:"quiet",mono:!0,className:"deep-link",onClick:p,"data-tip":h?"Split view: show the preview above":"Full height: hide the preview",children:[d.jsx(Nt,{name:h?"split":"full",className:"icon-inline"})," ",h?"split":"full"]}),E=d.jsx(Pt,{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:Ue("pane-head",l&&"pane-head-tabs"),...w.contextMenu(()=>(u==null?void 0:u())??[]),children:l?d.jsx(Pf,{...l,end:d.jsxs(d.Fragment,{children:[c,b,E]})}):d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"pane-title",children:i}),c,b,E]})}),y]})}function F9({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(()=>Cc(e,{open:()=>r(!0)})),children:d.jsx("img",{src:e,alt:t})}),n&&d.jsx(jk,{owner:"editor",onClose:()=>r(!1),menu:()=>Cc(e),children:d.jsx("img",{src:e,alt:t})})]})}const B9={image:F9};function U9({kind:e,src:t,path:n,openSeq:r,focus:o,full:i,onFull:l}){const c=S.useRef(null);St([r],()=>{var h;o&&((h=c.current)==null||h.focus())});const u=B9[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 H9="img[src], source[src], video[src], audio[src], video[poster], link[href], object[data]";function W9(e,t){if(!t)return e;const n=new DOMParser().parseFromString(e,"text/html");let r=!1;for(const o of n.querySelectorAll(H9))for(const i of["src","href","poster","data"]){const l=o.getAttribute(i),c=l===null?null:Ck(t.dir,l);c&&(o.setAttribute(i,t.urls.worktreeFile(t.worktreeId,c,t.version)),r=!0)}return r?`${n.doctype?`<!doctype html>
243
+ `:""}${n.documentElement.outerHTML}`:e}function K9({text:e,path:t,worktreeId:n,version:r,openSeq:o,focus:i}){const l=S.useRef(null);St([o],()=>{var p;i&&((p=l.current)==null||p.focus())});const c=Wr(),u=rS(t),h=S.useMemo(()=>W9(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 Z9(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 q9(e){const t=new Map,n=Array.from(e.querySelectorAll("h1, h2, h3, h4, h5, h6")),r=Z9(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}
244
+ ${l}`,level:Number(o.tagName[1]),depth:r[i],text:l,el:o}})}const G9=48,V9=16;function Y9({text:e,path:t,worktreeId:n,version:r,openSeq:o,focus:i,onChat:l}){ct();const c=Wr(),u=lt(),h=rS(t),p=Hk(e,r===void 0?void 0:{base:{worktreeId:n,dir:h,version:r,urls:c}}),m=S.useRef(null),g=S.useRef(null),[y,w]=S.useState([]),[b,E]=S.useState(-1),[_,N]=S.useState(null),T=$=>{var C;if(N(null),$){const j=window.getSelection();j==null||j.removeAllRanges(),j==null||j.addRange($)}(C=m.current)==null||C.focus()};St([o],()=>{var $;i&&(($=m.current)==null||$.focus())}),St([p],()=>{m.current&&w(q9(m.current))}),S.useLayoutEffect(()=>{const $=m.current;if(!$)return;let C=0;const j=()=>{if(C=0,$.scrollTop+$.clientHeight>=$.scrollHeight-1){E(y.length-1);return}const z=$.scrollTop+G9;let X=-1;for(let ae=0;ae<y.length;ae++)y[ae].el.offsetTop<=z&&(X=ae);E(X)},D=()=>{C||(C=requestAnimationFrame(j))};return j(),$.addEventListener("scroll",D),()=>{$.removeEventListener("scroll",D),C&&cancelAnimationFrame(C)}},[y]);const R=$=>{var j,D;const C=(j=y[$])==null?void 0:j.el;(D=m.current)==null||D.scrollTo({top:Math.max(0,C?C.offsetTop-V9:0),behavior:"smooth"})},O=$=>{const C=$.target.closest("a"),j=C==null?void 0:C.getAttribute("href");if(!j||(C==null?void 0:C.target)==="_blank")return;$.preventDefault();const D=Ck(h,j);D&&er({dispatch:u},{worktreeId:n,path:D,view:qi(D)})},B=$=>{var C;if(Tk($)){$.preventDefault(),$.stopPropagation();const j=(g.current&&Bm(g.current))??"";N(D=>({seed:j||(D==null?void 0:D.seed)||"",seq:((D==null?void 0:D.seq)??0)+1}));return}if($.key==="Escape"&&_){$.stopPropagation(),T(null);return}if(X_($)&&g.current){$.preventDefault(),J_(g.current);return}if(((C=Xx($))==null?void 0:C.id)==="composer"&&g.current){const j=Bm(g.current);if(!j)return;$.preventDefault(),$.stopPropagation(),l(j)}};return d.jsxs(d.Fragment,{children:[d.jsx("div",{ref:m,className:"editor-viewer editor-preview",tabIndex:-1,onClick:O,onKeyDown:B,children:d.jsx("div",{ref:g,className:"md md-preview",dangerouslySetInnerHTML:{__html:p}})}),_&&d.jsx(Y_,{root:m,body:g,seed:_.seed,seq:_.seq,onClose:T}),d.jsx(X9,{heads:y,at:b,onJump:R})]})}function X9({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:"editor-outline","aria-hidden":!0,onPointerEnter:l=>{l.pointerType==="mouse"&&o(!0)},onClick:()=>o(l=>!l),children:e.map((l,c)=>d.jsx("span",{className:"editor-outline-tick","data-level":l.level,"data-state":gr({current:c===t})},l.id))}),r&&d.jsx(Ns,{className:"editor-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 editor-outline-row","data-level":l.level,"data-state":gr({current:c===t}),onClick:()=>n(c),children:d.jsx("span",{className:"editor-outline-label",style:{"--outline-depth":l.depth},children:l.text})},l.id))})]})}function Q9({absPath:e,onReveal:t}){const n=wn("editor"),{host:r}=Wr();return uk(r)?d.jsxs(ze,{variant:"outline",tone:"quiet",mono:!0,className:"deep-link",...n.dropdown(()=>Gi(e,t,r),"right"),children:["open in ",d.jsx(Nt,{name:"caret",className:"icon-inline"})]}):null}const J9=S.lazy(async()=>{const[e]=await Promise.all([ig(()=>import("./Editor-CUcgZuoM.js").then(t=>t.E),__vite__mapDeps([0,1,2])),ig(()=>import("./grammar-DzHb7e7O.js"),[]).then(t=>t.grammarsReady)]);return e});function Sx({what:e}){return ME(!0,3e3)?d.jsx("div",{className:"empty",children:d.jsxs("span",{className:"live-text",children:["loading ",e]})}):null}const eB=()=>{},tB={diff:"diff",file:"text",preview:"book"};function nB(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 qN({editor:e,height:t,full:n=!1,onToggleFull:r,onDragStart:o,placement:i="stack"}){const l=i==="screen",c=lt(),u=Zn(),h=ct(),p=Wr(),m=OE(),g=jf(),{worktreeId:y,path:w,ref:b,since:E}=e,_=e.loose,N=P(M=>{var oe;return((oe=No(M))==null?void 0:oe.id)===y}),T=P(M=>{var ne,H;const oe=(ne=kn(M,y))==null?void 0:ne.worktree;return oe?oe.path:(H=No(M))==null?void 0:H.path}),R=_?_.source.kind==="grant"?_.source.path:null:T?`${T}/${w}`:w,O=b!==void 0,B=S.useMemo(()=>_?D9(_.source,w,M=>c({a:"editor-refused",file:{worktreeId:y,path:w},message:M}),L9(h?M=>h.send(M):null)):(m==null?void 0:m.bind({worktreeId:y,path:w,...b?{ref:b}:{},...E?{since:E}:{}}))??ZN,[m,y,w,b,E,_,c,h]),$=P(M=>_o(M,y).changedRanges[w]);S.useEffect(()=>{!$&&!O&&!N&&!_&&(h==null||h.send({t:"changed-ranges",worktreeId:y,path:w}))},[y,w,$,O,N,_,h]);const C=($==null?void 0:$.offset)??0,j=e.disk,D=e.view??"diff",z=(j==null?void 0:j.before)==="",X=YE(w,z).filter(M=>M!==D&&!(_&&M==="diff")),ae=(_==null?void 0:_.source.kind)==="grant"?_.source:null,A=O||N||_&&!ae?null:dM(w),[de,ue]=S.useState(!1),J=e.line&&!e.line.fiber?e.line.n:void 0;return d.jsxs(iw,{kind:"editor",className:Ue("editor-pane",n&&"full"),height:n||l?void 0:t,resizable:!n&&!l,onDragStart:o??eB,title:O?`${w} at ${b==null?void 0:b.slice(0,7)}`:E?`${w}, last turn`:w,menu:()=>T&&!_?xs({id:y,dir:T},w,{discard:!O&&!N,kept:N,ref:b,showing:e.view??void 0,added:z},{sock:h,dispatch:c}):[],onClose:()=>c({a:"close-editor"}),full:n,onToggleFull:l?void 0:r,actions:d.jsxs(d.Fragment,{children:[!A&&X.map(M=>d.jsxs(ze,{variant:"outline",tone:"quiet",mono:!0,className:"deep-link",onClick:()=>c({a:"editor-view",v:M}),"data-tip":nB(M,D),children:[d.jsx(Nt,{name:tB[M],className:"icon-inline"})," ",M]},M)),A==="image"&&d.jsxs(ze,{variant:"outline",tone:"quiet",mono:!0,className:"deep-link",onClick:()=>ue(!0),"data-tip":"Full size: see the picture over the window",children:[d.jsx(Nt,{name:"zen",className:"icon-inline"})," full size"]}),!N&&R!==null&&d.jsx(Q9,{absPath:R,onReveal:_?void 0:()=>h==null?void 0:h.send({t:"reveal",worktreeId:y,path:w})})]}),children:[j&&d.jsx(rB,{editor:e,disk:j,files:m}),d.jsx("div",{className:"editor-body",children:j?A?d.jsx(U9,{kind:A,src:ae?p.loose(ae.id,ae.version):p.worktreeFile(y,w,j.version),path:w,openSeq:e.seq,focus:e.focus,full:de,onFull:ue}):j.binary?d.jsx("div",{className:"empty",children:"not a text file: open it in another editor"}):j.tooLarge?d.jsx("div",{className:"empty",children:"too large to open here: open it in another editor"}):D==="preview"&&Ef(w)==="html"?d.jsx(K9,{text:j.after,path:w,worktreeId:y,version:O||N||_?void 0:j.version,openSeq:e.seq,focus:e.focus}):D==="preview"?d.jsx(Y9,{text:j.after,path:w,worktreeId:y,version:O||N||_?void 0:j.version,openSeq:e.seq,focus:e.focus,onChat:M=>Z0(u,{worktreeId:y,text:M,name:w})}):d.jsx(wk,{pane:!0,children:d.jsx(S.Suspense,{fallback:d.jsx(Sx,{what:D}),children:d.jsx(J9,{file:{worktreeId:y,path:w,...b?{ref:b}:{},...E?{since:E}:{}},disk:j,blame:e.blame,view:D,openSeq:e.seq,line:J,focus:e.focus,readOnly:O||!j.writable||l,numbers:!l,theme:g,sync:B,onCopy:_?void 0:(M,oe,ne)=>NP(ne,{worktreeId:y,path:M,...oe,...b?{ref:b}:{}}),onChat:(M,oe)=>Z0(u,oe&&(_?{worktreeId:y,text:oe.text,name:M}:{worktreeId:y,text:oe.text,source:{path:M,startLine:oe.startLine,endLine:oe.endLine,...b?{ref:b}:{}}})),onNew:()=>u.dispatch({a:"open-draft"}),onLineHover:O||_?void 0:M=>{M==null?an.post(y,{type:"highlight-clear"}):an.post(y,{type:"highlight-file",path:w,ranges:[[M+C,M+C]]})}},`${y}
245
+ ${_?"loose":b??E??""}
246
+ ${w}`)})}):d.jsx(Sx,{what:w},w)})]})}function rB({editor:e,disk:t,files:n}){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 h=c.version===null;return d.jsxs("div",{className:"editor-note",children:[d.jsx("span",{className:"editor-note-text",children:h?"deleted on disk; your edits are not saved":"changed on disk; your edits are not saved"}),d.jsx(ze,{variant:"outline",onClick:()=>n==null?void 0:n.reload(u),"data-tip":h?"Close the file; your edits go with it":"Take the file as it is on disk; undo brings your edits back",children:h?"close":"reload"}),d.jsx(ze,{variant:"outline",tone:"danger",onClick:()=>n==null?void 0:n.keepMine(u),"data-tip":h?"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})}):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 aw(e,{sock:t}){var r;const n=[];return e.canLogout&&((r=e.auth)==null?void 0:r.kind)!=="none"&&n.push({id:"logout",label:"log out",danger:!0,onClick:()=>t==null?void 0:t.send({t:"agent-logout",agent:e.id})}),!e.available&&!e.installing&&n.push({id:"install",label:e.onDemand&&e.reason==="not installed"?"install":"install again",onClick:()=>t==null?void 0:t.send({t:"install-agent",agent:e.id})}),n}function GN(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 oB=(e,t)=>{const n=bm(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"}},af="https://github.com/toyon-dev/toyon",sB=e=>`${af}/releases/tag/v${e}`,iB=`${af}/releases/latest`,aB=4e3;function lB(e,t,n,r){if(r==="asking")return{value:`${e} checking`,text:`Asking ${bm(n)} for the newest version`,act:"check",busy:!0};const o=bm(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(cM(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 cB(e,t,n,r,o,i=!1,l=null,c=null){if(n){if(n.restarting){const h=n.installed??n.running,p=n.restarting.length>0?v_(n.restarting):"Toyon is restarting; this page reloads when it is back";return{value:`${h} restarting`,text:p,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=GN(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?lB(e,t,l,c):{value:e,text:`Toyon ${e}, ${oB(t,l)}`,act:"check",busy:!1}}function uB(e,t){const n=r=>()=>window.open(r,"_blank");return zn([t?[{id:"check-update",label:"check for updates",...t.off?{disabled:t.off}:{},onClick:t.run}]:[],[{id:"release-notes",label:`release notes for ${e}`,onClick:n(sB(e))},{id:"latest-release",label:"latest release",onClick:n(iB)},{id:"repo",label:"Toyon on GitHub",onClick:n(af)},{id:"report",label:"report a problem",onClick:n(`${af}/issues/new`)}],[{id:"copy-version",label:"copy version",onClick:()=>on(e)}]])}const dB=nC.map(e=>({title:e,rows:sC(e).map(t=>[Lt(t),cc[t].label])}));function fB(){const e=lt(),t=ct(),n=wn("keys"),r=P(m=>m.themePrefs),o=P(m=>m.themes),i=P(m=>m.chatSide),l=P(m=>m.keepAwake),c=nk(),u=P(m=>m.agents),h=fl(),p=m=>{e({a:"palette-return",v:{mode:"keys",q:""}}),e(m)};return d.jsxs(Kf,{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(ze,{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(()=>Hf(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(mB,{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(ze,{variant:"field",mono:!0,onClick:()=>p({a:"open",overlay:{kind:"appearance"}}),children:Jd[r.mode]})]}),d.jsxs("div",{className:"keys-setting",children:[d.jsx("span",{className:"keys-d",children:"theme"}),d.jsx(ze,{variant:"field",mono:!0,onClick:()=>p({a:"open",overlay:{kind:"theme",slot:"theme"}}),children:xf(r,o,c).name})]}),d.jsxs("div",{className:"keys-setting",children:[d.jsx("span",{className:"keys-d",children:"chat side"}),d.jsx(ze,{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(ze,{variant:"field",mono:!0,onClick:()=>p({a:"open",overlay:{kind:"keep-awake"}}),children:ef[l]})]}),d.jsx(hB,{}),d.jsx(pB,{})]})]}),d.jsx("div",{className:"keys-card",children:dB.map(m=>d.jsxs("div",{children:[d.jsx("div",{className:"section-title keys-h",children:m.title}),m.rows.map(([g,y])=>d.jsxs("div",{className:"keys-row",children:[d.jsx(Zo,{k:g}),d.jsx("span",{className:"keys-d",children:y})]},g))]},m.title))})]})}function hB(){const e=ct(),t=lt(),n=wn("keys"),r=P(_=>_.version),o=P(_=>_.install),i=P(_=>_.registry),l=P(_=>_.update),c=P(_=>_.self),u=P(_=>_.rebuilt),h=P(_=>_.repos),p=P(_=>_.managed.updates),m=P(_=>_.updateCheck),g=cB(r,o,l,c,h,u,i,m),y=!p&&(g.act==="update"||g.act==="check"),w=g.settles&&m&&m!=="asking"?m:null;S.useEffect(()=>{if(!w)return;const _=()=>t({a:"update-check-settle",check:w}),N=setTimeout(_,aB);return()=>{clearTimeout(N),_()}},[w,t]);const b=()=>{g.act==="restart"?e==null||e.send({t:"restart-daemon"}):g.act==="reload"?window.location.reload():g.act==="rebuild"&&c?e==null||e.send({t:"run-after-land",repoId:c.repoId}):g.act==="update"?e==null||e.send({t:"update-now"}):g.act==="check"&&e&&(t({a:"update-check"}),e.send({t:"check-update"}))},E=()=>uB(r,g.act==="check"&&!g.busy?{run:b,...y?{off:"managed by your organization"}:{}}:null);return d.jsxs("div",{className:"keys-setting",...n.contextMenu(E),children:[d.jsx("span",{className:"keys-d",children:"version"}),d.jsx(ze,{variant:"field",mono:!0,busy:g.busy,disabled:y,onClick:b,...Ut(y?"updates are managed by your organization":g.text,void 0,{detail:g.detail}),children:g.value})]})}function pB(){const e=P(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: ${YO(e).join(", ")||"nothing turned off"}`;return d.jsx("div",{className:"hint",children:t})}function VN(e){return e.available?e.auth?e.auth.kind==="none"?"not logged in":e.auth.label:"ready":e.installing?"installing":"not installed"}function YN(e){var n,r;return e.available?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":e.reason??"not installed"}function mB({agent:e}){const t=lt(),n=ct(),r=wn("keys");return d.jsxs("div",{className:"keys-setting",children:[d.jsx("span",{className:"keys-d",children:e.name}),d.jsx(ze,{variant:"field",mono:!0,"data-tip":YN(e),...r.contextMenu(()=>aw(e,{sock:n})),onClick:()=>{t({a:"palette-return",v:{mode:"keys",q:""}}),t({a:"open",overlay:{kind:"agent-page",agent:e.id}})},children:VN(e)})]})}function gB({agentId:e}){const t=lt(),n=ct(),r=fl(),o=P(g=>g.home),i=P(g=>g.agents.find(y=>y.id===e)??null),l=P(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]),!i)return null;const u=aw(i,{sock:n}),h=()=>t({a:"close",back:!0}),p=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(Kf,{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(Pt,{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(ze,{variant:"field",mono:!0,"data-tip":YN(i),disabled:u.length===0,...c.dropdown(()=>u,"right"),children:VN(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",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(kB,{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(ze,{variant:"field",mono:!0,"data-tip":`reveal ${p(g.path)} in Finder`,onClick:()=>m(g),children:p(g.path)}):d.jsxs("span",{className:"keys-d",children:["not present: ",p(g.path)]})]},g.id))]})]})})}function kB({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 wB(){const e=lt(),t=ct(),n=P(o=>o.agents),r=P(o=>o.defaultAgent);return d.jsx(Or,{items:n,filter:(o,i)=>o.filter(l=>ns(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=>aw(o,{sock:t}),placeholder:"default agent for new worktrees",keys:{pick:"sets",back:"closes"},row:o=>d.jsx(On,{label:o.name,current:o.id===r,hint:o.available?o.sandboxed?void 0:"unsandboxed":o.reason??"not installed"})})}const yB=["dark","light","system","daylight"],vB=new Intl.DateTimeFormat(void 0,{hour:"numeric",minute:"2-digit"});function bB(){const e=lt(),t=ct(),n=P(u=>u.themePrefs),r=P(u=>u.themes),o=nk(),i=P(u=>u.daylight),l=u=>{var h;return((h=r.find(p=>p.id===n[Og({...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 ${vB.format(i.until)}`:"";return`${o.daylight?"dark":"light"} now${h} · ${l(u)}`};return d.jsx(Or,{items:yB,filter:(u,h)=>u.filter(p=>ns(h,Jd[p])),rowClass:()=>"picker-row",keyOf:u=>u,initialIndex:u=>u.indexOf(n.mode),onActive:u=>e({a:"preview-theme",theme:u?xf({...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(On,{label:Jd[u],current:u===n.mode,hint:c(u)})})}const xB=2,lg=e=>K1(e).join(" ").length<xB,EB=e=>({kind:"chat",id:e.id,name:e.name,hint:e.branch??"",fields:[e.name,e.branch??""]}),_B=e=>({kind:"chat",id:e.id,name:e.title,hint:W_(e),fields:[e.title,e.branch],prompt:e.prompt,archived:e});function SB(e,t,n){const r=K1(t),o=n==="all"&&!lg(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 NB=e=>e.flatMap(([t,n])=>Array.from({length:n},(r,o)=>t+o));function TB({repoId:e,scope:t}){const n=lt(),r=ct(),o=P(T=>T.clientId),i=P(T=>T.frame),l=P(T=>T.chats[e]),c=ik(),u=P(T=>T.archived[e]),[h,p]=S.useState(t),m=S.useCallback(()=>p(T=>T==="all"?"names":"all"),[]);S.useEffect(()=>{r==null||r.send({t:"list-archived",repoId:e})},[r,e]);const g=S.useMemo(()=>[...c.filter(T=>!$r(T.worktree)).map(EB),...(u??[]).map(_B)],[c,u]),y=S.useMemo(()=>new Map(g.map(T=>[T.id,T])),[g]),w=S.useMemo(()=>[...g,...((l==null?void 0:l.hits)??[]).map(T=>({kind:"hit",hit:T}))],[g,l]),b=S.useCallback((T,R)=>SB(T,R,h),[h]),E=S.useCallback(T=>{h==="all"&&!lg(T)&&(r==null||r.send({t:"search-chats",repoId:e,query:T.trim()}))},[r,e,h]),_=T=>!l||l.query!==T.trim(),N=T=>h==="all"&&!lg(T);return d.jsx(Or,{items:w,filter:b,onQuery:E,onTab:m,trailing:d.jsx(ze,{tone:"chrome",on:h==="names","aria-pressed":h==="names",onClick:m,children:"names only"}),keyOf:T=>T.kind==="hit"?`h:${T.hit.worktreeId}:${T.hit.seq}`:`w:${T.id}`,rowClass:T=>T.kind==="hit"?"chats-hit":Ue("picker-row",T.archived&&!T.archived.restorable&&"dim"),rowTitle:T=>{var R;return T.kind==="hit"?T.hit.text:((R=T.archived)==null?void 0:R.prompt)??T.name},groupOf:T=>T.kind==="hit"?`h:${T.hit.worktreeId}`:T.archived?"archived":"open",groupHead:(T,R)=>{if(!T.startsWith("h:"))return`${T} · ${R}`;const O=y.get(T.slice(2));return d.jsxs("span",{children:[(O==null?void 0:O.name)??"a worktree",(O==null?void 0:O.archived)&&d.jsxs(d.Fragment,{children:[" ",d.jsx("span",{className:"row-dim",children:"archived"})]}),` · ${R}`]})},headAlone:!0,onPick:T=>{const R=T.kind==="hit"?T.hit.worktreeId:T.id,O=T.kind==="hit"?T.hit.archived:!!T.archived;n(O?{a:"open-archived",id:R}:{a:"activate",id:R}),T.kind==="hit"&&n({a:"reveal",id:R,seq:T.hit.seq}),n({a:"close"})},onBack:()=>n({a:"close"}),rowMenu:T=>T.kind==="chat"&&T.archived?jd(T.archived,{clientId:o,frame:i},{sock:r,dispatch:n}):[],placeholder:h==="names"?"find a chat by name…":"search in chats…",keys:T=>({nav:"moves",tab:h==="names"?"searches messages too":"searches names only",pick:T?T.kind==="hit"?"opens the chat there":"opens its chat":void 0,back:"closes"}),empty:T=>T.trim()?N(T)?_(T)?"searching…":"no chat says that":"no chat is named that":u?"no chats yet":"looking…",footer:(T,R)=>{const O=R.filter(B=>B.kind==="hit").length;return l!=null&&l.truncated&&!_(T)&&O>0?d.jsxs("div",{className:"empty",children:["showing the first ",O,"; narrow the search"]}):null},row:T=>T.kind==="chat"?d.jsx(On,{label:T.name,hint:T.hint}):d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"chats-text",children:Rc(T.hit.text,NB(T.hit.match),0)}),d.jsxs("span",{className:"chats-said row-dim",children:[T.hit.role==="user"?"you":"the agent",T.hit.ts>0?` · ${to(T.hit.ts)}`:""]})]})})}const pl=function(e,t){let o=e;const i=ac[t];let l=null,c=0,u=null;const h=[],p={},m=function($,C){c=o*4+17,l=(function(j){const D=new Array(j);for(let z=0;z<j;z+=1){D[z]=new Array(j);for(let X=0;X<j;X+=1)D[z][X]=null}return D})(c),g(0,0),g(c-7,0),g(0,c-7),b(),w(),_($,C),o>=7&&E($),u==null&&(u=R(o,i,h)),N(u,C)},g=function($,C){for(let j=-1;j<=7;j+=1)if(!($+j<=-1||c<=$+j))for(let D=-1;D<=7;D+=1)C+D<=-1||c<=C+D||(0<=j&&j<=6&&(D==0||D==6)||0<=D&&D<=6&&(j==0||j==6)||2<=j&&j<=4&&2<=D&&D<=4?l[$+j][C+D]=!0:l[$+j][C+D]=!1)},y=function(){let $=0,C=0;for(let j=0;j<8;j+=1){m(!0,j);const D=Js.getLostPoint(p);(j==0||$>D)&&($=D,C=j)}return C},w=function(){for(let $=8;$<c-8;$+=1)l[$][6]==null&&(l[$][6]=$%2==0);for(let $=8;$<c-8;$+=1)l[6][$]==null&&(l[6][$]=$%2==0)},b=function(){const $=Js.getPatternPosition(o);for(let C=0;C<$.length;C+=1)for(let j=0;j<$.length;j+=1){const D=$[C],z=$[j];if(l[D][z]==null)for(let X=-2;X<=2;X+=1)for(let ae=-2;ae<=2;ae+=1)X==-2||X==2||ae==-2||ae==2||X==0&&ae==0?l[D+X][z+ae]=!0:l[D+X][z+ae]=!1}},E=function($){const C=Js.getBCHTypeNumber(o);for(let j=0;j<18;j+=1){const D=!$&&(C>>j&1)==1;l[Math.floor(j/3)][j%3+c-8-3]=D}for(let j=0;j<18;j+=1){const D=!$&&(C>>j&1)==1;l[j%3+c-8-3][Math.floor(j/3)]=D}},_=function($,C){const j=i<<3|C,D=Js.getBCHTypeInfo(j);for(let z=0;z<15;z+=1){const X=!$&&(D>>z&1)==1;z<6?l[z][8]=X:z<8?l[z+1][8]=X:l[c-15+z][8]=X}for(let z=0;z<15;z+=1){const X=!$&&(D>>z&1)==1;z<8?l[8][c-z-1]=X:z<9?l[8][15-z-1+1]=X:l[8][15-z-1]=X}l[c-8][8]=!$},N=function($,C){let j=-1,D=c-1,z=7,X=0;const ae=Js.getMaskFunction(C);for(let A=c-1;A>0;A-=2)for(A==6&&(A-=1);;){for(let de=0;de<2;de+=1)if(l[D][A-de]==null){let ue=!1;X<$.length&&(ue=($[X]>>>z&1)==1),ae(D,A-de)&&(ue=!ue),l[D][A-de]=ue,z-=1,z==-1&&(X+=1,z=7)}if(D+=j,D<0||c<=D){D-=j,j=-j;break}}},T=function($,C){let j=0,D=0,z=0;const X=new Array(C.length),ae=new Array(C.length);for(let J=0;J<C.length;J+=1){const M=C[J].dataCount,oe=C[J].totalCount-M;D=Math.max(D,M),z=Math.max(z,oe),X[J]=new Array(M);for(let ie=0;ie<X[J].length;ie+=1)X[J][ie]=255&$.getBuffer()[ie+j];j+=M;const ne=Js.getErrorCorrectPolynomial(oe),se=$c(X[J],ne.getLength()-1).mod(ne);ae[J]=new Array(ne.getLength()-1);for(let ie=0;ie<ae[J].length;ie+=1){const he=ie+se.getLength()-ae[J].length;ae[J][ie]=he>=0?se.getAt(he):0}}let A=0;for(let J=0;J<C.length;J+=1)A+=C[J].totalCount;const de=new Array(A);let ue=0;for(let J=0;J<D;J+=1)for(let M=0;M<C.length;M+=1)J<X[M].length&&(de[ue]=X[M][J],ue+=1);for(let J=0;J<z;J+=1)for(let M=0;M<C.length;M+=1)J<ae[M].length&&(de[ue]=ae[M][J],ue+=1);return de},R=function($,C,j){const D=Nx.getRSBlocks($,C),z=Tx();for(let ae=0;ae<j.length;ae+=1){const A=j[ae];z.put(A.getMode(),4),z.put(A.getLength(),Js.getLengthInBits(A.getMode(),$)),A.write(z)}let X=0;for(let ae=0;ae<D.length;ae+=1)X+=D[ae].dataCount;if(z.getLengthInBits()>X*8)throw"code length overflow. ("+z.getLengthInBits()+">"+X*8+")";for(z.getLengthInBits()+4<=X*8&&z.put(0,4);z.getLengthInBits()%8!=0;)z.putBit(!1);for(;!(z.getLengthInBits()>=X*8||(z.put(236,8),z.getLengthInBits()>=X*8));)z.put(17,8);return T(z,D)};p.addData=function($,C){C=C||"Byte";let j=null;switch(C){case"Numeric":j=jB($);break;case"Alphanumeric":j=CB($);break;case"Byte":j=AB($);break;case"Kanji":j=IB($);break;default:throw"mode:"+C}h.push(j),u=null},p.isDark=function($,C){if($<0||c<=$||C<0||c<=C)throw $+","+C;return l[$][C]},p.getModuleCount=function(){return c},p.make=function(){if(o<1){let $=1;for(;$<40;$++){const C=Nx.getRSBlocks($,i),j=Tx();for(let z=0;z<h.length;z++){const X=h[z];j.put(X.getMode(),4),j.put(X.getLength(),Js.getLengthInBits(X.getMode(),$)),X.write(j)}let D=0;for(let z=0;z<C.length;z++)D+=C[z].dataCount;if(j.getLengthInBits()<=D*8)break}o=$}m(!1,y())},p.createTableTag=function($,C){$=$||2,C=typeof C>"u"?$*4:C;let j="";j+='<table style="',j+=" border-width: 0px; border-style: none;",j+=" border-collapse: collapse;",j+=" padding: 0px; margin: "+C+"px;",j+='">',j+="<tbody>";for(let D=0;D<p.getModuleCount();D+=1){j+="<tr>";for(let z=0;z<p.getModuleCount();z+=1)j+='<td style="',j+=" border-width: 0px; border-style: none;",j+=" border-collapse: collapse;",j+=" padding: 0px; margin: 0px;",j+=" width: "+$+"px;",j+=" height: "+$+"px;",j+=" background-color: ",j+=p.isDark(D,z)?"#000000":"#ffffff",j+=";",j+='"/>';j+="</tr>"}return j+="</tbody>",j+="</table>",j},p.createSvgTag=function($,C,j,D){let z={};typeof arguments[0]=="object"&&(z=arguments[0],$=z.cellSize,C=z.margin,j=z.alt,D=z.title),$=$||2,C=typeof C>"u"?$*4:C,j=typeof j=="string"?{text:j}:j||{},j.text=j.text||null,j.id=j.text?j.id||"qrcode-description":null,D=typeof D=="string"?{text:D}:D||{},D.text=D.text||null,D.id=D.text?D.id||"qrcode-title":null;const X=p.getModuleCount()*$+C*2;let ae,A,de,ue,J="",M;for(M="l"+$+",0 0,"+$+" -"+$+",0 0,-"+$+"z ",J+='<svg version="1.1" xmlns="http://www.w3.org/2000/svg"',J+=z.scalable?"":' width="'+X+'px" height="'+X+'px"',J+=' viewBox="0 0 '+X+" "+X+'" ',J+=' preserveAspectRatio="xMinYMin meet"',J+=D.text||j.text?' role="img" aria-labelledby="'+O([D.id,j.id].join(" ").trim())+'"':"",J+=">",J+=D.text?'<title id="'+O(D.id)+'">'+O(D.text)+"</title>":"",J+=j.text?'<description id="'+O(j.id)+'">'+O(j.text)+"</description>":"",J+='<rect width="100%" height="100%" fill="white" cx="0" cy="0"/>',J+='<path d="',de=0;de<p.getModuleCount();de+=1)for(ue=de*$+C,ae=0;ae<p.getModuleCount();ae+=1)p.isDark(de,ae)&&(A=ae*$+C,J+="M"+A+","+ue+M);return J+='" stroke="transparent" fill="black"/>',J+="</svg>",J},p.createDataURL=function($,C){$=$||2,C=typeof C>"u"?$*4:C;const j=p.getModuleCount()*$+C*2,D=C,z=j-C;return MB(j,j,function(X,ae){if(D<=X&&X<z&&D<=ae&&ae<z){const A=Math.floor((X-D)/$),de=Math.floor((ae-D)/$);return p.isDark(de,A)?0:1}else return 1})},p.createImgTag=function($,C,j){$=$||2,C=typeof C>"u"?$*4:C;const D=p.getModuleCount()*$+C*2;let z="";return z+="<img",z+=' src="',z+=p.createDataURL($,C),z+='"',z+=' width="',z+=D,z+='"',z+=' height="',z+=D,z+='"',j&&(z+=' alt="',z+=O(j),z+='"'),z+="/>",z};const O=function($){let C="";for(let j=0;j<$.length;j+=1){const D=$.charAt(j);switch(D){case"<":C+="&lt;";break;case">":C+="&gt;";break;case"&":C+="&amp;";break;case'"':C+="&quot;";break;default:C+=D;break}}return C},B=function($){$=typeof $>"u"?2:$;const j=p.getModuleCount()*1+$*2,D=$,z=j-$;let X,ae,A,de,ue;const J={"██":"█","█ ":"▀"," █":"▄"," ":" "},M={"██":"▀","█ ":"▀"," █":" "," ":" "};let oe="";for(X=0;X<j;X+=2){for(A=Math.floor((X-D)/1),de=Math.floor((X+1-D)/1),ae=0;ae<j;ae+=1)ue="█",D<=ae&&ae<z&&D<=X&&X<z&&p.isDark(A,Math.floor((ae-D)/1))&&(ue=" "),D<=ae&&ae<z&&D<=X+1&&X+1<z&&p.isDark(de,Math.floor((ae-D)/1))?ue+=" ":ue+="█",oe+=$<1&&X+1>=z?M[ue]:J[ue];oe+=`
247
+ `}return j%2&&$>0?oe.substring(0,oe.length-j-1)+Array(j+1).join("▀"):oe.substring(0,oe.length-1)};return p.createASCII=function($,C){if($=$||1,$<2)return B(C);$-=1,C=typeof C>"u"?$*2:C;const j=p.getModuleCount()*$+C*2,D=C,z=j-C;let X,ae,A,de;const ue=Array($+1).join("██"),J=Array($+1).join(" ");let M="",oe="";for(X=0;X<j;X+=1){for(A=Math.floor((X-D)/$),oe="",ae=0;ae<j;ae+=1)de=1,D<=ae&&ae<z&&D<=X&&X<z&&p.isDark(A,Math.floor((ae-D)/$))&&(de=0),oe+=de?ue:J;for(A=0;A<$;A+=1)M+=oe+`
248
+ `}return M.substring(0,M.length-1)},p.renderTo2dContext=function($,C){C=C||2;const j=p.getModuleCount();for(let D=0;D<j;D++)for(let z=0;z<j;z++)$.fillStyle=p.isDark(D,z)?"black":"white",$.fillRect(z*C,D*C,C,C)},p};pl.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};pl.createStringToBytes=function(e,t){const n=(function(){const o=$B(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(),p=i(),m=i(),g=String.fromCharCode(u<<8|h),y=p<<8|m;c[g]=y,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 Ir={MODE_NUMBER:1,MODE_ALPHA_NUM:2,MODE_8BIT_BYTE:4,MODE_KANJI:8},ac={L:1,M:0,Q:3,H:2},Qs={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7},Js=(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 Qs.PATTERN000:return function(c,u){return(c+u)%2==0};case Qs.PATTERN001:return function(c,u){return c%2==0};case Qs.PATTERN010:return function(c,u){return u%3==0};case Qs.PATTERN011:return function(c,u){return(c+u)%3==0};case Qs.PATTERN100:return function(c,u){return(Math.floor(c/2)+Math.floor(u/3))%2==0};case Qs.PATTERN101:return function(c,u){return c*u%2+c*u%3==0};case Qs.PATTERN110:return function(c,u){return(c*u%2+c*u%3)%2==0};case Qs.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=$c([1],0);for(let u=0;u<l;u+=1)c=c.multiply($c([1,ti.gexp(u)],0));return c},o.getLengthInBits=function(l,c){if(1<=c&&c<10)switch(l){case Ir.MODE_NUMBER:return 10;case Ir.MODE_ALPHA_NUM:return 9;case Ir.MODE_8BIT_BYTE:return 8;case Ir.MODE_KANJI:return 8;default:throw"mode:"+l}else if(c<27)switch(l){case Ir.MODE_NUMBER:return 12;case Ir.MODE_ALPHA_NUM:return 11;case Ir.MODE_8BIT_BYTE:return 16;case Ir.MODE_KANJI:return 10;default:throw"mode:"+l}else if(c<41)switch(l){case Ir.MODE_NUMBER:return 14;case Ir.MODE_ALPHA_NUM:return 13;case Ir.MODE_8BIT_BYTE:return 16;case Ir.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 y=0;const w=l.isDark(m,g);for(let b=-1;b<=1;b+=1)if(!(m+b<0||c<=m+b))for(let E=-1;E<=1;E+=1)g+E<0||c<=g+E||b==0&&E==0||w==l.isDark(m+b,g+E)&&(y+=1);y>5&&(u+=3+y-5)}for(let m=0;m<c-1;m+=1)for(let g=0;g<c-1;g+=1){let y=0;l.isDark(m,g)&&(y+=1),l.isDark(m+1,g)&&(y+=1),l.isDark(m,g+1)&&(y+=1),l.isDark(m+1,g+1)&&(y+=1),(y==0||y==4)&&(u+=3)}for(let m=0;m<c;m+=1)for(let g=0;g<c-6;g+=1)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 p=Math.abs(100*h/c/c-50)/5;return u+=p*10,u},o})(),ti=(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})(),$c=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]^=ti.gexp(ti.glog(r.getAt(l))+ti.glog(o.getAt(c)));return $c(i,0)},r.mod=function(o){if(r.getLength()-o.getLength()<0)return r;const i=ti.glog(r.getAt(0))-ti.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]^=ti.gexp(ti.glog(o.getAt(c))+i);return $c(l,0).mod(o)},r},Nx=(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 ac.L:return e[(o-1)*4+0];case ac.M:return e[(o-1)*4+1];case ac.Q:return e[(o-1)*4+2];case ac.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 p=l[h*3+0],m=l[h*3+1],g=l[h*3+2];for(let y=0;y<p;y+=1)u.push(t(m,g))}return u},n})(),Tx=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},jB=function(e){const t=Ir.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},CB=function(e){const t=Ir.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},AB=function(e){const t=Ir.MODE_8BIT_BYTE,n=pl.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},IB=function(e){const t=Ir.MODE_KANJI,n=pl.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},XN=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},RB=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},$B=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},OB=function(e,t){const n=e,r=t,o=new Array(e*t),i={};i.setPixel=function(h,p,m){o[p*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 p=2,m=c(p);h.writeByte(p);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 p=h;let m=0,g=0;const y={};return y.write=function(w,b){if(w>>>b)throw"length over";for(;m+b>=8;)p.writeByte(255&(w<<m|g)),b-=8-m,w>>>=8-m,g=0,m=0;g=w<<m|g,m=m+b},y.flush=function(){m>0&&p.writeByte(g)},y},c=function(h){const p=1<<h,m=(1<<h)+1;let g=h+1;const y=u();for(let N=0;N<p;N+=1)y.add(String.fromCharCode(N));y.add(String.fromCharCode(p)),y.add(String.fromCharCode(m));const w=XN(),b=l(w);b.write(p,g);let E=0,_=String.fromCharCode(o[E]);for(E+=1;E<o.length;){const N=String.fromCharCode(o[E]);E+=1,y.contains(_+N)?_=_+N:(b.write(y.indexOf(_),g),y.size()<4095&&(y.size()==1<<g&&(g+=1),y.add(_+N)),_=N)}return b.write(y.indexOf(_),g),b.write(m,g),b.flush(),w.toByteArray()},u=function(){const h={};let p=0;const m={};return m.add=function(g){if(m.contains(g))throw"dup key:"+g;h[g]=p,p+=1},m.size=function(){return p},m.indexOf=function(g){return h[g]},m.contains=function(g){return typeof h[g]<"u"},m};return i},MB=function(e,t,n){const r=OB(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=XN();r.write(o);const i=RB(),l=o.toByteArray();for(let c=0;c<l.length;c+=1)i.writeByte(l[c]);return i.flush(),"data:image/gif;base64,"+i};pl.stringToBytes;function LB(e){const t=pl(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 or={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 ${lf(e)}.`,waiting:(e,t)=>`Toyon on ${lf(e)} is asking whether to let ${t} in.`,added:e=>`Added ${e}.`,notKept:e=>`Let in, but not listed: ${e}`,add:"add"};function PB(e,t){return e.reached?e.toyon&&!e.toyon.answering?or.notAnswering:t?or.listed:e.toyon?null:or.noToyon:or.offline}function jx(e){var t;return(t=e.toyon)!=null&&t.answering?0:e.toyon?1:e.reached?2:3}function lf(e){try{return new URL(e).host}catch{return e}}function QN(e,t,n){const r=lf(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 DB(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",or.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 zB=e=>e==="phone"?"phone":"laptop";function Cx({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:Ue("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(Nt,{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:Ue("tailnet-right",typeof t.right=="string"&&"hint"),children:t.right})]},t.key))})}const Ax=(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:zB(e.kind),right:t}},nm=4;function FB({text:e}){const{size:t,d:n}=S.useMemo(()=>{const r=LB(e);let o="";return r.forEach((i,l)=>{i.forEach((c,u)=>{c&&(o+=`M${u+nm} ${l+nm}h1v1h-1z`)})}),{size:r.length+nm*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 BB=5e3;function UB(e){return e.from===null?"A device that opened this address":`A Toyon page at ${lf(e.from)}`}function HB({knock:e,letIn:t,onAnswer:n}){return d.jsxs("div",{className:Ue("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?`${UB(e)} wants in.`:t?"is in.":"was turned away."})]}),t===null&&d.jsxs("div",{className:"devices-actions",children:[d.jsx(ze,{tone:"primary",onClick:()=>n(!0),children:"let in"}),d.jsx(ze,{variant:"outline",onClick:()=>n(!1),children:"not now"})]})]})}function WB({host:e,noPhone:t}){return d.jsxs("div",{className:"devices-address",children:[d.jsx("div",{className:"devices-frame",children:d.jsx(FB,{text:hC(e)})}),d.jsxs("div",{className:"devices-about",children:[d.jsx("p",{className:"devices-line",children:or.scan}),t&&d.jsx("p",{className:"devices-note",children:or.noPhone})]})]})}function KB(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)=>jx(r.d)-jx(o.d)||r.i-o.i).map(({d:r})=>r);return[...t,...n]}function ZB(){const e=lt(),t=Go(),n=Wr(),r=P(Z=>Z.frame==="desk"),o=P(Z=>{var je;return((je=Z.remote)==null?void 0:je.host)??null}),i=P(Z=>Z.machine),l=P(Z=>Z.tailscale),c=P(Z=>Z.knocks),[u,h]=S.useState(""),[p,m]=S.useState({kind:"idle"}),[g,y]=S.useState([]),w=()=>e({a:"close"}),b=p.kind==="asking"||p.kind==="waiting",E=oP(()=>bM(n),BB,!b),_=S.useRef(new AbortController);S.useEffect(()=>()=>_.current.abort(),[]);const N=async Z=>{if(b)return;const je=_.current.signal;m({kind:"asking",origin:Z});const He=await oE(Z,je,We=>m({kind:"waiting",origin:Z,word:We}));if(je.aborted)return;if(typeof He=="string"){m({kind:"failed",line:QN(He,Z,"this page")});return}const Fe=t.serving(),Pe=await NM(Lg(Fe.origin,Fe.token),Z,He.token);m(Pe?{kind:"failed",line:or.notKept(Pe)}:{kind:"added",name:t.displayName(Z)})},T=()=>{const Z=pC(u);Z?N(Z):m({kind:"failed",line:or.notAnAddress})},R=()=>{_.current.abort(),_.current=new AbortController,m({kind:"idle"})},O=(Z,je)=>{y(He=>He.some(Fe=>Fe.knock.id===Z.id)?He:[...He,{knock:Z,letIn:je}]),TM(n,Z.id,je)},B=c.filter(Z=>!g.some(je=>je.knock.id===Z.id)),$=[...g,...B.map(Z=>({knock:Z,letIn:null}))],[C,j]=S.useState(!1),[D,z]=S.useState(null),X=async Z=>{j(!0),z(null);const je=await(Z?xM(n):EM(n));j(!1),je&&z(je)},ae=(E==null?void 0:E.here)===!0,A=DB(E,l,o),de=o!==null,ue=r&&(ae||E===void 0)?d.jsx(ze,{variant:"outline",size:"sm",on:de,"aria-pressed":de,busy:C,disabled:!de&&(l==null?void 0:l.state)!=="ready",onClick:()=>void X(!de),...Ut(de?"Take this machine's name off your tailnet":"Give this machine a name on your tailnet"),children:de?"on":"off"}):null,[J,M]=S.useState(!1),[oe,ne]=S.useState(null),H=Z=>{window.open(Z,"_blank","noopener")===null?ne(Z):ne(null)},se=async Z=>{if(M(!0),z(null),Z==="connect"){const je=await _M(n);je&&z(je)}else{const je=await SM(n);"url"in je?H(je.url):z(je.why)}M(!1)},ie=r&&A.offer!==null?oe!==null?d.jsx(ze,{variant:"outline",size:"sm",onClick:()=>H(oe),children:"open the sign-in page"}):d.jsx(ze,{variant:"outline",size:"sm",busy:J,onClick:()=>void se(A.offer??"connect"),...A.note?Ut(A.note):{},children:A.offer==="connect"?"connect":"sign in"}):null,he=A.word===null&&ue===null&&ie===null?"this machine":d.jsxs(d.Fragment,{children:[A.word&&d.jsx("span",{className:"hint",children:A.word}),ue??ie]}),ge=[{key:"self",name:i??"This machine",host:o??void 0,reached:E===void 0?null:ae,icon:"laptop",right:he}],Ie=E?KB(E).map(Z=>{if(Z.kind==="phone"||Z.host==="")return Ax(Z,Z.reached?void 0:"not answering");const je=`https://${Z.host}`,He=PB(Z,t.get(je)!==null);return Ax(Z,He??d.jsx(ze,{variant:"outline",size:"sm",disabled:b,onClick:()=>void N(je),children:or.request}))}):[],ke=r&&o!==null&&E!==null&&(E===void 0||E.here),Q=E==null?void 0:E.devices.some(Z=>Z.kind==="machine"&&Z.host!==""&&Z.reached&&Z.toyon===null),we=ke&&E!==void 0&&!E.devices.some(Z=>Z.kind==="phone"),te=(()=>{switch(p.kind){case"asking":return or.asking(p.origin);case"waiting":return or.waiting(p.origin,p.word);case"added":return or.added(p.name);case"failed":return p.line;case"idle":return null}})();return d.jsxs(Kf,{boxClass:"devices-card",onClose:w,children:[d.jsx("div",{className:"devices-title",children:or.title}),d.jsx(Cx,{rows:ge}),A.note&&A.offer===null&&d.jsx("p",{className:"devices-note",children:A.note}),D&&d.jsx("p",{className:"devices-note",children:D}),r&&!de&&(l==null?void 0:l.state)==="ready"&&d.jsx("p",{className:"devices-note",children:or.turnOn}),ke&&o!==null&&d.jsx(WB,{host:o,noPhone:we}),p.kind==="waiting"&&d.jsx("div",{className:"knock-word devices-word",children:p.word}),te&&d.jsx("p",{className:Ue("devices-line",p.kind==="failed"&&"devices-failed"),children:te}),E!==void 0&&d.jsxs(d.Fragment,{children:[Ie.length>0&&d.jsx("div",{className:"devices-others",children:d.jsx(Cx,{rows:Ie})}),(E==null?void 0:E.devices.length)===0&&d.jsx("p",{className:"devices-note",children:or.noneOnTailnet}),Q&&d.jsx("p",{className:"devices-note",children:or.missing})]}),!b&&d.jsxs("form",{className:"devices-form",onSubmit:Z=>{Z.preventDefault(),T()},children:[d.jsx(Eo,{size:"md",font:"ui",value:u,placeholder:or.placeholder,"aria-label":"Address of the other machine",onChange:Z=>h(Z.target.value),className:"devices-field"}),d.jsx(ze,{type:"submit",variant:"outline",disabled:!u.trim(),children:or.add})]}),b&&d.jsx("div",{className:"devices-actions",children:d.jsx(ze,{tone:"quiet",onClick:R,children:"cancel"})}),B.length>0&&d.jsx("p",{className:"devices-line devices-centred",children:or.knocking}),$.map(Z=>d.jsx(HB,{knock:Z.knock,letIn:Z.letIn,onAnswer:je=>O(Z.knock,je)},Z.knock.id))]})}function qB({worktreeId:e,hits:t}){const n=lt(),r=ct(),o=P(c=>c.layout.changes),i=P(c=>{var h;const u=(h=kn(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(p=>`${p.path}:${p.line} ${p.text}`.toLowerCase().includes(h)):c},[]);return d.jsx(Or,{items:t,filter:l,keyOf:c=>`${c.path}:${c.line}`,rowClass:()=>"search-hit",rowTitle:c=>`${c.path}:${c.line}`,onPick:c=>{er({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?xs({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 GB({project:e}){const t=lt(),n=ct(),r=P(h=>h.paths),o=P(h=>h.home),i=S.useCallback(h=>{Uf(h)&&(n==null||n.send({t:"browse-path",path:h}))},[n]),l=S.useCallback((h,p)=>cF({query:p,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(Or,{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(On,{label:`put ${c??"it"} in ${Xm(h.path,o)}`,hint:d.jsx("bdi",{children:c?rN(h.path,c):h.path})}):h.kind==="up"?d.jsx(On,{label:`up to ${Xm(h.path,o)}`,hint:d.jsx("bdi",{children:h.path})}):d.jsx(On,{label:h.entry.name})})}function VB({worktreeId:e}){const t=lt(),n=ct(),r=P(m=>m.clientId),o=P(m=>kn(m,e)),i=P(m=>m.repos),c=It(e,"draft").trim(),u=S.useMemo(()=>i.filter(m=>m.id!==(o==null?void 0:o.worktree.repoId)),[i,o]),h=()=>t({a:"close"}),p=m=>{if(!o)return h();n==null||n.send({t:"handoff-ask",worktreeId:e,repoId:m.id,...c?{text:c}:{}}),c&&(n==null||n.send({t:"set-draft",boxId:e,text:"",clientId:r}),t({a:"set-draft",id:e,text:""})),h()};return d.jsx(Or,{lead:d.jsx("span",{className:"picker-chip",children:(o==null?void 0:o.worktree.title)??"worktree"}),items:u,filter:(m,g)=>m.filter(y=>ns(g,y.name,y.path)),keyOf:m=>m.id,row:m=>d.jsx(On,{label:m.name,hint:m.path}),onPick:p,onBack:()=>t({a:"close",back:!0}),placeholder:"continue in which project?",empty:"no other project is open",keys:{pick:"continues there",back:"closes"},footer:c?()=>d.jsxs("div",{className:"empty",children:["with your message: ",c.split(`
249
+ `)[0]]}):void 0})}const YB={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 XB(){const e=lt(),t=ct(),n=P(r=>r.keepAwake);return d.jsx(Or,{items:[...zj],filter:(r,o)=>r.filter(i=>ns(o,ef[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(On,{label:ef[r],current:r===n,hint:YB[r]})})}function QB(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=Em(t.rows,null);return n?`${n.n} ${n.tier==="waiting"?"waiting":"unread"}`:"all quiet"}function cg(e){try{return mC(new URL(e).hostname)}catch{return!1}}function JB(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 w of t)w()},c=new Map,u=w=>{var E;if(w.serving)return;(((E=w.store.getState().remote)==null?void 0:E.front)==="edge"||cg(w.origin))&&w!==o?w.sock.suspend():w.sock.resume()},h=w=>{var E;let b=(E=w.store.getState().remote)==null?void 0:E.front;c.set(w.origin,w.store.subscribe(()=>{var N;const _=(N=w.store.getState().remote)==null?void 0:N.front;_!==b&&(b=_,u(w))}))},p=()=>i,m={list:p,active:()=>o,serving:()=>n,get:w=>p().find(b=>b.origin===w)??null,displayName(w){const b=p().find(_=>_.origin===w);return b?p().filter(_=>_.name===b.name).length>1?`${b.name} (${new URL(b.origin).host})`:b.name:w},activate(w){const b=p().find(_=>_.origin===w);if(!b||b===o)return;const E=o;o=b,u(E),u(b),l()},add(w){var _;const b=r.find(N=>N.origin===w.origin);if(w.origin===n.origin)return n;if(b){if(b.token===w.token)return b;(_=c.get(b.origin))==null||_(),b.dispose(),r.splice(r.indexOf(b),1),o===b&&(o=n)}const E=e.build({...w,serving:!1});return r.push(E),h(E),cg(E.origin)&&E.sock.suspend(),l(),E},remove(w){var E;const b=r.find(_=>_.origin===w);b&&((E=c.get(w))==null||E(),c.delete(w),b.dispose(),b.storage.clear(),r.splice(r.indexOf(b),1),o===b&&(o=n),l())},broadcast(w){for(const b of p())b.store.dispatch(w)},subscribe(w){return t.add(w),()=>t.delete(w)}},g=w=>{for(const b of w)m.add(b);for(const b of[...r])w.some(E=>E.origin===b.origin)||m.remove(b.origin)};let y=n.store.getState().handed;return n.store.subscribe(()=>{const w=n.store.getState().handed;w!==y&&(y=w,g(y))}),g(y),m}function lw({form:e,anchored:t}){var ae;const n=lt(),r=ct(),o=Go(),i=so(),l=o.displayName(i.origin),c=P(A=>A.repos),u=P(A=>A.newProject?null:A.activeRepoId),h=P(A=>A.rows),p=P(A=>A.paths),m=P(A=>A.home),g=P(A=>A.pending),y=S.useMemo(()=>yv(c,h),[c,h]),w=RE(),b=$E(),E=S.useMemo(()=>w.map(A=>{var de;return{...A,repos:yv(A.repos,((de=b.find(ue=>ue.origin===A.origin))==null?void 0:de.rows)??[])}}),[w,b]),_=S.useCallback(A=>{Uf(A)&&(r==null||r.send({t:"browse-path",path:A}))},[r]),N=S.useCallback((A,de)=>lF({query:de,repos:y,pending:g,entries:[...p.entries].sort((ue,J)=>Number(J.isRepo)-Number(ue.isRepo)),target:p.target,answered:p.query,home:m,others:E}),[y,p,g,m,E]),T=A=>JN(h,A),R=()=>n({a:"close"}),O=()=>n({a:"close",back:!0}),B={sock:r,dispatch:n},$=A=>Ic(B,{t:"register-repo",path:A}),C=(A,de)=>Ic(B,{t:"create-repo",mode:"create",parent:A,name:de}),j=(A,de,ue)=>n({a:"new-project",v:Vg({mode:A,name:de,parent:aF(c,u,m),...ue?{url:ue}:{}})}),D=()=>n({a:"open",overlay:{kind:"projects",form:"disk"}}),z=()=>n({a:"open",overlay:{kind:"devices"}}),X=(A,de)=>{const ue=o.get(A);ue&&(ue.store.dispatch({a:"activate-repo",id:de}),o.activate(A))};return d.jsx(Or,{anchored:e==="pill"&&(t??!0),initialQuery:e==="disk"?"~/":"",lead:e==="disk"?void 0:d.jsx("span",{className:"picker-chip",children:((ae=c.find(A=>A.id===u))==null?void 0:ae.name)??"no project"}),trailing:e==="disk"?void 0:d.jsx(Pt,{icon:"folder",label:"Find a project on disk",onClick:D}),items:[],filter:N,initialIndex:A=>A.findIndex(de=>de.kind==="repo"&&!de.machine&&de.repo.id===u),groupOf:A=>A.kind==="machine"||A.kind==="repo"&&A.machine?A.machine.origin:i.origin,groupHead:A=>A===i.origin?l:d.jsx(eU,{origin:A}),keyOf:A=>A.kind==="repo"?A.machine?`${A.machine.origin}:${A.repo.id}`:A.repo.id:A.kind==="dir"?`d:${A.entry.path}`:A.kind==="open"?`open:${A.path}`:A.kind==="init"?`init:${A.path}`:A.kind==="pending"?`p:${A.pending.id}`:A.kind==="clone"?`clone:${A.url}`:A.kind==="new"?"new-project":A.kind==="disk"?"open-folder":A.kind==="add-machine"?"add-machine":A.kind==="machine"?`machine:${A.machine.origin}`:`new:${A.parent??""}/${A.name}`,rowClass:A=>Ue("picker-row",(A.kind==="new"||A.kind==="disk"||A.kind==="add-machine")&&"new-project-row"),onQuery:_,completionOf:A=>A.kind==="dir"?A.entry.isRepo?A.entry.path:`${A.entry.path}/`:null,narrowTo:A=>A.kind==="dir"&&!A.entry.isRepo?`${A.entry.path}/`:null,onPick:A=>{if(A.kind==="clone")return j("clone",A.name,A.url);if(A.kind==="create"&&!A.parent)return j("create",A.name);if(A.kind==="new")return j("create","");if(A.kind==="disk")return D();if(A.kind==="add-machine")return z();A.kind==="machine"?o.activate(A.machine.origin):A.kind==="pending"?n({a:"watch-import",id:A.pending.id}):A.kind==="repo"&&A.machine?X(A.machine.origin,A.repo.id):A.kind==="repo"?n({a:"activate-repo",id:A.repo.id}):A.kind==="open"?$(A.path):A.kind==="init"?sN(B,A.path):A.kind==="dir"?$(A.entry.path):A.parent&&C(A.parent,A.name),R()},onBack:O,rowMenu:A=>A.kind==="machine"||A.kind==="repo"&&A.machine?Ym(o,A.machine.origin):A.kind==="repo"?Hf(A.repo,u,B):A.kind==="pending"?uF(A.pending,B):[],placeholder:c.length>1?"switch project, or type a name or path":"type a name or a path to start",keys:A=>({complete:"completes the path",pick:(A==null?void 0:A.kind)==="dir"&&!A.entry.isRepo?"descends":(A==null?void 0:A.kind)==="pending"?"watches it":(A==null?void 0:A.kind)==="create"?A.parent?"creates it":"names it":(A==null?void 0:A.kind)==="clone"?"clones it":(A==null?void 0:A.kind)==="new"?"starts one":(A==null?void 0:A.kind)==="disk"?"browses":(A==null?void 0:A.kind)==="add-machine"?"adds one":(A==null?void 0:A.kind)==="machine"||(A==null?void 0:A.kind)==="repo"&&A.machine?"switches machine":"opens",back:"closes"}),empty:"nothing here; keep typing a path (~/… or /…)",row:A=>A.kind==="repo"&&A.machine?d.jsx(On,{label:A.repo.name,hint:d.jsx(tU,{origin:A.machine.origin,repo:A.repo})}):A.kind==="repo"?d.jsx(On,{label:A.repo.name,current:A.repo.id===u,hint:T(A.repo)}):A.kind==="pending"?d.jsx(On,{label:A.pending.name,hint:A.pending.error?"import failed":"importing…"}):A.kind==="dir"?d.jsx(On,{label:A.entry.name,hint:A.entry.isRepo?"git repo":void 0}):A.kind==="open"?d.jsx(On,{label:`open ${A.path}`,hint:"register with this daemon"}):A.kind==="init"?d.jsx(On,{label:`open ${A.path}`,hint:"no git yet; starts it here with the files in it"}):A.kind==="clone"?d.jsx(On,{label:`clone ${A.name}`,hint:nU(A.url)}):A.kind==="new"?d.jsx(On,{label:d.jsxs(d.Fragment,{children:[d.jsx(Nt,{name:"plus",className:"icon-inline"}),"new project"]})}):A.kind==="disk"?d.jsx(On,{label:d.jsxs(d.Fragment,{children:[d.jsx(Nt,{name:"folder",className:"icon-inline"}),"open folder"]})}):A.kind==="add-machine"?d.jsx(On,{label:d.jsxs(d.Fragment,{children:[d.jsx(Nt,{name:"devices",className:"icon-inline"}),"add a machine"]})}):A.kind==="machine"?d.jsx(On,{label:`switch to ${o.displayName(A.machine.origin)}`}):d.jsx(On,{label:`create ${A.name}`,hint:A.parent?`in ${A.parent}`:"new project"})})}function JN(e,t){const n=e.filter(u=>u.repoId===t.id),r=n.filter(xn).filter(u=>u.worktree.kind!=="spare"),o=r.filter(zc).length,i=r.length-1,l=n.length-n.filter(xn).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 eU({origin:e}){const t=Go(),n=t.get(e)??t.active(),r=Pa(n,m=>m.rows),o=Pa(n,m=>m.connected),i=Pa(n,m=>m.connectFailure),l=Pa(n,m=>m.incompatible),c=Pa(n,m=>{var g;return(g=m.remote)==null?void 0:g.front}),u=t.displayName(e),h=QB(u,{rows:r.filter(xn),connected:o,connectFailure:i,incompatible:l,suspended:(c==="edge"||cg(e))&&!o}),p=/^\d+ /.test(h);return d.jsxs(d.Fragment,{children:[u,d.jsx("span",{className:Ue("picker-group-tail",p&&"picker-group-owed"),children:h})]})}function tU({origin:e,repo:t}){const n=Go(),r=n.get(e),o=Pa(r??n.active(),i=>i.rows);return d.jsx(d.Fragment,{children:r?JN(o,t):null})}function nU(e){const t=e.match(/^[a-z+]+:\/\/(?:[^@/]*@)?([^/:]+)/i)??e.match(/^[^@]+@([^:]+):/);return(t==null?void 0:t[1])??"git remote"}function rU(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:()=>on(r)})}const n=[{id:"copy-ref",label:e.kind==="pr"?"copy PR number":"copy branch name",onClick:()=>on(e.ref)}];return zn([t,n])}const oU=[],sU={branch:"branch",remote:"globe",pr:"pr"},Ix={pr:0,branch:1,remote:2},iU={pr:"pull requests",branch:"branches",remote:"remote branches"};function aU({repoId:e}){const t=lt(),n=ct(),r=P(m=>m.clientId),o=P(m=>m.refs[e]),i=P(m=>m.rows),l=m=>{var g;return((g=i.find(y=>y.id===m))==null?void 0:g.name)??"a worktree"},c=S.useCallback(m=>[...m].sort((g,y)=>Ix[g.kind]-Ix[y.kind]),[]),u=S.useCallback(m=>n==null?void 0:n.send({t:"search-refs",repoId:e,query:m.trim()}),[n,e]),h=m=>!o||o.query!==m.trim(),p=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(Or,{items:(o==null?void 0:o.refs)??oU,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:rU,groupOf:m=>m.kind,groupHead:(m,g)=>`${iU[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)?"looking…":m.trim()?"no branch or PR matches":"no unmerged branches or open PRs",row:m=>d.jsx(On,{label:d.jsxs(d.Fragment,{children:[d.jsx(Nt,{name:sU[m.kind],className:"icon-inline"}),d.jsx("span",{className:"ref-name",children:m.name})]}),hint:p(m)})})}const Rx=[],rm=2;function lU({worktreeId:e}){const t=lt(),n=ct(),r=BE(e).search,o=P(h=>h.layout.changes),i=P(h=>{var m;const p=(m=kn(h,e))==null?void 0:m.worktree;return p?p.path:null}),l=S.useCallback((h,p)=>p.trim().length>=rm?h:Rx,[]),c=S.useCallback(h=>{const p=h.trim();p.length>=rm&&(n==null||n.send({t:"search",worktreeId:e,query:p}))},[n,e]),u=h=>!r||r.query.trim()!==h.trim();return d.jsx(Or,{items:(r==null?void 0:r.hits)??Rx,filter:l,onQuery:c,keyOf:h=>`${h.path}:${h.line}`,rowClass:()=>"search-hit",rowTitle:h=>`${h.path}:${h.line}`,onPick:h=>{er({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?xs({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<rm?"type at least two characters":u(h)?"searching…":"no matches",footer:(h,p)=>r!=null&&r.truncated&&!u(h)&&p.length>0?d.jsxs("div",{className:"empty",children:["showing the first ",p.length,"; 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})]})})}const $x=e=>e.source==="file"?"~/.toyon/themes":e.source==="vscode"?"VS Code":"";function cU({slot:e}){const t=lt(),n=ct(),r=P(N=>N.themePrefs),o=P(N=>N.themes),i=nk(),l=Og(r,i),c=r[e==="theme"?l:e],u=()=>t({a:"close"}),h=()=>t({a:"close",back:!0}),p=N=>t({a:"preview-theme",theme:N}),[m,g]=S.useState(null),[y,w]=S.useState(null),b=(N,T)=>N[T??l]??N.dark??N.light??null,E=S.useMemo(()=>oM(o),[o]),_=S.useMemo(()=>o.filter(N=>N.kind===e),[o,e]);return St([m,y],()=>{e==="theme"&&p(m?b(m,y):null)}),e!=="theme"?d.jsx(Or,{items:_,filter:(N,T)=>N.filter(R=>ns(T,R.name,R.id)),rowClass:()=>"picker-row",keyOf:N=>N.id,initialIndex:N=>N.findIndex(T=>T.id===c),onActive:p,onPick:N=>{n==null||n.send({t:"set-theme",prefs:{...r,[e]:N.id}}),u()},onBack:h,placeholder:`${e} slot override`,keys:{nav:"preview",pick:"keeps",back:"reverts"},empty:"no matching theme",row:N=>d.jsx(On,{label:N.name,current:N.id===c,hint:$x(N)})}):d.jsx(Or,{items:E,filter:(N,T)=>N.filter(R=>{var O,B;return ns(T,R.name,(O=R.dark)==null?void 0:O.name,(B=R.light)==null?void 0:B.name)}),rowClass:()=>"picker-row",keyOf:N=>{var T,R;return N.name+(((T=N.dark)==null?void 0:T.id)??((R=N.light)==null?void 0:R.id))},initialIndex:N=>N.findIndex(T=>{var R,O;return((R=T.dark)==null?void 0:R.id)===c||((O=T.light)==null?void 0:O.id)===c}),onActive:g,onSide:N=>{var T;N.dark&&N.light&&w((((T=b(N,y))==null?void 0:T.kind)??l)==="dark"?"light":"dark")},onPick:N=>{n==null||n.send({t:"set-theme",prefs:sM(r,N)}),u()},onBack:h,placeholder:"theme",keys:{nav:"preview",side:"dark/light",pick:"keeps",back:"reverts"},empty:"no matching theme",row:(N,T)=>{var $,C;const R=b(N,T?y:null),O=$x(N.dark??N.light),B=(($=N.dark)==null?void 0:$.id)===c||((C=N.light)==null?void 0:C.id)===c;return d.jsx(On,{label:N.name,current:B,hint:d.jsxs("span",{className:"theme-kinds",children:[O&&d.jsx("span",{children:O}),d.jsx("span",{className:"kind","data-state":gr({current:T&&(R==null?void 0:R.kind)==="dark"}),children:N.dark?"dark":""}),d.jsx("span",{className:"kind","data-state":gr({current:T&&(R==null?void 0:R.kind)==="light"}),children:N.light?"light":""})]})})}})}function eT(){const e=fP(),t=P(i=>i.frame==="phone"),n=dl(),r=P(i=>i.activeRepoId),o=P(i=>i.newProject);return d.jsxs(d.Fragment,{children:[(e==null?void 0:e.kind)==="quick-open"&&n&&d.jsx(Y8,{worktreeId:n}),(e==null?void 0:e.kind)==="search"&&n&&d.jsx(lU,{worktreeId:n}),(e==null?void 0:e.kind)==="element-sources"&&d.jsx(qB,{worktreeId:e.worktreeId,hits:e.hits}),(e==null?void 0:e.kind)==="refs"&&r&&d.jsx(aU,{repoId:r}),(e==null?void 0:e.kind)==="chats"&&r&&d.jsx(TB,{repoId:r,scope:e.names?"names":"all"}),(e==null?void 0:e.kind)==="keys"&&d.jsx(fB,{}),(e==null?void 0:e.kind)==="devices"&&d.jsx(ZB,{}),(e==null?void 0:e.kind)==="theme"&&d.jsx(cU,{slot:e.slot}),(e==null?void 0:e.kind)==="appearance"&&d.jsx(bB,{}),(e==null?void 0:e.kind)==="keep-awake"&&d.jsx(XB,{}),(e==null?void 0:e.kind)==="agent"&&d.jsx(wB,{}),(e==null?void 0:e.kind)==="agent-page"&&d.jsx(gB,{agentId:e.agent}),(e==null?void 0:e.kind)==="handoff"&&d.jsx(VB,{worktreeId:e.worktreeId}),(e==null?void 0:e.kind)==="commands"&&!t&&d.jsx(LN,{}),(e==null?void 0:e.kind)==="projects"&&e.form!=="pill"&&d.jsx(lw,{form:e.form},e.form),(e==null?void 0:e.kind)==="choose-folder"&&o&&d.jsx(GB,{project:o})]})}const kc="Lost the daemon; retrying",uU="Not run by Toyon",tT="new worktree",dU=(e,t)=>`in ${e}, started from ${t}`,fU=new Set(["waiting","working","starting","failed","crashed"]);function ug(e,t){if(t.offline)return kc;if(!xn(e))return e.locked?`Held by ${e.lockReason??"another tool"}`:t.path;if(t.op)return Hg(t.op);if($r(e.worktree))return tT;const n=Ug(e,t.needsSetup),r=e.worktree.lastTurn;return!fU.has(ai(e))&&r?Sk(r):t.at&&t.at!=="now"?`${n} · ${t.at}`:n}function hU(e,t){if(!xn(e)||t)return!1;const n=ai(e);return(n==="idle"||n==="asleep")&&!e.unseen}function pU(e){const t=e.worktree.lastTurn,n=e.worktree.landed?xk(e.worktree.lands):[],r=t?(zc(e)?vD:Sk)(t):void 0,o=e.worktree.pr&&!e.worktree.landed?vs(e.worktree.pr):void 0;return[...n,r,o].filter(i=>!!i)}function mU(e,t,n,r){let o;const i=(p,m)=>{const g=m==null?void 0:m[m.length-1];g&&(!o||g.at>o.mark.at)&&(o={title:p,mark:g})};for(const p of e)p.worktree&&i(p.worktree.title,p.worktree.lands);for(const p of t)i(p.title,p.lands);const l=o&&bk(o.mark),c=o?`Landed ${o.title} ${Bo(to(o.mark.at))}${l?`: ${Hr(l)}`:"."}`:void 0,u=n?A_(r,n):null,h=u?Hr(`${u.charAt(0).toUpperCase()}${u.slice(1)}`):n!=null&&n.fetchedAt?`Level with origin, fetched ${Bo(to(n.fetchedAt))}.`:void 0;return[c,h].filter(p=>!!p)}function gU(e){const t=e.prompt?vk(e.prompt):"";return[...t?[t]:[],...xk(e.lands)]}function kU(e){const n=[e.auto&&wU(e.auto,!!e.landed),e.cost!==void 0?Kc(e.cost):void 0].filter(r=>!!r);return n.length?n:void 0}function wU(e,t){const{what:n,idle:r}=Wj(e);return r?`${t?"":`${n}, `}${r} idle`:n}const Ox=25;function yU(e,t){if(e.length<=Ox+1)return{shown:e,rest:0};const n=e.slice(0,Ox),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}}const vU=.5;function bU(e){const t=e.usage,n=t&&t.size>0?t.used/t.size:0,r=[n>=vU?`${Math.round(100*n)}% of context`:void 0,e.queued?`${e.queued} queued`:void 0,(t==null?void 0:t.cost)!==void 0?Kc(t.cost):void 0].filter(o=>!!o);return r.length?r:void 0}function xU(e){const t=o=>e.filter(ss).find(i=>i.id===o)??null,n=t("archive"),r=t("land");return[{id:"archive",label:(n==null?void 0:n.label)??"archive",icon:"archive",item:n},{id:"land",label:(r==null?void 0:r.label)??"land",icon:"land",item:r},{id:"more",label:"more",icon:"more",item:null}]}const gd=e=>e>999?"1k+":String(e);function nT({width:e,placement:t="strip"}){const n=t==="screen",r=pi(),o=P(G=>G.chatSide)==="left"?"right":"left",i=lt(),l=ct(),{host:c}=Wr(),u=ik(),h=u[0]&&$r(u[0].worktree)?u[0]:null,p=h?u.slice(1):u,m=P(G=>ol(G,G.activeRepoId)),g=G=>h&&G.id===h.id&&m?{behind:m.behind,dirty:m.dirty}:G,[,y]=S.useState(0);S.useEffect(()=>{const G=setInterval(()=>y(ve=>ve+1),6e4);return()=>clearInterval(G)},[]);const w=sP(),b=iP(),E=aP(),_=lP(),N=(G,ve,tt)=>{G.key!=="ArrowLeft"&&G.key!=="ArrowRight"||G.shiftKey||G.altKey||G.metaKey||G.ctrlKey||(G.preventDefault(),Df([{depth:0,open:ve}],0,G.key)&&i({a:tt}))},T=Xi(),R=P(G=>G.clientId),O=P(G=>G.frame),B=P(G=>G.activeRepoId),$=P(G=>G.connected);S.useEffect(()=>{l&&$&&B&&l.send({t:"list-archived",repoId:B})},[l,$,B]);const C=dl(),j=zE(),D=P(G=>G.layout),z=P(G=>G.railOpen),X=P(G=>G.railPeek),ae=S.useRef(null),[A,de]=S.useState(!1);St([X],()=>{var G;X&&!n&&!r&&!((G=ae.current)!=null&&G.matches(":hover"))&&de(!0)}),S.useEffect(()=>{if(!A)return;let G=null;const ve=tt=>{if(!G){G={x:tt.clientX,y:tt.clientY};return}Math.abs(tt.clientX-G.x)+Math.abs(tt.clientY-G.y)<3||de(!1)};return window.addEventListener("pointermove",ve),()=>window.removeEventListener("pointermove",ve)},[A]);const ue=P(G=>G.focusRail),J=S.useRef(ue),M=S.useRef(null);St([ue],()=>{if(ue===J.current)return;J.current=ue;const G=requestAnimationFrame(()=>{var ve,tt;return(tt=(ve=M.current)==null?void 0:ve.querySelector('[data-state~="current"]'))==null?void 0:tt.focus()});return()=>cancelAnimationFrame(G)});const oe=P(G=>G.repos),ne=P(G=>G.shipping),H=P(G=>G.rows),se=G=>oe.find(ve=>ve.id===G.repoId)??null,ie=G=>B?Jg(G,B,H):null,he=wn("rail"),ge=ck(),Ie=P(G=>G.home),ke=G=>{const ve=G.worktree?G.worktree.path:G.path;return Ie&&ve.startsWith(`${Ie}/`)?`~${ve.slice(Ie.length)}`:ve},[Q,we]=S.useState(!1),[te,Z]=S.useState([]),je=G=>{!vd(G.worktree)||ie(G)||(we(!0),Z(ve=>ve.includes(G.worktree.id)?ve.filter(tt=>tt!==G.worktree.id):[...ve,G.worktree.id]))},He=()=>{we(!1),Z([])};St([Q],()=>{const G=ve=>ve.key==="Escape"&&He();return Q&&window.addEventListener("keydown",G),()=>window.removeEventListener("keydown",G)});const Fe=yk(l,i),Pe={sock:l,dispatch:i},We=G=>{we(!0),Z(ve=>G===C||ve.includes(G)?ve:[...ve,G])},Ht=G=>xn(G)?T_(G,se(G),{layout:D,shipping:ne,frame:O,repos:oe},Pe,{...ie(G)?{}:{graft:We},hostname:c}):uD(G,{clientId:R,frame:O},Pe,c),[ut,vn]=S.useState(null),Jt=G=>xn(G)?xU(Ht(G)):[];HN(M,{rowOf:G=>{if(!n||Q)return null;const ve=G.closest(".slide"),tt=ve==null?void 0:ve.dataset.row,it=tt?u.find(ft=>ft.id===tt):void 0;return ve&&tt&&it?{el:ve,key:tt,rungs:Jt(it).length}:null},onSlide:vn,onPick:(G,ve)=>{var ft;const tt=u.find(Gt=>Gt.id===G),it=tt?Jt(tt)[ve-1]:void 0;if(!(!tt||!it)){if(it.id==="more"){const Gt=(ft=M.current)==null?void 0:ft.querySelector(`.slide[data-row="${G}"]`);Gt&&he.openUnder(Gt,()=>Ht(tt),G)}else if(it.item&&!it.item.disabled){const Gt=it.item.onClick;window.setTimeout(Gt,UN)}}}});const xt=yU(E,(T==null?void 0:T.id)??null),kt=xt.shown.some(G=>(G.dirty??0)>0),ot=G=>d.jsxs("button",{type:"button",className:Ue("row row-edge row-quiet rail-disc-item rail-arch-item",(ge==null?void 0:ge.owner)==="rail"&&ge.key===G.id&&"menu-open"),"data-state":gr({current:!n&&(T==null?void 0:T.id)===G.id}),...Ut(YD(G),void 0,{placement:o,card:!0,detail:gU(G),aside:kU(G)}),onClick:()=>i({a:"open-archived",id:G.id}),...he.contextMenu(()=>jd(G,{clientId:R,frame:O},Pe),G.id),children:[d.jsxs("span",{className:"rail-gut",onClick:r?ve=>{ve.stopPropagation(),he.openUnder(ve.currentTarget,()=>jd(G,{clientId:R,frame:O},Pe),G.id)}:void 0,children:[d.jsx("span",{className:"rail-at row-dim",children:to(G.archivedAt)}),d.jsx("span",{className:"rail-more",...Ut("Actions"),onClick:ve=>{ve.stopPropagation(),he.openUnder(ve.currentTarget,()=>jd(G,{clientId:R,frame:O},Pe),G.id)},children:d.jsx(Nt,{name:"more"})})]}),d.jsx("span",{className:"branch",children:G.title}),kt&&d.jsx("span",{className:"rail-counts",children:d.jsx("span",{className:"rail-count row-dim","data-tip":G.dirty?`${G.dirty} uncommitted, kept`:void 0,children:G.dirty?`~${gd(G.dirty)}`:""})}),G.auto?d.jsx("span",{className:"rail-glyph rail-auto row-dim",children:d.jsx(Nt,{name:"clock",className:"icon-inline"})}):d.jsx("span",{className:"dot"}),n&&d.jsx("span",{className:"rail-at rail-at-end row-dim",children:to(G.archivedAt)})]},G.id),dt=[...u,...w].map(g),Tt=["ahead","dirty","behind"].filter(G=>dt.some(ve=>(ve[G]??0)>0)),Et=G=>{const ve=Tt.findIndex(tt=>(G[tt]??0)>0);return new Set(ve<0?[]:Tt.slice(ve))},dn=G=>{var Xe;const ve=xn(G)?G:null,tt=!!ve&&$r(ve.worktree),it=g(G),ft=oe.find(qe=>qe.id===G.repoId)??null,Gt=ft?ff(ft):"main",Ft=ft&&CC(ft)&&(m!=null&&m.fetchedAt)?` as of ${C_(m.fetchedAt)}`:"",An=Et(it),qn=!!it.ahead&&!it.dirty,zt=G.id,bn=(ge==null?void 0:ge.owner)==="rail"&&ge.key===zt,ye=ve?ie(ve):null,Me=ye&&ve?se(ve):null,Bt=ve&&!ye&&Q&&vd(ve.worktree)&&zt!==C,jt=cE(G,(Xe=ne[zt])==null?void 0:Xe.op),fn=d.jsxs("button",{type:"button",className:Ue("row row-edge",ve?"rail-item":"row-quiet rail-disc-item",n&&hU(G,jt)&&"row-quiet",bn&&"menu-open"),"data-state":gr({current:!n&&zt===C&&!T,checked:te.includes(zt)}),...ve?Ut(j?kc:jt?Hg(jt):Ug(G,Hd(se(ve))),void 0,{placement:o,card:!0,aside:bU(G),detail:$r(ve.worktree)?mU(u,E,m,Gt):[...ye&&Me?[dU(Me.name,ye.worktree.title)]:[],...pU(ve)],dot:j?void 0:jt?"spinner":ai(G)}):Ut(j?kc:G.locked?`Held by ${G.lockReason??"another tool"}`:uU,void 0,{placement:o,card:!0,detail:ke(G),dot:j||G.locked?void 0:"discovered"}),"data-wt":zt,onKeyDown:qe=>{var Ge,Wt;if(!ve||Q||qe.key!=="ArrowUp"&&qe.key!=="ArrowDown"||qe.altKey||qe.ctrlKey||qe.metaKey)return;qe.preventDefault();const _t=qe.key==="ArrowDown",Le=u.findIndex(Mt=>Mt.id===zt),$e=u[Le+(_t?1:-1)];$e&&(i({a:"activate",id:$e.id}),(Wt=(Ge=M.current)==null?void 0:Ge.querySelector(`[data-wt="${$e.id}"]`))==null||Wt.focus())},onClick:qe=>{ve&&!ye&&(Q||qe.shiftKey)?zt===C?we(!0):je(ve):tt&&!n?i({a:"open-draft"}):(i({a:"activate",id:zt}),ve&&!r&&i({a:"walked"}))},...he.contextMenu(()=>Ht(G),zt),children:[d.jsx("span",{className:"rail-gut",onClick:r&&!Q?qe=>{qe.stopPropagation(),he.openUnder(qe.currentTarget,()=>Ht(G),zt)}:void 0,children:Bt?d.jsx("input",{type:"checkbox",className:"rail-graft-check",checked:te.includes(zt),readOnly:!0,tabIndex:-1}):!Q&&d.jsxs(d.Fragment,{children:[ve&&!tt&&d.jsx("span",{className:"rail-at row-dim",children:to(Ja(ve.worktree))}),d.jsx("span",{className:"rail-more",...Ut("Actions"),onClick:qe=>{qe.stopPropagation(),he.openUnder(qe.currentTarget,()=>Ht(G),zt)},children:d.jsx(Nt,{name:"more"})})]})}),tt?d.jsxs("span",{className:"branch rail-main-label",children:[d.jsx(Nt,{name:"plus",className:"icon-inline"}),"new worktree"]}):d.jsx("span",{className:Ue("branch",(ve==null?void 0:ve.worktree.unnamed)&&"row-dim"),children:_m(G,ve?se(ve):null)}),(ve==null?void 0:ve.worktree.mode)&&ve.worktree.mode!=="auto"&&d.jsx("span",{className:"rail-badge badge-mode","data-tip":`${ve.worktree.mode} mode: the agent waits for you`,children:ve.worktree.mode}),ve&&(()=>{const qe=se(ve),_t=__(ve.worktree,qe);return _t&&_t!==(qe==null?void 0:qe.config.defaultProfile)?d.jsx("span",{className:"rail-badge badge-profile","data-tip":`runs the ${_t} profile`,children:_t}):null})(),(ve==null?void 0:ve.worktree.variant)&&d.jsxs("span",{className:"rail-badge badge-variant clickable","data-tip":"Keep this variant, archive the others",onClick:qe=>{qe.stopPropagation(),Fe.pickVariant(ve)},children:[d.jsxs("span",{className:"num",children:["v",ve.worktree.variant.index,"/",ve.worktree.variant.of]}),d.jsx("span",{className:"act",children:"pick"})]}),Me&&d.jsx("span",{className:"rail-guest row-dim",children:Me.name}),d.jsxs("span",{className:"rail-counts",children:[An.has("ahead")&&d.jsx("span",{className:"rail-count badge-ahead","data-tip":it.ahead?`${it.ahead} ahead of ${Gt}`:void 0,children:it.ahead?`+${gd(it.ahead)}`:""}),An.has("dirty")&&!qn&&d.jsx("span",{className:"rail-count badge-dirty","data-tip":it.dirty?`${it.dirty} uncommitted${tt?" on main":""}`:void 0,children:it.dirty?`~${gd(it.dirty)}`:""}),An.has("behind")&&d.jsx("span",{className:"rail-count rail-behind row-dim","data-tip":it.behind?`${it.behind} behind ${tt?"origin":Gt}${tt?"":Ft}`:void 0,children:it.behind?gd(it.behind):""}),n&&ve&&d.jsx("span",{className:"rail-at row-dim",children:tt?"":to(Ja(ve.worktree))})]}),(()=>{if(jt)return d.jsx(al,{size:"dot"});if(G.locked)return d.jsx("span",{className:"rail-glyph rail-lock row-dim",children:d.jsx(Nt,{name:"lock",className:"icon-inline"})});if(!ve)return d.jsx("span",{className:"dot discovered"});const qe=Q||j?null:uE(G.procs),_t=G.unseen?" unseen":"",Le=ai(G);return tt&&!qe&&Le!=="crashed"&&!j?d.jsxs(d.Fragment,{children:[d.jsx("span",{className:`dot ${Le} rail-main-dot`}),d.jsx("span",{className:"rail-glyph rail-main-strip",children:d.jsx(Nt,{name:"plus"})})]}):!qe||Le!=="crashed"?d.jsx("span",{className:`dot ${Le}${_t}`}):d.jsx("span",{className:`dot crashed clickable${_t}`,...Ut(qe.tip),onClick:$e=>{$e.stopPropagation(),i({a:"activate",id:zt}),i({a:"term-stream",id:zt,stream:qe.stream})}})})(),n&&d.jsx("span",{className:"rail-say row-dim",children:ug(G,{offline:j,needsSetup:Hd(ve?se(ve):null),path:ke(G),op:jt})})]},zt);if(!n||!ve)return fn;const K=(ut==null?void 0:ut.key)===zt?ut.step:null,pe=K===null?null:Jt(G)[Math.max(0,K-1)],_e=!!pe&&K!==null&&K>0&&(pe.id==="more"||!!pe.item&&!pe.item.disabled);return d.jsxs("div",{className:"slide","data-row":zt,children:[fn,pe&&d.jsxs("span",{className:"slide-verb","data-rung":_e?pe.id:void 0,"aria-hidden":"true",children:[d.jsx("span",{className:"slide-word",children:pe.label}),d.jsx(Nt,{name:pe.icon})]})]},zt)};return d.jsx("div",{ref:ae,className:Ue("rail",n&&"rail-screen",!n&&(Q||(ge==null?void 0:ge.owner)==="rail"||X)&&"hold",A&&"quiet",(n||z)&&"pinned",j&&"offline"),style:e!==void 0&&!n?{"--rail-width":`${e}px`}:void 0,onClick:r&&!n&&!z?G=>{G.target instanceof Element&&G.target.closest("button, .rail-gut")||i({a:"toggle-rail"})}:void 0,children:d.jsxs("div",{className:"rail-panel","data-tip":j?kc:void 0,"data-tip-placement":"follow",children:[d.jsxs("div",{className:"rail-list",ref:M,children:[h&&!n&&dn(h),p.map(dn),Q&&d.jsxs("div",{className:"rail-graft",children:[(()=>{const G=u.find(it=>it.worktree.id===C&&vd(it.worktree)&&!ie(it)),ve=te.filter(it=>it!==(G==null?void 0:G.worktree.id)),tt=ve.map(it=>{var ft;return((ft=u.find(Gt=>Gt.worktree.id===it))==null?void 0:ft.worktree.title)??it}).join(", ");return d.jsxs(ze,{size:"md",tone:"primary",disabled:!G||ve.length===0,"data-tip":G?`Merge the checked worktrees into ${G.worktree.title} and remove them`:"Select a worktree to graft onto",onClick:()=>{G&&window.confirm(`Graft ${tt} onto ${G.worktree.title}?
250
+
251
+ Their branches are merged in, then their directories and branches are removed.`)&&(l==null||l.send({t:"graft",targetId:G.worktree.id,sourceIds:ve}),He())},children:["graft ",ve.length]})})(),d.jsxs(ze,{size:"md",disabled:!te.some(G=>{var ve;return(((ve=u.find(tt=>tt.worktree.id===G))==null?void 0:ve.behind)??0)>0}),"data-tip":"Pull main into every selected worktree that's behind",onClick:()=>{for(const G of te){const ve=u.find(tt=>tt.worktree.id===G);((ve==null?void 0:ve.behind)??0)>0&&oi(l,i,{t:"sync-main",worktreeId:G})}He()},children:[d.jsx(Nt,{name:"pull",className:"icon-inline"})," sync"]}),d.jsx(ze,{size:"md",tone:"danger",disabled:te.length===0,"data-tip":"Archive all selected worktrees; their chats and work are kept",onClick:()=>{window.confirm(`Archive ${te.length} worktree(s)?
252
+
253
+ Their directories and branches go. The chats, commits and any uncommitted changes are kept, and each can be restored.`)&&(Hi(l,i,te),He())},children:"archive…"}),d.jsx(Pt,{icon:"close",label:"Cancel",hint:"esc",onClick:He})]}),!Q&&w.length>0&&d.jsxs(d.Fragment,{children:[d.jsxs("button",{className:"section-title section-row section-fold rail-disc-head","aria-expanded":b,...Ut(`${w.length} worktree${w.length===1?"":"s"} here that Toyon did not make`,void 0,{placement:o}),onClick:()=>i({a:"toggle-discovered"}),onKeyDown:G=>N(G,b,"toggle-discovered"),children:[d.jsx("span",{className:"rail-gut",children:d.jsx(Nt,{name:"caret",className:Ue("icon-inline disc-caret",!b&&"shut")})}),d.jsx("span",{className:"rail-label",children:"discovered"})]}),b&&w.map(dn)]}),!Q&&E.length>0&&d.jsxs(d.Fragment,{children:[d.jsxs("button",{type:"button",className:"section-title section-row section-fold rail-disc-head","aria-expanded":_,...Ut(`${E.length} archived worktree${E.length===1?"":"s"}, kept with ${E.length===1?"its chat":"their chats"}`,void 0,{placement:o}),onClick:()=>i({a:"toggle-archived"}),onKeyDown:G=>N(G,_,"toggle-archived"),children:[d.jsx("span",{className:"rail-gut",children:d.jsx(Nt,{name:"caret",className:Ue("icon-inline disc-caret",!_&&"shut")})}),d.jsx("span",{className:"rail-label",children:"archived"})]}),_&&xt.shown.map(ot),_&&xt.rest>0&&B&&d.jsxs("button",{type:"button",className:"row row-quiet rail-disc-item rail-arch-item",...Ut("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:[xt.rest," more"]}),d.jsx("span",{className:"dot"})]})]})]}),!n&&d.jsx("div",{className:"rail-foot",children:d.jsx(Pt,{icon:"worktrees",label:"Worktree panel",hint:Lt("rail"),tone:"chrome",on:z,onClick:()=>i({a:"toggle-rail"})})})]})})}function EU({screen:e,tabs:t,fold:n}){const r=lt(),o=Go(),i=so(),l=P(J=>J.reading),c=dP(),u=fl(),h=P(J=>J.repos),p=Ss(),m=dl(),g=Xi(),y=ak(),w=ik(),b=zE(),E=$E(),_=MM(w,m,E),N=w.find(J=>$r(J.worktree)),T=e==="home",R=!T&&!g&&!!p&&$r(p.worktree),O=P(J=>{var M;return R&&p?cE(p,(M=J.shipping[p.id])==null?void 0:M.op):null}),B=tk().length,$=o.displayName(i.origin),C=T?(c==null?void 0:c.name)??$:R?tT:(g==null?void 0:g.title)??(p==null?void 0:p.worktree.title)??(y==null?void 0:y.name)??null,j=w.filter(J=>!$r(J.worktree)).length,D=j===0?"no worktrees yet":`${j} ${j===1?"worktree":"worktrees"}`,z=T?c&&B>1?`${$} · ${D}`:D:g?W_(g):R?b?kc:O?Hg(O):(c==null?void 0:c.name)??null:p?ug(p,{offline:b,needsSetup:Hd(u),path:p.worktree.path,at:to(Ja(p.worktree))}):y?ug(y,{offline:b,needsSetup:!1,path:y.path}):null,X=!T&&!g&&!!p&&ai(p)==="waiting",ae=P(J=>{var M;return((M=J.overlay)==null?void 0:M.kind)==="projects"&&J.overlay.form==="pill"}),A=P(J=>{var M;return((M=J.overlay)==null?void 0:M.kind)==="commands"}),de=d.jsxs("div",{className:"phone-title",children:[T&&(h.length>1||B>1)?d.jsxs("span",{className:"phone-drop phone-switch",children:[d.jsxs(ze,{tone:"chrome",on:ae,onClick:()=>r({a:"toggle",overlay:{kind:"projects",form:"pill"}}),children:[d.jsx("span",{className:"phone-name",children:C}),d.jsx(Nt,{name:"caret",className:"icon-inline"})]}),ae&&d.jsx(lw,{form:"pill",anchored:{margin:6}})]}):d.jsx("span",{className:"phone-name",children:C}),z&&d.jsx("span",{className:Ue("phone-sub",X&&"phone-sub-asks"),children:z})]}),ue=_&&d.jsxs(ze,{size:"md",tone:"primary",onClick:()=>{const J=LM(w,m,E);if(!J)return;if(J.origin===null)return r({a:"activate",id:J.activate});const M=o.get(J.origin);M&&(M.store.dispatch({a:"activate",id:J.activate}),o.activate(J.origin))},children:[_.n," ",_.tier]});return d.jsxs("div",{className:"phone-bar",children:[d.jsxs("div",{className:"phone-bar-row",children:[!T&&d.jsx(Pt,{icon:"back",label:"Worktrees",tone:"chrome",onClick:()=>r({a:"screen",to:"home"})}),t?d.jsx("div",{className:"phone-tabs",children:t}):de,!t&&ue,T&&N&&d.jsx(Pt,{icon:"plus",label:"New worktree",tone:"chrome",onClick:()=>r({a:"activate",id:N.id})}),d.jsxs("span",{className:"phone-drop",children:[d.jsx(Pt,{icon:"more",label:"Menu",tone:"chrome",on:A,onClick:()=>r({a:"toggle",overlay:{kind:"commands"}})}),A&&d.jsx(LN,{anchored:{flip:"align",margin:6},trailing:d.jsx(Pt,{icon:"close",label:"Close",tone:"chrome",onClick:()=>r({a:"close"})})})]})]}),t&&!n&&d.jsx("div",{className:"phone-title-seat","data-away":l||void 0,children:d.jsxs("div",{className:"phone-title-strip",children:[de,ue]})})]})}const Id="toyonDepth",rT="toyonOver",om=-1;function sm(e){if(e.frame!=="phone"||!e.heard)return null;if(!(e.screen!=="home"&&(So(e,e.activeId)!==null||No(e)!==null)))return 0;const n=kn(e,e.activeId)!==null&&!xo(e)&&No(e)===null;return 1+(e.screen==="changes"||e.screen==="preview"&&n?1:0)+(e.editor?1:0)}const oT=(()=>{const e=new Set;return{watch(t){return e.add(t),()=>e.delete(t)},tell(t){for(const n of e)n(t)}}})(),im=e=>{const t=e&&typeof e=="object"?e[Id]:void 0;return typeof t=="number"?t:null},_U=e=>!!e&&typeof e=="object"&&e[rT]===!0;function sT(e,t=window,n=Kd,r=oT){const o=t.history;let i=im(o.state)??om,l=im(o.state)!==null,c=null;const u=()=>{const T=n.open();c&&!T.includes(c)&&(c=null);for(let R=T.length-1;R>=0;R--){const O=T[R];if(O!=null&&O.dismiss&&O!==c)return O}return null};let h=!1;const p=()=>{const T=sm(e.getState());if(T===null||h)return;l||(o.replaceState({[Id]:om},""),l=!0);const R=T+(u()?1:0);if(R!==i)if(R>i){for(let O=i+1;O<=R;O++)o.pushState({[Id]:O,[rT]:O>T},"");i=R}else o.go(-1),h=!0};let m=!1;const g=()=>{m||(m=!0,queueMicrotask(()=>{m=!1,p()}))},y=(T,R,O)=>{const B=u();if(B){c=B,n.shut(B);return}const $=O===0?"home":T.editor&&O===R-1?T.screen:"chat";e.dispatch({a:"screen",to:$})},w=T=>{const R=h;h=!1,i=im(T.state)??om;const O=e.getState(),B=sm(O);if(B===null)return;if(i<0){o.pushState({[Id]:0},""),i=0,p();return}if(R){p();return}const $=B+(u()?1:0);$!==i&&($>i?y(O,B,i):$===0&&O.activeId&&!_U(T.state)&&e.dispatch({a:"screen",to:"chat"}),p())},b=T=>{if(h){h=!1,p();return}const R=e.getState(),O=sm(R);O===null||O===0||R.screen==="preview"&&!R.editor&&O===2||T.dir==="forward"||y(R,O,O+(u()?1:0)-1)};t.addEventListener("popstate",w);const E=e.subscribe(p),_=n.watch(g),N=r.watch(b);return p(),()=>{t.removeEventListener("popstate",w),E(),_(),N()}}function SU({gated:e,active:t,url:n,hidden:r}){const o=Qg(t),i=C4(so(),o?n:null,e),l=S.useRef(null);return S.useEffect(()=>{if(!i)return;const c=new URL(i,location.href).origin,u=h=>{var m,g;if(h.source!==((m=l.current)==null?void 0:m.contentWindow)||h.origin!==c||!((g=h.data)!=null&&g.__toyon))return;const p=W1(h.data);(p==null?void 0:p.type)==="traversed"&&oT.tell({dir:p.dir??null})};return window.addEventListener("message",u),()=>window.removeEventListener("message",u)},[i]),d.jsx("div",{className:"phone-preview",hidden:r,children:o&&i?d.jsx("iframe",{ref:l,className:"phone-preview-frame",src:i,title:t.worktree.title}):d.jsx(Ts,{wide:!0,children:d.jsx("p",{className:"status-line",children:Ug(t)})})})}const NU=Mg();function TU(){const e=S.useRef(null);tP(e),nP(e);const t=lt(),n=P($=>$.screen),r=Ss(),o=Xi(),i=ak(),l=P($=>$.editor),c=P($=>$.remote),u=Uc(),h=P($=>$.connected),p=P($=>$.heard),m=P($=>$.connectFailure),g=pi(),y=so(),w=Go(),b=P($=>$.incompatible),E=x_({connected:h,heard:p,connectFailure:m,hasToken:y.serving?NU:!0,projectChord:Lt("project"),title:(r==null?void 0:r.worktree.title)??null,machine:y.serving?null:w.displayName(y.origin)}),_=n!=="home"&&(r!==null||o!==null||i!==null),N=_&&!u&&!o?r:null,{host:T}=Wr(),R=N?Sd(N.worktree.id,N.worktree.proxyPort,c,T):null,O=n==="preview"&&!N?"chat":n,B=[{id:"chat",label:"chat"},...N&&R?[{id:"preview",label:"preview",trail:d.jsx(Pt,{icon:"external",label:"Open in browser",tone:"chrome",onClick:()=>A4(y,R,Mm(y,c))})}]:[],{id:"changes",label:"code"}];return d.jsxs("div",{ref:e,className:"app phone","data-chat-side":"left","data-touch":g||void 0,"data-hover":!g||void 0,children:[d.jsx(m_,{}),d.jsx(y_,{}),d.jsx(EU,{screen:_?"chat":"home",fold:O!=="chat"||l!==null,tabs:_&&E===null&&d.jsx(Pf,{fill:!0,segmented:!0,owner:"phone-tabs",label:"worktree",items:B,current:O,onPick:$=>t({a:"screen",to:$})})}),d.jsx("div",{className:"phone-screen",children:d.jsxs("div",{className:"center-root",children:[b&&!y.serving?d.jsx(b_,{foreign:w.displayName(y.origin)}):E!==null?d.jsx(Ts,{wide:!0,children:d.jsx("p",{className:"status-line",children:E})}):_?l?d.jsx(qN,{editor:l,placement:"screen"}):O==="chat"?d.jsx(gc,{placement:"screen",archived:o,found:i}):O==="changes"?d.jsx(B_,{placement:"screen"}):null:d.jsx(nT,{placement:"screen"}),N&&R&&d.jsx(SU,{gated:Mm(y,c),active:N,url:R,hidden:O!=="preview"||l!==null},N.worktree.id),d.jsx(eT,{})]})})]})}const jU=640,CU=1e3,iT=`(max-width: ${jU}px), ((hover: none) and (max-width: ${CU}px))`,aT="(hover: none)",lT=()=>{var e;return(e=window.matchMedia)!=null&&e.call(window,iT).matches?"phone":"desk"},AU=()=>{var e;return((e=window.matchMedia)==null?void 0:e.call(window,aT).matches)??!1};function IU(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(iT,o=>e.dispatch({a:"frame",v:o?"phone":"desk"})),r=t(aT,o=>e.dispatch({a:"touch",v:o}));return()=>{n(),r()}}function RU(){try{const e=localStorage.getItem(Qe.theme);if(e){const t=JSON.parse(e);if(t!=null&&t.colors&&typeof t.colors.surface0=="string")return t}}catch{}return Pc}function cT(e,t={}){var o;const n=document.documentElement;for(const[i,l]of Object.entries(eM(e)))n.style.setProperty(i,l);n.style.colorScheme=e.kind,n.dataset.theme=e.kind;const r=lT()==="phone"?e.colors.surface0:e.colors.surface1;if((o=document.querySelector('meta[name="theme-color"]'))==null||o.setAttribute("content",r),t.remember!==!1)try{localStorage.setItem(Qe.theme,JSON.stringify(e))}catch{}}function uT(e){const t=$g(e);return{type:"theme",accent:t,accentFg:lM(t)}}function $U(){var e;return((e=window.matchMedia)==null?void 0:e.call(window,"(prefers-color-scheme: dark)").matches)??!0}const OU=12*36e5;function MU(){try{const e=localStorage.getItem(Qe.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<OU?{dark:!t.dark,until:0}:null}catch{return null}}function LU(e){try{localStorage.setItem(Qe.daylight,JSON.stringify(e))}catch{}}function PU(e){var r;const t=(r=window.matchMedia)==null?void 0:r.call(window,"(prefers-color-scheme: dark)");if(!t)return()=>{};const n=o=>e(o.matches);return t.addEventListener("change",n),()=>t.removeEventListener("change",n)}function dg(e,t){return[{id:"copy-name",label:"copy name",detail:e,onClick:()=>on(e)},{id:"copy-value",label:"copy value",detail:t,onClick:()=>on(t)}]}function fg(e){return[{id:"copy-value",label:"copy value",detail:e,onClick:()=>on(e)}]}function DU(e,t,{sock:n},r){return t?zn([[{id:"source",label:"open source",onClick:r}],Gi(`${e.dir}/${t}`,()=>n==null?void 0:n.send({t:"reveal",worktreeId:e.id,path:t}),as(n)),[{id:"copy-path",label:"copy path",onClick:()=>on(t)}]]):[]}function Oc(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 zU(e){const t=/^#([0-9a-f]{3,8})$/i.exec(e.trim());return t?t[1].length===4||t[1].length===8:!1}function Mx([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 dT(e,t){if(zU(e))return null;const n=Oc(e);if(!n)return null;const r=Oc(t);if(!r)return null;const[o,i]=[Mx(n),Mx(r)];return`${((Math.max(o,i)+.05)/(Math.min(o,i)+.05)).toFixed(2)}:1`}function FU({worktreeId:e,height:t,full:n,onToggleFull:r,onDragStart:o}){const i=lt(),l=ct(),c=P(h=>_o(h,e).design);S.useEffect(()=>{c||l==null||l.send({t:"design-scan",worktreeId:e})},[c,e,l]),S.useEffect(()=>()=>an.post(e,{type:"highlight-clear"}),[e]);const u={outline:h=>an.post(e,h),clear:()=>an.post(e,{type:"highlight-clear"}),open:h=>er({dispatch:i},{worktreeId:e,path:h})};return d.jsx(iw,{kind:"design",className:Ue("design-pane",n&&"full"),height:n?void 0:t,resizable:!n,onDragStart:o,title:c?d.jsx("span",{children:WU(c)}):void 0,onClose:()=>i({a:"toggle-design"}),closeHint:Lt("design"),full:n,onToggleFull:r,actions:d.jsxs(ze,{variant:"outline",onClick:()=>l==null?void 0:l.send({t:"design-scan",worktreeId:e}),"data-tip":"Scan this worktree again",children:[d.jsx(Nt,{name:"reload",className:"icon-inline"})," rescan"]}),children:c?d.jsxs("div",{className:"design-body",style:HU,onMouseLeave:u.clear,children:[c.tokens.length===0&&c.literals.length>0?d.jsx(YU,{literals:c.literals,outline:u.outline,clear:u.clear}):d.jsx(GU,{tokens:c.tokens,coverage:c.coverage,outline:u.outline,clear:u.clear}),d.jsx(s7,{index:c,outline:u.outline,clear:u.clear,onOpen:u.open}),d.jsx(i7,{index:c,outline:u.outline,clear:u.clear,onOpen:u.open})]}):d.jsx("div",{className:"empty",children:"reading the design system…"})})}const BU=720,UU=132,HU={"--design-column":`${BU}px`,"--design-cell":`${UU}px`};function WU(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 Wa=e=>`${e} use${e===1?"":"s"}`;function Zf({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 cf({children:e}){return d.jsx("p",{className:"design-gap",children:e})}const KU=[{kind:"font",label:"type"},{kind:"color",label:"color"},{kind:"length",label:"size & radius"},{kind:"shadow",label:"shadow"},{kind:"other",label:"computed"}];function ZU(e){return e.find(t=>t.kind==="color"&&Oc(t.resolved??t.value)!==null)}function qU(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 GU({tokens:e,coverage:t,outline:n,clear:r}){const o=ZU(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(Zf,{title:"Tokens",children:e.length===0?d.jsx(cf,{children:qU(t)}):KU.map(({kind:u,label:h})=>{const p=e.filter(g=>g.kind===u);if(p.length===0)return null;const m=hT(p.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(pT,{groups:t7(p),outline:n,clear:r}):d.jsx("div",{className:"design-breakout",style:fT(p.length),children:d.jsx("div",{className:"design-grid",children:p.map(g=>{const y=g.resolved??g.value,w=g.kind==="color"&&i?dT(y,i):null;return d.jsx(mT,{kind:g.kind,name:g.name,lines:g.resolved?[g.value,g.resolved]:[g.value],actual:y,ratio:w,largest:m,tipText:r7(g,w,o,c(g)),menu:()=>dg(g.name,y),outline:n,clear:r},g.name)})})})]},u)})})}const VU=[{role:"color",kind:"color",label:"color"},{role:"radius",kind:"length",label:"radius"},{role:"shadow",kind:"shadow",label:"shadow"}];function YU({literals:e,outline:t,clear:n}){const r=e.find(i=>i.ground&&Oc(i.value)!==null),o=n7(e);return d.jsxs(Zf,{title:"Values",note:"written out in the rules; no custom properties",children:[o.length>0&&d.jsx("div",{className:"design-group",children:d.jsx(pT,{groups:o,outline:t,clear:n})}),VU.map(({role:i,kind:l,label:c})=>{const u=e.filter(p=>p.role===i);if(u.length===0)return null;const h=hT(u.map(p=>p.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:fT(u.length),children:d.jsx("div",{className:"design-grid",children:u.map(p=>{const m=l==="color"&&r?dT(p.value,r.value):null;return d.jsx(mT,{kind:l,name:p.value,lines:[Wa(p.uses)],actual:p.value,ratio:m,largest:h,tipText:o7(p,m,r),menu:()=>fg(p.value),outline:t,clear:n},p.value)})})})]},i)})]})}function fT(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 hT(e){return e.reduce((t,n)=>Math.max(t,Math.abs(Number.parseFloat(n))||0),0)}const XU=["color","background-color","border-top-color","border-right-color","border-bottom-color","border-left-color","outline-color"];function QU(e,t){if(!e)return[];const n=getComputedStyle(e);return t.map(r=>[r,n.getPropertyValue(r)])}const hg=e=>(e.split(",")[0]??e).replace(/["']/g,"").trim();function JU(e){const t=/^[1-9]00\s+([\d.]+)px(?:\s*\/\s*([\d.]+)(px)?)?\s+(.+)$/.exec(e.trim());if(!t)return{family:hg(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:hg(t[4]??""),size:n,lead:o}}function am(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 e7(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 t7(e){const t=e.map(n=>({token:n,actual:n.resolved??n.value,...JU(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}
254
+ ${o.actual}`:void 0,menu:()=>o?dg(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}
255
+ ${i.actual}`,menu:()=>dg(i.token.name,i.actual)}))}})}function n7(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":hg(o);return{family:l,stack:o,name:i?Wa(i.uses):void 0,label:l,tipText:i?`${i.value}
256
+ ${Wa(i.uses)}: ${i.selectors.join(", ")}`:void 0,menu:()=>i?fg(i.value):[],rows:n.filter(c=>(c.family??"initial")===o).sort((c,u)=>am(u.value)-am(c.value)).map(c=>{const u=am(c.value),h=e7(c.lead,u),p=c.value.endsWith("px")?`${u}`:c.value;return{key:`${c.value}/${c.lead??""}`,sample:`${l} ${p}${h===null?"":`/${h}`}`,style:{fontFamily:o,fontSize:c.value,lineHeight:c.lead},name:Wa(c.uses),label:c.value,tipText:`${c.value}${c.lead?` / ${c.lead}`:""}
257
+ ${Wa(c.uses)}: ${c.selectors.join(", ")}`,menu:()=>fg(c.value)}})}})}function pT({groups:e,outline:t,clear:n}){const r=(i,l,c)=>t({type:"highlight-computed",props:QU(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?Ut(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),...Ut(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 mT({kind:e,name:t,lines:n,actual:r,ratio:o,largest:i,tipText:l,menu:c,outline:u,clear:h}){const p=e==="color"&&Oc(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:p?y=>{const w=y.currentTarget.querySelector(".design-fill"),b=w?getComputedStyle(w).backgroundColor:"";u({type:"highlight-computed",props:XU.map(E=>[E,b]),match:"any",label:t})}:void 0,onMouseLeave:p?h:void 0,...Ut(l),children:[e==="color"&&d.jsx("div",{className:"design-sample",children:p&&d.jsx("span",{className:"design-fill",style:{background:r}})}),d.jsxs("div",{className:"design-plate",children:[d.jsx("span",{className:"design-cell-name",children:t}),n.map((y,w)=>d.jsxs("span",{className:"design-cell-line",children:[d.jsx("span",{className:"design-cell-value",children:y}),w===0&&o&&d.jsx("span",{className:"design-cell-note",children:o})]},y)),Number.isFinite(m)&&i>0&&d.jsx("span",{className:"design-scale",style:{width:`${Math.max(2,Math.abs(m)/i*100)}%`}})]})]})}function r7(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(`
258
+ `)}function o7(e,t,n){const r=[e.value,`${Wa(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(`
259
+ `)}function gT({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 s7({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(kT,{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(p=>d.jsxs("span",{className:"design-variant",children:[p.prop,": ",p.values.join(" · ")]},p.prop))})},`${h.path}:${h.name}`);return d.jsxs(Zf,{title:"Components",note:`${l.length} reused of ${o.length}`,children:[!i&&d.jsx(cf,{children:"No TypeScript in this project, so the values each prop allows are not listed."}),d.jsx(gT,{shared:l.map(u),rest:c.map(u)})]})}function i7({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,p=o.length?`${c.length} reused of ${o.length}`+(h?`, ${h} with no component of their name`:""):void 0,m=g=>d.jsx(a7,{cls:g,outline:t,clear:n,onOpen:r},g.name);return d.jsx(Zf,{title:"Classes",note:p,children:o.length===0?d.jsx(cf,{children:"No stylesheet in this project defines a class. Utility-first CSS generates its own."}):l.length===0?d.jsx(cf,{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(gT,{shared:c.map(m),rest:u.map(m)})})}function a7({cls:e,outline:t,clear:n,onOpen:r}){return d.jsx(kT,{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 kT({count:e,name:t,path:n,onEnter:r,onLeave:o,onOpen:i,children:l}){const c=Ss(),u=ct();lt();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?DU({id:c.worktree.id,dir:c.worktree.path},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 l7({worktreeId:e,procs:t,borrowed:n,login:r,current:o,onRestart:i}){const l=ct();lt();const c={sock:l},u=(p,m)=>d.jsx(Pt,{icon:"reload",label:m,onClick:()=>i(p)}),h={id:Es,label:"login",tip:Ut("The agent's login; it closes once you are in",void 0,{placement:"top"}),trail:u(Es,"Run the login again")};return r&&o===Es?[h]:[{id:vo,label:"shell",tip:Ut("A shell in this worktree",void 0,{placement:"top"}),menu:()=>tN(e,c),trail:u(vo,"Restart the shell")},...r?[h]:[],...t.map(p=>({id:p.name,label:p.name,lead:d.jsx("span",{className:`dot ${p.status}`}),tip:Ut(QM(p.status),void 0,{placement:"top",dot:p.status,name:p.name,detail:p.command,aside:[`:${p.port}`]}),menu:()=>Vk(p,e,c),trail:u(p.name,`Restart ${p.name}`)})),...n.map(p=>({id:p,label:p,lead:d.jsx("span",{className:"dot borrowed"}),tip:Ut(`${p} runs on main for every worktree; this one reaches it at its usual address`,void 0,{placement:"top"})}))]}const c7=S.lazy(()=>ig(()=>import("./XTerm-V6sBDIe-.js"),__vite__mapDeps([3,4]))),u7=[];function d7({worktreeId:e,opened:t,height:n,onDragStart:r}){const o=lt(),i=ct(),l=jf(),c=P(z=>z.connected),u=P(z=>z.focusTerm),h=Ss(),p=(h==null?void 0:h.procs)??[],m=(h==null?void 0:h.borrowed)??u7,g=(h==null?void 0:h.login)??!1,y=It(e,"termStream"),w=P(z=>{var X;return((X=z.termRun)==null?void 0:X.id)===e&&y===vo?z.termRun.command:null}),[b,E]=S.useState(null),_=m.includes(y);S.useEffect(()=>{y===vo||(y===Es?g:p.some(X=>X.name===y)||m.includes(y))||o({a:"term-stream",id:e,stream:vo})},[p,m,g,y,e,o]);const N=z=>{z!==y&&(E(null),o({a:"term-stream",id:e,stream:z}))},T=S.useRef(!1),[R,O]=S.useState(0),B=z=>{z===vo&&z===y&&(T.current=!0),i==null||i.send({t:"term-restart",worktreeId:e,stream:z}),z===Es&&z===y&&(E(null),O(X=>X+1))},$=(z,X)=>{if(z)return E(null);if(T.current){T.current=!1,O(ae=>ae+1);return}E({code:X})},C=l7({worktreeId:e,procs:p,borrowed:m,login:g,current:y,onRestart:B}),j=S.useRef(!t),D=!j.current;return S.useEffect(()=>{j.current=!1},[]),d.jsxs(iw,{kind:"terminal",className:"term-pane",height:n,onDragStart:r,tabs:{items:C,current:y,onPick:N,font:"mono",owner:"terminal",label:"terminal streams"},onClose:()=>o({a:"toggle-terminal"}),closeHint:Lt("terminal"),children:[d.jsxs("div",{className:"term-body",children:[_&&d.jsx(Sc,{pane:!0,title:`${y} runs on main`,body:"Every worktree reaches main's copy until its own changes touch it, or until asked.",action:d.jsx(ze,{variant:"outline",onClick:()=>i==null?void 0:i.send({t:"own-procs",worktreeId:e,names:[y]}),children:"run it here"})}),d.jsx(wk,{pane:!0,children:d.jsx(S.Suspense,{fallback:d.jsx("div",{className:"empty",children:"loading terminal…"}),children:d.jsx(c7,{worktreeId:e,stream:y,theme:l,sock:i,connected:c,focusOnMount:D,focusReq:u,onAlive:$,run:w,onRan:()=>o({a:"term-ran"}),onEscape:()=>o({a:"toggle-terminal"})},`${y}:${R}`)})})]}),b!==null&&!_&&d.jsx(Sc,{pane:!0,title:y===vo?"the shell exited":y===Es?"the login did not finish":`${y} exited`,body:b.code===void 0?void 0:`exit code ${b.code}`,action:d.jsx(ze,{variant:"outline",onClick:()=>B(y),children:"restart"})})]})}function f7(e){return e==="reserved"?"checking out a fresh worktree…":e==="warming"?"copying dependencies and running setup…":"starting dev servers…"}const h7="preview off; it starts when the agent writes a file";function p7({worktree:e,log:t}){const n=ct(),r=lt(),o=e.procs,i=b=>n==null?void 0:n.send({t:"term-restart",worktreeId:e.id,stream:b.name}),l=o.some(b=>b.status==="crashed"||b.status==="unreachable"),c=P(b=>b.clientId),u=jc(e,"setup"),h=u&&u.status!=="terminated"?u:null,p=il(Nk(h??void 0)?h==null?void 0:h.since:void 0),m=!!e.worktree.parked&&o.length===0,g=()=>n==null?void 0:n.send({t:"preview-start",worktreeId:e.id}),y=h&&(h.status==="running"||h.status==="detached"),w=()=>n==null?void 0:n.send({t:"fix-preview",worktreeId:e.id,clientId:c});return d.jsxs(Ts,{wide:!0,children:[o.length===0?d.jsx("div",{className:"status-line",children:h?d.jsx("span",{className:"live-text","data-tip":P_[h.status],children:Dm("setup",h,p)}):m?h7:f7(e.worktree.phase)}):d.jsx("ul",{className:"boot-procs",children:o.map(b=>d.jsxs("li",{className:Ue("boot-proc",(b.status==="crashed"||b.status==="unreachable")&&"boot-bad"),children:[d.jsx("span",{className:"boot-name",children:b.name}),d.jsx("span",{className:"boot-status",children:m7(b)}),(b.status==="crashed"||b.status==="unreachable")&&d.jsx(ze,{variant:"outline",onClick:()=>i(b),children:"restart"}),b.detail&&b.status!=="asleep"&&d.jsx("div",{className:"boot-detail",children:b.detail})]},b.name))}),m&&d.jsx("div",{className:"status-actions",children:d.jsx(ze,{variant:"outline",size:"lg",onClick:g,children:"start preview"})}),y&&d.jsx("div",{className:"status-actions",children:d.jsx(ze,{variant:"outline","data-tip":D_("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(ze,{variant:"outline",size:"lg",onClick:w,children:"ask the agent to fix it"}),d.jsx(ze,{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(b=>`[${b.proc}] ${b.line}`).join(`
260
+ `)})]})}function m7(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 g7(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 k7(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 w7({active:e}){const t=lt(),n=ct(),r=fl(),o=P(c=>c.home),i=e.worktree.title,l=()=>{r!=null&&r.made&&(t({a:"new-project",v:{...Vg({mode:r.made==="git"?"init":"create",name:r.name,parent:oN(r.path,o)??r.path}),phase:"unmaking",repoId:r.id}}),t({a:"move-box",from:e.worktree.id,to:rl}),n==null||n.send({t:"unmake-repo",repoId:r.id}))};return d.jsx(Ts,{anchor:"line",foot:d.jsx("div",{className:"composer view-foot",children:d.jsx(mc,{active:e,greenfield:!0})}),children:d.jsx("p",{className:"form-title",children:r!=null&&r.made?d.jsx(ze,{variant:"inline",onClick:l,...Ut("Rename or move this project"),children:i}):i})})}function y7({pending:e}){const t=lt(),n=ct(),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(Ts,{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:"import-idle",children:"starting git…"}):e.lines.map((l,c)=>d.jsx("div",{children:l},c))}),d.jsx("div",{className:"status-actions",children:d.jsx(ze,{variant:"outline",size:"lg",onClick:o,children:r?"dismiss":"stop"})})]})}const v7=150,b7=/^[^\s@]+@[^\s@]+$/,x7=14;function E7({project:e}){var oe;const t=lt(),n=ct(),r=P(ne=>ne.repos),o=P(ne=>ne.home),i=P(ne=>ne.folderDialog),l=P(ne=>ne.gitIdentity),c=P(ne=>ne.choosingFolder),u=P(ne=>ne.chosenFolder),h=P(ne=>ne.paths),[p,m]=S.useState({name:"",email:""}),[g,y]=S.useState(null),w=S.useRef(null),{mode:b,name:E,parent:_}=e,N=b==="clone",T=b==="init",R=e.phase==="editing",O=E.trim(),B=T||!O?null:xc(E),$=!T&&O&&!B?rN(_,O):null,C=Xm(_,o),j=$!==null&&h.query===$&&((oe=h.target)==null?void 0:oe.exists)===!0,D=!l&&!N,z=!D||p.name.trim()!==""&&b7.test(p.email.trim()),X=R?g?"the folder you chose is already a project: open it, or choose another":!T&&!O?"name the project first":B??(j?`${C} already has a folder called ${O}`:z?null:"git needs your name and email first"):null;S.useEffect(()=>{if(!$)return;const ne=setTimeout(()=>n==null?void 0:n.send({t:"browse-path",path:$}),v7);return()=>clearTimeout(ne)},[$,n]),St([e.phase],()=>{var ne;e.phase==="editing"&&((ne=w.current)==null||ne.focus())}),St([e.error],()=>{e.error&&t({a:"notice",id:rl,text:e.error})});const ae={sock:n,dispatch:t},A=()=>{X||!R||(t({a:"new-project-set",v:{phase:"creating"}}),Ic(ae,{t:"create-repo",mode:b,parent:_.trim(),name:O,...N&&e.url?{url:e.url}:{},...D?{identity:{name:p.name.trim(),email:p.email.trim()}}:{}}))},de=ne=>{const H=r.find(se=>se.path===ll(ne,o));H?t({a:"activate-repo",id:H.id}):Ic(ae,{t:"register-repo",path:ne})},ue=ne=>{const H=Yk(ne);t({a:"new-project-set",v:{mode:"init",parent:H.parent,name:H.name}})},J=ne=>{i?(t({a:"choosing-folder",v:ne}),n==null||n.send({t:"choose-folder",start:_,purpose:ne})):t(ne==="location"?{a:"open",overlay:{kind:"choose-folder"}}:{a:"open",overlay:{kind:"projects",form:"disk"}})};St([u==null?void 0:u.seq],()=>{var H,se;if(!c||!u)return;t({a:"choosing-folder",v:!1});const ne=u.folder;if(!ne){(H=w.current)==null||H.focus();return}if(c==="open"){ne.kind==="project"?de(ne.path):D?ue(ne.path):sN(ae,ne.path);return}if(y(ne.kind==="project"?ne.path:null),ne.kind!=="project"){if(ne.kind==="empty"&&!N){ue(ne.path);return}t({a:"new-project-set",v:{mode:N?"clone":"create",parent:ne.path}}),(se=w.current)==null||se.focus()}});const M=T?"the folder you chose becomes the project":g?null:j?`${C} already has a folder called ${O}`:B;return d.jsxs(Ts,{anchor:"line",foot:d.jsx("div",{className:"composer view-foot",children:d.jsx(mc,{active:null,project:{name:O,why:X,busy:!R,create:A}})}),children:[N&&d.jsx("p",{className:"new-project-url",children:e.url}),d.jsxs("div",{className:"form-head",children:[T?d.jsx("p",{className:"form-title",children:E}):d.jsx(Eo,{ref:w,bare:!0,font:"lead",className:"new-project-field",autoFocus:!0,spellCheck:!1,autoComplete:"off",value:E,placeholder:"Project name",disabled:!R,style:{width:`${Math.max(E.length+1,x7)}ch`},onChange:ne=>t({a:"new-project-set",v:{name:ne.target.value}}),onKeyDown:ne=>{ne.key==="Enter"&&(ne.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",...Ut(_),children:C}),d.jsx(Pt,{icon:"folder",label:i?"Choose in Finder":"Choose a folder",className:"new-project-folder",on:c==="location",disabled:!R,onClick:()=>J("location")})]})]}),M&&d.jsx("p",{className:"hint",children:M}),g&&d.jsxs("p",{className:"hint",children:["the folder you chose is already a project:"," ",d.jsx(ze,{variant:"inline",autoFocus:!0,onClick:()=>de(g),children:"open it"}),", or choose another"]}),D&&d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"new-project-identity",children:[d.jsx(Eo,{size:"md",font:"ui",rule:!0,value:p.name,placeholder:"Your name",autoComplete:"name",disabled:!R,onChange:ne=>m({...p,name:ne.target.value})}),d.jsx(Eo,{size:"md",font:"ui",rule:!0,type:"email",value:p.email,placeholder:"Email",autoComplete:"email",disabled:!R,onChange:ne=>m({...p,email:ne.target.value})})]}),d.jsx("p",{className:"hint",children:"git labels the work you save with these, and asks only once"})]}),!N&&R&&d.jsx(ze,{tone:"quiet",className:"new-project-open",onClick:()=>J("open"),children:"or open a folder you already have"})]})}function La({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 _7(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(`
261
+ `)}function S7(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(`
262
+ `)}let N7=1;const lm=(e,t,n=!1)=>({id:N7++,name:e,cmd:t,shared:n}),T7=[{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 j7({repo:e,onClose:t}){const n=ct(),r=Zn(),o=P(ke=>ke.clientId),i=P(ke=>ke.rows.find(Q=>{var we;return xn(Q)&&Q.id===((we=ol(ke,e.id))==null?void 0:we.id)})??null),l=P(ke=>{var Q;return((Q=ol(ke,e.id))==null?void 0:Q.id)??null});S.useEffect(()=>{if(!t)return;const ke=Q=>Q.key==="Escape"&&t();return window.addEventListener("keydown",ke),()=>window.removeEventListener("keydown",ke)},[t]);const[c]=S.useState(()=>Object.keys(e.config.run).length>0),[u,h]=S.useState(()=>{const ke=Object.entries(e.config.run).map(([Q,we])=>lm(Q,Jx(we),lC(we)));return ke.length>0?ke:[lm("web","")]}),[p,m]=S.useState(()=>(e.config.setup??[]).join(`
263
+ `)),[g,y]=S.useState(()=>(e.config.teardown??[]).join(`
264
+ `)),[w,b]=S.useState(()=>e.config.check??""),[E,_]=S.useState(()=>Fi(e.config).land),[N,T]=S.useState(()=>Fi(e.config).automerge),[R,O]=S.useState(()=>Fi(e.config).merge??"default"),[B,$]=S.useState(()=>dC(e.configFile)),C=fC(e.configFile,B),j=!!e.remote&&E==="pr",D=u.length>1,z=u.some(ke=>ke.name.trim()&&ke.cmd.trim()),ae=!!i&&!t&&!c&&!z,A=(ke,Q)=>h(u.map((we,te)=>te===ke?{...we,...Q}:we)),de=ke=>ke.split(`
265
+ `).map(Q=>Q.trim()).filter(Boolean),ue=()=>de(p),J=()=>de(g),M=()=>{const{check:ke,land:Q,teardown:we,...te}=e.config,Z=e.remote?E:fm,je=R==="default"||Z!=="pr"&&R===hm?void 0:R,He={...Z!==fm?{route:Z}:{},...Z==="pr"&&N?{automerge:!0}:{},...je?{method:je}:{}};return{...te,setup:ue(),...J().length>0?{teardown:J()}:{},...w.trim()?{check:w.trim()}:{},...Object.keys(He).length>0?{land:He}:{}}},oe=()=>{n==null||n.send({t:"confirm-config",repoId:e.id,config:{...M(),run:Object.fromEntries(u.filter(ke=>ke.name.trim()&&ke.cmd.trim()).map((ke,Q)=>[ke.name.trim(),ke.shared&&Q>0?{cmd:ke.cmd.trim(),from:"trunk"}:ke.cmd.trim()]))},kind:B}),t==null||t()},ne=()=>{n==null||n.send({t:"confirm-config",repoId:e.id,config:{...M(),run:{}},kind:B}),t==null||t()},H=()=>n==null?void 0:n.send({t:"create-worktree",clientId:o,repoId:e.id,prompt:S7(e,C)}),se=e.services,ie=[p,g,...u.map(ke=>ke.cmd)].some(ke=>ke.includes("TOYON_WORKTREE"))||cC(e.config),he=se?[se.envUrl?`the database at ${se.envUrl.name} in ${se.envUrl.file}`:null,se.compose?`the stack in ${se.compose}`:null].filter(Boolean).join(" and "):"",ge=()=>se&&(n==null?void 0:n.send({t:"create-worktree",clientId:o,repoId:e.id,prompt:_7(e,C,se)})),Ie=(ke,Q)=>d.jsxs("div",{className:"setup-proc",children:[D&&d.jsx(Eo,{size:"md",rule:!0,className:"setup-name",value:ke.name,placeholder:"name",...Ut("Process name, shown in the status bar"),onChange:we=>A(Q,{name:we.target.value})}),d.jsx(Eo,{size:"md",rule:!0,className:"setup-cmd",value:ke.cmd,placeholder:"npm run dev",onChange:we=>A(Q,{cmd:we.target.value})}),D&&d.jsx(Pt,{icon:"close",label:"Remove",onClick:()=>h(u.filter((we,te)=>te!==Q))}),D&&Q>0&&d.jsx(KN,{className:"setup-shared",checked:ke.shared,onChange:we=>A(Q,{shared:we.target.checked}),tip:"Main runs it once for every worktree; a worktree whose changes touch it runs its own",children:"shared from main"})]},ke.id);return d.jsxs(Ts,{children:[d.jsxs("p",{className:"form-title",children:["how does ",e.name," start?"]}),se&&!ie&&d.jsxs("p",{className:"hint setup-shared-note",children:["Worktrees will share ",he,", migrations included."," ",d.jsx(ze,{tone:"quiet",disabled:!i,onClick:ge,children:"ask the agent to keep them apart"})]}),d.jsx(La,{label:"install",hint:"once per new worktree; one command per line",children:d.jsx(Tc,{size:"md",rule:!0,rows:Math.max(1,p.split(`
266
+ `).length),value:p,placeholder:"bun install",onChange:ke=>m(ke.target.value)})}),d.jsx(La,{label:"remove",hint:"once when a worktree goes, before its directory does; one command per line",children:d.jsx(Tc,{size:"md",rule:!0,rows:Math.max(1,g.split(`
267
+ `).length),value:g,placeholder:'dropdb --if-exists "app_$TOYON_WORKTREE"',onChange:ke=>y(ke.target.value)})}),d.jsx(La,{label:"check",hint:"runs after each of the agent's turns; the work lands only when it passes",children:d.jsx(Eo,{size:"md",rule:!0,value:w,placeholder:"bun run check",onChange:ke=>b(ke.target.value)})}),e.remote&&d.jsx(La,{label:"land",hint:"where a worktree's finished work goes; one way per repo",children:d.jsxs("div",{className:"setup-land",children:[d.jsx(ni,{value:E,options:NC.map(ke=>({id:ke.id,label:ke.name,description:ke.description})),onChange:_,hint:"where the work goes",placeholder:"where work lands"}),j&&d.jsx(ni,{value:N?"github":"you",options:jC.map(ke=>({id:ke.id,label:ke.name,description:ke.description})),onChange:ke=>T(ke==="github"),hint:"who merges the pull request",placeholder:"who merges it"})]})}),d.jsx(La,{label:"merge",hint:j?"how GitHub merges the pull request; only what the repo allows":"how the commits arrive on main",children:d.jsx(ni,{value:R==="default"&&!j?hm:R,options:[...j?[{id:"default",label:"what the repo allows",description:"the repo's allowed methods on GitHub: squash, else a merge commit, else rebase"}]:[],...TC.map(ke=>({id:ke.id,label:ke.name,description:ke.description}))],onChange:O,hint:"how the commits arrive on main",placeholder:"how the commits arrive"})}),d.jsx(La,{label:"start",hint:d.jsxs(d.Fragment,{children:["must listen on ",d.jsx("code",{...Ut("Toyon sets a different port for each worktree"),children:"$PORT"}),e.guess&&l&&d.jsxs(d.Fragment,{children:[" · from ",d.jsx(ze,{mono:!0,tone:"quiet",...Ut(`open ${e.guess} in the editor pane`),onClick:()=>Wi(r,n,l,e.guess??"",1),children:e.guess})]})]}),children:u[0]&&Ie(u[0],0)}),u.slice(1).map((ke,Q)=>d.jsxs("div",{className:"form-row",children:[d.jsx("span",{className:"form-label"}),d.jsx("div",{className:"form-control",children:Ie(ke,Q+1)})]},ke.id)),d.jsxs("div",{className:"form-row",children:[d.jsx("span",{className:"form-label"}),d.jsxs(ze,{tone:"quiet",onClick:()=>h([...u,lm("","")]),children:[d.jsx(Nt,{name:"plus",className:"icon-inline"})," another process"]})]}),d.jsxs("div",{className:"form-knobs",children:[d.jsx(ni,{value:B,options:T7,onChange:$,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:C}),t&&d.jsx(ze,{onClick:t,children:"cancel"}),(!c||t)&&d.jsx(ze,{...Ut("This project has no dev server: chat, changes and the terminal work, the preview stays empty"),onClick:ne,children:"no dev server"}),ae&&i?d.jsx(ze,{variant:"outline",size:"lg",disabled:i.agent!=="idle",...Ut("The agent reads the repo and writes the settings file; the daemon picks it up as soon as it lands"),onClick:H,children:"let the agent work it out"}):d.jsxs(ze,{variant:"outline",size:"lg",disabled:!z,...t?Ut("Restarts every worktree of this repo. Profiles and other keys in the file are kept."):{},onClick:oe,children:[t?"save + restart":"start"," ",d.jsx(Nt,{name:"forward",className:"icon-inline"})]})]})]})}function C7(e){return`${Math.round(e.w)} × ${Math.round(e.h)}`}function A7(e){return e.w>0&&e.h>0}function I7(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(A7(l)?C7(l):null)});return r.observe(e),()=>{r.disconnect(),n(null)}},[e,t,n])}const R7=1500,$7={set:(e,t)=>setTimeout(e,t),clear:e=>clearTimeout(e)};class O7{constructor(t,n,r=$7){Dt(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=c0(r));const i=vf(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)},R7)}title(t,n){const r=this.frame(t);r.title=c0(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 M7=Mg(),L7=2*6e4;function Lx(e){e==null||e.setAttribute("src",e.src)}const P7=8e3,kd="render:",D7=6e3,z7=1500;function Px(e,t){try{const n=new URL(e,t);return n.origin===new URL(t).origin?n.href:null}catch{return null}}function F7({onRoot:e}){const t=S.useRef(null),n=S.useCallback(V=>{t.current=V,e(V)},[e]),r=lt(),o=Zn(),i=ct(),l=S.useRef(i);l.current=i;const[c]=S.useState(()=>new O7((V,Ee,Ze)=>{var yt,sn;(yt=l.current)==null||yt.send({t:"visit",worktreeId:V,path:Ee,title:Ze}),hE((sn=o.getState().local[V])==null?void 0:sn.pages)&&an.post(V,{type:"links"})},(V,Ee,Ze)=>{var yt;return(yt=l.current)==null?void 0:yt.send({t:"page-title",worktreeId:V,path:Ee,title:Ze})}));S.useEffect(()=>()=>c.dispose(),[c]);const u=FE(),h=dl(),p=Ss(),m=P(V=>V.connected),g=P(V=>V.heard),y=P(V=>V.connectFailure),w=P(V=>V.remote),{host:b}=Wr(),E=so(),_=Go(),N=P(V=>V.editor),T=UE(),R=hP(),O=Bc(),B=P(V=>V.layout.term)&&!O,$=P(V=>V.focusTerm),C=S.useRef(!1),j=S.useRef($),D=!C.current||$!==j.current;S.useEffect(()=>{C.current=B&&!!h,j.current=$});const z=Uc(),X=P(V=>V.layout.design)&&!O&&!z,ae=P(V=>V.reloadReq),A=jf(),de=S.useRef(A);de.current=A;const ue=P(V=>V.zen),J=P(V=>{var Ee;return((Ee=V.dragFiles)==null?void 0:Ee.at)==="centre"}),M=S.useRef(ue);M.current=ue;const oe=It(h,"log"),ne=P(V=>V.incompatible),H=mP(),se=P(V=>{var Ee;return((Ee=V.overlay)==null?void 0:Ee.kind)==="setup"?V.repos.find(Ze=>Ze.id===V.overlay.repoId)??null:null}),ie=(p==null?void 0:p.worktree.empty)===!0,he=!!p&&zc(p),ge=H&&!ie&&!he?H:null,Ie=ge??se,ke=P(V=>V.pending.find(Ee=>Ee.id===V.activeImportId)??null),[Q,we]=S.useState([]),te=P(V=>V.renders),Z=S.useRef(new Map),je=S.useCallback((V,Ee,Ze)=>{var yt;clearTimeout(Ee.timer),Z.current.delete(V),(yt=l.current)==null||yt.send({t:"rendered",worktreeId:Ee.worktreeId,id:V,errors:Ee.errors.slice(0,e2),...Ee.url?{url:Ee.url.slice(0,t2)}:{},...Ee.title?{title:Ee.title.slice(0,JO)}:{},...Ze}),r({a:"render-done",id:V})},[r]),He=S.useRef((V,Ee)=>{});He.current=(V,Ee)=>{const Ze=Z.current.get(V);if(Ze)switch(Ee.type){case"frame-load":clearTimeout(Ze.timer),Ze.timer=setTimeout(()=>je(V,Ze,{ok:!0}),z7);break;case"loaded":Ze.url=Ee.url,Ze.title=Ee.title;break;case"navigated":Ze.url=Ee.url,Ee.title!==void 0&&(Ze.title=Ee.title);break;case"title":Ze.title=Ee.title;break;case"page-error":Ze.errors.push(v0(Ee));break}},S.useEffect(()=>{for(const V of te){if(Z.current.has(V.id))continue;const Ee={worktreeId:V.worktreeId,errors:[]};Z.current.set(V.id,Ee);const Ze=u.find(yt=>yt.id===V.worktreeId);if(!Ze||!xn(Ze)){je(V.id,Ee,{ok:!1,reason:"this tab has no preview for that worktree"});continue}if(!Px(V.path,Sd(Ze.worktree.id,Ze.worktree.proxyPort,w,b))){je(V.id,Ee,{ok:!1,reason:"not a route of the preview"});continue}Ee.timer=setTimeout(()=>je(V.id,Ee,{ok:!1,reason:"the page did not load"}),D7)}},[te,u,w,b,je]),S.useEffect(()=>()=>{for(const V of Z.current.values())clearTimeout(V.timer)},[]);const Fe=S.useRef(new Map),Pe=S.useRef(new Map),[We,Ht]=S.useState([]),ut=S.useRef(new Set),vn=S.useRef(new Set),Jt=S.useRef(V=>Lx(Fe.current.get(V)));S.useEffect(()=>{an.post=(V,Ee)=>{var Ze,yt;if(Ee.type==="reload"&&ut.current.has(V))return Jt.current(V);(yt=(Ze=Fe.current.get(V))==null?void 0:Ze.contentWindow)==null||yt.postMessage({__toyon:!0,...Ee},Pe.current.get(V)??"*")},an.broadcast=V=>{var Ee;for(const[Ze,yt]of Fe.current)(Ee=yt.contentWindow)==null||Ee.postMessage({__toyon:!0,...V},Pe.current.get(Ze)??"*")}},[]),S.useEffect(()=>{let V=null;const Ee=sn=>{sn.target instanceof HTMLElement&&sn.target.tagName!=="IFRAME"&&(V=sn.target)},Ze=sn=>{sn.relatedTarget===null&&setTimeout(()=>{document.activeElement===document.body&&(V=null)},0)},yt=sn=>{var ln,Vt,dr,Mr,Mn;if((ln=sn.data)!=null&&ln.__toyon)for(const[Ot,Ce]of Fe.current){if(Ce.contentWindow!==sn.source)continue;if(sn.origin!==Pe.current.get(Ot))return;const Te=W1(sn.data);if(!Te)return;if(Ot.startsWith(kd)){He.current(Ot.slice(kd.length),Te);return}switch(Te.type){case"key":window.dispatchEvent(new KeyboardEvent(Te.up?"keyup":"keydown",{key:Te.key,code:Te.code,metaKey:Te.meta,ctrlKey:!!Te.ctrl,shiftKey:!!Te.shift,altKey:!!Te.alt}));break;case"hmr":r({a:"hmr",id:Ot}),(Vt=l.current)==null||Vt.send({t:"page-loaded",worktreeId:Ot});break;case"loaded":ut.current.delete(Ot),vn.current.add(Ot),Ht(ht=>ht.includes(Ot)?ht:[...ht,Ot]),an.post(Ot,uT(de.current)),an.post(Ot,{type:"zen",on:M.current}),r({a:"hmr",id:Ot}),r({a:"page",id:Ot,url:Te.url,title:Te.title}),(dr=l.current)==null||dr.send({t:"page-loaded",worktreeId:Ot}),c.note(Ot,Te.url,Te.title);break;case"navigated":r({a:"page",id:Ot,url:Te.url,...Te.title!==void 0?{title:Te.title}:{}}),c.note(Ot,Te.url,Te.title);break;case"title":r({a:"page",id:Ot,title:Te.title}),c.title(Ot,Te.title);break;case"links":r({a:"links",id:Ot,links:Te.links});break;case"page-error":{const ht=v0(Te);ht&&((Mr=l.current)==null||Mr.send({t:"page-error",worktreeId:Ot,message:ht}));break}case"picked":{const{type:ht,verb:pt,site:Zt,...tn}=Te,W=Zt==="call"?{file:tn.callFile,line:tn.callLine}:{file:tn.file,line:tn.line};if(pt==="code"){r({a:"set-picking",v:!1});const me=(Mn=kn(o.getState(),Ot))==null?void 0:Mn.worktree;W.file?Wi(o,i,Ot,lE(W.file,me==null?void 0:me.path),W.line??1):i==null||i.send({t:"find-element",worktreeId:Ot,seq:Ko(),element:tn.element})}else YP(o,Ot,tn);break}case"pick-cancel":r({a:"set-picking",v:!1});break;case"drag-files":gk(o,o.getState().activeId?{at:"centre"}:null);break;case"drop-files":d_(o,i,o.getState().activeId?{at:"centre"}:null,E4(Te.files));break;case"focus":Te.gesture?V=null:document.activeElement===Ce&&(V!=null&&V.isConnected)&&V!==document.body&&V.focus();break;case"highlight-miss":console.warn(`[toyon] highlight miss on ${Te.path}: ${Te.fileMatched} elements from this file, ${Te.withSource} elements with source info on page, ranges=${JSON.stringify(Te.ranges)}`);break}return}};return window.addEventListener("message",yt),document.addEventListener("focusin",Ee),document.addEventListener("focusout",Ze),()=>{window.removeEventListener("message",yt),document.removeEventListener("focusin",Ee),document.removeEventListener("focusout",Ze)}},[r,o,i,c]),S.useEffect(()=>{an.broadcast({type:"zen",on:ue})},[ue]);const xt=S.useRef(new Map);St([ae==null?void 0:ae.id,ae==null?void 0:ae.n],()=>{if(!ae)return;const{id:V}=ae;clearTimeout(xt.current.get(V)),xt.current.set(V,setTimeout(()=>{xt.current.delete(V),an.post(V,{type:"reload"})},1200))});const kt=sk(),ot=kt&&!xn(kt)?kt:null,dt=Xi(),Tt=!!p&&p.procs.some(V=>V.status==="running"),Et=lk(),dn=Et!==null&&Et===h&&Tt;S.useEffect(()=>{Et&&dn&&!Q.includes(Et)&&we(V=>[...V,Et])},[Et,dn,Q]);const G=u.filter(V=>xn(V)&&V.procs.some(Ee=>Ee.status==="asleep")).map(V=>V.id).join(" ");S.useEffect(()=>{const V=new Set(G.split(" ").filter(Boolean));Q.some(Ee=>V.has(Ee))&&we(Ee=>Ee.filter(Ze=>!V.has(Ze)))},[G,Q]),S.useEffect(()=>{const V=Q.filter(Ee=>Ee!==Et).map(Ee=>setTimeout(()=>we(Ze=>Ze.filter(yt=>yt!==Ee)),L7));return()=>{for(const Ee of V)clearTimeout(Ee)}},[Q,Et]),S.useEffect(()=>{Ht(V=>V.every(Ee=>Q.includes(Ee))?V:V.filter(Ee=>Q.includes(Ee)))},[Q]);const ve=S.useMemo(()=>u.filter(xn).filter(V=>Q.includes(V.id)).map(V=>({id:V.worktree.id,port:V.worktree.proxyPort,title:V.worktree.title,url:Sd(V.worktree.id,V.worktree.proxyPort,w,b)})),[u,Q,w,b]),tt=S.useMemo(()=>te.flatMap(V=>{const Ee=u.find(yt=>yt.id===V.worktreeId);if(!Ee||!xn(Ee))return[];const Ze=Px(V.path,Sd(Ee.worktree.id,Ee.worktree.proxyPort,w,b));return Ze?[{id:`${kd}${V.id}`,path:V.path,url:Ze}]:[]}),[te,u,w,b]),it=Mm(E,w),ft=S.useMemo(()=>[...ve,...tt],[ve,tt]),Gt=p_(E,ft,it);Jt.current=V=>it?Gt.renew(V):Lx(Fe.current.get(V));const Ft=ve.filter(V=>{var Ee;return(Ee=u.find(Ze=>Ze.id===V.id))==null?void 0:Ee.procs.some(Ze=>Ze.status==="running")}).map(V=>V.id).join(" ");St([Ft],()=>{for(const V of Ft.split(" "))ut.current.has(V)&&Jt.current(V)});const An=P(V=>V.carryTo),[qn,zt]=S.useState(null),[bn,ye]=S.useState(Et),Me=S.useRef(null);bn!==Et&&(ye(Et),zt(g7({leaving:Me.current,arriving:Et,carryTo:An,repoOf:V=>{var Ee;return((Ee=u.find(Ze=>Ze.id===V))==null?void 0:Ee.repoId)??null}}))),S.useEffect(()=>{if(!qn)return;const V=setTimeout(()=>zt(null),P7);return()=>clearTimeout(V)},[qn]);const Bt=Et!==null&&We.includes(Et),jt=k7({previewId:Et,painted:Bt,ready:dn,carry:qn,mounted:Q}),fn=jt!==null&&jt!==Et;S.useEffect(()=>{Me.current=jt});const K=jt!==null&&!Ie&&!ke&&!O&&!z,[pe,_e]=S.useState(null),Xe=S.useCallback(V=>r({a:"preview-size",text:V}),[r]);I7(pe,K,Xe);const[qe,_t]=bo(Qe.editorHeight,0,V=>{const Ee=Number(V);return Number.isFinite(Ee)&&Ee>=120?Ee:0}),[Le,$e]=bo(Qe.designHeight,0,V=>{const Ee=Number(V);return Number.isFinite(Ee)&&Ee>0?Ee:0}),[Ge,Wt]=bo(Qe.designFull,!1,V=>V===null?void 0:V==="1"),[Mt,Tn]=bo(Qe.editorFull,!1,V=>V===null?void 0:V==="1"),[In,yn]=bo(Qe.termHeight,240,V=>{const Ee=Number(V);return Number.isFinite(Ee)&&Ee>=140?Ee:void 0}),wr=P(V=>V.termTall);St([wr],()=>{const V=t.current;wr&&V&&yn(Math.max(In,Math.round(V.clientHeight/2)))});const gn=V=>(Ee,Ze)=>{const yt=Ze.parentElement,sn=t.current;if(!yt||!sn)return null;let ln=0;for(const dr of Array.from(sn.querySelectorAll(":scope > .pane")))dr!==yt&&!dr.classList.contains("full")&&(ln+=dr.offsetHeight);const Vt=Math.max(sn.clientHeight-ln-80,V);return Math.min(Math.max(yt.getBoundingClientRect().bottom-Ee.clientY,V),Vt)},Nn=Ya(gn(120),V=>_t(Math.round(V))),ur=Ya(gn(160),V=>$e(Math.round(V))),nn=Ya(gn(140),V=>yn(Math.round(V))),en=P(V=>{var Ee,Ze;return p&&$r(p.worktree)?((Ze=(Ee=V.rows.find(yt=>{var sn;return yt.repoId===p.worktree.repoId&&((sn=yt.worktree)==null?void 0:sn.kind)==="worktree"}))==null?void 0:Ee.worktree)==null?void 0:Ze.title)??null:null}),Kt=lD({connected:m,heard:g,connectFailure:y,hasToken:E.serving?M7:!0,projectChord:Lt("project"),title:(p==null?void 0:p.worktree.title)??null,machine:E.serving?null:_.displayName(E.origin),needsSetup:!!H,busy:he,treeEmpty:ie,landsFrom:en});return d.jsxs("div",{className:"center-root",ref:n,children:[d.jsx("div",{className:Ue("center-area",J&&"drop-over"),style:{display:!(ue&&!z)&&(N&&Mt||X&&Ge)?"none":void 0},children:d.jsxs("div",{className:"frames-wrap",ref:_e,children:[ve.map(V=>d.jsx("iframe",{ref:Ee=>{Ee?(Fe.current.set(V.id,Ee),Pe.current.set(V.id,new URL(V.url).origin)):(Fe.current.delete(V.id),Pe.current.delete(V.id),ut.current.delete(V.id),vn.current.delete(V.id))},onLoad:()=>{vn.current.delete(V.id)?ut.current.delete(V.id):ut.current.add(V.id)},src:Gt.urlOf(V.id)??void 0,title:V.title,style:{display:K&&V.id===jt?"block":"none"}},V.id)),tt.map(V=>d.jsx("iframe",{ref:Ee=>{Ee?(Fe.current.set(V.id,Ee),Pe.current.set(V.id,new URL(V.url).origin)):(Fe.current.delete(V.id),Pe.current.delete(V.id))},onLoad:()=>He.current(V.id.slice(kd.length),{type:"frame-load"}),src:Gt.urlOf(V.id)??void 0,title:`checking ${V.path}`,style:{display:"none"}},V.id)),R?d.jsx(E7,{project:R}):d.jsxs(d.Fragment,{children:[ke&&d.jsx(y7,{pending:ke},ke.id),T&&p&&!ke&&d.jsx(w7,{active:p},p.worktree.id),Ie&&!ke&&!T&&d.jsx(j7,{repo:Ie,onClose:ge?void 0:()=>r({a:"close"})},`${Ie.id}:${JSON.stringify(Ie.config)}`),ot&&!Ie&&!ke&&!dt&&d.jsx(gc,{placement:"centre",found:ot},ot.id),dt&&!Ie&&!ke&&d.jsx(gc,{placement:"centre",archived:dt},dt.id),!Tt&&!ot&&!dt&&!Ie&&!ke&&!T&&ne&&d.jsx(b_,{foreign:E.serving?void 0:_.displayName(E.origin)}),!Tt&&!ot&&!dt&&!Ie&&!ke&&!T&&!ne&&(Kt!==null?d.jsx(Ts,{wide:!0,children:d.jsx("p",{className:"status-line",children:Kt})}):z?d.jsx(gc,{placement:"centre"}):fn?null:p&&d.jsx(p7,{worktree:p,log:oe}))]})]})}),N&&d.jsx(qN,{editor:N,height:Mt?"100%":qe>0?qe:"45%",full:Mt,onToggleFull:()=>Tn(!Mt),onDragStart:Nn}),X&&h&&!dt&&d.jsx(FU,{worktreeId:h,height:Ge?"100%":Le>0?Le:"55%",full:Ge,onToggleFull:()=>Wt(!Ge),onDragStart:ur},`design:${h}`),B&&h&&!dt&&d.jsx(d7,{worktreeId:h,opened:D,height:In,onDragStart:nn},`term:${h}`),d.jsx(eT,{})]})}function B7({width:e}){const t=P(r=>r.layout.chat),n=Bc();return d.jsx(gc,{placement:"dock",className:!t||n?"collapsed":void 0,width:e})}function U7(e,t){const n=[];return e&&(n.push(GE(e)),n.push({id:"copy-url",label:"copy URL",onClick:()=>on(e)})),zn([n,[{id:"reload",label:"reload preview",key:Lt("reload"),onClick:t.reload}]])}const H7=520,cm=8;function W7({winW:e,centre:t,leadRight:n,toolsLeft:r}){const o=t.right-t.left,i=Math.max(0,Math.min(H7,Math.floor(e*.4),o-2*cm)),l=t.left+(o-i)/2,c=n+cm,u=r-cm-i,h=Math.max(Math.min(l,u),c);return{left:Math.round(h),width:i}}function K7({center:e}){const t=YL(),n=DE(e),r=S.useRef(null);rP(r);const[o,i]=P0(),[l,c]=P0(),u=W7({winW:t,centre:n,leadRight:i.right,toolsLeft:c.left}),h=lt(),p=ct(),m=Zn(),g=wn("bar"),y=Ss(),w=Uc(),b=P(X=>X.zen)&&!w,E=P(X=>X.layout.changes),_=P(X=>X.layout.chat),N=Bc(),T=P(X=>X.layout.design),R=P(X=>{var ae;return((ae=X.overlay)==null?void 0:ae.kind)==="keys"}),O=X7(),B=(y==null?void 0:y.worktree.id)??null,$=P(X=>X.archivedPage!==null),C=!!y&&Qg(y)&&!$,j=P(X=>X.chatSide)==="left",D=!N&&d.jsx(Pt,{icon:"branch",label:"Changes panel",hint:Lt("changes"),tone:"chrome",on:E,onClick:()=>h({a:"toggle-changes"})}),z=!N&&!w&&d.jsx(Pt,{icon:"chat",label:"Chat panel",hint:Lt("composer"),tone:"chrome",on:_,onClick:()=>h({a:"toggle-chat"})});return d.jsxs("div",{className:"top-bar",ref:r,children:[b&&d.jsx("span",{className:"bar-zen-title",children:(y==null?void 0:y.worktree.title)??"Toyon"}),d.jsxs("span",{className:"bar-lead",ref:o,children:[j?z:D,d.jsx(Z7,{}),O&&d.jsx(qf,{icon:"download","data-tip":"Install Toyon as an app (own window, dock icon)",onClick:()=>void O.prompt(),children:"install app"}),d.jsx(G7,{}),d.jsx(V7,{})]}),!w&&d.jsx(q7,{worktreeId:B,repoId:(y==null?void 0:y.repoId)??null,ready:C,left:u.left,width:u.width}),d.jsx("span",{className:"bar-grow"}),d.jsxs("span",{className:"bar-tools",ref:l,children:[d.jsx(Y7,{}),d.jsx(Pt,{icon:"settings",label:"Settings & shortcuts",hint:Lt("keys"),tone:"chrome",on:R,"aria-controls":"keys-help","aria-expanded":R,onClick:()=>h({a:"toggle",overlay:{kind:"keys"}}),...g.contextMenu(()=>iN(m.getState(),{sock:p,dispatch:h}))}),!N&&!w&&d.jsx(Pt,{icon:"palette",label:"Design system",hint:Lt("design"),tone:"chrome",on:T,onClick:()=>h({a:"toggle-design"})}),j?D:z,!w&&d.jsx(Pt,{icon:"zen",className:"bar-zen",label:"Full-bleed preview",hint:Lt("zen"),tone:"chrome",on:b,onClick:()=>h({a:"toggle-zen"})})]})]})}function Z7(){const e=lt(),t=ct(),n=fl(),r=P(p=>p.activeRepoId),o=P(p=>p.repos),i=wn("bar"),l=()=>zn([[{id:"project",label:o.length>1?"switch project…":"open project…",key:Lt("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?Hf(n,r,{sock:t,dispatch:e}):[]]),c=P(p=>{var m;return((m=p.overlay)==null?void 0:m.kind)==="projects"&&p.overlay.form==="pill"}),u=P(p=>p.heard),h=P(p=>p.newProject!==null);return d.jsxs("span",{className:"bar-project",children:[d.jsx(ze,{tone:"chrome",className:"bar-pill",on:c,...Ut(o.length>1?"Switch project":"Open a project",Lt("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(lw,{form:"pill"})]})}function q7({worktreeId:e,repoId:t,ready:n,left:r,width:o}){const i=It(e,"page").url,l=EN(i),c=lt(),u=P(b=>{var E;return((E=b.overlay)==null?void 0:E.kind)==="routes"}),h=P(b=>b.previewSize),p=()=>{n&&e&&t&&!u&&c({a:"open",overlay:{kind:"routes"}})};St([e,n],()=>{u&&c({a:"close"})});const g=wn("bar").contextMenu(()=>n?U7(i,{reload:()=>e&&an.post(e,{type:"reload"})}):[]),y=P(b=>b.picking),w=lk();return d.jsxs("div",{className:"bar-center",style:{left:r,width:o},children:[d.jsx(Pt,{icon:"back",label:"Back",hint:Lt("back"),disabled:!n,onClick:()=>e&&an.post(e,{type:"back"}),...g}),d.jsx(Pt,{icon:"forward",label:"Forward",hint:Lt("forward"),disabled:!n,onClick:()=>e&&an.post(e,{type:"forward"}),...g}),d.jsx(Pt,{icon:"reload",label:"Reload preview",hint:Lt("reload"),disabled:!n,onClick:()=>e&&an.post(e,{type:"reload"}),...g}),d.jsxs("span",{className:"bar-route",children:[d.jsx(Eo,{className:"bar-path",value:n?l:"",readOnly:!0,disabled:!n,placeholder:n?"/":"",onMouseDown:b=>{b.button===0&&b.preventDefault()},onClick:p,onFocus:p,spellCheck:!1,...Ut("Go to a page",Lt("routes"))}),u&&n&&e&&t&&d.jsx(W8,{worktreeId:e,repoId:t,url:i},e),h&&d.jsx("span",{className:"bar-size",children:h})]}),d.jsx(Pt,{icon:"inspect",label:"Pick an element to open its code",hint:Lt("inspect"),also:{text:"Add an element to chat",key:Lt("pick")},on:y==="code",disabled:!n||!w,onClick:()=>w&&Nc(w,y,c,"code")})]})}function qf({icon:e,busy:t,children:n,...r}){return d.jsxs(ze,{disabled:t,...r,children:[!t&&d.jsx(Nt,{name:e,className:"icon-inline"}),d.jsx("span",{className:Ue(t&&"live-text"),children:n})]})}function G7(){const e=P(u=>u.self),t=P(u=>u.rebuilt),n=P(u=>u.repos),r=ct(),o=P(u=>{var h;return((h=u.update)==null?void 0:h.restarting)!=null}),i=GN(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(qf,{icon:"reload",busy:i.busy,onClick:c,...Ut(i.text,void 0,{detail:i.detail}),children:l})}function V7(){const e=P(o=>o.update),t=P(o=>o.managed.updates),n=ct(),r=tD(e);return!r||!t?null:d.jsx(qf,{icon:"reload",busy:r.busy,onClick:()=>{r.retry&&(n==null||n.send({t:"update-now"}))},...Ut(r.text),children:r.word})}function Y7(){const e=lt(),t=P(OL),n=P(i=>i.letIn),r=P(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(Pt,{icon:"devices",label:"Your devices",tone:"chrome",on:r,"aria-expanded":r,onClick:o}):d.jsx(qf,{icon:"devices","aria-expanded":r,onClick:o,...Ut("Open this machine on your phone, and let it in"),children:"open on phone"})}function X7(){const[e,t]=S.useState(null);return S.useEffect(()=>{if(Sf())return;const n=o=>{o.preventDefault(),t(o)},r=()=>t(null);return window.addEventListener("beforeinstallprompt",n),window.addEventListener("appinstalled",r),()=>{window.removeEventListener("beforeinstallprompt",n),window.removeEventListener("appinstalled",r)}},[]),e}function Q7(e,t,n){return t==="left"?n-e.left:e.right-n}const J7="input, textarea, [contenteditable], .monaco-editor, .xterm, iframe";function eH(){const e=Zn(),t=lt(),n=ct(),r=Bc(),o=pi(),i=Uc(),l=P(M=>M.zen)&&!i,c=Xi(),u=!!ak()||!!c,h=P(M=>M.layout.changes)&&!r,p=P(M=>M.layout.chat)&&!r&&!i&&!u,m=P(M=>M.chatSide),g=P(M=>M.railOpen),[y,w]=bo(Qe.changesWidth,220,M=>M?id(Number(M),220):void 0),[b,E]=bo(Qe.chatWidth,380,M=>M?id(Number(M),380):void 0),[_,N]=bo(Qe.railWidth,280,M=>M?id(Number(M),280):void 0),T=(M,oe,ne)=>{const H=oe.classList.contains("left")?"left":"right",se=H==="left"?oe.previousElementSibling:oe.nextElementSibling;return se?id(Q7(se.getBoundingClientRect(),H,M.clientX),ne):null},R=Ya((M,oe)=>T(M,oe,220),w),O=Ya((M,oe)=>T(M,oe,380),E),B=Ya((M,oe)=>T(M,oe,280),N),[$,C]=S.useState(null),D=wn("app").contextMenu(()=>eN(e.getState(),{sock:n,dispatch:t})),z=d.jsx(B_,{width:y}),X=!i&&!u&&d.jsx(B7,{width:b}),ae=!r&&d.jsx(nT,{width:_}),A=M=>!r&&g&&d.jsx("div",{className:`dock-resize ${M}`,onPointerDown:B}),de=m==="left",ue=de?{dock:X,open:p,drag:O}:{dock:z,open:h,drag:R},J=de?{dock:z,open:h,drag:R}:{dock:X,open:p,drag:O};return d.jsxs("div",{className:Ue("app",l&&"zen"),"data-chat-side":m,"data-touch":o||void 0,"data-hover":!o||void 0,onContextMenu:M=>{M.defaultPrevented||M.target instanceof Element&&M.target.closest(J7)||D.onContextMenu(M)},children:[d.jsx(m_,{}),d.jsx(y_,{}),d.jsx(K7,{center:$}),d.jsxs("div",{className:"docks",children:[de&&ae,de&&A("left"),ue.dock,ue.open&&d.jsx("div",{className:"dock-resize left",onPointerDown:ue.drag}),d.jsx(F7,{onRoot:C}),J.open&&d.jsx("div",{className:"dock-resize right",onPointerDown:J.drag}),J.dock,!de&&A("right"),!de&&ae]})]})}function tH(e){return e.altKey?"Alt":e.ctrlKey?"Control":e.metaKey?"Meta":null}function nH(e,t){return t==="Alt"?e.altKey:t==="Control"?e.ctrlKey:e.metaKey}const rH=200,oH={set:(e,t)=>setTimeout(e,t),clear:e=>clearTimeout(e)};function sH(e,t=oH){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=tH(u),l(),n&&(h?i():o=t.set(()=>{o=null,i()},rH))},keyup(u){n&&u===n&&c()},mods(u){n&&!nH(u,n)&&c()},end:c}}function iH(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 aH=new Set(["design","chats"]),lH=new Set(["reload","back","forward"]),cH=new Set(["project","commands","keys","zen"]);function uH(){const e=Zn(),t=ct();S.useEffect(()=>{const n=sH(p=>e.dispatch({a:"rail-peek",on:p})),r=n.end,o=p=>{e.getState().railOpen||n.press(p)},i=p=>n.keyup(p.key),l=p=>n.mods(p),c=()=>{var y,w;const p=e.getState(),g=((w=(y=document.activeElement)==null?void 0:y.closest("[data-pane]"))==null?void 0:w.dataset.pane)??(p.layout.term?"terminal":p.editor?"editor":p.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=p=>{p.key!=="Escape"||!e.getState().choosingFolder||(p.stopImmediatePropagation(),t==null||t.send({t:"cancel-folder"}),e.dispatch({a:"choosing-folder",v:!1}))},h=p=>{var E,_,N,T;l(p),Yj(p)&&!p.defaultPrevented&&p.preventDefault();const m=e.getState(),{dispatch:g}=e,y=R=>{const O=document.activeElement,B=!O||O===document.body||!!O.closest(".rail, .chat-input");g({a:"activate",id:R}),B&&g({a:"walked"})},w=Xx(p,{guest:!!((E=document.activeElement)!=null&&E.closest(".xterm"))});if(!(m.zen&&!xo(m)&&!m.overlay&&!m.picking&&!(w&&Vj.has(w.id))||(w==null?void 0:w.id)==="close"&&!Sf()||(_=document.activeElement)!=null&&_.closest(".monaco-editor")&&w&&aH.has(w.id))&&!(w&&tC(w.id,document.activeElement))&&!(w&&lH.has(w.id)&&!(nc(m)&&Wd(m)))){if(w){const R=p.defaultPrevented;if(p.preventDefault(),m.newProject&&!cH.has(w.id))return;switch(w.id){case"worktree":{const O=Qj(w.digit,m.visible.length),B=O===null?void 0:m.visible[O];B&&y(B.id);break}case"wt-prev":case"wt-next":{const O=iH(m.visible,m.visibleDiscovered,m.activeId,w.id==="wt-next"?1:-1);O&&y(O.activate),o(p);break}case"wt-unseen-prev":case"wt-unseen-next":{const O=Dg(m.visible,m.activeId,w.id==="wt-unseen-next"?1:-1);O&&y(O.activate),o(p);break}case"mark-unread":m.activeId&&!m.draft&&m.visible.some(O=>O.id===m.activeId)&&N_(t,g,m.activeId);break;case"wt-archive":{if(p.repeat||R)break;const O=m.draft||m.archivedPage?void 0:m.visible.find(B=>B.id===m.activeId);O&&yk(t,g).archive(O);break}case"new":g({a:"open-draft"});break;case"project":g({a:"toggle",overlay:{kind:"projects",form:"center"}});break;case"quick-open":((N=m.overlay)==null?void 0:N.kind)==="quick-open"?g({a:"close"}):m.activeId&&g({a:"open",overlay:{kind:"quick-open"}});break;case"routes":((T=m.overlay)==null?void 0:T.kind)==="routes"?g({a:"close"}):Wd(m)&&g({a:"open",overlay:{kind:"routes"}});break;case"reload":case"back":case"forward":{const O=nc(m);O&&an.post(O,{type:w.id});break}case"pick":case"inspect":{const O=nc(m);O&&Nc(O,m.picking,g,w.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&&!xo(m))&&!m.overlay&&c();break;case"changes":g(m.layout.changes&&(sl(m)==="changes"||No(m)!==null)?{a:"toggle-changes"}:{a:"focus-changes",tab:"changes"});break;case"files":g(m.layout.changes&&sl(m)==="files"?{a:"toggle-changes"}:{a:"focus-changes",tab:"files"});break;case"panel-tab-prev":case"panel-tab-next":if(Nf(m))break;g(m.layout.changes?{a:"focus-changes",tab:bL(m,w.id==="panel-tab-next"?1:-1)}:{a:"focus-changes"});break;case"composer":g(yE(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 O=m.rows.find(j=>j.id===m.activeId);if(!O)break;const B=_o(m,m.activeId).termStream;if(O.login&&B===Es)break;const $=[vo,...O.login?[Es]:[],...O.procs.map(j=>j.name)],C=$.indexOf(B);g({a:"term-stream",id:O.id,stream:$[(C+1)%$.length]??vo});break}}}else if(p.key==="Escape")if(m.newProject)m.newProject.phase==="editing"&&g({a:"close-new-project"});else if(m.picking){const R=nc(m);R&&an.post(R,{type:"pick-cancel"}),g({a:"set-picking",v:!1})}else 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&&an.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 dH=3,fH=2e3,hH=200,pH=5e3;function mH(){const e=Zn(),t=lt(),n=ct(),{storage:r}=so(),o=dl(),i=P(ie=>ie.activeRepoId),l=Ss(),c=sk(),u=P(ie=>ie.connected),h=P(ie=>ie.daylight),p=P(ie=>{var he;return((he=ie.daylight)==null?void 0:he.until)??0}),m=Xi(),g=P(ie=>ie.railOpen),y=P(ie=>ie.chatSide),w=P(ie=>ie.layouts),b=P(ie=>ie.lastActive),E=P(ie=>ie.discoveredOpen),_=P(ie=>ie.archivedOpen),N=P(ie=>ie.committedShut),T=P(ie=>ie.turnOpen),R=P(ie=>ie.treeOpen),O=jf(),B=P(ie=>ie.previewTheme!==null),$=P(ie=>ie.openUrl),C=FE();S.useEffect(()=>Kd.install(window),[]);const j=S.useRef([]);S.useEffect(()=>{if(!n||!u||!o)return;const ie=[o,...j.current.filter(he=>he!==o)];for(const he of ie.splice(dH))n.send({t:"unsubscribe",worktreeId:he});j.current.includes(o)||n.send({t:"subscribe",worktreeId:o}),j.current=ie},[o,u,n]),S.useEffect(()=>{if(!(!n||!u))for(const ie of j.current)n.send({t:"subscribe",worktreeId:ie})},[u,n]);const D=S.useRef(void 0);S.useEffect(()=>{if(!n||!u)return;let ie;const he=()=>{const ke=document.visibilityState==="visible"?o:null;n.send({t:"view",worktreeId:ke}),D.current=ke},ge=()=>{clearTimeout(ie),ie=setTimeout(he,hH)};D.current===void 0||D.current===o||document.visibilityState!=="visible"?he():ge();const Ie=()=>document.visibilityState==="visible"?ge():he();return document.addEventListener("visibilitychange",Ie),()=>{clearTimeout(ie),document.removeEventListener("visibilitychange",Ie)}},[o,u,n]);const z=(m==null?void 0:m.id)??null;S.useEffect(()=>{if(!(!n||!u||!z))return n.send({t:"subscribe",worktreeId:z}),()=>n.send({t:"unsubscribe",worktreeId:z})},[z,u,n]),S.useEffect(()=>{const ie=new Set(C.map(ge=>ge.id)),he=j.current.filter(ge=>!ie.has(ge));if(he.length!==0&&(j.current=j.current.filter(ge=>ie.has(ge)),!(!n||!u)))for(const ge of he)n.send({t:"unsubscribe",worktreeId:ge})},[C,u,n]);const X=(m==null?void 0:m.title)??(c==null?void 0:c.name)??null;S.useEffect(()=>{document.title=X?`${X} · Toyon`:"Toyon"},[X]);const ae=!!(l!=null&&l.unseen),A=P(ie=>ie.unreadHold!==null&&ie.unreadHold===ie.activeId);S.useEffect(()=>{if(!n||!o||!ae||A)return;let ie;const he=()=>document.visibilityState==="visible"&&document.hasFocus(),ge=()=>{clearTimeout(ie),he()&&(ie=setTimeout(()=>{he()&&n.send({t:"seen",worktreeId:o})},fH))},Ie=()=>clearTimeout(ie);return ge(),window.addEventListener("focus",ge),window.addEventListener("blur",Ie),()=>{Ie(),window.removeEventListener("focus",ge),window.removeEventListener("blur",Ie)}},[n,o,ae,A]);const de=S.useRef(0),ue=P(ie=>Xg(ie));S.useEffect(()=>{if(!n||!u||!i)return;const ie=()=>{Date.now()-de.current<pH||(de.current=Date.now(),n.send({t:"refresh-git",repoId:i}),ue&&ue!==i&&n.send({t:"refresh-git",repoId:ue}))};return window.addEventListener("focus",ie),()=>window.removeEventListener("focus",ie)},[n,u,i,ue]),S.useEffect(()=>{cT(O,{remember:!B}),an.broadcast(uT(O))},[O,B]);const J=S.useCallback(()=>{n==null||n.send({t:"zone",tz:Intl.DateTimeFormat().resolvedOptions().timeZone})},[n]);S.useEffect(()=>{if(!u)return;J();const ie=()=>{document.visibilityState==="visible"&&J()};return document.addEventListener("visibilitychange",ie),()=>document.removeEventListener("visibilitychange",ie)},[u,J]),S.useEffect(()=>{if(!u||p<=Date.now())return;const ie=setTimeout(J,p-Date.now()+1e3);return()=>clearTimeout(ie)},[u,p,J]),S.useEffect(()=>{h&&h.until>0&&LU(h)},[h]),S.useEffect(()=>{o&&r.set(Qe.active,o)},[o,r]);const M=P(ie=>ie.frame==="phone"?ie.screen!=="home":null);S.useEffect(()=>{M!==null&&r.session.set(Qe.phoneRow,M?"1":"0")},[M,r]);const oe=P(ie=>ie.frame==="phone"&&ie.screen==="home"?"surface1":"surface0");S.useEffect(()=>{try{sessionStorage.setItem(Qe.ground,oe)}catch{}},[oe]),S.useEffect(()=>{i&&r.set(Qe.repo,i)},[i,r]),S.useEffect(()=>{try{localStorage.setItem(Qe.rail,g?"1":"0")}catch{}},[g]),S.useEffect(()=>{try{localStorage.setItem(Qe.chatSide,y)}catch{}},[y]),S.useEffect(()=>{try{localStorage.setItem(Qe.layouts,JSON.stringify(w))}catch{}},[w]),S.useEffect(()=>{r.set(Qe.lastActive,JSON.stringify(b))},[b,r]),S.useEffect(()=>{r.set(Qe.discoveredOpen,JSON.stringify(E))},[E,r]),S.useEffect(()=>{r.set(Qe.archivedOpen,JSON.stringify(_))},[_,r]),S.useEffect(()=>{r.set(Qe.committedShut,JSON.stringify(N))},[N,r]),S.useEffect(()=>{r.set(Qe.turnOpen,JSON.stringify(T))},[T,r]),S.useEffect(()=>{r.set(Qe.treeOpen,JSON.stringify(R))},[R,r]),uH(),T4();const ne=S.useRef(null);S.useEffect(()=>{!$||ne.current===$||(ne.current=$,window.open($,"_blank"),t({a:"opened-url"}))},[$,t]);const H=S.useRef(null);return St([o],()=>{var te,Z,je,He;const ie=H.current;if(H.current=o,!ie||!o||ie===o)return;const he=e.getState(),ge=C.find(Fe=>Fe.id===ie),Ie=C.find(Fe=>Fe.id===o),ke=(Z=(te=ge==null?void 0:ge.worktree)==null?void 0:te.variant)==null?void 0:Z.group;if(!ke||((He=(je=Ie==null?void 0:Ie.worktree)==null?void 0:je.variant)==null?void 0:He.group)!==ke)return;const Q=Fe=>{var Pe;try{const We=(Pe=he.local[Fe])==null?void 0:Pe.page.url;return We?new URL(We).pathname+new URL(We).search:"/"}catch{return"/"}},we=Q(ie);we!==Q(o)&&an.post(o,{type:"navigate",path:we})}),P(ie=>ie.frame)==="phone"?d.jsx(TU,{}):d.jsx(eH,{})}function gH({origin:e,machine:t,onToken:n}){const[r,o]=S.useState({kind:"asking"}),[i,l]=S.useState(0);return St([i],()=>{const c=new AbortController;return o({kind:"asking"}),oE(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(Ts,{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.":QN(r.failure,e,"this device")}),r.kind==="failed"&&d.jsx("div",{className:"status-actions",children:d.jsx(ze,{variant:"outline",onClick:()=>l(c=>c+1),children:"ask again"})})]})}function kH(){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(Pj(t.worktreeId,t.stream))??[])n(t)}}}function wH(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 yH(e){const t={};try{const n=JSON.parse(e??"{}");if(!n||typeof n!="object")return t;for(const[r,o]of Object.entries(n))fL(o)&&(t[r]=o)}catch{}return t}function vH(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 wd(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 bH(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 xH=400,EH=2e3;function wT(){const e=new Map;return{another(t,n=0){return(e.get(t)??0)===n?!1:(e.set(t,n),!0)}}}function yT(e,t,n){const r=e.getState(),o=[];for(const[i,l]of t){if(l===n||r.local[i])continue;const c=os(i);c&&c.clientId!==r.clientId||o.push(i)}return o}function _H(e,t){const n=new Map,r=new Map,o=wT(),i=u=>{var p,m;clearTimeout((p=r.get(u))==null?void 0:p.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,p;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 y=r.get(m);if((y==null?void 0:y.text)===g.draft)continue;clearTimeout(y==null?void 0:y.timer);const w=(y==null?void 0:y.since)??Date.now(),b=Math.max(0,Math.min(xH,w+EH-Date.now()));r.set(m,{text:g.draft,timer:setTimeout(i,b,m),since:w})}for(const m of yT(e,n,""))clearTimeout((p=r.get(m))==null?void 0:p.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,p]of Object.entries(u))n.set(h,p)},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 SH(e,t){const n=new Map,r=new Map,o=wT(),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=Gg(u.attachments),p=JSON.stringify(h),m=r.get(c)??"[]";m!==p&&(r.set(c,p),l.push({id:c,items:h,before:pE(JSON.parse(m))}))}for(const c of yT(e,r,"[]"))r.set(c,"[]"),l.push({id:c,items:[],before:[]});for(const c of cL(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 NH(e,t){return e.subscribe(()=>{for(const n of lL(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(tc(o.outgoing.frame,n,o.draft,o.attachments)),e.dispatch({a:"sent-out",id:n}))}})}const Dx="not sent: the page reloaded while an upload was on its way; attach it again and send";function zx(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=os(c);if((u==null?void 0:u.clientId)!==r.clientId||(l=r.local[c])!=null&&l.outgoing)continue;const h=n.drafts[c]??"",p=n.attachments[c]??[],m=n.drafts[u.source]??"",g=[...p,...n.attachments[u.source]??[]],y=m||h,w=r.clientId;g.length&&t.send({t:"set-attachments",boxId:u.source,items:g,clientId:w}),y!==m&&t.send({t:"set-draft",boxId:u.source,text:y,clientId:w}),t.send({t:"set-attachments",boxId:c,items:[],clientId:w}),t.send({t:"set-draft",boxId:c,text:"",clientId:w}),delete n.drafts[c],delete n.attachments[c],y&&(n.drafts[u.source]=y),g.length&&(n.attachments[u.source]=g),i.push(u.source)}return i}function TH(e,t){const n=(t.storage??mM)(e.origin),r=KL(pL({cached:t.cached,systemDark:t.systemDark,daylight:t.daylight,storedActive:n.get(Qe.active),storedPhoneRow:n.session.get(Qe.phoneRow)==="1",storedRepo:n.get(Qe.repo),storedRailOpen:um(Qe.rail)==="1",storedChatSide:um(Qe.chatSide)==="right"?"right":"left",storedLayouts:yH(um(Qe.layouts)),storedLastActive:vH(n.get(Qe.lastActive)),storedDiscoveredOpen:wd(n.get(Qe.discoveredOpen)),storedArchivedOpen:wd(n.get(Qe.archivedOpen)),storedCommittedShut:wd(n.get(Qe.committedShut)),storedTurnOpen:wd(n.get(Qe.turnOpen)),storedTreeOpen:bH(n.get(Qe.treeOpen)),clientId:t.clientId,frame:t.frame,touch:t.touch})),o=kH(),i={version:null,protocol:null},l=p5(w=>r.dispatch({a:"server",msg:w}));let c,u,h,p=[];const m=new OM(e,w=>{if(w.t==="hello"){if(i.protocol=w.protocol,e.serving){const{rebuilt:E,update:_}=r.getState(),N=E&&(_==null?void 0:_.restarting)!=null;if(i.version!==null&&(N||w.version!==i.version||w.protocol!==od)){m.dispose(),t.reload();return}if(w.protocol!==od){r.dispatch({a:"incompatible"}),m.dispose();return}}else if(w.protocol!==od){r.dispatch({a:"incompatible"}),m.suspend();return}else r.getState().incompatible&&r.dispatch({a:"incompatible",v:!1});i.version=w.version;const b=new Set(m.sentWhileDown());if(b.size){const E=_=>Object.fromEntries(Object.entries(_).filter(([N])=>!b.has(N)));w.drafts=E(w.drafts),w.attachments=E(w.attachments)}p=zx(r,m,w),c.hello(w.drafts),u.hello(w.attachments)}if(w.t==="attachments"&&w.clientId!==r.getState().clientId&&u.heard(w.boxId,w.items),!(w.t==="draft"&&w.clientId!==r.getState().clientId&&!c.heard(w.boxId,w.text))){if(a2(w)){o.deliver(w);return}if(l2(w)){if(w.t==="file-written"&&UP(w))return;h.receive(w);return}if(w.t==="loose-written"){P9(w);return}if(Sz(w)){Cz(r,m,w);return}if(w.t==="open-refused"){jz(r,w);return}l(w);for(const b of p.splice(0))r.dispatch({a:"notice",id:b,text:Dx})}},(w,b)=>r.dispatch({a:"connected",v:w,failure:b}));ZP(r,m.urls),h=new M9({store:r,send:w=>m.send(w),timers:{set:(w,b)=>setTimeout(w,b),clear:w=>clearTimeout(w)},win:window});const g=h.start();c=_H(r,m),u=SH(r,m);const y=NH(r,m);return{origin:e.origin,serving:e.serving,token:e.token,get name(){return r.getState().machine??wH(e.origin)},store:r,sock:m,files:h,terminals:o,storage:n,heard:i,boot(w){if(w.t!=="hello"||w.protocol!==od)return;i.version??(i.version=w.version);const b=zx(r,m,w);u.hello(w.attachments),r.dispatch({a:"server",msg:w});for(const E of b)r.dispatch({a:"notice",id:E,text:Dx})},dispose(){m.dispose(),g(),c.dispose(),u.dispose(),y()}}}function um(e){try{return localStorage.getItem(e)}catch{return null}}window.__toyonShell=!0;window.top!==window&&(document.documentElement.dataset.framed="");kM(location.origin);const vT=RU();cT(vT);function jH(e,t){try{return e.getItem(t)}catch{return null}}function CH(){const e=jH(sessionStorage,Qe.client);if(e)return e;const t=Math.random().toString(36).slice(2,10);try{sessionStorage.setItem(Qe.client,t)}catch{}return t}const AH={cached:vT,systemDark:$U(),daylight:MU(),clientId:CH(),frame:lT(),touch:AU(),reload:()=>window.location.reload()},ci=JB({serving:{origin:location.origin,token:Q1()},build:e=>TH(e,AH)});IU({dispatch:e=>ci.broadcast(e)});PU(e=>ci.broadcast({a:"system-dark",v:e}));let Fx=sT(ci.active().store),Bx=ci.active();ci.subscribe(()=>{const e=ci.active();e!==Bx&&(Bx=e,Fx(),e.store.getState().frame==="phone"&&e.store.dispatch({a:"screen",to:"home"}),Fx=sT(e.store))});window.addEventListener("vite:preloadError",nD);const IH=(window.toyonBoot??Promise.resolve(null)).then(e=>{const t=e;t&&typeof t=="object"&&t.t==="hello"&&ci.active().boot(t)});function RH(e){J1(e),window.location.reload()}const $H=Ij.createRoot(document.getElementById("root"));IH.then(()=>{Cj.flushSync(()=>$H.render(d.jsx(Sj.StrictMode,{children:d.jsx(wk,{children:Mg()?d.jsx(qL,{machines:ci,children:d.jsx(mH,{})}):d.jsx(gH,{origin:location.origin,machine:location.host,onToken:RH})})}))),document.documentElement.style.removeProperty("background")});"serviceWorker"in navigator&&navigator.serviceWorker.register("/sw.js").catch(()=>{});export{Ns as F,ig as _,to as a,$g as b,DH as c,LH as d,Qx as e,Pj as f,rz as g,iM as h,Tk as i,d as j,MH as k,Xx as m,PH as p,S as r,J2 as s,Pc as t,St as u,f0 as w};