toyon 0.19.0 → 0.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/CHANGELOG.md +33 -0
- package/dist/cli.js +1 -1
- package/dist/daemon.js +604 -91
- package/dist/shell/assets/{Editor-B-1lrUVF.js → Editor--Z8ktewC.js} +3 -3
- package/dist/shell/assets/Editor--Z8ktewC.js.br +0 -0
- package/dist/shell/assets/Editor--Z8ktewC.js.gz +0 -0
- package/dist/shell/assets/{XTerm-CZl-vWEO.js → XTerm-DsUQ0Xew.js} +1 -1
- package/dist/shell/assets/XTerm-DsUQ0Xew.js.br +0 -0
- package/dist/shell/assets/XTerm-DsUQ0Xew.js.gz +0 -0
- package/dist/shell/assets/{cssMode-BpigOakf.js → cssMode-BjAkCPrp.js} +1 -1
- package/dist/shell/assets/cssMode-BjAkCPrp.js.br +0 -0
- package/dist/shell/assets/cssMode-BjAkCPrp.js.gz +0 -0
- package/dist/shell/assets/{freemarker2-vvh2KLdJ.js → freemarker2-BZCFxXwq.js} +1 -1
- package/dist/shell/assets/freemarker2-BZCFxXwq.js.br +0 -0
- package/dist/shell/assets/freemarker2-BZCFxXwq.js.gz +0 -0
- package/dist/shell/assets/{grammar-DBMSnNcB.js → grammar-CQ1uaD6_.js} +1 -1
- package/dist/shell/assets/{grammar-DBMSnNcB.js.br → grammar-CQ1uaD6_.js.br} +0 -0
- package/dist/shell/assets/grammar-CQ1uaD6_.js.gz +0 -0
- package/dist/shell/assets/{handlebars-ExFAR1bz.js → handlebars-G1zJeDLP.js} +1 -1
- package/dist/shell/assets/handlebars-G1zJeDLP.js.br +0 -0
- package/dist/shell/assets/handlebars-G1zJeDLP.js.gz +0 -0
- package/dist/shell/assets/{html-DpIWoe_L.js → html-CUHSCFMy.js} +1 -1
- package/dist/shell/assets/html-CUHSCFMy.js.br +0 -0
- package/dist/shell/assets/html-CUHSCFMy.js.gz +0 -0
- package/dist/shell/assets/{htmlMode-vCEOKCM-.js → htmlMode-gpMedtd9.js} +1 -1
- package/dist/shell/assets/htmlMode-gpMedtd9.js.br +0 -0
- package/dist/shell/assets/htmlMode-gpMedtd9.js.gz +0 -0
- package/dist/shell/assets/index-B3Alj0WH.css +1 -0
- package/dist/shell/assets/index-B3Alj0WH.css.br +0 -0
- package/dist/shell/assets/index-B3Alj0WH.css.gz +0 -0
- package/dist/shell/assets/index-VVd_p5tJ.js +278 -0
- package/dist/shell/assets/index-VVd_p5tJ.js.br +0 -0
- package/dist/shell/assets/index-VVd_p5tJ.js.gz +0 -0
- package/dist/shell/assets/{javascript-CF6f9y1O.js → javascript-BHWH8gQN.js} +1 -1
- package/dist/shell/assets/{jsonMode-CZzpDv9U.js → jsonMode-DyV5nvVT.js} +1 -1
- package/dist/shell/assets/jsonMode-DyV5nvVT.js.br +0 -0
- package/dist/shell/assets/jsonMode-DyV5nvVT.js.gz +0 -0
- package/dist/shell/assets/{liquid-5T0ZgJhW.js → liquid-Dy3tUgRC.js} +1 -1
- package/dist/shell/assets/liquid-Dy3tUgRC.js.br +0 -0
- package/dist/shell/assets/liquid-Dy3tUgRC.js.gz +0 -0
- package/dist/shell/assets/{lspLanguageFeatures-DrkNrp6u.js → lspLanguageFeatures-CB_Ow-w5.js} +1 -1
- package/dist/shell/assets/lspLanguageFeatures-CB_Ow-w5.js.br +0 -0
- package/dist/shell/assets/lspLanguageFeatures-CB_Ow-w5.js.gz +0 -0
- package/dist/shell/assets/{mdx-DnLcCYKb.js → mdx-DD5jgco_.js} +1 -1
- package/dist/shell/assets/mdx-DD5jgco_.js.br +0 -0
- package/dist/shell/assets/mdx-DD5jgco_.js.gz +0 -0
- package/dist/shell/assets/{python-Di4WuyJe.js → python-BvLKUXll.js} +1 -1
- package/dist/shell/assets/python-BvLKUXll.js.br +0 -0
- package/dist/shell/assets/python-BvLKUXll.js.gz +0 -0
- package/dist/shell/assets/{razor-NpEB1IHs.js → razor-B2tUlbzR.js} +1 -1
- package/dist/shell/assets/razor-B2tUlbzR.js.br +0 -0
- package/dist/shell/assets/razor-B2tUlbzR.js.gz +0 -0
- package/dist/shell/assets/{tsMode-BylSuxTF.js → tsMode-DMuNnqM7.js} +1 -1
- package/dist/shell/assets/tsMode-DMuNnqM7.js.br +0 -0
- package/dist/shell/assets/tsMode-DMuNnqM7.js.gz +0 -0
- package/dist/shell/assets/{xml-BYRl5HAh.js → xml-DdYgb5a2.js} +1 -1
- package/dist/shell/assets/xml-DdYgb5a2.js.br +0 -0
- package/dist/shell/assets/xml-DdYgb5a2.js.gz +0 -0
- package/dist/shell/assets/{yaml-DeSD0TUR.js → yaml-BDujJdoL.js} +1 -1
- package/dist/shell/assets/yaml-BDujJdoL.js.br +0 -0
- package/dist/shell/assets/yaml-BDujJdoL.js.gz +0 -0
- package/dist/shell/index.html +2 -2
- package/package.json +1 -1
- package/dist/shell/assets/Editor-B-1lrUVF.js.br +0 -0
- package/dist/shell/assets/Editor-B-1lrUVF.js.gz +0 -0
- package/dist/shell/assets/XTerm-CZl-vWEO.js.br +0 -0
- package/dist/shell/assets/XTerm-CZl-vWEO.js.gz +0 -0
- package/dist/shell/assets/cssMode-BpigOakf.js.br +0 -0
- package/dist/shell/assets/cssMode-BpigOakf.js.gz +0 -0
- package/dist/shell/assets/freemarker2-vvh2KLdJ.js.br +0 -0
- package/dist/shell/assets/freemarker2-vvh2KLdJ.js.gz +0 -0
- package/dist/shell/assets/grammar-DBMSnNcB.js.gz +0 -0
- package/dist/shell/assets/handlebars-ExFAR1bz.js.br +0 -0
- package/dist/shell/assets/handlebars-ExFAR1bz.js.gz +0 -0
- package/dist/shell/assets/html-DpIWoe_L.js.br +0 -0
- package/dist/shell/assets/html-DpIWoe_L.js.gz +0 -0
- package/dist/shell/assets/htmlMode-vCEOKCM-.js.br +0 -0
- package/dist/shell/assets/htmlMode-vCEOKCM-.js.gz +0 -0
- package/dist/shell/assets/index-CHbNBHbD.css +0 -1
- package/dist/shell/assets/index-CHbNBHbD.css.br +0 -0
- package/dist/shell/assets/index-CHbNBHbD.css.gz +0 -0
- package/dist/shell/assets/index-D5GN5OOv.js +0 -276
- package/dist/shell/assets/index-D5GN5OOv.js.br +0 -0
- package/dist/shell/assets/index-D5GN5OOv.js.gz +0 -0
- package/dist/shell/assets/jsonMode-CZzpDv9U.js.br +0 -0
- package/dist/shell/assets/jsonMode-CZzpDv9U.js.gz +0 -0
- package/dist/shell/assets/liquid-5T0ZgJhW.js.br +0 -0
- package/dist/shell/assets/liquid-5T0ZgJhW.js.gz +0 -0
- package/dist/shell/assets/lspLanguageFeatures-DrkNrp6u.js.br +0 -0
- package/dist/shell/assets/lspLanguageFeatures-DrkNrp6u.js.gz +0 -0
- package/dist/shell/assets/mdx-DnLcCYKb.js.br +0 -0
- package/dist/shell/assets/mdx-DnLcCYKb.js.gz +0 -0
- package/dist/shell/assets/python-Di4WuyJe.js.br +0 -0
- package/dist/shell/assets/python-Di4WuyJe.js.gz +0 -0
- package/dist/shell/assets/razor-NpEB1IHs.js.br +0 -0
- package/dist/shell/assets/razor-NpEB1IHs.js.gz +0 -0
- package/dist/shell/assets/tsMode-BylSuxTF.js.br +0 -0
- package/dist/shell/assets/tsMode-BylSuxTF.js.gz +0 -0
- package/dist/shell/assets/xml-BYRl5HAh.js.br +0 -0
- package/dist/shell/assets/xml-BYRl5HAh.js.gz +0 -0
- package/dist/shell/assets/yaml-DeSD0TUR.js.br +0 -0
- package/dist/shell/assets/yaml-DeSD0TUR.js.gz +0 -0
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/Editor--Z8ktewC.js","assets/grammar-CQ1uaD6_.js","assets/Editor-CB2SckMT.css","assets/XTerm-DsUQ0Xew.js","assets/XTerm-6GBZ9nXN.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
var CC=Object.defineProperty;var AC=(e,t,n)=>t in e?CC(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Et=(e,t,n)=>AC(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 a of i.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&r(a)}).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 eE(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Em={exports:{}},$c={},Sm={exports:{}},en={};/**
|
|
3
|
+
* @license React
|
|
4
|
+
* react.production.min.js
|
|
5
|
+
*
|
|
6
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
7
|
+
*
|
|
8
|
+
* This source code is licensed under the MIT license found in the
|
|
9
|
+
* LICENSE file in the root directory of this source tree.
|
|
10
|
+
*/var y0;function IC(){if(y0)return en;y0=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"),a=Symbol.for("react.context"),c=Symbol.for("react.forward_ref"),u=Symbol.for("react.suspense"),h=Symbol.for("react.memo"),f=Symbol.for("react.lazy"),m=Symbol.iterator;function g(W){return W===null||typeof W!="object"?null:(W=m&&W[m]||W["@@iterator"],typeof W=="function"?W:null)}var w={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},y=Object.assign,v={};function N(W,se,ce){this.props=W,this.context=se,this.refs=v,this.updater=ce||w}N.prototype.isReactComponent={},N.prototype.setState=function(W,se){if(typeof W!="object"&&typeof W!="function"&&W!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,W,se,"setState")},N.prototype.forceUpdate=function(W){this.updater.enqueueForceUpdate(this,W,"forceUpdate")};function x(){}x.prototype=N.prototype;function _(W,se,ce){this.props=W,this.context=se,this.refs=v,this.updater=ce||w}var T=_.prototype=new x;T.constructor=_,y(T,N.prototype),T.isPureReactComponent=!0;var j=Array.isArray,C=Object.prototype.hasOwnProperty,M={current:null},I={key:!0,ref:!0,__self:!0,__source:!0};function O(W,se,ce){var he,je={},$e=null,q=null;if(se!=null)for(he in se.ref!==void 0&&(q=se.ref),se.key!==void 0&&($e=""+se.key),se)C.call(se,he)&&!I.hasOwnProperty(he)&&(je[he]=se[he]);var H=arguments.length-2;if(H===1)je.children=ce;else if(1<H){for(var ve=Array(H),Se=0;Se<H;Se++)ve[Se]=arguments[Se+2];je.children=ve}if(W&&W.defaultProps)for(he in H=W.defaultProps,H)je[he]===void 0&&(je[he]=H[he]);return{$$typeof:e,type:W,key:$e,ref:q,props:je,_owner:M.current}}function A(W,se){return{$$typeof:e,type:W.type,key:se,ref:W.ref,props:W.props,_owner:W._owner}}function z(W){return typeof W=="object"&&W!==null&&W.$$typeof===e}function B(W){var se={"=":"=0",":":"=2"};return"$"+W.replace(/[=:]/g,function(ce){return se[ce]})}var U=/\/+/g;function Q(W,se){return typeof W=="object"&&W!==null&&W.key!=null?B(""+W.key):se.toString(36)}function ae(W,se,ce,he,je){var $e=typeof W;($e==="undefined"||$e==="boolean")&&(W=null);var q=!1;if(W===null)q=!0;else switch($e){case"string":case"number":q=!0;break;case"object":switch(W.$$typeof){case e:case t:q=!0}}if(q)return q=W,je=je(q),W=he===""?"."+Q(q,0):he,j(je)?(ce="",W!=null&&(ce=W.replace(U,"$&/")+"/"),ae(je,se,ce,"",function(Se){return Se})):je!=null&&(z(je)&&(je=A(je,ce+(!je.key||q&&q.key===je.key?"":(""+je.key).replace(U,"$&/")+"/")+W)),se.push(je)),1;if(q=0,he=he===""?".":he+":",j(W))for(var H=0;H<W.length;H++){$e=W[H];var ve=he+Q($e,H);q+=ae($e,se,ce,ve,je)}else if(ve=g(W),typeof ve=="function")for(W=ve.call(W),H=0;!($e=W.next()).done;)$e=$e.value,ve=he+Q($e,H++),q+=ae($e,se,ce,ve,je);else if($e==="object")throw se=String(W),Error("Objects are not valid as a React child (found: "+(se==="[object Object]"?"object with keys {"+Object.keys(W).join(", ")+"}":se)+"). If you meant to render a collection of children, use an array instead.");return q}function ee(W,se,ce){if(W==null)return W;var he=[],je=0;return ae(W,he,"","",function($e){return se.call(ce,$e,je++)}),he}function de(W){if(W._status===-1){var se=W._result;se=se(),se.then(function(ce){(W._status===0||W._status===-1)&&(W._status=1,W._result=ce)},function(ce){(W._status===0||W._status===-1)&&(W._status=2,W._result=ce)}),W._status===-1&&(W._status=0,W._result=se)}if(W._status===1)return W._result.default;throw W._result}var $={current:null},K={transition:null},V={ReactCurrentDispatcher:$,ReactCurrentBatchConfig:K,ReactCurrentOwner:M};function X(){throw Error("act(...) is not supported in production builds of React.")}return en.Children={map:ee,forEach:function(W,se,ce){ee(W,function(){se.apply(this,arguments)},ce)},count:function(W){var se=0;return ee(W,function(){se++}),se},toArray:function(W){return ee(W,function(se){return se})||[]},only:function(W){if(!z(W))throw Error("React.Children.only expected to receive a single React element child.");return W}},en.Component=N,en.Fragment=n,en.Profiler=o,en.PureComponent=_,en.StrictMode=r,en.Suspense=u,en.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=V,en.act=X,en.cloneElement=function(W,se,ce){if(W==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+W+".");var he=y({},W.props),je=W.key,$e=W.ref,q=W._owner;if(se!=null){if(se.ref!==void 0&&($e=se.ref,q=M.current),se.key!==void 0&&(je=""+se.key),W.type&&W.type.defaultProps)var H=W.type.defaultProps;for(ve in se)C.call(se,ve)&&!I.hasOwnProperty(ve)&&(he[ve]=se[ve]===void 0&&H!==void 0?H[ve]:se[ve])}var ve=arguments.length-2;if(ve===1)he.children=ce;else if(1<ve){H=Array(ve);for(var Se=0;Se<ve;Se++)H[Se]=arguments[Se+2];he.children=H}return{$$typeof:e,type:W.type,key:je,ref:$e,props:he,_owner:q}},en.createContext=function(W){return W={$$typeof:a,_currentValue:W,_currentValue2:W,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},W.Provider={$$typeof:i,_context:W},W.Consumer=W},en.createElement=O,en.createFactory=function(W){var se=O.bind(null,W);return se.type=W,se},en.createRef=function(){return{current:null}},en.forwardRef=function(W){return{$$typeof:c,render:W}},en.isValidElement=z,en.lazy=function(W){return{$$typeof:f,_payload:{_status:-1,_result:W},_init:de}},en.memo=function(W,se){return{$$typeof:h,type:W,compare:se===void 0?null:se}},en.startTransition=function(W){var se=K.transition;K.transition={};try{W()}finally{K.transition=se}},en.unstable_act=X,en.useCallback=function(W,se){return $.current.useCallback(W,se)},en.useContext=function(W){return $.current.useContext(W)},en.useDebugValue=function(){},en.useDeferredValue=function(W){return $.current.useDeferredValue(W)},en.useEffect=function(W,se){return $.current.useEffect(W,se)},en.useId=function(){return $.current.useId()},en.useImperativeHandle=function(W,se,ce){return $.current.useImperativeHandle(W,se,ce)},en.useInsertionEffect=function(W,se){return $.current.useInsertionEffect(W,se)},en.useLayoutEffect=function(W,se){return $.current.useLayoutEffect(W,se)},en.useMemo=function(W,se){return $.current.useMemo(W,se)},en.useReducer=function(W,se,ce){return $.current.useReducer(W,se,ce)},en.useRef=function(W){return $.current.useRef(W)},en.useState=function(W){return $.current.useState(W)},en.useSyncExternalStore=function(W,se,ce){return $.current.useSyncExternalStore(W,se,ce)},en.useTransition=function(){return $.current.useTransition()},en.version="18.3.1",en}var v0;function $k(){return v0||(v0=1,Sm.exports=IC()),Sm.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 b0;function RC(){if(b0)return $c;b0=1;var e=$k(),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 a(c,u,h){var f,m={},g=null,w=null;h!==void 0&&(g=""+h),u.key!==void 0&&(g=""+u.key),u.ref!==void 0&&(w=u.ref);for(f in u)r.call(u,f)&&!i.hasOwnProperty(f)&&(m[f]=u[f]);if(c&&c.defaultProps)for(f in u=c.defaultProps,u)m[f]===void 0&&(m[f]=u[f]);return{$$typeof:t,type:c,key:g,ref:w,props:m,_owner:o.current}}return $c.Fragment=n,$c.jsx=a,$c.jsxs=a,$c}var x0;function OC(){return x0||(x0=1,Em.exports=RC()),Em.exports}var d=OC(),S=$k();const MC=eE(S);var _m={exports:{}},io={},Nm={exports:{}},Tm={};/**
|
|
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 E0;function PC(){return E0||(E0=1,(function(e){function t(K,V){var X=K.length;K.push(V);e:for(;0<X;){var W=X-1>>>1,se=K[W];if(0<o(se,V))K[W]=V,K[X]=se,X=W;else break e}}function n(K){return K.length===0?null:K[0]}function r(K){if(K.length===0)return null;var V=K[0],X=K.pop();if(X!==V){K[0]=X;e:for(var W=0,se=K.length,ce=se>>>1;W<ce;){var he=2*(W+1)-1,je=K[he],$e=he+1,q=K[$e];if(0>o(je,X))$e<se&&0>o(q,je)?(K[W]=q,K[$e]=X,W=$e):(K[W]=je,K[he]=X,W=he);else if($e<se&&0>o(q,X))K[W]=q,K[$e]=X,W=$e;else break e}}return V}function o(K,V){var X=K.sortIndex-V.sortIndex;return X!==0?X:K.id-V.id}if(typeof performance=="object"&&typeof performance.now=="function"){var i=performance;e.unstable_now=function(){return i.now()}}else{var a=Date,c=a.now();e.unstable_now=function(){return a.now()-c}}var u=[],h=[],f=1,m=null,g=3,w=!1,y=!1,v=!1,N=typeof setTimeout=="function"?setTimeout:null,x=typeof clearTimeout=="function"?clearTimeout:null,_=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function T(K){for(var V=n(h);V!==null;){if(V.callback===null)r(h);else if(V.startTime<=K)r(h),V.sortIndex=V.expirationTime,t(u,V);else break;V=n(h)}}function j(K){if(v=!1,T(K),!y)if(n(u)!==null)y=!0,de(C);else{var V=n(h);V!==null&&$(j,V.startTime-K)}}function C(K,V){y=!1,v&&(v=!1,x(O),O=-1),w=!0;var X=g;try{for(T(V),m=n(u);m!==null&&(!(m.expirationTime>V)||K&&!B());){var W=m.callback;if(typeof W=="function"){m.callback=null,g=m.priorityLevel;var se=W(m.expirationTime<=V);V=e.unstable_now(),typeof se=="function"?m.callback=se:m===n(u)&&r(u),T(V)}else r(u);m=n(u)}if(m!==null)var ce=!0;else{var he=n(h);he!==null&&$(j,he.startTime-V),ce=!1}return ce}finally{m=null,g=X,w=!1}}var M=!1,I=null,O=-1,A=5,z=-1;function B(){return!(e.unstable_now()-z<A)}function U(){if(I!==null){var K=e.unstable_now();z=K;var V=!0;try{V=I(!0,K)}finally{V?Q():(M=!1,I=null)}}else M=!1}var Q;if(typeof _=="function")Q=function(){_(U)};else if(typeof MessageChannel<"u"){var ae=new MessageChannel,ee=ae.port2;ae.port1.onmessage=U,Q=function(){ee.postMessage(null)}}else Q=function(){N(U,0)};function de(K){I=K,M||(M=!0,Q())}function $(K,V){O=N(function(){K(e.unstable_now())},V)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(K){K.callback=null},e.unstable_continueExecution=function(){y||w||(y=!0,de(C))},e.unstable_forceFrameRate=function(K){0>K||125<K?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):A=0<K?Math.floor(1e3/K):5},e.unstable_getCurrentPriorityLevel=function(){return g},e.unstable_getFirstCallbackNode=function(){return n(u)},e.unstable_next=function(K){switch(g){case 1:case 2:case 3:var V=3;break;default:V=g}var X=g;g=V;try{return K()}finally{g=X}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(K,V){switch(K){case 1:case 2:case 3:case 4:case 5:break;default:K=3}var X=g;g=K;try{return V()}finally{g=X}},e.unstable_scheduleCallback=function(K,V,X){var W=e.unstable_now();switch(typeof X=="object"&&X!==null?(X=X.delay,X=typeof X=="number"&&0<X?W+X:W):X=W,K){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=X+se,K={id:f++,callback:V,priorityLevel:K,startTime:X,expirationTime:se,sortIndex:-1},X>W?(K.sortIndex=X,t(h,K),n(u)===null&&K===n(h)&&(v?(x(O),O=-1):v=!0,$(j,X-W))):(K.sortIndex=se,t(u,K),y||w||(y=!0,de(C))),K},e.unstable_shouldYield=B,e.unstable_wrapCallback=function(K){var V=g;return function(){var X=g;g=V;try{return K.apply(this,arguments)}finally{g=X}}}})(Tm)),Tm}var S0;function LC(){return S0||(S0=1,Nm.exports=PC()),Nm.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 _0;function DC(){if(_0)return io;_0=1;var e=$k(),t=LC();function n(s){for(var l="https://reactjs.org/docs/error-decoder.html?invariant="+s,p=1;p<arguments.length;p++)l+="&args[]="+encodeURIComponent(arguments[p]);return"Minified React error #"+s+"; visit "+l+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var r=new Set,o={};function i(s,l){a(s,l),a(s+"Capture",l)}function a(s,l){for(o[s]=l,s=0;s<l.length;s++)r.add(l[s])}var c=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),u=Object.prototype.hasOwnProperty,h=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,f={},m={};function g(s){return u.call(m,s)?!0:u.call(f,s)?!1:h.test(s)?m[s]=!0:(f[s]=!0,!1)}function w(s,l,p,k){if(p!==null&&p.type===0)return!1;switch(typeof l){case"function":case"symbol":return!0;case"boolean":return k?!1:p!==null?!p.acceptsBooleans:(s=s.toLowerCase().slice(0,5),s!=="data-"&&s!=="aria-");default:return!1}}function y(s,l,p,k){if(l===null||typeof l>"u"||w(s,l,p,k))return!0;if(k)return!1;if(p!==null)switch(p.type){case 3:return!l;case 4:return l===!1;case 5:return isNaN(l);case 6:return isNaN(l)||1>l}return!1}function v(s,l,p,k,b,E,R){this.acceptsBooleans=l===2||l===3||l===4,this.attributeName=k,this.attributeNamespace=b,this.mustUseProperty=p,this.propertyName=s,this.type=l,this.sanitizeURL=E,this.removeEmptyString=R}var N={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(s){N[s]=new v(s,0,!1,s,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(s){var l=s[0];N[l]=new v(l,1,!1,s[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(s){N[s]=new v(s,2,!1,s.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(s){N[s]=new v(s,2,!1,s,null,!1,!1)}),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(s){N[s]=new v(s,3,!1,s.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(s){N[s]=new v(s,3,!0,s,null,!1,!1)}),["capture","download"].forEach(function(s){N[s]=new v(s,4,!1,s,null,!1,!1)}),["cols","rows","size","span"].forEach(function(s){N[s]=new v(s,6,!1,s,null,!1,!1)}),["rowSpan","start"].forEach(function(s){N[s]=new v(s,5,!1,s.toLowerCase(),null,!1,!1)});var x=/[\-:]([a-z])/g;function _(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 l=s.replace(x,_);N[l]=new v(l,1,!1,s,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(s){var l=s.replace(x,_);N[l]=new v(l,1,!1,s,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(s){var l=s.replace(x,_);N[l]=new v(l,1,!1,s,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(s){N[s]=new v(s,1,!1,s.toLowerCase(),null,!1,!1)}),N.xlinkHref=new v("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(s){N[s]=new v(s,1,!1,s.toLowerCase(),null,!0,!0)});function T(s,l,p,k){var b=N.hasOwnProperty(l)?N[l]:null;(b!==null?b.type!==0:k||!(2<l.length)||l[0]!=="o"&&l[0]!=="O"||l[1]!=="n"&&l[1]!=="N")&&(y(l,p,b,k)&&(p=null),k||b===null?g(l)&&(p===null?s.removeAttribute(l):s.setAttribute(l,""+p)):b.mustUseProperty?s[b.propertyName]=p===null?b.type===3?!1:"":p:(l=b.attributeName,k=b.attributeNamespace,p===null?s.removeAttribute(l):(b=b.type,p=b===3||b===4&&p===!0?"":""+p,k?s.setAttributeNS(k,l,p):s.setAttribute(l,p))))}var j=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,C=Symbol.for("react.element"),M=Symbol.for("react.portal"),I=Symbol.for("react.fragment"),O=Symbol.for("react.strict_mode"),A=Symbol.for("react.profiler"),z=Symbol.for("react.provider"),B=Symbol.for("react.context"),U=Symbol.for("react.forward_ref"),Q=Symbol.for("react.suspense"),ae=Symbol.for("react.suspense_list"),ee=Symbol.for("react.memo"),de=Symbol.for("react.lazy"),$=Symbol.for("react.offscreen"),K=Symbol.iterator;function V(s){return s===null||typeof s!="object"?null:(s=K&&s[K]||s["@@iterator"],typeof s=="function"?s:null)}var X=Object.assign,W;function se(s){if(W===void 0)try{throw Error()}catch(p){var l=p.stack.trim().match(/\n( *(at )?)/);W=l&&l[1]||""}return`
|
|
35
|
+
`+W+s}var ce=!1;function he(s,l){if(!s||ce)return"";ce=!0;var p=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(l)if(l=function(){throw Error()},Object.defineProperty(l.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(l,[])}catch(ke){var k=ke}Reflect.construct(s,[],l)}else{try{l.call()}catch(ke){k=ke}s.call(l.prototype)}else{try{throw Error()}catch(ke){k=ke}s()}}catch(ke){if(ke&&k&&typeof ke.stack=="string"){for(var b=ke.stack.split(`
|
|
36
|
+
`),E=k.stack.split(`
|
|
37
|
+
`),R=b.length-1,G=E.length-1;1<=R&&0<=G&&b[R]!==E[G];)G--;for(;1<=R&&0<=G;R--,G--)if(b[R]!==E[G]){if(R!==1||G!==1)do if(R--,G--,0>G||b[R]!==E[G]){var ne=`
|
|
38
|
+
`+b[R].replace(" at new "," at ");return s.displayName&&ne.includes("<anonymous>")&&(ne=ne.replace("<anonymous>",s.displayName)),ne}while(1<=R&&0<=G);break}}}finally{ce=!1,Error.prepareStackTrace=p}return(s=s?s.displayName||s.name:"")?se(s):""}function je(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 $e(s){if(s==null)return null;if(typeof s=="function")return s.displayName||s.name||null;if(typeof s=="string")return s;switch(s){case I:return"Fragment";case M:return"Portal";case A:return"Profiler";case O:return"StrictMode";case Q:return"Suspense";case ae:return"SuspenseList"}if(typeof s=="object")switch(s.$$typeof){case B:return(s.displayName||"Context")+".Consumer";case z:return(s._context.displayName||"Context")+".Provider";case U:var l=s.render;return s=s.displayName,s||(s=l.displayName||l.name||"",s=s!==""?"ForwardRef("+s+")":"ForwardRef"),s;case ee:return l=s.displayName||null,l!==null?l:$e(s.type)||"Memo";case de:l=s._payload,s=s._init;try{return $e(s(l))}catch{}}return null}function q(s){var l=s.type;switch(s.tag){case 24:return"Cache";case 9:return(l.displayName||"Context")+".Consumer";case 10:return(l._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return s=l.render,s=s.displayName||s.name||"",l.displayName||(s!==""?"ForwardRef("+s+")":"ForwardRef");case 7:return"Fragment";case 5:return l;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return $e(l);case 8:return l===O?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof l=="function")return l.displayName||l.name||null;if(typeof l=="string")return l}return null}function H(s){switch(typeof s){case"boolean":case"number":case"string":case"undefined":return s;case"object":return s;default:return""}}function ve(s){var l=s.type;return(s=s.nodeName)&&s.toLowerCase()==="input"&&(l==="checkbox"||l==="radio")}function Se(s){var l=ve(s)?"checked":"value",p=Object.getOwnPropertyDescriptor(s.constructor.prototype,l),k=""+s[l];if(!s.hasOwnProperty(l)&&typeof p<"u"&&typeof p.get=="function"&&typeof p.set=="function"){var b=p.get,E=p.set;return Object.defineProperty(s,l,{configurable:!0,get:function(){return b.call(this)},set:function(R){k=""+R,E.call(this,R)}}),Object.defineProperty(s,l,{enumerable:p.enumerable}),{getValue:function(){return k},setValue:function(R){k=""+R},stopTracking:function(){s._valueTracker=null,delete s[l]}}}}function ye(s){s._valueTracker||(s._valueTracker=Se(s))}function J(s){if(!s)return!1;var l=s._valueTracker;if(!l)return!0;var p=l.getValue(),k="";return s&&(k=ve(s)?s.checked?"true":"false":s.value),s=k,s!==p?(l.setValue(s),!0):!1}function we(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 ge(s,l){var p=l.checked;return X({},l,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:p??s._wrapperState.initialChecked})}function Be(s,l){var p=l.defaultValue==null?"":l.defaultValue,k=l.checked!=null?l.checked:l.defaultChecked;p=H(l.value!=null?l.value:p),s._wrapperState={initialChecked:k,initialValue:p,controlled:l.type==="checkbox"||l.type==="radio"?l.checked!=null:l.value!=null}}function Ie(s,l){l=l.checked,l!=null&&T(s,"checked",l,!1)}function We(s,l){Ie(s,l);var p=H(l.value),k=l.type;if(p!=null)k==="number"?(p===0&&s.value===""||s.value!=p)&&(s.value=""+p):s.value!==""+p&&(s.value=""+p);else if(k==="submit"||k==="reset"){s.removeAttribute("value");return}l.hasOwnProperty("value")?rn(s,l.type,p):l.hasOwnProperty("defaultValue")&&rn(s,l.type,H(l.defaultValue)),l.checked==null&&l.defaultChecked!=null&&(s.defaultChecked=!!l.defaultChecked)}function pt(s,l,p){if(l.hasOwnProperty("value")||l.hasOwnProperty("defaultValue")){var k=l.type;if(!(k!=="submit"&&k!=="reset"||l.value!==void 0&&l.value!==null))return;l=""+s._wrapperState.initialValue,p||l===s.value||(s.value=l),s.defaultValue=l}p=s.name,p!==""&&(s.name=""),s.defaultChecked=!!s._wrapperState.initialChecked,p!==""&&(s.name=p)}function rn(s,l,p){(l!=="number"||we(s.ownerDocument)!==s)&&(p==null?s.defaultValue=""+s._wrapperState.initialValue:s.defaultValue!==""+p&&(s.defaultValue=""+p))}var qt=Array.isArray;function Ue(s,l,p,k){if(s=s.options,l){l={};for(var b=0;b<p.length;b++)l["$"+p[b]]=!0;for(p=0;p<s.length;p++)b=l.hasOwnProperty("$"+s[p].value),s[p].selected!==b&&(s[p].selected=b),b&&k&&(s[p].defaultSelected=!0)}else{for(p=""+H(p),l=null,b=0;b<s.length;b++){if(s[b].value===p){s[b].selected=!0,k&&(s[b].defaultSelected=!0);return}l!==null||s[b].disabled||(l=s[b])}l!==null&&(l.selected=!0)}}function Qt(s,l){if(l.dangerouslySetInnerHTML!=null)throw Error(n(91));return X({},l,{value:void 0,defaultValue:void 0,children:""+s._wrapperState.initialValue})}function an(s,l){var p=l.value;if(p==null){if(p=l.children,l=l.defaultValue,p!=null){if(l!=null)throw Error(n(92));if(qt(p)){if(1<p.length)throw Error(n(93));p=p[0]}l=p}l==null&&(l=""),p=l}s._wrapperState={initialValue:H(p)}}function Ft(s,l){var p=H(l.value),k=H(l.defaultValue);p!=null&&(p=""+p,p!==s.value&&(s.value=p),l.defaultValue==null&&s.defaultValue!==p&&(s.defaultValue=p)),k!=null&&(s.defaultValue=""+k)}function Qe(s){var l=s.textContent;l===s._wrapperState.initialValue&&l!==""&&l!==null&&(s.value=l)}function Wt(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 ln(s,l){return s==null||s==="http://www.w3.org/1999/xhtml"?Wt(l):s==="http://www.w3.org/2000/svg"&&l==="foreignObject"?"http://www.w3.org/1999/xhtml":s}var wt,mt=(function(s){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(l,p,k,b){MSApp.execUnsafeLocalFunction(function(){return s(l,p,k,b)})}:s})(function(s,l){if(s.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in s)s.innerHTML=l;else{for(wt=wt||document.createElement("div"),wt.innerHTML="<svg>"+l.valueOf().toString()+"</svg>",l=wt.firstChild;s.firstChild;)s.removeChild(s.firstChild);for(;l.firstChild;)s.appendChild(l.firstChild)}});function Vt(s,l){if(l){var p=s.firstChild;if(p&&p===s.lastChild&&p.nodeType===3){p.nodeValue=l;return}}s.textContent=l}var kn={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},Lt=["Webkit","ms","Moz","O"];Object.keys(kn).forEach(function(s){Lt.forEach(function(l){l=l+s.charAt(0).toUpperCase()+s.substring(1),kn[l]=kn[s]})});function Pn(s,l,p){return l==null||typeof l=="boolean"||l===""?"":p||typeof l!="number"||l===0||kn.hasOwnProperty(s)&&kn[s]?(""+l).trim():l+"px"}function _t(s,l){s=s.style;for(var p in l)if(l.hasOwnProperty(p)){var k=p.indexOf("--")===0,b=Pn(p,l[p],k);p==="float"&&(p="cssFloat"),k?s.setProperty(p,b):s[p]=b}}var yn=X({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 er(s,l){if(l){if(yn[s]&&(l.children!=null||l.dangerouslySetInnerHTML!=null))throw Error(n(137,s));if(l.dangerouslySetInnerHTML!=null){if(l.children!=null)throw Error(n(60));if(typeof l.dangerouslySetInnerHTML!="object"||!("__html"in l.dangerouslySetInnerHTML))throw Error(n(61))}if(l.style!=null&&typeof l.style!="object")throw Error(n(62))}}function te(s,l){if(s.indexOf("-")===-1)return typeof l.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 me=null;function Ge(s){return s=s.target||s.srcElement||window,s.correspondingUseElement&&(s=s.correspondingUseElement),s.nodeType===3?s.parentNode:s}var ot=null,Dt=null,Ct=null;function mn(s){if(s=pc(s)){if(typeof ot!="function")throw Error(n(280));var l=s.stateNode;l&&(l=id(l),ot(s.stateNode,s.type,l))}}function L(s){Dt?Ct?Ct.push(s):Ct=[s]:Dt=s}function re(){if(Dt){var s=Dt,l=Ct;if(Ct=Dt=null,mn(s),l)for(s=0;s<l.length;s++)mn(l[s])}}function be(s,l){return s(l)}function Xe(){}var Nt=!1;function Ot(s,l,p){if(Nt)return s(l,p);Nt=!0;try{return be(s,l,p)}finally{Nt=!1,(Dt!==null||Ct!==null)&&(Xe(),re())}}function ze(s,l){var p=s.stateNode;if(p===null)return null;var k=id(p);if(k===null)return null;p=k[l];e:switch(l){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(k=!k.disabled)||(s=s.type,k=!(s==="button"||s==="input"||s==="select"||s==="textarea")),s=!k;break e;default:s=!1}if(s)return null;if(p&&typeof p!="function")throw Error(n(231,l,typeof p));return p}var Me=!1;if(c)try{var Ze={};Object.defineProperty(Ze,"passive",{get:function(){Me=!0}}),window.addEventListener("test",Ze,Ze),window.removeEventListener("test",Ze,Ze)}catch{Me=!1}function Xt(s,l,p,k,b,E,R,G,ne){var ke=Array.prototype.slice.call(arguments,3);try{l.apply(p,ke)}catch(Ae){this.onError(Ae)}}var Bt=!1,vn=null,Ut=!1,cn=null,Yt={onError:function(s){Bt=!0,vn=s}};function Kt(s,l,p,k,b,E,R,G,ne){Bt=!1,vn=null,Xt.apply(Yt,arguments)}function Sn(s,l,p,k,b,E,R,G,ne){if(Kt.apply(this,arguments),Bt){if(Bt){var ke=vn;Bt=!1,vn=null}else throw Error(n(198));Ut||(Ut=!0,cn=ke)}}function An(s){var l=s,p=s;if(s.alternate)for(;l.return;)l=l.return;else{s=l;do l=s,(l.flags&4098)!==0&&(p=l.return),s=l.return;while(s)}return l.tag===3?p:null}function fr(s){if(s.tag===13){var l=s.memoizedState;if(l===null&&(s=s.alternate,s!==null&&(l=s.memoizedState)),l!==null)return l.dehydrated}return null}function oe(s){if(An(s)!==s)throw Error(n(188))}function Le(s){var l=s.alternate;if(!l){if(l=An(s),l===null)throw Error(n(188));return l!==s?null:s}for(var p=s,k=l;;){var b=p.return;if(b===null)break;var E=b.alternate;if(E===null){if(k=b.return,k!==null){p=k;continue}break}if(b.child===E.child){for(E=b.child;E;){if(E===p)return oe(b),s;if(E===k)return oe(b),l;E=E.sibling}throw Error(n(188))}if(p.return!==k.return)p=b,k=E;else{for(var R=!1,G=b.child;G;){if(G===p){R=!0,p=b,k=E;break}if(G===k){R=!0,k=b,p=E;break}G=G.sibling}if(!R){for(G=E.child;G;){if(G===p){R=!0,p=E,k=b;break}if(G===k){R=!0,k=E,p=b;break}G=G.sibling}if(!R)throw Error(n(189))}}if(p.alternate!==k)throw Error(n(190))}if(p.tag!==3)throw Error(n(188));return p.stateNode.current===p?s:l}function Ve(s){return s=Le(s),s!==null?jt(s):null}function jt(s){if(s.tag===5||s.tag===6)return s;for(s=s.child;s!==null;){var l=jt(s);if(l!==null)return l;s=s.sibling}return null}var ft=t.unstable_scheduleCallback,bn=t.unstable_cancelCallback,jr=t.unstable_shouldYield,ir=t.unstable_requestPaint,Zt=t.unstable_now,Qr=t.unstable_getCurrentPriorityLevel,dt=t.unstable_ImmediatePriority,Hn=t.unstable_UserBlockingPriority,rt=t.unstable_NormalPriority,_e=t.unstable_LowPriority,qe=t.unstable_IdlePriority,bt=null,it=null;function fn(s){if(it&&typeof it.onCommitFiberRoot=="function")try{it.onCommitFiberRoot(bt,s,void 0,(s.current.flags&128)===128)}catch{}}var Ht=Math.clz32?Math.clz32:In,un=Math.log,Kr=Math.LN2;function In(s){return s>>>=0,s===0?32:31-(un(s)/Kr|0)|0}var Wn=64,yr=4194304;function Kn(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 Y(s,l){var p=s.pendingLanes;if(p===0)return 0;var k=0,b=s.suspendedLanes,E=s.pingedLanes,R=p&268435455;if(R!==0){var G=R&~b;G!==0?k=Kn(G):(E&=R,E!==0&&(k=Kn(E)))}else R=p&~b,R!==0?k=Kn(R):E!==0&&(k=Kn(E));if(k===0)return 0;if(l!==0&&l!==k&&(l&b)===0&&(b=k&-k,E=l&-l,b>=E||b===16&&(E&4194240)!==0))return l;if((k&4)!==0&&(k|=p&16),l=s.entangledLanes,l!==0)for(s=s.entanglements,l&=k;0<l;)p=31-Ht(l),b=1<<p,k|=s[p],l&=~b;return k}function pe(s,l){switch(s){case 1:case 2:case 4:return l+250;case 8:case 16:case 32:case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return l+5e3;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return-1;case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function Je(s,l){for(var p=s.suspendedLanes,k=s.pingedLanes,b=s.expirationTimes,E=s.pendingLanes;0<E;){var R=31-Ht(E),G=1<<R,ne=b[R];ne===-1?((G&p)===0||(G&k)!==0)&&(b[R]=pe(G,l)):ne<=l&&(s.expiredLanes|=G),E&=~G}}function gt(s){return s=s.pendingLanes&-1073741825,s!==0?s:s&1073741824?1073741824:0}function Tt(){var s=Wn;return Wn<<=1,(Wn&4194240)===0&&(Wn=64),s}function xn(s){for(var l=[],p=0;31>p;p++)l.push(s);return l}function Zn(s,l,p){s.pendingLanes|=l,l!==536870912&&(s.suspendedLanes=0,s.pingedLanes=0),s=s.eventTimes,l=31-Ht(l),s[l]=p}function ar(s,l){var p=s.pendingLanes&~l;s.pendingLanes=l,s.suspendedLanes=0,s.pingedLanes=0,s.expiredLanes&=l,s.mutableReadLanes&=l,s.entangledLanes&=l,l=s.entanglements;var k=s.eventTimes;for(s=s.expirationTimes;0<p;){var b=31-Ht(p),E=1<<b;l[b]=0,k[b]=-1,s[b]=-1,p&=~E}}function $r(s,l){var p=s.entangledLanes|=l;for(s=s.entanglements;p;){var k=31-Ht(p),b=1<<k;b&l|s[k]&l&&(s[k]|=l),p&=~b}}var Gt=0;function xt(s){return s&=-s,1<s?4<s?(s&268435455)!==0?16:536870912:4:1}var To,jn,Jt,Zr,Or,Ne=!1,F=[],Z=null,le=null,xe=null,Re=new Map,Te=new Map,$t=[],on="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 tr(s,l){switch(s){case"focusin":case"focusout":Z=null;break;case"dragenter":case"dragleave":le=null;break;case"mouseover":case"mouseout":xe=null;break;case"pointerover":case"pointerout":Re.delete(l.pointerId);break;case"gotpointercapture":case"lostpointercapture":Te.delete(l.pointerId)}}function Rn(s,l,p,k,b,E){return s===null||s.nativeEvent!==E?(s={blockedOn:l,domEventName:p,eventSystemFlags:k,nativeEvent:E,targetContainers:[b]},l!==null&&(l=pc(l),l!==null&&jn(l)),s):(s.eventSystemFlags|=k,l=s.targetContainers,b!==null&&l.indexOf(b)===-1&&l.push(b),s)}function zs(s,l,p,k,b){switch(l){case"focusin":return Z=Rn(Z,s,l,p,k,b),!0;case"dragenter":return le=Rn(le,s,l,p,k,b),!0;case"mouseover":return xe=Rn(xe,s,l,p,k,b),!0;case"pointerover":var E=b.pointerId;return Re.set(E,Rn(Re.get(E)||null,s,l,p,k,b)),!0;case"gotpointercapture":return E=b.pointerId,Te.set(E,Rn(Te.get(E)||null,s,l,p,k,b)),!0}return!1}function En(s){var l=Zi(s.target);if(l!==null){var p=An(l);if(p!==null){if(l=p.tag,l===13){if(l=fr(p),l!==null){s.blockedOn=l,Or(s.priority,function(){Jt(p)});return}}else if(l===3&&p.stateNode.current.memoizedState.isDehydrated){s.blockedOn=p.tag===3?p.stateNode.containerInfo:null;return}}}s.blockedOn=null}function Oi(s){if(s.blockedOn!==null)return!1;for(var l=s.targetContainers;0<l.length;){var p=Hs(s.domEventName,s.eventSystemFlags,l[0],s.nativeEvent);if(p===null){p=s.nativeEvent;var k=new p.constructor(p.type,p);me=k,p.target.dispatchEvent(k),me=null}else return l=pc(p),l!==null&&jn(l),s.blockedOn=p,!1;l.shift()}return!0}function $a(s,l,p){Oi(s)&&p.delete(l)}function Mu(){Ne=!1,Z!==null&&Oi(Z)&&(Z=null),le!==null&&Oi(le)&&(le=null),xe!==null&&Oi(xe)&&(xe=null),Re.forEach($a),Te.forEach($a)}function Fs(s,l){s.blockedOn===l&&(s.blockedOn=null,Ne||(Ne=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,Mu)))}function Mi(s){function l(b){return Fs(b,s)}if(0<F.length){Fs(F[0],s);for(var p=1;p<F.length;p++){var k=F[p];k.blockedOn===s&&(k.blockedOn=null)}}for(Z!==null&&Fs(Z,s),le!==null&&Fs(le,s),xe!==null&&Fs(xe,s),Re.forEach(l),Te.forEach(l),p=0;p<$t.length;p++)k=$t[p],k.blockedOn===s&&(k.blockedOn=null);for(;0<$t.length&&(p=$t[0],p.blockedOn===null);)En(p),p.blockedOn===null&&$t.shift()}var Bs=j.ReactCurrentBatchConfig,Ca=!0;function Aa(s,l,p,k){var b=Gt,E=Bs.transition;Bs.transition=null;try{Gt=1,Us(s,l,p,k)}finally{Gt=b,Bs.transition=E}}function vs(s,l,p,k){var b=Gt,E=Bs.transition;Bs.transition=null;try{Gt=4,Us(s,l,p,k)}finally{Gt=b,Bs.transition=E}}function Us(s,l,p,k){if(Ca){var b=Hs(s,l,p,k);if(b===null)hp(s,l,k,Pi,p),tr(s,k);else if(zs(b,s,l,p,k))k.stopPropagation();else if(tr(s,k),l&4&&-1<on.indexOf(s)){for(;b!==null;){var E=pc(b);if(E!==null&&To(E),E=Hs(s,l,p,k),E===null&&hp(s,l,k,Pi,p),E===b)break;b=E}b!==null&&k.stopPropagation()}else hp(s,l,k,null,p)}}var Pi=null;function Hs(s,l,p,k){if(Pi=null,s=Ge(k),s=Zi(s),s!==null)if(l=An(s),l===null)s=null;else if(p=l.tag,p===13){if(s=fr(l),s!==null)return s;s=null}else if(p===3){if(l.stateNode.current.memoizedState.isDehydrated)return l.tag===3?l.stateNode.containerInfo:null;s=null}else l!==s&&(s=null);return Pi=s,null}function Li(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(Qr()){case dt:return 1;case Hn:return 4;case rt:case _e:return 16;case qe:return 536870912;default:return 16}default:return 16}}var Wo=null,Ws=null,Di=null;function Ia(){if(Di)return Di;var s,l=Ws,p=l.length,k,b="value"in Wo?Wo.value:Wo.textContent,E=b.length;for(s=0;s<p&&l[s]===b[s];s++);var R=p-s;for(k=1;k<=R&&l[p-k]===b[E-k];k++);return Di=b.slice(s,1<k?1-k:void 0)}function hr(s){var l=s.keyCode;return"charCode"in s?(s=s.charCode,s===0&&l===13&&(s=13)):s=l,s===10&&(s=13),32<=s||s===13?s:0}function Ra(){return!0}function Pu(){return!1}function Cr(s){function l(p,k,b,E,R){this._reactName=p,this._targetInst=b,this.type=k,this.nativeEvent=E,this.target=R,this.currentTarget=null;for(var G in s)s.hasOwnProperty(G)&&(p=s[G],this[G]=p?p(E):E[G]);return this.isDefaultPrevented=(E.defaultPrevented!=null?E.defaultPrevented:E.returnValue===!1)?Ra:Pu,this.isPropagationStopped=Pu,this}return X(l.prototype,{preventDefault:function(){this.defaultPrevented=!0;var p=this.nativeEvent;p&&(p.preventDefault?p.preventDefault():typeof p.returnValue!="unknown"&&(p.returnValue=!1),this.isDefaultPrevented=Ra)},stopPropagation:function(){var p=this.nativeEvent;p&&(p.stopPropagation?p.stopPropagation():typeof p.cancelBubble!="unknown"&&(p.cancelBubble=!0),this.isPropagationStopped=Ra)},persist:function(){},isPersistent:Ra}),l}var as={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(s){return s.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},ls=Cr(as),bs=X({},as,{view:0,detail:0}),Lu=Cr(bs),Yl,zi,Fi,Bi=X({},bs,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Ui,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!==Fi&&(Fi&&s.type==="mousemove"?(Yl=s.screenX-Fi.screenX,zi=s.screenY-Fi.screenY):zi=Yl=0,Fi=s),Yl)},movementY:function(s){return"movementY"in s?s.movementY:zi}}),Du=Cr(Bi),zu=X({},Bi,{dataTransfer:0}),op=Cr(zu),Fu=X({},bs,{relatedTarget:0}),vr=Cr(Fu),Bu=X({},as,{animationName:0,elapsedTime:0,pseudoElement:0}),Uu=Cr(Bu),Oa=X({},as,{clipboardData:function(s){return"clipboardData"in s?s.clipboardData:window.clipboardData}}),sp=Cr(Oa),Xl=X({},as,{data:0}),Ma=Cr(Xl),Pa={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Ln={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"},Hu={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function La(s){var l=this.nativeEvent;return l.getModifierState?l.getModifierState(s):(s=Hu[s])?!!l[s]:!1}function Ui(){return La}var Da=X({},bs,{key:function(s){if(s.key){var l=Pa[s.key]||s.key;if(l!=="Unidentified")return l}return s.type==="keypress"?(s=hr(s),s===13?"Enter":String.fromCharCode(s)):s.type==="keydown"||s.type==="keyup"?Ln[s.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Ui,charCode:function(s){return s.type==="keypress"?hr(s):0},keyCode:function(s){return s.type==="keydown"||s.type==="keyup"?s.keyCode:0},which:function(s){return s.type==="keypress"?hr(s):s.type==="keydown"||s.type==="keyup"?s.keyCode:0}}),za=Cr(Da),Ks=X({},Bi,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Ql=Cr(Ks),Jl=X({},bs,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Ui}),ec=Cr(Jl),Wu=X({},as,{propertyName:0,elapsedTime:0,pseudoElement:0}),Ny=Cr(Wu),Ku=X({},Bi,{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=Cr(Ku),Zu=[9,13,27,32],Ba=c&&"CompositionEvent"in window,Zs=null;c&&"documentMode"in document&&(Zs=document.documentMode);var pr=c&&"TextEvent"in window&&!Zs,Hi=c&&(!Ba||Zs&&8<Zs&&11>=Zs),qu=" ",Wi=!1;function tc(s,l){switch(s){case"keyup":return Zu.indexOf(l.keyCode)!==-1;case"keydown":return l.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function qs(s){return s=s.detail,typeof s=="object"&&"data"in s?s.data:null}var jo=!1;function nc(s,l){switch(s){case"compositionend":return qs(l);case"keypress":return l.which!==32?null:(Wi=!0,qu);case"textInput":return s=l.data,s===qu&&Wi?null:s;default:return null}}function ip(s,l){if(jo)return s==="compositionend"||!Ba&&tc(s,l)?(s=Ia(),Di=Ws=Wo=null,jo=!1,s):null;switch(s){case"paste":return null;case"keypress":if(!(l.ctrlKey||l.altKey||l.metaKey)||l.ctrlKey&&l.altKey){if(l.char&&1<l.char.length)return l.char;if(l.which)return String.fromCharCode(l.which)}return null;case"compositionend":return Hi&&l.locale!=="ko"?null:l.data;default:return null}}var rc={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 Gu(s){var l=s&&s.nodeName&&s.nodeName.toLowerCase();return l==="input"?!!rc[s.type]:l==="textarea"}function oc(s,l,p,k){L(k),l=rd(l,"onChange"),0<l.length&&(p=new ls("onChange","change",null,p,k),s.push({event:p,listeners:l}))}var Gs=null,Vs=null;function Vu(s){My(s,0)}function Ko(s){var l=Ga(s);if(J(l))return s}function ap(s,l){if(s==="change")return l}var Ua=!1;if(c){var Ha;if(c){var sc="oninput"in document;if(!sc){var Wa=document.createElement("div");Wa.setAttribute("oninput","return;"),sc=typeof Wa.oninput=="function"}Ha=sc}else Ha=!1;Ua=Ha&&(!document.documentMode||9<document.documentMode)}function ic(){Gs&&(Gs.detachEvent("onpropertychange",ac),Vs=Gs=null)}function ac(s){if(s.propertyName==="value"&&Ko(Vs)){var l=[];oc(l,Vs,s,Ge(s)),Ot(Vu,l)}}function Yu(s,l,p){s==="focusin"?(ic(),Gs=l,Vs=p,Gs.attachEvent("onpropertychange",ac)):s==="focusout"&&ic()}function lp(s){if(s==="selectionchange"||s==="keyup"||s==="keydown")return Ko(Vs)}function Xu(s,l){if(s==="click")return Ko(l)}function Qu(s,l){if(s==="input"||s==="change")return Ko(l)}function Ju(s,l){return s===l&&(s!==0||1/s===1/l)||s!==s&&l!==l}var Jr=typeof Object.is=="function"?Object.is:Ju;function Ys(s,l){if(Jr(s,l))return!0;if(typeof s!="object"||s===null||typeof l!="object"||l===null)return!1;var p=Object.keys(s),k=Object.keys(l);if(p.length!==k.length)return!1;for(k=0;k<p.length;k++){var b=p[k];if(!u.call(l,b)||!Jr(s[b],l[b]))return!1}return!0}function lc(s){for(;s&&s.firstChild;)s=s.firstChild;return s}function cc(s,l){var p=lc(s);s=0;for(var k;p;){if(p.nodeType===3){if(k=s+p.textContent.length,s<=l&&k>=l)return{node:p,offset:l-s};s=k}e:{for(;p;){if(p.nextSibling){p=p.nextSibling;break e}p=p.parentNode}p=void 0}p=lc(p)}}function D(s,l){return s&&l?s===l?!0:s&&s.nodeType===3?!1:l&&l.nodeType===3?D(s,l.parentNode):"contains"in s?s.contains(l):s.compareDocumentPosition?!!(s.compareDocumentPosition(l)&16):!1:!1}function Pe(){for(var s=window,l=we();l instanceof s.HTMLIFrameElement;){try{var p=typeof l.contentWindow.location.href=="string"}catch{p=!1}if(p)s=l.contentWindow;else break;l=we(s.document)}return l}function ht(s){var l=s&&s.nodeName&&s.nodeName.toLowerCase();return l&&(l==="input"&&(s.type==="text"||s.type==="search"||s.type==="tel"||s.type==="url"||s.type==="password")||l==="textarea"||s.contentEditable==="true")}function At(s){var l=Pe(),p=s.focusedElem,k=s.selectionRange;if(l!==p&&p&&p.ownerDocument&&D(p.ownerDocument.documentElement,p)){if(k!==null&&ht(p)){if(l=k.start,s=k.end,s===void 0&&(s=l),"selectionStart"in p)p.selectionStart=l,p.selectionEnd=Math.min(s,p.value.length);else if(s=(l=p.ownerDocument||document)&&l.defaultView||window,s.getSelection){s=s.getSelection();var b=p.textContent.length,E=Math.min(k.start,b);k=k.end===void 0?E:Math.min(k.end,b),!s.extend&&E>k&&(b=k,k=E,E=b),b=cc(p,E);var R=cc(p,k);b&&R&&(s.rangeCount!==1||s.anchorNode!==b.node||s.anchorOffset!==b.offset||s.focusNode!==R.node||s.focusOffset!==R.offset)&&(l=l.createRange(),l.setStart(b.node,b.offset),s.removeAllRanges(),E>k?(s.addRange(l),s.extend(R.node,R.offset)):(l.setEnd(R.node,R.offset),s.addRange(l)))}}for(l=[],s=p;s=s.parentNode;)s.nodeType===1&&l.push({element:s,left:s.scrollLeft,top:s.scrollTop});for(typeof p.focus=="function"&&p.focus(),p=0;p<l.length;p++)s=l[p],s.element.scrollLeft=s.left,s.element.scrollTop=s.top}}var rr=c&&"documentMode"in document&&11>=document.documentMode,On=null,xs=null,Xs=null,eo=!1;function ed(s,l,p){var k=p.window===p?p.document:p.nodeType===9?p:p.ownerDocument;eo||On==null||On!==we(k)||(k=On,"selectionStart"in k&&ht(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}),Xs&&Ys(Xs,k)||(Xs=k,k=rd(xs,"onSelect"),0<k.length&&(l=new ls("onSelect","select",null,l,p),s.push({event:l,listeners:k}),l.target=On)))}function Ki(s,l){var p={};return p[s.toLowerCase()]=l.toLowerCase(),p["Webkit"+s]="webkit"+l,p["Moz"+s]="moz"+l,p}var Ka={animationend:Ki("Animation","AnimationEnd"),animationiteration:Ki("Animation","AnimationIteration"),animationstart:Ki("Animation","AnimationStart"),transitionend:Ki("Transition","TransitionEnd")},cp={},Ty={};c&&(Ty=document.createElement("div").style,"AnimationEvent"in window||(delete Ka.animationend.animation,delete Ka.animationiteration.animation,delete Ka.animationstart.animation),"TransitionEvent"in window||delete Ka.transitionend.transition);function td(s){if(cp[s])return cp[s];if(!Ka[s])return s;var l=Ka[s],p;for(p in l)if(l.hasOwnProperty(p)&&p in Ty)return cp[s]=l[p];return s}var jy=td("animationend"),$y=td("animationiteration"),Cy=td("animationstart"),Ay=td("transitionend"),Iy=new Map,Ry="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 Qs(s,l){Iy.set(s,l),i(l,[s])}for(var up=0;up<Ry.length;up++){var dp=Ry[up],z$=dp.toLowerCase(),F$=dp[0].toUpperCase()+dp.slice(1);Qs(z$,"on"+F$)}Qs(jy,"onAnimationEnd"),Qs($y,"onAnimationIteration"),Qs(Cy,"onAnimationStart"),Qs("dblclick","onDoubleClick"),Qs("focusin","onFocus"),Qs("focusout","onBlur"),Qs(Ay,"onTransitionEnd"),a("onMouseEnter",["mouseout","mouseover"]),a("onMouseLeave",["mouseout","mouseover"]),a("onPointerEnter",["pointerout","pointerover"]),a("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 uc="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),B$=new Set("cancel close invalid load scroll toggle".split(" ").concat(uc));function Oy(s,l,p){var k=s.type||"unknown-event";s.currentTarget=p,Sn(k,l,void 0,s),s.currentTarget=null}function My(s,l){l=(l&4)!==0;for(var p=0;p<s.length;p++){var k=s[p],b=k.event;k=k.listeners;e:{var E=void 0;if(l)for(var R=k.length-1;0<=R;R--){var G=k[R],ne=G.instance,ke=G.currentTarget;if(G=G.listener,ne!==E&&b.isPropagationStopped())break e;Oy(b,G,ke),E=ne}else for(R=0;R<k.length;R++){if(G=k[R],ne=G.instance,ke=G.currentTarget,G=G.listener,ne!==E&&b.isPropagationStopped())break e;Oy(b,G,ke),E=ne}}}if(Ut)throw s=cn,Ut=!1,cn=null,s}function Dn(s,l){var p=l[yp];p===void 0&&(p=l[yp]=new Set);var k=s+"__bubble";p.has(k)||(Py(l,s,2,!1),p.add(k))}function fp(s,l,p){var k=0;l&&(k|=4),Py(p,s,k,l)}var nd="_reactListening"+Math.random().toString(36).slice(2);function dc(s){if(!s[nd]){s[nd]=!0,r.forEach(function(p){p!=="selectionchange"&&(B$.has(p)||fp(p,!1,s),fp(p,!0,s))});var l=s.nodeType===9?s:s.ownerDocument;l===null||l[nd]||(l[nd]=!0,fp("selectionchange",!1,l))}}function Py(s,l,p,k){switch(Li(l)){case 1:var b=Aa;break;case 4:b=vs;break;default:b=Us}p=b.bind(null,l,p,s),b=void 0,!Me||l!=="touchstart"&&l!=="touchmove"&&l!=="wheel"||(b=!0),k?b!==void 0?s.addEventListener(l,p,{capture:!0,passive:b}):s.addEventListener(l,p,!0):b!==void 0?s.addEventListener(l,p,{passive:b}):s.addEventListener(l,p,!1)}function hp(s,l,p,k,b){var E=k;if((l&1)===0&&(l&2)===0&&k!==null)e:for(;;){if(k===null)return;var R=k.tag;if(R===3||R===4){var G=k.stateNode.containerInfo;if(G===b||G.nodeType===8&&G.parentNode===b)break;if(R===4)for(R=k.return;R!==null;){var ne=R.tag;if((ne===3||ne===4)&&(ne=R.stateNode.containerInfo,ne===b||ne.nodeType===8&&ne.parentNode===b))return;R=R.return}for(;G!==null;){if(R=Zi(G),R===null)return;if(ne=R.tag,ne===5||ne===6){k=E=R;continue e}G=G.parentNode}}k=k.return}Ot(function(){var ke=E,Ae=Ge(p),Oe=[];e:{var Ce=Iy.get(s);if(Ce!==void 0){var Ye=ls,nt=s;switch(s){case"keypress":if(hr(p)===0)break e;case"keydown":case"keyup":Ye=za;break;case"focusin":nt="focus",Ye=vr;break;case"focusout":nt="blur",Ye=vr;break;case"beforeblur":case"afterblur":Ye=vr;break;case"click":if(p.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":Ye=Du;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":Ye=op;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":Ye=ec;break;case jy:case $y:case Cy:Ye=Uu;break;case Ay:Ye=Ny;break;case"scroll":Ye=Lu;break;case"wheel":Ye=Fa;break;case"copy":case"cut":case"paste":Ye=sp;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":Ye=Ql}var st=(l&4)!==0,or=!st&&s==="scroll",ue=st?Ce!==null?Ce+"Capture":null:Ce;st=[];for(var ie=ke,fe;ie!==null;){fe=ie;var Fe=fe.stateNode;if(fe.tag===5&&Fe!==null&&(fe=Fe,ue!==null&&(Fe=ze(ie,ue),Fe!=null&&st.push(fc(ie,Fe,fe)))),or)break;ie=ie.return}0<st.length&&(Ce=new Ye(Ce,nt,null,p,Ae),Oe.push({event:Ce,listeners:st}))}}if((l&7)===0){e:{if(Ce=s==="mouseover"||s==="pointerover",Ye=s==="mouseout"||s==="pointerout",Ce&&p!==me&&(nt=p.relatedTarget||p.fromElement)&&(Zi(nt)||nt[Es]))break e;if((Ye||Ce)&&(Ce=Ae.window===Ae?Ae:(Ce=Ae.ownerDocument)?Ce.defaultView||Ce.parentWindow:window,Ye?(nt=p.relatedTarget||p.toElement,Ye=ke,nt=nt?Zi(nt):null,nt!==null&&(or=An(nt),nt!==or||nt.tag!==5&&nt.tag!==6)&&(nt=null)):(Ye=null,nt=ke),Ye!==nt)){if(st=Du,Fe="onMouseLeave",ue="onMouseEnter",ie="mouse",(s==="pointerout"||s==="pointerover")&&(st=Ql,Fe="onPointerLeave",ue="onPointerEnter",ie="pointer"),or=Ye==null?Ce:Ga(Ye),fe=nt==null?Ce:Ga(nt),Ce=new st(Fe,ie+"leave",Ye,p,Ae),Ce.target=or,Ce.relatedTarget=fe,Fe=null,Zi(Ae)===ke&&(st=new st(ue,ie+"enter",nt,p,Ae),st.target=fe,st.relatedTarget=or,Fe=st),or=Fe,Ye&&nt)t:{for(st=Ye,ue=nt,ie=0,fe=st;fe;fe=Za(fe))ie++;for(fe=0,Fe=ue;Fe;Fe=Za(Fe))fe++;for(;0<ie-fe;)st=Za(st),ie--;for(;0<fe-ie;)ue=Za(ue),fe--;for(;ie--;){if(st===ue||ue!==null&&st===ue.alternate)break t;st=Za(st),ue=Za(ue)}st=null}else st=null;Ye!==null&&Ly(Oe,Ce,Ye,st,!1),nt!==null&&or!==null&&Ly(Oe,or,nt,st,!0)}}e:{if(Ce=ke?Ga(ke):window,Ye=Ce.nodeName&&Ce.nodeName.toLowerCase(),Ye==="select"||Ye==="input"&&Ce.type==="file")var at=ap;else if(Gu(Ce))if(Ua)at=Qu;else{at=lp;var yt=Yu}else(Ye=Ce.nodeName)&&Ye.toLowerCase()==="input"&&(Ce.type==="checkbox"||Ce.type==="radio")&&(at=Xu);if(at&&(at=at(s,ke))){oc(Oe,at,p,Ae);break e}yt&&yt(s,Ce,ke),s==="focusout"&&(yt=Ce._wrapperState)&&yt.controlled&&Ce.type==="number"&&rn(Ce,"number",Ce.value)}switch(yt=ke?Ga(ke):window,s){case"focusin":(Gu(yt)||yt.contentEditable==="true")&&(On=yt,xs=ke,Xs=null);break;case"focusout":Xs=xs=On=null;break;case"mousedown":eo=!0;break;case"contextmenu":case"mouseup":case"dragend":eo=!1,ed(Oe,p,Ae);break;case"selectionchange":if(rr)break;case"keydown":case"keyup":ed(Oe,p,Ae)}var vt;if(Ba)e:{switch(s){case"compositionstart":var Mt="onCompositionStart";break e;case"compositionend":Mt="onCompositionEnd";break e;case"compositionupdate":Mt="onCompositionUpdate";break e}Mt=void 0}else jo?tc(s,p)&&(Mt="onCompositionEnd"):s==="keydown"&&p.keyCode===229&&(Mt="onCompositionStart");Mt&&(Hi&&p.locale!=="ko"&&(jo||Mt!=="onCompositionStart"?Mt==="onCompositionEnd"&&jo&&(vt=Ia()):(Wo=Ae,Ws="value"in Wo?Wo.value:Wo.textContent,jo=!0)),yt=rd(ke,Mt),0<yt.length&&(Mt=new Ma(Mt,s,null,p,Ae),Oe.push({event:Mt,listeners:yt}),vt?Mt.data=vt:(vt=qs(p),vt!==null&&(Mt.data=vt)))),(vt=pr?nc(s,p):ip(s,p))&&(ke=rd(ke,"onBeforeInput"),0<ke.length&&(Ae=new Ma("onBeforeInput","beforeinput",null,p,Ae),Oe.push({event:Ae,listeners:ke}),Ae.data=vt))}My(Oe,l)})}function fc(s,l,p){return{instance:s,listener:l,currentTarget:p}}function rd(s,l){for(var p=l+"Capture",k=[];s!==null;){var b=s,E=b.stateNode;b.tag===5&&E!==null&&(b=E,E=ze(s,p),E!=null&&k.unshift(fc(s,E,b)),E=ze(s,l),E!=null&&k.push(fc(s,E,b))),s=s.return}return k}function Za(s){if(s===null)return null;do s=s.return;while(s&&s.tag!==5);return s||null}function Ly(s,l,p,k,b){for(var E=l._reactName,R=[];p!==null&&p!==k;){var G=p,ne=G.alternate,ke=G.stateNode;if(ne!==null&&ne===k)break;G.tag===5&&ke!==null&&(G=ke,b?(ne=ze(p,E),ne!=null&&R.unshift(fc(p,ne,G))):b||(ne=ze(p,E),ne!=null&&R.push(fc(p,ne,G)))),p=p.return}R.length!==0&&s.push({event:l,listeners:R})}var U$=/\r\n?/g,H$=/\u0000|\uFFFD/g;function Dy(s){return(typeof s=="string"?s:""+s).replace(U$,`
|
|
39
|
+
`).replace(H$,"")}function od(s,l,p){if(l=Dy(l),Dy(s)!==l&&p)throw Error(n(425))}function sd(){}var pp=null,mp=null;function gp(s,l){return s==="textarea"||s==="noscript"||typeof l.children=="string"||typeof l.children=="number"||typeof l.dangerouslySetInnerHTML=="object"&&l.dangerouslySetInnerHTML!==null&&l.dangerouslySetInnerHTML.__html!=null}var kp=typeof setTimeout=="function"?setTimeout:void 0,W$=typeof clearTimeout=="function"?clearTimeout:void 0,zy=typeof Promise=="function"?Promise:void 0,K$=typeof queueMicrotask=="function"?queueMicrotask:typeof zy<"u"?function(s){return zy.resolve(null).then(s).catch(Z$)}:kp;function Z$(s){setTimeout(function(){throw s})}function wp(s,l){var p=l,k=0;do{var b=p.nextSibling;if(s.removeChild(p),b&&b.nodeType===8)if(p=b.data,p==="/$"){if(k===0){s.removeChild(b),Mi(l);return}k--}else p!=="$"&&p!=="$?"&&p!=="$!"||k++;p=b}while(p);Mi(l)}function Js(s){for(;s!=null;s=s.nextSibling){var l=s.nodeType;if(l===1||l===3)break;if(l===8){if(l=s.data,l==="$"||l==="$!"||l==="$?")break;if(l==="/$")return null}}return s}function Fy(s){s=s.previousSibling;for(var l=0;s;){if(s.nodeType===8){var p=s.data;if(p==="$"||p==="$!"||p==="$?"){if(l===0)return s;l--}else p==="/$"&&l++}s=s.previousSibling}return null}var qa=Math.random().toString(36).slice(2),cs="__reactFiber$"+qa,hc="__reactProps$"+qa,Es="__reactContainer$"+qa,yp="__reactEvents$"+qa,q$="__reactListeners$"+qa,G$="__reactHandles$"+qa;function Zi(s){var l=s[cs];if(l)return l;for(var p=s.parentNode;p;){if(l=p[Es]||p[cs]){if(p=l.alternate,l.child!==null||p!==null&&p.child!==null)for(s=Fy(s);s!==null;){if(p=s[cs])return p;s=Fy(s)}return l}s=p,p=s.parentNode}return null}function pc(s){return s=s[cs]||s[Es],!s||s.tag!==5&&s.tag!==6&&s.tag!==13&&s.tag!==3?null:s}function Ga(s){if(s.tag===5||s.tag===6)return s.stateNode;throw Error(n(33))}function id(s){return s[hc]||null}var vp=[],Va=-1;function ei(s){return{current:s}}function zn(s){0>Va||(s.current=vp[Va],vp[Va]=null,Va--)}function Mn(s,l){Va++,vp[Va]=s.current,s.current=l}var ti={},Mr=ei(ti),to=ei(!1),qi=ti;function Ya(s,l){var p=s.type.contextTypes;if(!p)return ti;var k=s.stateNode;if(k&&k.__reactInternalMemoizedUnmaskedChildContext===l)return k.__reactInternalMemoizedMaskedChildContext;var b={},E;for(E in p)b[E]=l[E];return k&&(s=s.stateNode,s.__reactInternalMemoizedUnmaskedChildContext=l,s.__reactInternalMemoizedMaskedChildContext=b),b}function no(s){return s=s.childContextTypes,s!=null}function ad(){zn(to),zn(Mr)}function By(s,l,p){if(Mr.current!==ti)throw Error(n(168));Mn(Mr,l),Mn(to,p)}function Uy(s,l,p){var k=s.stateNode;if(l=l.childContextTypes,typeof k.getChildContext!="function")return p;k=k.getChildContext();for(var b in k)if(!(b in l))throw Error(n(108,q(s)||"Unknown",b));return X({},p,k)}function ld(s){return s=(s=s.stateNode)&&s.__reactInternalMemoizedMergedChildContext||ti,qi=Mr.current,Mn(Mr,s),Mn(to,to.current),!0}function Hy(s,l,p){var k=s.stateNode;if(!k)throw Error(n(169));p?(s=Uy(s,l,qi),k.__reactInternalMemoizedMergedChildContext=s,zn(to),zn(Mr),Mn(Mr,s)):zn(to),Mn(to,p)}var Ss=null,cd=!1,bp=!1;function Wy(s){Ss===null?Ss=[s]:Ss.push(s)}function V$(s){cd=!0,Wy(s)}function ni(){if(!bp&&Ss!==null){bp=!0;var s=0,l=Gt;try{var p=Ss;for(Gt=1;s<p.length;s++){var k=p[s];do k=k(!0);while(k!==null)}Ss=null,cd=!1}catch(b){throw Ss!==null&&(Ss=Ss.slice(s+1)),ft(dt,ni),b}finally{Gt=l,bp=!1}}return null}var Xa=[],Qa=0,ud=null,dd=0,$o=[],Co=0,Gi=null,_s=1,Ns="";function Vi(s,l){Xa[Qa++]=dd,Xa[Qa++]=ud,ud=s,dd=l}function Ky(s,l,p){$o[Co++]=_s,$o[Co++]=Ns,$o[Co++]=Gi,Gi=s;var k=_s;s=Ns;var b=32-Ht(k)-1;k&=~(1<<b),p+=1;var E=32-Ht(l)+b;if(30<E){var R=b-b%5;E=(k&(1<<R)-1).toString(32),k>>=R,b-=R,_s=1<<32-Ht(l)+b|p<<b|k,Ns=E+s}else _s=1<<E|p<<b|k,Ns=s}function xp(s){s.return!==null&&(Vi(s,1),Ky(s,1,0))}function Ep(s){for(;s===ud;)ud=Xa[--Qa],Xa[Qa]=null,dd=Xa[--Qa],Xa[Qa]=null;for(;s===Gi;)Gi=$o[--Co],$o[Co]=null,Ns=$o[--Co],$o[Co]=null,_s=$o[--Co],$o[Co]=null}var go=null,ko=null,qn=!1,Zo=null;function Zy(s,l){var p=Oo(5,null,null,0);p.elementType="DELETED",p.stateNode=l,p.return=s,l=s.deletions,l===null?(s.deletions=[p],s.flags|=16):l.push(p)}function qy(s,l){switch(s.tag){case 5:var p=s.type;return l=l.nodeType!==1||p.toLowerCase()!==l.nodeName.toLowerCase()?null:l,l!==null?(s.stateNode=l,go=s,ko=Js(l.firstChild),!0):!1;case 6:return l=s.pendingProps===""||l.nodeType!==3?null:l,l!==null?(s.stateNode=l,go=s,ko=null,!0):!1;case 13:return l=l.nodeType!==8?null:l,l!==null?(p=Gi!==null?{id:_s,overflow:Ns}:null,s.memoizedState={dehydrated:l,treeContext:p,retryLane:1073741824},p=Oo(18,null,null,0),p.stateNode=l,p.return=s,s.child=p,go=s,ko=null,!0):!1;default:return!1}}function Sp(s){return(s.mode&1)!==0&&(s.flags&128)===0}function _p(s){if(qn){var l=ko;if(l){var p=l;if(!qy(s,l)){if(Sp(s))throw Error(n(418));l=Js(p.nextSibling);var k=go;l&&qy(s,l)?Zy(k,p):(s.flags=s.flags&-4097|2,qn=!1,go=s)}}else{if(Sp(s))throw Error(n(418));s.flags=s.flags&-4097|2,qn=!1,go=s}}}function Gy(s){for(s=s.return;s!==null&&s.tag!==5&&s.tag!==3&&s.tag!==13;)s=s.return;go=s}function fd(s){if(s!==go)return!1;if(!qn)return Gy(s),qn=!0,!1;var l;if((l=s.tag!==3)&&!(l=s.tag!==5)&&(l=s.type,l=l!=="head"&&l!=="body"&&!gp(s.type,s.memoizedProps)),l&&(l=ko)){if(Sp(s))throw Vy(),Error(n(418));for(;l;)Zy(s,l),l=Js(l.nextSibling)}if(Gy(s),s.tag===13){if(s=s.memoizedState,s=s!==null?s.dehydrated:null,!s)throw Error(n(317));e:{for(s=s.nextSibling,l=0;s;){if(s.nodeType===8){var p=s.data;if(p==="/$"){if(l===0){ko=Js(s.nextSibling);break e}l--}else p!=="$"&&p!=="$!"&&p!=="$?"||l++}s=s.nextSibling}ko=null}}else ko=go?Js(s.stateNode.nextSibling):null;return!0}function Vy(){for(var s=ko;s;)s=Js(s.nextSibling)}function Ja(){ko=go=null,qn=!1}function Np(s){Zo===null?Zo=[s]:Zo.push(s)}var Y$=j.ReactCurrentBatchConfig;function mc(s,l,p){if(s=p.ref,s!==null&&typeof s!="function"&&typeof s!="object"){if(p._owner){if(p=p._owner,p){if(p.tag!==1)throw Error(n(309));var k=p.stateNode}if(!k)throw Error(n(147,s));var b=k,E=""+s;return l!==null&&l.ref!==null&&typeof l.ref=="function"&&l.ref._stringRef===E?l.ref:(l=function(R){var G=b.refs;R===null?delete G[E]:G[E]=R},l._stringRef=E,l)}if(typeof s!="string")throw Error(n(284));if(!p._owner)throw Error(n(290,s))}return s}function hd(s,l){throw s=Object.prototype.toString.call(l),Error(n(31,s==="[object Object]"?"object with keys {"+Object.keys(l).join(", ")+"}":s))}function Yy(s){var l=s._init;return l(s._payload)}function Xy(s){function l(ue,ie){if(s){var fe=ue.deletions;fe===null?(ue.deletions=[ie],ue.flags|=16):fe.push(ie)}}function p(ue,ie){if(!s)return null;for(;ie!==null;)l(ue,ie),ie=ie.sibling;return null}function k(ue,ie){for(ue=new Map;ie!==null;)ie.key!==null?ue.set(ie.key,ie):ue.set(ie.index,ie),ie=ie.sibling;return ue}function b(ue,ie){return ue=ui(ue,ie),ue.index=0,ue.sibling=null,ue}function E(ue,ie,fe){return ue.index=fe,s?(fe=ue.alternate,fe!==null?(fe=fe.index,fe<ie?(ue.flags|=2,ie):fe):(ue.flags|=2,ie)):(ue.flags|=1048576,ie)}function R(ue){return s&&ue.alternate===null&&(ue.flags|=2),ue}function G(ue,ie,fe,Fe){return ie===null||ie.tag!==6?(ie=km(fe,ue.mode,Fe),ie.return=ue,ie):(ie=b(ie,fe),ie.return=ue,ie)}function ne(ue,ie,fe,Fe){var at=fe.type;return at===I?Ae(ue,ie,fe.props.children,Fe,fe.key):ie!==null&&(ie.elementType===at||typeof at=="object"&&at!==null&&at.$$typeof===de&&Yy(at)===ie.type)?(Fe=b(ie,fe.props),Fe.ref=mc(ue,ie,fe),Fe.return=ue,Fe):(Fe=Ld(fe.type,fe.key,fe.props,null,ue.mode,Fe),Fe.ref=mc(ue,ie,fe),Fe.return=ue,Fe)}function ke(ue,ie,fe,Fe){return ie===null||ie.tag!==4||ie.stateNode.containerInfo!==fe.containerInfo||ie.stateNode.implementation!==fe.implementation?(ie=wm(fe,ue.mode,Fe),ie.return=ue,ie):(ie=b(ie,fe.children||[]),ie.return=ue,ie)}function Ae(ue,ie,fe,Fe,at){return ie===null||ie.tag!==7?(ie=ra(fe,ue.mode,Fe,at),ie.return=ue,ie):(ie=b(ie,fe),ie.return=ue,ie)}function Oe(ue,ie,fe){if(typeof ie=="string"&&ie!==""||typeof ie=="number")return ie=km(""+ie,ue.mode,fe),ie.return=ue,ie;if(typeof ie=="object"&&ie!==null){switch(ie.$$typeof){case C:return fe=Ld(ie.type,ie.key,ie.props,null,ue.mode,fe),fe.ref=mc(ue,null,ie),fe.return=ue,fe;case M:return ie=wm(ie,ue.mode,fe),ie.return=ue,ie;case de:var Fe=ie._init;return Oe(ue,Fe(ie._payload),fe)}if(qt(ie)||V(ie))return ie=ra(ie,ue.mode,fe,null),ie.return=ue,ie;hd(ue,ie)}return null}function Ce(ue,ie,fe,Fe){var at=ie!==null?ie.key:null;if(typeof fe=="string"&&fe!==""||typeof fe=="number")return at!==null?null:G(ue,ie,""+fe,Fe);if(typeof fe=="object"&&fe!==null){switch(fe.$$typeof){case C:return fe.key===at?ne(ue,ie,fe,Fe):null;case M:return fe.key===at?ke(ue,ie,fe,Fe):null;case de:return at=fe._init,Ce(ue,ie,at(fe._payload),Fe)}if(qt(fe)||V(fe))return at!==null?null:Ae(ue,ie,fe,Fe,null);hd(ue,fe)}return null}function Ye(ue,ie,fe,Fe,at){if(typeof Fe=="string"&&Fe!==""||typeof Fe=="number")return ue=ue.get(fe)||null,G(ie,ue,""+Fe,at);if(typeof Fe=="object"&&Fe!==null){switch(Fe.$$typeof){case C:return ue=ue.get(Fe.key===null?fe:Fe.key)||null,ne(ie,ue,Fe,at);case M:return ue=ue.get(Fe.key===null?fe:Fe.key)||null,ke(ie,ue,Fe,at);case de:var yt=Fe._init;return Ye(ue,ie,fe,yt(Fe._payload),at)}if(qt(Fe)||V(Fe))return ue=ue.get(fe)||null,Ae(ie,ue,Fe,at,null);hd(ie,Fe)}return null}function nt(ue,ie,fe,Fe){for(var at=null,yt=null,vt=ie,Mt=ie=0,Er=null;vt!==null&&Mt<fe.length;Mt++){vt.index>Mt?(Er=vt,vt=null):Er=vt.sibling;var gn=Ce(ue,vt,fe[Mt],Fe);if(gn===null){vt===null&&(vt=Er);break}s&&vt&&gn.alternate===null&&l(ue,vt),ie=E(gn,ie,Mt),yt===null?at=gn:yt.sibling=gn,yt=gn,vt=Er}if(Mt===fe.length)return p(ue,vt),qn&&Vi(ue,Mt),at;if(vt===null){for(;Mt<fe.length;Mt++)vt=Oe(ue,fe[Mt],Fe),vt!==null&&(ie=E(vt,ie,Mt),yt===null?at=vt:yt.sibling=vt,yt=vt);return qn&&Vi(ue,Mt),at}for(vt=k(ue,vt);Mt<fe.length;Mt++)Er=Ye(vt,ue,Mt,fe[Mt],Fe),Er!==null&&(s&&Er.alternate!==null&&vt.delete(Er.key===null?Mt:Er.key),ie=E(Er,ie,Mt),yt===null?at=Er:yt.sibling=Er,yt=Er);return s&&vt.forEach(function(di){return l(ue,di)}),qn&&Vi(ue,Mt),at}function st(ue,ie,fe,Fe){var at=V(fe);if(typeof at!="function")throw Error(n(150));if(fe=at.call(fe),fe==null)throw Error(n(151));for(var yt=at=null,vt=ie,Mt=ie=0,Er=null,gn=fe.next();vt!==null&&!gn.done;Mt++,gn=fe.next()){vt.index>Mt?(Er=vt,vt=null):Er=vt.sibling;var di=Ce(ue,vt,gn.value,Fe);if(di===null){vt===null&&(vt=Er);break}s&&vt&&di.alternate===null&&l(ue,vt),ie=E(di,ie,Mt),yt===null?at=di:yt.sibling=di,yt=di,vt=Er}if(gn.done)return p(ue,vt),qn&&Vi(ue,Mt),at;if(vt===null){for(;!gn.done;Mt++,gn=fe.next())gn=Oe(ue,gn.value,Fe),gn!==null&&(ie=E(gn,ie,Mt),yt===null?at=gn:yt.sibling=gn,yt=gn);return qn&&Vi(ue,Mt),at}for(vt=k(ue,vt);!gn.done;Mt++,gn=fe.next())gn=Ye(vt,ue,Mt,gn.value,Fe),gn!==null&&(s&&gn.alternate!==null&&vt.delete(gn.key===null?Mt:gn.key),ie=E(gn,ie,Mt),yt===null?at=gn:yt.sibling=gn,yt=gn);return s&&vt.forEach(function($C){return l(ue,$C)}),qn&&Vi(ue,Mt),at}function or(ue,ie,fe,Fe){if(typeof fe=="object"&&fe!==null&&fe.type===I&&fe.key===null&&(fe=fe.props.children),typeof fe=="object"&&fe!==null){switch(fe.$$typeof){case C:e:{for(var at=fe.key,yt=ie;yt!==null;){if(yt.key===at){if(at=fe.type,at===I){if(yt.tag===7){p(ue,yt.sibling),ie=b(yt,fe.props.children),ie.return=ue,ue=ie;break e}}else if(yt.elementType===at||typeof at=="object"&&at!==null&&at.$$typeof===de&&Yy(at)===yt.type){p(ue,yt.sibling),ie=b(yt,fe.props),ie.ref=mc(ue,yt,fe),ie.return=ue,ue=ie;break e}p(ue,yt);break}else l(ue,yt);yt=yt.sibling}fe.type===I?(ie=ra(fe.props.children,ue.mode,Fe,fe.key),ie.return=ue,ue=ie):(Fe=Ld(fe.type,fe.key,fe.props,null,ue.mode,Fe),Fe.ref=mc(ue,ie,fe),Fe.return=ue,ue=Fe)}return R(ue);case M:e:{for(yt=fe.key;ie!==null;){if(ie.key===yt)if(ie.tag===4&&ie.stateNode.containerInfo===fe.containerInfo&&ie.stateNode.implementation===fe.implementation){p(ue,ie.sibling),ie=b(ie,fe.children||[]),ie.return=ue,ue=ie;break e}else{p(ue,ie);break}else l(ue,ie);ie=ie.sibling}ie=wm(fe,ue.mode,Fe),ie.return=ue,ue=ie}return R(ue);case de:return yt=fe._init,or(ue,ie,yt(fe._payload),Fe)}if(qt(fe))return nt(ue,ie,fe,Fe);if(V(fe))return st(ue,ie,fe,Fe);hd(ue,fe)}return typeof fe=="string"&&fe!==""||typeof fe=="number"?(fe=""+fe,ie!==null&&ie.tag===6?(p(ue,ie.sibling),ie=b(ie,fe),ie.return=ue,ue=ie):(p(ue,ie),ie=km(fe,ue.mode,Fe),ie.return=ue,ue=ie),R(ue)):p(ue,ie)}return or}var el=Xy(!0),Qy=Xy(!1),pd=ei(null),md=null,tl=null,Tp=null;function jp(){Tp=tl=md=null}function $p(s){var l=pd.current;zn(pd),s._currentValue=l}function Cp(s,l,p){for(;s!==null;){var k=s.alternate;if((s.childLanes&l)!==l?(s.childLanes|=l,k!==null&&(k.childLanes|=l)):k!==null&&(k.childLanes&l)!==l&&(k.childLanes|=l),s===p)break;s=s.return}}function nl(s,l){md=s,Tp=tl=null,s=s.dependencies,s!==null&&s.firstContext!==null&&((s.lanes&l)!==0&&(ro=!0),s.firstContext=null)}function Ao(s){var l=s._currentValue;if(Tp!==s)if(s={context:s,memoizedValue:l,next:null},tl===null){if(md===null)throw Error(n(308));tl=s,md.dependencies={lanes:0,firstContext:s}}else tl=tl.next=s;return l}var Yi=null;function Ap(s){Yi===null?Yi=[s]:Yi.push(s)}function Jy(s,l,p,k){var b=l.interleaved;return b===null?(p.next=p,Ap(l)):(p.next=b.next,b.next=p),l.interleaved=p,Ts(s,k)}function Ts(s,l){s.lanes|=l;var p=s.alternate;for(p!==null&&(p.lanes|=l),p=s,s=s.return;s!==null;)s.childLanes|=l,p=s.alternate,p!==null&&(p.childLanes|=l),p=s,s=s.return;return p.tag===3?p.stateNode:null}var ri=!1;function Ip(s){s.updateQueue={baseState:s.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function ev(s,l){s=s.updateQueue,l.updateQueue===s&&(l.updateQueue={baseState:s.baseState,firstBaseUpdate:s.firstBaseUpdate,lastBaseUpdate:s.lastBaseUpdate,shared:s.shared,effects:s.effects})}function js(s,l){return{eventTime:s,lane:l,tag:0,payload:null,callback:null,next:null}}function oi(s,l,p){var k=s.updateQueue;if(k===null)return null;if(k=k.shared,(hn&2)!==0){var b=k.pending;return b===null?l.next=l:(l.next=b.next,b.next=l),k.pending=l,Ts(s,p)}return b=k.interleaved,b===null?(l.next=l,Ap(k)):(l.next=b.next,b.next=l),k.interleaved=l,Ts(s,p)}function gd(s,l,p){if(l=l.updateQueue,l!==null&&(l=l.shared,(p&4194240)!==0)){var k=l.lanes;k&=s.pendingLanes,p|=k,l.lanes=p,$r(s,p)}}function tv(s,l){var p=s.updateQueue,k=s.alternate;if(k!==null&&(k=k.updateQueue,p===k)){var b=null,E=null;if(p=p.firstBaseUpdate,p!==null){do{var R={eventTime:p.eventTime,lane:p.lane,tag:p.tag,payload:p.payload,callback:p.callback,next:null};E===null?b=E=R:E=E.next=R,p=p.next}while(p!==null);E===null?b=E=l:E=E.next=l}else b=E=l;p={baseState:k.baseState,firstBaseUpdate:b,lastBaseUpdate:E,shared:k.shared,effects:k.effects},s.updateQueue=p;return}s=p.lastBaseUpdate,s===null?p.firstBaseUpdate=l:s.next=l,p.lastBaseUpdate=l}function kd(s,l,p,k){var b=s.updateQueue;ri=!1;var E=b.firstBaseUpdate,R=b.lastBaseUpdate,G=b.shared.pending;if(G!==null){b.shared.pending=null;var ne=G,ke=ne.next;ne.next=null,R===null?E=ke:R.next=ke,R=ne;var Ae=s.alternate;Ae!==null&&(Ae=Ae.updateQueue,G=Ae.lastBaseUpdate,G!==R&&(G===null?Ae.firstBaseUpdate=ke:G.next=ke,Ae.lastBaseUpdate=ne))}if(E!==null){var Oe=b.baseState;R=0,Ae=ke=ne=null,G=E;do{var Ce=G.lane,Ye=G.eventTime;if((k&Ce)===Ce){Ae!==null&&(Ae=Ae.next={eventTime:Ye,lane:0,tag:G.tag,payload:G.payload,callback:G.callback,next:null});e:{var nt=s,st=G;switch(Ce=l,Ye=p,st.tag){case 1:if(nt=st.payload,typeof nt=="function"){Oe=nt.call(Ye,Oe,Ce);break e}Oe=nt;break e;case 3:nt.flags=nt.flags&-65537|128;case 0:if(nt=st.payload,Ce=typeof nt=="function"?nt.call(Ye,Oe,Ce):nt,Ce==null)break e;Oe=X({},Oe,Ce);break e;case 2:ri=!0}}G.callback!==null&&G.lane!==0&&(s.flags|=64,Ce=b.effects,Ce===null?b.effects=[G]:Ce.push(G))}else Ye={eventTime:Ye,lane:Ce,tag:G.tag,payload:G.payload,callback:G.callback,next:null},Ae===null?(ke=Ae=Ye,ne=Oe):Ae=Ae.next=Ye,R|=Ce;if(G=G.next,G===null){if(G=b.shared.pending,G===null)break;Ce=G,G=Ce.next,Ce.next=null,b.lastBaseUpdate=Ce,b.shared.pending=null}}while(!0);if(Ae===null&&(ne=Oe),b.baseState=ne,b.firstBaseUpdate=ke,b.lastBaseUpdate=Ae,l=b.shared.interleaved,l!==null){b=l;do R|=b.lane,b=b.next;while(b!==l)}else E===null&&(b.shared.lanes=0);Ji|=R,s.lanes=R,s.memoizedState=Oe}}function nv(s,l,p){if(s=l.effects,l.effects=null,s!==null)for(l=0;l<s.length;l++){var k=s[l],b=k.callback;if(b!==null){if(k.callback=null,k=p,typeof b!="function")throw Error(n(191,b));b.call(k)}}}var gc={},us=ei(gc),kc=ei(gc),wc=ei(gc);function Xi(s){if(s===gc)throw Error(n(174));return s}function Rp(s,l){switch(Mn(wc,l),Mn(kc,s),Mn(us,gc),s=l.nodeType,s){case 9:case 11:l=(l=l.documentElement)?l.namespaceURI:ln(null,"");break;default:s=s===8?l.parentNode:l,l=s.namespaceURI||null,s=s.tagName,l=ln(l,s)}zn(us),Mn(us,l)}function rl(){zn(us),zn(kc),zn(wc)}function rv(s){Xi(wc.current);var l=Xi(us.current),p=ln(l,s.type);l!==p&&(Mn(kc,s),Mn(us,p))}function Op(s){kc.current===s&&(zn(us),zn(kc))}var Yn=ei(0);function wd(s){for(var l=s;l!==null;){if(l.tag===13){var p=l.memoizedState;if(p!==null&&(p=p.dehydrated,p===null||p.data==="$?"||p.data==="$!"))return l}else if(l.tag===19&&l.memoizedProps.revealOrder!==void 0){if((l.flags&128)!==0)return l}else if(l.child!==null){l.child.return=l,l=l.child;continue}if(l===s)break;for(;l.sibling===null;){if(l.return===null||l.return===s)return null;l=l.return}l.sibling.return=l.return,l=l.sibling}return null}var Mp=[];function Pp(){for(var s=0;s<Mp.length;s++)Mp[s]._workInProgressVersionPrimary=null;Mp.length=0}var yd=j.ReactCurrentDispatcher,Lp=j.ReactCurrentBatchConfig,Qi=0,Xn=null,mr=null,br=null,vd=!1,yc=!1,vc=0,X$=0;function Pr(){throw Error(n(321))}function Dp(s,l){if(l===null)return!1;for(var p=0;p<l.length&&p<s.length;p++)if(!Jr(s[p],l[p]))return!1;return!0}function zp(s,l,p,k,b,E){if(Qi=E,Xn=l,l.memoizedState=null,l.updateQueue=null,l.lanes=0,yd.current=s===null||s.memoizedState===null?tC:nC,s=p(k,b),yc){E=0;do{if(yc=!1,vc=0,25<=E)throw Error(n(301));E+=1,br=mr=null,l.updateQueue=null,yd.current=rC,s=p(k,b)}while(yc)}if(yd.current=Ed,l=mr!==null&&mr.next!==null,Qi=0,br=mr=Xn=null,vd=!1,l)throw Error(n(300));return s}function Fp(){var s=vc!==0;return vc=0,s}function ds(){var s={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return br===null?Xn.memoizedState=br=s:br=br.next=s,br}function Io(){if(mr===null){var s=Xn.alternate;s=s!==null?s.memoizedState:null}else s=mr.next;var l=br===null?Xn.memoizedState:br.next;if(l!==null)br=l,mr=s;else{if(s===null)throw Error(n(310));mr=s,s={memoizedState:mr.memoizedState,baseState:mr.baseState,baseQueue:mr.baseQueue,queue:mr.queue,next:null},br===null?Xn.memoizedState=br=s:br=br.next=s}return br}function bc(s,l){return typeof l=="function"?l(s):l}function Bp(s){var l=Io(),p=l.queue;if(p===null)throw Error(n(311));p.lastRenderedReducer=s;var k=mr,b=k.baseQueue,E=p.pending;if(E!==null){if(b!==null){var R=b.next;b.next=E.next,E.next=R}k.baseQueue=b=E,p.pending=null}if(b!==null){E=b.next,k=k.baseState;var G=R=null,ne=null,ke=E;do{var Ae=ke.lane;if((Qi&Ae)===Ae)ne!==null&&(ne=ne.next={lane:0,action:ke.action,hasEagerState:ke.hasEagerState,eagerState:ke.eagerState,next:null}),k=ke.hasEagerState?ke.eagerState:s(k,ke.action);else{var Oe={lane:Ae,action:ke.action,hasEagerState:ke.hasEagerState,eagerState:ke.eagerState,next:null};ne===null?(G=ne=Oe,R=k):ne=ne.next=Oe,Xn.lanes|=Ae,Ji|=Ae}ke=ke.next}while(ke!==null&&ke!==E);ne===null?R=k:ne.next=G,Jr(k,l.memoizedState)||(ro=!0),l.memoizedState=k,l.baseState=R,l.baseQueue=ne,p.lastRenderedState=k}if(s=p.interleaved,s!==null){b=s;do E=b.lane,Xn.lanes|=E,Ji|=E,b=b.next;while(b!==s)}else b===null&&(p.lanes=0);return[l.memoizedState,p.dispatch]}function Up(s){var l=Io(),p=l.queue;if(p===null)throw Error(n(311));p.lastRenderedReducer=s;var k=p.dispatch,b=p.pending,E=l.memoizedState;if(b!==null){p.pending=null;var R=b=b.next;do E=s(E,R.action),R=R.next;while(R!==b);Jr(E,l.memoizedState)||(ro=!0),l.memoizedState=E,l.baseQueue===null&&(l.baseState=E),p.lastRenderedState=E}return[E,k]}function ov(){}function sv(s,l){var p=Xn,k=Io(),b=l(),E=!Jr(k.memoizedState,b);if(E&&(k.memoizedState=b,ro=!0),k=k.queue,Hp(lv.bind(null,p,k,s),[s]),k.getSnapshot!==l||E||br!==null&&br.memoizedState.tag&1){if(p.flags|=2048,xc(9,av.bind(null,p,k,b,l),void 0,null),xr===null)throw Error(n(349));(Qi&30)!==0||iv(p,l,b)}return b}function iv(s,l,p){s.flags|=16384,s={getSnapshot:l,value:p},l=Xn.updateQueue,l===null?(l={lastEffect:null,stores:null},Xn.updateQueue=l,l.stores=[s]):(p=l.stores,p===null?l.stores=[s]:p.push(s))}function av(s,l,p,k){l.value=p,l.getSnapshot=k,cv(l)&&uv(s)}function lv(s,l,p){return p(function(){cv(l)&&uv(s)})}function cv(s){var l=s.getSnapshot;s=s.value;try{var p=l();return!Jr(s,p)}catch{return!0}}function uv(s){var l=Ts(s,1);l!==null&&Yo(l,s,1,-1)}function dv(s){var l=ds();return typeof s=="function"&&(s=s()),l.memoizedState=l.baseState=s,s={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:bc,lastRenderedState:s},l.queue=s,s=s.dispatch=eC.bind(null,Xn,s),[l.memoizedState,s]}function xc(s,l,p,k){return s={tag:s,create:l,destroy:p,deps:k,next:null},l=Xn.updateQueue,l===null?(l={lastEffect:null,stores:null},Xn.updateQueue=l,l.lastEffect=s.next=s):(p=l.lastEffect,p===null?l.lastEffect=s.next=s:(k=p.next,p.next=s,s.next=k,l.lastEffect=s)),s}function fv(){return Io().memoizedState}function bd(s,l,p,k){var b=ds();Xn.flags|=s,b.memoizedState=xc(1|l,p,void 0,k===void 0?null:k)}function xd(s,l,p,k){var b=Io();k=k===void 0?null:k;var E=void 0;if(mr!==null){var R=mr.memoizedState;if(E=R.destroy,k!==null&&Dp(k,R.deps)){b.memoizedState=xc(l,p,E,k);return}}Xn.flags|=s,b.memoizedState=xc(1|l,p,E,k)}function hv(s,l){return bd(8390656,8,s,l)}function Hp(s,l){return xd(2048,8,s,l)}function pv(s,l){return xd(4,2,s,l)}function mv(s,l){return xd(4,4,s,l)}function gv(s,l){if(typeof l=="function")return s=s(),l(s),function(){l(null)};if(l!=null)return s=s(),l.current=s,function(){l.current=null}}function kv(s,l,p){return p=p!=null?p.concat([s]):null,xd(4,4,gv.bind(null,l,s),p)}function Wp(){}function wv(s,l){var p=Io();l=l===void 0?null:l;var k=p.memoizedState;return k!==null&&l!==null&&Dp(l,k[1])?k[0]:(p.memoizedState=[s,l],s)}function yv(s,l){var p=Io();l=l===void 0?null:l;var k=p.memoizedState;return k!==null&&l!==null&&Dp(l,k[1])?k[0]:(s=s(),p.memoizedState=[s,l],s)}function vv(s,l,p){return(Qi&21)===0?(s.baseState&&(s.baseState=!1,ro=!0),s.memoizedState=p):(Jr(p,l)||(p=Tt(),Xn.lanes|=p,Ji|=p,s.baseState=!0),l)}function Q$(s,l){var p=Gt;Gt=p!==0&&4>p?p:4,s(!0);var k=Lp.transition;Lp.transition={};try{s(!1),l()}finally{Gt=p,Lp.transition=k}}function bv(){return Io().memoizedState}function J$(s,l,p){var k=li(s);if(p={lane:k,action:p,hasEagerState:!1,eagerState:null,next:null},xv(s))Ev(l,p);else if(p=Jy(s,l,p,k),p!==null){var b=Gr();Yo(p,s,k,b),Sv(p,l,k)}}function eC(s,l,p){var k=li(s),b={lane:k,action:p,hasEagerState:!1,eagerState:null,next:null};if(xv(s))Ev(l,b);else{var E=s.alternate;if(s.lanes===0&&(E===null||E.lanes===0)&&(E=l.lastRenderedReducer,E!==null))try{var R=l.lastRenderedState,G=E(R,p);if(b.hasEagerState=!0,b.eagerState=G,Jr(G,R)){var ne=l.interleaved;ne===null?(b.next=b,Ap(l)):(b.next=ne.next,ne.next=b),l.interleaved=b;return}}catch{}finally{}p=Jy(s,l,b,k),p!==null&&(b=Gr(),Yo(p,s,k,b),Sv(p,l,k))}}function xv(s){var l=s.alternate;return s===Xn||l!==null&&l===Xn}function Ev(s,l){yc=vd=!0;var p=s.pending;p===null?l.next=l:(l.next=p.next,p.next=l),s.pending=l}function Sv(s,l,p){if((p&4194240)!==0){var k=l.lanes;k&=s.pendingLanes,p|=k,l.lanes=p,$r(s,p)}}var Ed={readContext:Ao,useCallback:Pr,useContext:Pr,useEffect:Pr,useImperativeHandle:Pr,useInsertionEffect:Pr,useLayoutEffect:Pr,useMemo:Pr,useReducer:Pr,useRef:Pr,useState:Pr,useDebugValue:Pr,useDeferredValue:Pr,useTransition:Pr,useMutableSource:Pr,useSyncExternalStore:Pr,useId:Pr,unstable_isNewReconciler:!1},tC={readContext:Ao,useCallback:function(s,l){return ds().memoizedState=[s,l===void 0?null:l],s},useContext:Ao,useEffect:hv,useImperativeHandle:function(s,l,p){return p=p!=null?p.concat([s]):null,bd(4194308,4,gv.bind(null,l,s),p)},useLayoutEffect:function(s,l){return bd(4194308,4,s,l)},useInsertionEffect:function(s,l){return bd(4,2,s,l)},useMemo:function(s,l){var p=ds();return l=l===void 0?null:l,s=s(),p.memoizedState=[s,l],s},useReducer:function(s,l,p){var k=ds();return l=p!==void 0?p(l):l,k.memoizedState=k.baseState=l,s={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:s,lastRenderedState:l},k.queue=s,s=s.dispatch=J$.bind(null,Xn,s),[k.memoizedState,s]},useRef:function(s){var l=ds();return s={current:s},l.memoizedState=s},useState:dv,useDebugValue:Wp,useDeferredValue:function(s){return ds().memoizedState=s},useTransition:function(){var s=dv(!1),l=s[0];return s=Q$.bind(null,s[1]),ds().memoizedState=s,[l,s]},useMutableSource:function(){},useSyncExternalStore:function(s,l,p){var k=Xn,b=ds();if(qn){if(p===void 0)throw Error(n(407));p=p()}else{if(p=l(),xr===null)throw Error(n(349));(Qi&30)!==0||iv(k,l,p)}b.memoizedState=p;var E={value:p,getSnapshot:l};return b.queue=E,hv(lv.bind(null,k,E,s),[s]),k.flags|=2048,xc(9,av.bind(null,k,E,p,l),void 0,null),p},useId:function(){var s=ds(),l=xr.identifierPrefix;if(qn){var p=Ns,k=_s;p=(k&~(1<<32-Ht(k)-1)).toString(32)+p,l=":"+l+"R"+p,p=vc++,0<p&&(l+="H"+p.toString(32)),l+=":"}else p=X$++,l=":"+l+"r"+p.toString(32)+":";return s.memoizedState=l},unstable_isNewReconciler:!1},nC={readContext:Ao,useCallback:wv,useContext:Ao,useEffect:Hp,useImperativeHandle:kv,useInsertionEffect:pv,useLayoutEffect:mv,useMemo:yv,useReducer:Bp,useRef:fv,useState:function(){return Bp(bc)},useDebugValue:Wp,useDeferredValue:function(s){var l=Io();return vv(l,mr.memoizedState,s)},useTransition:function(){var s=Bp(bc)[0],l=Io().memoizedState;return[s,l]},useMutableSource:ov,useSyncExternalStore:sv,useId:bv,unstable_isNewReconciler:!1},rC={readContext:Ao,useCallback:wv,useContext:Ao,useEffect:Hp,useImperativeHandle:kv,useInsertionEffect:pv,useLayoutEffect:mv,useMemo:yv,useReducer:Up,useRef:fv,useState:function(){return Up(bc)},useDebugValue:Wp,useDeferredValue:function(s){var l=Io();return mr===null?l.memoizedState=s:vv(l,mr.memoizedState,s)},useTransition:function(){var s=Up(bc)[0],l=Io().memoizedState;return[s,l]},useMutableSource:ov,useSyncExternalStore:sv,useId:bv,unstable_isNewReconciler:!1};function qo(s,l){if(s&&s.defaultProps){l=X({},l),s=s.defaultProps;for(var p in s)l[p]===void 0&&(l[p]=s[p]);return l}return l}function Kp(s,l,p,k){l=s.memoizedState,p=p(k,l),p=p==null?l:X({},l,p),s.memoizedState=p,s.lanes===0&&(s.updateQueue.baseState=p)}var Sd={isMounted:function(s){return(s=s._reactInternals)?An(s)===s:!1},enqueueSetState:function(s,l,p){s=s._reactInternals;var k=Gr(),b=li(s),E=js(k,b);E.payload=l,p!=null&&(E.callback=p),l=oi(s,E,b),l!==null&&(Yo(l,s,b,k),gd(l,s,b))},enqueueReplaceState:function(s,l,p){s=s._reactInternals;var k=Gr(),b=li(s),E=js(k,b);E.tag=1,E.payload=l,p!=null&&(E.callback=p),l=oi(s,E,b),l!==null&&(Yo(l,s,b,k),gd(l,s,b))},enqueueForceUpdate:function(s,l){s=s._reactInternals;var p=Gr(),k=li(s),b=js(p,k);b.tag=2,l!=null&&(b.callback=l),l=oi(s,b,k),l!==null&&(Yo(l,s,k,p),gd(l,s,k))}};function _v(s,l,p,k,b,E,R){return s=s.stateNode,typeof s.shouldComponentUpdate=="function"?s.shouldComponentUpdate(k,E,R):l.prototype&&l.prototype.isPureReactComponent?!Ys(p,k)||!Ys(b,E):!0}function Nv(s,l,p){var k=!1,b=ti,E=l.contextType;return typeof E=="object"&&E!==null?E=Ao(E):(b=no(l)?qi:Mr.current,k=l.contextTypes,E=(k=k!=null)?Ya(s,b):ti),l=new l(p,E),s.memoizedState=l.state!==null&&l.state!==void 0?l.state:null,l.updater=Sd,s.stateNode=l,l._reactInternals=s,k&&(s=s.stateNode,s.__reactInternalMemoizedUnmaskedChildContext=b,s.__reactInternalMemoizedMaskedChildContext=E),l}function Tv(s,l,p,k){s=l.state,typeof l.componentWillReceiveProps=="function"&&l.componentWillReceiveProps(p,k),typeof l.UNSAFE_componentWillReceiveProps=="function"&&l.UNSAFE_componentWillReceiveProps(p,k),l.state!==s&&Sd.enqueueReplaceState(l,l.state,null)}function Zp(s,l,p,k){var b=s.stateNode;b.props=p,b.state=s.memoizedState,b.refs={},Ip(s);var E=l.contextType;typeof E=="object"&&E!==null?b.context=Ao(E):(E=no(l)?qi:Mr.current,b.context=Ya(s,E)),b.state=s.memoizedState,E=l.getDerivedStateFromProps,typeof E=="function"&&(Kp(s,l,E,p),b.state=s.memoizedState),typeof l.getDerivedStateFromProps=="function"||typeof b.getSnapshotBeforeUpdate=="function"||typeof b.UNSAFE_componentWillMount!="function"&&typeof b.componentWillMount!="function"||(l=b.state,typeof b.componentWillMount=="function"&&b.componentWillMount(),typeof b.UNSAFE_componentWillMount=="function"&&b.UNSAFE_componentWillMount(),l!==b.state&&Sd.enqueueReplaceState(b,b.state,null),kd(s,p,b,k),b.state=s.memoizedState),typeof b.componentDidMount=="function"&&(s.flags|=4194308)}function ol(s,l){try{var p="",k=l;do p+=je(k),k=k.return;while(k);var b=p}catch(E){b=`
|
|
40
|
+
Error generating stack: `+E.message+`
|
|
41
|
+
`+E.stack}return{value:s,source:l,stack:b,digest:null}}function qp(s,l,p){return{value:s,source:null,stack:p??null,digest:l??null}}function Gp(s,l){try{console.error(l.value)}catch(p){setTimeout(function(){throw p})}}var oC=typeof WeakMap=="function"?WeakMap:Map;function jv(s,l,p){p=js(-1,p),p.tag=3,p.payload={element:null};var k=l.value;return p.callback=function(){Ad||(Ad=!0,cm=k),Gp(s,l)},p}function $v(s,l,p){p=js(-1,p),p.tag=3;var k=s.type.getDerivedStateFromError;if(typeof k=="function"){var b=l.value;p.payload=function(){return k(b)},p.callback=function(){Gp(s,l)}}var E=s.stateNode;return E!==null&&typeof E.componentDidCatch=="function"&&(p.callback=function(){Gp(s,l),typeof k!="function"&&(ii===null?ii=new Set([this]):ii.add(this));var R=l.stack;this.componentDidCatch(l.value,{componentStack:R!==null?R:""})}),p}function Cv(s,l,p){var k=s.pingCache;if(k===null){k=s.pingCache=new oC;var b=new Set;k.set(l,b)}else b=k.get(l),b===void 0&&(b=new Set,k.set(l,b));b.has(p)||(b.add(p),s=wC.bind(null,s,l,p),l.then(s,s))}function Av(s){do{var l;if((l=s.tag===13)&&(l=s.memoizedState,l=l!==null?l.dehydrated!==null:!0),l)return s;s=s.return}while(s!==null);return null}function Iv(s,l,p,k,b){return(s.mode&1)===0?(s===l?s.flags|=65536:(s.flags|=128,p.flags|=131072,p.flags&=-52805,p.tag===1&&(p.alternate===null?p.tag=17:(l=js(-1,1),l.tag=2,oi(p,l,1))),p.lanes|=1),s):(s.flags|=65536,s.lanes=b,s)}var sC=j.ReactCurrentOwner,ro=!1;function qr(s,l,p,k){l.child=s===null?Qy(l,null,p,k):el(l,s.child,p,k)}function Rv(s,l,p,k,b){p=p.render;var E=l.ref;return nl(l,b),k=zp(s,l,p,k,E,b),p=Fp(),s!==null&&!ro?(l.updateQueue=s.updateQueue,l.flags&=-2053,s.lanes&=~b,$s(s,l,b)):(qn&&p&&xp(l),l.flags|=1,qr(s,l,k,b),l.child)}function Ov(s,l,p,k,b){if(s===null){var E=p.type;return typeof E=="function"&&!gm(E)&&E.defaultProps===void 0&&p.compare===null&&p.defaultProps===void 0?(l.tag=15,l.type=E,Mv(s,l,E,k,b)):(s=Ld(p.type,null,k,l,l.mode,b),s.ref=l.ref,s.return=l,l.child=s)}if(E=s.child,(s.lanes&b)===0){var R=E.memoizedProps;if(p=p.compare,p=p!==null?p:Ys,p(R,k)&&s.ref===l.ref)return $s(s,l,b)}return l.flags|=1,s=ui(E,k),s.ref=l.ref,s.return=l,l.child=s}function Mv(s,l,p,k,b){if(s!==null){var E=s.memoizedProps;if(Ys(E,k)&&s.ref===l.ref)if(ro=!1,l.pendingProps=k=E,(s.lanes&b)!==0)(s.flags&131072)!==0&&(ro=!0);else return l.lanes=s.lanes,$s(s,l,b)}return Vp(s,l,p,k,b)}function Pv(s,l,p){var k=l.pendingProps,b=k.children,E=s!==null?s.memoizedState:null;if(k.mode==="hidden")if((l.mode&1)===0)l.memoizedState={baseLanes:0,cachePool:null,transitions:null},Mn(il,wo),wo|=p;else{if((p&1073741824)===0)return s=E!==null?E.baseLanes|p:p,l.lanes=l.childLanes=1073741824,l.memoizedState={baseLanes:s,cachePool:null,transitions:null},l.updateQueue=null,Mn(il,wo),wo|=s,null;l.memoizedState={baseLanes:0,cachePool:null,transitions:null},k=E!==null?E.baseLanes:p,Mn(il,wo),wo|=k}else E!==null?(k=E.baseLanes|p,l.memoizedState=null):k=p,Mn(il,wo),wo|=k;return qr(s,l,b,p),l.child}function Lv(s,l){var p=l.ref;(s===null&&p!==null||s!==null&&s.ref!==p)&&(l.flags|=512,l.flags|=2097152)}function Vp(s,l,p,k,b){var E=no(p)?qi:Mr.current;return E=Ya(l,E),nl(l,b),p=zp(s,l,p,k,E,b),k=Fp(),s!==null&&!ro?(l.updateQueue=s.updateQueue,l.flags&=-2053,s.lanes&=~b,$s(s,l,b)):(qn&&k&&xp(l),l.flags|=1,qr(s,l,p,b),l.child)}function Dv(s,l,p,k,b){if(no(p)){var E=!0;ld(l)}else E=!1;if(nl(l,b),l.stateNode===null)Nd(s,l),Nv(l,p,k),Zp(l,p,k,b),k=!0;else if(s===null){var R=l.stateNode,G=l.memoizedProps;R.props=G;var ne=R.context,ke=p.contextType;typeof ke=="object"&&ke!==null?ke=Ao(ke):(ke=no(p)?qi:Mr.current,ke=Ya(l,ke));var Ae=p.getDerivedStateFromProps,Oe=typeof Ae=="function"||typeof R.getSnapshotBeforeUpdate=="function";Oe||typeof R.UNSAFE_componentWillReceiveProps!="function"&&typeof R.componentWillReceiveProps!="function"||(G!==k||ne!==ke)&&Tv(l,R,k,ke),ri=!1;var Ce=l.memoizedState;R.state=Ce,kd(l,k,R,b),ne=l.memoizedState,G!==k||Ce!==ne||to.current||ri?(typeof Ae=="function"&&(Kp(l,p,Ae,k),ne=l.memoizedState),(G=ri||_v(l,p,G,k,Ce,ne,ke))?(Oe||typeof R.UNSAFE_componentWillMount!="function"&&typeof R.componentWillMount!="function"||(typeof R.componentWillMount=="function"&&R.componentWillMount(),typeof R.UNSAFE_componentWillMount=="function"&&R.UNSAFE_componentWillMount()),typeof R.componentDidMount=="function"&&(l.flags|=4194308)):(typeof R.componentDidMount=="function"&&(l.flags|=4194308),l.memoizedProps=k,l.memoizedState=ne),R.props=k,R.state=ne,R.context=ke,k=G):(typeof R.componentDidMount=="function"&&(l.flags|=4194308),k=!1)}else{R=l.stateNode,ev(s,l),G=l.memoizedProps,ke=l.type===l.elementType?G:qo(l.type,G),R.props=ke,Oe=l.pendingProps,Ce=R.context,ne=p.contextType,typeof ne=="object"&&ne!==null?ne=Ao(ne):(ne=no(p)?qi:Mr.current,ne=Ya(l,ne));var Ye=p.getDerivedStateFromProps;(Ae=typeof Ye=="function"||typeof R.getSnapshotBeforeUpdate=="function")||typeof R.UNSAFE_componentWillReceiveProps!="function"&&typeof R.componentWillReceiveProps!="function"||(G!==Oe||Ce!==ne)&&Tv(l,R,k,ne),ri=!1,Ce=l.memoizedState,R.state=Ce,kd(l,k,R,b);var nt=l.memoizedState;G!==Oe||Ce!==nt||to.current||ri?(typeof Ye=="function"&&(Kp(l,p,Ye,k),nt=l.memoizedState),(ke=ri||_v(l,p,ke,k,Ce,nt,ne)||!1)?(Ae||typeof R.UNSAFE_componentWillUpdate!="function"&&typeof R.componentWillUpdate!="function"||(typeof R.componentWillUpdate=="function"&&R.componentWillUpdate(k,nt,ne),typeof R.UNSAFE_componentWillUpdate=="function"&&R.UNSAFE_componentWillUpdate(k,nt,ne)),typeof R.componentDidUpdate=="function"&&(l.flags|=4),typeof R.getSnapshotBeforeUpdate=="function"&&(l.flags|=1024)):(typeof R.componentDidUpdate!="function"||G===s.memoizedProps&&Ce===s.memoizedState||(l.flags|=4),typeof R.getSnapshotBeforeUpdate!="function"||G===s.memoizedProps&&Ce===s.memoizedState||(l.flags|=1024),l.memoizedProps=k,l.memoizedState=nt),R.props=k,R.state=nt,R.context=ne,k=ke):(typeof R.componentDidUpdate!="function"||G===s.memoizedProps&&Ce===s.memoizedState||(l.flags|=4),typeof R.getSnapshotBeforeUpdate!="function"||G===s.memoizedProps&&Ce===s.memoizedState||(l.flags|=1024),k=!1)}return Yp(s,l,p,k,E,b)}function Yp(s,l,p,k,b,E){Lv(s,l);var R=(l.flags&128)!==0;if(!k&&!R)return b&&Hy(l,p,!1),$s(s,l,E);k=l.stateNode,sC.current=l;var G=R&&typeof p.getDerivedStateFromError!="function"?null:k.render();return l.flags|=1,s!==null&&R?(l.child=el(l,s.child,null,E),l.child=el(l,null,G,E)):qr(s,l,G,E),l.memoizedState=k.state,b&&Hy(l,p,!0),l.child}function zv(s){var l=s.stateNode;l.pendingContext?By(s,l.pendingContext,l.pendingContext!==l.context):l.context&&By(s,l.context,!1),Rp(s,l.containerInfo)}function Fv(s,l,p,k,b){return Ja(),Np(b),l.flags|=256,qr(s,l,p,k),l.child}var Xp={dehydrated:null,treeContext:null,retryLane:0};function Qp(s){return{baseLanes:s,cachePool:null,transitions:null}}function Bv(s,l,p){var k=l.pendingProps,b=Yn.current,E=!1,R=(l.flags&128)!==0,G;if((G=R)||(G=s!==null&&s.memoizedState===null?!1:(b&2)!==0),G?(E=!0,l.flags&=-129):(s===null||s.memoizedState!==null)&&(b|=1),Mn(Yn,b&1),s===null)return _p(l),s=l.memoizedState,s!==null&&(s=s.dehydrated,s!==null)?((l.mode&1)===0?l.lanes=1:s.data==="$!"?l.lanes=8:l.lanes=1073741824,null):(R=k.children,s=k.fallback,E?(k=l.mode,E=l.child,R={mode:"hidden",children:R},(k&1)===0&&E!==null?(E.childLanes=0,E.pendingProps=R):E=Dd(R,k,0,null),s=ra(s,k,p,null),E.return=l,s.return=l,E.sibling=s,l.child=E,l.child.memoizedState=Qp(p),l.memoizedState=Xp,s):Jp(l,R));if(b=s.memoizedState,b!==null&&(G=b.dehydrated,G!==null))return iC(s,l,R,k,G,b,p);if(E){E=k.fallback,R=l.mode,b=s.child,G=b.sibling;var ne={mode:"hidden",children:k.children};return(R&1)===0&&l.child!==b?(k=l.child,k.childLanes=0,k.pendingProps=ne,l.deletions=null):(k=ui(b,ne),k.subtreeFlags=b.subtreeFlags&14680064),G!==null?E=ui(G,E):(E=ra(E,R,p,null),E.flags|=2),E.return=l,k.return=l,k.sibling=E,l.child=k,k=E,E=l.child,R=s.child.memoizedState,R=R===null?Qp(p):{baseLanes:R.baseLanes|p,cachePool:null,transitions:R.transitions},E.memoizedState=R,E.childLanes=s.childLanes&~p,l.memoizedState=Xp,k}return E=s.child,s=E.sibling,k=ui(E,{mode:"visible",children:k.children}),(l.mode&1)===0&&(k.lanes=p),k.return=l,k.sibling=null,s!==null&&(p=l.deletions,p===null?(l.deletions=[s],l.flags|=16):p.push(s)),l.child=k,l.memoizedState=null,k}function Jp(s,l){return l=Dd({mode:"visible",children:l},s.mode,0,null),l.return=s,s.child=l}function _d(s,l,p,k){return k!==null&&Np(k),el(l,s.child,null,p),s=Jp(l,l.pendingProps.children),s.flags|=2,l.memoizedState=null,s}function iC(s,l,p,k,b,E,R){if(p)return l.flags&256?(l.flags&=-257,k=qp(Error(n(422))),_d(s,l,R,k)):l.memoizedState!==null?(l.child=s.child,l.flags|=128,null):(E=k.fallback,b=l.mode,k=Dd({mode:"visible",children:k.children},b,0,null),E=ra(E,b,R,null),E.flags|=2,k.return=l,E.return=l,k.sibling=E,l.child=k,(l.mode&1)!==0&&el(l,s.child,null,R),l.child.memoizedState=Qp(R),l.memoizedState=Xp,E);if((l.mode&1)===0)return _d(s,l,R,null);if(b.data==="$!"){if(k=b.nextSibling&&b.nextSibling.dataset,k)var G=k.dgst;return k=G,E=Error(n(419)),k=qp(E,k,void 0),_d(s,l,R,k)}if(G=(R&s.childLanes)!==0,ro||G){if(k=xr,k!==null){switch(R&-R){case 4:b=2;break;case 16:b=8;break;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:b=32;break;case 536870912:b=268435456;break;default:b=0}b=(b&(k.suspendedLanes|R))!==0?0:b,b!==0&&b!==E.retryLane&&(E.retryLane=b,Ts(s,b),Yo(k,s,b,-1))}return mm(),k=qp(Error(n(421))),_d(s,l,R,k)}return b.data==="$?"?(l.flags|=128,l.child=s.child,l=yC.bind(null,s),b._reactRetry=l,null):(s=E.treeContext,ko=Js(b.nextSibling),go=l,qn=!0,Zo=null,s!==null&&($o[Co++]=_s,$o[Co++]=Ns,$o[Co++]=Gi,_s=s.id,Ns=s.overflow,Gi=l),l=Jp(l,k.children),l.flags|=4096,l)}function Uv(s,l,p){s.lanes|=l;var k=s.alternate;k!==null&&(k.lanes|=l),Cp(s.return,l,p)}function em(s,l,p,k,b){var E=s.memoizedState;E===null?s.memoizedState={isBackwards:l,rendering:null,renderingStartTime:0,last:k,tail:p,tailMode:b}:(E.isBackwards=l,E.rendering=null,E.renderingStartTime=0,E.last=k,E.tail=p,E.tailMode=b)}function Hv(s,l,p){var k=l.pendingProps,b=k.revealOrder,E=k.tail;if(qr(s,l,k.children,p),k=Yn.current,(k&2)!==0)k=k&1|2,l.flags|=128;else{if(s!==null&&(s.flags&128)!==0)e:for(s=l.child;s!==null;){if(s.tag===13)s.memoizedState!==null&&Uv(s,p,l);else if(s.tag===19)Uv(s,p,l);else if(s.child!==null){s.child.return=s,s=s.child;continue}if(s===l)break e;for(;s.sibling===null;){if(s.return===null||s.return===l)break e;s=s.return}s.sibling.return=s.return,s=s.sibling}k&=1}if(Mn(Yn,k),(l.mode&1)===0)l.memoizedState=null;else switch(b){case"forwards":for(p=l.child,b=null;p!==null;)s=p.alternate,s!==null&&wd(s)===null&&(b=p),p=p.sibling;p=b,p===null?(b=l.child,l.child=null):(b=p.sibling,p.sibling=null),em(l,!1,b,p,E);break;case"backwards":for(p=null,b=l.child,l.child=null;b!==null;){if(s=b.alternate,s!==null&&wd(s)===null){l.child=b;break}s=b.sibling,b.sibling=p,p=b,b=s}em(l,!0,p,null,E);break;case"together":em(l,!1,null,null,void 0);break;default:l.memoizedState=null}return l.child}function Nd(s,l){(l.mode&1)===0&&s!==null&&(s.alternate=null,l.alternate=null,l.flags|=2)}function $s(s,l,p){if(s!==null&&(l.dependencies=s.dependencies),Ji|=l.lanes,(p&l.childLanes)===0)return null;if(s!==null&&l.child!==s.child)throw Error(n(153));if(l.child!==null){for(s=l.child,p=ui(s,s.pendingProps),l.child=p,p.return=l;s.sibling!==null;)s=s.sibling,p=p.sibling=ui(s,s.pendingProps),p.return=l;p.sibling=null}return l.child}function aC(s,l,p){switch(l.tag){case 3:zv(l),Ja();break;case 5:rv(l);break;case 1:no(l.type)&&ld(l);break;case 4:Rp(l,l.stateNode.containerInfo);break;case 10:var k=l.type._context,b=l.memoizedProps.value;Mn(pd,k._currentValue),k._currentValue=b;break;case 13:if(k=l.memoizedState,k!==null)return k.dehydrated!==null?(Mn(Yn,Yn.current&1),l.flags|=128,null):(p&l.child.childLanes)!==0?Bv(s,l,p):(Mn(Yn,Yn.current&1),s=$s(s,l,p),s!==null?s.sibling:null);Mn(Yn,Yn.current&1);break;case 19:if(k=(p&l.childLanes)!==0,(s.flags&128)!==0){if(k)return Hv(s,l,p);l.flags|=128}if(b=l.memoizedState,b!==null&&(b.rendering=null,b.tail=null,b.lastEffect=null),Mn(Yn,Yn.current),k)break;return null;case 22:case 23:return l.lanes=0,Pv(s,l,p)}return $s(s,l,p)}var Wv,tm,Kv,Zv;Wv=function(s,l){for(var p=l.child;p!==null;){if(p.tag===5||p.tag===6)s.appendChild(p.stateNode);else if(p.tag!==4&&p.child!==null){p.child.return=p,p=p.child;continue}if(p===l)break;for(;p.sibling===null;){if(p.return===null||p.return===l)return;p=p.return}p.sibling.return=p.return,p=p.sibling}},tm=function(){},Kv=function(s,l,p,k){var b=s.memoizedProps;if(b!==k){s=l.stateNode,Xi(us.current);var E=null;switch(p){case"input":b=ge(s,b),k=ge(s,k),E=[];break;case"select":b=X({},b,{value:void 0}),k=X({},k,{value:void 0}),E=[];break;case"textarea":b=Qt(s,b),k=Qt(s,k),E=[];break;default:typeof b.onClick!="function"&&typeof k.onClick=="function"&&(s.onclick=sd)}er(p,k);var R;p=null;for(ke in b)if(!k.hasOwnProperty(ke)&&b.hasOwnProperty(ke)&&b[ke]!=null)if(ke==="style"){var G=b[ke];for(R in G)G.hasOwnProperty(R)&&(p||(p={}),p[R]="")}else ke!=="dangerouslySetInnerHTML"&&ke!=="children"&&ke!=="suppressContentEditableWarning"&&ke!=="suppressHydrationWarning"&&ke!=="autoFocus"&&(o.hasOwnProperty(ke)?E||(E=[]):(E=E||[]).push(ke,null));for(ke in k){var ne=k[ke];if(G=b!=null?b[ke]:void 0,k.hasOwnProperty(ke)&&ne!==G&&(ne!=null||G!=null))if(ke==="style")if(G){for(R in G)!G.hasOwnProperty(R)||ne&&ne.hasOwnProperty(R)||(p||(p={}),p[R]="");for(R in ne)ne.hasOwnProperty(R)&&G[R]!==ne[R]&&(p||(p={}),p[R]=ne[R])}else p||(E||(E=[]),E.push(ke,p)),p=ne;else ke==="dangerouslySetInnerHTML"?(ne=ne?ne.__html:void 0,G=G?G.__html:void 0,ne!=null&&G!==ne&&(E=E||[]).push(ke,ne)):ke==="children"?typeof ne!="string"&&typeof ne!="number"||(E=E||[]).push(ke,""+ne):ke!=="suppressContentEditableWarning"&&ke!=="suppressHydrationWarning"&&(o.hasOwnProperty(ke)?(ne!=null&&ke==="onScroll"&&Dn("scroll",s),E||G===ne||(E=[])):(E=E||[]).push(ke,ne))}p&&(E=E||[]).push("style",p);var ke=E;(l.updateQueue=ke)&&(l.flags|=4)}},Zv=function(s,l,p,k){p!==k&&(l.flags|=4)};function Ec(s,l){if(!qn)switch(s.tailMode){case"hidden":l=s.tail;for(var p=null;l!==null;)l.alternate!==null&&(p=l),l=l.sibling;p===null?s.tail=null:p.sibling=null;break;case"collapsed":p=s.tail;for(var k=null;p!==null;)p.alternate!==null&&(k=p),p=p.sibling;k===null?l||s.tail===null?s.tail=null:s.tail.sibling=null:k.sibling=null}}function Lr(s){var l=s.alternate!==null&&s.alternate.child===s.child,p=0,k=0;if(l)for(var b=s.child;b!==null;)p|=b.lanes|b.childLanes,k|=b.subtreeFlags&14680064,k|=b.flags&14680064,b.return=s,b=b.sibling;else for(b=s.child;b!==null;)p|=b.lanes|b.childLanes,k|=b.subtreeFlags,k|=b.flags,b.return=s,b=b.sibling;return s.subtreeFlags|=k,s.childLanes=p,l}function lC(s,l,p){var k=l.pendingProps;switch(Ep(l),l.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Lr(l),null;case 1:return no(l.type)&&ad(),Lr(l),null;case 3:return k=l.stateNode,rl(),zn(to),zn(Mr),Pp(),k.pendingContext&&(k.context=k.pendingContext,k.pendingContext=null),(s===null||s.child===null)&&(fd(l)?l.flags|=4:s===null||s.memoizedState.isDehydrated&&(l.flags&256)===0||(l.flags|=1024,Zo!==null&&(fm(Zo),Zo=null))),tm(s,l),Lr(l),null;case 5:Op(l);var b=Xi(wc.current);if(p=l.type,s!==null&&l.stateNode!=null)Kv(s,l,p,k,b),s.ref!==l.ref&&(l.flags|=512,l.flags|=2097152);else{if(!k){if(l.stateNode===null)throw Error(n(166));return Lr(l),null}if(s=Xi(us.current),fd(l)){k=l.stateNode,p=l.type;var E=l.memoizedProps;switch(k[cs]=l,k[hc]=E,s=(l.mode&1)!==0,p){case"dialog":Dn("cancel",k),Dn("close",k);break;case"iframe":case"object":case"embed":Dn("load",k);break;case"video":case"audio":for(b=0;b<uc.length;b++)Dn(uc[b],k);break;case"source":Dn("error",k);break;case"img":case"image":case"link":Dn("error",k),Dn("load",k);break;case"details":Dn("toggle",k);break;case"input":Be(k,E),Dn("invalid",k);break;case"select":k._wrapperState={wasMultiple:!!E.multiple},Dn("invalid",k);break;case"textarea":an(k,E),Dn("invalid",k)}er(p,E),b=null;for(var R in E)if(E.hasOwnProperty(R)){var G=E[R];R==="children"?typeof G=="string"?k.textContent!==G&&(E.suppressHydrationWarning!==!0&&od(k.textContent,G,s),b=["children",G]):typeof G=="number"&&k.textContent!==""+G&&(E.suppressHydrationWarning!==!0&&od(k.textContent,G,s),b=["children",""+G]):o.hasOwnProperty(R)&&G!=null&&R==="onScroll"&&Dn("scroll",k)}switch(p){case"input":ye(k),pt(k,E,!0);break;case"textarea":ye(k),Qe(k);break;case"select":case"option":break;default:typeof E.onClick=="function"&&(k.onclick=sd)}k=b,l.updateQueue=k,k!==null&&(l.flags|=4)}else{R=b.nodeType===9?b:b.ownerDocument,s==="http://www.w3.org/1999/xhtml"&&(s=Wt(p)),s==="http://www.w3.org/1999/xhtml"?p==="script"?(s=R.createElement("div"),s.innerHTML="<script><\/script>",s=s.removeChild(s.firstChild)):typeof k.is=="string"?s=R.createElement(p,{is:k.is}):(s=R.createElement(p),p==="select"&&(R=s,k.multiple?R.multiple=!0:k.size&&(R.size=k.size))):s=R.createElementNS(s,p),s[cs]=l,s[hc]=k,Wv(s,l,!1,!1),l.stateNode=s;e:{switch(R=te(p,k),p){case"dialog":Dn("cancel",s),Dn("close",s),b=k;break;case"iframe":case"object":case"embed":Dn("load",s),b=k;break;case"video":case"audio":for(b=0;b<uc.length;b++)Dn(uc[b],s);b=k;break;case"source":Dn("error",s),b=k;break;case"img":case"image":case"link":Dn("error",s),Dn("load",s),b=k;break;case"details":Dn("toggle",s),b=k;break;case"input":Be(s,k),b=ge(s,k),Dn("invalid",s);break;case"option":b=k;break;case"select":s._wrapperState={wasMultiple:!!k.multiple},b=X({},k,{value:void 0}),Dn("invalid",s);break;case"textarea":an(s,k),b=Qt(s,k),Dn("invalid",s);break;default:b=k}er(p,b),G=b;for(E in G)if(G.hasOwnProperty(E)){var ne=G[E];E==="style"?_t(s,ne):E==="dangerouslySetInnerHTML"?(ne=ne?ne.__html:void 0,ne!=null&&mt(s,ne)):E==="children"?typeof ne=="string"?(p!=="textarea"||ne!=="")&&Vt(s,ne):typeof ne=="number"&&Vt(s,""+ne):E!=="suppressContentEditableWarning"&&E!=="suppressHydrationWarning"&&E!=="autoFocus"&&(o.hasOwnProperty(E)?ne!=null&&E==="onScroll"&&Dn("scroll",s):ne!=null&&T(s,E,ne,R))}switch(p){case"input":ye(s),pt(s,k,!1);break;case"textarea":ye(s),Qe(s);break;case"option":k.value!=null&&s.setAttribute("value",""+H(k.value));break;case"select":s.multiple=!!k.multiple,E=k.value,E!=null?Ue(s,!!k.multiple,E,!1):k.defaultValue!=null&&Ue(s,!!k.multiple,k.defaultValue,!0);break;default:typeof b.onClick=="function"&&(s.onclick=sd)}switch(p){case"button":case"input":case"select":case"textarea":k=!!k.autoFocus;break e;case"img":k=!0;break e;default:k=!1}}k&&(l.flags|=4)}l.ref!==null&&(l.flags|=512,l.flags|=2097152)}return Lr(l),null;case 6:if(s&&l.stateNode!=null)Zv(s,l,s.memoizedProps,k);else{if(typeof k!="string"&&l.stateNode===null)throw Error(n(166));if(p=Xi(wc.current),Xi(us.current),fd(l)){if(k=l.stateNode,p=l.memoizedProps,k[cs]=l,(E=k.nodeValue!==p)&&(s=go,s!==null))switch(s.tag){case 3:od(k.nodeValue,p,(s.mode&1)!==0);break;case 5:s.memoizedProps.suppressHydrationWarning!==!0&&od(k.nodeValue,p,(s.mode&1)!==0)}E&&(l.flags|=4)}else k=(p.nodeType===9?p:p.ownerDocument).createTextNode(k),k[cs]=l,l.stateNode=k}return Lr(l),null;case 13:if(zn(Yn),k=l.memoizedState,s===null||s.memoizedState!==null&&s.memoizedState.dehydrated!==null){if(qn&&ko!==null&&(l.mode&1)!==0&&(l.flags&128)===0)Vy(),Ja(),l.flags|=98560,E=!1;else if(E=fd(l),k!==null&&k.dehydrated!==null){if(s===null){if(!E)throw Error(n(318));if(E=l.memoizedState,E=E!==null?E.dehydrated:null,!E)throw Error(n(317));E[cs]=l}else Ja(),(l.flags&128)===0&&(l.memoizedState=null),l.flags|=4;Lr(l),E=!1}else Zo!==null&&(fm(Zo),Zo=null),E=!0;if(!E)return l.flags&65536?l:null}return(l.flags&128)!==0?(l.lanes=p,l):(k=k!==null,k!==(s!==null&&s.memoizedState!==null)&&k&&(l.child.flags|=8192,(l.mode&1)!==0&&(s===null||(Yn.current&1)!==0?gr===0&&(gr=3):mm())),l.updateQueue!==null&&(l.flags|=4),Lr(l),null);case 4:return rl(),tm(s,l),s===null&&dc(l.stateNode.containerInfo),Lr(l),null;case 10:return $p(l.type._context),Lr(l),null;case 17:return no(l.type)&&ad(),Lr(l),null;case 19:if(zn(Yn),E=l.memoizedState,E===null)return Lr(l),null;if(k=(l.flags&128)!==0,R=E.rendering,R===null)if(k)Ec(E,!1);else{if(gr!==0||s!==null&&(s.flags&128)!==0)for(s=l.child;s!==null;){if(R=wd(s),R!==null){for(l.flags|=128,Ec(E,!1),k=R.updateQueue,k!==null&&(l.updateQueue=k,l.flags|=4),l.subtreeFlags=0,k=p,p=l.child;p!==null;)E=p,s=k,E.flags&=14680066,R=E.alternate,R===null?(E.childLanes=0,E.lanes=s,E.child=null,E.subtreeFlags=0,E.memoizedProps=null,E.memoizedState=null,E.updateQueue=null,E.dependencies=null,E.stateNode=null):(E.childLanes=R.childLanes,E.lanes=R.lanes,E.child=R.child,E.subtreeFlags=0,E.deletions=null,E.memoizedProps=R.memoizedProps,E.memoizedState=R.memoizedState,E.updateQueue=R.updateQueue,E.type=R.type,s=R.dependencies,E.dependencies=s===null?null:{lanes:s.lanes,firstContext:s.firstContext}),p=p.sibling;return Mn(Yn,Yn.current&1|2),l.child}s=s.sibling}E.tail!==null&&Zt()>al&&(l.flags|=128,k=!0,Ec(E,!1),l.lanes=4194304)}else{if(!k)if(s=wd(R),s!==null){if(l.flags|=128,k=!0,p=s.updateQueue,p!==null&&(l.updateQueue=p,l.flags|=4),Ec(E,!0),E.tail===null&&E.tailMode==="hidden"&&!R.alternate&&!qn)return Lr(l),null}else 2*Zt()-E.renderingStartTime>al&&p!==1073741824&&(l.flags|=128,k=!0,Ec(E,!1),l.lanes=4194304);E.isBackwards?(R.sibling=l.child,l.child=R):(p=E.last,p!==null?p.sibling=R:l.child=R,E.last=R)}return E.tail!==null?(l=E.tail,E.rendering=l,E.tail=l.sibling,E.renderingStartTime=Zt(),l.sibling=null,p=Yn.current,Mn(Yn,k?p&1|2:p&1),l):(Lr(l),null);case 22:case 23:return pm(),k=l.memoizedState!==null,s!==null&&s.memoizedState!==null!==k&&(l.flags|=8192),k&&(l.mode&1)!==0?(wo&1073741824)!==0&&(Lr(l),l.subtreeFlags&6&&(l.flags|=8192)):Lr(l),null;case 24:return null;case 25:return null}throw Error(n(156,l.tag))}function cC(s,l){switch(Ep(l),l.tag){case 1:return no(l.type)&&ad(),s=l.flags,s&65536?(l.flags=s&-65537|128,l):null;case 3:return rl(),zn(to),zn(Mr),Pp(),s=l.flags,(s&65536)!==0&&(s&128)===0?(l.flags=s&-65537|128,l):null;case 5:return Op(l),null;case 13:if(zn(Yn),s=l.memoizedState,s!==null&&s.dehydrated!==null){if(l.alternate===null)throw Error(n(340));Ja()}return s=l.flags,s&65536?(l.flags=s&-65537|128,l):null;case 19:return zn(Yn),null;case 4:return rl(),null;case 10:return $p(l.type._context),null;case 22:case 23:return pm(),null;case 24:return null;default:return null}}var Td=!1,Dr=!1,uC=typeof WeakSet=="function"?WeakSet:Set,et=null;function sl(s,l){var p=s.ref;if(p!==null)if(typeof p=="function")try{p(null)}catch(k){nr(s,l,k)}else p.current=null}function nm(s,l,p){try{p()}catch(k){nr(s,l,k)}}var qv=!1;function dC(s,l){if(pp=Ca,s=Pe(),ht(s)){if("selectionStart"in s)var p={start:s.selectionStart,end:s.selectionEnd};else e:{p=(p=s.ownerDocument)&&p.defaultView||window;var k=p.getSelection&&p.getSelection();if(k&&k.rangeCount!==0){p=k.anchorNode;var b=k.anchorOffset,E=k.focusNode;k=k.focusOffset;try{p.nodeType,E.nodeType}catch{p=null;break e}var R=0,G=-1,ne=-1,ke=0,Ae=0,Oe=s,Ce=null;t:for(;;){for(var Ye;Oe!==p||b!==0&&Oe.nodeType!==3||(G=R+b),Oe!==E||k!==0&&Oe.nodeType!==3||(ne=R+k),Oe.nodeType===3&&(R+=Oe.nodeValue.length),(Ye=Oe.firstChild)!==null;)Ce=Oe,Oe=Ye;for(;;){if(Oe===s)break t;if(Ce===p&&++ke===b&&(G=R),Ce===E&&++Ae===k&&(ne=R),(Ye=Oe.nextSibling)!==null)break;Oe=Ce,Ce=Oe.parentNode}Oe=Ye}p=G===-1||ne===-1?null:{start:G,end:ne}}else p=null}p=p||{start:0,end:0}}else p=null;for(mp={focusedElem:s,selectionRange:p},Ca=!1,et=l;et!==null;)if(l=et,s=l.child,(l.subtreeFlags&1028)!==0&&s!==null)s.return=l,et=s;else for(;et!==null;){l=et;try{var nt=l.alternate;if((l.flags&1024)!==0)switch(l.tag){case 0:case 11:case 15:break;case 1:if(nt!==null){var st=nt.memoizedProps,or=nt.memoizedState,ue=l.stateNode,ie=ue.getSnapshotBeforeUpdate(l.elementType===l.type?st:qo(l.type,st),or);ue.__reactInternalSnapshotBeforeUpdate=ie}break;case 3:var fe=l.stateNode.containerInfo;fe.nodeType===1?fe.textContent="":fe.nodeType===9&&fe.documentElement&&fe.removeChild(fe.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(n(163))}}catch(Fe){nr(l,l.return,Fe)}if(s=l.sibling,s!==null){s.return=l.return,et=s;break}et=l.return}return nt=qv,qv=!1,nt}function Sc(s,l,p){var k=l.updateQueue;if(k=k!==null?k.lastEffect:null,k!==null){var b=k=k.next;do{if((b.tag&s)===s){var E=b.destroy;b.destroy=void 0,E!==void 0&&nm(l,p,E)}b=b.next}while(b!==k)}}function jd(s,l){if(l=l.updateQueue,l=l!==null?l.lastEffect:null,l!==null){var p=l=l.next;do{if((p.tag&s)===s){var k=p.create;p.destroy=k()}p=p.next}while(p!==l)}}function rm(s){var l=s.ref;if(l!==null){var p=s.stateNode;switch(s.tag){case 5:s=p;break;default:s=p}typeof l=="function"?l(s):l.current=s}}function Gv(s){var l=s.alternate;l!==null&&(s.alternate=null,Gv(l)),s.child=null,s.deletions=null,s.sibling=null,s.tag===5&&(l=s.stateNode,l!==null&&(delete l[cs],delete l[hc],delete l[yp],delete l[q$],delete l[G$])),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 Vv(s){return s.tag===5||s.tag===3||s.tag===4}function Yv(s){e:for(;;){for(;s.sibling===null;){if(s.return===null||Vv(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 om(s,l,p){var k=s.tag;if(k===5||k===6)s=s.stateNode,l?p.nodeType===8?p.parentNode.insertBefore(s,l):p.insertBefore(s,l):(p.nodeType===8?(l=p.parentNode,l.insertBefore(s,p)):(l=p,l.appendChild(s)),p=p._reactRootContainer,p!=null||l.onclick!==null||(l.onclick=sd));else if(k!==4&&(s=s.child,s!==null))for(om(s,l,p),s=s.sibling;s!==null;)om(s,l,p),s=s.sibling}function sm(s,l,p){var k=s.tag;if(k===5||k===6)s=s.stateNode,l?p.insertBefore(s,l):p.appendChild(s);else if(k!==4&&(s=s.child,s!==null))for(sm(s,l,p),s=s.sibling;s!==null;)sm(s,l,p),s=s.sibling}var Ar=null,Go=!1;function si(s,l,p){for(p=p.child;p!==null;)Xv(s,l,p),p=p.sibling}function Xv(s,l,p){if(it&&typeof it.onCommitFiberUnmount=="function")try{it.onCommitFiberUnmount(bt,p)}catch{}switch(p.tag){case 5:Dr||sl(p,l);case 6:var k=Ar,b=Go;Ar=null,si(s,l,p),Ar=k,Go=b,Ar!==null&&(Go?(s=Ar,p=p.stateNode,s.nodeType===8?s.parentNode.removeChild(p):s.removeChild(p)):Ar.removeChild(p.stateNode));break;case 18:Ar!==null&&(Go?(s=Ar,p=p.stateNode,s.nodeType===8?wp(s.parentNode,p):s.nodeType===1&&wp(s,p),Mi(s)):wp(Ar,p.stateNode));break;case 4:k=Ar,b=Go,Ar=p.stateNode.containerInfo,Go=!0,si(s,l,p),Ar=k,Go=b;break;case 0:case 11:case 14:case 15:if(!Dr&&(k=p.updateQueue,k!==null&&(k=k.lastEffect,k!==null))){b=k=k.next;do{var E=b,R=E.destroy;E=E.tag,R!==void 0&&((E&2)!==0||(E&4)!==0)&&nm(p,l,R),b=b.next}while(b!==k)}si(s,l,p);break;case 1:if(!Dr&&(sl(p,l),k=p.stateNode,typeof k.componentWillUnmount=="function"))try{k.props=p.memoizedProps,k.state=p.memoizedState,k.componentWillUnmount()}catch(G){nr(p,l,G)}si(s,l,p);break;case 21:si(s,l,p);break;case 22:p.mode&1?(Dr=(k=Dr)||p.memoizedState!==null,si(s,l,p),Dr=k):si(s,l,p);break;default:si(s,l,p)}}function Qv(s){var l=s.updateQueue;if(l!==null){s.updateQueue=null;var p=s.stateNode;p===null&&(p=s.stateNode=new uC),l.forEach(function(k){var b=vC.bind(null,s,k);p.has(k)||(p.add(k),k.then(b,b))})}}function Vo(s,l){var p=l.deletions;if(p!==null)for(var k=0;k<p.length;k++){var b=p[k];try{var E=s,R=l,G=R;e:for(;G!==null;){switch(G.tag){case 5:Ar=G.stateNode,Go=!1;break e;case 3:Ar=G.stateNode.containerInfo,Go=!0;break e;case 4:Ar=G.stateNode.containerInfo,Go=!0;break e}G=G.return}if(Ar===null)throw Error(n(160));Xv(E,R,b),Ar=null,Go=!1;var ne=b.alternate;ne!==null&&(ne.return=null),b.return=null}catch(ke){nr(b,l,ke)}}if(l.subtreeFlags&12854)for(l=l.child;l!==null;)Jv(l,s),l=l.sibling}function Jv(s,l){var p=s.alternate,k=s.flags;switch(s.tag){case 0:case 11:case 14:case 15:if(Vo(l,s),fs(s),k&4){try{Sc(3,s,s.return),jd(3,s)}catch(st){nr(s,s.return,st)}try{Sc(5,s,s.return)}catch(st){nr(s,s.return,st)}}break;case 1:Vo(l,s),fs(s),k&512&&p!==null&&sl(p,p.return);break;case 5:if(Vo(l,s),fs(s),k&512&&p!==null&&sl(p,p.return),s.flags&32){var b=s.stateNode;try{Vt(b,"")}catch(st){nr(s,s.return,st)}}if(k&4&&(b=s.stateNode,b!=null)){var E=s.memoizedProps,R=p!==null?p.memoizedProps:E,G=s.type,ne=s.updateQueue;if(s.updateQueue=null,ne!==null)try{G==="input"&&E.type==="radio"&&E.name!=null&&Ie(b,E),te(G,R);var ke=te(G,E);for(R=0;R<ne.length;R+=2){var Ae=ne[R],Oe=ne[R+1];Ae==="style"?_t(b,Oe):Ae==="dangerouslySetInnerHTML"?mt(b,Oe):Ae==="children"?Vt(b,Oe):T(b,Ae,Oe,ke)}switch(G){case"input":We(b,E);break;case"textarea":Ft(b,E);break;case"select":var Ce=b._wrapperState.wasMultiple;b._wrapperState.wasMultiple=!!E.multiple;var Ye=E.value;Ye!=null?Ue(b,!!E.multiple,Ye,!1):Ce!==!!E.multiple&&(E.defaultValue!=null?Ue(b,!!E.multiple,E.defaultValue,!0):Ue(b,!!E.multiple,E.multiple?[]:"",!1))}b[hc]=E}catch(st){nr(s,s.return,st)}}break;case 6:if(Vo(l,s),fs(s),k&4){if(s.stateNode===null)throw Error(n(162));b=s.stateNode,E=s.memoizedProps;try{b.nodeValue=E}catch(st){nr(s,s.return,st)}}break;case 3:if(Vo(l,s),fs(s),k&4&&p!==null&&p.memoizedState.isDehydrated)try{Mi(l.containerInfo)}catch(st){nr(s,s.return,st)}break;case 4:Vo(l,s),fs(s);break;case 13:Vo(l,s),fs(s),b=s.child,b.flags&8192&&(E=b.memoizedState!==null,b.stateNode.isHidden=E,!E||b.alternate!==null&&b.alternate.memoizedState!==null||(lm=Zt())),k&4&&Qv(s);break;case 22:if(Ae=p!==null&&p.memoizedState!==null,s.mode&1?(Dr=(ke=Dr)||Ae,Vo(l,s),Dr=ke):Vo(l,s),fs(s),k&8192){if(ke=s.memoizedState!==null,(s.stateNode.isHidden=ke)&&!Ae&&(s.mode&1)!==0)for(et=s,Ae=s.child;Ae!==null;){for(Oe=et=Ae;et!==null;){switch(Ce=et,Ye=Ce.child,Ce.tag){case 0:case 11:case 14:case 15:Sc(4,Ce,Ce.return);break;case 1:sl(Ce,Ce.return);var nt=Ce.stateNode;if(typeof nt.componentWillUnmount=="function"){k=Ce,p=Ce.return;try{l=k,nt.props=l.memoizedProps,nt.state=l.memoizedState,nt.componentWillUnmount()}catch(st){nr(k,p,st)}}break;case 5:sl(Ce,Ce.return);break;case 22:if(Ce.memoizedState!==null){n0(Oe);continue}}Ye!==null?(Ye.return=Ce,et=Ye):n0(Oe)}Ae=Ae.sibling}e:for(Ae=null,Oe=s;;){if(Oe.tag===5){if(Ae===null){Ae=Oe;try{b=Oe.stateNode,ke?(E=b.style,typeof E.setProperty=="function"?E.setProperty("display","none","important"):E.display="none"):(G=Oe.stateNode,ne=Oe.memoizedProps.style,R=ne!=null&&ne.hasOwnProperty("display")?ne.display:null,G.style.display=Pn("display",R))}catch(st){nr(s,s.return,st)}}}else if(Oe.tag===6){if(Ae===null)try{Oe.stateNode.nodeValue=ke?"":Oe.memoizedProps}catch(st){nr(s,s.return,st)}}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:Vo(l,s),fs(s),k&4&&Qv(s);break;case 21:break;default:Vo(l,s),fs(s)}}function fs(s){var l=s.flags;if(l&2){try{e:{for(var p=s.return;p!==null;){if(Vv(p)){var k=p;break e}p=p.return}throw Error(n(160))}switch(k.tag){case 5:var b=k.stateNode;k.flags&32&&(Vt(b,""),k.flags&=-33);var E=Yv(s);sm(s,E,b);break;case 3:case 4:var R=k.stateNode.containerInfo,G=Yv(s);om(s,G,R);break;default:throw Error(n(161))}}catch(ne){nr(s,s.return,ne)}s.flags&=-3}l&4096&&(s.flags&=-4097)}function fC(s,l,p){et=s,e0(s)}function e0(s,l,p){for(var k=(s.mode&1)!==0;et!==null;){var b=et,E=b.child;if(b.tag===22&&k){var R=b.memoizedState!==null||Td;if(!R){var G=b.alternate,ne=G!==null&&G.memoizedState!==null||Dr;G=Td;var ke=Dr;if(Td=R,(Dr=ne)&&!ke)for(et=b;et!==null;)R=et,ne=R.child,R.tag===22&&R.memoizedState!==null?r0(b):ne!==null?(ne.return=R,et=ne):r0(b);for(;E!==null;)et=E,e0(E),E=E.sibling;et=b,Td=G,Dr=ke}t0(s)}else(b.subtreeFlags&8772)!==0&&E!==null?(E.return=b,et=E):t0(s)}}function t0(s){for(;et!==null;){var l=et;if((l.flags&8772)!==0){var p=l.alternate;try{if((l.flags&8772)!==0)switch(l.tag){case 0:case 11:case 15:Dr||jd(5,l);break;case 1:var k=l.stateNode;if(l.flags&4&&!Dr)if(p===null)k.componentDidMount();else{var b=l.elementType===l.type?p.memoizedProps:qo(l.type,p.memoizedProps);k.componentDidUpdate(b,p.memoizedState,k.__reactInternalSnapshotBeforeUpdate)}var E=l.updateQueue;E!==null&&nv(l,E,k);break;case 3:var R=l.updateQueue;if(R!==null){if(p=null,l.child!==null)switch(l.child.tag){case 5:p=l.child.stateNode;break;case 1:p=l.child.stateNode}nv(l,R,p)}break;case 5:var G=l.stateNode;if(p===null&&l.flags&4){p=G;var ne=l.memoizedProps;switch(l.type){case"button":case"input":case"select":case"textarea":ne.autoFocus&&p.focus();break;case"img":ne.src&&(p.src=ne.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(l.memoizedState===null){var ke=l.alternate;if(ke!==null){var Ae=ke.memoizedState;if(Ae!==null){var Oe=Ae.dehydrated;Oe!==null&&Mi(Oe)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(n(163))}Dr||l.flags&512&&rm(l)}catch(Ce){nr(l,l.return,Ce)}}if(l===s){et=null;break}if(p=l.sibling,p!==null){p.return=l.return,et=p;break}et=l.return}}function n0(s){for(;et!==null;){var l=et;if(l===s){et=null;break}var p=l.sibling;if(p!==null){p.return=l.return,et=p;break}et=l.return}}function r0(s){for(;et!==null;){var l=et;try{switch(l.tag){case 0:case 11:case 15:var p=l.return;try{jd(4,l)}catch(ne){nr(l,p,ne)}break;case 1:var k=l.stateNode;if(typeof k.componentDidMount=="function"){var b=l.return;try{k.componentDidMount()}catch(ne){nr(l,b,ne)}}var E=l.return;try{rm(l)}catch(ne){nr(l,E,ne)}break;case 5:var R=l.return;try{rm(l)}catch(ne){nr(l,R,ne)}}}catch(ne){nr(l,l.return,ne)}if(l===s){et=null;break}var G=l.sibling;if(G!==null){G.return=l.return,et=G;break}et=l.return}}var hC=Math.ceil,$d=j.ReactCurrentDispatcher,im=j.ReactCurrentOwner,Ro=j.ReactCurrentBatchConfig,hn=0,xr=null,lr=null,Ir=0,wo=0,il=ei(0),gr=0,_c=null,Ji=0,Cd=0,am=0,Nc=null,oo=null,lm=0,al=1/0,Cs=null,Ad=!1,cm=null,ii=null,Id=!1,ai=null,Rd=0,Tc=0,um=null,Od=-1,Md=0;function Gr(){return(hn&6)!==0?Zt():Od!==-1?Od:Od=Zt()}function li(s){return(s.mode&1)===0?1:(hn&2)!==0&&Ir!==0?Ir&-Ir:Y$.transition!==null?(Md===0&&(Md=Tt()),Md):(s=Gt,s!==0||(s=window.event,s=s===void 0?16:Li(s.type)),s)}function Yo(s,l,p,k){if(50<Tc)throw Tc=0,um=null,Error(n(185));Zn(s,p,k),((hn&2)===0||s!==xr)&&(s===xr&&((hn&2)===0&&(Cd|=p),gr===4&&ci(s,Ir)),so(s,k),p===1&&hn===0&&(l.mode&1)===0&&(al=Zt()+500,cd&&ni()))}function so(s,l){var p=s.callbackNode;Je(s,l);var k=Y(s,s===xr?Ir:0);if(k===0)p!==null&&bn(p),s.callbackNode=null,s.callbackPriority=0;else if(l=k&-k,s.callbackPriority!==l){if(p!=null&&bn(p),l===1)s.tag===0?V$(s0.bind(null,s)):Wy(s0.bind(null,s)),K$(function(){(hn&6)===0&&ni()}),p=null;else{switch(xt(k)){case 1:p=dt;break;case 4:p=Hn;break;case 16:p=rt;break;case 536870912:p=qe;break;default:p=rt}p=h0(p,o0.bind(null,s))}s.callbackPriority=l,s.callbackNode=p}}function o0(s,l){if(Od=-1,Md=0,(hn&6)!==0)throw Error(n(327));var p=s.callbackNode;if(ll()&&s.callbackNode!==p)return null;var k=Y(s,s===xr?Ir:0);if(k===0)return null;if((k&30)!==0||(k&s.expiredLanes)!==0||l)l=Pd(s,k);else{l=k;var b=hn;hn|=2;var E=a0();(xr!==s||Ir!==l)&&(Cs=null,al=Zt()+500,ta(s,l));do try{gC();break}catch(G){i0(s,G)}while(!0);jp(),$d.current=E,hn=b,lr!==null?l=0:(xr=null,Ir=0,l=gr)}if(l!==0){if(l===2&&(b=gt(s),b!==0&&(k=b,l=dm(s,b))),l===1)throw p=_c,ta(s,0),ci(s,k),so(s,Zt()),p;if(l===6)ci(s,k);else{if(b=s.current.alternate,(k&30)===0&&!pC(b)&&(l=Pd(s,k),l===2&&(E=gt(s),E!==0&&(k=E,l=dm(s,E))),l===1))throw p=_c,ta(s,0),ci(s,k),so(s,Zt()),p;switch(s.finishedWork=b,s.finishedLanes=k,l){case 0:case 1:throw Error(n(345));case 2:na(s,oo,Cs);break;case 3:if(ci(s,k),(k&130023424)===k&&(l=lm+500-Zt(),10<l)){if(Y(s,0)!==0)break;if(b=s.suspendedLanes,(b&k)!==k){Gr(),s.pingedLanes|=s.suspendedLanes&b;break}s.timeoutHandle=kp(na.bind(null,s,oo,Cs),l);break}na(s,oo,Cs);break;case 4:if(ci(s,k),(k&4194240)===k)break;for(l=s.eventTimes,b=-1;0<k;){var R=31-Ht(k);E=1<<R,R=l[R],R>b&&(b=R),k&=~E}if(k=b,k=Zt()-k,k=(120>k?120:480>k?480:1080>k?1080:1920>k?1920:3e3>k?3e3:4320>k?4320:1960*hC(k/1960))-k,10<k){s.timeoutHandle=kp(na.bind(null,s,oo,Cs),k);break}na(s,oo,Cs);break;case 5:na(s,oo,Cs);break;default:throw Error(n(329))}}}return so(s,Zt()),s.callbackNode===p?o0.bind(null,s):null}function dm(s,l){var p=Nc;return s.current.memoizedState.isDehydrated&&(ta(s,l).flags|=256),s=Pd(s,l),s!==2&&(l=oo,oo=p,l!==null&&fm(l)),s}function fm(s){oo===null?oo=s:oo.push.apply(oo,s)}function pC(s){for(var l=s;;){if(l.flags&16384){var p=l.updateQueue;if(p!==null&&(p=p.stores,p!==null))for(var k=0;k<p.length;k++){var b=p[k],E=b.getSnapshot;b=b.value;try{if(!Jr(E(),b))return!1}catch{return!1}}}if(p=l.child,l.subtreeFlags&16384&&p!==null)p.return=l,l=p;else{if(l===s)break;for(;l.sibling===null;){if(l.return===null||l.return===s)return!0;l=l.return}l.sibling.return=l.return,l=l.sibling}}return!0}function ci(s,l){for(l&=~am,l&=~Cd,s.suspendedLanes|=l,s.pingedLanes&=~l,s=s.expirationTimes;0<l;){var p=31-Ht(l),k=1<<p;s[p]=-1,l&=~k}}function s0(s){if((hn&6)!==0)throw Error(n(327));ll();var l=Y(s,0);if((l&1)===0)return so(s,Zt()),null;var p=Pd(s,l);if(s.tag!==0&&p===2){var k=gt(s);k!==0&&(l=k,p=dm(s,k))}if(p===1)throw p=_c,ta(s,0),ci(s,l),so(s,Zt()),p;if(p===6)throw Error(n(345));return s.finishedWork=s.current.alternate,s.finishedLanes=l,na(s,oo,Cs),so(s,Zt()),null}function hm(s,l){var p=hn;hn|=1;try{return s(l)}finally{hn=p,hn===0&&(al=Zt()+500,cd&&ni())}}function ea(s){ai!==null&&ai.tag===0&&(hn&6)===0&&ll();var l=hn;hn|=1;var p=Ro.transition,k=Gt;try{if(Ro.transition=null,Gt=1,s)return s()}finally{Gt=k,Ro.transition=p,hn=l,(hn&6)===0&&ni()}}function pm(){wo=il.current,zn(il)}function ta(s,l){s.finishedWork=null,s.finishedLanes=0;var p=s.timeoutHandle;if(p!==-1&&(s.timeoutHandle=-1,W$(p)),lr!==null)for(p=lr.return;p!==null;){var k=p;switch(Ep(k),k.tag){case 1:k=k.type.childContextTypes,k!=null&&ad();break;case 3:rl(),zn(to),zn(Mr),Pp();break;case 5:Op(k);break;case 4:rl();break;case 13:zn(Yn);break;case 19:zn(Yn);break;case 10:$p(k.type._context);break;case 22:case 23:pm()}p=p.return}if(xr=s,lr=s=ui(s.current,null),Ir=wo=l,gr=0,_c=null,am=Cd=Ji=0,oo=Nc=null,Yi!==null){for(l=0;l<Yi.length;l++)if(p=Yi[l],k=p.interleaved,k!==null){p.interleaved=null;var b=k.next,E=p.pending;if(E!==null){var R=E.next;E.next=b,k.next=R}p.pending=k}Yi=null}return s}function i0(s,l){do{var p=lr;try{if(jp(),yd.current=Ed,vd){for(var k=Xn.memoizedState;k!==null;){var b=k.queue;b!==null&&(b.pending=null),k=k.next}vd=!1}if(Qi=0,br=mr=Xn=null,yc=!1,vc=0,im.current=null,p===null||p.return===null){gr=1,_c=l,lr=null;break}e:{var E=s,R=p.return,G=p,ne=l;if(l=Ir,G.flags|=32768,ne!==null&&typeof ne=="object"&&typeof ne.then=="function"){var ke=ne,Ae=G,Oe=Ae.tag;if((Ae.mode&1)===0&&(Oe===0||Oe===11||Oe===15)){var Ce=Ae.alternate;Ce?(Ae.updateQueue=Ce.updateQueue,Ae.memoizedState=Ce.memoizedState,Ae.lanes=Ce.lanes):(Ae.updateQueue=null,Ae.memoizedState=null)}var Ye=Av(R);if(Ye!==null){Ye.flags&=-257,Iv(Ye,R,G,E,l),Ye.mode&1&&Cv(E,ke,l),l=Ye,ne=ke;var nt=l.updateQueue;if(nt===null){var st=new Set;st.add(ne),l.updateQueue=st}else nt.add(ne);break e}else{if((l&1)===0){Cv(E,ke,l),mm();break e}ne=Error(n(426))}}else if(qn&&G.mode&1){var or=Av(R);if(or!==null){(or.flags&65536)===0&&(or.flags|=256),Iv(or,R,G,E,l),Np(ol(ne,G));break e}}E=ne=ol(ne,G),gr!==4&&(gr=2),Nc===null?Nc=[E]:Nc.push(E),E=R;do{switch(E.tag){case 3:E.flags|=65536,l&=-l,E.lanes|=l;var ue=jv(E,ne,l);tv(E,ue);break e;case 1:G=ne;var ie=E.type,fe=E.stateNode;if((E.flags&128)===0&&(typeof ie.getDerivedStateFromError=="function"||fe!==null&&typeof fe.componentDidCatch=="function"&&(ii===null||!ii.has(fe)))){E.flags|=65536,l&=-l,E.lanes|=l;var Fe=$v(E,G,l);tv(E,Fe);break e}}E=E.return}while(E!==null)}c0(p)}catch(at){l=at,lr===p&&p!==null&&(lr=p=p.return);continue}break}while(!0)}function a0(){var s=$d.current;return $d.current=Ed,s===null?Ed:s}function mm(){(gr===0||gr===3||gr===2)&&(gr=4),xr===null||(Ji&268435455)===0&&(Cd&268435455)===0||ci(xr,Ir)}function Pd(s,l){var p=hn;hn|=2;var k=a0();(xr!==s||Ir!==l)&&(Cs=null,ta(s,l));do try{mC();break}catch(b){i0(s,b)}while(!0);if(jp(),hn=p,$d.current=k,lr!==null)throw Error(n(261));return xr=null,Ir=0,gr}function mC(){for(;lr!==null;)l0(lr)}function gC(){for(;lr!==null&&!jr();)l0(lr)}function l0(s){var l=f0(s.alternate,s,wo);s.memoizedProps=s.pendingProps,l===null?c0(s):lr=l,im.current=null}function c0(s){var l=s;do{var p=l.alternate;if(s=l.return,(l.flags&32768)===0){if(p=lC(p,l,wo),p!==null){lr=p;return}}else{if(p=cC(p,l),p!==null){p.flags&=32767,lr=p;return}if(s!==null)s.flags|=32768,s.subtreeFlags=0,s.deletions=null;else{gr=6,lr=null;return}}if(l=l.sibling,l!==null){lr=l;return}lr=l=s}while(l!==null);gr===0&&(gr=5)}function na(s,l,p){var k=Gt,b=Ro.transition;try{Ro.transition=null,Gt=1,kC(s,l,p,k)}finally{Ro.transition=b,Gt=k}return null}function kC(s,l,p,k){do ll();while(ai!==null);if((hn&6)!==0)throw Error(n(327));p=s.finishedWork;var b=s.finishedLanes;if(p===null)return null;if(s.finishedWork=null,s.finishedLanes=0,p===s.current)throw Error(n(177));s.callbackNode=null,s.callbackPriority=0;var E=p.lanes|p.childLanes;if(ar(s,E),s===xr&&(lr=xr=null,Ir=0),(p.subtreeFlags&2064)===0&&(p.flags&2064)===0||Id||(Id=!0,h0(rt,function(){return ll(),null})),E=(p.flags&15990)!==0,(p.subtreeFlags&15990)!==0||E){E=Ro.transition,Ro.transition=null;var R=Gt;Gt=1;var G=hn;hn|=4,im.current=null,dC(s,p),Jv(p,s),At(mp),Ca=!!pp,mp=pp=null,s.current=p,fC(p),ir(),hn=G,Gt=R,Ro.transition=E}else s.current=p;if(Id&&(Id=!1,ai=s,Rd=b),E=s.pendingLanes,E===0&&(ii=null),fn(p.stateNode),so(s,Zt()),l!==null)for(k=s.onRecoverableError,p=0;p<l.length;p++)b=l[p],k(b.value,{componentStack:b.stack,digest:b.digest});if(Ad)throw Ad=!1,s=cm,cm=null,s;return(Rd&1)!==0&&s.tag!==0&&ll(),E=s.pendingLanes,(E&1)!==0?s===um?Tc++:(Tc=0,um=s):Tc=0,ni(),null}function ll(){if(ai!==null){var s=xt(Rd),l=Ro.transition,p=Gt;try{if(Ro.transition=null,Gt=16>s?16:s,ai===null)var k=!1;else{if(s=ai,ai=null,Rd=0,(hn&6)!==0)throw Error(n(331));var b=hn;for(hn|=4,et=s.current;et!==null;){var E=et,R=E.child;if((et.flags&16)!==0){var G=E.deletions;if(G!==null){for(var ne=0;ne<G.length;ne++){var ke=G[ne];for(et=ke;et!==null;){var Ae=et;switch(Ae.tag){case 0:case 11:case 15:Sc(8,Ae,E)}var Oe=Ae.child;if(Oe!==null)Oe.return=Ae,et=Oe;else for(;et!==null;){Ae=et;var Ce=Ae.sibling,Ye=Ae.return;if(Gv(Ae),Ae===ke){et=null;break}if(Ce!==null){Ce.return=Ye,et=Ce;break}et=Ye}}}var nt=E.alternate;if(nt!==null){var st=nt.child;if(st!==null){nt.child=null;do{var or=st.sibling;st.sibling=null,st=or}while(st!==null)}}et=E}}if((E.subtreeFlags&2064)!==0&&R!==null)R.return=E,et=R;else e:for(;et!==null;){if(E=et,(E.flags&2048)!==0)switch(E.tag){case 0:case 11:case 15:Sc(9,E,E.return)}var ue=E.sibling;if(ue!==null){ue.return=E.return,et=ue;break e}et=E.return}}var ie=s.current;for(et=ie;et!==null;){R=et;var fe=R.child;if((R.subtreeFlags&2064)!==0&&fe!==null)fe.return=R,et=fe;else e:for(R=ie;et!==null;){if(G=et,(G.flags&2048)!==0)try{switch(G.tag){case 0:case 11:case 15:jd(9,G)}}catch(at){nr(G,G.return,at)}if(G===R){et=null;break e}var Fe=G.sibling;if(Fe!==null){Fe.return=G.return,et=Fe;break e}et=G.return}}if(hn=b,ni(),it&&typeof it.onPostCommitFiberRoot=="function")try{it.onPostCommitFiberRoot(bt,s)}catch{}k=!0}return k}finally{Gt=p,Ro.transition=l}}return!1}function u0(s,l,p){l=ol(p,l),l=jv(s,l,1),s=oi(s,l,1),l=Gr(),s!==null&&(Zn(s,1,l),so(s,l))}function nr(s,l,p){if(s.tag===3)u0(s,s,p);else for(;l!==null;){if(l.tag===3){u0(l,s,p);break}else if(l.tag===1){var k=l.stateNode;if(typeof l.type.getDerivedStateFromError=="function"||typeof k.componentDidCatch=="function"&&(ii===null||!ii.has(k))){s=ol(p,s),s=$v(l,s,1),l=oi(l,s,1),s=Gr(),l!==null&&(Zn(l,1,s),so(l,s));break}}l=l.return}}function wC(s,l,p){var k=s.pingCache;k!==null&&k.delete(l),l=Gr(),s.pingedLanes|=s.suspendedLanes&p,xr===s&&(Ir&p)===p&&(gr===4||gr===3&&(Ir&130023424)===Ir&&500>Zt()-lm?ta(s,0):am|=p),so(s,l)}function d0(s,l){l===0&&((s.mode&1)===0?l=1:(l=yr,yr<<=1,(yr&130023424)===0&&(yr=4194304)));var p=Gr();s=Ts(s,l),s!==null&&(Zn(s,l,p),so(s,p))}function yC(s){var l=s.memoizedState,p=0;l!==null&&(p=l.retryLane),d0(s,p)}function vC(s,l){var p=0;switch(s.tag){case 13:var k=s.stateNode,b=s.memoizedState;b!==null&&(p=b.retryLane);break;case 19:k=s.stateNode;break;default:throw Error(n(314))}k!==null&&k.delete(l),d0(s,p)}var f0;f0=function(s,l,p){if(s!==null)if(s.memoizedProps!==l.pendingProps||to.current)ro=!0;else{if((s.lanes&p)===0&&(l.flags&128)===0)return ro=!1,aC(s,l,p);ro=(s.flags&131072)!==0}else ro=!1,qn&&(l.flags&1048576)!==0&&Ky(l,dd,l.index);switch(l.lanes=0,l.tag){case 2:var k=l.type;Nd(s,l),s=l.pendingProps;var b=Ya(l,Mr.current);nl(l,p),b=zp(null,l,k,s,b,p);var E=Fp();return l.flags|=1,typeof b=="object"&&b!==null&&typeof b.render=="function"&&b.$$typeof===void 0?(l.tag=1,l.memoizedState=null,l.updateQueue=null,no(k)?(E=!0,ld(l)):E=!1,l.memoizedState=b.state!==null&&b.state!==void 0?b.state:null,Ip(l),b.updater=Sd,l.stateNode=b,b._reactInternals=l,Zp(l,k,s,p),l=Yp(null,l,k,!0,E,p)):(l.tag=0,qn&&E&&xp(l),qr(null,l,b,p),l=l.child),l;case 16:k=l.elementType;e:{switch(Nd(s,l),s=l.pendingProps,b=k._init,k=b(k._payload),l.type=k,b=l.tag=xC(k),s=qo(k,s),b){case 0:l=Vp(null,l,k,s,p);break e;case 1:l=Dv(null,l,k,s,p);break e;case 11:l=Rv(null,l,k,s,p);break e;case 14:l=Ov(null,l,k,qo(k.type,s),p);break e}throw Error(n(306,k,""))}return l;case 0:return k=l.type,b=l.pendingProps,b=l.elementType===k?b:qo(k,b),Vp(s,l,k,b,p);case 1:return k=l.type,b=l.pendingProps,b=l.elementType===k?b:qo(k,b),Dv(s,l,k,b,p);case 3:e:{if(zv(l),s===null)throw Error(n(387));k=l.pendingProps,E=l.memoizedState,b=E.element,ev(s,l),kd(l,k,null,p);var R=l.memoizedState;if(k=R.element,E.isDehydrated)if(E={element:k,isDehydrated:!1,cache:R.cache,pendingSuspenseBoundaries:R.pendingSuspenseBoundaries,transitions:R.transitions},l.updateQueue.baseState=E,l.memoizedState=E,l.flags&256){b=ol(Error(n(423)),l),l=Fv(s,l,k,p,b);break e}else if(k!==b){b=ol(Error(n(424)),l),l=Fv(s,l,k,p,b);break e}else for(ko=Js(l.stateNode.containerInfo.firstChild),go=l,qn=!0,Zo=null,p=Qy(l,null,k,p),l.child=p;p;)p.flags=p.flags&-3|4096,p=p.sibling;else{if(Ja(),k===b){l=$s(s,l,p);break e}qr(s,l,k,p)}l=l.child}return l;case 5:return rv(l),s===null&&_p(l),k=l.type,b=l.pendingProps,E=s!==null?s.memoizedProps:null,R=b.children,gp(k,b)?R=null:E!==null&&gp(k,E)&&(l.flags|=32),Lv(s,l),qr(s,l,R,p),l.child;case 6:return s===null&&_p(l),null;case 13:return Bv(s,l,p);case 4:return Rp(l,l.stateNode.containerInfo),k=l.pendingProps,s===null?l.child=el(l,null,k,p):qr(s,l,k,p),l.child;case 11:return k=l.type,b=l.pendingProps,b=l.elementType===k?b:qo(k,b),Rv(s,l,k,b,p);case 7:return qr(s,l,l.pendingProps,p),l.child;case 8:return qr(s,l,l.pendingProps.children,p),l.child;case 12:return qr(s,l,l.pendingProps.children,p),l.child;case 10:e:{if(k=l.type._context,b=l.pendingProps,E=l.memoizedProps,R=b.value,Mn(pd,k._currentValue),k._currentValue=R,E!==null)if(Jr(E.value,R)){if(E.children===b.children&&!to.current){l=$s(s,l,p);break e}}else for(E=l.child,E!==null&&(E.return=l);E!==null;){var G=E.dependencies;if(G!==null){R=E.child;for(var ne=G.firstContext;ne!==null;){if(ne.context===k){if(E.tag===1){ne=js(-1,p&-p),ne.tag=2;var ke=E.updateQueue;if(ke!==null){ke=ke.shared;var Ae=ke.pending;Ae===null?ne.next=ne:(ne.next=Ae.next,Ae.next=ne),ke.pending=ne}}E.lanes|=p,ne=E.alternate,ne!==null&&(ne.lanes|=p),Cp(E.return,p,l),G.lanes|=p;break}ne=ne.next}}else if(E.tag===10)R=E.type===l.type?null:E.child;else if(E.tag===18){if(R=E.return,R===null)throw Error(n(341));R.lanes|=p,G=R.alternate,G!==null&&(G.lanes|=p),Cp(R,p,l),R=E.sibling}else R=E.child;if(R!==null)R.return=E;else for(R=E;R!==null;){if(R===l){R=null;break}if(E=R.sibling,E!==null){E.return=R.return,R=E;break}R=R.return}E=R}qr(s,l,b.children,p),l=l.child}return l;case 9:return b=l.type,k=l.pendingProps.children,nl(l,p),b=Ao(b),k=k(b),l.flags|=1,qr(s,l,k,p),l.child;case 14:return k=l.type,b=qo(k,l.pendingProps),b=qo(k.type,b),Ov(s,l,k,b,p);case 15:return Mv(s,l,l.type,l.pendingProps,p);case 17:return k=l.type,b=l.pendingProps,b=l.elementType===k?b:qo(k,b),Nd(s,l),l.tag=1,no(k)?(s=!0,ld(l)):s=!1,nl(l,p),Nv(l,k,b),Zp(l,k,b,p),Yp(null,l,k,!0,s,p);case 19:return Hv(s,l,p);case 22:return Pv(s,l,p)}throw Error(n(156,l.tag))};function h0(s,l){return ft(s,l)}function bC(s,l,p,k){this.tag=s,this.key=p,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=l,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=k,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Oo(s,l,p,k){return new bC(s,l,p,k)}function gm(s){return s=s.prototype,!(!s||!s.isReactComponent)}function xC(s){if(typeof s=="function")return gm(s)?1:0;if(s!=null){if(s=s.$$typeof,s===U)return 11;if(s===ee)return 14}return 2}function ui(s,l){var p=s.alternate;return p===null?(p=Oo(s.tag,l,s.key,s.mode),p.elementType=s.elementType,p.type=s.type,p.stateNode=s.stateNode,p.alternate=s,s.alternate=p):(p.pendingProps=l,p.type=s.type,p.flags=0,p.subtreeFlags=0,p.deletions=null),p.flags=s.flags&14680064,p.childLanes=s.childLanes,p.lanes=s.lanes,p.child=s.child,p.memoizedProps=s.memoizedProps,p.memoizedState=s.memoizedState,p.updateQueue=s.updateQueue,l=s.dependencies,p.dependencies=l===null?null:{lanes:l.lanes,firstContext:l.firstContext},p.sibling=s.sibling,p.index=s.index,p.ref=s.ref,p}function Ld(s,l,p,k,b,E){var R=2;if(k=s,typeof s=="function")gm(s)&&(R=1);else if(typeof s=="string")R=5;else e:switch(s){case I:return ra(p.children,b,E,l);case O:R=8,b|=8;break;case A:return s=Oo(12,p,l,b|2),s.elementType=A,s.lanes=E,s;case Q:return s=Oo(13,p,l,b),s.elementType=Q,s.lanes=E,s;case ae:return s=Oo(19,p,l,b),s.elementType=ae,s.lanes=E,s;case $:return Dd(p,b,E,l);default:if(typeof s=="object"&&s!==null)switch(s.$$typeof){case z:R=10;break e;case B:R=9;break e;case U:R=11;break e;case ee:R=14;break e;case de:R=16,k=null;break e}throw Error(n(130,s==null?s:typeof s,""))}return l=Oo(R,p,l,b),l.elementType=s,l.type=k,l.lanes=E,l}function ra(s,l,p,k){return s=Oo(7,s,k,l),s.lanes=p,s}function Dd(s,l,p,k){return s=Oo(22,s,k,l),s.elementType=$,s.lanes=p,s.stateNode={isHidden:!1},s}function km(s,l,p){return s=Oo(6,s,null,l),s.lanes=p,s}function wm(s,l,p){return l=Oo(4,s.children!==null?s.children:[],s.key,l),l.lanes=p,l.stateNode={containerInfo:s.containerInfo,pendingChildren:null,implementation:s.implementation},l}function EC(s,l,p,k,b){this.tag=l,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=xn(0),this.expirationTimes=xn(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=xn(0),this.identifierPrefix=k,this.onRecoverableError=b,this.mutableSourceEagerHydrationData=null}function ym(s,l,p,k,b,E,R,G,ne){return s=new EC(s,l,p,G,ne),l===1?(l=1,E===!0&&(l|=8)):l=0,E=Oo(3,null,null,l),s.current=E,E.stateNode=s,E.memoizedState={element:k,isDehydrated:p,cache:null,transitions:null,pendingSuspenseBoundaries:null},Ip(E),s}function SC(s,l,p){var k=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:M,key:k==null?null:""+k,children:s,containerInfo:l,implementation:p}}function p0(s){if(!s)return ti;s=s._reactInternals;e:{if(An(s)!==s||s.tag!==1)throw Error(n(170));var l=s;do{switch(l.tag){case 3:l=l.stateNode.context;break e;case 1:if(no(l.type)){l=l.stateNode.__reactInternalMemoizedMergedChildContext;break e}}l=l.return}while(l!==null);throw Error(n(171))}if(s.tag===1){var p=s.type;if(no(p))return Uy(s,p,l)}return l}function m0(s,l,p,k,b,E,R,G,ne){return s=ym(p,k,!0,s,b,E,R,G,ne),s.context=p0(null),p=s.current,k=Gr(),b=li(p),E=js(k,b),E.callback=l??null,oi(p,E,b),s.current.lanes=b,Zn(s,b,k),so(s,k),s}function zd(s,l,p,k){var b=l.current,E=Gr(),R=li(b);return p=p0(p),l.context===null?l.context=p:l.pendingContext=p,l=js(E,R),l.payload={element:s},k=k===void 0?null:k,k!==null&&(l.callback=k),s=oi(b,l,R),s!==null&&(Yo(s,b,R,E),gd(s,b,R)),R}function Fd(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 g0(s,l){if(s=s.memoizedState,s!==null&&s.dehydrated!==null){var p=s.retryLane;s.retryLane=p!==0&&p<l?p:l}}function vm(s,l){g0(s,l),(s=s.alternate)&&g0(s,l)}function _C(){return null}var k0=typeof reportError=="function"?reportError:function(s){console.error(s)};function bm(s){this._internalRoot=s}Bd.prototype.render=bm.prototype.render=function(s){var l=this._internalRoot;if(l===null)throw Error(n(409));zd(s,l,null,null)},Bd.prototype.unmount=bm.prototype.unmount=function(){var s=this._internalRoot;if(s!==null){this._internalRoot=null;var l=s.containerInfo;ea(function(){zd(null,s,null,null)}),l[Es]=null}};function Bd(s){this._internalRoot=s}Bd.prototype.unstable_scheduleHydration=function(s){if(s){var l=Zr();s={blockedOn:null,target:s,priority:l};for(var p=0;p<$t.length&&l!==0&&l<$t[p].priority;p++);$t.splice(p,0,s),p===0&&En(s)}};function xm(s){return!(!s||s.nodeType!==1&&s.nodeType!==9&&s.nodeType!==11)}function Ud(s){return!(!s||s.nodeType!==1&&s.nodeType!==9&&s.nodeType!==11&&(s.nodeType!==8||s.nodeValue!==" react-mount-point-unstable "))}function w0(){}function NC(s,l,p,k,b){if(b){if(typeof k=="function"){var E=k;k=function(){var ke=Fd(R);E.call(ke)}}var R=m0(l,k,s,0,null,!1,!1,"",w0);return s._reactRootContainer=R,s[Es]=R.current,dc(s.nodeType===8?s.parentNode:s),ea(),R}for(;b=s.lastChild;)s.removeChild(b);if(typeof k=="function"){var G=k;k=function(){var ke=Fd(ne);G.call(ke)}}var ne=ym(s,0,!1,null,null,!1,!1,"",w0);return s._reactRootContainer=ne,s[Es]=ne.current,dc(s.nodeType===8?s.parentNode:s),ea(function(){zd(l,ne,p,k)}),ne}function Hd(s,l,p,k,b){var E=p._reactRootContainer;if(E){var R=E;if(typeof b=="function"){var G=b;b=function(){var ne=Fd(R);G.call(ne)}}zd(l,R,s,b)}else R=NC(p,l,s,b,k);return Fd(R)}To=function(s){switch(s.tag){case 3:var l=s.stateNode;if(l.current.memoizedState.isDehydrated){var p=Kn(l.pendingLanes);p!==0&&($r(l,p|1),so(l,Zt()),(hn&6)===0&&(al=Zt()+500,ni()))}break;case 13:ea(function(){var k=Ts(s,1);if(k!==null){var b=Gr();Yo(k,s,1,b)}}),vm(s,1)}},jn=function(s){if(s.tag===13){var l=Ts(s,134217728);if(l!==null){var p=Gr();Yo(l,s,134217728,p)}vm(s,134217728)}},Jt=function(s){if(s.tag===13){var l=li(s),p=Ts(s,l);if(p!==null){var k=Gr();Yo(p,s,l,k)}vm(s,l)}},Zr=function(){return Gt},Or=function(s,l){var p=Gt;try{return Gt=s,l()}finally{Gt=p}},ot=function(s,l,p){switch(l){case"input":if(We(s,p),l=p.name,p.type==="radio"&&l!=null){for(p=s;p.parentNode;)p=p.parentNode;for(p=p.querySelectorAll("input[name="+JSON.stringify(""+l)+'][type="radio"]'),l=0;l<p.length;l++){var k=p[l];if(k!==s&&k.form===s.form){var b=id(k);if(!b)throw Error(n(90));J(k),We(k,b)}}}break;case"textarea":Ft(s,p);break;case"select":l=p.value,l!=null&&Ue(s,!!p.multiple,l,!1)}},be=hm,Xe=ea;var TC={usingClientEntryPoint:!1,Events:[pc,Ga,id,L,re,hm]},jc={findFiberByHostInstance:Zi,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},jC={bundleType:jc.bundleType,version:jc.version,rendererPackageName:jc.rendererPackageName,rendererConfig:jc.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:j.ReactCurrentDispatcher,findHostInstanceByFiber:function(s){return s=Ve(s),s===null?null:s.stateNode},findFiberByHostInstance:jc.findFiberByHostInstance||_C,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 Wd=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Wd.isDisabled&&Wd.supportsFiber)try{bt=Wd.inject(jC),it=Wd}catch{}}return io.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=TC,io.createPortal=function(s,l){var p=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!xm(l))throw Error(n(200));return SC(s,l,null,p)},io.createRoot=function(s,l){if(!xm(s))throw Error(n(299));var p=!1,k="",b=k0;return l!=null&&(l.unstable_strictMode===!0&&(p=!0),l.identifierPrefix!==void 0&&(k=l.identifierPrefix),l.onRecoverableError!==void 0&&(b=l.onRecoverableError)),l=ym(s,1,!1,null,null,p,!1,k,b),s[Es]=l.current,dc(s.nodeType===8?s.parentNode:s),new bm(l)},io.findDOMNode=function(s){if(s==null)return null;if(s.nodeType===1)return s;var l=s._reactInternals;if(l===void 0)throw typeof s.render=="function"?Error(n(188)):(s=Object.keys(s).join(","),Error(n(268,s)));return s=Ve(l),s=s===null?null:s.stateNode,s},io.flushSync=function(s){return ea(s)},io.hydrate=function(s,l,p){if(!Ud(l))throw Error(n(200));return Hd(null,s,l,!0,p)},io.hydrateRoot=function(s,l,p){if(!xm(s))throw Error(n(405));var k=p!=null&&p.hydratedSources||null,b=!1,E="",R=k0;if(p!=null&&(p.unstable_strictMode===!0&&(b=!0),p.identifierPrefix!==void 0&&(E=p.identifierPrefix),p.onRecoverableError!==void 0&&(R=p.onRecoverableError)),l=m0(l,null,s,1,p??null,b,!1,E,R),s[Es]=l.current,dc(s),k)for(s=0;s<k.length;s++)p=k[s],b=p._getVersion,b=b(p._source),l.mutableSourceEagerHydrationData==null?l.mutableSourceEagerHydrationData=[p,b]:l.mutableSourceEagerHydrationData.push(p,b);return new Bd(l)},io.render=function(s,l,p){if(!Ud(l))throw Error(n(200));return Hd(null,s,l,!1,p)},io.unmountComponentAtNode=function(s){if(!Ud(s))throw Error(n(40));return s._reactRootContainer?(ea(function(){Hd(null,null,s,!1,function(){s._reactRootContainer=null,s[Es]=null})}),!0):!1},io.unstable_batchedUpdates=hm,io.unstable_renderSubtreeIntoContainer=function(s,l,p,k){if(!Ud(p))throw Error(n(200));if(s==null||s._reactInternals===void 0)throw Error(n(38));return Hd(s,l,p,!1,k)},io.version="18.3.1-next-f1338f8080-20240426",io}var N0;function tE(){if(N0)return _m.exports;N0=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(),_m.exports=DC(),_m.exports}var nE=tE(),Kd={},T0;function zC(){if(T0)return Kd;T0=1;var e=tE();return Kd.createRoot=e.createRoot,Kd.hydrateRoot=e.hydrateRoot,Kd}var FC=zC();const Si="shell",rE="check",$f="ToolSearch",Ck="AskUserQuestion";function Zd(e){const t=[];for(const n of e){const r=t.at(-1),{event:o}=n;o.type==="text-delta"&&(r==null?void 0:r.event.type)==="text-delta"&&r.event.messageId===o.messageId?t[t.length-1]={seq:r.seq,event:{...r.event,text:r.event.text+o.text}}:o.type==="thinking-delta"&&(r==null?void 0:r.event.type)==="thinking-delta"?t[t.length-1]={seq:r.seq,event:{type:"thinking-delta",text:r.event.text+o.text}}:o.type==="tool-delta"&&(r==null?void 0:r.event.type)==="tool-delta"&&r.event.toolId===o.toolId?t[t.length-1]={seq:r.seq,event:{...o,text:r.event.text+o.text}}:t.push(n)}return t}const BC=new Set(["edit","delete","move","execute"]),UC=new Set(["Edit","Write","MultiEdit","NotebookEdit","Bash"]);function oE(e){return e.kind?BC.has(e.kind):UC.has(e.name)}const HC=["read","edit","delete","move","search","execute","fetch"];function Ak(e){return HC.includes(e??"")}function sE(e,t){return(Ak(e.kind)||e.name===Ck||e.name===$f)&&ch(t)}const WC=/^(?:mcp__(.+?)__(.+)|([A-Za-z0-9_-]+)\/([A-Za-z0-9_-]+))$/;function KC(e){const t=WC.exec(e);if(!t)return null;const n=t[1]??t[3]??"",r=t[2]??t[4]??"";return{server:n,tool:r.replace(/[_-]+/g," ").trim()}}function ch(e){if(!e||typeof e!="object")return!0;const t=e;return Object.keys(t).every(n=>n==="locations"&&Array.isArray(t[n])&&t[n].length===0)}const xu=[{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"}],Cf="auto";function ZC(e){return e.branch.startsWith("toyon/")}function qC(e){return e.unread===!0||e.lastTurn!=null&&(e.seenAt==null||e.seenAt<e.lastTurn.at)}const Po="shell",Os="login";function GC(e,t){return`${e}/${t}`}function VC(e,t,n,r=0){var i;let o=e;for(let a=r;a>0;a--){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 zo=e=>e==="working"||e==="waiting",YC=["use","always","off"];function iE(e){return e.find(t=>t.id==="default")}function XC(e,t){const n=iE(e);if(n){if(t!==void 0&&t!==n.id){const r=e.find(o=>o.id===t);if(r)return r}if(n.description)return e.find(r=>r!==n&&r.name===n.description)}}function Nn(e){return e.worktree!==void 0}function ya(e){return e.kind==="main"}function Eu(e){return e.kind==="spare"}function Nr(e){return Eu(e)||ya(e)}function Ik(e){return e.kind==="worktree"}function aE(e){return e.kind==="worktree"&&ZC(e)}function ua(e){var t;return e.kind==="worktree"&&((t=e.from)==null?void 0:t.kind)!=="pr"}function gf(e){return e.kind==="worktree"}function uh(e){return!!e.branch&&!e.locked&&!(e.worktree&&Nr(e.worktree))}const _i=e=>{var t;return e.promptedAt??((t=e.lastTurn)==null?void 0:t.at)??e.createdAt},j0=e=>Nr(e)?0:1;function QC(e){return[...e].sort((t,n)=>j0(t.worktree)-j0(n.worktree)||_i(n.worktree)-_i(t.worktree))}function $0(e,t){const n=new Map;for(const r of e)n.set(r.id,r.promptedAt??0);for(const r of t){if(!Nn(r)||r.worktree.kind==="spare")continue;const o=r.worktree.repoId;n.set(o,Math.max(n.get(o)??0,_i(r.worktree)))}return[...e].sort((r,o)=>(n.get(o.id)??0)-(n.get(r.id)??0))}function JC(e,t){var o,i;const n=t.counts(e.id);if(n.dirty===void 0||n.ahead===void 0)return"its changes are not counted yet";if(n.dirty>0)return"it has uncommitted changes";if(n.ahead>0)return"it has commits not on main";if(t.drafted(e.id))return"unsent text waits in its composer";if(t.pending(e.id))return"its agent is still busy";const r=(o=e.lastTurn)==null?void 0:o.end;return r?r==="stopped"?"its last turn was stopped":r==="failed"?"its last turn failed":r==="asking"?"its agent is waiting on an answer":qC(e)?"its last reply is unread":e.planned?"it showed a plan":((i=e.pr)==null?void 0:i.state)==="open"?"its pull request is still open":null:"its agent has not run yet"}const C0="not opened in ";function eA(e){const t=e.lastIndexOf(C0);return t<0?{what:e}:{what:e.slice(0,t).replace(/,\s*$/,""),idle:e.slice(t+C0.length)}}const lE={image:6,paste:4,file:8,pick:8},tA={image:"image",paste:"paste",file:"file",pick:"element"},nA={image:"Image",paste:"Pasted text"},cE=(e,t)=>`${nA[e]} ${t}`,Rk=e=>`at most ${lE[e]} ${tA[e]}s per message`,rA=(e,t)=>e.filter(n=>n.kind===t).length,oA=(e,t)=>Math.max(0,lE[t]-rA(e,t));function mg(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 Ok(e,t){const n={...t};return e.map(r=>[r,n[r.kind]++])}function Kc(e,t){const n={...e};for(const r of t)n[r.kind]++;return n}function Mk(e){return e>=1024*1024?`${(e/1024/1024).toFixed(1)} MB`:`${Math.max(1,Math.round(e/1024))} KB`}const Sl=e=>`card:${e}`,kf=[{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"}],sA=new Set(["zen","close","back","forward"]);function uE(e,{guest:t=!1}={}){var r,o;if(e.altKey){if(e.metaKey||e.ctrlKey)return null;const i=kf.find(a=>a.alt&&!!a.shift===e.shiftKey&&(a.key===e.key||a.key.length===1&&e.code===`Key${a.key.toUpperCase()}`));return i&&i.id!=="worktree"?{id:i.id}:null}if(!e.metaKey&&!e.ctrlKey){if(e.shiftKey||t)return null;const i=kf.find(a=>a.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 kf){if(i.id==="worktree")continue;const a=i.ctrlAlias;if(a&&e.ctrlKey&&a.key===n&&!!a.shift===e.shiftKey&&!(t&&a.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 iA(e){return e.altKey||e.key.toLowerCase()!=="s"?!1:!!e.ctrlKey!==e.metaKey}function dE(e){const t=kf.find(n=>n.id===e);if(!t)throw new Error(`unknown chord ${e}`);return t}function aA(e,t){return e===t-1?"⌘9":e<8?`⌘${e+1}`:void 0}function lA(e,t){return t===0?null:e===9?t-1:e-1<t?e-1:null}function cA(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 uA(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 dA(e,t){const n=dE(e);return!!n.textKeeps&&cA(t)&&!(n.emptyGives&&uA(t))}const fA=["Find","Preview","Panels","Worktrees"],Zc={"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"}},hA={ArrowUp:"↑",ArrowDown:"↓",ArrowLeft:"←",ArrowRight:"→",Backspace:"⌫",Tab:"Tab"};function pA(e,t={}){var c;const n=dE(e),r=Zc[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":hA[o]??o.toUpperCase(),a=o!==n.key&&o===((c=n.ctrlAlias)==null?void 0:c.key)?n.ctrlAlias:void 0;return a?`⌃${a.shift?"⇧":""}${i}`:`${n.alt?"⌥":n.ctrl?"⌃":"⌘"}${n.shift?"⇧":""}${i}`}function mA(e){return Object.keys(Zc).filter(t=>Zc[t].section===e&&!Zc[t].hidden)}const A0={m:6e4,h:60*6e4};function gA(e){const[t,n]=kA(e);return`${t}${n.charAt(0)}`}function kA(e){const t=e/A0.h;if(t>=1&&Number.isInteger(t))return[t,"hour"];const n=e/A0.m;return n>=1&&Number.isInteger(n)?[n,"minute"]:n>=60?[Math.round(n),"minute"]:[Math.max(1,Math.round(e/1e3)),"second"]}const Qc={folder:{shared:".toyon/settings.json",local:".toyon/settings.local.json"},root:{shared:"toyon.json",local:"toyon.local.json"}};function fE(e){return typeof e=="string"?e:e.cmd}function wA(e){return typeof e!="string"&&e.from==="trunk"}function yA(e){return[...e.setup??[],...e.teardown??[],...Object.values(e.run).map(fE),...Object.values(e.profiles??{}).flatMap(n=>Object.values(n.env??{}))].some(n=>n.includes("TOYON_WORKTREE"))}function vA(e){return e===Qc.folder.local||e===Qc.root.local}function bA(e){return vA(e)?"local":"shared"}function xA(e,t){return(Object.values(Qc).find(r=>r.shared===e||r.local===e)??Qc.folder)[t]}const EA=e=>`https://${e}/`;function SA(e){let t=e.trim();if(t==="")return null;/^[a-z]+:\/\//i.test(t)||(t=`https://${t}`);let n;try{n=new URL(t)}catch{return null}return NA(n.origin)?n.origin:null}function _A(e){return e.toLowerCase().endsWith(".fly.dev")}function NA(e){let t;try{t=new URL(e)}catch{return!1}return t.origin!==e?!1:t.protocol==="https:"||t.protocol==="http:"&&Pk(t.hostname)}const TA="toyon_grant";function Pk(e){return e==="127.0.0.1"||e==="::1"||e==="[::1]"||e==="localhost"||e.endsWith(".localhost")}function jA(e,t,n){return e.replace("{id}",t).replace("{port}",String(n))}const $A=4401,CA=25e4;function AA(e,t){let n=0;for(;n<e.length&&n<t.length&&e[n]===t[n];)n++;let r=0;for(;r<e.length-n&&r<t.length-n&&e[e.length-1-r]===t[t.length-1-r];)r++;const o=e.slice(0,n).map(i=>({mark:" ",value:i}));return o.push(...IA(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 IA(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)>CA)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,a=0;for(;i<e.length&&a<t.length;)e[i]===t[a]?(o.push({mark:" ",value:e[i]}),i++,a++):(r[(i+1)*n+a]??0)>=(r[i*n+a+1]??0)?(o.push({mark:"-",value:e[i]}),i++):(o.push({mark:"+",value:t[a]}),a++);for(;i<e.length;)o.push({mark:"-",value:e[i++]});for(;a<t.length;)o.push({mark:"+",value:t[a++]});return o}const RA=/[\p{L}\p{N}_$]+|\s+|[^\s\p{L}\p{N}_$]/gu;function I0(e){return e.match(RA)??[]}const OA=.4;function MA(e,t){if(e===t)return null;const n=AA(I0(e),I0(t));let r=0;for(const o of n)o.mark===" "&&(r+=o.value.length);return r<OA*Math.max(e.length,t.length)?null:{before:R0(n,"-"),after:R0(n,"+")}}function R0(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 hE(n)}function O0(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(hE)}function hE(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 PA=[{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"}],LA=[{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"}],DA=[{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)"}],gg="merge",kg="merge";function vi(e){var n,r,o;const t=((n=e.land)==null?void 0:n.route)??gg;return{land:t,automerge:t==="pr"&&((r=e.land)==null?void 0:r.automerge)===!0,...(o=e.land)!=null&&o.method?{merge:e.land.method}:{}}}function dh(e){return e.base??e.defaultBranch}function zA(e){return e.base!==void 0&&e.base!==e.defaultBranch}function FA(e){return!!e.pr&&(e.lands??[]).some(t=>{var n;return t.pr===((n=e.pr)==null?void 0:n.number)})}function BA(e){return{land:"a land",commit:"a commit","sync-main":"a sync","pull-main":"a pull"}[e]}function fh(e){return FA(e)&&!e.landed?void 0:e.pr}function Lk(e,t){const n=fh(t);return e.land==="pr"&&(!n||n.state==="closed")?"create pr":"land"}function Af(e,t="main"){const n={merge:"merge into",squash:"squash onto",rebase:"rebase onto"}[e.merge??kg];switch(e.land){case"merge":return`Commit and ${n} ${t} here`;case"push":return`Commit, ${n} ${t} on origin and push it`;case"pr":return e.automerge?"Commit, push the branch and create a PR that GitHub merges when its rules allow":"Commit, push the branch and create a PR"}}function pE(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 M0(e,t="|"){return e.map(n=>kE(n)).join(t)}function wg(e,t){return typeof t=="bigint"?t.toString():t}function hh(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function UA(e){return e==null}function Dk(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function HA(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 fo(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function $i(...e){const t={};for(const n of e){const r=Object.getOwnPropertyDescriptors(n);Object.assign(t,r)}return Object.defineProperties({},t)}function WA(e){return JSON.stringify(e)}function KA(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const mE="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Jc(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const ZA=hh(()=>{var e;if(ss.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 eu(e){if(Jc(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!(Jc(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function gE(e){return eu(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}const qA=new Set(["string","number","symbol"]);function Il(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Ci(e,t,n){const r=new e._zod.constr(t??e._zod.def);return(!t||n!=null&&n.parent)&&(r._zod.parent=e),r}function ct(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 kE(e){return typeof e=="bigint"?e.toString()+"n":typeof e=="string"?`"${e}"`:`${e}`}function GA(e){return Object.keys(e).filter(t=>e[t]._zod.optin!==void 0&&e[t]._zod.optout==="optional")}const VA={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 YA(e,t){const n=e._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const i=$i(e._zod.def,{get shape(){const a={};for(const c of Reflect.ownKeys(t)){if(!Object.prototype.hasOwnProperty.call(n.shape,c))throw new Error(`Unrecognized key: "${String(c)}"`);t[c]&&fo(a,c,n.shape[c])}return fo(this,"shape",a),a},checks:[]});return Ci(e,i)}function XA(e,t){const n=e._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const i=$i(e._zod.def,{get shape(){const a={...e._zod.def.shape};for(const c of Reflect.ownKeys(t)){if(!Object.prototype.hasOwnProperty.call(n.shape,c))throw new Error(`Unrecognized key: "${String(c)}"`);t[c]&&delete a[c]}return fo(this,"shape",a),a},checks:[]});return Ci(e,i)}function QA(e,t){if(!eu(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 a of Reflect.ownKeys(t))if(Object.getOwnPropertyDescriptor(i,a)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}const o=$i(e._zod.def,{get shape(){const i={...e._zod.def.shape,...t};return fo(this,"shape",i),i}});return Ci(e,o)}function JA(e,t){if(!eu(t))throw new Error("Invalid input to safeExtend: expected a plain object");const n=$i(e._zod.def,{get shape(){const r={...e._zod.def.shape,...t};return fo(this,"shape",r),r}});return Ci(e,n)}function eI(e,t){var r,o;if(!((r=t==null?void 0:t._zod)!=null&&r.def))throw new Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if((o=e._zod.def.checks)!=null&&o.length)throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");const n=$i(e._zod.def,{get shape(){const i={...e._zod.def.shape,...t._zod.def.shape};return fo(this,"shape",i),i},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return Ci(e,n)}function P0(e,t,n,r="partial"){const i=t._zod.def.checks;if(i&&i.length>0)throw new Error(`.${r}() cannot be used on object schemas containing refinements`);const c=$i(t._zod.def,{get shape(){const u=t._zod.def.shape,h={...u};if(n)for(const f of Reflect.ownKeys(n)){if(!Object.prototype.hasOwnProperty.call(u,f))throw new Error(`Unrecognized key: "${String(f)}"`);n[f]&&(h[f]=e?new e({type:"optional",innerType:u[f]}):u[f])}else for(const f of Reflect.ownKeys(u))h[f]=e?new e({type:"optional",innerType:u[f]}):u[f];return fo(this,"shape",h),h},checks:[]});return Ci(t,c)}function tI(e,t,n){const r=$i(t._zod.def,{get shape(){const o=t._zod.def.shape,i={...o};if(n)for(const a of Reflect.ownKeys(n)){if(!Object.prototype.hasOwnProperty.call(i,a))throw new Error(`Unrecognized key: "${String(a)}"`);n[a]&&(i[a]=new e({type:"nonoptional",innerType:o[a]}))}else for(const a of Reflect.ownKeys(o))i[a]=new e({type:"nonoptional",innerType:o[a]});return fo(this,"shape",i),i}});return Ci(t,r)}function gl(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 nI(e,t=0){var n;if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(((n=e.issues[r])==null?void 0:n.continue)===!1)return!0;return!1}function ph(e,t){return t.map(n=>{var r;return(r=n).path??(r.path=[]),n.path.unshift(e),n})}function Cc(e){return typeof e=="string"?e:e==null?void 0:e.message}function L0(e,t,n){var r;for(let o=t;o<e.length;o++)(r=e[o]).schema??(r.schema=n)}function Ul(e,t,n){var g,w,y,v,N,x,_,T,j,C;var r;const o=(w=(g=e.inst)==null?void 0:g._zod)==null?void 0:w.traits;o!=null&&o.has("$ZodType")&&(o.has("$ZodCheck")?(r=e).schema??(r.schema=e.inst):e.schema=e.inst);const i=e.schema!==e.inst?(v=(y=e.schema)==null?void 0:y._zod.def)==null?void 0:v.error:void 0,a=e.message?e.message:Cc((_=(x=(N=e.inst)==null?void 0:N._zod.def)==null?void 0:x.error)==null?void 0:_.call(x,e))??Cc(i==null?void 0:i(e))??Cc((T=t==null?void 0:t.error)==null?void 0:T.call(t,e))??Cc((j=n.customError)==null?void 0:j.call(n,e))??Cc((C=n.localeError)==null?void 0:C.call(n,e))??"Invalid input",{inst:c,schema:u,continue:h,input:f,...m}=e;return m.path??(m.path=[]),m.message=a,t!=null&&t.reportInput&&(m.input=f),m}const rI=/[\uD800-\uDBFF]/;function zk(e){const t=e.length;if(!rI.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 Fk(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function oI(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 tu(...e){const[t,n,r]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:r}:{...t}}function sI(e,t){for(const n in t){const r=Object.getOwnPropertyDescriptor(t,n);r.get?Object.defineProperty(e,n,{...r,enumerable:!1}):iI(e,n,r.value)}}function Rl(e,t,n,r=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:r,value:n}),n}function wE(e,t,n){return Rl(e,t,n,!1)}function iI(e,t,n){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?n:Rl(this,t,n.bind(this))},set(r){Rl(this,t,r)}})}function aI(e,t){const n=Object.getPrototypeOf(e);return t in n?void 0:n}let jm,gi=!1;const lI={configurable:!0,get(){gi=!0}};function Tn(e,t,n){const r=Object.getPrototypeOf(e._zod);if(t in r&&jm!==e._zod){jm=void 0;return}jm=e._zod,Object.defineProperty(r,t,{configurable:!0,get(){Object.defineProperty(this,t,lI);const o=gi;gi=!1;try{const i=n(this);return gi?delete this[t]:Object.defineProperty(this,t,{configurable:!0,writable:!0,value:i}),gi=gi||o,i}catch(i){throw delete this[t],gi=gi||o,i}},set(o){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:o})}})}function cI(e,t,n,r){const o=aI(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 uI="~constantCatch";function dI(e){const t=()=>e;return t[uI]=!0,t}var D0;const $m={value:void 0,enumerable:!1};let z0="captureStackTrace"in Error?Error:null;function fI(e){const t=z0;if(t){const n=t.stackTraceLimit;if(typeof n=="number"){try{t.stackTraceLimit=0}catch{return z0=null,new e}try{return new e}finally{t.stackTraceLimit=n}}}return new e}function Ee(e,t,n,r){const o={};function i(g){this.def=g,this.constr=m,this.traits=new Set}i.prototype=o;const a=n,c=a&&new WeakSet;function u(g,w){if(!g._zod){$m.value=new i(w);try{Object.defineProperty(g,"_zod",$m)}finally{$m.value=void 0}}if(g._zod.traits.has(e))return;if(g._zod.traits.add(e),t(g,w),c){const v=Object.getPrototypeOf(g),N=g._zod.constr.prototype;let x=v;for(;x&&x!==N;)x=Object.getPrototypeOf(x);const _=x??v;c.has(_)||(c.add(_),sI(_,a))}const y=m.prototype;for(const v in y)Object.prototype.hasOwnProperty.call(y,v)&&(v in g||(g[v]=y[v].bind(g)))}const h=(r==null?void 0:r.Parent)??Object;class f extends h{}Object.defineProperty(f,"name",{value:e});function m(g){var N;const w=r!=null&&r.Parent?fI(f):this;u(w,g);const y=w._zod.deferred;if(y){for(const x of y)x();w._zod.deferred=void 0}const v=(N=globalThis.__zod_globalConfig)==null?void 0:N.postProcessor;return v&&v(w),w}return Object.defineProperty(m,"init",{value:u}),Object.defineProperty(m,Symbol.hasInstance,{value:g=>{var w,y;return r!=null&&r.Parent&&g instanceof r.Parent?!0:(y=(w=g==null?void 0:g._zod)==null?void 0:w.traits)==null?void 0:y.has(e)}}),Object.defineProperty(m,"name",{value:e}),m}class _l extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class yE extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}(D0=globalThis).__zod_globalConfig??(D0.__zod_globalConfig={});const ss=globalThis.__zod_globalConfig;function Ai(e){return e&&Object.assign(ss,e),ss}function hI(){const e=this._zod;return e.message??(e.message=JSON.stringify(e.def,wg,2)),e.message}function pI(e){this._zod.message=e}const mI={get:hI,set:pI,enumerable:!0,configurable:!0},Cm={value:void 0,enumerable:!1},Am={value:void 0,enumerable:!1},F0=new WeakSet([Object.prototype,Error.prototype]),vE=(e,t)=>{e.name="$ZodError",Cm.value=e._zod,Object.defineProperty(e,"_zod",Cm),Am.value=t,Object.defineProperty(e,"issues",Am),Cm.value=void 0,Am.value=void 0,Object.defineProperty(e,"message",mI);const n=Object.getPrototypeOf(e);F0.has(n)||(F0.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})}}))},bE=Ee("$ZodError",vE),xE=Ee("$ZodError",vE,void 0,{Parent:Error});function gI(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 kI(e,t=n=>n.message){const n={},r=[];for(const o of e.issues)o.path.length>0?gI(n,o.path[0],()=>[]).push(t(o)):r.push(t(o));return{formErrors:r,fieldErrors:n}}function wI(e,t=n=>n.message){const n={_errors:[]},r=(o,i=[])=>{for(const a of o.issues)if(a.code==="invalid_union"&&a.errors.length)a.errors.map(c=>r({issues:c},[...i,...a.path]));else if(a.code==="invalid_key")r({issues:a.issues},[...i,...a.path]);else if(a.code==="invalid_element")r({issues:a.issues},[...i,...a.path]);else{const c=[...i,...a.path];if(c.length===0)n._errors.push(t(a));else{let u=n,h=0;for(;h<c.length;){const f=c[h],m=h===c.length-1;if(f==="_errors"){m&&u._errors.push(t(a)),h++;continue}Object.prototype.hasOwnProperty.call(u,f)||Object.defineProperty(u,f,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});const g=u[f];m&&g._errors.push(t(a)),u=g,h++}}}};return r(e),n}function mh(e,t){return{callee:(t==null?void 0:t.callee)??e,Err:t==null?void 0:t.Err}}const Bk=e=>{const t=(n,r,o,i)=>{const a=o?{...o,async:!1}:{async:!1},c=n._zod.run({value:r,issues:[]},a);if(c instanceof Promise)throw new _l;if(c.issues.length){const u=new((i==null?void 0:i.Err)??e)(c.issues.map(h=>Ul(h,a,Ai())));throw mE(u,(i==null?void 0:i.callee)??t),u}return c.value};return t},Uk=e=>{const t=async(n,r,o,i)=>{const a=o?{...o,async:!0}:{async:!0};let c=n._zod.run({value:r,issues:[]},a);if(c instanceof Promise&&(c=await c),c.issues.length){const u=new((i==null?void 0:i.Err)??e)(c.issues.map(h=>Ul(h,a,Ai())));throw mE(u,(i==null?void 0:i.callee)??t),u}return c.value};return t},gh=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 _l;return i.issues.length?{success:!1,error:new(e??bE)(i.issues.map(a=>Ul(a,o,Ai())))}:{success:!0,data:i.value}},yI=gh(xE),kh=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(a=>Ul(a,o,Ai())))}:{success:!0,data:i.value}},vI=kh(xE),bI=e=>{const t=Bk(e),n=(r,o,i,a)=>{const c=i?{...i,direction:"backward"}:{direction:"backward"};return t(r,o,c,mh(n,a))};return n},xI=e=>{const t=Bk(e),n=(r,o,i,a)=>t(r,o,i,mh(n,a));return n},EI=e=>{const t=Uk(e),n=async(r,o,i,a)=>{const c=i?{...i,direction:"backward"}:{direction:"backward"};return await t(r,o,c,mh(n,a))};return n},SI=e=>{const t=Uk(e),n=async(r,o,i,a)=>await t(r,o,i,mh(n,a));return n},_I=e=>(t,n,r)=>{const o=r?{...r,direction:"backward"}:{direction:"backward"};return gh(e)(t,n,o)},NI=e=>(t,n,r)=>gh(e)(t,n,r),TI=e=>async(t,n,r)=>{const o=r?{...r,direction:"backward"}:{direction:"backward"};return kh(e)(t,n,o)},jI=e=>async(t,n,r)=>kh(e)(t,n,r),$I=/^[cC][0-9a-z]{6,}$/,CI=/^[0-9a-z]+$/,AI=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,II=/^[0-9a-vA-V]{20}$/,RI=/^[A-Za-z0-9]{27}$/,OI=/^[a-zA-Z0-9_-]{21}$/;function MI(e){return new RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}const PI=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,LI=/^([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})$/,B0=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)$/,DI=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,zI="^[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$";function FI(){return new RegExp(zI,"u")}const BI=/^(?:(?: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])$/,UI=/^(([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}|:))$/,HI=/^((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])$/,WI=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,KI=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,EE=/^[A-Za-z0-9_-]*$/,ZI=/^https?$/,qI=/^\+[1-9]\d{6,14}$/,SE="(?:(?:\\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 GI(e){return new RegExp(`^${e}$`)}const VI=GI(SE);function yg(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 YI(e){return new RegExp(`^${yg(e)}$`)}function XI(e){const t=["Z"];e.offset&&t.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const n=`${yg({precision:e.precision,seconds:!0})}(?:${t.join("|")})`,r=e.local?`${n}|${yg({precision:e.precision})}`:n;return new RegExp(`^${SE}T(?:${r})$`)}const QI=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}$`)},JI=/^-?\d+$/,eR=/^-?\d+(?:\.\d+)?$/,tR=/^(?:true|false)$/i,nR=/^[^A-Z]*$/,rR=/^[^a-z]*$/,po=Ee("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),Hk=e=>{const t=e.value;return!UA(t)&&t.length!==void 0},If={number:"number",bigint:"bigint",object:"date"},_E=Ee("$ZodCheckLessThan",(e,t)=>{po.init(e,t);const n=If[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:If[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})}}),NE=Ee("$ZodCheckGreaterThan",(e,t)=>{po.init(e,t);const n=If[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:If[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})}}),oR=Ee("$ZodCheckMultipleOf",(e,t)=>{po.init(e,t),e._zod.onattach.push(n=>{var r;(r=n._zod.bag).multipleOf??(r.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof n.value=="bigint"?t.value!==BigInt(0)&&n.value%t.value===BigInt(0):HA(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})}}),sR=Ee("$ZodCheckNumberFormat",(e,t)=>{var a;po.init(e,t),t.format=t.format||"float64";const n=(a=t.format)==null?void 0:a.includes("int"),r=n?"int":"number",[o,i]=VA[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=JI)}),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})}}),iR=Ee("$ZodCheckMaxLength",(e,t)=>{var n;po.init(e,t),(n=e._zod.def).when??(n.when=Hk),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?zk(o):i)<=t.maximum)return;const c=Fk(o);r.issues.push({origin:c,code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),aR=Ee("$ZodCheckMinLength",(e,t)=>{var n;po.init(e,t),(n=e._zod.def).when??(n.when=Hk),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?zk(o):i)>=t.minimum)return;const c=Fk(o);r.issues.push({origin:c,code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),lR=Ee("$ZodCheckLengthEquals",(e,t)=>{var n;po.init(e,t),(n=e._zod.def).when??(n.when=Hk),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,a=typeof o=="string"&&i>=t.length&&i<=t.length*2?zk(o):i;if(a===t.length)return;const c=Fk(o),u=a>t.length;r.issues.push({origin:c,...u?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!t.abort})}}),wh=Ee("$ZodCheckStringFormat",(e,t)=>{var n,r;po.init(e,t),e._zod.onattach.push(o=>{const i=o._zod.bag;i.format=t.format,t.pattern&&(i.patterns??(i.patterns=new Set),i.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=o=>{t.pattern.lastIndex=0,!t.pattern.test(o.value)&&o.issues.push({origin:"string",code:"invalid_format",format:t.format,input:o.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),cR=Ee("$ZodCheckRegex",(e,t)=>{wh.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})}}),uR=Ee("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=nR),wh.init(e,t)}),dR=Ee("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=rR),wh.init(e,t)}),fR=Ee("$ZodCheckIncludes",(e,t)=>{po.init(e,t);const n=Il(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})}}),hR=Ee("$ZodCheckStartsWith",(e,t)=>{po.init(e,t);const n=new RegExp(`^${Il(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})}}),pR=Ee("$ZodCheckEndsWith",(e,t)=>{po.init(e,t);const n=new RegExp(`.*${Il(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})}}),mR=Ee("$ZodCheckOverwrite",(e,t)=>{po.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});class gR{constructor(t=[],n={}){this.content=[],this.indent=0,this.args=t,this.closed=n}indented(t){this.indent+=1,t(this),this.indent-=1}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}const r=t.split(`
|
|
43
|
+
`).filter(a=>a),o=Math.min(...r.map(a=>a.length-a.trimStart().length)),i=r.map(a=>a.slice(o)).map(a=>" ".repeat(this.indent*2)+a);for(const a of i)this.content.push(a)}compile(){const t=Function,n=(this==null?void 0:this.content)??[""];return new t(...Object.keys(this.closed),`return function (${this.args.join(", ")}) {
|
|
44
|
+
${n.join(`
|
|
45
|
+
`)}
|
|
46
|
+
};`)(...Object.values(this.closed))}}const kR={major:4,minor:5,patch:4},Gn=Ee("$ZodType",(e,t)=>{var i;var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=kR;const r=e._zod.def.checks,o=e._zod.traits.has("$ZodCheck")?[e,...r??[]]:r!=null&&r.length?[...r]:[];for(const a of o)for(const c of a._zod.onattach)c(e);if(o.length===0)(n=e._zod).deferred??(n.deferred=[]),(i=e._zod.deferred)==null||i.push(()=>{e._zod.run=e._zod.parse});else{const a=(u,h,f)=>{if(u.memo)return u;let m=gl(u),g;for(const w of h){if(w._zod.def.when){if(nI(u)||!w._zod.def.when(u))continue}else if(m)continue;const y=u.issues.length,v=w._zod.check(u);if(v instanceof Promise&&(f==null?void 0:f.async)===!1)throw new _l;if(g||v instanceof Promise)g=(g??Promise.resolve()).then(async()=>{await v,u.issues.length!==y&&(L0(u.issues,y,e),m||(m=gl(u,y)))});else{if(u.issues.length===y)continue;L0(u.issues,y,e),m||(m=gl(u,y))}}return g?g.then(()=>u):u},c=(u,h,f)=>{if(gl(u))return u.aborted=!0,u;const m=a(h,o,f);if(m instanceof Promise){if(f.async===!1)throw new _l;return m.then(g=>e._zod.parse(g,f))}return e._zod.parse(m,f)};e._zod.run=(u,h)=>{if(h.skipChecks)return e._zod.parse(u,h);if(h.direction==="backward"){const m=e._zod.parse({value:u.value,issues:[]},{...h,skipChecks:!0});return m instanceof Promise?m.then(g=>c(g,u,h)):c(m,u,h)}const f=e._zod.parse(u,h);if(f instanceof Promise){if(h.async===!1)throw new _l;return f.then(m=>a(m,o,h))}return a(f,o,h)}}},{get"~standard"(){return wE(this,"~standard",TE(this))},set"~standard"(e){Rl(this,"~standard",e)}}),U0=e=>{var t;return e.success?{value:e.data}:{issues:(t=e.error)==null?void 0:t.issues}};function TE(e){return{validate:t=>{try{return U0(yI(e,t))}catch{return vI(e,t).then(U0)}},vendor:"zod",version:1}}const Wk=Ee("$ZodString",(e,t)=>{var n;Gn.init(e,t),e._zod.pattern=[...((n=e==null?void 0:e._zod.bag)==null?void 0:n.patterns)??[]].pop()??QI(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}}),Vn=Ee("$ZodStringFormat",(e,t)=>{wh.init(e,t),Wk.init(e,t)}),wR=Ee("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=LI),Vn.init(e,t)}),yR=Ee("$ZodUUID",(e,t)=>{if(t.version){const r={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(r===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=B0(r))}else t.pattern??(t.pattern=B0());Vn.init(e,t)}),vR=Ee("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=DI),Vn.init(e,t)}),jE=1,$E=2;function bR(e,t){var n;if(!t.normalize&&((n=t.protocol)==null?void 0:n.source)===ZI.source&&!/^https?:\/\//i.test(e))return jE;try{return new URL(e)}catch{return $E}}const xR=/[\t\n\r]/g;function ER(e){return e.replace(xR,"")}function SR(e,t){return t.lastIndex=0,t.test(e.hostname)}function _R(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(":")?e.protocol.slice(0,-1):e.protocol)}const NR=Ee("$ZodURL",(e,t)=>{Vn.init(e,t),e._zod.check=n=>{try{const r=n.value.trim(),o=bR(r,t);if(o===jE){n.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:n.value,inst:e,continue:!t.abort});return}if(o===$E){n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort});return}t.hostname&&!SR(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&&!_R(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:ER(r);return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),TR=Ee("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=FI()),Vn.init(e,t)}),jR=Ee("$ZodNanoID",(e,t)=>{if(t.length!==void 0&&(!Number.isInteger(t.length)||t.length<1))throw new Error(`Invalid nanoid length: ${t.length}`);t.pattern??(t.pattern=t.length===void 0?OI:MI(t.length)),Vn.init(e,t)}),$R=Ee("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=$I),Vn.init(e,t)}),CR=Ee("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=CI),Vn.init(e,t)}),AR=Ee("$ZodULID",(e,t)=>{t.pattern??(t.pattern=AI),Vn.init(e,t)}),IR=Ee("$ZodXID",(e,t)=>{t.pattern??(t.pattern=II),Vn.init(e,t)}),RR=Ee("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=RI),Vn.init(e,t)}),OR=Ee("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=XI(t)),Vn.init(e,t),(t.local||t.precision===-1)&&(e._zod.bag.laxFormat=!0,e._zod.onattach.push(n=>{n._zod.bag.laxFormat=!0}))}),MR=Ee("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=VI),Vn.init(e,t)}),PR=Ee("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=YI(t)),Vn.init(e,t)}),LR=Ee("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=PI),Vn.init(e,t)}),DR=Ee("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=BI),Vn.init(e,t),e._zod.bag.format="ipv4"}),zR=/^[0-9a-fA-F:.]+$/;function CE(e){if(!zR.test(e))return!1;try{return new URL(`http://[${e}]`),!0}catch{return!1}}const FR=Ee("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=UI),Vn.init(e,t),e._zod.bag.format="ipv6",e._zod.check=n=>{CE(n.value)||n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}}),BR=Ee("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=HI),Vn.init(e,t)});function UR(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:CE(n)}const HR=Ee("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=WI),Vn.init(e,t),e._zod.check=n=>{UR(n.value)||n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}});function AE(e){if(e==="")return!0;if(/\s/.test(e)||e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const WR=Ee("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=KI),Vn.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{AE(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});function KR(e){if(!EE.test(e))return!1;const t=e.replace(/[-_]/g,r=>r==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return AE(n)}const ZR=Ee("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=EE),Vn.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{KR(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),qR=Ee("$ZodE164",(e,t)=>{t.pattern??(t.pattern=qI),Vn.init(e,t)});function GR(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 VR=Ee("$ZodJWT",(e,t)=>{Vn.init(e,t),e._zod.check=n=>{GR(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),IE=Ee("$ZodNumber",(e,t)=>{Gn.init(e,t),e._zod.pattern=e._zod.bag.pattern??eR,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}}),YR=Ee("$ZodNumberFormat",(e,t)=>{sR.init(e,t),IE.init(e,t)}),XR=Ee("$ZodBoolean",(e,t)=>{Gn.init(e,t),e._zod.pattern=tR,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}}),QR=Ee("$ZodUnknown",(e,t)=>{Gn.init(e,t),e._zod.parse=n=>n}),JR=Ee("$ZodNever",(e,t)=>{Gn.init(e,t),e._zod.parse=(n,r)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)});function H0(e,t,n){e.issues.length&&t.issues.push(...ph(n,e.issues)),t.value[n]=e.value}const eO=Ee("$ZodArray",(e,t)=>{Gn.init(e,t);const n=ss.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 a=[];for(let c=0;c<i.length;c++){const u=i[c],h=t.element._zod.run({value:u,issues:[]},o);h instanceof Promise?a.push(h.then(f=>H0(f,r,c))):H0(h,r,c)}return a.length?Promise.all(a).then(()=>r):r}});function Rf(e,t,n,r,o,i){const a=n in r,c=i==="optional";if(!(!a&&c&&o==="optional")){if(e.issues.length){if(o!==void 0&&c&&!a)return;t.issues.push(...ph(n,e.issues))}if(!a&&o===void 0){e.issues.length||t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[n]});return}e.value===void 0?a&&(t.value[n]=void 0):t.value[n]=e.value}}const tO=[];function RE(e){var a,c,u,h;const t=Object.keys(e.shape),n=Object.getOwnPropertySymbols(e.shape),r=n.length?n:tO,o=r.length?[...t,...r]:t;for(const f of o)if(!((h=(u=(c=(a=e.shape)==null?void 0:a[f])==null?void 0:c._zod)==null?void 0:u.traits)!=null&&h.has("$ZodType")))throw new Error(`Invalid element at key "${String(f)}": expected a Zod schema`);const i=GA(e.shape);return{...e,allKeys:o,symbolKeys:r,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(i)}}function OE(e,t,n,r,o,i){const a=[],c=o.keySet,u=o.catchall._zod,h=u.def.type,f=u.optin,m=u.optout;for(const g in t){if(c.has(g))continue;if(g==="__proto__"){h==="never"&&a.push(g);continue}if(h==="never"){a.push(g);continue}const w=u.run({value:t[g],issues:[]},r);w instanceof Promise?e.push(w.then(y=>Rf(y,n,g,t,f,m))):Rf(w,n,g,t,f,m)}return a.length&&n.issues.push({code:"unrecognized_keys",keys:a,input:t,inst:i,continue:!0}),e.length?Promise.all(e).then(()=>n):n}const vg=new WeakMap,nO=Ee("$ZodObject",(e,t)=>{Gn.init(e,t);const n=Object.getOwnPropertyDescriptor(t,"shape");if(!(n!=null&&n.get)){const u=t.shape;vg.set(t,u),Object.defineProperty(t,"shape",{get:()=>{const h={...u};return Object.defineProperty(t,"shape",{value:h}),vg.set(t,h),h}})}const r=hh(()=>RE(t));Tn(e,"propValues",u=>{const h=u.def.shape,f={};for(const m in h){const g=h[m]._zod;if(g.values){Object.prototype.hasOwnProperty.call(f,m)||fo(f,m,new Set);for(const w of g.values)f[m].add(w);g.optin!==void 0&&f[m].add(void 0)}}return f});const o=Jc,i=t.catchall;let a;const c=ss.memoizer;c==null||c.attach(e),e._zod.parse=(u,h)=>{a??(a=r.value);const f=u.value;if(!o(f))return u.issues.push({expected:"object",code:"invalid_type",input:f,inst:e}),u;u.value=c?c.alloc(e,u,{},h):{};const m=[],g=a.shape;for(const w of a.allKeys){if(w==="__proto__")continue;const y=g[w],v=y._zod.optin,N=y._zod.optout,x=y._zod.run({value:f[w],issues:[]},h);x instanceof Promise?m.push(x.then(_=>Rf(_,u,w,f,v,N))):Rf(x,u,w,f,v,N)}return i?OE(m,f,u,h,r.value,e):m.length?Promise.all(m).then(()=>u):u}}),rO=Ee("$ZodObjectJIT",(e,t)=>{nO.init(e,t);const n=e._zod.parse,r=hh(()=>RE(t)),o=ss.memoizer,i=w=>{var C,M;const y=r.value,v=y.symbolKeys,N=new gR(["payload","ctx"],{shape:w,inst:e,memo:o,syms:v}),x=I=>`shape[${I}]._zod.run({ value: input[${I}], issues: [] }, ctx)`,_=(I,O)=>`
|
|
47
|
+
for (let i = 0; i < ${I}.issues.length; i++) {
|
|
48
|
+
const iss = ${I}.issues[i];
|
|
49
|
+
iss.path = iss.path ? [${O}, ...iss.path] : [${O}];
|
|
50
|
+
payload.issues.push(iss);
|
|
51
|
+
}`;N.write("const input = payload.value;");const T=Object.create(null);let j=0;for(const I of y.allKeys)T[I]=`key_${j++}`;N.write(o?"const newResult = memo.alloc(inst, payload, {}, ctx);":"const newResult = {};");for(const I of y.allKeys){if(I==="__proto__")continue;const O=T[I],A=typeof I=="symbol"?`syms[${v.indexOf(I)}]`:WA(I),z=`${A} in input`,B=w[I],U=(C=B==null?void 0:B._zod)==null?void 0:C.optin,Q=U!==void 0,ae=((M=B==null?void 0:B._zod)==null?void 0:M.optout)==="optional";if(N.write(`const ${O} = ${x(A)};`),Q&&ae){const ee=U==="optional"?`${O}_present`:`${O}.value !== undefined || ${O}_present`;N.write(`
|
|
52
|
+
const ${O}_present = ${z};
|
|
53
|
+
if (!${O}.issues.length || ${O}_present) {
|
|
54
|
+
if (${O}.issues.length) {${_(O,A)}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (${ee}) {
|
|
58
|
+
newResult[${A}] = ${O}.value;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
`)}else Q?N.write(`
|
|
63
|
+
if (${O}.issues.length) {${_(O,A)}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (${O}.value === undefined) {
|
|
67
|
+
if (${z}) {
|
|
68
|
+
newResult[${A}] = undefined;
|
|
69
|
+
}
|
|
70
|
+
} else {
|
|
71
|
+
newResult[${A}] = ${O}.value;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
`):N.write(`
|
|
75
|
+
const ${O}_present = ${z};
|
|
76
|
+
if (${O}.issues.length) {${_(O,A)}
|
|
77
|
+
}
|
|
78
|
+
if (!${O}_present && !${O}.issues.length) {
|
|
79
|
+
payload.issues.push({
|
|
80
|
+
code: "invalid_type",
|
|
81
|
+
expected: "nonoptional",
|
|
82
|
+
input: undefined,
|
|
83
|
+
path: [${A}]
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
if (${O}_present) {
|
|
88
|
+
newResult[${A}] = ${O}.value;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
`)}return N.write("payload.value = newResult;"),N.write("return payload;"),N.compile()};let a;const c=Jc,u=!ss.jitless,f=u&&ZA.value,m=t.catchall;let g;e._zod.parse=(w,y)=>{g??(g=r.value);const v=w.value;return c(v)?u&&f&&(y==null?void 0:y.async)===!1&&y.jitless!==!0?(a||(a=i(t.shape)),w=a(w,y),m?OE([],v,w,y,g,e):w):n(w,y):(w.issues.push({expected:"object",code:"invalid_type",input:v,inst:e}),w)}});function W0(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=>!gl(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(a=>Ul(a,r,Ai())))}),t)}const ME=Ee("$ZodUnion",(e,t)=>{Gn.init(e,t),Tn(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),Tn(e,"optout",r=>r.def.options.some(o=>o._zod.optout==="optional")?"optional":void 0),Tn(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)))}),Tn(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=>Dk(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 a=[];for(const c of t.options){const u=c._zod.run({value:r.value,issues:[]},o);if(u instanceof Promise)a.push(u),i=!0;else{if(u.issues.length===0)return u;a.push(u)}}return i?Promise.all(a).then(c=>W0(c,r,e,o)):W0(a,r,e,o)}}),oO=Ee("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,ME.init(e,t);const n=e._zod.parse;Tn(e,"propValues",o=>{const i={};for(const a of o.def.options){const c=a._zod.propValues;if(!c||Object.keys(c).length===0)throw new Error(`Invalid discriminated union option at index "${o.def.options.indexOf(a)}"`);for(const[u,h]of Object.entries(c)){Object.prototype.hasOwnProperty.call(i,u)||fo(i,u,new Set);for(const f of h)i[u].add(f)}}return i}),t.options.forEach((o,i)=>{const a=vg.get(o._zod.def);if(a&&!Object.prototype.hasOwnProperty.call(a,t.discriminator))throw new Error(`Invalid discriminated union option at index "${i}"`)});const r=hh(()=>{var a;const o=t.options,i=new Map;for(const c of o){const u=(a=c._zod.propValues)==null?void 0:a[t.discriminator];if(!u||u.size===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(c)}"`);for(const h of u){if(i.has(h))throw new Error(`Duplicate discriminator value "${String(h)}"`);i.set(h,c)}}return i});e._zod.parse=(o,i)=>{const a=o.value;if(!Jc(a))return o.issues.push({code:"invalid_type",expected:"object",input:a,inst:e}),o;const c=r.value.get(a==null?void 0:a[t.discriminator]);return c?c._zod.run(o,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:a,path:[t.discriminator],inst:e}),o)}}),sO=Ee("$ZodIntersection",(e,t)=>{Gn.init(e,t),e._zod.parse=(n,r)=>{const o=n.value,i=t.left._zod.run({value:o,issues:[]},r),a=t.right._zod.run({value:o,issues:[]},r);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([u,h])=>K0(n,u,h)):K0(n,i,a)}});function bg(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(eu(e)&&eu(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 a=bg(e[i],t[i]);if(!a.valid)return{valid:!1,mergeErrorPath:[i,...a.mergeErrorPath]};o[i]=a.data}return{valid:!0,data:o}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const n=[];for(let r=0;r<e.length;r++){const o=e[r],i=t[r],a=bg(o,i);if(!a.valid)return{valid:!1,mergeErrorPath:[r,...a.mergeErrorPath]};n.push(a.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function K0(e,t,n){const r=new Map;let o;const i=new Map,a=(h,f)=>{var g,w;let m;if(h.code==="unrecognized_keys"&&!((g=h.path)!=null&&g.length))o??(o=h),m=h.keys;else if(h.code==="invalid_key"&&h.origin==="record"&&((w=h.path)==null?void 0:w.length)===1){const y=String(h.path[0]);i.has(y)||i.set(y,h),m=[y]}else return!1;for(const y of m)r.has(y)||r.set(y,{}),r.get(y)[f]=!0;return!0};for(const h of t.issues)a(h,"l")||e.issues.push(h);for(const h of n.issues)a(h,"r")||e.issues.push(h);const c=[...r].filter(([,h])=>h.l&&h.r).map(([h])=>h);if(c.length){const h=o?c.filter(f=>o.keys.includes(f)):[];h.length&&e.issues.push({...o,keys:h});for(const f of c)!h.includes(f)&&i.has(f)&&e.issues.push(i.get(f))}const u=bg(t.value,n.value);if(!u.valid){if(gl(e))return e;throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(u.mergeErrorPath)}`)}return e.value=u.data,e}const iO=Ee("$ZodTuple",(e,t)=>{Gn.init(e,t);const n=t.items,r=ss.memoizer;r==null||r.attach(e),e._zod.parse=(o,i)=>{const a=o.value;if(!Array.isArray(a))return o.issues.push({input:a,inst:e,expected:"tuple",code:"invalid_type"}),o;o.value=r?r.alloc(e,o,[],i):[];const c=[],u=Z0(n,"optin"),h=Z0(n,"optout");if(!t.rest){if(a.length<u)return o.issues.push({code:"too_small",minimum:u,inclusive:!0,input:a,inst:e,origin:"array"}),o;a.length>n.length&&o.issues.push({code:"too_big",maximum:n.length,inclusive:!0,input:a,inst:e,origin:"array"})}const f=new Array(n.length);for(let m=0;m<n.length;m++){const g=n[m]._zod.run({value:a[m],issues:[]},i);g instanceof Promise?c.push(g.then(w=>{f[m]=w})):f[m]=g}if(t.rest){let m=n.length-1;const g=a.slice(n.length);for(const w of g){m++;const y=t.rest._zod.run({value:w,issues:[]},i);y instanceof Promise?c.push(y.then(v=>q0(v,o,m))):q0(y,o,m)}}return c.length?Promise.all(c).then(()=>G0(f,o,n,a,h)):G0(f,o,n,a,h)}});function Z0(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 q0(e,t,n){e.issues.length&&t.issues.push(...ph(n,e.issues)),t.value[n]=e.value}function G0(e,t,n,r,o){for(let i=0;i<n.length;i++){const a=e[i],c=i<r.length;if(!c&&i>=o&&n[i]._zod.optin==="optional"){t.value.length=i;break}if(a.issues.length){if(!c&&i>=o){t.value.length=i;break}t.issues.push(...ph(i,a.issues))}t.value[i]=a.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 aO=Ee("$ZodEnum",(e,t)=>{Gn.init(e,t);const n=pE(t.entries),r=new Set(n);e._zod.values=r;const o=n.filter(i=>qA.has(typeof i));e._zod.pattern=new RegExp(o.length?`^(${o.map(i=>Il(i.toString())).join("|")})$`:"^[^\\s\\S]$"),e._zod.parse=(i,a)=>{const c=i.value;return r.has(c)||i.issues.push({code:"invalid_value",values:n,input:c,inst:e}),i}}),lO=Ee("$ZodLiteral",(e,t)=>{Gn.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"?Il(r):r?Il(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}}),cO=Ee("$ZodTransform",(e,t)=>{var n;Gn.init(e,t),e._zod.optin="optional",(n=ss.memoizer)==null||n.guard(e),e._zod.parse=(r,o)=>{if(o.direction==="backward")throw new yE(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 _l;return r.value=i,r}});function V0(e,t){return e.value=t.issues.length?void 0:t.value,e}const PE=Ee("$ZodOptional",(e,t)=>{Gn.init(e,t),Tn(e,"optin",n=>n.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),e._zod.optout="optional",Tn(e,"values",n=>{const r=n.def.innerType._zod.values;return r?new Set([...r,void 0]):void 0}),Tn(e,"pattern",n=>{const r=n.def.innerType._zod.pattern;return r?new RegExp(`^(${Dk(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=>V0(n,i)):V0(n,o)}return t.innerType._zod.run(n,r)}}),uO=Ee("$ZodExactOptional",(e,t)=>{PE.init(e,t),Tn(e,"values",n=>n.def.innerType._zod.values),Tn(e,"pattern",n=>n.def.innerType._zod.pattern),e._zod.parse=(n,r)=>t.innerType._zod.run(n,r)}),dO=Ee("$ZodNullable",(e,t)=>{Gn.init(e,t),Tn(e,"optin",n=>n.def.innerType._zod.optin),Tn(e,"optout",n=>n.def.innerType._zod.optout),Tn(e,"pattern",n=>{const r=n.def.innerType._zod.pattern;return r?new RegExp(`^(${Dk(r.source)}|null)$`):void 0}),Tn(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)}),fO=Ee("$ZodDefault",(e,t)=>{Gn.init(e,t),e._zod.optin="defaulted",Tn(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=>Y0(i,t)):Y0(o,t)}});function Y0(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const hO=Ee("$ZodPrefault",(e,t)=>{Gn.init(e,t),e._zod.optin="defaulted",Tn(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))}),pO=Ee("$ZodNonOptional",(e,t)=>{Gn.init(e,t),Tn(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=>X0(i,e)):X0(o,e)}});function X0(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 Q0(e,t,n,r){return t.issues.length?(e.value=n.catchValue({...t,value:e.value,error:{issues:t.issues.map(o=>Ul(o,r,Ai()))},input:e.value}),e):(e.value=t.value,t.memo&&(e.memo=!0),e)}const mO=Ee("$ZodCatch",(e,t)=>{Gn.init(e,t),Tn(e,"optin",n=>n.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),Tn(e,"optout",n=>n.def.innerType._zod.optout),Tn(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=>Q0(n,i,t,r)):Q0(n,o,t,r)}}),gO=Ee("$ZodPipe",(e,t)=>{Gn.init(e,t),Tn(e,"values",n=>n.def.in._zod.values),Tn(e,"optin",n=>n.def.in._zod.optin),Tn(e,"optout",n=>n.def.out._zod.optout),Tn(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(a=>qd(a,t.in,r)):qd(i,t.in,r)}const o=t.in._zod.run(n,r);return o instanceof Promise?o.then(i=>qd(i,t.out,r)):qd(o,t.out,r)}});function qd(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 kO=Ee("$ZodReadonly",(e,t)=>{Gn.init(e,t),Tn(e,"propValues",n=>n.def.innerType._zod.propValues),Tn(e,"values",n=>n.def.innerType._zod.values),Tn(e,"optin",n=>{var r,o;return(o=(r=n.def.innerType)==null?void 0:r._zod)==null?void 0:o.optin}),Tn(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(J0):J0(o)}});function J0(e){return e.memo||(e.value=Object.freeze(e.value)),e}const wO=Ee("$ZodCustom",(e,t)=>{po.init(e,t),Gn.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=>eb(i,n,r,e));eb(o,n,r,e)}});function eb(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(tu(o))}}class yO extends Error{constructor(){super("Cannot parse a reference cycle that closes through a transform"),this.name="ZodCyclicError"}}const xg="~memo",tb=[];function Im(e){return e.map(t=>t.path?{...t,path:t.path.slice()}:{...t})}const nb=new WeakMap;function LE(e,t){const n=nb.get(e);if(n!==void 0)return n;if(t.has(e))return!0;t.add(e);let r=!1;const o=c=>{!r&&(c!=null&&c._zod)&&LE(c,t)&&(r=!0)},i=e._zod.def;switch(i.type){case"object":{for(const c of Reflect.ownKeys(i.shape))o(i.shape[c]);o(i.catchall);break}case"array":o(i.element);break;case"tuple":for(const c of i.items)o(c);o(i.rest);break;case"record":case"map":o(i.keyType),o(i.valueType);break;case"set":o(i.valueType);break;case"union":for(const c of i.options)o(c);break;case"intersection":o(i.left),o(i.right);break;case"optional":case"nullable":case"default":case"prefault":case"catch":case"readonly":case"nonoptional":case"promise":case"success":o(i.innerType);break;case"pipe":o(i.in),o(i.out);break;case"function":o(i.input),o(i.output);break;case"lazy":o(e._zod.innerType);break;case"template_literal":case"string":case"number":case"int":case"boolean":case"bigint":case"symbol":case"undefined":case"null":case"void":case"never":case"any":case"unknown":case"date":case"nan":case"enum":case"literal":case"file":case"transform":case"custom":break;default:for(const c in i){const u=Object.getOwnPropertyDescriptor(i,c);if(!u||u.get)continue;const h=u.value;if(!(!h||typeof h!="object")){if(h._zod)o(h);else if(Array.isArray(h))for(const f of h)o(f)}}}return t.delete(e),nb.set(e,r),r}function vO(e,t){let n=e.buckets.get(t);return n||(n=new Map,e.buckets.set(t,n)),n}let Gd;const Vd=[],bO={alloc(e,t,n){const r=Gd;if(!r)return n;Gd=void 0;const o={value:n,issues:null};return r.set(t.value,o),Vd.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"&&EO(i,o.value))throw new yO;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,a=(c,u)=>{if(n===void 0&&(n=LE(e,new Set),!n))return e._zod.parse=i,e._zod.run===a&&(e._zod.run=i),i(c,u);const h=c.value;if(h===null||typeof h!="object")return i(c,u);let f=u[xg];f||(f={buckets:new Map,backEdges:void 0},u[xg]=f);let m;r===u?m=o:(m=vO(f,e),r=u,o=m);const g=m.get(h);if(g)return c.value=g.value,g.issues?g.issues.length&&c.issues.push(...Im(g.issues)):(c.memo=!0,f.backEdges??(f.backEdges=new Set),f.backEdges.add(g.value)),c;Gd=m;const w=Vd.length,y=i(c,u);Gd=void 0;const v=Vd.length>w?Vd.pop():void 0;return y instanceof Promise?y.then(N=>(v&&(v.issues=N.issues.length?Im(N.issues):tb),N)):(v&&(v.issues=y.issues.length?Im(y.issues):tb),y)};e._zod.parse=a,e._zod.run===i&&(e._zod.run=a)})}};function xO(){return bO}function EO(e,t){var r;const n=(r=e[xg])==null?void 0:r.backEdges;return n!==void 0&&t!==null&&typeof t=="object"&&n.has(t)}const SO=()=>{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,a){return i==="number"&&typeof a=="number"&&!Number.isFinite(a)?String(a):r[i]??i}return i=>{switch(i.code){case"invalid_type":{const a=o(i.expected),c=oI(i.input),u=o(c,i.input);return`Invalid input: expected ${a}, received ${u}`}case"invalid_value":return i.values.length===1?`Invalid input: expected ${kE(i.values[0])}`:`Invalid option: expected one of ${M0(i.values,"|")}`;case"too_big":{const a=i.exact?"exactly ":i.inclusive?"<=":"<",c=t(i.origin);return c?`Too big: expected ${i.origin??"value"} to have ${a}${i.maximum.toString()} ${c.unit??"elements"}`:`Too big: expected ${i.origin??"value"} to be ${a}${i.maximum.toString()}`}case"too_small":{const a=i.exact?"exactly ":i.inclusive?">=":">",c=t(i.origin);return c?`Too small: expected ${i.origin} to have ${a}${i.minimum.toString()} ${c.unit}`:`Too small: expected ${i.origin} to be ${a}${i.minimum.toString()}`}case"invalid_format":{const a=i;return a.format==="starts_with"?`Invalid string: must start with "${a.prefix}"`:a.format==="ends_with"?`Invalid string: must end with "${a.suffix}"`:a.format==="includes"?`Invalid string: must include "${a.includes}"`:a.format==="regex"?`Invalid string: must match pattern ${a.pattern}`:`Invalid ${n[a.format]??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":""}: ${M0(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 _O(){return{localeError:SO()}}var rb;class NO{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...n){const r=n[0];return this._map.set(t,r),r&&typeof r=="object"&&"id"in r&&this._idmap.set(r.id,t),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(t){const n=this._map.get(t);return n&&typeof n=="object"&&"id"in n&&this._idmap.delete(n.id),this._map.delete(t),this}get(t){const n=t._zod.parent;if(n){const r={...this.get(n)??{}};delete r.id;const o={...r,...this._map.get(t)};return Object.keys(o).length?o:void 0}return this._map.get(t)}has(t){return this._map.has(t)}}function TO(){return new NO}(rb=globalThis).__zod_globalRegistry??(rb.__zod_globalRegistry=TO());const zc=globalThis.__zod_globalRegistry;function jO(e,t){return new e({type:"string",...ct(t)})}function $O(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...ct(t)})}function CO(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...ct(t)})}function AO(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...ct(t)})}function IO(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...ct(t)})}function RO(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...ct(t)})}function OO(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...ct(t)})}function MO(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...ct(t)})}function PO(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...ct(t)})}function LO(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...ct(t)})}function DO(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...ct(t)})}function zO(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...ct(t)})}function FO(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...ct(t)})}function BO(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...ct(t)})}function UO(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...ct(t)})}function HO(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...ct(t)})}function WO(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...ct(t)})}function KO(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...ct(t)})}function ZO(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...ct(t)})}function qO(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...ct(t)})}function GO(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...ct(t)})}function VO(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...ct(t)})}function YO(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...ct(t)})}function XO(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...ct(t)})}function QO(e,t){return new e({type:"string",format:"date",check:"string_format",...ct(t)})}function JO(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...ct(t)})}function e2(e,t){return new e({type:"string",format:"duration",check:"string_format",...ct(t)})}function t2(e,t){return new e({type:"number",checks:[],...ct(t)})}function n2(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...ct(t)})}function r2(e,t){return new e({type:"boolean",...ct(t)})}function o2(e){return new e({type:"unknown"})}function s2(e,t){return new e({type:"never",...ct(t)})}function ob(e,t){return new _E({check:"less_than",...ct(t),value:e,inclusive:!1})}function Rm(e,t){return new _E({check:"less_than",...ct(t),value:e,inclusive:!0})}function sb(e,t){return new NE({check:"greater_than",...ct(t),value:e,inclusive:!1})}function Om(e,t){return new NE({check:"greater_than",...ct(t),value:e,inclusive:!0})}function ib(e,t){return new oR({check:"multiple_of",...ct(t),value:e})}function DE(e,t){return new iR({check:"max_length",...ct(t),maximum:e})}function Of(e,t){return new aR({check:"min_length",...ct(t),minimum:e})}function zE(e,t){return new lR({check:"length_equals",...ct(t),length:e})}function i2(e,t){return new cR({check:"string_format",format:"regex",...ct(t),pattern:e})}function a2(e){return new uR({check:"string_format",format:"lowercase",...ct(e)})}function l2(e){return new dR({check:"string_format",format:"uppercase",...ct(e)})}function c2(e,t){return new fR({check:"string_format",format:"includes",...ct(t),includes:e})}function u2(e,t){return new hR({check:"string_format",format:"starts_with",...ct(t),prefix:e})}function d2(e,t){return new pR({check:"string_format",format:"ends_with",...ct(t),suffix:e})}function Hl(e){return new mR({check:"overwrite",tx:e})}function f2(e){return Hl(t=>t.normalize(e))}function h2(){return Hl(e=>e.trim())}function p2(){return Hl(e=>e.toLowerCase())}function m2(){return Hl(e=>e.toUpperCase())}function g2(){return Hl(e=>KA(e))}function k2(e,t,n){return new e({type:"array",element:t,...ct(n)})}function w2(e,t,n){return new e({type:"custom",check:"custom",fn:t,...ct(n)})}function y2(e,t){const n=v2(r=>(r.addIssue=o=>{if(typeof o=="string")r.issues.push(tu(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(tu(i))}},e(r.value,r)),t);return n}function v2(e,t){const n=new po({check:"custom",...ct(t)});return n._zod.check=e,n}function qc(e,...t){for(const n of t)for(const r of Reflect.ownKeys(n))Object.prototype.propertyIsEnumerable.call(n,r)&&fo(e,r,n[r]);return e}function FE(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)??zc,target:t,unrepresentable:(e==null?void 0:e.unrepresentable)??"throw",override:(e==null?void 0:e.override)??(()=>{}),io:(e==null?void 0:e.io)??"output",counter:0,seen:new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:(e==null?void 0:e.cycles)??"ref",reused:(e==null?void 0:e.reused)??"inline",intersections:[],deferred:[],external:(e==null?void 0:e.external)??void 0}}function Ni(e,t,n,r,o){const i=typeof t.unrepresentable=="function"?t.unrepresentable({zodSchema:e,path:r.path,message:o}):t.unrepresentable;if(i==="any")return!1;if(i===void 0||i==="throw")throw new Error(o);return Object.assign(n,i),!0}function wr(e,t,n={path:[],schemaPath:[]}){var f,m;var r;const o=e._zod.def,i=t.seen.get(e);if(i)return i.count++,n.schemaPath.includes(e)&&(i.cycle=n.path),i.schema;const a={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,a),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;const c=(m=(f=e._zod).toJSONSchema)==null?void 0:m.call(f);if(c)a.schema=c;else{const g={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,a.schema,g);else{const y=a.schema,v=t.processors[o.type];if(!v)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${o.type}`);v(e,t,y,g)}const w=e._zod.parent;w&&(a.ref||(a.ref=w),wr(w,t,g),t.seen.get(w).isParent=!0)}const u=t.metadataRegistry.get(e);return u&&qc(a.schema,u),t.io==="input"&&Yr(e)&&(delete a.schema.examples,delete a.schema.default),t.io==="input"&&"_prefault"in a.schema&&((r=a.schema).default??(r.default=a.schema._prefault)),delete a.schema._prefault,t.seen.get(e).schema}function ab(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function BE(e,t){var a,c,u,h;const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");if(e.external&&e.sharedDefsExtractedFor===e.external)return;const r=new Map;for(const f of e.seen.entries()){const m=(a=e.metadataRegistry.get(f[0]))==null?void 0:a.id;if(m){const g=r.get(m);if(g&&g!==f[0])throw new Error(`Duplicate schema id "${m}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(m,f[0])}}const o=f=>{var v;const m=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){const N=(v=e.external.registry.get(f[0]))==null?void 0:v.id,x=e.external.uri??(T=>T);if(N)return{ref:x(N)};const _=f[1].defId??f[1].schema.id??`schema${e.counter++}`;return f[1].defId=_,{defId:_,ref:`${x("__shared")}#/${m}/${ab(_)}`}}const g="#",w=`${g}/${m}/`;if(f[1]===n&&!f[1].schema.id)return{ref:g};const y=f[1].schema.id??`__schema${e.counter++}`;return{defId:y,ref:w+ab(y)}},i=f=>{if(f[1].schema.$ref)return;const m=f[1],{ref:g,defId:w}=o(f);m.def={...m.schema},w&&(m.defId=w);const y=m.schema;for(const v in y)delete y[v];y.$ref=g};if(e.cycles==="throw")for(const f of e.seen.entries()){const m=f[1];if(m.cycle)throw new Error(`Cycle detected: #/${(c=m.cycle)==null?void 0:c.join("/")}/<root>
|
|
92
|
+
|
|
93
|
+
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const f of e.seen.entries()){const m=f[1];if(t===f[0]){i(f);continue}if(e.external){const w=(u=e.external.registry.get(f[0]))==null?void 0:u.id;if(t!==f[0]&&w){i(f);continue}}if((h=e.metadataRegistry.get(f[0]))==null?void 0:h.id){i(f);continue}if(m.cycle){i(f);continue}if(m.count>1&&e.reused==="ref"){i(f);continue}}e.external&&(e.sharedDefsExtractedFor=e.external)}function UE(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;UE(r);const o=Object.keys(r);if(o.length!==1||o[0]!=="type")return;const i=r.type;for(const a of Array.isArray(i)?i:[i]){if(typeof a!="string")return;n.includes(a)||n.push(a)}}delete e.anyOf,e.type=n.length===1?n[0]:n}const HE=new Set(["type","properties","required","additionalProperties"]),lb=["oneOf","anyOf"];function cb(e){const t=e.additionalProperties;return t===void 0||t===!1||typeof t!="object"||t===null?null:Object.keys(t).length?t:null}function Eg(e){var i;const t=[];for(const a of e){if(typeof a!="object"||a.type!=="object")return null;for(const c in a)if(!HE.has(c))return null;t.push(a)}const n={},r=new Set;for(const a of t){for(const c in a.properties){if(Object.prototype.hasOwnProperty.call(n,c))continue;const u=[];for(const f of t){const m=((i=f.properties)==null?void 0:i[c])??cb(f);m!=null&&(u.some(g=>JSON.stringify(g)===JSON.stringify(m))||u.push(m))}const h=u.length===1?u[0]:Eg(u)??{allOf:u};fo(n,c,h)}for(const c of a.required??[])r.add(c)}const o={type:"object",properties:n};if(r.size&&(o.required=[...r]),t.every(a=>a.additionalProperties===!1))o.additionalProperties=!1;else{const a=[];for(const c of t){const u=cb(c);u&&!a.some(h=>JSON.stringify(h)===JSON.stringify(u))&&a.push(u)}a.length===1?o.additionalProperties=a[0]:a.length>1&&(o.additionalProperties={allOf:a})}return o}function b2(e){const t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(const o of HE)if(o in e)return;const n=t.filter(o=>lb.some(i=>Array.isArray(o[i])));let r=null;if(!n.length)r=Eg(t);else{const o=n[0],i=lb.find(u=>Array.isArray(o[u]));if(Object.keys(o).length!==1)return;const a=t.filter(u=>u!==o),c=o[i].map(u=>Eg([...a,u]));if(c.some(u=>!u))return;r={[i]:c}}r&&(delete e.allOf,qc(e,r))}function WE(e,t){var c,u,h,f;const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=m=>{const g=e.seen.get(m);if(g.ref===null)return;const w=g.def??g.schema,y={...w},v=g.ref;if(g.ref=null,v){r(v);const x=e.seen.get(v),_=x.schema;if(_.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(w.allOf=w.allOf??[],w.allOf.push(_)):qc(w,_),qc(w,y),m._zod.parent===v)for(const j in w)j==="$ref"||j==="allOf"||j in y||delete w[j];if(_.$ref&&x.def)for(const j in w)j==="$ref"||j==="allOf"||j in x.def&&JSON.stringify(w[j])===JSON.stringify(x.def[j])&&delete w[j]}const N=m._zod.parent;if(N&&N!==v){r(N);const x=e.seen.get(N);if(x!=null&&x.schema.$ref&&(w.$ref=x.schema.$ref,x.def))for(const _ in w)_==="$ref"||_==="allOf"||_ in x.def&&JSON.stringify(w[_])===JSON.stringify(x.def[_])&&delete w[_]}e.override({zodSchema:m,jsonSchema:w,path:g.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(const m of[...e.seen.entries()].reverse())r(m[0]);if(e.target!=="openapi-3.0")for(const m of e.seen.entries())UE(m[1].def??m[1].schema);for(const m of e.deferred)m();if(e.intersections.length){const m=new Map;for(const g of e.seen.values())for(const w of[g.schema,g.def]){const y=w==null?void 0:w.allOf;if(!Array.isArray(y))continue;const v=m.get(y);v?v.push(w):m.set(y,[w])}for(const g of e.intersections)for(const w of m.get(g)??[])b2(w)}}const o={};if(e.target==="draft-2020-12"?o.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?o.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?o.$schema="http://json-schema.org/draft-04/schema#":e.target,(c=e.external)!=null&&c.uri){const m=(u=e.external.registry.get(t))==null?void 0:u.id;if(!m)throw new Error("Schema is missing an `id` property");o.$id=e.external.uri(m)}qc(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 a=((f=e.external)==null?void 0:f.defs)??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(const m of e.seen.entries()){const g=m[1];g.def&&g.defId&&(g.def.id===g.defId&&delete g.def.id,fo(a,g.defId,g.def))}e.external&&(e.sharedEmitDoneFor=e.external),e.external||Object.keys(a).length>0&&(e.target==="draft-2020-12"?o.$defs=a:o.definitions=a);try{const m=JSON.parse(JSON.stringify(o));return Object.defineProperty(m,"~standard",{value:{...t["~standard"],jsonSchema:{input:Mf(t,"input",e.processors),output:Mf(t,"output",e.processors)}},enumerable:!1,writable:!1}),m}catch{throw new Error("Error converting schema to JSON.")}}function Yr(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 Yr(r.element,n);if(r.type==="set")return Yr(r.valueType,n);if(r.type==="lazy")return Yr(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 Yr(r.innerType,n);if(r.type==="intersection")return Yr(r.left,n)||Yr(r.right,n);if(r.type==="record"||r.type==="map")return Yr(r.keyType,n)||Yr(r.valueType,n);if(r.type==="pipe")return e._zod.traits.has("$ZodCodec")?!0:Yr(r.in,n)||Yr(r.out,n);if(r.type==="object"){for(const o in r.shape)if(Yr(r.shape[o],n))return!0;return!1}if(r.type==="union"){for(const o of r.options)if(Yr(o,n))return!0;return!1}if(r.type==="tuple"){for(const o of r.items)if(Yr(o,n))return!0;return!!(r.rest&&Yr(r.rest,n))}return!1}const x2=(e,t={})=>n=>{const r=FE({...n,processors:t});return wr(e,r),BE(r,e),WE(r,e)},Mf=(e,t,n={})=>r=>{const{libraryOptions:o,target:i}=r??{},a=FE({...o??{},target:i,io:t,processors:n});return wr(e,a),BE(a,e),WE(a,e)},E2={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},S2=(e,t,n,r)=>{const o=n;o.type="string";const{minimum:i,maximum:a,format:c,patterns:u,contentEncoding:h,laxFormat:f}=e._zod.bag;if(typeof i=="number"&&(o.minLength=i),typeof a=="number"&&(o.maxLength=a),c&&(o.format=E2[c]??c,o.format===""&&delete o.format,(c==="time"||f)&&delete o.format),h&&(o.contentEncoding=h),u&&u.size>0){const m=[...u];m.length===1?o.pattern=m[0].source:m.length>1&&(o.allOf=[...m.map(g=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:g.source}))])}},_2=(e,t,n,r)=>{const o=n,{minimum:i,maximum:a,format:c,multipleOf:u,exclusiveMaximum:h,exclusiveMinimum:f}=e._zod.bag;typeof c=="string"&&c.includes("int")?o.type="integer":o.type="number";const m=typeof f=="number"&&f>=(i??Number.NEGATIVE_INFINITY),g=typeof h=="number"&&h<=(a??Number.POSITIVE_INFINITY),w=t.target==="draft-04"||t.target==="openapi-3.0";m?w?(o.minimum=f,o.exclusiveMinimum=!0):o.exclusiveMinimum=f:typeof i=="number"&&(o.minimum=i),g?w?(o.maximum=h,o.exclusiveMaximum=!0):o.exclusiveMaximum=h:typeof a=="number"&&(o.maximum=a),typeof u=="number"&&(Number.isFinite(u)&&u!==0?o.multipleOf=Math.abs(u):Ni(e,t,o,r,`A multipleOf divisor of ${u} cannot be represented in JSON Schema`))},N2=(e,t,n,r)=>{n.type="boolean"},T2=(e,t,n,r)=>{n.not={}},j2=(e,t,n,r)=>{},$2=(e,t,n,r)=>{const o=e._zod.def,i=pE(o.entries);if(i.length===0){n.not={};return}i.every(a=>typeof a=="number")&&(n.type="number"),i.every(a=>typeof a=="string")&&(n.type="string"),n.enum=i},C2=(e,t,n,r)=>{const o=e._zod.def;if(o.values.length===0){n.not={};return}const i=[];for(const a of o.values)if(a===void 0){if(Ni(e,t,n,r,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof a=="bigint"){if(Ni(e,t,n,r,"BigInt literals cannot be represented in JSON Schema"))return;i.push(Number(a))}else i.push(a);if(i.length!==0)if(i.length===1){const a=i[0];n.type=a===null?"null":typeof a,t.target==="draft-04"||t.target==="openapi-3.0"?n.enum=[a]:n.const=a}else i.every(a=>typeof a=="number")&&(n.type="number"),i.every(a=>typeof a=="string")&&(n.type="string"),i.every(a=>typeof a=="boolean")&&(n.type="boolean"),i.every(a=>a===null)&&(n.type="null"),n.enum=i},A2=(e,t,n,r)=>{Ni(e,t,n,r,"Custom types cannot be represented in JSON Schema")},I2=(e,t,n,r)=>{Ni(e,t,n,r,"Transforms cannot be represented in JSON Schema")},R2=(e,t,n,r)=>{const o=n,i=e._zod.def,{minimum:a,maximum:c}=e._zod.bag;typeof a=="number"&&(o.minItems=a),typeof c=="number"&&(o.maxItems=c),o.type="array",o.items=wr(i.element,t,{...r,path:[...r.path,"items"]})};function Pf(e){const t=e._zod.def;return t.type==="pipe"&&t.in._zod.traits.has("$ZodTransform")?Pf(t.out):t.type==="catch"?Pf(t.innerType):e._zod.optin}const O2=(e,t,n,r)=>{var f;const o=n,i=e._zod.def,a=i.shape;if(Object.getOwnPropertySymbols(a).length&&Ni(e,t,o,r,"Symbol keys cannot be represented in JSON Schema"))return;o.type="object",o.properties={};for(const m in a)fo(o.properties,m,wr(a[m],t,{...r,path:[...r.path,"properties",m]}));const u=new Set(Object.keys(a)),h=new Set([...u].filter(m=>{const g=i.shape[m];return t.io==="input"?Pf(g)===void 0:g._zod.optout===void 0}));h.size>0&&(o.required=Array.from(h)),((f=i.catchall)==null?void 0:f._zod.def.type)==="never"?o.additionalProperties=!1:i.catchall?i.catchall&&(o.additionalProperties=wr(i.catchall,t,{...r,path:[...r.path,"additionalProperties"]})):t.io==="output"&&(o.additionalProperties=!1)},M2=(e,t,n,r)=>{const o=e._zod.def,i=o.inclusive===!1,a=o.options.map((c,u)=>wr(c,t,{...r,path:[...r.path,i?"oneOf":"anyOf",u]}));i?n.oneOf=a:n.anyOf=a},P2=(e,t,n,r)=>{const o=e._zod.def,i=wr(o.left,t,{...r,path:[...r.path,"allOf",0]}),a=wr(o.right,t,{...r,path:[...r.path,"allOf",1]}),c=h=>"allOf"in h&&Object.keys(h).length===1,u=[...c(i)?i.allOf:[i],...c(a)?a.allOf:[a]];n.allOf=u,t.intersections.push(u)},L2=(e,t,n,r)=>{const o=n,i=e._zod.def;o.type="array";const a=t.target==="draft-2020-12"?"prefixItems":"items",c=t.target==="draft-2020-12"||t.target==="openapi-3.0"?"items":"additionalItems",u=i.items.map((v,N)=>wr(v,t,{...r,path:[...r.path,a,N]})),h=i.rest?wr(i.rest,t,{...r,path:[...r.path,c,...t.target==="openapi-3.0"?[i.items.length]:[]]}):null;let f=i.items.length;for(;f>0;){const v=i.items[f-1];if(!(t.io==="input"?Pf(v)!==void 0:v._zod.optout==="optional"))break;f--}const m=i.items.length,g=!i.rest;t.target==="draft-2020-12"?(o.prefixItems=u,g?o.items=!1:h&&(o.items=h),f>0&&(o.minItems=f),g&&(o.maxItems=m)):t.target==="openapi-3.0"?(o.items={anyOf:u},h&&o.items.anyOf.push(h),f>0&&(o.minItems=f),g&&(o.maxItems=m)):(o.items=u,g?o.additionalItems=!1:h&&(o.additionalItems=h),f>0&&(o.minItems=f),g&&(o.maxItems=m));const{minimum:w,maximum:y}=e._zod.bag;typeof w=="number"&&(o.minItems=w),typeof y=="number"&&(o.maxItems=y)},D2=(e,t,n,r)=>{const o=e._zod.def,i=wr(o.innerType,t,r),a=t.seen.get(e);t.target==="openapi-3.0"?(a.ref=o.innerType,n.nullable=!0):n.anyOf=[i,{type:"null"}]},z2=(e,t,n,r)=>{const o=e._zod.def;wr(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType},Kk=Symbol();function KE(e,t,n,r,o){let i=!1;const a=JSON.stringify(e,(c,u)=>typeof u!="bigint"?u:(i=!0,null));return i?(Ni(t,n,r,o,"BigInt defaults cannot be represented in JSON Schema"),Kk):JSON.parse(a)}const F2=(e,t,n,r)=>{const o=e._zod.def;wr(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType;const a=KE(o.defaultValue,e,t,n,r);a!==Kk&&(n.default=a)},B2=(e,t,n,r)=>{const o=e._zod.def;wr(o.innerType,t,r);const i=t.seen.get(e);if(i.ref=o.innerType,t.io!=="input")return;const a=KE(o.defaultValue,e,t,n,r);a!==Kk&&(n._prefault=a)},U2=(e,t,n,r)=>{const o=e._zod.def;wr(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType;let a;try{a=o.catchValue(void 0)}catch{Ni(e,t,n,r,"Dynamic catch values are not supported in JSON Schema");return}n.default=a},H2=(e,t,n,r)=>{const o=e._zod.def,i=o.in._zod.traits.has("$ZodTransform"),a=t.io==="input"?i?o.out:o.in:o.out;wr(a,t,r);const c=t.seen.get(e);c.ref=a},W2=(e,t,n,r)=>{const o=e._zod.def;wr(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType,n.readOnly=!0},ZE=(e,t,n,r)=>{const o=e._zod.def;wr(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType},ub=new WeakSet([Object.prototype,Error.prototype]);function Yd(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 K2=(e,t)=>{bE.init(e,t),e.name="ZodError";const n=Object.getPrototypeOf(e);ub.has(n)||(ub.add(n),Yd(n,"format",r=>o=>wI(r,o)),Yd(n,"flatten",r=>o=>kI(r,o)),Yd(n,"addIssue",r=>o=>{r.issues.push(o),r.message=JSON.stringify(r.issues,wg,2)}),Yd(n,"addIssues",r=>o=>{r.issues.push(...o),r.message=JSON.stringify(r.issues,wg,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},Ho=Ee("ZodError",K2,void 0,{Parent:Error}),Z2=Bk(Ho),q2=Uk(Ho),G2=gh(Ho),V2=kh(Ho),Y2=bI(Ho),X2=xI(Ho),Q2=EI(Ho),J2=SI(Ho),eM=_I(Ho),tM=NI(Ho),nM=TI(Ho),rM=jI(Ho);function oM(){ss.localeError||Ai(_O())}function yh(){ss.memoizer||Ai({memoizer:xO()})}const Qn=Ee("ZodType",(e,t)=>(oM(),Gn.init(e,t),e.def=t,e.type=t.type,e),{check(...e){const t=this.def;return this.clone($i(t,{checks:[...t.checks??[],...e.map(n=>typeof n=="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return Ci(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(nP(e,t))},superRefine(e,t){return this.check(rP(e,t))},overwrite(e){return this.check(Hl(e))},optional(){return hb(this)},exactOptional(){return WM(this)},nullable(){return pb(this)},nullish(){return hb(pb(this))},nonoptional(e){return YM(this,e)},array(){return ga(this)},or(e){return MM([this,e])},and(e){return zM(this,e)},transform(e){return mb(this,HM(e))},default(e){return qM(this,e)},prefault(e){return VM(this,e)},catch(e){return QM(this,e)},pipe(e){return mb(this,e)},readonly(){return tP(this)},describe(e){const t=this.clone();return zc.add(t,{description:e}),t},meta(...e){if(e.length===0)return zc.get(this);const t=this.clone();return zc.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 wE(this,"~standard",{...TE(this),jsonSchema:{input:Mf(this,"input"),output:Mf(this,"output")}})},set"~standard"(e){Rl(this,"~standard",e)},parse:function e(t,n){return Z2(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await q2(this,t,n,{callee:e})},safeParse(e,t){return G2(this,e,t)},async safeParseAsync(e,t){return V2(this,e,t)},get spa(){return this==null?void 0:this.safeParseAsync},set spa(e){Rl(this,"spa",e)},encode:function e(t,n){return Y2(this,t,n,{callee:e})},decode:function e(t,n){return X2(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await Q2(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await J2(this,t,n,{callee:e})},safeEncode(e,t){return eM(this,e,t)},safeDecode(e,t){return tM(this,e,t)},async safeEncodeAsync(e,t){return nM(this,e,t)},async safeDecodeAsync(e,t){return rM(this,e,t)},toJSONSchema(e){return x2(this,{})(e)},get description(){var e;return(e=zc.get(this))==null?void 0:e.description},get _def(){return this._zod.def}}),qE=Ee("_ZodString",(e,t)=>{Wk.init(e,t),Qn.init(e,t),e._zod.processJSONSchema=(r,o,i)=>S2(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(i2(...e))},includes(...e){return this.check(c2(...e))},startsWith(...e){return this.check(u2(...e))},endsWith(...e){return this.check(d2(...e))},min(...e){return this.check(Of(...e))},max(...e){return this.check(DE(...e))},length(...e){return this.check(zE(...e))},nonempty(...e){return this.check(Of(1,...e))},lowercase(e){return this.check(a2(e))},uppercase(e){return this.check(l2(e))},trim(){return this.check(h2())},normalize(...e){return this.check(f2(...e))},toLowerCase(){return this.check(p2())},toUpperCase(){return this.check(m2())},slugify(){return this.check(g2())}}),sM=Ee("ZodString",(e,t)=>{Wk.init(e,t),qE.init(e,t)},{email(e){return this.check($O(uM,e))},url(e){return this.check(MO(fM,e))},jwt(e){return this.check(YO(TM,e))},emoji(e){return this.check(PO(hM,e))},guid(e){return this.check(CO(dM,e))},uuid(e){return this.check(AO(Xd,e))},uuidv4(e){return this.check(IO(Xd,e))},uuidv6(e){return this.check(RO(Xd,e))},uuidv7(e){return this.check(OO(Xd,e))},nanoid(e){return this.check(LO(pM,e))},cuid(e){return this.check(DO(mM,e))},cuid2(e){return this.check(zO(gM,e))},ulid(e){return this.check(FO(kM,e))},base64(e){return this.check(qO(SM,e))},base64url(e){return this.check(GO(_M,e))},xid(e){return this.check(BO(wM,e))},ksuid(e){return this.check(UO(yM,e))},ipv4(e){return this.check(HO(vM,e))},ipv6(e){return this.check(WO(bM,e))},cidrv4(e){return this.check(KO(xM,e))},cidrv6(e){return this.check(ZO(EM,e))},e164(e){return this.check(VO(NM,e))},datetime(e){return this.check(XO(iM,e))},date(e){return this.check(QO(aM,e))},time(e){return this.check(JO(lM,e))},duration(e){return this.check(e2(cM,e))}});function $n(e){return jO(sM,e)}const Jn=Ee("ZodStringFormat",(e,t)=>{Vn.init(e,t),qE.init(e,t)}),iM=Ee("ZodISODateTime",(e,t)=>{OR.init(e,t),Jn.init(e,t)}),aM=Ee("ZodISODate",(e,t)=>{MR.init(e,t),Jn.init(e,t)}),lM=Ee("ZodISOTime",(e,t)=>{PR.init(e,t),Jn.init(e,t)}),cM=Ee("ZodISODuration",(e,t)=>{LR.init(e,t),Jn.init(e,t)}),uM=Ee("ZodEmail",(e,t)=>{vR.init(e,t),Jn.init(e,t)}),dM=Ee("ZodGUID",(e,t)=>{wR.init(e,t),Jn.init(e,t)}),Xd=Ee("ZodUUID",(e,t)=>{yR.init(e,t),Jn.init(e,t)}),fM=Ee("ZodURL",(e,t)=>{NR.init(e,t),Jn.init(e,t)}),hM=Ee("ZodEmoji",(e,t)=>{TR.init(e,t),Jn.init(e,t)}),pM=Ee("ZodNanoID",(e,t)=>{jR.init(e,t),Jn.init(e,t)}),mM=Ee("ZodCUID",(e,t)=>{$R.init(e,t),Jn.init(e,t)}),gM=Ee("ZodCUID2",(e,t)=>{CR.init(e,t),Jn.init(e,t)}),kM=Ee("ZodULID",(e,t)=>{AR.init(e,t),Jn.init(e,t)}),wM=Ee("ZodXID",(e,t)=>{IR.init(e,t),Jn.init(e,t)}),yM=Ee("ZodKSUID",(e,t)=>{RR.init(e,t),Jn.init(e,t)}),vM=Ee("ZodIPv4",(e,t)=>{DR.init(e,t),Jn.init(e,t)}),bM=Ee("ZodIPv6",(e,t)=>{FR.init(e,t),Jn.init(e,t)}),xM=Ee("ZodCIDRv4",(e,t)=>{BR.init(e,t),Jn.init(e,t)}),EM=Ee("ZodCIDRv6",(e,t)=>{HR.init(e,t),Jn.init(e,t)}),SM=Ee("ZodBase64",(e,t)=>{WR.init(e,t),Jn.init(e,t)}),_M=Ee("ZodBase64URL",(e,t)=>{ZR.init(e,t),Jn.init(e,t)}),NM=Ee("ZodE164",(e,t)=>{qR.init(e,t),Jn.init(e,t)}),TM=Ee("ZodJWT",(e,t)=>{VR.init(e,t),Jn.init(e,t)}),GE=Ee("ZodNumber",(e,t)=>{IE.init(e,t),Qn.init(e,t),e._zod.processJSONSchema=(r,o,i)=>_2(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(sb(e,t))},gte(e,t){return this.check(Om(e,t))},min(e,t){return this.check(Om(e,t))},lt(e,t){return this.check(ob(e,t))},lte(e,t){return this.check(Rm(e,t))},max(e,t){return this.check(Rm(e,t))},int(e){return this.check(db(e))},safe(e){return this.check(db(e))},positive(e){return this.check(sb(0,e))},nonnegative(e){return this.check(Om(0,e))},negative(e){return this.check(ob(0,e))},nonpositive(e){return this.check(Rm(0,e))},multipleOf(e,t){return this.check(ib(e,t))},step(e,t){return this.check(ib(e,t))},finite(){return this}});function Is(e){return t2(GE,e)}const jM=Ee("ZodNumberFormat",(e,t)=>{YR.init(e,t),GE.init(e,t)});function db(e){return n2(jM,e)}const $M=Ee("ZodBoolean",(e,t)=>{XR.init(e,t),Qn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>N2(e,n,r)});function Mo(e){return r2($M,e)}const CM=Ee("ZodUnknown",(e,t)=>{QR.init(e,t),Qn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>j2()});function fb(){return o2(CM)}const AM=Ee("ZodNever",(e,t)=>{JR.init(e,t),Qn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>T2(e,n,r)});function IM(e){return s2(AM,e)}const RM=Ee("ZodArray",(e,t)=>{yh(),eO.init(e,t),Qn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>R2(e,n,r,o),e.element=t.element},{min(e,t){return this.check(Of(e,t))},nonempty(e){return this.check(Of(1,e))},max(e,t){return this.check(DE(e,t))},length(e,t){return this.check(zE(e,t))},unwrap(){return this.element}});function ga(e,t){return k2(RM,e,t)}const OM=Ee("ZodObject",(e,t)=>{yh(),rO.init(e,t),Qn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>O2(e,n,r,o),cI(e,"shape",n=>n._zod.def.shape,!1)},{keyof(){return kl(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:fb()})},loose(){return this.clone({...this._zod.def,catchall:fb()})},strict(){return this.clone({...this._zod.def,catchall:IM()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return QA(this,e)},safeExtend(e){return JA(this,e)},merge(e){return eI(this,e)},pick(e){return YA(this,e)},omit(e){return XA(this,e)},partial(...e){return P0(Zk,this,e[0])},exactPartial(...e){return P0(XE,this,e[0],"exactPartial")},required(...e){return tI(QE,this,e[0])}});function Sr(e,t){const n={type:"object",shape:e??{},...ct(t)};return new OM(n)}const VE=Ee("ZodUnion",(e,t)=>{ME.init(e,t),Qn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>M2(e,n,r,o),e.options=t.options});function MM(e,t){return new VE({type:"union",options:e,...ct(t)})}const PM=Ee("ZodDiscriminatedUnion",(e,t)=>{VE.init(e,t),oO.init(e,t)});function LM(e,t,n){return new PM({type:"union",options:t,discriminator:e,...ct(n)})}const DM=Ee("ZodIntersection",(e,t)=>{sO.init(e,t),Qn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>P2(e,n,r,o)});function zM(e,t){return new DM({type:"intersection",left:e,right:t})}const FM=Ee("ZodTuple",(e,t)=>{yh(),iO.init(e,t),Qn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>L2(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 Zk({type:"optional",innerType:n}))})}});function YE(e,t,n){const r=t instanceof Gn,o=r?n:t,i=r?t:null;return new FM({type:"tuple",items:e,rest:i,...ct(o)})}const Sg=Ee("ZodEnum",(e,t)=>{aO.init(e,t),Qn.init(e,t),e._zod.processJSONSchema=(r,o,i)=>$2(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 a of r)if(n.has(a))i[a]=t.entries[a];else throw new Error(`Key ${a} not found in enum`);return new Sg({...t,checks:[],...ct(o),entries:i})},e.exclude=(r,o)=>{const i={...t.entries};for(const a of r)if(n.has(a))delete i[a];else throw new Error(`Key ${a} not found in enum`);return new Sg({...t,checks:[],...ct(o),entries:i})}});function kl(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(r=>[r,r])):e;return new Sg({type:"enum",entries:n,...ct(t)})}const BM=Ee("ZodLiteral",(e,t)=>{lO.init(e,t),Qn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>C2(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 Vr(e,t){return new BM({type:"literal",values:Array.isArray(e)?e:[e],...ct(t)})}const UM=Ee("ZodTransform",(e,t)=>{yh(),cO.init(e,t),Qn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>I2(e,n,r,o),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new yE(e.constructor.name);n.addIssue=i=>{if(typeof i=="string")n.issues.push(tu(i,n.value,t));else{const a=i;a.fatal&&(a.continue=!1),a.code??(a.code="custom"),"input"in a||(a.input=n.value),a.inst??(a.inst=e),n.issues.push(tu(a))}};const o=t.transform(n.value,n);return o instanceof Promise?o.then(i=>(n.value=i,n)):(n.value=o,n)}});function HM(e){return new UM({type:"transform",transform:e})}const Zk=Ee("ZodOptional",(e,t)=>{PE.init(e,t),Qn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>ZE(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function hb(e){return new Zk({type:"optional",innerType:e})}const XE=Ee("ZodExactOptional",(e,t)=>{uO.init(e,t),Qn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>ZE(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function WM(e){return new XE({type:"optional",innerType:e})}const KM=Ee("ZodNullable",(e,t)=>{dO.init(e,t),Qn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>D2(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function pb(e){return new KM({type:"nullable",innerType:e})}const ZM=Ee("ZodDefault",(e,t)=>{fO.init(e,t),Qn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>F2(e,n,r,o),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function qM(e,t){return new ZM({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():gE(t)}})}const GM=Ee("ZodPrefault",(e,t)=>{hO.init(e,t),Qn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>B2(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function VM(e,t){return new GM({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():gE(t)}})}const QE=Ee("ZodNonOptional",(e,t)=>{pO.init(e,t),Qn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>z2(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function YM(e,t){return new QE({type:"nonoptional",innerType:e,...ct(t)})}const XM=Ee("ZodCatch",(e,t)=>{mO.init(e,t),Qn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>U2(e,n,r,o),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function QM(e,t){return new XM({type:"catch",innerType:e,catchValue:typeof t=="function"?t:dI(t)})}const JM=Ee("ZodPipe",(e,t)=>{gO.init(e,t),Qn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>H2(e,n,r,o),e.in=t.in,e.out=t.out});function mb(e,t){return new JM({type:"pipe",in:e,out:t})}const eP=Ee("ZodReadonly",(e,t)=>{kO.init(e,t),Qn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>W2(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function tP(e){return new eP({type:"readonly",innerType:e})}const JE=Ee("ZodCustom",(e,t)=>{wO.init(e,t),Qn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>A2(e,n,r,o)});function nP(e,t={}){return w2(JE,e,t)}function rP(e,t){return y2(e,t)}function oP(e,t={}){const n=new JE({type:"custom",check:"custom",fn:r=>r instanceof e,abort:!0,...ct(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 sP=["off","tailscale","any"],iP={updates:!0,deploy:!0,remote:"any",agents:null,customAgents:!0,brandedListener:!0,planSignIn:!0};Sr({updates:Mo().optional(),deploy:Mo().optional(),remote:kl(sP).optional(),agents:ga($n()).optional(),customAgents:Mo().optional(),brandedListener:Mo().optional(),planSignIn:Mo().optional()});const aP={...iP,source:null,problem:null};function lP(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 Mm=6e3,gb=1500;function cP(e){if(e.length<=Mm)return e;const t=e.length-Mm;return`${e.slice(0,gb)}
|
|
94
|
+
[${t} characters cut here]
|
|
95
|
+
${e.slice(e.length-(Mm-gb))}`}const da=133,uP=2e3,Lf=5e6,dP=["image/png","image/jpeg","image/gif","image/webp"],kb=2576,Pm=5*1024*1024,fP=1200,hP=10,pP=1e5,wb=100*1024*1024,mP="pasted-text.txt";function gP(e){return e.t==="term-data"||e.t==="term-snapshot"||e.t==="term-exit"}function kP(e){return e.t==="file-read"||e.t==="file-written"||e.t==="file-blame"}const wP=80;function qk(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,wP)}}function eS(e){return e.length>=fP||e.split(`
|
|
97
|
+
`).length>=hP}function yP({startLine:e,endLine:t}){return e===t?`${e}`:`${e}-${t}`}function vP(e){return`${e.path.slice(e.path.lastIndexOf("/")+1)} (${yP(e)})`}const bP=/\u001B(?:\[[0-?]*[ -/]*[@-~]|\][^\u0007]*(?:\u0007|\u001B\\))/g;function xP(e){return e.replace(bP,"")}const tS="Projects";function EP(e){for(const t of e){const n=t.codePointAt(0)??0;if(n<32||n===127)return!0}return!1}function nu(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":EP(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 SP=/^(?:https?|ssh|git|file):\/\/\S+$/i,nS=/^[\w.-]+@[\w.-]+:\S+$/;function _P(e){const t=e.trim();if(!SP.test(t)&&!nS.test(t))return null;const n=NP(t);return n&&!nu(n)?{url:t,name:n}:null}function NP(e){var o;const t=((o=e.split(/[?#]/)[0])==null?void 0:o.replace(/\/+$/,""))??"";return((nS.test(t)?t.split(":")[1]??"":t).split("/").pop()??"").replace(/\.git$/i,"")}const TP=Sr({component:$n().nullable(),file:$n().nullable(),line:Is().nullable(),callFile:$n().nullable().default(null),callLine:Is().nullable().default(null),tag:$n(),selector:$n()}),jP=Sr({tag:$n().max(40),id:$n().max(200),classes:ga($n().max(120)).max(16),text:$n().max(200),attrs:ga(YE([$n().max(40),$n().max(200)])).max(12)}),$P=YE([Is(),Is()]),CP=TP.extend({classes:$n(),text:$n(),html:$n(),route:$n(),element:jP}),AP=LM("type",[Sr({type:Vr("loaded"),url:$n(),title:$n()}),Sr({type:Vr("navigated"),url:$n(),title:$n().optional()}),Sr({type:Vr("traversed"),dir:kl(["back","forward"]).optional()}),Sr({type:Vr("title"),title:$n()}),Sr({type:Vr("links"),links:ga(Sr({path:$n().max(2048),text:$n().max(120)})).max(200)}),Sr({type:Vr("hmr")}),Sr({type:Vr("touch"),phase:kl(["start","move","end","cancel"]),x:Is(),y:Is()}),Sr({type:Vr("page-error"),message:$n(),source:$n().optional(),line:Is().optional()}),CP.extend({type:Vr("picked"),verb:kl(["chat","code"]).default("chat"),site:kl(["call","source"]).default("source")}),Sr({type:Vr("pick-cancel")}),Sr({type:Vr("highlight-miss"),path:$n(),fileMatched:Is(),withSource:Is(),ranges:ga($P).nullable()}),Sr({type:Vr("drag-files"),over:Mo().default(!0)}),Sr({type:Vr("drop-files"),files:ga(oP(File))}),Sr({type:Vr("focus"),gesture:Mo()}),Sr({type:Vr("key"),key:$n(),code:$n().optional(),meta:Mo(),ctrl:Mo().optional(),shift:Mo().optional(),alt:Mo().optional(),up:Mo().optional()})]);function rS(e){const t=AP.safeParse(e);return t.success?t.data:null}const IP=["rows","repos","visits","themes"];function RP(e){return IP.map(t=>e[t]??"").join(".")}const OP=/["“”]([^"“”]*)["“”]?|(\S+)/g;function oS(e){const t=new Set;for(const n of e.matchAll(OP)){const r=(n[1]??n[2]??"").replace(/\s+/g," ").trim().toLowerCase();r&&t.add(r)}return[...t]}const MP="now",PP="http://preview.invalid",LP=200;function yb(e){const t=e==null?void 0:e.replace(/\s+/g," ").trim().slice(0,LP).trim();return t||void 0}function vh(e){let t;try{t=new URL(e,PP)}catch{return null}if(t.pathname.startsWith("/__toyon"))return null;const n=vb(t.pathname)||"/",r=t.hash.startsWith("#/")?vb(t.hash.split("?")[0]??""):"";return r.length>1?`${n}${r}`:n}const vb=e=>e.replace(/\/+$/,""),DP={static:4,mixed:3.5,param:3,optional:2,"optional-static":2,splat:1},Df=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");function sS(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 a="",c=0;for(const h of e.matchAll(/\[([^\]=]+)(?:=[^\]]*)?\]|\{\$([\w-]+)\}/g)){const f=e.slice(c,h.index);f&&(i.push({text:f}),a+=Df(f)),i.push({name:h[1]??h[2]??"param"}),a+="[^/]+?",c=(h.index??0)+h[0].length}const u=e.slice(c);if(u&&(i.push({text:u}),a+=Df(u)),i.some(h=>"name"in h))return{kind:"mixed",pattern:a,parts:i}}return{kind:"static",text:e}}function zP(e){const t=e.split("/").filter(Boolean).map(sS);if(t.every(r=>r.kind==="static"))return null;let n="";for(const r of t)r.kind==="static"?n+=`/${Df(r.text)}`:r.kind==="optional-static"?n+=`(?:/${Df(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+DP[o.kind],0),statics:t.filter(r=>r.kind==="static").length}}function FP(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 bh(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(sS))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 Su={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"}},iS={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"}},BP={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"}},UP={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"}},HP={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"}},WP={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"}},KP={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"}},ZP={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"}},qP={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"}},GP={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"}},VP={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"}},YP={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"}},XP={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"}},QP={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"}},JP={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"}},eL={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"}},tL={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"}},nL={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"}},rL={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"}},oL=[qP,GP,VP,YP,XP,QP,JP,eL,tL,nL,rL],wf=[Su,iS,BP,UP,HP,WP,KP,ZP,...oL],sL={mode:"dark",light:iS.id,dark:Su.id},iL=["surface0","surface1","surface2","element0","element1","border0","border1","text0","text1","text2","red","orange","yellow","green","aqua","blue","purple","diffAdd","diffDel"];function aL(e){return`--${e.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`)}`}function _g(e){return aS(ka(e))}function aS(e){return e>.008856?116*e**(1/3)-16:903.3*e}function Gk(e,t){const n=_g(e)+t,r=va(e);if(!r)return e;let o=0,i=2;for(let a=0;a<24;a++){const c=(o+i)/2,u=Ol(Math.min(255,r[0]*c),Math.min(255,r[1]*c),Math.min(255,r[2]*c));_g(u)<n?o=c:i=c}return Ol(Math.min(255,r[0]*o),Math.min(255,r[1]*o),Math.min(255,r[2]*o))}function lL(e){return Gk(e.colors.surface1,-4)}function cL(e){return Gk(e.colors.surface0,-4)}const bb=["surface0","surface1","surface2","element0","element1","border0","border1"];function uL(e){if(e.kind!=="dark")return e;const t=bb.reduce((o,i)=>ka(e.colors[i])<ka(e.colors[o])?i:o),n=e.colors[t];if(ka(n)<=0)return e;const r={...e.colors};for(const o of[...bb,"text1","text2"]){const i=vL(e.colors[o],n)*.05-.05;r[o]=Gk(r[o],aS(i)-_g(r[o]))}return r.surface0="#000000",r.surface1="#000000",{...e,colors:r}}function xb(e){return yL(e,.55)}function dL(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 fL(e){const t={};for(const n of iL)t[aL(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(dL(e)))t[`--syntax-${n}`]=r;return t["--accent"]=Vk(e),t["--fault"]=hL(e),t["--sunken"]=lL(e),t["--sunken-floor"]=cL(e),t["--scrim"]=wL(e.colors.surface0,.7),t["--shadow"]=e.kind==="dark"?"#00000066":"#0000002e",t["--diff-add-word"]=xb(e.colors.diffAdd),t["--diff-del-word"]=xb(e.colors.diffDel),t}function Vk(e){return lS(e.accent??"")??e.colors.orange}function hL(e){return Vk(e)===lS(e.colors.orange)?e.colors.red:e.colors.orange}function pL(e){return e==="system"||e==="daylight"}function Yk(e,t){return e.mode==="system"?t.system?"dark":"light":e.mode==="daylight"?t.daylight?"dark":"light":e.mode}function xh(e,t,n){const r=Yk(e,n);return t.find(o=>o.id===e[r])??wf.find(o=>o.kind===r)??Su}function mL(e,t){if(e.pair){const a=t.find(c=>c.id===e.pair);if(a&&a.kind!==e.kind)return a}const n=e.kind==="dark"?"light":"dark",r=a=>a.toLowerCase().replace(/\b(dark|light)\b/g,"*").replace(/\s+/g," ").trim(),o=r(e.name);if(!o.includes("*"))return null;const i=e.id.startsWith("vscode:")?e.id.slice(0,e.id.lastIndexOf(":")+1):null;return t.find(a=>a.kind===n&&a.source===e.source&&(!i||a.id.startsWith(i))&&r(a.name)===o)??null}function gL(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=mL(o,e),a={name:r(o)};a[o.kind]=o,n.add(o.id),i&&(a[i.kind]=i,n.add(i.id)),t.push(a)}return t}function kL(e,t){const n={...e};return t.dark&&(n.dark=t.dark.id),t.light&&(n.light=t.light.id),!pL(n.mode)&&!t[n.mode]&&(n.mode=t.dark?"dark":"light"),n}function va(e){const t=/^#([0-9a-f]{3,8})$/i.exec(e.trim());if(!t)return null;let n=t[1];if((n.length===3||n.length===4)&&(n=[...n].map(o=>o+o).join("")),n.length!==6&&n.length!==8)return null;const r=o=>parseInt(n.slice(o,o+2),16);return[r(0),r(2),r(4),n.length===8?r(6)/255:1]}function lS(e){const t=va(e);return t?Ol(t[0],t[1],t[2],t[3]):null}function Ol(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 wL(e,t){const n=va(e);return n?Ol(n[0],n[1],n[2],t):e}function yL(e,t){const n=va(e);return n?Ol(n[0],n[1],n[2],Math.min(1,n[3]*t)):e}function uG(e,t){const n=va(e),r=va(t);if(!n||!r)return e;const o=n[3];return Ol(n[0]*o+r[0]*(1-o),n[1]*o+r[1]*(1-o),n[2]*o+r[2]*(1-o))}function ka(e){const t=va(e);if(!t)return 0;const n=r=>{const o=r/255;return o<=.03928?o/12.92:((o+.055)/1.055)**2.4};return .2126*n(t[0])+.7152*n(t[1])+.0722*n(t[2])}function vL(e,t){const n=ka(e),r=ka(t);return(Math.max(n,r)+.05)/(Math.min(n,r)+.05)}function bL(e){return ka(e)>.179?"#1d2021":"#fbf1c7"}function Ng(e){if(e===null||e==="")return"the npm registry";try{return new URL(e).host}catch{return e}}function cS(e,t){const n=Eb(e),r=Eb(t);if(!n||!r)return!1;for(let o=0;o<3;o++){const i=n.nums[o]??0,a=r.nums[o]??0;if(i!==a)return i>a}return n.pre===r.pre?!1:n.pre===null?!0:r.pre===null?!1:n.pre>r.pre}function Eb(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 xL=[[/\.(png|jpe?g|gif|webp|avif|bmp|ico)$/i,"image"]];function EL(e){var t;return((t=xL.find(([n])=>n.test(e)))==null?void 0:t[1])??null}const SL=[[/\.(md|markdown)$/i,"markdown"],[/\.html?$/i,"html"]];function Eh(e){var t;return((t=SL.find(([n])=>n.test(e)))==null?void 0:t[1])??null}const Ke={active:"toyon-active",phoneRow:"toyon-phone-row",repo:"toyon-repo",lastActive:"toyon-last",discoveredOpen:"toyon-disc",archivedOpen:"toyon-arch",committedShut:"toyon-committed-shut",turnOpen:"toyon-turn-open",treeOpen:"toyon-tree",token:"toyon-token",theme:"toyon-theme",daylight:"toyon-sun",changesWidth:"toyon-changes-w",chatWidth:"toyon-chat-w",editorHeight:"toyon-dh",editorFull:"toyon-dfull",editorWrap:"toyon-dwrap",designHeight:"toyon-dsh",designFull:"toyon-dsfull",termHeight:"toyon-th",rail:"toyon-rail",railWidth:"toyon-rail-w",chatSide:"toyon-chat-side",clipboardOffer:"toyon-clipboard-offer",blackGround:"toyon-black",installOffered:"toyon-install-offered",layouts:"toyon-layouts",client:"toyon-client",ground:"toyon-ground",profilePrefix:"toyon-profile-",modePrefix:"toyon-mode-",modelPrefix:"toyon-model-",effortPrefix:"toyon-effort-",version:"toyon-version"},_L=[Ke.active,Ke.repo,Ke.lastActive,Ke.discoveredOpen,Ke.archivedOpen,Ke.committedShut,Ke.turnOpen,Ke.treeOpen,Ke.profilePrefix,Ke.modePrefix,Ke.modelPrefix,Ke.effortPrefix,Ke.phoneRow,Ke.version],NL=[Ke.profilePrefix,Ke.modePrefix,Ke.modelPrefix,Ke.effortPrefix],yf=(e,t)=>`${e}@${t}`,TL="toyon",Ac="snapshots",co={hello:e=>`hello@${e}`,chat:(e,t)=>`chat@${e}/${t}`,chats:e=>`chat@${e}/`};function jL(e,t=typeof localStorage>"u"?null:localStorage,n=typeof sessionStorage>"u"?null:sessionStorage){const r=a=>({get(c){try{return(a==null?void 0:a.getItem(yf(c,e)))??null}catch{return null}},set(c,u){try{a==null||a.setItem(yf(c,e),u)}catch{}},remove(c){try{a==null||a.removeItem(yf(c,e))}catch{}}}),o=r(t),i=r(n);return{...o,session:{get:i.get,set:i.set},clear(){for(const a of[t,n])for(const c of uS(a).filter(u=>u.endsWith(`@${e}`)))try{a==null||a.removeItem(c)}catch{}}}}function uS(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 $L="orch-";function CL(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 a=Ke[i],c=$L+a.slice(6);Sb(r,c,a)}for(const[r,o]of[[t,_L.filter(i=>i!==Ke.phoneRow)],[n,[Ke.phoneRow]]]){const i=uS(r).filter(a=>!a.includes("@"));for(const a of o){const c=NL.includes(a)?i.filter(u=>u.startsWith(a)):i.filter(u=>u===a);for(const u of c)Sb(r,u,yf(u,e))}}}function Sb(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 dS(){const e=location.hash.match(/token=([a-f0-9]+)/);if(e!=null&&e[1])return fS(e[1]),e[1];try{return localStorage.getItem(Ke.token)??sessionStorage.getItem(Ke.token)??""}catch{return""}}function fS(e){try{localStorage.setItem(Ke.token,e)}catch{}}function zf(){return dS()!==""}function Xk(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,a)=>`${n.origin}/attachments/${i}/${a}?${r}`,attachmentWhere:(i,a)=>`${n.origin}/attachments/${i}/${a}?${r}&where`,upload:i=>`${n.origin}/uploads/${i}?${r}`,worktreeFile:(i,a,c)=>`${n.origin}/files/${i}/${a.split("/").map(encodeURIComponent).join("/")}?${r}${o(c)}`,loose:(i,a)=>`${n.origin}/loose/${encodeURIComponent(i)}?${r}${o(a)}`,health:`${n.origin}/health`,restart:i=>`${n.origin}/restart?${r}${i?`&${MP}`:""}`,uploads:i=>`${n.origin}/uploads?kind=${i}`,tailnet:`${n.origin}/tailnet`,remote:`${n.origin}/remote`,tailscale:`${n.origin}/tailscale`,machines:`${n.origin}/machines`,knockAnswer:i=>`${n.origin}/knock/${i}/answer`,previewGrant:`${n.origin}/preview-grant`,changelog:`${n.origin}/changelog`}}const Wl=e=>({authorization:`Bearer ${e.token}`});async function AL(e,t,n,r){try{await n.slice(0,1).arrayBuffer()}catch{return"could not be read"}return new Promise(o=>{const i=new XMLHttpRequest;i.open("POST",e.uploads(t)),i.setRequestHeader("authorization",Wl(e).authorization),i.setRequestHeader("content-type",n.type||"application/octet-stream"),r&&(i.upload.onprogress=a=>a.lengthComputable&&r(a.loaded/a.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 IL(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 hS(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 RL(e){var t;try{const n=await fetch(e.changelog,{headers:Wl(e)});return!n.ok||!((t=n.headers.get("content-type"))!=null&&t.startsWith("text/markdown"))?null:await n.text()}catch{return null}}async function OL(e,t){try{const n=await fetch(t,{headers:Wl(e)});return n.ok?await n.json():null}catch{return null}}async function Sh(e,t,n,r){try{const o=await fetch(t,{method:"POST",headers:{...Wl(e),"content-type":"application/json"},body:JSON.stringify(n)});return o.ok?null:await o.text()||`refused (${o.status})`}catch{return r}}const ML=e=>OL(e,e.tailnet),PL=e=>Sh(e,e.remote,{tailscale:!0},"Toyon is not answering; try again once it is back."),LL=e=>Sh(e,e.remote,{off:!0},"Toyon is not answering; try again once it is back.");async function pS(e,t,n){try{const r=await fetch(t,{method:"POST",headers:{...Wl(e),"content-type":"application/json"},body:JSON.stringify(n)});return r.ok?await r.json():null}catch{return null}}const mS="Toyon is not answering; try again once it is back.",DL=async e=>{const t=await pS(e,e.tailscale,{up:!0});return t===null?mS:t.refused},zL=async e=>await pS(e,e.tailscale,{login:!0})??{why:mS},FL=(e,t,n)=>Sh(e,e.machines,{origin:t,token:n},"Toyon here is not answering; the machine is not listed yet."),BL=(e,t,n)=>Sh(e,e.knockAnswer(t),{letIn:n},"Toyon is not answering");async function gS(e){try{const t=await fetch(e.previewGrant,{method:"POST",headers:Wl(e)});return t.ok?await t.json():null}catch{return null}}const UL=2e3;async function kS(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,UL))}return"gone"}async function Tg(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 HL=1e3,WL=3e4,KL=1500,ZL=5e3,_b=50,qL=e=>e.t==="chat"||e.t==="create-worktree"||e.t==="restore-worktree";class GL{constructor(t,n,r,o={},i={}){Et(this,"ws",null);Et(this,"queue",[]);Et(this,"closed",!1);Et(this,"attempt",0);Et(this,"timer",null);Et(this,"downAt",null);Et(this,"downCode",0);Et(this,"sayTimer",null);Et(this,"sentDown",new Set);Et(this,"drops",0);Et(this,"urls");Et(this,"suspended",!1);Et(this,"connectDeadline");Et(this,"settle");Et(this,"backoffMin");Et(this,"wake",()=>{var n;if(this.closed||this.suspended||document.visibilityState!=="visible"||((n=this.ws)==null?void 0:n.readyState)===WebSocket.OPEN)return;this.timer&&clearTimeout(this.timer),this.timer=null,this.attempt=0,this.drops=0,this.downAt!==null&&(this.downAt=Date.now(),this.onStatus(!1,null),this.armSay());const t=this.ws;this.connect(),t==null||t.close()});this.onMsg=n,this.onStatus=r,this.hooks=i,this.connectDeadline=o.connectDeadline??ZL,this.settle=o.settle??KL,this.backoffMin=o.backoffMin??HL,this.urls=Xk(t.origin,t.token),this.suspended=i.held??!1,this.connect(),document.addEventListener("visibilitychange",this.wake),window.addEventListener("online",this.wake)}suspend(){if(this.suspended||this.closed)return;this.suspended=!0,this.timer&&clearTimeout(this.timer),this.timer=null;const t=this.ws;this.ws=null,t==null||t.close(),this.onStatus(!1,null)}resume(){!this.suspended||this.closed||(this.suspended=!1,this.attempt=0,this.connect())}async diagnose(t){if(t===$A)return"unauthorized";if(this.drops<2)return null;try{return(await fetch(this.urls.health,{signal:AbortSignal.timeout(2e3)})).ok?"blocked":"down"}catch{return"down"}}say(t){this.downAt??(this.downAt=Date.now()),this.downCode=t,this.armSay()}armSay(){if(this.downAt===null)return;const t=this.downAt,n=()=>!this.closed&&this.downAt===t&&document.visibilityState==="visible";this.sayTimer&&clearTimeout(this.sayTimer),this.sayTimer=setTimeout(()=>{n()&&this.diagnose(this.downCode).then(r=>{n()&&this.onStatus(!1,r)})},Math.max(0,t+this.settle-Date.now()))}connect(){var i,a;if(this.closed||this.suspended)return;const t=((a=(i=this.hooks).known)==null?void 0:a.call(i))??null,n=new WebSocket(t===null?this.urls.ws:`${this.urls.ws}&known=${t}`);this.ws=n;let r=!1;const o=setTimeout(()=>{n.readyState===WebSocket.CONNECTING&&n.close()},this.connectDeadline);n.onmessage=c=>{if(!r){r=!0,clearTimeout(o),this.attempt=0,this.drops=0,this.downAt=null,this.sayTimer&&clearTimeout(this.sayTimer),this.sayTimer=null,this.onStatus(!0);for(const u of this.queue)n.send(u.raw);this.queue=[]}try{this.onMsg(JSON.parse(c.data))}catch{}},n.onclose=c=>{if(clearTimeout(o),this.ws!==n||(this.onStatus(!1),this.closed||this.suspended))return;this.drops++,this.say(c.code);const u=Math.min(WL,this.backoffMin*2**this.attempt++);this.timer=setTimeout(()=>this.connect(),u/2+Math.random()*(u/2))},n.onerror=()=>n.close()}send(t){const n=JSON.stringify(t);if(this.ws&&this.ws.readyState===WebSocket.OPEN){this.ws.send(n);return}if(t.t.startsWith("term-"))return;const r=t.t==="subscribe"||t.t==="unsubscribe"?`sub:${t.worktreeId}`:t.t==="view"?"view":null;r&&(this.queue=this.queue.filter(o=>o.key!==r)),qL(t)&&t.boxId&&this.sentDown.add(t.boxId),this.queue.push({key:r,raw:n}),this.queue.length>_b&&this.queue.splice(0,this.queue.length-_b)}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 Qk(e){return e==="cancelled"||e==="expired"}function wS(e){const t=e.findLast(n=>n.kind==="ask"||_u(n));return(t==null?void 0:t.kind)!=="ask"||t.ask.kind!=="question"?null:Qk(t.outcome)?t:null}function VL(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 YL(e){return e.map(()=>({selected:[]}))}function Nb(e,t,n,r){return e.map((o,i)=>{if(i!==t)return o;const a=o.selected.includes(n);return r?{...o,selected:a?o.selected.filter(c=>c!==n):[...o.selected,n]}:{...o,selected:[n]}})}function Ff(e,t,n){return e.map((r,o)=>{if(o!==t)return r;const{note:i,...a}=r;return n===void 0?a:{...a,note:n}})}function Tb(e,t,n,r){return e.map((o,i)=>i!==t?o:{selected:n&&!r?[]:o.selected,note:o.note??""})}function vf(e,t){const n=e[t];return n&&n.note!==void 0&&!n.note.trim()?Ff(e,t,void 0):e}function XL(e){return e?e.options.length+(e.note?1:0):0}function QL(e,t){return!!(e!=null&&e.note)&&t===e.options.length}function yS(e,t){return!!e&&e.note!==void 0&&(t||e.selected.length===0)}function Nl(e){var t;return!!e&&(e.selected.length>0||!!((t=e.note)!=null&&t.trim()))}function Qd(e,t){return e.every((n,r)=>!n.required||Nl(t[r]))}function JL(e,t){var o;const n=((t==null?void 0:t.selected)??[]).map(i=>{var a;return ew(((a=e.options.find(c=>c.value===i))==null?void 0:a.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 e4(e,t){var o;const n=((t==null?void 0:t.selected)??[]).map(i=>{var a;return ew(((a=e.options.find(c=>c.value===i))==null?void 0:a.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 Jk(e,t){return e.map((n,r)=>{const o=JL(n,t==null?void 0:t[r]);return e.length>1&&n.header?`${n.header} · ${o}`:o})}function t4(e,t){return((t==null?void 0:t.selected)??[]).map(n=>{var r,o;return((o=(r=e.options.find(i=>i.value===n))==null?void 0:r.description)==null?void 0:o.trim())??""}).filter(Boolean)}function n4(e){return e.outcome!=="answered"||e.ask.kind!=="question"?null:{message:e.ask.message,questions:e.ask.questions,answers:e.answers}}function r4(e){if(e.outcome!=="answered")return null;const t=(e.answers??[]).map(n=>{var r;return((r=n.note)==null?void 0:r.trim())??""}).filter(Boolean);return t.length>0?t.join(`
|
|
98
|
+
`):null}function o4(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 wl(e,t){if(!e)return 0;if(yS(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 s4(e,t,n){return Math.max(0,Math.min(n-1,e+t))}function i4(e,t,n){const r=e.length;for(let o=1;o<=r;o++){const i=(n+o)%r;if(!Nl(t[i]))return i}return-1}function yl(e){return e.length>1?e.length:-1}function a4(e){return e.length+(yl(e)===-1?0:1)}function jb(e,t,n){const r=i4(e,t,n);if(r!==-1)return{current:r,cursor:wl(e[r],t[r]),send:!1};const o=yl(e);return o!==-1?{current:o,cursor:0,send:!1}:{current:n,cursor:wl(e[n],t[n]),send:!0}}const vS=/\s*\(recommended\)\s*$/i;function l4(e){return vS.test(e)}function ew(e){return e.replace(vS,"")}const c4={skipped:"you skipped this",cancelled:"the turn was stopped before you answered",expired:"Toyon restarted before you answered"};function u4(e,t){const n=t??0;return n===0?null:`${n} behind ${e}`}function _h(e){const t=new Date(e);return`${String(t.getHours()).padStart(2,"0")}:${String(t.getMinutes()).padStart(2,"0")}`}function bS(e,t){if(t.fetchFailed)return`could not reach origin${t.fetchedAt?` since ${_h(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 d4(e){return e.stale!=="diverged"}function xS(e,t,n,r){return n!==null&&r===n.host?`${jA(n.previews,e,t)}/`:r.endsWith(".localhost")?`http://w${e}.${r}:${t}/`:Pk(r)?`http://${r==="localhost"?"127.0.0.1":r}:${t}/`:`https://${r}:${t}/`}function $b(e){return e.ranges.map(([t,n])=>[t+e.offset,n+e.offset])}function ES(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 f4(e){var r;const t=(r=e.source)==null?void 0:r.replace(/[?#].*$/,""),n=t?` (${ES(t)}:${e.line??"?"})`:"";return`${e.message}${n}`.slice(0,uP)}function Jd(e,t){return!Number.isFinite(e)||e<=0?t:Math.min(Math.max(e,170),Math.floor(window.innerWidth*.5))}function ks(e){var t,n,r;return e.agent==="waiting"?"waiting":e.agent==="working"&&e.stopping?"stopping":e.agent==="working"?"working":e.agent==="error"||((n=(t=e.worktree)==null?void 0:t.lastTurn)==null?void 0:n.end)==="failed"?"failed":e.background?"background":(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 h4={waiting:"Waiting for you",stopping:"Agent stopping",working:"Agent working",background:"Running in the background",failed:"Agent failed",landed:"Landed",crashed:"Crashed",running:"Running",starting:"Starting",asleep:"Asleep",idle:"Idle"};function Nh(e,t=!1){const n=ks(e);return n==="idle"&&t?"Not set up":n==="background"&&e.wakes?`Wakes ${_h(e.wakes)}`:h4[n]}const p4={starting:"Starting",running:"Running",unreachable:"Not answering",crashed:"Crashed",stopped:"Stopped",asleep:"Asleep"};function m4(e){return p4[e]}const g4=new Set(["idle","asleep","running","starting","background","landed"]);function SS(e,t){return t&&g4.has(ks(e))?t:null}const k4={land:"Landing",commit:"Committing","sync-main":"Syncing with main","pull-main":"Pulling"};function tw(e){return k4[e]}function _S(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 nw(e){const t=e.lastIndexOf("/");return t<0?{name:e,dir:""}:{name:e.slice(t+1),dir:e.slice(0,t)}}const NS=new Intl.Collator(void 0,{numeric:!0,sensitivity:"base"}).compare;function Bf(e){const t=[];for(let n=e.indexOf("/");n!==-1;n=e.indexOf("/",n+1))t.push(e.slice(0,n));return t}function TS(e){const t=new Set;for(const n of e)for(const r of Bf(n))t.add(r);return[...t].sort(NS)}function rw(e){return e.includes("A")||e==="??"?"added":e.includes("D")?"deleted":""}function ow(e){if(e==="??")return"A";if(e==="UU"||e==="AA"||e==="DD"||e.includes("U"))return"C";const t=e.trim()[0]??"";return t==="T"?"M":t||"·"}const w4=/Firefox\//.test(navigator.userAgent);function sw(){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 y4=/Chrome\//.test(navigator.userAgent)&&sw(),zt=e=>pA(e,{firefox:w4,pwa:y4});function iw(e){return e.component?`<${e.component} />`:`<${e.tag}>`}function jg(e,t){return e.worktree&&Nr(e.worktree)&&t?t.defaultBranch:e.name}function aw(e){const t=Math.max(0,e/1e3),n=(a,c)=>`${a} ${c}${a===1?"":"s"}`;if(t<60)return"a moment";const r=t/60;if(r<60)return n(Math.floor(r),"minute");const o=r/60;if(o<24)return n(Math.floor(o),"hour");const 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 sr(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 fa(e){const t=Math.max(0,Math.floor(e));return t<100?`${t}s`:`${Math.floor(t/60)}m ${t%60}s`}function v4(e,t,n,r){var a;if(!t)return null;const o=e.filter(Nn).filter(c=>c.repoId===t&&(c.worktree.agent??r)===n);return((a=o.find(c=>Nr(c.worktree))??o[0])==null?void 0:a.id)??null}const b4=200;function x4(e,t){const n=new Map(e.map(r=>[r.path,r]));for(const r of t){if(n.size>=b4)break;const o=vh(r.path);o&&!n.has(o)&&n.set(o,{path:o,text:r.text})}return n.size===e.length?e:[...n.values()]}function jS(e){return e!==void 0&&!e.routes.some(t=>!t.endpoint)}const Ti=e=>"uploading"in e&&e.uploading===!0;function Tl(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 lw=e=>e.filter(t=>!Ti(t)).map(Tl);let E4=0;function $g(e,t){const n=new Map(t.filter(o=>!Ti(o)).map(o=>[JSON.stringify(Tl(o)),o]));return[...e.map(o=>{const i=JSON.stringify(o),a=n.get(i);if(a)return n.delete(i),a;const c=`d${++E4}`;return o.kind==="paste"?{...o,key:c,...qk(o.text)}:{...o,key:c}}),...t.filter(Ti)]}const Cg="out:",S4=(e,t,n)=>`${Cg}${e}:${t}:${n}`;function ms(e){if(!e.startsWith(Cg))return null;const t=e.slice(Cg.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 Fc(e,t,n,r){const o=r.length?lw(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 _4(e,t){const n=new Set,r=[];for(const o of e){if(n.has(o.log))continue;const i=t[o.id];if(!i||i.attachments.some(Ti)){n.add(o.log);continue}r.push(o.id)}return r}const $S=e=>e.flatMap(t=>"upload"in t&&t.upload?[t.upload]:[]);function N4(e){const t=n=>$S(n.items).some(r=>!n.before.includes(r));return[...e.filter(t),...e.filter(n=>!t(n))]}function T4(e,t){const n=new Map(t.rows.map(a=>[a.id,a])),r=new Map(e.map(a=>[a.id,a])),o=[];let i=!0;for(const a of t.ids){const c=n.get(a)??r.get(a);c?o.push(c):i=!1}return{rows:o,complete:i}}const cl=300,j4=20;function $4(e,t){return e.rows.length===0&&e.repos.length===0?null:{protocol:da,at:t,version:e.version,machine:e.machine??"",install:e.install,registry:e.registry,repos:e.repos,rows:e.rows,trunks:e.trunks,themePrefs:e.themePrefs,agents:e.agents,defaultAgent:e.defaultAgent,agentChosen:e.agentChosen,home:e.home,folderDialog:e.folderDialog,keepAwake:e.keepAwake,remote:e.remote,tailscale:e.tailscale,machines:e.handed,gitIdentity:e.gitIdentity,visits:e.visits,managed:e.managed}}const Cb=e=>(e==null?void 0:e.protocol)===da,C4={rows:"",repos:"",visits:"",themes:""};function A4(e){const{at:t,...n}=e;return{t:"hello",...n,rows:e.rows.map(I4),trunks:Object.fromEntries(Object.entries(e.trunks).map(([r,o])=>[r,R4(o)])),stamps:C4,themes:[],drafts:{},attachments:{},knocks:[],letIn:!1,self:null,update:null,pending:[]}}function I4(e){const{stopping:t,shipping:n,queued:r,syncQueued:o,...i}=e;return{...i,agent:e.agent==="working"?"idle":e.agent,procs:[],login:!1}}function R4(e){const{shipping:t,...n}=e;return n}function O4(e){let t=null;for(const{event:n}of e){const r=n.ts;typeof r=="number"&&(t===null||r>t)&&(t=r)}return t}function ef(e,t){return e.length>t?e.slice(e.length-t):[...e]}function M4(e,t,n=j4){const r=new Set(t.map(a=>a.id)),o=Object.keys(e).filter(a=>!r.has(a)),i=Object.entries(e).filter(([a])=>r.has(a)).sort((a,c)=>c[1].at-a[1].at);return[...o,...i.slice(n).map(([a])=>a)]}class P4{constructor(){Et(this,"events",[]);Et(this,"seq",-1);Et(this,"whole",!1)}reset(t,n,r){this.events=ef(Zd(t),cl),this.seq=n,this.whole=r}extend(t,n){this.events.push(...t),n>this.seq&&(this.seq=n),this.events.length>cl*2&&(this.events=ef(Zd(this.events),cl))}since(){return this.whole&&this.seq>=0?this.seq:void 0}add(t,n){this.events.push({seq:t,event:n}),t>this.seq&&(this.seq=t),this.events.length>cl*2&&(this.events=ef(Zd(this.events),cl))}snapshot(t,n){return this.events=ef(Zd(this.events),cl),{protocol:da,at:n,events:[...this.events],seq:this.seq,...t?{draft:t}:{}}}}function _u(e){return e.kind==="user"||e.kind==="handed"}function CS(e){return e.map(t=>_u(t)?t.attachments:void 0)}const bf=["files","changes","history"],L4=e=>bf.includes(e),Kl=e=>(e==null?void 0:e.worktree.id)??null,Ml="new-project",Sa=Object.freeze({chat:[],log:[],queue:[],page:{},turn:{edits:!1,hmr:!1},changedRanges:{},commitFiles:{},search:null,design:null,draft:"",attachments:[],commands:[],termStream:Po}),cw=e=>({...e,phase:"editing",repoId:null}),AS=()=>cw({mode:"create",name:"",parent:`~/${tS}`}),D4=Object.freeze({changes:!1,changesTab:"files",chat:!0,term:!1,design:!1});function z4(e){if(!e||typeof e!="object")return!1;const t=e;return typeof t.changes=="boolean"&&L4(t.changesTab)&&typeof t.chat=="boolean"&&typeof t.term=="boolean"&&typeof t.design=="boolean"}function ao(e,t){const n=e.layout;let r=!1;for(const o of Object.keys(t))t[o]!==n[o]&&(r=!0);return r?{...e,layout:{...n,...t}}:e}function uw(e,t){return{...e,layout:t,changesAuto:!1}}const ji=e=>Eh(e)?"preview":"file",F4=(e,t)=>e===t||!!e&&!!t&&e.at===t.at&&(e.at!=="tree"||t.at!=="tree"||e.worktreeId===t.worktreeId&&e.dir===t.dir)&&(e.at!=="rail"||t.at!=="rail"||e.worktreeId===t.worktreeId),Ic=(e,t)=>e.worktreeId===t.worktreeId&&e.path===t.path&&e.ref===t.ref&&e.since===t.since;function IS(e,t,n,r){var i;if(!r.fiber)return r;const o=(i=Xr(e,t).changedRanges[n])==null?void 0:i.offset;return o===void 0?r:{n:r.n-o}}function B4(e){const t=e.cached??Su,n={connected:!1,connectFailure:null,repos:[],rows:[],activeRepoId:null,visible:[],lent:null,archiving:[],shipping:{},visibleDiscovered:[],discoveredOpen:e.storedDiscoveredOpen??{},archivedOpen:e.storedArchivedOpen??{},committedShut:e.storedCommittedShut??{},turnOpen:e.storedTurnOpen??{},treeOpen:e.storedTreeOpen??{},treeReveal:null,refs:{},chats:{},archived:{},archivedPage:null,lastActive:e.storedLastActive??{},pendingOpen:!1,activeId:null,carryTo:null,clientId:e.clientId,storedActive:e.storedActive??null,storedRepo:e.storedRepo??null,heard:!1,heardAt:null,recalledAt:null,stamps:null,local:{},editor:null,openUrl:null,reloadReq:null,dragFiles:null,sharing:null,picking:!1,overlay:null,paletteReturn:null,incompatible:!1,layout:D4,focusChanges:0,editCommit:0,focusChat:0,walked:0,railOpen:e.storedRailOpen??!1,chatSide:e.storedChatSide??"left",blackGround:e.storedBlackGround??!1,focusRail:0,railPeek:!1,unreadHold:null,layouts:e.storedLayouts??{},screen:e.storedActive&&e.storedPhoneRow?"chat":"home",left:null,frame:e.frame??"desk",touch:e.touch??!1,reading:!1,typing:!1,changesAuto:!0,zen:!1,focusTerm:0,termRun:null,termTall:0,previewSize:null,themes:wf.some(o=>o.id===t.id)?wf:[...wf,t],themePrefs:{...sL,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:aP,letIn:!1,knocks:[],tailscale:null,handed:[],gitIdentity:!0,self:null,rebuilt:!1,update:null,updateCheck:null,version:"",install:"none",registry:null,ranBefore:e.storedVersion??null,notesPage:!1,notesSeen:!1,choosingFolder:!1,newProject:null,autoSend:null,outbox:[],chosenFolder:null,pending:[],activeImportId:null,agents:[],defaultAgent:"claude",agentChosen:!1,agentConfigs:{},draft:null,trunks:{},visits:{}},r=e.storedRepo?n.layouts[e.storedRepo]:void 0;return r?uw(n,r):n}function RS(e){var t;return{system:e.systemDark,daylight:((t=e.daylight)==null?void 0:t.dark)??e.systemDark}}function U4(e){return e.previewTheme??xh(e.themePrefs,e.themes,RS(e))}function Xr(e,t){return t&&e.local[t]||Sa}function dw(e,t){const n=Xr(e,t);return n.draft.trim()!==""||n.attachments.length>0}function No(e,t){return t&&e.rows.find(n=>n.id===t)||null}function OS(e,t){const n=No(e,t);return n?zo(n.agent)||!!e.shipping[n.id]||(n.queued??0)>0:!1}function nn(e,t){const n=No(e,t);return n&&Nn(n)?n:null}function MS(e){var o;const t=nn(e,e.activeId);if(!t||!ya(t.worktree)||t.agent!=="idle"||!((o=Pl(e,t.repoId))!=null&&o.empty))return!1;const n=Ii(e,t.repoId),r=e.rows.some(i=>{var a;return i.repoId===t.repoId&&((a=i.worktree)==null?void 0:a.kind)==="worktree"});return!!(n!=null&&n.needsSetup)&&!r&&Xr(e,t.id).chat.length===0}function Th(e){return e.newProject!==null||MS(e)}function H4(e){return e.incompatible||Th(e)}function W4(e){return(!e.needsSetup||!!e.assumed)&&Object.keys(e.config.run).length===0}function Uf(e){return!!(e!=null&&e.needsSetup)&&!e.assumed}function fw(e){const t=e.archivedPage?null:No(e,e.activeId);return(t==null?void 0:t.repoId)??e.activeRepoId}function rs(e){const t=Ii(e,fw(e));return!!t&&W4(t)}function PS(e){return e.layout.chat&&!rs(e)&&!e.archivedPage&&!pw(e)?{a:"toggle-chat"}:{a:"focus-chat"}}function LS(e,t){var n;return!e.activeRepoId||!((n=e.archived[e.activeRepoId])!=null&&n.some(r=>r.id===t))?e:{...e,archivedPage:t,notesPage:!1,editor:null,screen:"chat"}}function Jo(e){return rs(e)?e:ao(e,{chat:!0})}function Ii(e,t){return t&&e.repos.find(n=>n.id===t)||null}function DS(e,t){if(!t)return null;const n=e.rows.filter(Nn).filter(r=>r.repoId===t);return n.find(r=>Eu(r.worktree))??n.find(r=>ya(r.worktree))??null}function Pl(e,t){return t&&e.trunks[t]||null}function vl(e){return rs(e)||e.archivedPage||e.notesPage?null:e.activeId}function jh(e){return e.procs.some(t=>t.status==="running"||t.status==="starting")}function Hf(e){if(e.archivedPage||e.notesPage)return null;const t=nn(e,e.activeId);return t&&jh(t)?{worktreeId:t.worktree.id,repoId:t.repoId}:null}function Ag(e){const t=vl(e),n=nn(e,t);return n?{id:n.worktree.id,act:jh(n)?"frame":"start"}:null}function hw(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&&Nn(o)&&o.repoId===t?o:null}function zS(e,t){return e.repoId!==t&&(e.agent==="waiting"||!!e.unseen)}function $h(e,t,n,r){return e.repoId===t||hw(e,t,n)!==null||zS(e,t)||e.id===r}function FS(e,t,n){return!e||!t||!Nn(e)||e.repoId===t||hw(e,t,n)?null:zS(e,t)?e.id:null}function BS(e,t){return t.length?e.filter(n=>!t.includes(n.id)):e}function K4(e,t,n,r){const o=BS(e,n).filter(Nn);return QC(t?o.filter(i=>$h(i,t,o,r)):o)}function Z4(e,t){const n=e.filter(r=>!Nn(r));return t?n.filter(r=>r.repoId===t):n}function Ll(e,t,n=e.rows){var c;const r=n.filter(Nn),o=e.archiving.length?r.filter(u=>!e.archiving.includes(u.id)):r,i=t?e.lastActive[t]:void 0;if(i&&o.some(u=>u.id===i))return i;const a=t?o.filter(u=>u.repoId===t):o;return((c=a.find(u=>Eu(u.worktree))??a.find(u=>ya(u.worktree))??a[0])==null?void 0:c.id)??null}function Ab(e,t){const n=Object.entries(e),r=n.filter(([o])=>!t(o));return r.length===n.length?e:Object.fromEntries(r)}function US(e,t,n){const r={};for(const a of t)a.shipping&&(r[a.id]=a.shipping);for(const a of Object.values(n))a.shipping&&(r[a.id]=a.shipping);for(const[a,c]of Object.entries(e))!c.sent||r[a]||(t.some(u=>u.id===a)||XS({trunks:n},a))&&(r[a]=c);const o=Object.keys(r);return o.length===Object.keys(e).length&&o.every(a=>q4(e[a],r[a]))?e:r}const q4=(e,t)=>!!e&&!!t&&e.op===t.op&&e.step===t.step&&e.sent===t.sent;function bl(e,t){var m;const n=No(e,t),r=!!n&&Nn(n)&&!!e.activeRepoId&&$h(n,e.activeRepoId,e.rows,e.lent),o=r&&e.lent!==t?FS(n,e.activeRepoId,e.rows):r?e.lent:null,i=r?e.activeRepoId:(n==null?void 0:n.repoId)??e.activeRepoId,a=n&&Nn(n)?{...e.lastActive,[n.repoId]:n.id}:e.lastActive,c=e.activeId!==t?e.activeId:null,u=c?e.local[c]:void 0,h=u&&((m=u.mark)==null?void 0:m.by)==="reveal"?xl(u,"reveal"):null,f=c&&h?{...e.local,[c]:h}:e.local;return{...e,activeId:t,activeRepoId:i,lent:o,lastActive:a,editor:null,archivedPage:null,notesPage:!1,local:f}}function Dl(e){return Fo(e)?"history":e.layout.changesTab}function G4(e,t){const n=Dl(e);if(Fo(e))return n;const r=bf.length;return bf[(bf.indexOf(n)+t+r)%r]??"changes"}function pw(e){if(e.archivedPage)return null;const t=No(e,e.activeId);return t&&!Nn(t)?t:null}function V4(e){return e.notesSeen||e.ranBefore===null||!cS(e.version,e.ranBefore)?null:e.version}const Y4=1500;function HS(e,t){return e.left&&t-e.left.at<Y4?e.left.face:null}function X4(e,t){var n,r;return{id:e.id,repoId:e.repoId,title:e.worktree.title,branch:e.worktree.branch,path:e.path,createdAt:e.worktree.createdAt,archivedAt:t,restorable:!0,transcript:e.transcript??"",...e.sessionId?{sessionId:e.sessionId}:{},...e.dirty?{uncommitted:!0,dirty:e.dirty}:{},...e.worktree.landed?{landed:!0}:{},...(n=e.worktree.lands)!=null&&n.length?{lands:e.worktree.lands}:{},...((r=e.usage)==null?void 0:r.cost)!==void 0?{cost:e.usage.cost}:{}}}function Q4(e,t){let n=e;for(const[r,o]of Object.entries(e))o.some(i=>t.includes(i.id))&&(n={...n,[r]:o.filter(i=>!t.includes(i.id))});return n}function Fo(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 xl(e,t){var o;if(((o=e.mark)==null?void 0:o.by)!==t)return e;const{mark:n,...r}=e;return r}const WS=e=>e.kind==="theme"||e.kind==="appearance"||e.kind==="keep-awake"||e.kind==="agent"||e.kind==="agent-page"||e.kind==="choose-folder"||e.kind==="split";let J4=0;function ru(e){if(!e.sending)return e;const{sending:t,...n}=e;return n}function eD(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]=ru(r[o]);return{...e,local:r}}function tD(e,t,n,r){var a;let o=e;const i=n?(a=o[n])==null?void 0:a.sending:void 0;if(i&&n&&r&&r!==n){const c=o[r]??Sa,u=c.chat.some(h=>h.kind==="user")?{at:i.at}:i;o={...o,[n]:ru(o[n]),[r]:{...c,sending:u}}}for(const c of t){const u=o[c.id];u!=null&&u.sending&&!u.sending.message&&zo(c.agent)&&(o={...o,[c.id]:ru(u)})}return o}function kt(e,t,n){return{...e,local:{...e.local,[t]:n(e.local[t]??Sa)}}}function Ib(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 nD(e,t){const n=t.type==="agent-question"||t.type==="agent-permission"||t.type==="pieces-proposed"&&!t.held||t.type==="pieces-shown",r=t.type==="agent-ask-end"||t.type==="pieces-go"||t.type==="pieces-declined"?t.id:null;if(!n&&!r)return e;const o=t.type==="agent-ask-end"&&Qk(t.outcome),i=t.type==="agent-ask-end"&&t.outcome==="expired"?t.id:null,{card:a,cardParked:c,askRevived:u,...h}=e;return{...h,...a&&!n&&(a.id!==r||o)?{card:a}:{},...c&&!n&&c!==r?{cardParked:c}:{},...i?{askRevived:i}:u&&!n?{askRevived:u}:{}}}function rD(e,t,n){return kt(e,t,r=>({...r,chat:[...r.chat,n],chatAt:Date.now()}))}function KS(e,t,n){return rD(Jo(e),t,{kind:"error",text:n})}function Ig(e,t){const n=Kl(nn(e,e.activeId));return n?kt(Jo(e),n,r=>({...r,notice:t})):e}function Rb(e,t,n){return nn(e,t)?KS(e,t,n):Ig(e,n)}function oD(e,t){const n=e.paletteReturn;return!t||!n?{overlay:null,paletteReturn:null}:{overlay:{kind:n.mode},paletteReturn:n}}function sD(e){const t=e.activeRepoId;if(!t)return e;const n=e.layouts[t];return n?uw(e,n):e.frame==="desk"?{...e,layouts:{...e.layouts,[t]:e.layout}}:e}function iD(e){return e.a==="server"&&e.msg.t==="git-status"}function aD(e){return{agent:e.defaultAgent}}function lD(e){const t=nn(e,e.activeId);return!!t&&Nr(t.worktree)&&!e.archivedPage&&!Th(e)?e.draft?e:{...e,draft:aD(e)}:e.draft?{...e,draft:null}:e}function ZS(e){var r;const t=e.archivedPage,n=t!==null&&((r=e.editor)==null?void 0:r.worktreeId)===t&&nn(e,t)===null;return{...e,archivedPage:null,...n?{editor:null}:{}}}function cD(e){const t=e.activeRepoId;if(!t)return e;const n=nn(e,e.activeId);return!n||n.repoId===t||$h(n,t,BS(e.rows,e.archiving),e.lent)?e:bl(e,Ll(e,t))}function qS(e,t,n){const r=t.some(i=>!e.knocks.some(a=>a.id===i.id)),o={...e,knocks:t,letIn:n};return r&&o.overlay===null?bi(o,{a:"open",overlay:{kind:"devices"}}):o}const uD=e=>{var t;return e.frame==="desk"&&(e.remote!==null||((t=e.tailscale)==null?void 0:t.state)==="ready")};function bi(e,t){let n=lD(cD(dD(e,t)));return n.unreadHold!==null&&n.activeId!==n.unreadHold&&(n={...n,unreadHold:null}),n.archivedPage!==null&&(Fo(n)===null||nn(n,n.archivedPage)!==null)&&(n=ZS(n)),n.activeRepoId!==e.activeRepoId?n=sD(n):n.frame==="desk"&&n.activeRepoId&&!iD(t)&&n.layout!==e.layout&&(n={...n,layouts:{...n.layouts,[n.activeRepoId]:n.layout}}),n.rows===e.rows&&n.activeRepoId===e.activeRepoId&&n.archiving===e.archiving&&n.lent===e.lent?n:{...n,visible:K4(n.rows,n.activeRepoId,n.archiving,n.lent),visibleDiscovered:Z4(n.rows,n.activeRepoId)}}function dD(e,t){var n,r,o,i,a,c,u,h;switch(t.a){case"connected":return{...e,connected:t.v,connectFailure:t.v?null:t.failure===void 0?e.connectFailure:t.failure,local:t.v?e.local:gD(e.local)};case"activate":return{...bl(e,t.id),carryTo:null,screen:t.id?"chat":"home"};case"open-draft":{if(Th(e))return e;const f=((n=DS(e,e.activeRepoId))==null?void 0:n.id)??null;return f?Jo({...bl(e,f),carryTo:f,overlay:null,paletteReturn:null,focusChat:e.focusChat+1,screen:"chat"}):e}case"draft-carry":return e.draft?{...e,draft:{...e.draft,carry:t.v}}:e;case"draft-agent":return e.draft?{...e,draft:{...e.draft,agent:t.id}}:e;case"draft-profile":return e.draft?{...e,draft:{...e.draft,profile:t.profile}}:e;case"open-archived":return LS(e,t.id);case"close-archived":return e.archivedPage?ZS(e):e;case"open-release-notes":return e.newProject?e:{...e,notesPage:!0,notesSeen:!0,overlay:null,paletteReturn:null,editor:null};case"close-release-notes":return e.notesPage?{...e,notesPage:!1}:e;case"sending":return kt(e,t.id,f=>({...f,sending:{message:t.message,at:Date.now()}}));case"sent-box":return kt(e,t.id,({notice:f,...m})=>({...xl(m,"walk"),draft:"",attachments:[],sent:(m.sent??0)+1}));case"answered":return kt(e,t.id,f=>({...f,sent:(f.sent??0)+1}));case"hold-send":{const f=e.local[t.id];if(!f)return e;const m=S4(e.clientId,++J4,t.id),g={...Sa,draft:t.text,attachments:f.attachments,outgoing:{frame:t.frame,log:t.log}},w=kt(e,t.id,({notice:y,...v})=>({...xl(v,"walk"),draft:"",attachments:[]}));return{...w,local:{...w.local,[m]:g},outbox:[...e.outbox,{id:m,log:t.log,kinds:f.attachments.map(y=>y.kind)}]}}case"sent-out":{const f=e.local[t.id],m=f==null?void 0:f.outgoing;if(!f||!m)return e;const{[t.id]:g,...w}=e.local,y={...e,local:w,outbox:e.outbox.filter(T=>T.id!==t.id)},v=f.draft,N=f.attachments.length?lw(f.attachments):void 0,x=T=>({...T,sent:(T.sent??0)+1});if(m.frame.t==="restore-worktree"||m.frame.t==="adopt-worktree")return kt(y,m.log,T=>({...x(T),sending:{message:{text:v,attachments:N},at:Date.now()}}));if(m.frame.t==="agent-answer")return kt(y,m.log,x);const _=m.frame.t==="chat"&&OS(e,m.log);return kt(y,m.log,T=>_?x(T):{...x(T),sending:{message:{text:v,attachments:N},at:Date.now()}})}case"unsend":{const f=e.local[t.id],m=(r=ms(t.id))==null?void 0:r.source;if(!(f!=null&&f.outgoing)||!m)return e;const{[t.id]:g,...w}=e.local,y={...e,local:w,outbox:e.outbox.filter(v=>v.id!==t.id)};return kt(Jo(y),m,v=>({...v,draft:v.draft||f.draft,attachments:[...f.attachments,...v.attachments],...t.notice?{notice:t.notice}:{}}))}case"drop-out":{if(!((o=e.local[t.id])!=null&&o.outgoing))return e;const{[t.id]:f,...m}=e.local;return{...e,local:m,outbox:e.outbox.filter(g=>g.id!==t.id)}}case"archive-worktrees":{const f=t.ids.filter(C=>!e.archiving.includes(C)&&nn(e,C));if(f.length===0)return e;const m=Date.now();let g=e.archived;for(const C of f){const M=nn(e,C);M&&(g={...g,[M.repoId]:[X4(M,m),...g[M.repoId]??[]]})}const w={...e,archiving:[...e.archiving,...f],archived:g};if(!e.activeId||!f.includes(e.activeId))return w;const y=e.visible.filter(C=>C.id===e.activeId||!w.archiving.includes(C.id)),v=y.findIndex(C=>C.id===e.activeId),N=[C=>C.agent==="waiting",C=>Ik(C.worktree)&&!!C.worktree.landed&&C.agent==="idle",C=>!!C.unseen,C=>C.agent==="working",C=>!Nr(C.worktree)&&ks(C)==="running"],x=C=>{for(const M of N){const I=C(M);if(I)return I.id}},_=x(C=>y.findLast((M,I)=>I<v&&C(M))),j=bl(w,_??x(C=>y.find((M,I)=>I>v&&C(M)))??Ll(w,e.activeRepoId));return e.frame==="phone"?{...j,screen:"home"}:j}case"shipping":return e.shipping[t.id]||!(No(e,t.id)||XS(e,t.id))?e:{...e,shipping:{...e.shipping,[t.id]:{op:t.op,sent:!0}}};case"activate-repo":{if(!Ii(e,t.id))return e;const f=e.newProject?{...e,newProject:null}:e;if(t.id===e.activeRepoId)return f;const m=Ll(f,t.id);return{...bl(f,m),carryTo:null,activeRepoId:t.id,lent:null,pendingOpen:!1}}case"open-repo":return{...e,pendingOpen:!0};case"new-project":return{...e,newProject:t.v,overlay:null,paletteReturn:null,previewTheme:null,editor:null,notesPage:!1};case"new-project-set":{if(!e.newProject)return e;const f="name"in t.v||"parent"in t.v||"url"in t.v||"mode"in t.v,{error:m,...g}=e.newProject;return{...e,newProject:{...f?g:e.newProject,...t.v}}}case"close-new-project":return e.newProject&&e.repos.length>0?{...e,newProject:null,choosingFolder:!1}:e;case"auto-sent":return e.autoSend?{...e,autoSend:null}:e;case"watch-import":return{...e,activeImportId:t.id};case"close-editor":return{...e,editor:null};case"open-file":{const f=t.v,m=e.editor,g=m&&Ic(m,f)?m:null,w=f.line&&IS(e,f.worktreeId,f.path,f.line);return{...e,editor:{worktreeId:f.worktreeId,path:f.path,...f.ref?{ref:f.ref}:{},...f.since?{since:f.since}:{},view:f.view??(g==null?void 0:g.view)??null,seq:f.seq,disk:(g==null?void 0:g.disk)??null,...w?{line:w}:{},focus:f.focus,conflict:(g==null?void 0:g.conflict)??null,blame:(g==null?void 0:g.blame)??null}}}case"open-loose":{const f=t.v,m={before:f.text,after:f.text,version:null,writable:f.source.kind!=="bytes"&&f.source.kind!=="text"&&!f.tooLarge&&!f.binary,binary:f.binary,tooLarge:f.tooLarge};return{...e,editor:{worktreeId:f.worktreeId,path:f.name,view:ji(f.name),seq:f.seq,disk:m,focus:!0,conflict:null,blame:null,loose:{source:f.source}}}}case"editor-read":{const f=e.editor;if(!f||f.loose||!Ic(f,t.file))return e;const m=t.disk;if(!m){const y=KS(e,f.worktreeId,t.error??`could not read ${f.path}`);return f.disk?y:{...y,editor:null}}const g=ji(f.path),w=m.before===""?f.view&&f.view!=="diff"?f.view:g:f.view??(m.before===m.after?g:"diff");return{...e,editor:{...f,view:w,disk:m}}}case"editor-conflict":{const f=e.editor;return f&&!f.loose&&Ic(f,t.file)?{...e,editor:{...f,conflict:t.theirs}}:e}case"editor-view":return e.editor?{...e,editor:{...e.editor,view:t.v,line:void 0}}:e;case"editor-refused":{const f=e.editor;if(!f||!Ic(f,t.file))return e;const m=f.loose&&f.disk?{...f.disk,writable:!1}:f.disk;return{...e,editor:{...f,refused:t.message,disk:m}}}case"editor-blame":{const f=e.editor;return f&&!f.loose&&Ic(f,t.file)?{...e,editor:{...f,blame:t.blame}}:e}case"notice":return kt(Jo(e),((i=ms(t.id))==null?void 0:i.source)??t.id,f=>({...f,notice:t.text}));case"link-refused":return kt(e,t.id,({refusedLink:f,...m})=>t.v?{...m,refusedLink:t.v}:m);case"card-draft":return kt(e,t.id,f=>({...f,card:t.card}));case"card-park":return kt(e,t.id,f=>({...f,cardParked:t.cardId}));case"card-unpark":return kt(e,t.id,({cardParked:f,...m})=>m);case"ask-revive":return kt(e,t.id,({askRevived:f,...m})=>t.askId?{...m,askRevived:t.askId}:m);case"opened-url":return e.openUrl?{...e,openUrl:null}:e;case"set-draft":return kt(e,t.id,f=>{const{notice:m,...g}=xl(f,"walk");return{...g,draft:t.text,...m!==void 0&&t.text===""?{notice:m}:{}}});case"move-box":return YS(e,t.from,t.to);case"walk":return kt(e,t.id,f=>({...xl(f,"walk"),draft:t.text,...t.walk?{mark:{by:"walk",at:t.walk.at,from:t.walk.from}}:{}}));case"reveal":return kt(Jo(e),t.id,f=>{var m;return{...f,mark:{by:"reveal",seq:t.seq,n:((m=f.mark)==null?void 0:m.by)==="reveal"?f.mark.n+1:1}}});case"attach":return kt(Jo(e),t.id,({notice:f,...m})=>({...m,attachments:[...m.attachments,...t.items]}));case"upload-progress":return(a=e.local[t.id])!=null&&a.attachments.some(f=>f.key===t.key&&Ti(f))?kt(e,t.id,f=>({...f,attachments:f.attachments.map(m=>m.key===t.key?{...m,progress:t.progress}:m)})):e;case"attached":return(c=e.local[t.id])!=null&&c.attachments.some(f=>f.key===t.key)?kt(e,t.id,f=>({...f,attachments:f.attachments.map(m=>m.key===t.key?t.item:m)})):e;case"detach":{const f=kt(e,t.id,({notice:m,...g})=>({...g,attachments:g.attachments.filter(w=>w.key!==t.key)}));return(u=e.local[t.id])!=null&&u.outgoing?bi(f,{a:"unsend",id:t.id}):f}case"clear-attachments":return kt(e,t.id,({notice:f,...m})=>m.attachments.length?{...m,attachments:[]}:m);case"hmr":return kt(e,t.id,f=>({...f,turn:{...f.turn,hmr:!0}}));case"page":return kt(e,t.id,f=>({...f,page:{url:t.url??f.page.url,title:t.title??f.page.title}}));case"links":return kt(e,t.id,f=>{const m=x4(f.links??[],t.links);return m===f.links?f:{...f,links:m}});case"drag-files":return F4(e.dragFiles,t.v)?e:{...e,dragFiles:t.v};case"sharing":return e.sharing===t.v?e:{...e,sharing:t.v};case"set-picking":return{...e,picking:t.v};case"preview-size":return e.previewSize===t.text?e:{...e,previewSize:t.text};case"open":return{...e,overlay:t.overlay,previewTheme:null,paletteReturn:WS(t.overlay)?e.paletteReturn:null};case"choosing-folder":return{...e,choosingFolder:t.v};case"close":return{...e,previewTheme:null,...oD(e,t.back)};case"toggle":return((h=e.overlay)==null?void 0:h.kind)===t.overlay.kind?bi(e,{a:"close"}):bi(e,{a:"open",overlay:t.overlay});case"palette-return":return{...e,paletteReturn:t.v};case"toggle-changes":return{...ao(e,{changes:!e.layout.changes}),changesAuto:!1};case"focus-changes":return{...ao(e,{changes:!0,changesTab:t.tab&&!Fo(e)?t.tab:e.layout.changesTab}),changesAuto:!1,focusChanges:e.focusChanges+1};case"changes-tab":return ao(e,{changesTab:t.v});case"edit-commit":return{...ao(e,{changes:!0}),changesAuto:!1,editCommit:e.editCommit+1};case"toggle-chat":return rs(e)?e:ao(e,{chat:!e.layout.chat});case"focus-chat":return{...Jo(e),focusChat:e.focusChat+1};case"walked":return{...e,walked:e.walked+1};case"show-chat":return Jo(e);case"hold-unread":return{...e,unreadHold:t.id};case"toggle-rail":return{...e,railOpen:!e.railOpen};case"toggle-chat-side":return{...e,chatSide:e.chatSide==="left"?"right":"left"};case"toggle-black-ground":return{...e,blackGround:!e.blackGround};case"update-check":return{...e,updateCheck:"asking"};case"update-check-settle":return e.updateCheck===t.check?{...e,updateCheck:null}:e;case"focus-rail":return{...e,railOpen:!0,focusRail:e.focusRail+1,screen:"home"};case"screen":return e.screen===t.to&&!e.editor?e:{...t.to==="changes"&&e.screen!=="changes"?ao(e,{changesTab:"changes"}):e,screen:t.to,editor:null,left:t.to==="home"&&e.screen!=="home"?{face:e.screen,at:Date.now()}:e.left};case"frame":{if(e.frame===t.v)return e;const f={...e,frame:t.v};if(t.v!=="desk"||!f.activeRepoId)return f;const m=f.layouts[f.activeRepoId];return m?uw(f,m):f}case"touch":return e.touch===t.v?e:{...e,touch:t.v};case"reading":return e.reading===t.on?e:{...e,reading:t.on};case"typing":return e.typing===t.on?e:{...e,typing:t.on};case"rail-peek":return e.railPeek===t.on?e:{...e,railPeek:t.on};case"toggle-discovered":{const f=e.activeRepoId;return f?{...e,discoveredOpen:{...e.discoveredOpen,[f]:!e.discoveredOpen[f]}}:e}case"toggle-archived":{const f=e.activeRepoId;return f?{...e,archivedOpen:{...e.archivedOpen,[f]:!e.archivedOpen[f]}}:e}case"toggle-committed":{const f=e.activeRepoId;return f?{...e,committedShut:{...e.committedShut,[f]:!e.committedShut[f]}}:e}case"toggle-turn":{const f=e.activeRepoId;return f?{...e,turnOpen:{...e.turnOpen,[f]:!e.turnOpen[f]}}:e}case"tree-folder":{const f=e.treeOpen[t.worktreeId]??[];if(f.includes(t.path)===t.open)return e;const m=t.open?[...f,t.path]:f.filter(w=>w!==t.path),g={...e.treeOpen};return m.length>0?g[t.worktreeId]=m:delete g[t.worktreeId],{...e,treeOpen:g}}case"tree-reveal":{const f=e.treeOpen[t.worktreeId]??[],m=[];for(let y=t.path.indexOf("/");y!==-1;y=t.path.indexOf("/",y+1))m.push(t.path.slice(0,y));m.push(t.path);const g=m.filter(y=>!f.includes(y)),w=g.length?{...e.treeOpen,[t.worktreeId]:[...f,...g]}:e.treeOpen;return{...ao(e,{changes:!0,changesTab:"files"}),changesAuto:!1,focusChanges:e.focusChanges+1,treeOpen:w,treeReveal:{worktreeId:t.worktreeId,path:t.path}}}case"files-asked":return kt(e,t.worktreeId,f=>({...f,filesFor:t.key}));case"toggle-zen":return rs(e)?e:{...e,zen:!e.zen};case"toggle-terminal":return ao(e,{term:!e.layout.term});case"focus-terminal":return{...ao(e,{term:!0}),focusTerm:e.focusTerm+1};case"toggle-design":return rs(e)?e:ao(e,{design:!e.layout.design});case"term-stream":return kt({...ao(e,{term:!0}),termTall:t.tall?e.termTall+1:e.termTall},t.id,f=>({...f,termStream:t.stream}));case"term-run":return kt({...ao(e,{term:!0}),focusTerm:e.focusTerm+1,termRun:{id:t.id,command:t.command}},t.id,f=>({...f,termStream:Po}));case"term-ran":return e.termRun?{...e,termRun:null}:e;case"preview-theme":return{...e,previewTheme:t.theme};case"system-dark":return{...e,systemDark:t.v};case"incompatible":return t.v===!1?{...e,incompatible:!1}:{...e,incompatible:!0,connected:!1};case"server":return xD(e,t.msg);case"recall":return bD(e,t.hello,t.chats)}}function GS(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 VS(e,t,n){const r=new Set(t.map(a=>a.id));n&&r.add(n);const o=([a,c])=>r.has(a)||!!c.draft||c.attachments.length>0,i=Object.entries(e);return i.every(o)?e:Object.fromEntries(i.filter(o))}function fD(e,t,n){var o;let r=e;for(const i of n){if(!((o=i.worktree)!=null&&o.landed)||t.some(h=>{var f;return h.id===i.id&&((f=h.worktree)==null?void 0:f.landed)}))continue;const a=r[i.id];if(!(a!=null&&a.git)||a.git.files.length===0)continue;r===e&&(r={...e});const{extras:c,...u}=a.git;r[i.id]={...a,git:{...u,files:[]}}}return r}function hD(e,t){const{version:n,files:r,ahead:o,behind:i,unpushed:a,head:c}=t,u={version:n,files:r,...o===void 0?{}:{ahead:o},...i===void 0?{}:{behind:i},...a===void 0?{}:{unpushed:a},...c===void 0?{}:{head:c}};if(t.extras)return{...u,extras:t.extras};const h=new Map(e==null?void 0:e.files.map(w=>[w.path,w])),f=r.map(w=>{const y=h.get(w.path);return y&&y.xy===w.xy&&y.add!==void 0?{...w,add:y.add,del:y.del}:w}),m=e!=null&&e.extras&&e.head===c?e.extras:void 0,g=m&&r.length===0&&m.turn?{committed:m.committed}:m;return{...u,files:f,...g?{extras:g}:{}}}function pD(e,t,n){if(!e||e.head!==t.head)return{};if(e.version===t.version)return n;const r=new Set([...e.files,...t.files].map(i=>i.path));let o=n;for(const i of Object.keys(n))r.has(i)&&(o===n&&(o={...n}),delete o[i]);return o}function mD(e){let t=e;for(const[n,r]of Object.entries(e))!r.git||r.git.version===0||(t===e&&(t={...e}),t[n]={...r,git:{...r.git,version:0}});return t}function gD(e){let t=e;for(const[n,r]of Object.entries(e)){if(r.filesFor===void 0)continue;t===e&&(t={...e});const{filesFor:o,...i}=r;t[n]=i}return t}function kD(e,t){let n=e;for(const[r,o]of Object.entries(t)){const i=n[r];i!=null&&i.draft||ms(r)||(n===e&&(n={...e}),n[r]={...i??Sa,draft:o})}return n}function wD(e,t){let n=e;for(const[r,o]of Object.entries(t)){const i=n[r];i!=null&&i.attachments.length||ms(r)||(n===e&&(n={...e}),n[r]={...i??Sa,attachments:$g(o,[])})}return n}function yD(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 ki(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 Ob(e){const t=e.newProject;if((t==null?void 0:t.phase)!=="creating"||!t.repoId)return e;const n=DS(e,t.repoId);if(!n)return e;const r=Xr(e,Ml);return!r.draft.trim()&&r.attachments.length===0?{...e,newProject:null}:{...YS(e,Ml,n.id),newProject:null,autoSend:n.id}}function YS(e,t,n){const r=e.local[t];if(!r)return e;const o=kt(e,n,i=>({...i,draft:r.draft,attachments:r.attachments}));return kt(o,t,i=>({...i,draft:"",attachments:[]}))}function tf(e,t,n){return e.stamps?{...e.stamps,[t]:n}:null}function vD(e){return e.stamps?RP(e.stamps):null}function XS(e,t){return Object.values(e.trunks).some(n=>n.id===t)}function QS(e,t,n){var y;const{rows:r,repos:o,trunks:i,visits:a}=t.same?e:t,c=v=>!!v&&r.some(N=>N.id===v),u=v=>!!v&&o.some(N=>N.id===v),h=u(e.activeRepoId)?e.activeRepoId:u(e.storedRepo)?e.storedRepo:null,f=c(e.activeId)?e.activeId:c(e.storedActive)?e.storedActive:Ll(e,h,r),m=r.find(v=>v.id===f),g=!!h&&!!m&&Nn(m)&&$h(m,h,r,e.lent),w={...e,heard:!n,heardAt:n?e.heardAt:Date.now(),recalledAt:n?e.recalledAt:null,stamps:n?null:t.stamps,repos:o,rows:r,activeId:f,lent:g?e.lent===f?e.lent:FS(m??null,h,r):null,activeRepoId:g?h:(m==null?void 0:m.repoId)??h??((y=o[0])==null?void 0:y.id)??null,trunks:i,archiving:e.archiving.length?[]:e.archiving,shipping:US({},r,i),local:mD(VS(wD(kD(e.local,t.drafts),t.attachments),r,e.archivedPage)),lastActive:yD(e.lastActive,r),treeOpen:GS(e.treeOpen,r),discoveredOpen:ki(e.discoveredOpen,o),archivedOpen:ki(e.archivedOpen,o),committedShut:ki(e.committedShut,o),turnOpen:ki(e.turnOpen,o),refs:ki(e.refs,o),chats:ki(e.chats,o),archived:ki(e.archived,o),themes:!n&&t.themes?t.themes:e.themes,themePrefs:!n&&t.themePrefs?t.themePrefs:e.themePrefs,agents:t.agents,defaultAgent:t.defaultAgent,agentChosen:t.agentChosen,home:t.home,folderDialog:t.folderDialog,keepAwake:t.keepAwake,remote:t.remote,machine:t.machine,managed:t.managed,tailscale:t.tailscale,handed:t.machines,gitIdentity:t.gitIdentity,newProject:e.newProject??(!n&&o.length===0&&r.length===0&&t.pending.length===0?AS():null),pending:n?e.pending:t.pending,visits:a,self:n?e.self:t.self,update:n?e.update:t.update,updateCheck:!n&&e.updateCheck==="asking"?null:e.updateCheck,version:n?e.version:t.version,install:n?e.install:t.install,registry:n?e.registry:t.registry,activeImportId:t.pending.some(v=>v.id===e.activeImportId)?e.activeImportId:null};return n?w:qS(w,t.knocks,t.letIn)}function Rg(e,t=[]){let n=t,r;for(const{seq:o,event:i}of e)n=e_(n,i,o),i.type==="usage"&&(r=JS(i));return r?{chat:n,usage:r}:{chat:n}}function bD(e,t,n){var i;let r=QS(e,A4(t),!0);r={...r,recalledAt:t.at};for(const[a,c]of Object.entries(n))if(r.rows.some(u=>u.id===a))try{const{chat:u,usage:h}=Rg(c.events);r=kt(r,a,f=>({...f,chat:t_(u),chatAt:O4(c.events)??t.at,running:void 0,...h?{usage:h}:{},...c.draft&&!f.draft?{draft:c.draft}:{}}))}catch{}const o=r.activeId;return o&&r.screen!=="home"&&!(((i=r.local[o])==null?void 0:i.chat.length)??0)&&(r={...r,screen:"home"}),r}function xD(e,t){var n,r,o,i,a,c,u,h,f,m,g,w,y,v,N;switch(t.t){case"hello":return QS(e,t,!1);case"self":{const x=((n=e.self)==null?void 0:n.building)===!0&&e.self.rebuild&&!((r=t.self)!=null&&r.building);return{...e,self:t.self,rebuilt:e.rebuilt||x&&((o=t.self)==null?void 0:o.buildFailed)===void 0}}case"remote":return{...e,remote:t.remote,machine:t.machine};case"machines":return{...e,handed:t.machines};case"tailscale":return{...e,tailscale:t.tailscale};case"knocks":return qS(e,t.knocks,t.letIn);case"update":return{...e,update:t.update};case"update-checked":return{...e,updateCheck:t.check};case"visits":return{...e,visits:{...e.visits,[t.repoId]:t.pages},stamps:tf(e,"visits",t.stamp)};case"themes":return{...e,themes:t.themes,themePrefs:t.prefs,stamps:tf(e,"themes",t.stamp)};case"daylight":return{...e,daylight:{dark:t.dark,until:t.until}};case"keep-awake":return{...e,keepAwake:t.mode};case"agents":return{...e,agents:t.agents,defaultAgent:t.defaultAgent,agentChosen:t.agentChosen};case"agent-config":{const{t:x,..._}=t;return{...e,agentConfigs:{...e.agentConfigs,[_.agent]:_}}}case"pending-repos":{const x=new Set(e.pending.map(M=>M.id)),_=t.pending.find(M=>!x.has(M.id)),T=_&&e.pendingOpen?_.id:e.activeImportId,j=t.pending.some(M=>M.id===T),C=t.pending.some(M=>M.id===T&&M.error);return{...e,pending:t.pending,activeImportId:j?T:null,pendingOpen:C?!1:e.pendingOpen,newProject:_&&e.pendingOpen&&((i=e.newProject)==null?void 0:i.phase)==="creating"?null:e.newProject}}case"path-entries":return{...e,paths:{query:t.query,entries:t.entries,target:t.target}};case"folder-chosen":return{...e,chosenFolder:{seq:(((a=e.chosenFolder)==null?void 0:a.seq)??0)+1,folder:t.folder}};case"refs":return{...e,refs:{...e.refs,[t.repoId]:{query:t.query,refs:t.refs}}};case"chat-hits":return{...e,chats:{...e.chats,[t.repoId]:{query:t.query,hits:t.hits,truncated:t.truncated,asks:t.asks}}};case"archived":{const x=(e.archived[t.repoId]??[]).filter(_=>e.archiving.includes(_.id)&&!t.items.some(T=>T.id===_.id));return{...e,archived:{...e.archived,[t.repoId]:x.length?[...x,...t.items]:t.items}}}case"draft":return t.clientId===e.clientId||ms(t.boxId)?e:kt(e,t.boxId,x=>{var _;return x.draft===t.text||((_=x.mark)==null?void 0:_.by)==="walk"?x:{...x,draft:t.text}});case"attachments":return t.clientId===e.clientId||ms(t.boxId)?e:kt(e,t.boxId,x=>({...x,attachments:$g(t.items,x.attachments)}));case"repos":{const x=new Set(e.repos.map(A=>A.id)),_=t.repos.find(A=>!x.has(A.id));let T=e.activeRepoId,j=e.pendingOpen,C=e.newProject;_&&(j||!T)?(T=_.id,j=!1,C&&C.phase!=="unmaking"&&(C={...C,phase:"creating",repoId:_.id})):t.repos.some(A=>A.id===T)||(T=((c=t.repos[0])==null?void 0:c.id)??null),(C==null?void 0:C.phase)==="unmaking"&&!t.repos.some(A=>A.id===(C==null?void 0:C.repoId))&&(C={...C,phase:"editing",repoId:null}),t.repos.length===0&&!C&&(C=AS());const M=e.gitIdentity||t.repos.some(A=>A.made&&!x.has(A.id)),I=tf(e,"repos",t.stamp),O=ki(e.visits,t.repos);return T===e.activeRepoId?{...e,repos:t.repos,stamps:I,visits:O,pendingOpen:j,newProject:C,gitIdentity:M}:Ob({...e,repos:t.repos,stamps:I,visits:O,pendingOpen:j,newProject:C,gitIdentity:M,activeRepoId:T,activeId:Ll(e,T),editor:null})}case"worktrees":{const{rows:x,complete:_}=T4(e.rows,t),T=t.trunks??e.trunks;let j=e.activeId;(!j||!x.some(A=>A.id===j))&&(j=Ll(e,e.activeRepoId,x));const C=new Set(e.rows.map(A=>A.id)),M=A=>{var z;return((z=A.worktree)==null?void 0:z.kind)==="worktree"&&A.worktree.createdBy===e.clientId},I=x.find(A=>!C.has(A.id)&&M(A));I&&e.rows.length>0&&(j=I.id);const O=e.archiving.filter(A=>x.some(z=>z.id===A));return Ob({...bl({...e,rows:x,trunks:T,stamps:tf(e,"rows",_?t.stamp:""),archiving:O.length===e.archiving.length?e.archiving:O,shipping:US(e.shipping,x,T),local:VS(tD(fD(e.local,e.rows,x),x,e.activeId,j===(I==null?void 0:I.id)?I.id:void 0),x,e.archivedPage),treeOpen:GS(e.treeOpen,x)},j),editor:j===e.activeId?e.editor:null,...I&&j===I.id?{carryTo:I.id}:{},...j===e.activeId?{activeRepoId:e.activeRepoId}:{},archivedPage:I?null:e.archivedPage,notesPage:I?!1:e.notesPage})}case"log":return kt(e,t.worktreeId,x=>({...x,log:VC(x.log.slice(-400),t.proc,t.line,t.retract)}));case"agent":{const x=t.event,_=t.worktreeId;let T=kt(e,_,j=>{const C=e_(j.chat,x,t.seq),M=x.type==="turn-end",I=M||x.type==="agent-error"||x.type==="agent-auth-required",A=x.type==="tool-start"||x.type==="tool-end"||M||x.type==="tool-update"&&x.background?Ib(C,j.running):j.running;let z=j.turn;x.type==="turn-start"?z={edits:!1,hmr:!1}:x.type==="tool-start"&&oE(x)&&(z={...z,edits:!0});const B=x.type==="session-info"&&x.model?x.model:j.model,U=x.type==="session-info"&&x.effort?x.effort:j.effort,Q=x.type==="usage"?{...JS(x),heard:Date.now()}:j.usage,ae=e.rows.find(K=>K.id===_),ee=zo(ae==null?void 0:ae.agent),de=j.sending?ee?ru(j):{...j,sending:{at:j.sending.at}}:j,$=nD(x.type==="user-message"?de:I?ru(j):j,x);return{...x.type==="user-message"?xl($,"reveal"):$,chat:C,...C!==j.chat?{chatAt:Date.now()}:{},...A!==j.running?{running:A}:{},turn:z,...B!==j.model?{model:B}:{},...U!==j.effort?{effort:U}:{},...Q!==j.usage?{usage:Q}:{}}});if(x.type==="agent-ask-end"&&!Qk(x.outcome)&&((u=T.local[Sl(x.id)])!=null&&u.attachments.length)&&(T=kt(T,Sl(x.id),j=>({...j,attachments:[]}))),x.type==="user-message"){const j=wS(((h=e.local[_])==null?void 0:h.chat)??[]),C=j?Sl(j.id):null,M=C?((f=T.local[C])==null?void 0:f.attachments)??[]:[];C&&M.length&&(T=kt(T,C,I=>({...I,attachments:[]})),T=kt(T,_,I=>({...I,attachments:[...I.attachments,...M]})))}if(x.type==="turn-end"){const j=T.local[_].turn;j.edits&&!j.hmr&&(T={...T,reloadReq:{id:_,n:(((m=T.reloadReq)==null?void 0:m.n)??0)+1}})}return(x.type==="agent-question"||x.type==="agent-permission"||x.type==="pieces-proposed"&&!x.held||x.type==="pieces-shown")&&_===e.activeId&&(T=Jo(T)),T}case"backfill":{const x=_=>t.events.some(({event:T})=>T.type==="user-message"&&T.text===_);return kt(e,t.worktreeId,({sending:_,...T})=>{const{chat:j,usage:C}=t.after!==void 0?Rg(t.events,T.chat):Rg(t.events);return{...T,..._&&!(_.message&&x(_.message.text))?{sending:_}:{},chat:j,chatAt:Date.now(),running:Ib(j,T.running),log:t.log??T.log,...C?{usage:C}:{}}})}case"git-status":{const x=(g=e.local[t.worktreeId])==null?void 0:g.git;if(t.version>0&&x&&t.version<x.version||t.version>0&&x&&t.version===x.version&&!t.extras)return e;let _=e.layout.changes,T=e.changesAuto;const j=((w=t.extras)==null?void 0:w.committed.length)??0;e.changesAuto&&t.worktreeId===e.activeId&&!_&&(t.files.length>0||j>0)&&(_=!0,T=!1);const C=t.worktreeId===e.archivedPage?Fo(e):null;C&&(t.files.length>0||j>0||C.landed)&&(_=!0);const M=kt(e,t.worktreeId,I=>{const O=hD(I.git,t);return{...I,git:O,changedRanges:pD(I.git,O,I.changedRanges)}});return{...ao(M,{changes:_}),changesAuto:T}}case"changed-ranges":{const x=kt(e,t.worktreeId,T=>({...T,changedRanges:{...T.changedRanges,[t.path]:{ranges:t.ranges,offset:t.lineOffset}}})),_=x.editor;return!((y=_==null?void 0:_.line)!=null&&y.fiber)||_.worktreeId!==t.worktreeId||_.path!==t.path?x:{...x,editor:{..._,line:IS(x,_.worktreeId,_.path,_.line)}}}case"shipped":{const x=t.worktreeId,_={...e,shipping:Ab(e.shipping,T=>{var j;return T===x&&((j=e.shipping[T])==null?void 0:j.sent)===!0}),openUrl:t.ok&&t.url?t.url:e.openUrl};return!t.ok&&!t.asked?x?Rb(_,x,t.message):Ig(_,t.message):_}case"files":return kt(e,t.worktreeId,x=>({...x,files:t.paths,submodules:t.submodules,ignored:t.ignored}));case"search-results":return kt(e,t.worktreeId,x=>({...x,search:{query:t.query,hits:t.hits,truncated:t.truncated}}));case"element-sources":{if(e.editor&&e.editor.seq>t.seq)return e;const[x]=t.hits;if(!x)return kt(e,t.worktreeId,T=>({...T,notice:"nothing in the source matches this element"}));if(!t.sure)return bi(e,{a:"open",overlay:{kind:"element-sources",worktreeId:t.worktreeId,hits:t.hits}});const _=bi(e,{a:"open-file",v:{worktreeId:t.worktreeId,path:x.path,view:"file",line:{n:x.line},focus:!0,seq:t.seq}});return _.layout.changes?_:bi(_,{a:"toggle-changes"})}case"design-index":return kt(e,t.worktreeId,x=>({...x,design:t.index}));case"routes":return kt(e,t.worktreeId,x=>({...x,pages:{routes:t.routes,unseen:t.unseen}}));case"queue":return kt(e,t.worktreeId,x=>({...x,queue:t.items}));case"agent-commands":return kt(e,t.worktreeId,x=>({...x,commands:t.commands}));case"git-log":return kt(e,t.worktreeId,x=>({...x,commits:t.commits}));case"git-commit":return kt(e,t.worktreeId,x=>({...x,commitFiles:{...x.commitFiles,[t.sha]:t.files}}));case"error":{const x=t.worktreeId,_=e.newProject,T=(_==null?void 0:_.phase)==="creating"&&!_.repoId,j=x?e.archiving.includes(x)?[x]:[]:e.archiving,C={...eD(e,x),archiving:j.length?e.archiving.filter(M=>!j.includes(M)):e.archiving,archived:j.length?Q4(e.archived,j):e.archived,shipping:Ab(e.shipping,M=>!x||M===x),newProject:T?{..._,phase:"editing",error:t.message}:(_==null?void 0:_.phase)==="unmaking"?null:_,pendingOpen:T?!1:e.pendingOpen,updateCheck:!x&&e.updateCheck==="asking"?null:e.updateCheck};return T?C:x?Rb(C,x,t.message):Ig(C,t.message)}case"unsent":{const x=((v=ms(t.boxId))==null?void 0:v.source)??t.boxId,_=!No(e,x)&&!!e.activeRepoId&&((N=e.archived[e.activeRepoId])==null?void 0:N.some(T=>T.id===x));return kt(Jo(_?LS(e,x):e),x,({sending:T,...j})=>({...j,draft:j.draft||t.text,attachments:[...$g(t.items,[]),...j.attachments],notice:t.message}))}default:return e}}function JS(e){return{used:e.used,size:e.size,...e.cost!==void 0?{cost:e.cost}:{}}}function ED(e,t){const n=t.trim();return n!==""&&(e.trim()===n||e.trim().endsWith(`: ${n}`))}function e_(e,t,n){var i,a,c,u;const r=e[e.length-1],o=n===void 0?{}:{seq:n};switch(t.type){case"fix-asked":return[...e,{kind:"asked",about:t.kind,why:t.why,...t.toolId?{toolId:t.toolId}:{}}];case"user-message":return[...e,{kind:"user",text:t.text,...(i=t.attachments)!=null&&i.length?{attachments:t.attachments}:{},...o}];case"handed":return[...e,{kind:"handed",via:t.via,...t.body?{body:t.body}:{},...t.path?{path:t.path}:{},...t.note?{note:t.note}:{},origin:t.origin,...(a=t.attachments)!=null&&a.length?{attachments:t.attachments}:{},...o,ts:t.ts}];case"text-delta":{const h=t.messageId?{messageId:t.messageId}:{};if((r==null?void 0:r.kind)==="assistant"&&r.messageId===t.messageId)return[...e.slice(0,-1),{...r,text:r.text+t.text}];const f=t.messageId===void 0?-1:SD(e,t.messageId);if(f!==-1){const m=e.slice(),g=m[f];return m[f]={...g,text:g.text+t.text},m}return[...e,{kind:"assistant",text:t.text,...o,...h}]}case"thinking-delta":return(r==null?void 0:r.kind)==="thinking"?[...e.slice(0,-1),{...r,text:r.text+t.text}]:[...e,{kind:"thinking",text:t.text}];case"tool-start":return[...e,{kind:"tool",id:t.toolId,name:t.name,input:t.input,done:!1,...t.kind?{toolKind:t.kind}:{},...t.title?{title:t.title}:{},...t.parentToolId?{parentToolId:t.parentToolId}:{},...t.subagent?{subagent:!0}:{}}];case"tool-update":{const h=e.findLastIndex(g=>g.kind==="tool"&&g.id===t.toolId);if(h===-1)return e;const f=e.slice(),m=f[h];return f[h]={...m,...t.name?{name:t.name}:{},...t.title?{title:t.title}:{},...t.input!==void 0?{input:t.input}:{},...t.kind?{toolKind:t.kind}:{},...t.background?{background:!0}:{},...t.until?{until:t.until}:{}},f}case"tool-delta":{const h=e.findLastIndex(g=>g.kind==="tool"&&g.id===t.toolId);if(h===-1)return e;const f=e.slice(),m=f[h];return f[h]={...m,output:(m.output??"")+t.text},f}case"tool-end":{const h=e.findLastIndex(g=>g.kind==="tool"&&g.id===t.toolId);if(h===-1)return e;const f=e.slice(),m=f[h];return f[h]={...m,output:t.output,isError:t.isError,...(c=t.images)!=null&&c.length?{images:t.images}:{},...t.detached?{detached:!0}:{},...t.fixable?{fixable:t.fixable}:{},...t.cut?{cut:!0}:{},done:!0},f}case"agent-error":return(r==null?void 0:r.kind)==="assistant"&&ED(t.message,r.text)?[...e.slice(0,-1),{kind:"error",text:t.message,...o}]:[...e,{kind:"error",text:t.message,...o}];case"agent-blocked":return[...e,{kind:"blocked",tool:t.tool,path:t.path,reason:t.reason}];case"grafted":return[...e,{kind:"grafted",title:t.title,branch:t.branch}];case"landed":return[...e,{kind:"landed",text:t.message,...t.mark?{mark:t.mark}:{},...t.url?{url:t.url}:{},ts:t.ts}];case"piece-landed":return[...e,{kind:"piece-landed",worktreeId:t.worktreeId,repoName:t.repoName,title:t.title,...t.url?{url:t.url}:{},...t.same?{same:!0}:{},...t.again?{again:!0}:{},...t.awaited?{awaited:!0}:{},ts:t.ts}];case"pieces-proposed":{const h=t.held?e.findLast(m=>m.kind==="ask"&&!m.outcome&&m.ask.kind==="permission"&&!!m.ask.plan):void 0,f=(h==null?void 0:h.kind)==="ask"&&h.ask.kind==="permission"?{companion:h.id,plan:h.ask.plan}:{};return[...e,{kind:"pieces",id:t.id,pieces:t.pieces,fates:Object.fromEntries(t.pieces.map(m=>[m.id,m.fate])),mode:t.mode,...t.held?{held:!0}:{},...t.plan?{plan:t.plan}:{},...t.by?{by:t.by}:{},...f,state:t.held?"held":"proposed",outcomes:[],later:[],ts:t.ts}]}case"pieces-stale":{const h=ul(e,t.id,["held","proposed"]);return h===-1?e:e.with(h,{...e[h],stale:!0})}case"pieces-shown":{const h=ul(e,t.id,["held","proposed"]);if(h===-1)return e;const f=e[h];return e.with(h,{...f,state:"proposed",...t.plan?{plan:t.plan}:{}})}case"pieces-fate":{const h=ul(e,t.id,["held","proposed"]);if(h===-1)return e;const f=e[h];return e.with(h,{...f,fates:{...f.fates,[t.pieceId]:t.fate}})}case"pieces-go":{const h=ul(e,t.id,["held","proposed"]);return h===-1?e:e.with(h,{...e[h],state:"going"})}case"pieces":{const h=ul(e,t.id,["held","proposed","going"]);return h===-1?[...e,{kind:"pieces",id:t.id,pieces:[],fates:{},mode:Cf,state:"done",outcomes:t.outcomes,later:[],ts:t.ts}]:e.with(h,{...e[h],state:"done",outcomes:t.outcomes})}case"pieces-declined":{const h=ul(e,t.id,["held","proposed","going"]);if(h===-1)return e;const f=e[h];return e.with(h,{...f,state:"declined",...t.reason?{reason:t.reason}:{}})}case"piece-made":case"piece-dropped":{const h=e.findLastIndex(v=>v.kind==="pieces"&&v.id===t.id),f=h===-1?void 0:e[h],m=t.type==="piece-made"?{pieceId:t.pieceId,worktreeId:t.worktreeId,title:t.title}:{pieceId:t.pieceId,reason:t.reason},g=t.type==="piece-made"?t.title:(u=f==null?void 0:f.pieces.find(v=>v.id===t.pieceId))==null?void 0:u.title,w={kind:"piece-later",id:t.id,...g?{title:g}:{},...m,ts:t.ts};return[...f?e.with(h,{...f,later:[...f.later,m]}):e,w]}case"restored":return[...e,{kind:"restored",archivedAt:t.archivedAt,branch:t.branch,uncommitted:t.uncommitted,ts:t.ts}];case"adopted":return[...e,{kind:"adopted",branch:t.branch,ts:t.ts}];case"agent-auth-required":return[...e,{kind:"auth",agent:t.agent,agentName:t.agentName,methods:t.methods,...t.rejected?{rejected:!0}:{},...t.withheld?{withheld:!0}:{},...t.provider?{provider:t.provider}:{},...t.detail?{detail:t.detail}:{},...t.refresh?{refresh:t.refresh}:{},done:!1}];case"agent-auth-ok":return e.some(h=>h.kind==="auth"&&!h.done)?e.map(h=>h.kind==="auth"&&!h.done?{...h,done:!0}:h):e;case"agent-question":return Mb(e,t.toolId,{kind:"ask",id:t.id,ask:{kind:"question",message:t.message,questions:t.questions}});case"agent-permission":{const h={kind:"ask",id:t.id,ask:{kind:"permission",title:t.title,...t.command?{command:t.command}:{},...t.detail?{detail:t.detail}:{},...t.plan?{plan:t.plan}:{},...t.pieces?{pieces:t.pieces}:{},choices:t.choices}},f=t.pieces?e.findLastIndex(w=>w.kind==="pieces"&&w.id===t.pieces):-1,m=f===-1?e:e.with(f,{...e[f],companion:t.id,...t.plan&&!e[f].plan?{plan:t.plan}:{}}),g=m.findLast(w=>w.kind==="tool"&&w.id===t.toolId);return(g==null?void 0:g.kind)!=="tool"||t.plan||g.toolKind==="switch_mode"?Mb(m,t.toolId,h):[...m,{...h,toolId:g.id}]}case"agent-ask-end":{const h=e.findLastIndex(g=>g.kind==="ask"&&g.id===t.id&&!g.outcome);if(h===-1)return e;const f=e[h];if(f.toolId&&_D(f,t.choiceId))return[...e.slice(0,h),...e.slice(h+1)];const m=e.slice();return m[h]={...m[h],outcome:t.outcome,...t.answers?{answers:t.answers}:{},...t.choiceId?{choiceId:t.choiceId}:{}},m}case"turn-end":{const h=t_(e);return t.stopReason==="interrupted"?[...h,{kind:"stopped",...o}]:h}default:return e}}function t_(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 SD(e,t){let n=e.length-1;for(;n>=0&&_u(e[n]);)n--;const r=e[n];return(r==null?void 0:r.kind)==="assistant"&&r.messageId===t?n:-1}function ul(e,t,n){return e.findLastIndex(r=>r.kind==="pieces"&&r.id===t&&n.includes(r.state))}function _D(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 Mb(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 ND(e){let t=e;const n=new Set;return{getState:()=>t,dispatch(r){const o=bi(t,r);if(o!==t){t=o;for(const i of n)i()}},subscribe(r){return n.add(r),()=>n.delete(r)}}}const n_=S.createContext(null),mw=S.createContext(null),r_=S.createContext(null);function TD({store:e,sock:t,files:n,children:r}){return d.jsx(n_.Provider,{value:e,children:d.jsx(mw.Provider,{value:t,children:d.jsx(r_.Provider,{value:n,children:r})})})}const o_=S.createContext(null),s_=S.createContext(null);function jD({machines:e,children:t}){const n=S.useSyncExternalStore(e.subscribe,e.active);return d.jsx(o_.Provider,{value:e,children:d.jsx(s_.Provider,{value:n,children:d.jsx(TD,{store:n.store,sock:n.sock,files:n.files,children:d.jsx(S.Fragment,{children:t},n.origin)})})})}function is(){const e=S.useContext(o_);if(!e)throw new Error("useMachines outside <MachinesProvider>");return e}function mo(){const e=S.useContext(s_);if(!e)throw new Error("useMachine outside <MachinesProvider>");return e}function gw(){const e=is();return S.useSyncExternalStore(e.subscribe,e.list)}function pl(e,t){return S.useSyncExternalStore(e.store.subscribe,()=>t(e.store.getState()))}const Og=(e,t)=>e.length===t.length&&e.every((n,r)=>n===t[r]);function i_(){const e=is(),t=mo(),n=gw(),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]),a=S.useCallback(()=>{const c=r.map(m=>e.displayName(m.origin)),u=r.map(m=>m.store.getState().repos),h=o.current;if(h&&h.others===r&&Og(h.names,c)&&Og(h.repos,u))return h.value;const f=r.map((m,g)=>({origin:m.origin,name:c[g]??m.origin,repos:u[g]??[]}));return o.current={others:r,names:c,repos:u,value:f},f},[r,e]);return S.useSyncExternalStore(i,a)}function a_(){const e=mo(),t=gw(),n=S.useMemo(()=>t.filter(a=>a!==e),[t,e]),r=S.useRef(null),o=S.useCallback(a=>{const c=n.map(u=>u.store.subscribe(a));return()=>{for(const u of c)u()}},[n]),i=S.useCallback(()=>{const a=n.map(h=>{const f=h.store.getState();return f.connected&&!f.incompatible?f.rows:Pb}),c=r.current;if(c&&c.others===n&&Og(c.rows,a))return c.value;const u=n.map((h,f)=>({origin:h.origin,rows:(a[f]??Pb).filter(Nn)}));return r.current={others:n,rows:a,value:u},u},[n]);return S.useSyncExternalStore(o,i)}const Pb=[];function dG(){return mo().terminals}function Un(){const e=S.useContext(n_);if(!e)throw new Error("useStore outside <StoreProvider>");return e}function P(e){const t=Un();return S.useSyncExternalStore(t.subscribe,()=>e(t.getState()))}function kw(){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 Un().dispatch}function tt(){return S.useContext(mw)}function Wr(){const e=S.useContext(mw);return(e==null?void 0:e.urls)??Xk(location.origin,"")}function ww(){return S.useContext(r_)}function $D(e=!1,t=!0){const n=S.useRef(null);return S.useEffect(()=>{if(!t)return;const r=()=>{const i=n.current;!i||document.activeElement===i||(i.focus(),e&&i instanceof HTMLInputElement&&i.select())};r();const o=requestAnimationFrame(r);return()=>cancelAnimationFrame(o)},[e,t]),n}function xo(e,t,n,r=CD){const o=()=>{try{return n(r.get(e))??t}catch{return t}},[i,a]=S.useState(()=>({key:e,value:o()}));return i.key!==e&&a({key:e,value:o()}),[i.key===e?i.value:o(),h=>{a({key:e,value:h});try{r.set(e,typeof h=="boolean"?h?"1":"0":String(h))}catch{}}]}const CD={get:e=>localStorage.getItem(e),set:(e,t)=>localStorage.setItem(e,t)};function jl(e,t){return n=>{n.preventDefault(),document.body.classList.add("resizing");const r=n.currentTarget;r.classList.add("active");const o=a=>{const c=e(a,r);c!==null&&t(c)},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 l_(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 yw(e,t){const[n,r]=S.useState(void 0);return S.useEffect(()=>{if(e===void 0){r(void 0);return}const o=setTimeout(()=>r(e),t);return()=>clearTimeout(o)},[e,t]),n}const vw=1500;function xi(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 AD(){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 ID(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(),a=parseFloat(getComputedStyle(r).getPropertyValue("--scroll-foot"))||0,c=i.bottom-(o.bottom-a);if(c<=0)return;const u=parseFloat(getComputedStyle(r).paddingTop)||0;r.scrollTop+=Math.min(c,Math.max(0,i.top-o.top-u))}),n=>{t.current=n}}const Lm=40,RD=1200,OD=150,MD=new Set(["ArrowUp","ArrowDown","PageUp","PageDown","Home","End"," "]);function c_(e,t){const n=S.useRef(!0),r=S.useRef(Number.NEGATIVE_INFINITY),o=S.useRef(!1),[i,a]=S.useState(!1),[c,u]=S.useState(!1),[h,f]=S.useState(!1),[m,g]=S.useState(null),w=S.useCallback(C=>{n.current=C,e.current&&(e.current.style.overflowAnchor=C?"none":"")},[e]),y=S.useRef(null),v=S.useRef(null);ut([t],()=>{n.current||f(!0)});const N=S.useCallback(()=>n.current,[]),x=S.useCallback(()=>{const C=e.current;C&&(w(C.scrollHeight-C.scrollTop-C.clientHeight<Lm),a(!n.current),u(C.scrollTop>=Lm),n.current&&f(!1))},[e,w]),_=S.useCallback(C=>{Math.abs(C)<4||(g(C<0?"up":"down"),v.current&&clearTimeout(v.current),v.current=setTimeout(()=>g(null),RD))},[]),T=S.useCallback(()=>{const C=e.current;C&&(C.scrollTop=C.scrollHeight,w(!0),a(!1),f(!1))},[e,w]),j=S.useCallback(()=>{const C=e.current;C&&(r.current=performance.now(),C.scrollTop=0)},[e]);return S.useEffect(()=>{const C=e.current;if(!C)return;w(n.current);const M=()=>o.current||performance.now()-r.current<OD,I=()=>{n.current&&!M()?u(C.scrollTop>=Lm):x()};C.addEventListener("scroll",I,{passive:!0});const O=()=>{r.current=performance.now()},A=K=>{O(),_(K.deltaY)},z=K=>{var V;O(),y.current=((V=K.touches[0])==null?void 0:V.clientY)??null},B=K=>{var X;O();const V=(X=K.touches[0])==null?void 0:X.clientY;V===void 0||y.current===null||(_(y.current-V),y.current=V)},U=()=>{o.current=!0},Q=()=>{o.current=!1},ae=K=>{if(!MD.has(K.key))return;const V=K.target;(V===document.body||V instanceof Node&&C.contains(V))&&O()};C.addEventListener("wheel",A,{passive:!0}),C.addEventListener("touchstart",z,{passive:!0}),C.addEventListener("touchmove",B,{passive:!0}),C.addEventListener("pointerdown",U,{passive:!0}),window.addEventListener("pointerup",Q,{passive:!0}),window.addEventListener("pointercancel",Q,{passive:!0}),document.addEventListener("keydown",ae);const ee=()=>{C.scrollTop=C.scrollHeight},de=new ResizeObserver(()=>{n.current&&ee()});de.observe(C);for(const K of C.children)de.observe(K);const $=new MutationObserver(K=>{for(const V of K){for(const X of V.addedNodes)X instanceof Element&&de.observe(X);for(const X of V.removedNodes)X instanceof Element&&de.unobserve(X)}n.current&&ee()});return $.observe(C,{childList:!0}),()=>{C.removeEventListener("scroll",I),C.removeEventListener("wheel",A),C.removeEventListener("touchstart",z),C.removeEventListener("touchmove",B),C.removeEventListener("pointerdown",U),window.removeEventListener("pointerup",Q),window.removeEventListener("pointercancel",Q),document.removeEventListener("keydown",ae),$.disconnect(),de.disconnect(),v.current&&clearTimeout(v.current)}},[e,x,_,w]),{offEnd:i,offStart:c,away:h,moving:m,pinned:N,jump:T,start:j,read:x}}function Lb(e,t,n){const r=document.createRange();return r.selectNodeContents(e),r.setEnd(t,n),r.toString().length}function Db(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 u_(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)?Lb(n,r.anchorNode,r.anchorOffset):null,a=r&&r.rangeCount>0&&o(r.focusNode)?Lb(n,r.focusNode,r.focusOffset):null,c=r&&(i!==null||a!==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]]:Db(n,i),[f,m]=a===null?[c[2],c[3]]:Db(n,a);u&&f&&r.setBaseAndExtent(u,h,f,m)},[e,t])}function ut(e,t){const n=S.useRef(t);n.current=t,S.useEffect(()=>n.current(),e)}function d_(e){const[t,n]=S.useState({left:0,right:0});return S.useLayoutEffect(()=>{if(!e)return;const r=()=>{const i=e.getBoundingClientRect();let{left:a,right:c}=i;const u=e.closest("[data-pinned]");if(u){const f=u.getBoundingClientRect(),m=u.offsetWidth/f.width;a=u.offsetLeft+(a-f.left)*m,c=u.offsetLeft+(c-f.left)*m}const h={left:Math.round(a),right:Math.round(c)};n(f=>f.left===h.left&&f.right===h.right?f:h)};r();const o=new ResizeObserver(r);return o.observe(e),window.addEventListener("resize",r),()=>{o.disconnect(),window.removeEventListener("resize",r)}},[e]),t}function zb(){const[e,t]=S.useState(null);return[t,d_(e)]}function fG(e){e.ctrlKey&&e.stopPropagation()}function f_(e,t){return e.defaultPrevented||e.ctrlKey?!1:t<1.01}function hG(e){S.useEffect(()=>{const t=e.current;if(!t)return;const n=r=>{var o;f_(r,((o=window.visualViewport)==null?void 0:o.scale)??1)&&r.preventDefault()};return t.addEventListener("wheel",n,{passive:!1}),()=>t.removeEventListener("wheel",n)},[e])}const h_={axis:null,dx:0,dy:0,at:Number.NEGATIVE_INFINITY},PD=2,LD=4,DD=300;function zD(e,t,n){const r=Math.abs(t.deltaX),o=Math.abs(t.deltaY),i=r>o?"x":"y",a=n-e.at<=DD?e:h_;if(a.axis===null){const u=a.dx+r,h=a.dy+o,f=Math.max(u,h)>=PD?u>h?"x":"y":null;return{scrolls:f!==null&&f===i,next:{axis:f,dx:u,dy:h,at:n}}}return i===a.axis?{scrolls:!0,next:{...a,at:n}}:(i==="x"?r:o)>=LD?{scrolls:!0,next:{...a,axis:i,at:n}}:{scrolls:!1,next:{...a,at:n}}}function pG(e){S.useEffect(()=>{const t=e.current;if(!t)return;let n=h_;const r=o=>{var c;if(o.ctrlKey)return;const{scrolls:i,next:a}=zD(n,o,o.timeStamp);n=a,!i&&(o.stopPropagation(),f_(o,((c=window.visualViewport)==null?void 0:c.scale)??1)&&o.preventDefault())};return t.addEventListener("wheel",r,{capture:!0,passive:!1}),()=>t.removeEventListener("wheel",r,{capture:!0})},[e])}function FD(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 BD(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 UD(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 HD(e,t,n){const[r,o]=S.useState(),i=S.useRef(e);return i.current=e,S.useEffect(()=>{if(!n)return;let a=!0,c;const u=()=>void i.current().then(h=>{a&&(o(h),c=setTimeout(u,t))});return u(),()=>{a=!1,clearTimeout(c)}},[t,n]),r}const Zl=()=>P(e=>e.activeId),p_=()=>l_(!P(e=>e.connected),900),WD=e=>!e.connected&&(e.connectFailure==="down"||e.connectFailure==="blocked"),m_=()=>P(WD),Ps=()=>P(e=>nn(e,e.activeId)),bw=()=>P(e=>No(e,e.activeId)),g_=()=>P(e=>e.rows),xw=()=>P(e=>e.visible),KD=()=>P(e=>e.visibleDiscovered),ZD=()=>P(e=>e.activeRepoId?e.discoveredOpen[e.activeRepoId]??!1:!1),Fb=[],qD=()=>P(e=>e.activeRepoId?e.archived[e.activeRepoId]??Fb:Fb),GD=()=>P(e=>e.activeRepoId?e.archivedOpen[e.activeRepoId]??!1:!1),VD=()=>P(e=>!(e.activeRepoId&&e.committedShut[e.activeRepoId])),YD=()=>P(e=>!!(e.activeRepoId&&e.turnOpen[e.activeRepoId])),_a=()=>P(Fo),Ew=()=>P(pw),XD=()=>P(e=>Ii(e,e.activeRepoId)),ql=()=>P(e=>Ii(e,fw(e))),k_=e=>P(t=>Xr(t,e)),It=(e,t)=>P(n=>Xr(n,e)[t]),QD=()=>P(e=>e.overlay),Ch=()=>P(U4),w_=()=>P(MS),Nu=()=>P(H4),Tu=()=>P(rs),JD=()=>P(e=>e.newProject),Na=()=>P(e=>e.touch),ez=()=>P(e=>e.draft),Sw=()=>P(vl),tz=()=>P(e=>{const t=No(e,e.activeId),n=t?e.repos.find(r=>r.id===t.repoId):null;return Uf(n)?n:null});function nz(e){return e.image?{kind:"image",blob:e.image,sig:`image:${e.image.type}:${e.image.size}`}:e.text&&eS(e.text)?{kind:"text",text:e.text,sig:`text:${e.text}`}:null}function rz(){try{return localStorage.getItem(Ke.clipboardOffer)==="1"}catch{return!1}}let Ms={access:"none",on:typeof localStorage<"u"&&rz(),offer:null},Mg="";const Pg=new Set;function Ah(e){Ms={...Ms,...e};for(const t of Pg)t()}async function oz(){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 nz({image:e,text:t})}async function Ih({taken:e=!1,asking:t=!1}={}){if(!Ms.on||!(Ms.access==="granted"||t&&Ms.access==="prompt"))return;let n;try{n=await oz()}catch{return}e&&(Mg=(n==null?void 0:n.sig)??""),Ah({offer:n&&n.sig!==Mg?n:null})}const sz=()=>void Ih();let Bb=!1;function iz(){var e,t;Bb||(Bb=!0,!(!((e=navigator.clipboard)!=null&&e.read)||!((t=navigator.permissions)!=null&&t.query))&&navigator.permissions.query({name:"clipboard-read"}).then(n=>{const r=()=>{Ah({access:n.state,...n.state==="denied"?{offer:null}:{}})};n.onchange=r,r(),window.addEventListener("focus",sz),document.hasFocus()&&Ih()},()=>{}))}function az(e){return Pg.add(e),iz(),()=>{Pg.delete(e)}}const lz=()=>Ms;function cz(e){try{localStorage.setItem(Ke.clipboardOffer,e?"1":"0")}catch{}Ah({on:e,offer:null}),e&&Ih({asking:!0})}function y_(){Ms.offer&&(Mg=Ms.offer.sig),Ah({offer:null})}const uz=()=>void Ih({taken:!0});function dz(){return S.useSyncExternalStore(az,()=>Ms.offer)}const v_="application/x-toyon-source";function mG(e){const t=e.endColumn===1&&e.endLineNumber>e.startLineNumber?e.endLineNumber-1:e.endLineNumber;return{startLine:e.startLineNumber,endLine:t}}function fz(e,t){e.setData(v_,JSON.stringify(t))}const Ub=e=>typeof e=="number"&&Number.isInteger(e)&&e>=1;function hz(e,t){const n=e.getData(v_);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:a}=r;return!Ub(o)||!Ub(i)||i<o?null:{path:r.path,startLine:o,endLine:i,...typeof a=="string"?{ref:a}:{}}}const b_=e=>({left:e.x,top:e.y,right:e.x,bottom:e.y});function pz(e,t){return t.matchWidth===void 0?void 0:Math.max(0,e.right-e.left+t.matchWidth)}const mz=new Set(["top","bottom"]),Dm={top:"bottom",bottom:"top",left:"right",right:"left"};function zm(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 Hb(e,t,n,r,o){return n==="top"||n==="left"?e>=o:e+t<=r-o}function Fm(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 Wb(e,t,n,r,o){return n==="start"?e+t<=r-o:e>=o}const Kb=(e,t,n,r)=>n||!r?e:t,Zb=(e,t,n,r)=>Math.max(r,Math.min(e,n-r-t));function gz(e,t,n,r){const{offset:o=0,alignOffset:i=0,cover:a=!1,flip:c="none",margin:u=8}=r,h=mz.has(r.side),f=h?{a:{start:e.top,end:e.bottom},size:t.h,limit:n.h}:{a:{start:e.left,end:e.right},size:t.w,limit:n.w},m=h?{a:{start:e.left,end:e.right},size:t.w,limit:n.w}:{a:{start:e.top,end:e.bottom},size:t.h,limit:n.h};let g=r.side;if(c==="side"||c==="both"){const N=zm(f.a,f.size,g,o,a),x=zm(f.a,f.size,Dm[g],o,a);g=Kb(g,Dm[g],Hb(N,f.size,g,f.limit,u),Hb(x,f.size,Dm[g],f.limit,u))}let w=r.align??"center";if((c==="align"||c==="both")&&w!=="center"){const N=w==="start"?"end":"start",x=Fm(m.a,m.size,w,i),_=Fm(m.a,m.size,N,i);w=Kb(w,N,Wb(x,m.size,w,m.limit,u),Wb(_,m.size,N,m.limit,u))}const y=Zb(zm(f.a,f.size,g,o,a),f.size,f.limit,u),v=Zb(Fm(m.a,m.size,w,i),m.size,m.limit,u);return h?{x:v,y,side:g,align:w}:{x:y,y:v,side:g,align:w}}function kz(e,t,n){var i,a;const r=e.length;if(r===0)return-1;let o=t<0?n===1?0:r-1:(t+n+r)%r;for(let c=0;c<r&&((i=e[o])!=null&&i.disabled);c++)o=(o+n+r)%r;return(a=e[o])!=null&&a.disabled?-1:o}const x_={sep:!0},gs=e=>!("sep"in e);function Rh(e){const t=[];for(const n of e)(gs(n)||t.length>0&&gs(t[t.length-1]))&&t.push(n);for(;t.length>0&&!gs(t[t.length-1]);)t.pop();return t}const Bn=e=>Rh(e.flatMap((t,n)=>n?[x_,...t]:t));let dl=null,wz=0;const Lg=new Set,qb=()=>{for(const e of Lg)e()},uo={get:()=>dl,subscribe(e){return Lg.add(e),()=>{Lg.delete(e)}},open(e){const t=Rh(e.items);if(t.length===0)return uo.close();dl={...e,items:t,id:++wz},qb()},close(){dl&&(dl=null,qb())},toggle(e){dl&&dl.target===e.target?uo.close():uo.open(e)}};function _w(){return S.useSyncExternalStore(uo.subscribe,uo.get)}function E_(e){const t=e.nativeEvent;return t&&"pointerType"in t?t.pointerType==="":e.clientX===0&&e.clientY===0}function yz(e,t){return E_(e)?{anchor:(t.querySelector('[data-state~="cursor"]')??t).getBoundingClientRect()}:{at:{x:e.clientX,y:e.clientY}}}function vz(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:b_(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=Rh(t(E_(r)?"keyboard":"pointer",r.target));if(o.length===0)return;r.preventDefault(),r.stopPropagation();const i=r.currentTarget;uo.open({items:o,owner:e,key:n,target:i,...yz(r,i)})}}},dropdown(t,n="left",r,o){return{"aria-haspopup":"menu",onClick:i=>{i.stopPropagation();const a=i.currentTarget;uo.toggle({items:t(),...o?{head:o()}:{},owner:e,key:r,target:a,toggles:!0,anchor:a.getBoundingClientRect(),align:n})}}},openUnder(t,n,r){uo.open({items:n(),owner:e,key:r,target:t,toggles:!0,anchor:t.getBoundingClientRect(),align:"left"})}}),[e])}const S_=e=>({id:"open-out",label:sw()?"open in the browser":"open in a new tab",onClick:()=>window.open(e,"_blank")}),tn=e=>{var t;return void((t=navigator.clipboard)==null?void 0:t.writeText(e).catch(()=>{}))};function __(e,t){const n=navigator.clipboard;if(n){if(typeof ClipboardItem>"u"||!n.write){e==="text/plain"&&t.then(r=>r.text()).then(tn,()=>{});return}n.write([new ClipboardItem({[e]:t})]).catch(()=>{})}}const N_=e=>__("text/plain",fetch(e).then(t=>t.blob())),bz=e=>__("image/png",xz(e));async function xz(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(a=>a?o(a):i(new Error("could not encode image")),"image/png"))}finally{n.close()}}function T_(e){return Pk(e)}function Bo(e){return(e==null?void 0:e.urls.host)??(typeof location=="object"?location.hostname:"127.0.0.1")}function Uo(e,t,n="reveal in Finder"){return!e||!T_(t)?[]:[{id:"reveal",label:n,onClick:e}]}function Ez(e,t){const n=[];for(const r of t)r.xy.includes("D")?n.push(`-${r.path}`):/[?ARC]/.test(r.xy)&&n.push(`+${r.path}`);return`${e??""}
|
|
99
|
+
${n.sort().join(`
|
|
100
|
+
`)}`}function Oh(e,t,{sock:n,dispatch:r}){var a,c;if(!n)return;const o=t.local[e]??Sa,i=Ez((a=o.git)==null?void 0:a.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 Sz=["diff","file","preview"],j_=(e,t)=>Sz.filter(n=>!(n==="preview"&&!Eh(e))&&!(n==="diff"&&t));let _z=0;const Lo=()=>++_z;function Fn({dispatch:e},{focus:t=!0,...n}){e({a:"open-file",v:{...n,focus:t,seq:Lo()}})}const Dg=new Map;function $_(e,t,n=""){const{sock:r}=e;if(!r)return Promise.resolve("not connected to the daemon");const o=Lo();return new Promise(i=>{Dg.set(o,a=>{a.ok?(Fn(e,{...t,view:ji(t.path)}),i(null)):i(a.reason==="changed"?"a file is already there":a.message??"the file was not made")}),r.send({t:"write-file",...t,content:n,base:null,seq:o})})}function Nz(e){const t=Dg.get(e.seq);return t?(Dg.delete(e.seq),t(e),!0):!1}function Tz({dispatch:e},t){e({a:"tree-reveal",...t})}function Rs(e,t,{discard:n=!1,ref:r,since:o,showing:i,noDiff:a=!1,kept:c=!1,select:u},h){const{sock:f,dispatch:m}=h,g=j_(t,a).filter(_=>_!==i).map(_=>({id:`view:${_}`,label:`view ${_}`,onClick:()=>i?m({a:"editor-view",v:_}):Fn(h,{worktreeId:e.id,path:t,view:_,ref:r,since:o})})),w=`${e.dir}/${t}`,y=c?[]:Uo(()=>f==null?void 0:f.send({t:"reveal",worktreeId:e.id,path:t}),Bo(f));return Bn([g,[{id:"copy-path",label:"copy path",onClick:()=>tn(w)}],y,u?[{id:"select",label:"select…",onClick:()=>u(t)}]:[],n?[{id:"discard",label:"discard changes…",danger:!0,onClick:()=>{window.confirm(C_([t]))&&(f==null||f.send({t:"discard-files",worktreeId:e.id,paths:[t]}))}}]:[]])}function C_(e){if(e.length===1)return`Discard uncommitted changes to ${e[0]}?`;const t=e.slice(0,12),n=e.length-t.length,r=[...t,...n>0?[`and ${n} more`]:[]].join(`
|
|
101
|
+
`);return`Discard uncommitted changes to ${e.length} files?
|
|
102
|
+
|
|
103
|
+
${r}`}const So=(e,t,n)=>e.dispatch({a:"notice",id:t,text:n});function Mh(e,t,n){var o;const r=oA(((o=e.getState().local[t])==null?void 0:o.attachments)??[],n);return r===0&&So(e,t,Rk(n)),r}const jz=1e3,$z=1e4,A_=new WeakMap;function Cz(e,t){A_.set(e,t)}async function I_(e,t,n,r){var y,v;const{local:o,...i}=n;e.dispatch({a:"attach",id:t,items:[{...n,upload:"",uploading:!0}]});const a=()=>{var N;return(N=Object.entries(e.getState().local).find(([,x])=>x.attachments.some(_=>_.key===n.key)))==null?void 0:N[0]},c=A_.get(e);let u=-1;const h=N=>{const x=Math.min(99,Math.floor(N*100)),_=a();x===u||_===void 0||(u=x,e.dispatch({a:"upload-progress",id:_,key:n.key,progress:x}))},f=()=>(u=-1,c?AL(c,n.kind,r,h):Promise.resolve(null));let m=await f();const g=m===null;g&&So(e,a()??t,`${n.name}: Toyon is not answering; it attaches once it is back`);for(let N=jz;m===null&&a()!==void 0;N=Math.min(N*2,$z))await new Promise(x=>setTimeout(x,N)),a()!==void 0&&(m=await f());const w=a();if(!(m===null||w===void 0))if(typeof m=="string")e.dispatch({a:"detach",id:w,key:n.key}),So(e,w,`${n.name}: ${m}`);else{const N=i.kind==="file"?{...i,...m}:{...i,upload:m.upload,bytes:m.bytes};e.dispatch({a:"attached",id:w,key:n.key,item:N});const x=(v=e.getState().local[((y=ms(w))==null?void 0:y.source)??w])==null?void 0:v.notice;g&&(x!=null&&x.startsWith(`${n.name}: Toyon is not answering`))&&So(e,w,"")}o&&URL.revokeObjectURL(o)}function Nw(e,t,n){if(!t||n.length===0)return;const r=Mh(e,t,"file");if(r!==0){for(const o of n.slice(0,r)){const i=o.name||"file";if(o.size>wb){So(e,t,`${i}: larger than ${Mk(wb)}`);continue}const a={kind:"file",key:crypto.randomUUID(),upload:"",name:i,bytes:o.size,text:!1};I_(e,t,a,o)}n.length>r&&So(e,t,`kept ${r} of ${n.length}: ${Rk("file")}`)}}function Tw(e,t,n,r={}){if(!t)return;const o=xP(r.source?n.replace(/\r?\n$/,""):n);if(o.length>pP)return r.source?So(e,t,"that paste is too large; save it in the worktree and reference it with @path"):Nw(e,t,[new File([o],mP,{type:"text/plain"})]);Mh(e,t,"paste")!==0&&e.dispatch({a:"attach",id:t,items:[{kind:"paste",key:crypto.randomUUID(),text:o,...r,...qk(o)}]})}function R_(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 Bm(e,t){var i;const n=e.getState(),r=nn(n,n.activeId),o=Kl(r);if(t&&o&&t.worktreeId===(r==null?void 0:r.worktree.id)&&t.text.trim()){const a="source"in t?{source:t.source}:{name:t.name};(((i=n.local[o])==null?void 0:i.attachments)??[]).some(u=>{var w;if(u.kind!=="paste")return!1;if(!("source"in t))return u.name===t.name&&u.text===t.text;const{path:h,startLine:f,endLine:m,ref:g}=t.source;return((w=u.source)==null?void 0:w.path)===h&&u.source.startLine===f&&u.source.endLine===m&&u.source.ref===g})||Tw(e,o,t.text,a)}e.dispatch(t?{a:"focus-chat"}:PS(n))}function jw(e,t){return t!==e.activeId?null:Kl(nn(e,t))}const O_=(e,t)=>`@${e}${t?"/":""}`,$w=e=>`${e.map(t=>O_(t.path,t.folder)).join(" ")} `;function M_(e,t,n){const r=t>0&&!/\s/.test(e[t-1]??"")?" ":"";return{text:`${e.slice(0,t)}${r}${n}${e.slice(t)}`,caret:t+r.length+n.length}}function P_(e,t,n){var o;const r=((o=e.getState().local[t])==null?void 0:o.draft)??"";e.dispatch({a:"set-draft",id:t,text:M_(r,r.length,n).text}),e.dispatch({a:"focus-chat"})}function Cw(e,t,n){const r=jw(e.getState(),t);r&&P_(e,r,n)}function Az(e,t,n,r){Cw(e,t,$w([{path:n,folder:r}]))}function Iz(e,t,n){n.length!==0&&Cw(e,t,$w(n.map(r=>({path:r,folder:!1}))))}function Gb(e,t,n){Cw(e,t,n)}function Rz(e,t){return nn(e,t)?t:null}function Oz(e,t){var r;const n=(r=nn(e,t))==null?void 0:r.worktree;return n?[n.path]:[]}function Vb(e,t){if(!e)return e;const n=t.find(r=>e.startsWith(`${r}/`));return n?e.slice(n.length+1):e}function Mz(e,t,n){var g;e.dispatch({a:"set-picking",v:!1});const r=e.getState(),o=Rz(r,t);if(!o)return;const{classes:i,route:a,element:c,...u}=n,h=Oz(r,t),f={...u,file:Vb(u.file,h),callFile:Vb(u.callFile,h)};!(((g=r.local[o])==null?void 0:g.attachments)??[]).some(w=>w.kind==="pick"&&w.selector===f.selector)&&Mh(e,o,"pick")>0&&e.dispatch({a:"attach",id:o,items:[{kind:"pick",key:crypto.randomUUID(),...f}]}),e.dispatch({a:"focus-chat"})}function Pz(e,t=[],n=[]){const r={path:"",name:"",kind:"folder",children:[],ignored:!1},o=new Map([["",r]]),i=u=>{const h=o.get(u);if(h)return h;const f=u.lastIndexOf("/"),m={path:u,name:u.slice(f+1),kind:"folder",children:[],ignored:!1};return i(f===-1?"":u.slice(0,f)).children.push(m),o.set(u,m),m},a=(u,h,f=!1)=>{const m=u.lastIndexOf("/");i(m===-1?"":u.slice(0,m)).children.push({path:u,name:u.slice(m+1),kind:h,children:[],ignored:f})};for(const u of e)a(u,"file");for(const u of t)a(u,"submodule");for(const u of n)u.endsWith("/")?a(u.slice(0,-1),"ignored",!0):a(u,"file",!0);const c=u=>{const h=f=>f.kind==="file"?1:0;u.children.sort((f,m)=>h(f)-h(m)||NS(f.name,m.name));for(const f of u.children)f.kind==="folder"&&c(f)};return c(r),r.children}function Lz(e,t){const n=[],r=(o,i)=>{for(const a of o){const c=a.kind==="folder"&&t(a.path);n.push({path:a.path,name:a.name,depth:i,kind:a.kind,open:c,ignored:a.ignored}),c&&r(a.children,i+1)}};return r(e,0),n}const L_=e=>{const t=e.lastIndexOf("/");return t===-1?"":e.slice(0,t)};function Dz(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 zz(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 Bf(o))n.add(i)}return{files:t,folders:n}}function D_(e){const t=e.findLast(n=>n.kind==="pieces"&&n.state!=="declined");return(t==null?void 0:t.kind)==="pieces"?t:null}function Fz(e){return!!e.plan&&!e.companion}function Ri(e,t){return e.fates[t.id]??t.fate}function ju(e,t){var r;const n=t.after;return n?"piece"in n?{kind:"piece",title:((r=e.pieces.find(o=>o.id===n.piece))==null?void 0:r.title)??"another piece"}:{kind:"branch",...n}:null}function z_(e){const t={worktrees:0,queued:0,sent:0,here:0,skipped:0};for(const n of e.pieces){const r=Ri(e,n);r==="worktree"?n.after?t.queued++:t.worktrees++:r==="send"?t.sent++:r==="here"?t.here++:t.skipped++}return t}const F_=(e,t,n=`${t}s`)=>`${e} ${e===1?t:n}`,Bz=e=>e.length<=1?e[0]??"":`${e.slice(0,-1).join(", ")} and ${e.at(-1)}`;function Uz(e,t){const n=z_(e),r=[];if(n.here&&r.push("this plan here"),n.worktrees&&r.push(`${F_(n.worktrees,"worktree")} now`),n.queued){const i=e.pieces.filter(u=>Ri(e,u)==="worktree"&&u.after),a=i.every(u=>u.after&&"id"in u.after&&u.after.id===t),c=i.length===1?ju(e,i[0]):null;r.push(a?`${n.queued} when this branch lands`:c?`1 when ${c.kind==="branch"?c.branch:c.title} lands`:`${n.queued} queued`)}n.sent&&r.push(`${n.sent} sent on`);const o=n.skipped?`; ${n.skipped} skipped`:"";return r.length===0?`Starts nothing${o}.`:`Starts ${Bz(r)}${o}.`}function zg(e){var i;const t=e.pieces.length===1?e.pieces[0]:void 0;if(t)return t.fate==="send"?`Send ${t.title} to ${((i=t.to)==null?void 0:i.title)??"the worktree"}?`:t.fate==="here"?`Keep ${t.title} here?`:t.project?`Continue in ${t.project.name}?`:t.after?`Queue a worktree for ${t.title}?`:`Start a worktree for ${t.title}?`;const n=z_(e),o=[n.worktrees?`start ${F_(n.worktrees,"worktree")}`:"",n.queued?`queue ${n.queued}`:"",n.sent?`send ${n.sent}`:"",n.here?`do ${n.here} here`:"",n.skipped?`skip ${n.skipped}`:""].filter(Boolean).join(", ");return`${o.charAt(0).toUpperCase()}${o.slice(1)}?`}function Hz(e,t){var c;const n=ju(e,t),r=n?` once ${n.kind==="branch"?n.branch:n.title} lands`:"",o=t.project?{fate:"worktree",label:`start a worktree in ${t.project.name}`,description:`a copy of that project, with this text as its plan${r}`,notes:!0}:{fate:"worktree",label:n?"queue a worktree":"start a worktree",description:`a copy of this project, with this text as its plan${r}`,notes:!0},i={fate:"here",label:"do it here",description:"this worktree's agent, after its turn",notes:!1},a={fate:null,label:"not now",notes:!1};return t.fate==="send"?[{fate:"send",label:`send to ${((c=t.to)==null?void 0:c.title)??"the worktree"}`,description:"that worktree's agent, as a message",notes:!0},a]:t.fate==="here"?[i,o,a]:t.project?[o,a]:[o,i,a]}function Wz(e,t){var n;return t==="worktree"?e.project?`new worktree in ${e.project.name}`:"new worktree":t==="here"?"here":t==="skip"?"skip":`sent to ${((n=e.to)==null?void 0:n.title)??"the worktree"}`}function B_(e,t,n){var r;if(t==="worktree"){const o=e.project?` in ${e.project.name}`:"",i=n?`, once ${n.kind==="branch"?n.branch:n.title} lands`:"";return`Starts as a new worktree${o}${i}, with this text as its plan.`}return t==="here"?"This worktree's agent does it.":t==="send"?`Goes to ${((r=e.to)==null?void 0:r.title)??"that worktree"}'s agent as a message.`:"Skipped: nothing happens to this piece."}function Yb(e,t,n,r){const o=n?r==null?void 0:r.trim():void 0;return{t:"pieces-answer",worktreeId:t,id:e.id,go:n,...o?{note:o}:{}}}function U_(e,t,n,r){return{t:"pieces-fate",worktreeId:t,id:e.id,pieceId:n,fate:r}}function Kz(e,t=[]){if(e.fate==="send")return["send","skip"];const n=e.after;return!!n&&"piece"in n&&t.findIndex(o=>o.id===n.piece)>t.findIndex(o=>o.id===e.id)?["here","skip"]:e.project?["worktree","skip"]:["here","worktree","skip"]}const ou=e=>e.state==="held"||e.state==="proposed";function H_(e){const t=n=>n.fate==="here"?0:n.fate==="worktree"?n.after?2:1:3;return[...e.pieces].sort((n,r)=>t(n)-t(r))}function Zz(e,t){if(ou(e)){const r=Ri(e,t);return r==="worktree"?{word:t.after?"queued":"worktree"}:r==="send"?{word:"sent"}:{word:r}}const n=su(e,t);return n.kind==="worktree"||n.kind==="sent"&&n.worktreeId?{worktreeId:n.worktreeId,...n.title?{title:n.title}:{}}:{word:n.kind==="sent"?"sent":n.kind}}function su(e,t){if(e.state==="going")return{kind:"starting"};const n=e.outcomes.find(a=>a.pieceId===t.id),r=e.later.findLast(a=>a.pieceId===t.id);if(!n)return{kind:"skipped"};if(n.error)return{kind:"failed",error:n.error};if(n.fate==="here")return{kind:"here"};if(n.fate==="skip")return{kind:"skipped"};const o=n.repoName?{repoName:n.repoName}:{};if(n.fate==="send")return{kind:"sent",...n.worktreeId?{worktreeId:n.worktreeId}:{},...n.title?{title:n.title}:{},...o};const i=n.worktreeId?n:r!=null&&r.worktreeId?r:null;return i!=null&&i.worktreeId?{kind:"worktree",worktreeId:i.worktreeId,...i.title?{title:i.title}:{},..."repoName"in i&&i.repoName?{repoName:i.repoName}:{}}:r!=null&&r.reason?{kind:"dropped",reason:r.reason}:{kind:"queued",after:ju(e,t),...n.after?{said:n.after}:{}}}function qz(e,t){var o;if(t)return"plan";const n=H_(e),r=ou(e)?void 0:n.find(i=>Ri(e,i)==="here");return(r==null?void 0:r.id)??((o=n[0])==null?void 0:o.id)??"plan"}function Gz(e){if(e.state!=="done")return[];const t=new Map;for(const n of e.pieces){const r=n.after;if(!r||Ri(e,n)!=="here")continue;if("id"in r){t.set(r.id,r.title);continue}const o=e.pieces.find(a=>a.id===r.piece),i=o?su(e,o):null;((i==null?void 0:i.kind)==="worktree"||(i==null?void 0:i.kind)==="sent"&&i.worktreeId)&&t.set(i.worktreeId,i.title??(o==null?void 0:o.title)??"the worktree")}return[...t].map(([n,r])=>({id:n,title:r}))}function Aw(e){const t=e.findLast(n=>n.kind==="ask"&&!n.outcome||n.kind==="pieces"&&n.state==="proposed");return(t==null?void 0:t.kind)==="ask"||(t==null?void 0:t.kind)==="pieces"?t:null}function Vz(e){const t=e?Aw(e.chat):null;return(t==null?void 0:t.kind)!=="ask"||t.ask.kind!=="question"||(e==null?void 0:e.cardParked)===t.id?null:Sl(t.id)}function Yz(e){return e.kind==="ask"?VL(e):zg(e)}const W_=new Set(dP),Xz=/^image\.[a-z0-9]+$/i,Qz=e=>Xz.test(e.name),Jz=(e,t)=>e===t||e.name===t.name&&e.size===t.size&&e.type===t.type&&e.lastModified===t.lastModified;function e3(e){if(!e)return[];const t=[];for(const i of Array.from(e.items??[])){if(i.kind!=="file"||!i.type.startsWith("image/"))continue;const a=i.getAsFile();a&&t.push(a)}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(a=>Jz(a,i))||n.push(i);const r=n.filter(i=>!Qz(i));if(r.length>0)return r;const o=n.find(i=>W_.has(i.type))??n[0];return o?[o]:[]}function t3(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 n3(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 r3(e){try{return await createImageBitmap(e)}catch{throw new Error(`${e.name||"image"}: not a readable image`)}}function Xb(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(a=>a?o(a):i(new Error("could not encode image")),n,.9))}async function o3(e){const t=await r3(e);try{const n=Math.max(t.width,t.height);let r=e,o=e.type,i=t.width,a=t.height;if(!W_.has(o)||n>kb||e.size>Pm){const c=o==="image/jpeg"?"image/jpeg":"image/png";let u=Math.min(1,kb/n);for(r=await Xb(t,u,c);r.size>Pm&&u>.1;)u*=.7,r=await Xb(t,u,c);if(r.size>Pm)throw new Error(`${e.name||"image"}: too large even after downscaling`);o=c,i=Math.max(1,Math.round(t.width*u)),a=Math.max(1,Math.round(t.height*u))}return{blob:r,name:e.name||`pasted.${o==="image/jpeg"?"jpg":"png"}`,mimeType:o,width:i,height:a}}finally{t.close()}}const Gc={el:null},s3=80,i3=2e3;let _o=null,Fg;const K_=(e,t)=>{clearTimeout(Fg),Fg=setTimeout(()=>Rw(e),t)};function Iw(e,t){_o??(_o={refused:!1}),e.dispatch({a:"drag-files",v:_o.refused?null:t}),K_(e,i3)}function Z_(e){_o&&K_(e,s3)}const a3=()=>(_o==null?void 0:_o.refused)??!1;function Rw(e){_o&&(clearTimeout(Fg),_o=null,e.dispatch({a:"drag-files",v:null}))}function l3(e){_o&&(_o.refused=!0,e.dispatch({a:"drag-files",v:null}))}let c3=0;function u3(e){const{blob:t,...n}=e;return{kind:"image",key:`img${++c3}`,...n,upload:"",bytes:t.size,local:URL.createObjectURL(t)}}async function Ph(e,t,n){var a;if(!t||n.length===0)return;const r=Mh(e,t,"image");if(r===0)return;const o=await Promise.allSettled(n.slice(0,r).map(o3));for(const c of o)c.status==="fulfilled"&&I_(e,t,u3(c.value),c.value.blob);const i=o.find(c=>c.status==="rejected");i?So(e,t,String(((a=i.reason)==null?void 0:a.message)??i.reason)):n.length>r&&So(e,t,`kept ${r} of ${n.length}: ${Rk("image")}`)}function d3(e,t,n){n.kind==="image"?Ph(e,t,[new File([n.blob],"image.png",{type:n.blob.type})]):Tw(e,t,n.text),y_()}function Wf(e,t,n){const r=o=>o.type.startsWith("image/");Ph(e,t,n.filter(r)),Nw(e,t,n.filter(o=>!r(o)))}function q_(e,t){const n=document.createElement("input");n.type="file",n.multiple=!0,n.onchange=()=>Wf(e,t,Array.from(n.files??[])),n.click()}function Ta(e){const t=e.getState();if(t.newProject)return Ml;const n=Fo(t)??pw(t);if(n)return n.id;const r=nn(t,t.activeId);return Vz(r?t.local[r.worktree.id]:void 0)??Kl(r)}function G_(e,t,n=Ta(e)){Wf(e,n,t.filter(o=>!o.folder).map(o=>o.file));const r=t.find(o=>o.folder);n&&r&&So(e,n,`${r.file.name}: a folder cannot be attached; drop its files`)}const Bg=Promise.resolve(null);function f3(e){var n,r,o;if(!e)return[];const t=[];for(const i of Array.from(e.items)){if(i.kind!=="file")continue;const a=i.getAsFile();if(!a)continue;const c=((n=i.getAsFileSystemHandle)==null?void 0:n.call(i).then(u=>(u==null?void 0:u.kind)==="file"?u:null,()=>null))??Bg;t.push({file:a,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:Bg});return t}const h3=e=>e.map(t=>({file:t,handle:Bg}));async function V_(e){const t=Lf*4;if(e.size>t)return{text:"",tooLarge:!0};const n=await n3(e,t);return n===null?null:n.length>Lf?{text:"",tooLarge:!0}:{text:n,tooLarge:!1}}async function p3(e,t){const n=Ta(e),r=e.getState().activeId,o=f=>n&&So(e,n,f),i=t.filter(f=>f.file.type.startsWith("image/")).map(f=>f.file);i.length&&Ph(e,n,i);const a=t.filter(f=>!f.file.type.startsWith("image/")),c=a[0];if(!c||!r)return;const u=await V_(c.file);if(!u)return void o(`${c.file.name}: not a text file`);const h=await c.handle;e.dispatch({a:"open-loose",v:{worktreeId:r,name:c.file.name,...u,binary:!1,source:h?{kind:"handle",handle:h}:{kind:"bytes"},seq:Lo()}}),a.length>1&&o(`opened ${c.file.name}; one file opens at a time`)}async function m3(e,t,n,r){const o=jw(e.getState(),n.worktreeId)??Ta(e),i=c=>o&&So(e,o,c),a={sock:t,dispatch:c=>e.dispatch(c)};for(const{file:c}of r){const u=await V_(c);if(!u){i(`${c.name}: not a text file`);continue}if(u.tooLarge){i(`${c.name}: too large to add here`);continue}const h=n.dir?`${n.dir}/${c.name}`:c.name,f=await $_(a,{worktreeId:n.worktreeId,path:h},u.text);f&&i(`${c.name}: ${f}`)}}function g3(e){const t=Ta(e);t&&So(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 Y_(e,t,n,r){const o=(_o==null?void 0:_o.refused)??!1;Rw(e),!(o||r.length===0)&&(n?n.at==="chat"||n.at==="centre"&&e.getState().newProject?G_(e,r):n.at==="centre"?p3(e,r):n.at==="rail"?k3(e,n,r):m3(e,t,n,r):g3(e))}function k3(e,t,n){const r=nn(e.getState(),t.worktreeId);r&&(e.dispatch(Nr(r.worktree)?{a:"open-draft"}:{a:"activate",id:r.worktree.id}),G_(e,n,Kl(r)))}const Ug=e=>!!e&&Array.from(e.types).includes("Files");function Qb(e,t){var c,u;const n=t instanceof Element?t:t instanceof Node?t.parentElement:null;if(!n)return null;if((c=Gc.el)!=null&&c.contains(n))return Ta(e)?{at:"chat"}:null;const r=(u=n.closest(".rail [data-wt]"))==null?void 0:u.dataset.wt;if(r)return nn(e.getState(),r)?{at:"rail",worktreeId:r}:null;const o=n.closest(".tree"),i=o==null?void 0:o.dataset.worktree;if(o&&i){const h=n.closest("[data-path]"),f=h==null?void 0:h.dataset.kind;if(f==="submodule")return null;const m=(h==null?void 0:h.dataset.path)??"";return{at:"tree",worktreeId:i,dir:f==="file"?L_(m):m}}if(!n.closest(".center-root")||n.closest('[data-pane="terminal"], [data-pane="design"]'))return null;const a=e.getState();return a.activeId||a.newProject?{at:"centre"}:null}function w3(){const e=Un(),t=tt();S.useEffect(()=>{const n=a=>{a.defaultPrevented||!Ug(a.dataTransfer)||(a.preventDefault(),Iw(e,Qb(e,a.target)),a.dataTransfer&&(a.dataTransfer.dropEffect=e.getState().dragFiles?"copy":"none"))},r=a=>{a.defaultPrevented||!Ug(a.dataTransfer)||(a.preventDefault(),Y_(e,t,Qb(e,a.target),f3(a.dataTransfer)))},o=()=>Z_(e),i=a=>{a.key==="Escape"&&l3(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 X_(e,t,n){const r=Un(),o=S.useRef(!1);return{onPaste:u=>{uz();const h=e3(u.clipboardData);if(h.length>0)return u.preventDefault(),void Ph(r,e,h);const f=t3(u.clipboardData);if(f.length>0)return u.preventDefault(),Nw(r,e,f);if(o.current)return;const m=u.clipboardData.getData("text/plain");if(m.trim()&&(n!=null&&n(m))){u.preventDefault();return}const g=m.trim()?hz(u.clipboardData,t):null;!(g&&m.includes(`
|
|
104
|
+
`))&&!eS(m)||(u.preventDefault(),Tw(r,e,m,g?{source:g}:{}))},onPasteKey:u=>{o.current=(u.metaKey||u.ctrlKey)&&u.shiftKey&&u.key.toLowerCase()==="v"},onPasteKeyUp:()=>{o.current=!1}}}function y3(e,t,n){const r=S.useRef(n);r.current=n,S.useEffect(()=>{const o=e.current;if(!o)return;const i=a=>{const{inputType:c,data:u,isComposing:h}=a;a.target!==t.current||h||!u||c!=="insertText"&&c!=="insertFromPaste"||r.current(u)&&a.preventDefault()};return o.addEventListener("beforeinput",i),()=>o.removeEventListener("beforeinput",i)},[e,t])}const v3=640,b3=1e3,Q_=`(max-width: ${v3}px), ((hover: none) and (max-width: ${b3}px))`,J_="(hover: none)",Ow=()=>{var e;return(e=window.matchMedia)!=null&&e.call(window,Q_).matches?"phone":"desk"},x3=()=>{var e;return((e=window.matchMedia)==null?void 0:e.call(window,J_).matches)??!1},eN=()=>window.top!==window;function E3(e){const t=(o,i)=>{var u;const a=(u=window.matchMedia)==null?void 0:u.call(window,o);if(!a)return()=>{};const c=h=>i(h.matches);return a.addEventListener("change",c),()=>a.removeEventListener("change",c)},n=t(Q_,o=>e.dispatch({a:"frame",v:o?"phone":"desk"})),r=t(J_,o=>e.dispatch({a:"touch",v:o}));return()=>{n(),r()}}const tN=(e,t)=>{const n=e.indexOf("#"),[r,o]=n===-1?[e,""]:[e.slice(0,n),e.slice(n)];return`${r}${r.includes("?")?"&":"?"}${TA}=${encodeURIComponent(t)}${o}`},Hg=(e,t)=>!e.serving&&t!==null,S3=3e3;function nN(e,t,n){const[r,o]=S.useState(()=>new Map),i=S.useRef(new Set),a=S.useRef(t);a.current=t;const c=S.useRef(new Map),u=S.useCallback((h,f)=>{i.current.has(h)||(i.current.add(h),gS(e.sock.urls).then(m=>{if(i.current.delete(h),!!a.current.some(w=>w.id===h&&w.url===f)){if(!m){c.current.set(h,setTimeout(()=>{c.current.delete(h),a.current.some(w=>w.id===h&&w.url===f)&&u(h,f)},S3));return}o(w=>new Map(w).set(h,{url:f,src:tN(f,m.code)}))}}))},[e]);return S.useEffect(()=>{const h=c.current;return()=>{for(const f of h.values())clearTimeout(f);h.clear()}},[]),S.useEffect(()=>{var f;if(!n)return;for(const m of t)((f=r.get(m.id))==null?void 0:f.url)!==m.url&&u(m.id,m.url);const h=new Set(t.map(m=>m.id));[...r.keys()].some(m=>!h.has(m))&&o(m=>new Map([...m].filter(([g])=>h.has(g))))},[n,t,r,u]),{urlOf:h=>{var f,m;return n?((f=r.get(h))==null?void 0:f.src)??null:((m=t.find(g=>g.id===h))==null?void 0:m.url)??null},renew:h=>{const f=t.find(m=>m.id===h);!f||!n||(o(m=>{const g=new Map(m);return g.delete(h),g}),u(h,f.url))}}}function _3(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}]),nN(e,r.current,n).urlOf("one")}function N3(e,t,n){if(!n){window.open(t,"_blank");return}const r=window.open("","_blank");gS(e.sock.urls).then(o=>{const i=o?tN(t,o.code):t;r?r.location.href=i:window.open(i,"_blank")})}function He(...e){return e.filter(Boolean).join(" ")}const T3={branch:"M4.5 5.1v5.8 M11.5 6.6c0 2.6-7 1.6-7 4.3 M4.5 1.9a1.6 1.6 0 1 0 0 3.2 1.6 1.6 0 1 0 0-3.2z M4.5 10.9a1.6 1.6 0 1 0 0 3.2 1.6 1.6 0 1 0 0-3.2z M11.5 3.4a1.6 1.6 0 1 0 0 3.2 1.6 1.6 0 1 0 0-3.2z",chat:"M2.5 3.5a1.5 1.5 0 0 1 1.5-1.5h8a1.5 1.5 0 0 1 1.5 1.5v6a1.5 1.5 0 0 1-1.5 1.5H7l-3.2 2.6V11H4a1.5 1.5 0 0 1-1.5-1.5z",settings:"M12.38 6.99 14.05 7.26 14.05 8.74 12.38 9.01 11.82 10.38 12.81 11.76 11.76 12.81 10.38 11.82 9.01 12.38 8.74 14.05 7.26 14.05 6.99 12.38 5.62 11.82 4.24 12.81 3.19 11.76 4.18 10.38 3.62 9.01 1.95 8.74 1.95 7.26 3.62 6.99 4.18 5.62 3.19 4.24 4.24 3.19 5.62 4.18 6.99 3.62 7.26 1.95 8.74 1.95 9.01 3.62 10.38 4.18 11.76 3.19 12.81 4.24 11.82 5.62z M8 6.4a1.6 1.6 0 1 0 0 3.2 1.6 1.6 0 1 0 0-3.2z",zen:"M2 6V3a1 1 0 0 1 1-1h3 M10 2h3a1 1 0 0 1 1 1v3 M14 10v3a1 1 0 0 1-1 1h-3 M6 14H3a1 1 0 0 1-1-1v-3",back:"M9.5 3.5 5 8l4.5 4.5",forward:"M6.5 3.5 11 8l-4.5 4.5",reload:"M13.5 2.5v3.5H10 M12.4 9.2a4.8 4.8 0 1 1-1-4.9l2.1 1.7",pick:"M8 4.2a3.8 3.8 0 1 0 0 7.6 3.8 3.8 0 1 0 0-7.6z M8 1.5v2.7 M8 11.8v2.7 M1.5 8h2.7 M11.8 8h2.7",inspect:"M6.5 13.5h-3a1 1 0 0 1-1-1v-9a1 1 0 0 1 1-1h9a1 1 0 0 1 1 1v3 M8.2 8.2l5.3 2-2.3.9-.9 2.3z",terminal:"M2 3a1 1 0 0 1 1-1h10a1 1 0 0 1 1 1v10a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1z M4.8 5.6 7.4 8l-2.6 2.4 M8.6 10.6h2.8",close:"M4.2 4.2 11.8 11.8 M11.8 4.2 4.2 11.8",edit:"M10.6 2.6 13.4 5.4 5.8 13H3v-2.8z M9.2 4l2.8 2.8 M3 10.2l2.8 2.8",check:"M3.4 8.4 6.4 11.4 12.6 4.6",split:"M2.5 2.5h11v11h-11z M2.5 8h11",full:"M2.5 2.5h11v11h-11z",more:"M3.55 8a.45 .45 0 1 0 .9 0a.45 .45 0 1 0-.9 0z M7.55 8a.45 .45 0 1 0 .9 0a.45 .45 0 1 0-.9 0z M11.55 8a.45 .45 0 1 0 .9 0a.45 .45 0 1 0-.9 0z",caret:"M4.5 6.5 8 10l3.5-3.5","caret-up":"M4.5 9.5 8 6l3.5 3.5",stop:"M4.5 4.5h7v7h-7z",send:"M8 13V3.2 M4 7.2 8 3.2l4 4",external:"M9 3h4v4 M13 3 8 8 M11.5 9.5V13H3V4.5h3.5",plus:"M8 3.5v9 M3.5 8h9",download:"M8 2.5v7.4 M4.9 6.8 8 9.9l3.1-3.1 M3 13h10",copy:"M5.5 5.5h8v8h-8z M10.5 5.5v-3h-8v8h3",pull:"M8 3.2v7.4 M4.9 7.4 8 10.6l3.1-3.2",layers:"M6 2.5h7.5V10 M2.5 6h8v7.5h-8z",text:"M3.5 3.5h9 M3.5 6.5h9 M3.5 9.5h9 M3.5 12.5h5",wrap:"M3.5 4h9 M3.5 8h7a2 2 0 0 1 0 4H8 M9.5 10.5 8 12l1.5 1.5 M3.5 12h2.5",file:"M4.5 2.5h4.5l2.5 2.5v8.5h-7z M9 2.5V5h2.5",diff:"M8 2.8v5 M5.5 5.3h5 M5.5 11.2h5",folder:"M2.2 3.9a1 1 0 0 1 1-1h2.9l1.5 1.7h5.2a1 1 0 0 1 1 1v5.9a1 1 0 0 1-1 1H3.2a1 1 0 0 1-1-1z",book:"M8 4.6c-1.2-1-2.7-1.4-4.4-1.3v7.6c1.7-.1 3.2.3 4.4 1.3 1.2-1 2.7-1.4 4.4-1.3V3.3c-1.7-.1-3.2.3-4.4 1.3z M8 4.6v8.6",eye:"M2 8c1.6-2.9 3.6-4.3 6-4.3s4.4 1.4 6 4.3c-1.6 2.9-3.6 4.3-6 4.3S3.6 10.9 2 8z M8 6.1a1.9 1.9 0 1 0 0 3.8 1.9 1.9 0 1 0 0-3.8z",trash:"M3.6 4.6h8.8 M6.4 4.6V3.2a.7.7 0 0 1 .7-.7h1.8a.7.7 0 0 1 .7.7v1.4 M5 4.6l.55 8.1a.9.9 0 0 0 .9.84h3.1a.9.9 0 0 0 .9-.84L11 4.6",move:"M2.8 8h9.2 M8.9 4.9 12 8l-3.1 3.1",search:"M7.2 2.6a4.6 4.6 0 1 0 0 9.2 4.6 4.6 0 1 0 0-9.2z M10.5 10.5 13.5 13.5",run:"M3.4 4.2 7.6 8l-4.2 3.8 M9 11.8h4",bulb:"M4.8 8.8a4 4 0 1 1 6.4 0L9.5 10.6v1.4H6.5v-1.4z M6.7 13.8h2.6",spawn:"M2.5 8h3.3 M5.8 8c2.2 0 2.2-3.6 4.4-3.6h1.5 M5.8 8c2.2 0 2.2 3.6 4.4 3.6h1.5 M12.05 4.4a.45 .45 0 1 0 .9 0a.45 .45 0 1 0-.9 0z M12.05 11.6a.45 .45 0 1 0 .9 0a.45 .45 0 1 0-.9 0z",globe:"M8 2.2a5.8 5.8 0 1 0 0 11.6 5.8 5.8 0 1 0 0-11.6z M2.2 8h11.6 M8 2.2c-3 3.4-3 8.2 0 11.6 3-3.4 3-8.2 0-11.6z",worktrees:"M3.8 2.95a1.05 1.05 0 1 0 0 2.1 1.05 1.05 0 1 0 0-2.1z M7.4 4h5.4 M3.8 6.95a1.05 1.05 0 1 0 0 2.1 1.05 1.05 0 1 0 0-2.1z M7.4 8h5.4 M3.8 10.95a1.05 1.05 0 1 0 0 2.1 1.05 1.05 0 1 0 0-2.1z M7.4 12h5.4",swap:"M3 6.2h9.2 M9.7 3.7 12.2 6.2 9.7 8.7 M13 10.2H3.8 M6.3 7.7 3.8 10.2l2.5 2.5",palette:"M2.3 8.4C2.3 4.7 5 2.2 8.5 2.2c3.4 0 5.2 2.2 5.2 4.6 0 1.9-1.4 2.6-2.7 2.8-.9.15-1.3.7-1.1 1.4.2.9-.5 2.2-2.1 2.2-3.2 0-5.5-2-5.5-4.8z M5 6.2a.5.5 0 1 0 0 1 .5.5 0 1 0 0-1z M7.8 4.9a.5.5 0 1 0 0 1 .5.5 0 1 0 0-1z M11 5.8a.5.5 0 1 0 0 1 .5.5 0 1 0 0-1z",lock:"M4.4 7.3h7.2v6.1H4.4z M6.2 7.3V5.5a1.8 1.8 0 0 1 3.6 0v1.8",phone:"M5.4 2.2h5.2a1.2 1.2 0 0 1 1.2 1.2v9.2a1.2 1.2 0 0 1-1.2 1.2H5.4a1.2 1.2 0 0 1-1.2-1.2V3.4a1.2 1.2 0 0 1 1.2-1.2z M7.1 11.6h1.8",laptop:"M3.4 3.4h9.2a1 1 0 0 1 1 1v6.2H2.4V4.4a1 1 0 0 1 1-1z M1.5 12.6h13",devices:"M8.8 11.2H3.2a1 1 0 0 1-1-1V4.2a1 1 0 0 1 1-1h8.8a1 1 0 0 1 1 1v1.3 M4.6 13.6h4.2 M10.6 6.9h3a.9.9 0 0 1 .9.9v5a.9.9 0 0 1-.9.9h-3a.9.9 0 0 1-.9-.9v-5a.9.9 0 0 1 .9-.9z M11.6 12.1h1",pr:"M4.5 5.1v5.8 M4.5 1.9a1.6 1.6 0 1 0 0 3.2 1.6 1.6 0 1 0 0-3.2z M4.5 10.9a1.6 1.6 0 1 0 0 3.2 1.6 1.6 0 1 0 0-3.2z M11.5 10.9a1.6 1.6 0 1 0 0 3.2 1.6 1.6 0 1 0 0-3.2z M11.5 10.9V6.6a2 2 0 0 0-2-2H8 M9.6 2.9 7.9 4.6l1.7 1.7",clock:"M8 2.2a5.8 5.8 0 1 0 0 11.6 5.8 5.8 0 1 0 0-11.6z M8 4.8V8l2.2 1.4",archive:"M2.4 3.2h11.2v2.8H2.4z M3.4 6v6.1a.9.9 0 0 0 .9.9h7.4a.9.9 0 0 0 .9-.9V6 M6.6 8.6h2.8",attach:"M13.7 7.4 8.2 12.9a3.6 3.6 0 0 1-5.1-5.1l5.5-5.5a2.4 2.4 0 0 1 3.4 3.4l-5.5 5.5a1.2 1.2 0 0 1-1.7-1.7l5.1-5.1",cube:"M8 2.4 13.2 5.2v5.6L8 13.6 2.8 10.8V5.2z M2.8 5.2 8 8l5.2-2.8 M8 8v5.6",dot:"M8 4.6a3.4 3.4 0 1 0 0 6.8 3.4 3.4 0 1 0 0-6.8z"};function St({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:T3[e]})})}function Kf({className:e}){return d.jsxs("span",{className:He("spinner",e),"aria-hidden":"true",children:[d.jsx("span",{}),d.jsx("span",{}),d.jsx("span",{}),d.jsx("span",{})]})}const j3='button, a[href], input, textarea, select, summary, label, [role="button"], [role="menuitem"]';function Jb(e){var n;const t=e;return((n=t==null?void 0:t.closest)==null?void 0:n.call(t,j3))??t??null}function $3(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 C3(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 A3(e,t){const n=new Set;for(const r of e)if($3(r,t))for(let o=r;o;o=o.parent)n.add(o);return e.filter(r=>!n.has(r)&&r.dismiss).reverse()}const I3=e=>{setTimeout(e,0)};function R3({schedule:e=I3}={}){let t=[],n=null,r=!1;const o=new Set,i=()=>{for(const c of[...o])c()},a=c=>{var u;for(const h of[...t].reverse())(u=h.dismiss)==null||u.call(h,c)};return{register(c){const u=c.trigger??(c.from===void 0?n:null),h={box:c.box,trigger:u,parent:C3(t,c.from??u),dismiss:c.dismiss,onKey:c.onKey,back:c.back};return t=[...t,h],i(),h},unregister(c){t=t.filter(u=>u!==c),i()},top:()=>t[t.length-1]??null,open:()=>t,watch(c){return o.add(c),()=>o.delete(c)},shut(c){var u;c.back?c.back():(u=c.dismiss)==null||u.call(c,"outside")},install(c){const u=c.document,h=v=>{var _;const N=v.target,x=N?A3(t,N):[];for(const T of x)(_=T.dismiss)==null||_.call(T,"outside");r=x.length>0&&v.pointerType==="touch",r&&v.preventDefault(),n=Jb(v.target)},f=()=>e(()=>n=null),m=()=>{r=!1,f()},g=v=>{if(r){r=!1,v.preventDefault(),v.stopPropagation();return}n||(n=Jb(v.target),f())},w=v=>{var x;const N=t[t.length-1];(x=N==null?void 0:N.onKey)==null||x.call(N,v)},y=()=>e(()=>{var v;((v=u.activeElement)==null?void 0:v.tagName)==="IFRAME"&&a("frame")});return u.addEventListener("pointerdown",h,!0),u.addEventListener("pointerup",f,!0),u.addEventListener("pointercancel",m,!0),u.addEventListener("click",g,!0),c.addEventListener("keydown",w,!0),c.addEventListener("blur",y),()=>{u.removeEventListener("pointerdown",h,!0),u.removeEventListener("pointerup",f,!0),u.removeEventListener("pointercancel",m,!0),u.removeEventListener("click",g,!0),c.removeEventListener("keydown",w,!0),c.removeEventListener("blur",y)}}}}const zl=R3(),O3=()=>zl.open().some(e=>!!e.dismiss);function M3(){return S.useSyncExternalStore(zl.watch,O3,()=>!1)}const Um=typeof HTMLElement<"u"&&"showPopover"in HTMLElement.prototype,ex=e=>(e==null?void 0:e.getBoundingClientRect())??null;function P3(e,t,n,r){const o=e.querySelector(t);if(!o)return null;const i=e.getBoundingClientRect(),a=o.getBoundingClientRect();return{offset:n==="top"?i.bottom-a.bottom:a.top-i.top,alignOffset:r==="end"?i.right-a.right:a.left-i.left}}function Ls({className:e,anchor:t,placement:n,coverBy:r,track:o=t==="parent",raiseKey:i,onDismiss:a,onKey:c,onBack:u,trigger:h,from:f,boxRef:m,handle:g,children:w,...y}){const v=S.useRef(null),N=S.useRef({anchor:t,placement:n,coverBy:r,onDismiss:a,onKey:c,onBack:u,trigger:h,from:f});N.current={anchor:t,placement:n,coverBy:r,onDismiss:a,onKey:c,onBack:u,trigger:h,from:f};const x=S.useCallback(()=>{const T=v.current,{anchor:j,placement:C,coverBy:M}=N.current;if(!T||!j||!C)return;const I=j==="parent"?ex(T.parentElement):j();if(!I)return;const O=pz(I,C);O!==void 0&&(T.style.width=`${O}px`);for(let A=0;A<2;A++){const z=M?P3(T,M,T.dataset.side??"",T.dataset.align??""):null,B=gz(I,{w:T.offsetWidth,h:T.offsetHeight},{w:window.innerWidth,h:window.innerHeight},z?{...C,...z}:C);T.style.left=`${B.x}px`,T.style.top=`${B.y}px`;const U=T.dataset.side!==B.side||T.dataset.align!==B.align;if(T.dataset.side=B.side,T.dataset.align=B.align,!U)break}},[]);S.useImperativeHandle(g,()=>({update:x}),[x]),S.useLayoutEffect(()=>{const T=v.current;if(!T)return;m&&(m.current=T),Um&&(T.popover="manual",T.matches(":popover-open")||T.showPopover());const{onDismiss:j,onKey:C,onBack:M,trigger:I,from:O}=N.current,A=j||C?zl.register({box:T,trigger:I,from:O,dismiss:j?z=>{var B,U;return(U=(B=N.current).onDismiss)==null?void 0:U.call(B,z)}:void 0,onKey:C?z=>{var B,U;return(U=(B=N.current).onKey)==null?void 0:U.call(B,z)}:void 0,back:M?()=>{var z,B;return(B=(z=N.current).onBack)==null?void 0:B.call(z)}:void 0}):null;return()=>{A&&zl.unregister(A),m&&(m.current=null),Um&&T.isConnected&&T.matches(":popover-open")&&T.hidePopover()}},[m]),S.useLayoutEffect(x),S.useLayoutEffect(()=>{if(!o)return;let T=0,j="";const C=()=>{const M=v.current,{anchor:I}=N.current,O=M&&I?I==="parent"?ex(M.parentElement):I():null;if(M&&O){const A=`${O.left},${O.top},${O.right},${O.bottom},${M.offsetWidth},${M.offsetHeight},${window.innerWidth},${window.innerHeight}`;A!==j&&(j=A,x())}T=requestAnimationFrame(C)};return T=requestAnimationFrame(C),()=>cancelAnimationFrame(T)},[o,x]);const _=S.useRef(!0);return ut([i],()=>{if(_.current){_.current=!1;return}const T=v.current;!Um||!(T!=null&&T.matches(":popover-open"))||(T.hidePopover(),T.showPopover(),x())}),d.jsx("div",{ref:v,className:He("float",e),...y,children:w})}const L3=/^[⌘⇧⌥⌃]+/;function os({k:e,chip:t=!1,className:n}){var a;const r=(a=e.match(L3))==null?void 0:a[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 Pt(e,t,{placement:n,detail:r,card:o,dot:i,name:a,aside:c,also:u}={}){const h=a?`${e}: ${a}`:e,f=(Array.isArray(r)?r:[r]).filter(g=>!!g),m=[h,...f,...c??[]].join(", ");return{"data-tip":e,"data-tip-key":t,"data-tip-placement":n,"data-tip-detail":f.length?f.join(`
|
|
105
|
+
`):void 0,"data-tip-card":o||a||c!=null&&c.length?"":void 0,"data-tip-dot":i,"data-tip-name":a,"data-tip-aside":c!=null&&c.length?c.join(`
|
|
106
|
+
`):void 0,"data-tip-also":u==null?void 0:u.text,"data-tip-also-key":u==null?void 0:u.key,"aria-label":t?`${m} (${t})`:m}}const D3=120,z3=600,F3=150,tx=6,B3=18,Hm=8;function nx(e){const t=e.dataset.tipPlacement;return t==="follow"||t==="top"||t==="bottom"||t==="left"||t==="right"?t:"bottom"}function rN(e){return e==="follow"?{side:"bottom",align:"start",offset:B3,alignOffset:-12,flip:"both",margin:Hm}:e==="left"||e==="right"?{side:e,align:"start",offset:tx,flip:"both",margin:Hm}:{side:e,align:"center",offset:tx,flip:"side",margin:Hm}}function U3(e,t){return e.placement==="follow"?b_(t):e.el.getBoundingClientRect()}function oN(){var u;const[e,t]=S.useState(null),n=S.useRef(null),r=S.useRef(null),o=S.useRef({x:0,y:0}),i=Na();if(S.useEffect(()=>{if(i)return;let h=0,f=0,m=null,g=!1,w=0;const y=()=>{window.clearTimeout(h),window.clearTimeout(f)},v=()=>{y(),g&&(w=Date.now()),g=!1,m=null,t(null)},N=(O,A)=>{var B,U;const z=O.dataset.tip;if(!z)return v();y(),g=!0,t({el:O,text:z,key:O.dataset.tipKey,detail:(B=O.dataset.tipDetail)==null?void 0:B.split(`
|
|
107
|
+
`),card:O.dataset.tipCard!==void 0,dot:O.dataset.tipDot,name:O.dataset.tipName,aside:(U=O.dataset.tipAside)==null?void 0:U.split(`
|
|
108
|
+
`),also:O.dataset.tipAlso&&O.dataset.tipAlsoKey?{text:O.dataset.tipAlso,key:O.dataset.tipAlsoKey}:void 0,placement:A})},x=O=>{const A=O.target;if(!(A instanceof Element))return null;const z=A.closest("[data-tip], .float");return(z==null?void 0:z.dataset.tip)!==void 0?z:null},_=O=>{o.current={x:O.clientX,y:O.clientY};const A=x(O);if(A===m)return;if(y(),m=A,!A){g&&(f=window.setTimeout(v,F3));return}const z=nx(A);if(g||Date.now()-w<z3)return N(A,z);h=window.setTimeout(()=>N(A,z),D3)},T=O=>{O.relatedTarget||v()},j=O=>{const A=x(O);if(A!=null&&A.matches(":focus-visible")){y(),m=A;const z=nx(A);N(A,z==="follow"?"bottom":z)}},C=()=>v(),M=O=>{O.key!=="Shift"&&O.key!=="Control"&&O.key!=="Alt"&&O.key!=="Meta"&&v()},I=O=>{m&&O.target instanceof Node&&O.target.contains(m)&&v()};return document.addEventListener("mouseover",_),document.addEventListener("mouseout",T),document.addEventListener("mousedown",v),document.addEventListener("keydown",M),document.addEventListener("scroll",I,!0),document.addEventListener("focusin",j),document.addEventListener("focusout",C),window.addEventListener("blur",v),()=>{y(),document.removeEventListener("mouseover",_),document.removeEventListener("mouseout",T),document.removeEventListener("mousedown",v),document.removeEventListener("keydown",M),document.removeEventListener("scroll",I,!0),document.removeEventListener("focusin",j),document.removeEventListener("focusout",C),window.removeEventListener("blur",v)}},[i]),S.useLayoutEffect(()=>{e&&!e.el.isConnected&&t(null)},[e]),S.useEffect(()=>{if((e==null?void 0:e.placement)!=="follow")return;const h=f=>{var m;o.current={x:f.clientX,y:f.clientY},(m=r.current)==null||m.update()};return document.addEventListener("mousemove",h),()=>document.removeEventListener("mousemove",h)},[e]),!e)return null;const a=d.jsxs(d.Fragment,{children:[e.dot&&d.jsx("span",{className:`dot ${e.dot} tooltip-dot`}),e.text]}),c=d.jsxs(d.Fragment,{children:[a,e.key&&d.jsx(os,{k:e.key,className:"tooltip-key"})]});return d.jsxs(Ls,{className:He("tooltip",e.card&&"tooltip-card"),role:"tooltip",boxRef:n,handle:r,anchor:()=>U3(e,o.current),placement:rN(e.placement),track:!1,raiseKey:e,children:[e.also?d.jsxs("div",{className:"tooltip-pair",children:[d.jsx("span",{children:a}),e.key?d.jsx(os,{k:e.key,className:"tooltip-key"}):d.jsx("span",{}),d.jsx("span",{className:"tooltip-also",children:e.also.text}),d.jsx(os,{k:e.also.key,className:"tooltip-key"})]}):e.name?d.jsxs("div",{className:"tooltip-head",children:[d.jsx("span",{children:c}),d.jsx("span",{className:"tooltip-name",children:e.name})]}):c,(u=e.detail)==null?void 0:u.map((h,f)=>d.jsx("div",{className:"tooltip-detail",children:h},f)),e.aside&&d.jsx("div",{className:"tooltip-foot",children:e.aside.map(h=>d.jsx("span",{children:h},h))})]})}const H3={sm:"",md:"btn-md",lg:"btn-lg"},W3={ghost:"",outline:"btn-outline",field:"btn-outline btn-field",inline:"btn-inline"},sN={primary:"tone-primary",quiet:"tone-quiet",danger:"tone-danger",strong:"tone-strong",chrome:"tone-chrome"};function De({variant:e="ghost",size:t="sm",tone:n,on:r,mono:o,busy:i,className:a,type:c="button",disabled:u,children:h,...f}){const m=He("btn",W3[e],H3[t],n&&sN[n],r&&"on",o&&"btn-mono",i&&"btn-busy",a);return d.jsxs("button",{className:m,type:c,disabled:i||u,"aria-busy":i||void 0,...f,children:[i&&d.jsx(Kf,{}),h]})}function Rt({icon:e,label:t,hint:n,detail:r,also:o,silent:i,badge:a,tone:c,on:u,className:h,type:f="button",...m}){const g=He("btn-icon",c&&sN[c],u&&"on",h),w=Pt(t,n,{detail:r,also:o});return d.jsxs("button",{className:g,type:f,...i?{"aria-label":w["aria-label"]}:w,...m,children:[typeof e=="string"?d.jsx(St,{name:e}):e,a]})}function $u(e,t,n){return n===0?0:(e+t+n)%n}function rx(e,t,n){return e>=0?$u(e,t,n):n===0?-1:t>0?0:n-1}function iN(e,t,n){var i;const r=e.length,o=n.toLowerCase();for(let a=1;a<=r;a++){const c=(Math.max(t,-1)+a)%r;if((i=e[c])!=null&&i.trim().toLowerCase().startsWith(o))return c}return-1}function Wm(e,t){return e&&e.length>t.length&&e.toLowerCase().startsWith(t.toLowerCase())?e.slice(t.length):null}function K3(e,t){if(e==null)return null;if(typeof e=="string"){const o=Wm(e,t);return o?{text:o,accept:o,params:[]}:null}const n=Wm(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:Wm(e.accept,t),params:r}}function aN(e){const{results:t,keyOf:n,q:r,onPick:o,listRef:i,onActive:a,onSide:c,completionOf:u,narrowTo:h,setQ:f,tabPicks:m,onIdlePick:g}=e,[w,y]=S.useState(()=>{var M;return e.idle?-1:Math.max(0,((M=e.initialIndex)==null?void 0:M.call(e,t))??0)}),v=w>=0&&t[w]?n(t[w]):null,N=S.useRef(a);N.current=a,ut([v],()=>{var M,I,O;(I=(M=i.current)==null?void 0:M.querySelector('.picker-item[data-state~="cursor"]'))==null||I.scrollIntoView({block:"nearest"}),(O=N.current)==null||O.call(N,w>=0?t[w]??null:null)});const x=w<0?-1:Math.min(w,Math.max(0,t.length-1)),_=x>=0?t[x]??null:null,T=_?K3(u==null?void 0:u(_,r),r):null,j=M=>{const I=h==null?void 0:h(M,r);if(I==null)return o(M,r);f==null||f(I),y(0)};return{index:x,active:_,ghost:T,setIndex:y,pick:j,onKeyDown:M=>{if(M.key==="ArrowDown")M.preventDefault(),y(rx(x,1,t.length));else if(M.key==="ArrowUp")M.preventDefault(),y(rx(x,-1,t.length));else if((M.key==="ArrowLeft"||M.key==="ArrowRight")&&c&&_)M.preventDefault(),c(_,M.key==="ArrowLeft"?-1:1);else if(M.key==="Tab"&&(T!=null&&T.accept))M.preventDefault(),f==null||f(r+T.accept),y(0);else if(M.key==="Tab"&&m&&_)M.preventDefault(),j(_);else if(M.key==="Enter"&&_)M.preventDefault(),j(_);else if(M.key==="Enter"&&x<0&&g)M.preventDefault(),g(r);else return!1;return!0}}}function ur(e){const t=Object.keys(e).filter(n=>e[n]);return t.length>0?t.join(" "):void 0}const Z3=new Set(["Shift","Meta","Control","Alt","CapsLock","Fn"]);function lN(){const e=_w(),t=Un();return S.useEffect(()=>{if(!e)return;const n=()=>{e.target.isConnected||uo.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(q3,{spec:e},e.id):null}function q3({spec:e}){const t=e.items,n=t.filter(gs),[r,o]=S.useState(-1),i=S.useRef({idx:r,items:n});i.current={idx:r,items:n};const a=S.useRef(null),c=m=>{var g,w;{const y=()=>uo.close(),{idx:v,items:N}=i.current;if(Z3.has(m.key))return;if(m.key==="ArrowDown"||m.key==="ArrowUp"){m.preventDefault(),m.stopPropagation();const x=m.key==="ArrowDown"?1:-1;o(kz(N,v,x));return}if((m.key==="Enter"||m.key===" ")&&v>=0&&N[v]&&!N[v].disabled){m.preventDefault(),m.stopPropagation(),N[v].onClick(),y();return}if(m.key==="Escape"){m.stopPropagation(),y();return}if(m.key.length===1&&!m.metaKey&&!m.ctrlKey&&!m.altKey){m.preventDefault(),m.stopPropagation();const x=Array.from(((g=a.current)==null?void 0:g.querySelectorAll(".menu-label"))??[],T=>T.textContent??""),_=iN(x,v,m.key);_>=0&&!((w=N[_])!=null&&w.disabled)&&o(_);return}y()}};S.useEffect(()=>{const m=()=>uo.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}=vz(e),f=n.some(m=>m.checked);return d.jsxs(Ls,{className:He("menu",e.head!==void 0&&"menu-headed"),role:"menu",boxRef:a,anchor:()=>u,placement:h,track:!1,from:e.target,trigger:e.toggles?e.target:null,onDismiss:()=>uo.close(),onKey:c,onContextMenu:m=>m.preventDefault(),children:[e.head!==void 0&&d.jsx("div",{className:"menu-head",children:e.head}),t.map((m,g)=>{if(!gs(m))return d.jsx("hr",{className:"menu-sep"},`sep-${g}`);const w=n.indexOf(m);return d.jsx(G3,{item:m,gutter:f,cursor:w===r,onEnter:()=>o(w)},m.id)})]})}function G3({item:e,gutter:t,cursor:n,onEnter:r}){const o=e.disabled!==void 0,i=e.detail??e.disabled;return d.jsxs("button",{...e.checked===void 0?{role:"menuitem"}:{role:"menuitemcheckbox","aria-checked":e.checked},"aria-disabled":o||void 0,className:He("row row-keyed",e.danger&&"danger",i!==void 0&&"row-tall",o&&"disabled"),"data-state":ur({cursor:n,checked:e.checked}),onMouseMove:o||n?void 0:r,onClick:()=>{o||(e.onClick(),uo.close())},children:[t&&d.jsx("span",{className:"menu-check",children:e.checked&&d.jsx(St,{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(os,{k:e.key,className:"menu-key row-dim"})]})}const Zf=8,V3=104,Y3=.25,cN=220,Wg=.5,X3=100;function Q3(e,t){return Math.max(0,-uN(e,t))}function uN(e,t){const n=e.filter(a=>t-a.t<=X3);if(n.length<2)return 0;const r=n[0],o=n[n.length-1],i=o.t-r.t;return i>0?(o.x-r.x)/i:0}function J3(e,t,n){return e>0?e:n>0&&t>=Wg?1:0}function e5({dx:e,dy:t}){return Math.abs(e)<Zf&&Math.abs(t)<Zf?null:Math.abs(e)>Math.abs(t)&&e<0?"slide":"other"}function t5(e,t,n=V3){const r=Math.max(0,-e),o=t*n,i=Math.min(t,Math.floor(r/n)),a=r<=o?r:o+(r-o)*Y3,c=Math.min(1,r/(n/2));return{step:i,x:-a,well:c}}function dN(e,t){const n=S.useRef(t);n.current=t,S.useEffect(()=>{const r=e.current;if(!r)return;let o=null,i=null,a=!1,c=0,u=[],h=0,f=0;const m=(T,j,C,M)=>{T.el.dataset.slide!==M&&(T.el.dataset.slide=M,T.el.offsetWidth),T.el.style.setProperty("--slide-x",`${j}px`),T.el.style.setProperty("--slide-well",`${Math.round(C*100)}%`)},g=T=>{T.el.style.removeProperty("--slide-x"),T.el.style.removeProperty("--slide-well"),delete T.el.dataset.slide},w=(T=0)=>{var O;const j=o,C=a,M=j?J3(c,T,j.rungs):0,I=M!==c;o=null,i=null,a=!1,c=0,u=[],!(!j||!C)&&(I&&(n.current.onSlide({key:j.key,step:M}),(O=navigator.vibrate)==null||O.call(navigator,8)),m(j,0,0,"settle"),M>0&&n.current.onPick(j.key,M),h=window.setTimeout(()=>{g(j),n.current.onSlide(null)},cN))};let y=null;const v=T=>{if(!T.isPrimary||T.pointerType==="mouse"&&T.button!==0)return w();const j=T.target instanceof Element?n.current.rowOf(T.target):null;!j||j.el.dataset.slide||(window.clearTimeout(h),o=j,y=T.pointerId,i={x:T.clientX,y:T.clientY})},N=T=>{var O;const j=o;if(!j||!i||T.pointerId!==y)return;const C=T.clientX-i.x,M=T.clientY-i.y;if(!a){const A=e5({dx:C,dy:M});if(A==="other"&&(o=null,i=null,y=null),A!=="slide")return;a=!0;try{j.el.setPointerCapture(T.pointerId)}catch{}n.current.onSlide({key:j.key,step:0})}u.push({x:T.clientX,t:T.timeStamp}),u.length>8&&u.shift();const I=t5(C,j.rungs,j.rung);m(j,I.x,I.well,"drag"),I.step!==c&&(c=I.step,n.current.onSlide({key:j.key,step:c}),c>0&&((O=navigator.vibrate)==null||O.call(navigator,8)))},x=T=>{T.pointerId===y&&(a&&(f=T.timeStamp+400),y=null,w(T.type==="pointerup"?Q3(u,T.timeStamp):0))},_=T=>{T.timeStamp>=f||(T.preventDefault(),T.stopPropagation())};return r.addEventListener("pointerdown",v),r.addEventListener("pointermove",N),r.addEventListener("pointerup",x),r.addEventListener("pointercancel",x),r.addEventListener("click",_,!0),()=>{window.clearTimeout(h),r.removeEventListener("pointerdown",v),r.removeEventListener("pointermove",N),r.removeEventListener("pointerup",x),r.removeEventListener("pointercancel",x),r.removeEventListener("click",_,!0)}},[e])}const fN=1/3,n5=220;function r5({dx:e,dy:t}){return Math.abs(e)<Zf&&Math.abs(t)<Zf?null:Math.abs(e)<=Math.abs(t)?"other":e<0?"left":"right"}function o5(e,t,n){return n==="left"?Math.min(0,Math.max(-t,e)):Math.max(0,Math.min(t,e))}function s5(e,t,n,r){const o=n==="left"?-r:r;return o>=Wg?!0:o<=-Wg?!1:Math.abs(e)>=t*fN}function i5(e,t){for(let n=e;n!==t&&n instanceof HTMLElement;n=n.parentElement){const r=getComputedStyle(n).overflowX;if((r==="auto"||r==="scroll")&&n.scrollWidth>n.clientWidth+1)return n}return null}const ox=-1;function a5(e,t){const n=S.useRef(t);n.current=t;const r=S.useRef(()=>{});return S.useEffect(()=>{const o=e.current;if(!o)return;let i=null,a=null,c=null,u=!1,h=0,f=null,m=null,g=0,w=null,y=[],v=0,N=0;const x=(U,Q)=>{const ae=m;ae&&(ae.dataset.swipe!==Q&&(ae.dataset.swipe=Q,ae.offsetWidth),ae.style.translate=`${U}px`)},_=()=>{const U=m;m=null,U&&(delete U.dataset.swipe,U.offsetWidth,U.style.removeProperty("translate"))},T=()=>{i=null,a=null,c=null,u=!1,f=null,g=0,w=null,y=[]},j=U=>{try{o.setPointerCapture(U.pointerId)}catch{}},C=U=>{var ee,de;const Q=f,ae=(m==null?void 0:m.clientWidth)??0;T(),Q&&(x(U?Q==="left"?-ae:ae:0,"settle"),(de=(ee=n.current).onSettle)==null||de.call(ee,U),v=window.setTimeout(()=>{nE.flushSync(()=>n.current.onEnd(U)),_()},n5))},M=U=>{var ae;if(U.pointerType==="mouse")return;if(!U.isPrimary)return f?C(!1):T();if(m||(((ae=window.visualViewport)==null?void 0:ae.scale)??1)>1.01)return;const Q=U.target instanceof Element?U.target:null;!Q||Q.closest("textarea, input, [contenteditable], iframe, .float")||(window.clearTimeout(v),i={x:U.clientX,y:U.clientY},a=Q,c=i5(Q,o),w=U.pointerId,h=U.clientX)},I=(U,Q,ae,ee)=>{if(!i||!a)return;const de=U-i.x,$=Q-i.y;if(u&&c){c.scrollLeft-=U-h,h=U;return}if(!f){const K=r5({dx:de,dy:$});if(K===null)return;if(K==="other")return T();if(c){u=!0,h=U,ee&&j(ee);return}const V=n.current.take(a,K);if(!V)return T();m=V,f=K,ee&&j(ee)}y.push({x:U,t:ae}),y.length>8&&y.shift(),g=o5(de,(m==null?void 0:m.clientWidth)??0,f),x(g,"drag")},O=(U,Q)=>{var $;if(!f)return T();const ae=(m==null?void 0:m.clientWidth)??0,ee=Q?uN(y,U):0,de=Q&&s5(g,ae,f,ee);de&&Math.abs(g)<ae*fN&&(($=navigator.vibrate)==null||$.call(navigator,8)),C(de)},A=U=>{U.pointerId===w&&I(U.clientX,U.clientY,U.timeStamp,U)},z=U=>{U.pointerId===w&&((f||u)&&(N=U.timeStamp+400),O(U.timeStamp,U.type==="pointerup"))};r.current=U=>{const Q=performance.now();if(U.phase==="start"){if(m||i)return;i={x:U.x,y:U.y},a=o,c=null,w=ox;return}if(w===ox){if(U.phase==="move")return I(U.x+g,U.y,Q);O(Q,U.phase==="end")}};const B=U=>{U.timeStamp>=N||(U.preventDefault(),U.stopPropagation())};return o.addEventListener("pointerdown",M),o.addEventListener("pointermove",A),o.addEventListener("pointerup",z),o.addEventListener("pointercancel",z),o.addEventListener("click",B,!0),()=>{r.current=()=>{},window.clearTimeout(v),o.removeEventListener("pointerdown",M),o.removeEventListener("pointermove",A),o.removeEventListener("pointerup",z),o.removeEventListener("pointercancel",z),o.removeEventListener("click",B,!0)}},[e]),S.useCallback(o=>r.current(o),[])}function Lh({items:e,current:t,onPick:n,fill:r,font:o,segmented:i,quiet:a,end:c,label:u,owner:h}){const f=wn(h),m=S.useRef(null),g=Math.max(0,e.findIndex(y=>y.id===t)),w=y=>{var x,_;if(y.key!=="ArrowLeft"&&y.key!=="ArrowRight")return;y.preventDefault();const v=e.findIndex(T=>T.id===t),N=e[$u(v,y.key==="ArrowRight"?1:-1,e.length)];N&&(n(N.id),(_=(x=m.current)==null?void 0:x.querySelectorAll('[role="tab"]')[e.indexOf(N)])==null||_.focus())};return d.jsxs("div",{className:He("tabs",r&&"tabs-fill",o==="mono"&&"tabs-mono",i&&"tabs-segmented",a&&"tabs-quiet"),children:[d.jsx("div",{className:"tabs-list",role:"tablist","aria-label":u,ref:m,onKeyDown:w,style:i?{"--tabs-at":g,"--tabs-count":e.length}:void 0,children:e.map(y=>{const v=y.id===t;return d.jsxs("div",{className:He("tab",v&&!!y.trail&&"tab-trailed",y.fit&&"tab-fit",y.far&&"tab-far"),"data-state":ur({current:v}),...y.menu?f.contextMenu(y.menu):{},children:[d.jsxs("button",{type:"button",className:"tab-btn",role:"tab","aria-selected":v,tabIndex:v?0:-1,onClick:()=>n(y.id),...y.tip,...y.ariaLabel?{"aria-label":y.ariaLabel}:{},children:[y.lead,y.label]}),v&&y.trail&&d.jsx("span",{className:"tab-trail",children:y.trail})]},y.id)})}),c&&d.jsx("span",{className:"tabs-end",children:c})]})}function ys({anchor:e="top",wide:t,foot:n,children:r}){const o=d.jsx("div",{className:He("view",e==="line"&&"view-anchored",t&&"view-wide"),children:r});return n?d.jsxs("div",{className:"view-stack",children:[o,n]}):o}const hN=e=>`Toyon restarts once ${e.join(", ")} ${e.length===1?"finishes":"finish"}`,l5=(e,t)=>[...e,...t.filter(n=>!e.includes(n))];function c5(e,t,n){const r=[...t],o=[...n],i=(c,u)=>{const h=c.indexOf(u);return h===-1?!1:(c.splice(h,1),!0)};return[...e.map(c=>i(r,c)?{name:c,dot:"working",note:null}:i(o,c)?{name:c,dot:"waiting",note:"asking you"}:{name:c,dot:"idle",note:"finished"}),...o.map(c=>({name:c,dot:"waiting",note:"asking you"}))]}function u5(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 d5(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:hN(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 Kg=!1;function f5(){Kg=!0}function iu({title:e,body:t,action:n,pane:r,children:o}){return d.jsxs("div",{className:He("crash",r&&"in-pane"),children:[d.jsx("div",{className:"crash-title",children:e}),t&&d.jsx("div",{className:"crash-body",children:t}),o,n]})}const sx={title:"Toyon was updated",body:"This page is still running the old build. Reload to pick up the new one."};class Mw extends S.Component{constructor(){super(...arguments);Et(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(iu,{pane:this.props.pane,title:Kg?sx.title:"Toyon hit an error",body:Kg?sx.body:n.message||String(n),action:d.jsx(De,{variant:"outline",onClick:()=>window.location.reload(),children:"reload"})}):this.props.children}}const Zg={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.`},h5=1e3,ix={held:[],asking:[],seen:[]};async function ax(e,t,n){for(;;){await new Promise(i=>setTimeout(i,h5));const[r,o]=await Promise.all([Tg(e),hS(e)]);if(r!==null&&r!==t)break;n(o??{waiting:[],asking:[]})}window.location.reload()}function pN({foreign:e}={}){return e?d.jsx(p5,{name:e}):d.jsx(m5,{})}function p5({name:e}){const t=is(),n=t.list()[0];return d.jsx(iu,{title:`Toyon on ${e} was updated`,body:Zg.foreign(e),action:n&&d.jsxs(De,{variant:"outline",onClick:()=>t.activate(n.origin),children:["back to ",t.displayName(n.origin)]})})}function m5(){const e=Wr(),[t,n]=S.useState(!0),[r,o]=S.useState(null),[i,a]=S.useState(ix),c=S.useRef(null),u=S.useCallback(y=>a(v=>({held:y.waiting,asking:y.asking,seen:l5(v.seen,y.waiting)})),[]),h=S.useCallback(async y=>{n(!0),o(null);const v=c.current??{pid:await Tg(e)},N=await IL(e,y);if(N){n(c.current!==null),o(N);return}y&&a(ix),!c.current&&(c.current=v,ax(e,v.pid,u))},[u,e]);S.useEffect(()=>{let y=!0;return(async()=>{const[v,N]=await Promise.all([Tg(e),hS(e)]);if(!(!y||c.current)){if(N===null){h(!1);return}c.current={pid:v},u(N),ax(e,v,u)}})(),()=>{y=!1}},[u,h,e]);const f=t&&i.held.length>0,m=f?c5(i.seen,i.held,i.asking):[],g=m.filter(y=>y.dot==="working").length,w=m.filter(y=>y.dot!=="waiting").length;return d.jsx(iu,{title:Zg.title,body:r??(f?u5(g,w):Zg.waiting),action:f?d.jsx(De,{variant:"outline",onClick:()=>void h(!0),children:"restart now"}):d.jsx(De,{variant:"outline",busy:t,onClick:()=>void h(!1),children:"restart"}),children:m.length>0&&d.jsx("ul",{className:"crash-list",children:m.map((y,v)=>d.jsxs("li",{className:He("crash-row",y.dot!=="working"&&"row-dim"),children:[d.jsx("span",{className:He("dot",y.dot)}),d.jsx("span",{className:"crash-row-name",children:y.name}),y.note&&d.jsx("span",{className:"crash-row-note",children:y.note})]},v))})})}const ha=(e,t=!1)=>({text:e,live:t}),g5={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"},k5={probing:e=>`connecting to ${e}`,down:e=>`Toyon on ${e} is not answering.
|
|
109
|
+
is Tailscale on here, and is Toyon running there?`,blocked:e=>`Toyon on ${e} is up, but this page's websocket to it never connected.
|
|
110
|
+
a proxy, VPN or browser extension is the usual cause`,unauthorized:e=>`this page's token for ${e} is not the one running there.
|
|
111
|
+
forget ${e} here and pair it again`},w5="no access token for this address.\nrun `toyon` or `toyon open` in your repo to get a signed-in page";function mN(e){if(e.standing&&!e.connected&&e.connectFailure!=="unauthorized")return null;if(!e.connected&&(!e.heard||e.connectFailure)){const t=e.connectFailure===null;return e.machine?ha(k5[e.connectFailure??"probing"](e.machine),t):e.hasToken?ha(g5[e.connectFailure??"probing"],t):ha(w5)}return e.title===null?ha(e.heard?`nothing open yet.
|
|
112
|
+
press ${e.projectChord} to open a project, or type a name there to start a new one`:""):null}function y5(e){const t=mN(e);return t!==null?t:e.needsSetup&&e.busy?ha(`building in ${e.title}; the preview appears once it starts`,!0):e.needsSetup&&e.treeEmpty?ha(`${e.title} is empty so far; say what to build`):e.treeEmpty&&e.landsFrom?ha(`nothing runs on main until ${e.landsFrom} lands`):null}const dn={post:(e,t)=>{},broadcast:e=>{}};function au(e,t,n,r){const o=t===r;dn.post(e,o?{type:"pick-cancel"}:{type:"pick-start",verb:r}),n({a:"set-picking",v:o?!1:r})}function gN(e){return[{id:"copy-sha",label:`copy ${e.short}`,onClick:()=>tn(e.sha)},{id:"copy-subject",label:"copy subject",onClick:()=>tn(e.subject)}]}function Dh(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 a=t-1;a>=0;a--)if((((i=e[a])==null?void 0:i.depth)??0)<r.depth)return{do:"to",at:a};return null}const kN="application/x-toyon-mention";let ba=null;function v5(e){return e.kind==="worktree"?`@${e.title} `:$w(e.items)}function b5(e){return e.kind==="worktree"?e.branch:e.items.map(t=>t.path).join(" ")}function lu(e,t){e.dataTransfer.setData(kN,"1"),e.dataTransfer.setData("text/plain",b5(t)),e.dataTransfer.effectAllowed="copy",ba=t}function Cu(e){ba=null,Rw(e)}function wN(e,t){const n=e.getState().activeId;return(t.kind==="paths"?t.worktreeId===n:t.worktreeId!==n)?Ta(e):null}const yN=e=>ba!==null&&Array.from(e.dataTransfer.types).includes(kN);function x5(e,t){if(!yN(t)||!ba)return;t.preventDefault();const n=wN(e,ba)!==null;t.dataTransfer.dropEffect=n?"copy":"none",n&&Iw(e,{at:"chat"})}function vN(e,t){if(!yN(t)||!ba)return null;t.preventDefault();const n=ba,r=a3();if(Cu(e),r)return null;const o=wN(e,n);return o?{boxId:o,words:v5(n)}:null}function E5(e,t,n){const r=e.ownerDocument;if(typeof r.caretPositionFromPoint!="function")return null;const o=r.caretPositionFromPoint(t,n);return(o==null?void 0:o.offsetNode)===e?o.offset:null}function zh(e){return e!=null&&e.config.profiles?Object.keys(e.config.profiles):[]}function bN(e,t){const n=zh(t);if(n.length!==0)return e.profile&&n.includes(e.profile)?e.profile:t==null?void 0:t.config.defaultProfile}const S5=e=>Af(vi((e==null?void 0:e.config)??{}),e==null?void 0:e.defaultBranch).toLowerCase();function Ei(e,t,n){t({a:"shipping",id:n.worktreeId,op:n.t}),e==null||e.send(n)}const xN=(e,t)=>JC(e.worktree,{pending:()=>e.agent!=="idle"||(e.queued??0)>0||!!e.shipping,drafted:t,counts:()=>({dirty:e.dirty,ahead:e.ahead})});function $l(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 EN(e,t,n){t({a:"hold-unread",id:n}),e==null||e.send({t:"mark-unread",worktreeId:n})}function SN(e,t,n){return{rename(r){if(!aE(r.worktree))return;const o=window.prompt("Rename worktree (its branch follows as a slug):",r.worktree.title);o!=null&&o.trim()&&(e==null||e.send({t:"rename-worktree",worktreeId:r.worktree.id,title:o.trim()}))},setProfile(r,o){e==null||e.send({t:"set-worktree-profile",worktreeId:r.worktree.id,profile:o})},ownProcs(r){e==null||e.send({t:"own-procs",worktreeId:r.worktree.id})},shareProcs(r){const o=(r.worktree.owns??[]).join(", ");window.confirm(`Stop this worktree's own ${o} and use main's?
|
|
113
|
+
|
|
114
|
+
What they hold that main's do not (a database of their own) is not carried over.`)&&(e==null||e.send({t:"share-procs",worktreeId:r.worktree.id}))},archive(r){var a;if(!Ik(r.worktree))return;const o=xN(r,n);if(!o)return $l(e,t,[r.worktree.id]);window.confirm(`Archive worktree "${r.worktree.title}"? ${(a=o[0])==null?void 0:a.toUpperCase()}${o.slice(1)}.
|
|
115
|
+
|
|
116
|
+
Its directory and branch (${r.worktree.branch}) go. The chat, its draft, the commits and any uncommitted changes are kept, and the project menu can restore it.`)&&$l(e,t,[r.worktree.id])}}}function _N(e,t,n,{sock:r,dispatch:o},i){var M,I;const a=e.worktree.id,c=SN(r,o,n.drafted),u=[],h=[],f=[],m=[],g=[],w=[];zo(e.agent)&&u.push({id:"stop",label:"stop agent",onClick:()=>r==null?void 0:r.send({t:"stop-agent",worktreeId:a})});const y=!n.shipping[a],v=n.frame==="phone";((e.dirty??0)>0||(e.ahead??0)>0||!v&&!n.layout.changes)&&u.push({id:"changes",label:`view changes${(e.dirty??0)>0?` (${e.dirty})`:""}`,onClick:()=>{o({a:"activate",id:a}),v?o({a:"screen",to:"changes"}):n.layout.changes||o({a:"toggle-changes"})}}),h.push({id:"copy-branch",label:"copy branch name",onClick:()=>tn(e.worktree.branch)}),h.push(...Uo(()=>r==null?void 0:r.send({t:"reveal",worktreeId:a}),i.hostname)),v||h.push({id:"copy-path",label:"copy path",onClick:()=>tn(e.path)});const{transcript:N,sessionId:x}=e,_=!!N&&!Nr(e.worktree);_&&T_(i.hostname)&&h.push({id:"reveal-transcript",label:"reveal transcript in Finder",onClick:()=>r==null?void 0:r.send({t:"reveal-transcript",worktreeId:a})});const T=!v&&!!i.palette;T&&_&&h.push({id:"copy-transcript",label:"copy transcript path",onClick:()=>tn(N)}),T&&x&&h.push({id:"copy-session",label:"copy session id",onClick:()=>tn(x)});const j=bN(e.worktree,t);for(const O of Eu(e.worktree)?[]:zh(t))g.push({id:`profile:${O}`,label:`run with ${O}`,checked:O===j,onClick:()=>c.setProfile(e,O)});if(!ya(e.worktree)&&((M=e.borrowed)!=null&&M.length)&&g.push({id:"own-procs",label:`run ${e.borrowed.join(", ")} here`,detail:"on main now",onClick:()=>c.ownProcs(e)}),!ya(e.worktree)&&((I=e.worktree.owns)!=null&&I.length)&&g.push({id:"share-procs",label:`use main's ${e.worktree.owns.join(", ")}…`,detail:"runs here now",danger:!0,onClick:()=>c.shareProcs(e)}),aE(e.worktree)&&f.push({id:"rename",label:"rename…",onClick:()=>c.rename(e)}),i.graft&&gf(e.worktree)){const O=i.graft;f.push({id:"graft",label:"graft with…",onClick:()=>O(a)})}f.push({id:"unread",label:"mark as unread",key:zt("mark-unread"),disabled:e.unseen?"already unread":void 0,onClick:()=>EN(r,o,a)});const C=y?void 0:"waiting on the one in progress";if(e.syncQueued)m.push({id:"sync",label:"call off the sync from main",onClick:()=>r==null?void 0:r.send({t:"unqueue-sync",worktreeId:a})});else if(uh(e)&&(e.behind??0)>0){const O=zo(e.agent)&&(e.dirty??0)>0;m.push({id:"sync",label:`sync from main${O?" after the turn":""} (${e.behind} behind)`,disabled:C,onClick:()=>Ei(r,o,{t:"sync-main",worktreeId:a})})}return ua(e.worktree)&&!(e.worktree.landed&&e.dirty===0)&&m.push({id:"land",label:Lk(vi((t==null?void 0:t.config)??{}),e.worktree),detail:S5(t),disabled:C,onClick:()=>Ei(r,o,{t:"land",worktreeId:a})}),e.worktree.kind==="worktree"&&m.push({id:"split",label:"continue elsewhere…",sub:!0,onClick:()=>o({a:"open",overlay:{kind:"split",worktreeId:a}})}),Ik(e.worktree)&&w.push({id:"archive",label:xN(e,n.drafted)?"archive…":"archive",key:zt("wt-archive"),danger:!0,onClick:()=>c.archive(e)}),Bn([u,h,f,m,g,w])}function _5(e,t,{sock:n,dispatch:r},o){const i=[],a=t.frame==="phone",c=[{id:"adopt",label:"take over",disabled:e.locked?`held by ${e.lockReason??"another tool"}`:void 0,onClick:()=>n==null?void 0:n.send({t:"adopt-worktree",worktreeId:e.id,clientId:t.clientId})}];return uh(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})}),a||i.push({id:"shell",label:"open a shell here",onClick:()=>{r({a:"activate",id:e.id}),r({a:"focus-terminal"})}}),i.push(...Uo(()=>n==null?void 0:n.send({t:"reveal",worktreeId:e.id}),o)),Bn([c,i,a?[]:[{id:"copy-path",label:"copy path",onClick:()=>tn(e.path)}]])}const N5={sm:"",md:"field-md",lg:"field-lg"};function NN({size:e="sm",font:t,bare:n,rule:r,className:o}){const i=t??(e==="lg"?"ui":"mono");return He("field",N5[e],i==="ui"&&"field-ui",i==="lead"&&"field-lead",n&&"field-bare",r&&"field-rule",o)}const Do=S.forwardRef(function({size:t,font:n,bare:r,rule:o,className:i,...a},c){return d.jsx("input",{ref:c,className:NN({size:t,font:n,bare:r,rule:o,className:i}),...a})}),cu=S.forwardRef(function({size:t,font:n,bare:r,rule:o,className:i,...a},c){return d.jsx("textarea",{ref:c,className:NN({size:t,font:n,bare:r,rule:o,className:i}),...a})}),ho=e=>/[.!?…]$/.test(e)?e:`${e}.`,TN=160;function Fh(e,t=TN){const n=e.replace(/\s+/g," ").trim();if(n.length<=t)return n;const r=n.slice(0,t);return`${r.slice(0,Math.max(r.lastIndexOf(" "),1)).trimEnd()}…`}function Pw(e){return e.subjects.length?Fh(e.subjects.join("; ")):void 0}function jN(e){const t=Pw(e);if(t)return e.pr===void 0?t:Fh(`PR #${e.pr}: ${t}`)}function Lw(e,t=3){const n=[];for(const a of e??[]){const c=jN(a);c&&n.push({at:a.at,line:c})}if(n.length===0)return[];const r=n.slice(-t),o=n.length-r.length,i=r.map(({at:a,line:c})=>n.length===1?ho(c):`${Dw(bo(sr(a)))}: ${ho(c)}`);return o>0?[`${o} earlier landing${o===1?"":"s"}.`,...i]:i}const T5="checks running",j5="checks failed",$N="preview up";function $5(e){if(e.state!=="open")return[];const t=[];return(e.checks==="pending"||e.checks==="fail")&&t.push({text:e.checks==="fail"?j5:T5,url:`${e.url}/checks`,tip:"Open the checks on GitHub",open:"open the checks"}),e.preview&&t.push({text:$N,url:e.preview,tip:`Open the branch on ${new URL(e.preview).hostname}`,open:"open the preview"}),t}function C5(e,t){const n=[];let r=e;for(const o of t){const i=new RegExp(`(^|; |, )${o.text.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}(?=;|\\.|$)`).exec(r);if(!i)continue;const a=i.index+(i[1]??"").length;a>0&&n.push(r.slice(0,a)),n.push(o),r=r.slice(a+o.text.length)}return r&&n.push(r),n}function As(e){const t=`PR #${e.number}`;if(e.state==="merged")return`${t} merged.`;if(e.state==="closed")return`${t} was closed without merging.`;const n=e.preview?`; ${$N}.`:".";if(e.automerge){const r=e.review==="review_required"?"it is approved and checks pass":"checks pass";return`${t} open; GitHub merges it when ${r}${n}`}return e.mergeable===!1?`${t} open; it conflicts with main${n}`:e.review==="changes_requested"?`${t} open; changes requested${n}`:e.checks==="fail"?`${t} open; checks failed${n}`:e.checks==="pending"?`${t} open; checks running${n}`:e.review==="review_required"?`${t} open; waiting on review${n}`:e.review==="approved"?`${t} approved${e.checks==="pass"?", checks pass":""}${n}`:`${t} open and ready to merge${n}`}function CN(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 Dw=e=>`${e.charAt(0).toUpperCase()}${e.slice(1)}`;function zw(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 AN(e,t,n=null){return e!=null&&e.stale?`The work changed since this was written. ${t?"Run the check again and refresh":"Refresh"} the message.`:n==="unanswered"?`The model did not answer with a message. ${t?"Run the check again and ask":"Ask"} for it again.`:`${t?"Run the repo's check here and write":"Write"} the recap and the commit message.`}function A5(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 nf(e,t=0,n=!0,r){var o,i;if(e.check==="pending")return"Checking the work…";if(e.check==="fail"){const a=(i=(o=e.checkTail)==null?void 0:o.split(`
|
|
117
|
+
`).find(c=>c.trim()))==null?void 0:i.trim();return`Check failed${a?`: ${ho(a)}`:"."}`}return zw(e,t,n)==="unasked"?A5(r):null}function lx(e,t){const n=I5(e,t);return n?ho(Dw(n)):""}function I5(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 IN=e=>/^[A-Z][a-z]+(\s|$)/.test(e)?`${e.charAt(0).toLowerCase()}${e.slice(1)}`:e;function R5(e,t){const n=t??0;return n>0?`${n} behind ${e}; land takes it in first.`:""}function O5(e){return e>0?ho(Dw(`${e} ${e===1?"file":"files"} changed`)):""}function M5(e,t=null){return e.stale?"Changed since this was written.":t==="unanswered"?"No message yet: the model did not answer.":e.why?`Not ready: ${ho(IN(e.why))}`:null}function rf(e){return ho(e)}const bo=e=>e==="now"?"just now":`${e} ago`;function P5(e,t,n){switch(e){case"asking":return`Waiting on you${n==="now"?"":` for ${n}`}${t.ask?`: ${ho(t.ask)}`:"."}`;case"failed":return t.auth?`Stopped ${bo(n)}: not logged in.`:t.error?`Failed ${bo(n)}: ${ho(t.error)}`:`Failed ${bo(n)}.`;case"stopped":return t.planBack?`Sent the plan back ${bo(n)}. Say what to change.`:`Stopped ${bo(n)}.`;case"done":return t.cut?`Ended early ${bo(n)} (${t.cut}).`:`Finished ${bo(n)}.`}}function Fw(e){var n;const t=(n=e.recap)==null?void 0:n.text;return t?ho(t):P5(e.end,e.facts,sr(e.at))}function L5(e){var n;const t=(n=e.recap)==null?void 0:n.text;return t?`Last stop, ${bo(sr(e.at))}: ${ho(IN(t))}`:void 0}function uu(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 Bw(e){return(e==null?void 0:e.status)==="running"||(e==null?void 0:e.status)==="detached"}function RN(e){const t=e&&e.status!=="terminated"?e.since:void 0,n=yw(t,vw);return t!==void 0&&n===t?e:void 0}function ON(e,t){const n=e.stage?[e.stage]:[];switch(e.status){case"queued":return[...n,"queued"];case"running":return[...n,`${fa(t)} of ${gA(e.timeoutMs)}`];case"detached":return[...n,fa(t),"detached"];case"terminated":return[e.why??"stopped"]}}function qf(e,t,n){return[e,...ON(t,n)].join(" · ")}const qg={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 MN(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 D5({active:e,ahead:t,behind:n,unpushed:r,dirty:o}){var Wt,ln,wt;const i=tt(),a=lt(),c=wn("changes"),u=Nn(e)?e.worktree:null,h=e.id,f=P(mt=>{var Vt;return(Vt=mt.shipping[h])==null?void 0:Vt.op}),m=P(mt=>{var Vt;return(Vt=mt.shipping[h])==null?void 0:Vt.step}),g=yw(m,vw),w=uu(e,"commit"),y=uu(e,"check"),v=f?w:y,N=RN(v),x=xi(Bw(N)?N==null?void 0:N.since:void 0),[_,T]=S.useState("");ut([h],()=>T("")),ut([o],()=>{o||T("")});const j=S.useRef(null),C=(Wt=u==null?void 0:u.landing)!=null&&Wt.subject?u.landing.body?`${u.landing.subject}
|
|
118
|
+
|
|
119
|
+
${u.landing.body}`:u.landing.subject:null,M=()=>{_===""&&C&&T(C);const mt=j.current;mt&&(mt.focus(),requestAnimationFrame(()=>mt.setSelectionRange(mt.value.length,mt.value.length)))},I=P(mt=>mt.editCommit);ut([I],()=>{I&&M()});const O=_.trim()||void 0,A=P(mt=>{var Vt;return!!((Vt=mt.agents.find(kn=>kn.id===((u==null?void 0:u.agent)??mt.defaultAgent)))!=null&&Vt.quick)}),z=u==null?void 0:u.landing,B=O?null:zw(z,o?1:0,A),U=(z==null?void 0:z.check)==="pending",Q=!!(z!=null&&z.stale),ae=()=>{f||i==null||i.send({t:"judge",worktreeId:h})},ee=()=>{f||!O&&!C||Ei(i,a,{t:"commit",worktreeId:h,message:O??C??""})},de=()=>{f||Ei(i,a,{t:"land",worktreeId:h,...O?{message:O}:{}})},$=((ln=u==null?void 0:u.landing)==null?void 0:ln.check)==="fail",K=!!(u!=null&&u.landed)&&!o,V=u?fh({...u,landed:K}):void 0,X=(V==null?void 0:V.state)==="open",W=X&&(o||r>0),se=U||Q||!!B,ce=!!u&&ua(u)&&!K&&(o||t>0)&&!$&&!X&&!se,he=!!u&&W&&!$&&!se,je=!!u&&ua(u)&&!U&&(Q||B==="unwritten"||B==="unanswered")&&!zo(e.agent),$e=P(mt=>mt.repos.find(Vt=>Vt.id===e.repoId)??null),q=vi(($e==null?void 0:$e.config)??{}),H=Af(q,$e==null?void 0:$e.defaultBranch),ve=Lk(q,u??{}),Se=$e?dh($e):"main",ye=uh(e)?u4(Se,n):null,J=zo(e.agent),we=o&&!u?"commit or discard the changes here first":void 0,ge=!!e.syncQueued,Be=o&&J?`Merge ${Se} into this worktree once the turn ends, uncommitted changes kept`:`Merge ${Se} into this worktree${o?", uncommitted changes kept":""}`,Ie=X&&!W&&CN(V),We=ce?ve:he?"update":Ie?"land":(V==null?void 0:V.state)==="merged"?"pull":"land",pt=f==="commit"?g??"commit":f==="land"?g?`${We}: ${g}`:We:null,rn=pt&&N?qf(pt,N,x):pt,qt=S.useRef(!1);rn?o&&(qt.current=!0):qt.current=!1;const Ue=!!u&&(o||qt.current),Qt=Ue&&!!rn,an=f?null:v?N?ON(N,x).join(" · "):null:U?"writing the message":null,Ft=N&&(N.status==="running"||N.status==="detached")?N:null,Qe=Ft&&d.jsx(Rt,{icon:"stop",tone:"danger",label:MN(Ft.kind),onClick:()=>i==null?void 0:i.send({t:"run-stop",worktreeId:h,kind:Ft.kind})});return d.jsxs("div",{className:"composer commit-box",children:[Ue&&d.jsx("div",{className:"composer-field",children:Qt?d.jsx("div",{className:"commit-running live-text","data-tip":N?qg[N.status]:void 0,children:rn}):d.jsx(cu,{size:"lg",bare:!0,ref:j,value:_,onChange:mt=>T(mt.target.value),onKeyDown:mt=>{mt.key==="Enter"&&(mt.metaKey||mt.ctrlKey)?(mt.preventDefault(),ee()):mt.key==="Tab"&&!mt.shiftKey&&_===""&&C&&(mt.preventDefault(),M())},placeholder:C??(B==="unanswered"?"no message yet: the model did not answer. Check again, or write one here":B==="unasked"?"no message yet: write one here to commit or land":"commit message…")})}),d.jsxs("div",{className:"hint composer-knobs",children:[d.jsxs("span",{className:"commit-where",children:[d.jsx(St,{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 ${Se}`,children:[t," ahead"]}),(u==null?void 0:u.landed)&&d.jsxs("span",{className:"badge-landed","data-tip":`Merged into ${Se}`,children:[d.jsx(St,{name:"check",className:"icon-inline"})," landed"]})]}),d.jsxs("span",{className:"commit-acts",children:[rn?d.jsxs(d.Fragment,{children:[!Qt&&d.jsx("span",{className:"live-text",children:rn}),Qe]}):d.jsxs(d.Fragment,{children:[u&&o&&d.jsx(De,{disabled:!O&&!C||!!f,onClick:ee,...Pt(C&&!O?"Commit with the suggested message":"git add -A && git commit","⌘⏎"),children:"commit"}),u&&ce&&d.jsx(De,{tone:"primary",disabled:!!f,"data-tip":H,onClick:de,children:ve}),je&&d.jsx(De,{tone:"primary",disabled:!!f,"data-tip":AN(z,!!((wt=$e==null?void 0:$e.config.check)!=null&&wt.trim()),B),onClick:ae,children:"check"}),U&&d.jsx("span",{className:"live-text",children:"check"}),he&&V&&d.jsx(De,{tone:"primary",disabled:!!f,"data-tip":`Commit, take ${Se} in and push the branch; PR #${V.number} takes the new commits`,onClick:de,children:"update"}),Ie&&d.jsx(De,{tone:"primary",disabled:!!f,"data-tip":"Merge the PR now, by the method the repo allows",onClick:de,children:"land"})]}),V&&d.jsxs(De,{"data-tip":`Open PR #${V.number} on GitHub`,onClick:()=>window.open(V.url,"_blank"),...c.contextMenu(()=>[{id:"open-pr",label:"open on GitHub",onClick:()=>window.open(V.url,"_blank")},{id:"copy-link",label:"copy link",onClick:()=>tn(V.url)}]),children:["view ",d.jsx(St,{name:"external",className:"icon-inline"})]}),(V==null?void 0:V.preview)&&d.jsxs(De,{"data-tip":`Open the branch on ${new URL(V.preview).hostname}`,onClick:()=>window.open(V.preview,"_blank"),...c.contextMenu(()=>[{id:"open-preview",label:"open the preview",onClick:()=>window.open(V.preview,"_blank")},{id:"copy-preview",label:"copy link",onClick:()=>tn(V.preview??"")}]),children:["preview ",d.jsx(St,{name:"external",className:"icon-inline"})]})]})]}),(ye||an)&&d.jsxs("div",{className:"composer-notes",children:[an&&d.jsxs("div",{className:"hint composer-note","data-tip":N?qg[N.status]:void 0,children:[d.jsx("span",{children:an}),Qe]}),ye&&d.jsxs("div",{className:"hint composer-note",children:[d.jsx("span",{children:ye}),f==="sync-main"?d.jsx("span",{className:"live-text",children:g?`sync: ${g}`:"sync"}):ge?d.jsx("span",{className:"live-text","data-tip":"Runs once the turn ends, the uncommitted changes kept. The row's menu calls it off",children:"syncing after next turn"}):d.jsx(De,{variant:"outline",disabled:!!f||!!we,"data-tip":we??Be,onClick:()=>Ei(i,a,{t:"sync-main",worktreeId:h}),children:"sync"})]})]})]})}function Uw(){return P(e=>e.chatSide)}const z5=S.memo(function({c:t,id:n,selected:r,onToggle:o}){const i=wn("changes"),a=Uw();return d.jsxs("button",{className:"row row-sm log-row row-edge",id:n,"data-state":ur({current:r,cursor:r}),role:"option","aria-selected":r,tabIndex:-1,onClick:()=>o(t.sha),...i.contextMenu(()=>gN(t)),"data-tip":`${t.subject}
|
|
120
|
+
${t.short} · ${t.author}`,"data-tip-placement":a,children:[d.jsx("span",{className:"subject",children:t.subject}),d.jsx("span",{className:"at row-dim",children:sr(t.at)})]})});function F5(e,t){const n=No(e,t);if(!n||!Nn(n))return"take this worktree over to change files here";if(ya(n.worktree))return"start a worktree to change files"}function PN(e,t,n,r){return{id:"new-file",label:"new file…",disabled:F5(e.getState(),t),onClick:()=>r(n)}}function B5(e,t,n,r){const{worktreeId:o,dir:i,path:a,folder:c,newIn:u}=e,h=jw(t.getState(),o)?void 0:"take this worktree over to talk to an agent here",f=O_(a,c),m=[...c?[]:[{id:"open",label:"open",onClick:()=>Fn(n,{worktreeId:o,path:a,view:ji(a)})}],{id:"add-to-chat",label:"add to chat",disabled:h,onClick:()=>Az(t,o,a,c)}],g=[PN(t,o,u,r),{id:"ask-rename",label:"ask the agent to rename…",disabled:h,onClick:()=>Gb(t,o,`Rename ${f} to `)},{id:"ask-delete",label:"ask the agent to delete…",disabled:h,onClick:()=>Gb(t,o,`Delete ${f} and update whatever still uses it`)}],w=[...Uo(()=>{var y;return(y=n.sock)==null?void 0:y.send({t:"reveal",worktreeId:o,path:a})},Bo(n.sock)),{id:"copy-path",label:"copy path",onClick:()=>tn(`${i}/${a}`)},{id:"copy-relative-path",label:"copy relative path",onClick:()=>tn(a)}];return Bn([m,w,g])}function U5(e,t,n,r){return Bn([[PN(t,e.worktreeId,"",r)],Uo(()=>{var o;return(o=n.sock)==null?void 0:o.send({t:"reveal",worktreeId:e.worktreeId})},Bo(n.sock))])}const of=[],H5=[],cx=new Set,ux=e=>`tree-row-${e}`;function W5({worktreeId:e,dir:t,openPath:n,openRef:r,rootRef:o}){const i=Un(),a=tt(),c=lt(),u=It(e,"files"),h=It(e,"submodules"),f=It(e,"ignored"),m=It(e,"git"),g=(m==null?void 0:m.files)??H5,w=m==null?void 0:m.version,y=P(J=>J.connected);ut([e,w,y,a],()=>Oh(e,i.getState(),{sock:a,dispatch:c}));const v=P(J=>{var we;return((we=J.dragFiles)==null?void 0:we.at)==="tree"&&J.dragFiles.worktreeId===e?J.dragFiles.dir:null}),N=P(J=>J.treeOpen[e]??of),x=S.useMemo(()=>new Set(N),[N]),[_,T]=S.useState(cx);ut([e,n,r],()=>T(n&&!r?new Set(Bf(n).filter(J=>!x.has(J))):cx));const j=S.useCallback(J=>x.has(J)||_.has(J),[x,_]),C=S.useCallback(J=>{const we=x.has(J)||_.has(J);if(we&&_.has(J)){const ge=new Set(_);ge.delete(J),T(ge)}c({a:"tree-folder",worktreeId:e,path:J,open:!we})},[x,_,e,c]),M=S.useMemo(()=>Pz(u??of,h??of,f??of),[u,h,f]),I=S.useMemo(()=>Lz(M,j),[M,j]),O=S.useMemo(()=>zz(g),[g]),A=P(J=>J.treeReveal),z=A&&A.worktreeId===e?A:null,[B,U]=S.useState(()=>(z==null?void 0:z.path)??null),[Q,ae]=S.useState({worktreeId:e,linked:z});(Q.worktreeId!==e||Q.linked!==z)&&(ae({worktreeId:e,linked:z}),U((z==null?void 0:z.path)??null));const[ee,de]=S.useState(!1),$=S.useMemo(()=>{if(B===null)return-1;const J=I.findIndex(we=>we.path===B);if(J>=0)return J;for(const we of Bf(B).reverse()){const ge=I.findIndex(Be=>Be.path===we);if(ge>=0)return ge}return-1},[I,B]);ut([$,ee],()=>{var J,we;ee&&((we=(J=o.current)==null?void 0:J.querySelector('[data-state~="cursor"]'))==null||we.scrollIntoView({block:"nearest"}))});const K=S.useCallback((J,we)=>Fn({dispatch:c},{worktreeId:e,path:J,view:ji(J),focus:we}),[e,a,c]),V=S.useCallback(J=>{U(J.path),J.kind==="folder"?C(J.path):J.kind==="file"&&K(J.path,!1)},[C,K]),X=J=>{var Be;if(J.metaKey||J.ctrlKey||J.altKey)return;const we=I[$],ge=Ie=>{const We=I[Ie];We&&(U(We.path),We.kind==="file"&&K(We.path,!1))};switch(J.key){case"ArrowDown":case"ArrowUp":J.preventDefault(),ge($<0?0:$u($,J.key==="ArrowDown"?1:-1,I.length));return;case" ":J.preventDefault(),(we==null?void 0:we.kind)==="file"?K(we.path,!1):(we==null?void 0:we.kind)==="folder"&&C(we.path);return;case"Enter":J.preventDefault(),(we==null?void 0:we.kind)==="file"?K(we.path,!0):(we==null?void 0:we.kind)==="folder"&&C(we.path);return;case"ArrowRight":case"ArrowLeft":{J.preventDefault();const Ie=I.map(pt=>pt.kind==="folder"?{depth:pt.depth,open:pt.open}:{depth:pt.depth}),We=Dh(Ie,$,J.key);(We==null?void 0:We.do)==="to"?ge(We.at):We&&we&&C(we.path);return}case"Escape":J.stopPropagation(),n!==null?c({a:"close-editor"}):(Be=document.activeElement)==null||Be.blur();return}if(J.key.length===1){const Ie=iN(I.map(We=>We.name),$,J.key);Ie>=0&&(J.preventDefault(),ge(Ie))}},[W,se]=S.useState(null),ce=S.useRef(0),he=S.useCallback(J=>{J&&!j(J)&&C(J),ce.current++,se({dir:J,error:null,busy:!1})},[j,C]),je=S.useCallback(()=>{ce.current++,se(null)},[]),$e=S.useCallback(J=>{if(!W||W.busy)return;const we=Dz(W.dir,J);if("error"in we){se({...W,error:we.error});return}const ge=++ce.current;se({...W,error:null,busy:!0}),$_({sock:a,dispatch:c},{worktreeId:e,path:we.path}).then(Be=>{Be===null&&U(we.path),ge===ce.current&&se(Be===null?null:{...W,error:Be,busy:!1})})},[W,e,a,c]),q=wn("tree"),H=S.useCallback(J=>B5({worktreeId:e,dir:t,path:J.path,folder:J.kind!=="file",newIn:J.kind==="folder"||J.kind==="ignored"?J.path:L_(J.path)},i,{sock:a,dispatch:c},he),[e,t,i,a,c,he]),ve=S.useCallback((J,we)=>{J.kind==="file"&&dn.post(e,we?{type:"highlight-file",path:J.path,ranges:null}:{type:"highlight-clear"})},[e]),Se=S.useCallback((J,we)=>lu(we,{kind:"paths",worktreeId:e,items:[{path:J.path,folder:J.kind!=="file"}]}),[e]),ye=S.useCallback(()=>Cu(i),[i]);return d.jsx("div",{className:He("tree",v===""&&"drop-over"),role:"tree","aria-label":"files","data-worktree":e,"aria-activedescendant":ee&&$>=0?ux($):void 0,tabIndex:0,ref:o,onKeyDown:X,onFocus:()=>{var J;de(!0),B===null&&U(n&&I.some(we=>we.path===n)?n:((J=I[0])==null?void 0:J.path)??null)},onBlur:J=>!J.currentTarget.contains(J.relatedTarget)&&de(!1),onMouseDown:J=>{if(J.button!==0)return;const we=J.target.closest("[data-path]");(we==null?void 0:we.dataset.path)!==void 0&&U(we.dataset.path)},...q.contextMenu(J=>{const we=I[$];return J==="keyboard"&&we?H(we):U5({worktreeId:e},i,{sock:a},he)}),children:u===void 0?d.jsx("div",{className:"empty",children:d.jsx("span",{className:"live-text",children:"listing files"})}):I.length===0&&!W?d.jsx("div",{className:"empty",children:"no files"}):K5(I.map((J,we)=>d.jsx(q5,{row:J,id:ux(we),status:O.files.get(J.path),changedInside:J.kind!=="file"&&O.folders.has(J.path),current:ee?we===$:!r&&J.path===n,cursor:ee&&we===$,dropOver:v===J.path,onPress:V,menu:H,onHover:ve,onDragStart:Se,onDragEnd:ye},J.path)),W&&(()=>{var we;const J=W.dir===""?-1:I.findIndex(ge=>ge.path===W.dir);return{at:J,node:d.jsx(Z5,{depth:J>=0?(((we=I[J])==null?void 0:we.depth)??0)+1:0,error:W.error,onSubmit:$e,onCancel:je},"new-file")}})())})}function K5(e,t){return t?[...e.slice(0,t.at+1),t.node,...e.slice(t.at+1)]:e}function Z5({depth:e,error:t,onSubmit:n,onCancel:r}){const[o,i]=S.useState(""),a={"--tree-depth":e},c=e===0||void 0;return d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"row row-sm tree-row row-rails","data-kind":"file","data-root":c,style:a,children:[d.jsx("span",{className:"tree-caret row-dim"}),d.jsx(Do,{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:a,children:[d.jsx("span",{className:"tree-caret"}),d.jsx("span",{className:"hint",children:t})]})]})}const q5=S.memo(function({row:t,id:n,status:r,changedInside:o,current:i,cursor:a,dropOver:c,onPress:u,menu:h,onHover:f,onDragStart:m,onDragEnd:g}){const w=wn("tree"),y=Uw(),v=t.kind==="submodule",N=v?"A submodule: its files belong to its own repository":t.kind==="ignored"?"Ignored by git, so what is inside is not listed":null;return d.jsxs("div",{role:"treeitem",id:n,"aria-level":t.depth+1,"aria-expanded":t.kind==="folder"?t.open:void 0,"aria-selected":a,className:He("row row-sm tree-row row-rails row-edge",c&&"drop-over"),"data-state":ur({current:i,cursor:a}),"data-kind":t.kind,"data-path":t.path,style:{"--tree-depth":t.depth},draggable:!v,onDragStart:x=>m(t,x),onDragEnd:g,onClick:()=>u(t),onMouseEnter:()=>f(t,!0),onMouseLeave:()=>f(t,!1),...w.contextMenu(()=>h(t)),...N?Pt(N,void 0,{placement:y}):{},children:[d.jsx("span",{className:"tree-caret row-dim",children:t.kind==="folder"&&d.jsx(St,{name:"caret",className:He("icon-inline disc-caret",!t.open&&"shut")})}),d.jsx("span",{className:He("tree-name",(v||t.ignored)&&"row-dim"),children:t.name}),r?d.jsx("span",{className:`xy ${rw(r.xy)}`,children:ow(r.xy)}):o&&d.jsx("span",{className:"dot tree-changed"})]})});function LN({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 sf=S.memo(function({f:t,id:n,active:r,selected:o,checking:i=!1,checked:a=!1,onOpen:c,onCheck:u,menu:h,onHover:f,onDragStart:m,onDragEnd:g}){const w=wn("changes"),y=Uw(),{name:v,dir:N}=nw(t.path);return d.jsxs("button",{className:"row row-sm git-file row-edge",id:n,"data-state":ur({current:r,cursor:o,checked:a}),role:"option","aria-selected":o,tabIndex:-1,onClick:x=>u&&(i||x.shiftKey)?u(t.path):c(t.path),draggable:!!m,onDragStart:m&&(x=>m(t.path,x)),onDragEnd:g,...w.contextMenu(()=>h(t.path)),onMouseEnter:()=>f(t.path,!0),onMouseLeave:()=>f(t.path,!1),"data-tip":N?t.path:void 0,"data-tip-placement":y,children:[i&&d.jsx("input",{type:"checkbox",className:"changes-check",checked:a,readOnly:!0,tabIndex:-1}),d.jsx("span",{className:`xy ${rw(t.xy)}`,children:ow(t.xy)}),d.jsxs("span",{className:"path",children:[d.jsx("span",{className:"name",children:v}),N&&d.jsx("span",{className:"dir row-dim",children:N})]}),d.jsx(LN,{f:t})]})}),G5={added:"A",changed:"M",removed:"D"},V5={added:"added",changed:"",removed:"deleted"},Y5=S.memo(function({tests:t,id:n,cursor:r,onPick:o}){return t.map((i,a)=>d.jsxs("button",{className:"row row-sm changes-test row-rails row-edge",id:`${n}-t${a}`,"data-state":ur({current:r===a,cursor:r===a}),"data-sub":!0,role:"option","aria-selected":r===a,tabIndex:-1,onClick:()=>o(a),"data-tip":[...i.group,i.name].join(" · "),"data-tip-placement":"follow",children:[d.jsx("span",{className:`xy ${V5[i.change]}`,children:G5[i.change]}),d.jsx("span",{className:"name",children:i.name})]},a))}),dx=new Set(["test","tests","__tests__","spec","e2e","__snapshots__","__mocks__","fixtures","testdata"]),X5=/([._-]tests?\.[^.]+$)|([._]specs?\.[^.]+$)|(^tests?[._-])|(^conftest\.py$)|(\.snap$)|([a-z0-9](Tests?|Spec)\.[^.]+$)/;function Gf(e){const t=(e.endsWith("/")?e.slice(0,-1):e).split("/"),n=t.pop()??"";return e.endsWith("/")&&dx.has(n.toLowerCase())?!0:t.some(r=>dx.has(r.toLowerCase()))||X5.test(n)}function af(e){const t=e.filter(n=>!Gf(n.path));return t.length===0||t.length===e.length?{files:e,source:t.length}:{files:[...t,...e.filter(n=>Gf(n.path))],source:t.length}}const Gg="(?<q>[\"'`])(?<name>(?:\\\\.|(?!\\k<q>).)*)\\k<q>",fx={tests:[new RegExp(`^\\s*(?:test|it)(?:\\.(?!each\\b)\\w+)*(?:\\.each\\(.*\\))?\\(\\s*${Gg}`)],groups:[new RegExp(`^\\s*describe(?:\\.(?!each\\b)\\w+)*(?:\\.each\\(.*\\))?\\(\\s*${Gg}`)]},Q5={js:fx,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*${Gg}`),/^\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*\(/,...fx.tests]}},J5={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"},e6=3,t6=/^\s*(?:[)}\]]|end\b)/,Km=e=>e.length-e.trimStart().length;function hx(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 px(e,t){const n=t.split(`
|
|
121
|
+
`),r=[],o=[];let i=Number.NEGATIVE_INFINITY;return n.forEach((a,c)=>{var g,w,y;if(a.trim()==="")return;const u=Km(a);for(;o.length>0&&(((g=o.at(-1))==null?void 0:g.indent)??0)>=u;)o.pop();(w=e.mark)!=null&&w.test(a)&&(i=c);const f=!e.mark||c-i<=e6?hx(a,e.tests):null,m=f??hx(a,e.groups);if(m!==null){if(f!==null){i=Number.NEGATIVE_INFINITY;let v=c+1;for(;v<n.length&&(((y=n[v])==null?void 0:y.trim())===""||Km(n[v]??"")>u);)v++;v<n.length&&Km(n[v]??"")===u&&t6.test(n[v]??"")&&v++;const N=n.slice(c,v).map(x=>x.trim()).join(`
|
|
122
|
+
`).trim();r.push({group:o.map(x=>x.name),name:m,line:c,end:v,body:N})}o.push({indent:u,name:m})}}),r}function mx(e){const t=new Map;for(const n of e){const r=[...n.group,n.name].join(`
|
|
123
|
+
`);let o=0;for(;t.has(`${r}
|
|
124
|
+
${o}`);)o++;t.set(`${r}
|
|
125
|
+
${o}`,n)}return t}function n6(e,t,n){const r=Q5[J5[e.slice(e.lastIndexOf(".")+1).toLowerCase()]??""];if(!r)return[];const o=mx(px(r,t)),i=mx(px(r,n)),a=[];for(const[f,m]of i){const g=o.get(f);(g==null?void 0:g.body)!==m.body&&a.push({name:m.name,group:m.group,change:g?"changed":"added",line:m.line+1})}const c=n.split(`
|
|
126
|
+
`).length;let u=1;for(const[f,m]of o){const g=i.get(f);g?u=Math.min(g.end+1,c):a.push({name:m.name,group:m.group,change:"removed",line:u})}const h=f=>f.change==="removed"?0:1;return a.sort((f,m)=>f.line-m.line||h(f)-h(m))}const lf=[];function r6(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=sr(r.at);return`${o}, last commit ${i==="now"?"just now":`${i} ago`}`}const gx='[role="option"]:not([data-sub])',kx=[];function DN({width:e,placement:t="dock"}){var yr,Kn;const n=t==="screen",r=tt(),o=lt(),i=Un(),a=Zl(),c=_a(),u=(c==null?void 0:c.id)??a,h=Ps(),f=P(Y=>Y.layout.changes),m=Nu(),g=P(Y=>Y.focusChanges),w=It(u,"git"),y=P(Y=>Y.editor&&Y.editor.worktreeId===u?Y.editor.path:null),v=P(Y=>Y.editor&&Y.editor.worktreeId===u?Y.editor.ref??null:null),N=P(Y=>Y.editor&&Y.editor.worktreeId===u?Y.editor.since??null:null),x=(w==null?void 0:w.files)??lf,_=((yr=w==null?void 0:w.extras)==null?void 0:yr.committed)??lf,{files:T,source:j}=S.useMemo(()=>af(x),[x]),C=_.length>0,M=VD(),{files:I,source:O}=S.useMemo(()=>af(M?_:lf),[_,M]),A=(Kn=w==null?void 0:w.extras)==null?void 0:Kn.turn,z=A==null?void 0:A.base,B=YD(),{files:U,source:Q}=S.useMemo(()=>af(A&&B?A.files:lf),[A,B]),ae=T.length,ee=T.length+U.length,de=P(Y=>Y.editor&&Y.editor.worktreeId===u?Y.editor.disk:null),$=S.useMemo(()=>y!==null&&de&&Gf(y)?n6(y,de.before,de.after):kx,[y,de]),[K,V]=S.useState(!1);ut([y,v,N],()=>V(!1));const X=j>0?T.length-j:0,W=O>0?I.length-O:0,se=Q>0?U.length-Q:0,ce=T.length===0,he=S.useMemo(()=>{if(T.length===0)return;const Y=T.reduce((Tt,xn)=>Tt+(xn.add??0),0),pe=T.reduce((Tt,xn)=>Tt+(xn.del??0),0),Je=[Y>0&&`+${Y}`,pe>0&&`−${pe}`].filter(Boolean).join(" "),gt=`${T.length} uncommitted ${T.length===1?"file":"files"}`;return Je?`${gt}, ${Je}`:gt},[T]),je=!!w&&ce&&(w.ahead??0)===0,$e=P(Dl),q=c!==null||$e==="changes",H=c!==null||$e==="history",ve=S.useCallback(Y=>o({a:"changes-tab",v:Y}),[o]),Se=S.useRef($e);Se.current=$e;const ye=S.useRef(null),J=bw(),we=P(Y=>{const pe=Ii(Y,J==null?void 0:J.repoId);return pe?dh(pe):"main"}),ge=It(u,"commits"),Be=It(u,"commitFiles"),[Ie,We]=S.useState(null),pt=S.useRef(null);pt.current=Ie;const rn=S.useRef(null),qt=It(u,"changedRanges"),Ue=S.useCallback((Y,pe)=>{if(!u||c)return;if(!pe){rn.current=null,dn.post(u,{type:"highlight-clear"});return}rn.current=Y;const Je=qt[Y];Je?dn.post(u,{type:"highlight-file",path:Y,ranges:$b(Je)}):r==null||r.send({t:"changed-ranges",worktreeId:u,path:Y})},[u,c,qt,r]);S.useEffect(()=>{const Y=rn.current;if(!Y||!u)return;const pe=qt[Y];pe&&dn.post(u,{type:"highlight-file",path:Y,ranges:$b(pe)})},[qt,u]);const Qt=c&&T.length>0?(w==null?void 0:w.head)??null:null,an=S.useCallback((Y,pe=!1,Je)=>u&&Fn({dispatch:o},{worktreeId:u,path:Y,focus:pe,ref:Qt??void 0,since:Je}),[u,Qt,r,o]),Ft=S.useMemo(()=>c?T:[...T,...U,...I],[c,T,U,I]),Qe=S.useMemo(()=>{const Y=[];for(const pe of ge??[])if(Y.push({commit:pe}),pe.sha===Ie)for(const Je of af(Be[pe.sha]??[]).files)Y.push({commit:pe,file:Je});return Y},[ge,Ie,Be]),Wt=S.useMemo(()=>Qe.filter(Y=>!Y.file&&Y.commit.ahead).length,[Qe]),ln=S.useMemo(()=>Qe.findIndex(Y=>!Y.file&&!Y.commit.ahead),[Qe]),wt=c?Ft.length:0,mt=(q?Ft.length:0)+(H?Qe.length:0),Vt=S.useMemo(()=>{const Y=new Map;if(!c||T.length===0&&Qe.every(Je=>Je.commit.landedAt))return Y;let pe;return Qe.forEach((Je,gt)=>{const Tt=!!Je.commit.landedAt;Tt!==pe&&(pe=Tt,Y.set(gt,Tt?"landed":"not landed"))}),Y},[c,T,Qe]),kn=S.useRef(null),[{row:Lt,at:Pn},_t]=S.useReducer((Y,pe)=>typeof pe=="number"?{row:pe,at:-1}:pe,{row:0,at:-1}),[yn,er]=S.useState(!1),te=(Y,pe)=>yn?Sn(Y):pe,me=Y=>`changes-row-${Y}`,[Ge,ot]=S.useState(!1),[Dt,Ct]=S.useState([]),mn=S.useCallback(()=>{ot(!1),Ct([])},[]),L=S.useCallback(Y=>{ot(!0),Ct(pe=>pe.includes(Y)?pe.filter(Je=>Je!==Y):[...pe,Y])},[]),re=S.useMemo(()=>T.filter(Y=>Dt.includes(Y.path)).map(Y=>Y.path),[T,Dt]);ut([T],()=>Ct(Y=>{const pe=Y.filter(Je=>T.some(gt=>gt.path===Je));return pe.length===Y.length?Y:pe})),ut([Ge],()=>{if(!Ge)return;const Y=pe=>pe.key==="Escape"&&mn();return window.addEventListener("keydown",Y),()=>window.removeEventListener("keydown",Y)}),ut([u,$e],()=>{_t(0),mn()});const be=w==null?void 0:w.head,Xe=S.useRef("");S.useEffect(()=>{if(!(H||je)||!u)return;const Y=`${u}:${be??""}`;Xe.current!==Y&&(Xe.current=Y,r==null||r.send({t:"git-log",worktreeId:u}))},[H,je,u,be,r]);const Nt=S.useCallback(Y=>{We(pe=>pe===Y?null:Y),u&&!Be[Y]&&(r==null||r.send({t:"git-commit",worktreeId:u,sha:Y}))},[u,Be,r]);ut([Lt,Pn,yn],()=>{var Y,pe;yn&&((pe=(Y=kn.current)==null?void 0:Y.querySelector('[data-state~="cursor"]'))==null||pe.scrollIntoView({block:"nearest"}))});const Ot=S.useRef(-1),ze=Y=>Y>=ae&&Y<ee?z:void 0,Me=Y=>{var pe;return((pe=Ft[Y])==null?void 0:pe.path)===y&&(N??void 0)===ze(Y)&&(Y<ae?v===Qt:!v)};Ot.current=q?Ft.findIndex((Y,pe)=>Me(pe)):-1,S.useEffect(()=>{if(!g)return;const Y=Se.current==="files";Ot.current>=0&&_t(Ot.current);const pe=requestAnimationFrame(()=>{var Je;return(Je=(Y?ye:kn).current)==null?void 0:Je.focus()});return()=>cancelAnimationFrame(pe)},[g]);const Ze=S.useCallback((Y,pe=!1)=>{const Je=Ft[Y];Je&&(_t(Y),an(Je.path,pe,Y>=ae&&Y<ee?z:void 0),Ue(Je.path,!0))},[Ft,an,Ue,ae,ee,z]),Xt=S.useCallback((Y,pe=!1)=>{const Je=pt.current;u&&Je&&Fn({dispatch:o},{worktreeId:u,path:Y,ref:Je,focus:pe})},[u,r,o]),Bt=S.useCallback(Y=>{const pe=Qe[Y-wt];pe&&(_t(Y),pe.file&&Xt(pe.file.path))},[Qe,wt,Xt]),vn=S.useCallback(Y=>{const pe=Qe[Y-wt];pe&&(_t(Y),pe.file?Xt(pe.file.path,!0):Nt(pe.commit.sha))},[Qe,wt,Xt,Nt]),Ut=Y=>H&&Y>=wt,cn=Y=>{if(y===null)return!1;if(q&&Y<Ft.length)return Me(Y);const pe=Ut(Y)?Qe[Y-wt]:void 0;return!!(pe!=null&&pe.file)&&v===pe.commit.sha&&pe.file.path===y},Yt=Y=>cn(Y)&&!K?$:kx,Kt=Pn<Yt(Lt).length?Pn:-1,Sn=Y=>yn&&Lt===Y&&Kt<0,An=()=>{var pe,Je;const Y=[];for(let gt=0;gt<mt;gt++){const Tt=Ut(gt)?Qe[gt-wt]:void 0,xn=Tt?(pe=Tt.file)==null?void 0:pe.path:(Je=Ft[gt])==null?void 0:Je.path,Zn=Tt!=null&&Tt.file?1:0,ar=Yt(gt);Tt&&!Tt.file?Y.push({row:gt,at:-1,depth:Zn,open:Tt.commit.sha===Ie}):xn!==void 0&&Gf(xn)?Y.push({row:gt,at:-1,depth:Zn,open:ar.length>0}):Y.push({row:gt,at:-1,depth:Zn});for(let $r=0;$r<ar.length;$r++)Y.push({row:gt,at:$r,depth:Zn+1})}return Y},fr=(Y,pe=!1)=>{const Je=$[Y];!Je||!u||y===null||Fn({dispatch:o},{worktreeId:u,path:y,ref:v??void 0,since:N??void 0,line:{n:Je.line},focus:pe})},oe=Y=>Yt(Y).length>0&&d.jsx(Y5,{tests:$,id:me(Y),cursor:yn&&Lt===Y?Kt:-1,onPick:pe=>{_t({row:Y,at:pe}),fr(pe)}}),Le=Y=>{var pe;if(Ge&&Y.key==="Escape")Y.preventDefault(),Y.stopPropagation(),mn();else if(Ge&&Y.key===" "){Y.preventDefault();const Je=q&&Lt<T.length?T[Lt]:void 0;Je&&L(Je.path)}else if(Y.key==="ArrowDown"&&Kt+1<Yt(Lt).length)Y.preventDefault(),_t({row:Lt,at:Kt+1}),fr(Kt+1);else if(Y.key==="ArrowUp"&&Kt>=0)Y.preventDefault(),Kt===0?_t(Lt):(_t({row:Lt,at:Kt-1}),fr(Kt-1));else if(Y.key==="Enter"&&Kt>=0)Y.preventDefault(),fr(Kt,!0);else if(Y.key==="ArrowDown"||Y.key==="ArrowUp"){Y.preventDefault();const Je=$u(Lt,Y.key==="ArrowDown"?1:-1,mt);Ut(Je)?Bt(Je):Ze(Je)}else if(Y.key==="Enter")Y.preventDefault(),Ut(Lt)?vn(Lt):Ze(Lt,!0);else if(Y.key==="ArrowRight"||Y.key==="ArrowLeft"){Y.preventDefault();const Je=An(),gt=Dh(Je,Je.findIndex(Zn=>Zn.row===Lt&&Zn.at===Kt),Y.key),Tt=gt&&Je[gt.at];if(!gt||!Tt)return;const xn=Ut(Tt.row)?Qe[Tt.row-wt]:void 0;gt.do==="to"?Tt.at>=0?(_t({row:Tt.row,at:Tt.at}),fr(Tt.at)):xn!=null&&xn.file&&Tt.row>Lt?Bt(Tt.row):_t(Tt.row):xn&&!xn.file?Nt(xn.commit.sha):gt.do==="close"?V(!0):cn(Tt.row)?V(!1):xn!=null&&xn.file?Bt(Tt.row):Ze(Tt.row)}else Y.key==="Escape"&&(Y.stopPropagation(),y!==null?o({a:"close-editor"}):(pe=document.activeElement)==null||pe.blur())},Ve=c?c.id:h==null?void 0:h.worktree.id,jt=c?c.path:h?h.worktree.path:"",ft=c!==null,bn=S.useMemo(()=>Ve?(Y,pe)=>lu(pe,{kind:"paths",worktreeId:Ve,items:[{path:Y,folder:!1}]}):void 0,[Ve]),jr=S.useRef(re);jr.current=re;const ir=S.useMemo(()=>Ve?(Y,pe)=>{const Je=jr.current;if(!Je.includes(Y))return bn==null?void 0:bn(Y,pe);lu(pe,{kind:"paths",worktreeId:Ve,items:Je.map(gt=>({path:gt,folder:!1}))})}:void 0,[Ve,bn]),Zt=S.useCallback(()=>Cu(i),[i]),Qr=S.useCallback(Y=>Ve?Rs({id:Ve,dir:jt},Y,{discard:!ft,kept:ft,ref:Qt??void 0,select:ft?void 0:L},{sock:r,dispatch:o}):[],[Ve,jt,ft,Qt,L,r,o]),dt=S.useCallback(Y=>Ve?Rs({id:Ve,dir:jt},Y,{kept:ft},{sock:r,dispatch:o}):[],[Ve,jt,ft,r,o]),Hn=S.useCallback(Y=>Ve?Rs({id:Ve,dir:jt},Y,{kept:ft,since:z},{sock:r,dispatch:o}):[],[Ve,jt,ft,z,r,o]),rt=S.useCallback(Y=>Ve?Rs({id:Ve,dir:jt},Y,{ref:pt.current??void 0,kept:ft},{sock:r,dispatch:o}):[],[Ve,jt,ft,r,o]),_e=wn("changes"),qe=()=>{if(q&&Lt<Ft.length){const pe=Ft[Lt];return pe?(Lt<ae?Qr:Lt<ee?Hn:dt)(pe.path):[]}const Y=Ut(Lt)?Qe[Lt-wt]:void 0;return Y?Y.file?rt(Y.file.path):gN(Y.commit):[]},bt=(Y,pe)=>{const Je=Ft.findIndex((gt,Tt)=>Tt>=Y&>.path===pe);_t(Je),Me(Je)&&$.length>0?V(gt=>!gt):an(pe,!1,ze(Je))},it=S.useRef(bt);it.current=bt;const fn=S.useCallback(Y=>it.current(0,Y),[]),Ht=S.useCallback(Y=>it.current(ae,Y),[ae]),un=S.useCallback(Y=>it.current(ee,Y),[ee]),Kr=S.useCallback(Y=>{_t(wt+Qe.findIndex(pe=>!pe.file&&pe.commit.sha===Y)),Nt(Y)},[Qe,wt,Nt]),In=S.useCallback(Y=>{_t(wt+Qe.findIndex(pe=>{var Je;return((Je=pe.file)==null?void 0:Je.path)===Y})),Y===y&&v===pt.current&&$.length>0?V(pe=>!pe):Xt(Y)},[Qe,wt,Xt,y,v,$]),Wn=S.useCallback(()=>{},[]);return d.jsxs("div",{className:He("changes-dock",n&&"changes-screen",!n&&(!f||m)&&"collapsed"),style:n?void 0:{width:e},children:[!c&&d.jsx(Lh,{fill:!n,quiet:n,owner:"changes-tabs",label:"changes panel",items:[{id:"files",label:d.jsx(St,{name:"folder",className:"icon-inline"}),fit:!0,ariaLabel:"files",tip:Pt("files",zt("files"))},{id:"changes",label:"changes",tip:Pt("changes",zt("changes"),{detail:he})},{id:"history",label:"history"}],current:$e,onPick:ve}),$e==="files"&&u?d.jsx(W5,{worktreeId:u,dir:h?h.worktree.path:(J==null?void 0:J.path)??"",openPath:y,openRef:v,rootRef:ye}):d.jsxs("div",{className:He("changes-list",H&&"history"),role:"listbox","aria-label":c?"kept work":H?"commits":"changed files","aria-activedescendant":yn&&Lt>=0&&Lt<mt?Kt<0?me(Lt):`${me(Lt)}-t${Kt}`:void 0,tabIndex:0,ref:kn,onKeyDown:Le,onFocus:()=>er(!0),onMouseDown:Y=>{var gt;if(Y.button!==0)return;Y.preventDefault();const pe=Y.target.closest(gx),Je=pe?Array.from(Y.currentTarget.querySelectorAll(gx)).indexOf(pe):-1;Je>=0&&_t(Je),(gt=kn.current)==null||gt.focus()},onBlur:Y=>!Y.currentTarget.contains(Y.relatedTarget)&&er(!1),..._e.contextMenu(Y=>Y==="keyboard"?qe():[]),children:[q&&T.length>0&&d.jsxs(d.Fragment,{children:[(C||((w==null?void 0:w.ahead)??0)>0||c)&&d.jsx("div",{className:"section-title section-row",children:"uncommitted"}),T.map((Y,pe)=>d.jsxs(S.Fragment,{children:[X>0&&pe===j&&d.jsx("div",{className:"section-title changes-sub",children:"tests"}),d.jsx(sf,{f:Y,id:me(pe),active:te(pe,cn(pe)),selected:Sn(pe),checking:Ge,checked:Dt.includes(Y.path),onOpen:fn,onCheck:ft?void 0:L,menu:Qr,onHover:Ue,onDragStart:ir,onDragEnd:Zt}),oe(pe)]},`${Y.xy}:${Y.path}`))]}),q&&!c&&A&&d.jsxs(d.Fragment,{children:[d.jsxs("button",{type:"button",className:"section-title section-row section-fold","aria-expanded":B,"data-tip":"What changed since your last message","data-tip-placement":"follow",onClick:()=>o({a:"toggle-turn"}),onKeyDown:Y=>(Y.key==="Enter"||Y.key===" ")&&Y.stopPropagation(),children:["last turn",d.jsx(St,{name:"caret",className:He("icon-inline disc-caret",!B&&"shut")})]}),U.map((Y,pe)=>d.jsxs(S.Fragment,{children:[se>0&&pe===Q&&d.jsx("div",{className:"section-title changes-sub",children:"tests"}),d.jsx(sf,{f:Y,id:me(ae+pe),active:te(ae+pe,cn(ae+pe)),selected:Sn(ae+pe),onOpen:Ht,menu:Hn,onHover:Ue,onDragStart:bn,onDragEnd:Zt}),oe(ae+pe)]},`t-${Y.path}`))]}),q&&!c&&C&&d.jsxs(d.Fragment,{children:[d.jsxs("button",{type:"button",className:"section-title section-row section-fold","aria-expanded":M,"data-tip":`Committed on this branch, not yet on ${we}`,"data-tip-placement":"follow",onClick:()=>o({a:"toggle-committed"}),onKeyDown:Y=>(Y.key==="Enter"||Y.key===" ")&&Y.stopPropagation(),children:["committed",d.jsx(St,{name:"caret",className:He("icon-inline disc-caret",!M&&"shut")})]}),I.map((Y,pe)=>d.jsxs(S.Fragment,{children:[W>0&&pe===O&&d.jsx("div",{className:"section-title changes-sub",children:"tests"}),d.jsx(sf,{f:Y,id:me(ee+pe),active:te(ee+pe,cn(ee+pe)),selected:Sn(ee+pe),onOpen:un,menu:dt,onHover:Ue,onDragStart:bn,onDragEnd:Zt}),oe(ee+pe)]},`c-${Y.path}`))]}),q&&!c&&je&&d.jsx("div",{className:"empty",children:r6(we,!!J&&uh(J),(w==null?void 0:w.behind)??0,ge==null?void 0:ge[0])}),H&&Qe.map((Y,pe)=>d.jsxs(S.Fragment,{children:[c&&Vt.has(pe)&&d.jsx("div",{className:"section-title section-row",children:Vt.get(pe)}),!c&&Wt>0&&pe===0&&d.jsx("div",{className:"section-title section-row",children:"on this branch"}),!c&&Wt>0&&pe===ln&&d.jsx("div",{className:"section-title section-row",children:we}),Y.file?d.jsxs(d.Fragment,{children:[d.jsx(sf,{f:Y.file,id:me(wt+pe),active:te(wt+pe,cn(wt+pe)),selected:Sn(wt+pe),onOpen:In,menu:rt,onHover:Wn,onDragStart:bn,onDragEnd:Zt}),oe(wt+pe)]}):d.jsx(z5,{c:Y.commit,id:me(wt+pe),selected:Sn(wt+pe),onToggle:Kr})]},Y.file?`${Y.commit.sha}:${Y.file.path}`:Y.commit.sha)),H&&ge===void 0&&d.jsx("div",{className:"empty",children:d.jsx("span",{className:"live-text",children:"reading history"})}),H&&(ge==null?void 0:ge.length)===0&&T.length===0&&d.jsx("div",{className:"empty",children:"no commits yet"})]}),Ge&&d.jsxs("div",{className:"changes-pick",children:[d.jsxs(De,{size:"md",tone:"danger",disabled:re.length===0,"data-tip":"Throw away the uncommitted changes to every checked file",onClick:()=>{!Ve||re.length===0||window.confirm(C_(re))&&(r==null||r.send({t:"discard-files",worktreeId:Ve,paths:re}),mn())},children:["discard ",re.length,"…"]}),d.jsx(De,{size:"md",disabled:re.length===0,"data-tip":"Name every checked file in the chat",onClick:()=>{Ve&&Iz(i,Ve,re),mn()},children:"add to chat"}),d.jsx(Rt,{icon:"close",label:"Cancel",hint:"esc",onClick:mn})]}),J&&!c&&d.jsx(D5,{active:J,ahead:(w==null?void 0:w.ahead)??J.ahead??0,behind:(w==null?void 0:w.behind)??J.behind??0,unpushed:(w==null?void 0:w.unpushed)??J.unpushed??0,dirty:!ce})]})}function o6(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 wx(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 Au(e){return e>0&&e<.005?"<$0.01":`$${e.toFixed(2)}`}function s6(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 i6(e){if(!(e<.5))return e<.8?"worth compacting between tasks":"compact before the next task"}const zN=["five_hour","seven_day","seven_day_overage_included"],a6={five_hour:"the 5-hour window",seven_day:"the week",seven_day_overage_included:"the Fable week"},l6={five_hour:"5-hour",seven_day:"this week",seven_day_overage_included:"Fable week"};function FN(e,t){return zN.flatMap(n=>{const r=e.windows[n];return r&&r.resetsAt>t?[{key:n,used:r.used,resetsAt:r.resetsAt}]:[]})}function c6(e,t){return Math.min(1,Math.max(0,...FN(e,t).map(n=>n.used)))}const u6=e=>`${Math.round(100*e)}%`;function yx(e,t){const n=FN(e,t).map(r=>`${u6(r.used)} of ${a6[r.key]}`);return n.length?n.join(", "):"plan windows reset"}function d6(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 f6(e,t,n=r=>d6(r,t)){return zN.flatMap(r=>{const o=e.windows[r];if(!o)return[];const i=l6[r];if(o.resetsAt<=t)return[{key:r,name:i,used:0,sub:`reset ${n(o.resetsAt)}, read again on the next reply`}];const a=e.binding===r&&e.status==="rejected"?", out until then":e.binding===r&&e.status==="allowed_warning"?", nearly out":"";return[{key:r,name:i,used:o.used,sub:`resets ${n(o.resetsAt)}${a}`}]})}function h6(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 BN(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(Au(e.cost)),t.push(sr(e.archivedAt)),t.filter(Boolean).join(" · ")}function UN({sock:e},t,n){e==null||e.send({t:"restore-worktree",archiveId:t,clientId:n})}function xf(e,t,{sock:n,dispatch:r}){const o=[{id:"restore",label:"restore",disabled:e.restorable?void 0:"its commits were not kept",onClick:()=>{UN({sock:n},e.id,t.clientId),r({a:"close"})}}],i=[{id:"copy-branch",label:"copy branch name",onClick:()=>tn(e.branch)}];i.push(...Uo(()=>n==null?void 0:n.send({t:"reveal-transcript",worktreeId:e.id}),Bo(n),"reveal transcript in Finder"));const{sessionId:a}=e;return t.frame!=="phone"&&a&&i.push({id:"copy-session",label:"copy session id",onClick:()=>tn(a)}),Bn([o,i,[{id:"delete",label:"delete…",danger:!0,onClick:()=>{window.confirm(`Delete "${e.title}"?
|
|
127
|
+
|
|
128
|
+
Its chat, attachments and kept commits go with it, and it cannot be restored.`)&&(n==null||n.send({t:"delete-archived",archiveId:e.id}))}}]])}const p6=new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"});function HN(e){const[t,n]=S.useState(()=>Date.now());return S.useEffect(()=>{const r=setInterval(()=>n(Date.now()),6e4);return()=>clearInterval(r)},[]),`${aw(t-e)} ago`}function Rr({icon:e,word:t,tone:n,at:r,below:o,children:i,...a}){const c=r!==void 0?{"data-tip":`${t} ${p6.format(r)}`,"data-tip-placement":"top"}:null,u=(Array.isArray(o)?o:[o]).filter(h=>h!=null&&h!==!1);return d.jsx("div",{...a,className:"daemon-row row-edge","data-tone":n,children:d.jsxs("div",{className:"daemon-head",children:[d.jsxs("span",{...c,className:"daemon-tag",children:[d.jsx(St,{name:e,className:"icon-inline"}),t]}),d.jsxs("div",{className:"daemon-body",children:[d.jsx("div",{className:"daemon-line",children:i}),u.map((h,f)=>d.jsx("div",{className:"daemon-below row-dim",children:h},f))]})]})})}function m6({item:e}){const t=tt(),n=P(u=>u.clientId),r=e.uncommitted?"its chat, commits and uncommitted changes":"its chat and commits",o=e.cost!==void 0?`; the session cost ${Au(e.cost)}`:"",i=e.restorable?`Toyon kept ${r}${o}. A message sent below restores it first.`:`Its commits were not kept, so there is nothing to restore${o}; its row's menu on the rail can delete it.`,a=HN(e.archivedAt),c=Lw(e.lands);return d.jsxs(Rr,{icon:"archive",word:"archived",tone:"quiet",at:e.archivedAt,below:[...c,i],children:[d.jsxs("span",{className:"daemon-text",children:[a,e.landed?", after it was merged into main":""]}),e.restorable&&d.jsx(De,{variant:"inline",tone:"strong",onClick:()=>UN({sock:t},e.id,n),children:"restore"})]})}function wa(e,t,n,r,o){const{layout:i}=e.getState();Fn({dispatch:e.dispatch},{worktreeId:n,path:r,view:"file",line:{n:o,fiber:!0}}),i.changes||e.dispatch({a:"toggle-changes"})}function g6(e){let t=0;return e.map(n=>{const r={start:t,len:n};return t+=n,r})}function k6(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 vx(e,t,n){let r=0,o=e.length-1;for(;r<o;){const a=r+o>>1,c=e[a];(n?t>c.start+c.len:t>=c.start+c.len)?r=a+1:o=a}const i=e[r];return{i:r,at:t-i.start}}function w6(e,t){return{from:vx(e,t.start,!1),to:vx(e,t.end,!0)}}function bx(e,t){if(e.length===0)return-1;const n=e.findIndex(r=>r.start>=t);return n===-1?0:n}function y6(e,t,n){return t===0?-1:(e+n+t)%t}function Hw(e){return e.key==="f"&&(e.metaKey||e.ctrlKey)&&!e.altKey&&!e.shiftKey}function v6({label:e,query:t,onQuery:n,seed:r,seq:o,status:i,none:a,onStep:c,onClose:u}){const h=S.useRef(null);return ut([o],()=>{var f,m;r&&n(r),(f=h.current)==null||f.focus(),(m=h.current)==null||m.select()}),d.jsxs("div",{className:"find",children:[d.jsx(Do,{ref:h,autoFocus:!0,value:t,onChange:f=>n(f.target.value),placeholder:"find…","aria-label":e,className:"find-field",spellCheck:!1,onKeyDown:f=>{if(f.key==="Escape"){f.preventDefault(),f.stopPropagation(),u();return}if(f.key==="Enter"){f.preventDefault(),c(f.shiftKey?-1:1);return}if(Hw(f)){f.preventDefault(),f.stopPropagation(),f.currentTarget.select();return}f.key.toLowerCase()==="g"&&(f.metaKey||f.ctrlKey)&&!f.altKey&&(f.preventDefault(),f.stopPropagation(),c(f.shiftKey?-1:1))}}),d.jsx("span",{className:"find-count","aria-live":"polite",children:i}),d.jsx(Rt,{icon:"caret",label:"Previous match",hint:"⇧↩",className:"find-prev",disabled:a,onClick:()=>c(-1)}),d.jsx(Rt,{icon:"caret",label:"Next match",hint:"↩",disabled:a,onClick:()=>c(1)}),d.jsx(Rt,{icon:"close",label:"Close",hint:"esc",onClick:u})]})}const WN="find",KN="find-current",ZN=typeof CSS<"u"&&"highlights"in CSS;function b6(e){const t=e.parentElement;return t?typeof t.checkVisibility=="function"?t.checkVisibility():!0:!1}function x6(e,t){const n=e instanceof Element?e:e.parentElement;return!!(n!=null&&n.closest(t))}function E6(e,t){const n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_TEXT,o=>o instanceof Element?t&&o.matches(t)?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_SKIP:NodeFilter.FILTER_ACCEPT),r=[];for(let o=n.nextNode();o;o=n.nextNode()){const i=o;i.data.length>0&&b6(i)&&r.push(i)}return r}const Vg={matches:[],ranges:[]};function S6(e,t,n){if(!t)return Vg;const r=E6(e,n),o=k6(r.map(c=>c.data).join(""),t),i=g6(r.map(c=>c.data.length)),a=o.map(c=>{const{from:u,to:h}=w6(i,c),f=document.createRange();return f.setStart(r[u.i],u.at),f.setEnd(r[h.i],h.at),f});return{matches:o,ranges:a}}function _6(e,t){ZN&&(CSS.highlights.set(WN,new Highlight(...e.filter((n,r)=>r!==t))),CSS.highlights.set(KN,new Highlight(...e[t]?[e[t]]:[])))}function N6(){ZN&&(CSS.highlights.delete(WN),CSS.highlights.delete(KN))}function T6(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 xx=48;function j6(e,t){const n=t.getBoundingClientRect(),r=e.getBoundingClientRect(),o=parseFloat(getComputedStyle(e).getPropertyValue("--scroll-foot"))||0;n.top>=r.top+xx&&n.bottom<=r.bottom-o-xx||(e.scrollTop+=n.top-r.top-r.height/3)}function qN({root:e,body:t,seed:n,seq:r,onClose:o,onReveal:i,skip:a}){const[c,u]=S.useState(n),[h,f]=S.useState(Vg),[m,g]=S.useState(-1),w=S.useRef({found:Vg,at:-1}),y=S.useRef(""),v=S.useRef(!1),[N,x]=S.useState(0);S.useLayoutEffect(()=>{const C=t.current;if(!C)return;let M=0;const I=new MutationObserver(O=>{a&&O.every(A=>x6(A.target,a))||M||(M=requestAnimationFrame(()=>{M=0,x(A=>A+1)}))});return I.observe(C,{childList:!0,characterData:!0,subtree:!0,attributes:!0}),()=>{I.disconnect(),M&&cancelAnimationFrame(M)}},[t,a]),S.useLayoutEffect(()=>{const C=t.current;if(!C)return;const M=S6(C,c,a),I=c!==y.current;y.current=c,I&&(v.current=!0);const{found:O,at:A}=w.current;let z;I?O.matches[A]?z=bx(M.matches,O.matches[A].start):z=e.current?T6(M.ranges,e.current):bx(M.matches,0):z=Math.min(A,M.matches.length-1),w.current={found:M,at:z},f(M),g(z)},[c,N,a]),S.useLayoutEffect(()=>{_6(h.ranges,m);const C=h.ranges[m];C&&(v.current&&e.current&&(j6(e.current,C),i==null||i()),v.current=!1)},[h,m,e,i]),S.useLayoutEffect(()=>N6,[]);const _=h.matches.length,T=C=>{if(_===0)return;v.current=!0;const M=y6(w.current.at,_,C);w.current={...w.current,at:M},g(M)},j=()=>o(h.ranges[m]??null);return d.jsx(v6,{label:"find in this document",query:c,onQuery:u,seed:n,seq:r,status:c?_===0?"no matches":`${m+1}/${_}`:"",none:_===0,onStep:T,onClose:j})}function GN(e){return e.key==="a"&&(e.metaKey||e.ctrlKey)&&!e.altKey&&!e.shiftKey}function VN(e,t,n,r,o){S.useEffect(()=>{let i=!1;const a=u=>{const h=u.target instanceof Element?u.target:null;i=!!e.current&&!!h&&e.current.contains(h)&&!(o&&h.closest(o))},c=u=>{const h=e.current;if(!h||u.defaultPrevented||!t(u))return;const f=document.activeElement;o&&(f!=null&&f.closest(o))||!(f&&f!==document.body?h.contains(f):i)&&!(r!=null&&r(f))||(u.preventDefault(),n(h,u))};return window.addEventListener("pointerdown",a,!0),window.addEventListener("keydown",c),()=>{window.removeEventListener("pointerdown",a,!0),window.removeEventListener("keydown",c)}},[e,t,n,r,o])}function $6(e,t){const n=S.useCallback(r=>{var o;return YN(r,(o=t==null?void 0:t.upTo)==null?void 0:o.call(t,r))},[t]);VN(e,GN,n,void 0,t==null?void 0:t.except)}function Yg(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 YN(e,t){const n=document.createRange();n.selectNodeContents(e),t&&n.setEndBefore(t);const r=window.getSelection();r&&(r.removeAllRanges(),r.addRange(n))}function C6(e){return e.shiftKey||e.altKey||e.metaKey||e.ctrlKey?null:e.key==="ArrowLeft"?-1:e.key==="ArrowRight"?1:null}function A6(e,t,n){const r=e+n;return r<0||r>=t?null:r}const XN=S.createContext(null),I6="input, textarea, [contenteditable]";function Ex(e){return[...e.values()].filter(t=>{var n;return(n=t.el())==null?void 0:n.isConnected}).sort((t,n)=>{const r=t.el(),o=n.el();return!r||!o||r===o?0:r.compareDocumentPosition(o)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1})}function Bh({children:e}){const t=S.useRef(new Map),[n,r]=S.useState(null),o=S.useRef(n);o.current=n;const i=S.useMemo(()=>{const c=u=>{const h=Ex(t.current),f=h.findIndex(m=>m.id===u);r(f<0?null:{id:u,at:f,of:h.length})};return{register(u){return t.current.set(u.id,u),()=>{var h;t.current.delete(u.id),((h=o.current)==null?void 0:h.id)===u.id&&r(null)}},open:c,step(u){const h=o.current;if(!h)return;const f=Ex(t.current),m=f.findIndex(y=>y.id===h.id),g=m<0?null:A6(m,f.length,u),w=g===null?void 0:f[g];w&&c(w.id)},close(){var f,m,g;const u=o.current;if(r(null),!u)return;const h=document.activeElement;h!=null&&h.matches(I6)||(g=(m=(f=t.current.get(u.id))==null?void 0:f.el())==null?void 0:m.querySelector(".chip-link"))==null||g.focus({preventScroll:!0})}}},[]),a=S.useMemo(()=>({api:i,shown:n}),[i,n]);return d.jsx(XN.Provider,{value:a,children:e})}function R6(e,t){const n=S.useContext(XN),r=S.useId(),[o,i]=S.useState(!1),a=n==null?void 0:n.api;if(S.useLayoutEffect(()=>{if(!(!a||!t))return a.register({id:r,el:()=>e.current})},[a,r,t,e]),!a)return{open:o,show:()=>i(!0),close:()=>i(!1),nav:void 0};const c=(n==null?void 0:n.shown)??null,u=(c==null?void 0:c.id)===r;return{open:u,show:()=>a.open(r),close:a.close,nav:u&&c?{at:c.at,of:c.of,step:a.step}:void 0}}const O6=e=>e.t==="open-path"||e.t==="open-loose",pa=new Map,M6=16;function Xg({sock:e,dispatch:t},n,r){const o=QN({worktreeId:n,href:r.href});t({a:"link-refused",id:n,v:null}),e==null||e.send({t:"open-by-path",path:r.path,seq:o})}function P6(e,t){e==null||e.send({t:"open-by-path",path:t,seq:QN(null)})}function QN(e){const t=Lo();pa.set(t,e);for(const n of pa.keys()){if(pa.size<=M6)break;pa.delete(n)}return t}function L6(e,t){if(!pa.has(t.seq))return;const n=pa.get(t.seq);pa.delete(t.seq),n?e.dispatch({a:"link-refused",id:n.worktreeId,v:{href:n.href,message:t.message}}):e.dispatch({a:"server",msg:{t:"error",message:t.message}})}function D6(e,t,n){var i;const r=e.getState();if(n.t==="open-path"){const a={dispatch:u=>e.dispatch(u)};if(No(r,n.worktreeId)){r.activeId!==n.worktreeId&&e.dispatch({a:"activate",id:n.worktreeId}),Fn(a,{worktreeId:n.worktreeId,path:n.path});return}const c=Object.keys(r.trunks).find(u=>{var h;return((h=r.trunks[u])==null?void 0:h.id)===n.worktreeId});if(!c)return;if(((i=No(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})}Fn(a,{worktreeId:n.worktreeId,path:n.path});return}const o=r.activeId;if(!o){e.dispatch({a:"server",msg:{t:"error",message:`open a project first; ${n.name} needs a window to open in`}});return}e.dispatch({a:"open-loose",v:{worktreeId:o,name:n.name,text:n.text,binary:n.binary,tooLarge:n.tooLarge,source:{kind:"grant",id:n.id,path:n.path,version:n.version},seq:Lo()}})}function Ww({open:e,remove:t},n){const r=n==null?void 0:n.sock,o=n&&r?()=>r.send({t:"reveal-attachment",worktreeId:n.worktreeId,file:n.file}):void 0,i=n&&r?r.urls.attachmentWhere(n.worktreeId,n.file):void 0;return[[...e?[{id:"open",label:"open full size",onClick:e}]:[],...Uo(o,Bo(r),"reveal the copy")],i?[{id:"copy-path",label:"copy path",onClick:()=>N_(i)}]:[],t?[{id:"remove",label:"remove",onClick:t}]:[]]}function du(e,t={},n){return Bn([[{id:"copy-image",label:"copy image",onClick:()=>bz(e)}],...Ww(t,n)])}function JN({text:e,href:t}){return e!==void 0?[{id:"copy-text",label:"copy text",onClick:()=>tn(e)}]:t?[{id:"copy-text",label:"copy text",onClick:()=>N_(t)}]:[]}function z6(e,t={}){return Bn([JN(e),...Ww(t)])}function F6(e,t={},n){return Bn([JN(e),...Ww(t,n)])}function eT(e){return[S_(e),{id:"copy-link",label:"copy link",onClick:()=>tn(e)}]}function Uh(e,t,n){if(e.kind==="worktree"){const{id:o,archived:i}=e;return()=>n.dispatch(i?{a:"open-archived",id:o}:{a:"activate",id:o})}if(!t)return null;if(e.kind==="outside")return()=>Xg(n,t,e);if(e.kind==="path")return()=>Xg(n,t,{href:e.path,path:e.path});if(e.kind!=="file")return null;const r=e.file;return r.folder?()=>Tz(n,{worktreeId:t,path:r.path}):()=>Fn(n,{worktreeId:t,path:r.path,...r.line?{line:{n:r.line}}:{}})}function B6(e,t,n){const r=Uh(e,t,n),{sock:o}=n,i=e.kind==="file"?t?()=>o==null?void 0:o.send({t:"reveal",worktreeId:t,path:e.file.path}):void 0:()=>o==null?void 0:o.send({t:"reveal-path",path:e.path}),a=e.kind==="file"?e.file.path:e.path;return[[...r?[{id:"open",label:"open",onClick:r}]:[],...Uo(i,Bo(o))],[{id:"copy-path",label:"copy path",onClick:()=>tn(a)}]]}function U6(e,t){const n=Uh(e,null,t);return[n?[{id:"open",label:e.archived?"open archived chat":"open chat",onClick:n}]:[],[{id:"copy-branch",label:"copy branch",onClick:()=>tn(e.branch)}]]}function Qg(e){return e?[{id:"copy-code",label:"copy code",onClick:()=>tn(e)}]:[]}function oa(e,t,n,r={}){const{dispatch:o,sock:i}=n,a=r.link,c=a?a.kind==="out"?[eT(a.href)]:a.kind==="worktree"?U6(a,n):B6(a,t,n):[],u=[{id:"copy",label:"copy message",onClick:()=>tn(e.text)}],h=[];return e.kind==="user"&&t&&h.push({id:"draft",label:"edit in composer",onClick:()=>{const f=e.seq;if(f===void 0||!i)return o({a:"set-draft",id:t,text:e.text});o({a:"set-draft",id:t,text:""}),i.send({t:"redraft",worktreeId:t,seq:f})}}),Bn([Qg(r.code),...c,u,h])}function tT(e,t,n){return[Uo(t,n),[{id:"copy-path",label:"copy path",onClick:()=>tn(e)}]]}function Kw(e,t,n){return Bn(tT(e,t,n))}function H6(e,t){const n=e.callFile??e.file,r=n?tT(n,void 0,t.host):[],o=t.remove?[{id:"remove",label:"remove",onClick:t.remove}]:[];return Bn([...r,o])}const Sx=8,W6=.7,K6=100,Z6=400,q6=260,G6=80,V6=220;function _x({dx:e,dy:t}){return Math.abs(e)<Sx&&Math.abs(t)<Sx?null:Math.abs(t)>Math.abs(e)?"away":"other"}function Y6(e,t){const n=e.filter(i=>t-i.t<=K6),r=n[0],o=n[n.length-1];return!r||!o||o.t===r.t?0:(o.y-r.y)/(o.t-r.t)}const X6=e=>Math.abs(e)>=W6;function Q6(e,t){return Math.min(V6,Math.max(G6,e/Math.abs(t)))}function J6(e,t,n){const r=S.useRef(n);r.current=n,S.useEffect(()=>{const o=e.current;if(!o)return;let i=null,a=!1,c=[],u=0;const h=(v,N,x)=>{x!==void 0&&o.style.setProperty("--swipe-ms",`${x}ms`),o.dataset.swipe!==N&&(o.dataset.swipe=N,o.offsetWidth),o.style.setProperty("--swipe-y",`${v}px`),o.style.setProperty("--swipe-fade",`${Math.min(1,Math.abs(v)/(window.innerHeight/2))}`)},f=()=>{o.style.removeProperty("--swipe-y"),o.style.removeProperty("--swipe-fade"),o.style.removeProperty("--swipe-ms"),delete o.dataset.swipe},m=()=>{const v=a;i=null,a=!1,c=[],v&&(h(0,"settle"),u=window.setTimeout(f,q6))},g=v=>{var _;const N=v.touches[0],x=v.target;if(v.touches.length!==1||!N||(((_=window.visualViewport)==null?void 0:_.scale)??1)>1.01)return m();o.dataset.swipe==="leave"||!(x===o||x!=null&&x.closest(t))||(window.clearTimeout(u),i={x:N.clientX,y:N.clientY,at:v.timeStamp},c=[{y:N.clientY,t:v.timeStamp}])},w=v=>{const N=v.touches[0];if(!i||!N)return;const x=N.clientX-i.x,_=N.clientY-i.y;if(!a){const T=_x({dx:x,dy:_});if(T==="other"&&(i=null),T!=="away")return;a=!0}v.preventDefault(),c.push({y:N.clientY,t:v.timeStamp}),c.length>16&&c.shift(),h(_,"drag")},y=v=>{const N=v.changedTouches[0];if(!i||!N)return;const x=N.clientY-i.y,_=v.timeStamp-i.at;if(!a&&_<Z6&&v.target!==o&&_x({dx:N.clientX-i.x,dy:x})===null){v.preventDefault(),i=null,r.current();return}const j=Y6(c,v.timeStamp);if(!a||!X6(j))return m();i=null,a=!1,c=[];const C=Math.sign(j)*window.innerHeight,M=Q6(Math.abs(C-x),j);h(C,"leave",M),u=window.setTimeout(()=>r.current(),M)};return o.addEventListener("touchstart",g,{passive:!0}),o.addEventListener("touchmove",w,{passive:!1}),o.addEventListener("touchend",y),o.addEventListener("touchcancel",m),()=>{window.clearTimeout(u),o.removeEventListener("touchstart",g),o.removeEventListener("touchmove",w),o.removeEventListener("touchend",y),o.removeEventListener("touchcancel",m)}},[e,t])}function Zw({owner:e,onClose:t,menu:n,nav:r,children:o}){const i=wn(e),a=S.useRef(null);return J6(a,"img",t),d.jsxs(Ls,{className:"attach-full scrim",boxRef:a,onDismiss:t,onKey:c=>{if(c.key==="Escape"){c.stopPropagation(),t();return}const u=r&&C6(c);u&&(c.preventDefault(),c.stopPropagation(),r.step(u))},onClick:c=>{c.target===c.currentTarget&&t()},...n&&i.contextMenu(n),children:[o,d.jsxs("div",{className:"attach-head",children:[r&&r.of>1&&d.jsxs("span",{className:"attach-count",children:[r.at+1," of ",r.of]}),d.jsx(Rt,{icon:"close",label:"Close",tone:"quiet",onClick:t})]})]})}function eF({item:e}){if(!e.outcome)return null;const t=c4[e.outcome];if(e.ask.kind==="permission"){const{title:n,choices:r}=e.ask,o=r.find(i=>i.id===e.choiceId);return d.jsxs("div",{className:"ask-closed",children:[!e.toolId&&d.jsx("div",{className:"ask-lead",children:n}),d.jsx("div",{className:"ask-answered",children:o?o.name:t??"closed"})]})}return d.jsxs("div",{className:"ask-closed",children:[d.jsx("div",{className:"ask-lead",children:e.ask.message}),d.jsx("div",{className:"ask-answered",children:t??"closed"})]})}function qw(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 nT=e=>e.slice(0,Math.max(0,e.lastIndexOf("/")));function rT(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 a=n.endsWith("/"),c=n.slice(i.length+1).replace(/\/+$/,"");if(!c||c.split("/").some(f=>f===".."))return null;if(a)return{path:c,folder:!0};const u=(r==null?void 0:r[1])??(o==null?void 0:o[1]),h=u?Number.parseInt(u,10):void 0;return h&&h>0?{path:c,line:h}:{path:c}}function oT(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 tF(e){return e.length<2||!e.startsWith("/")||e.startsWith("//")||/\s/.test(e)?null:e}function Hh(e,t){const n=e.closest("[data-worktree]"),r=n==null?void 0:n.getAttribute("data-worktree");if(n&&r)return{kind:"worktree",id:r,branch:n.getAttribute("data-branch")??"",archived:n.hasAttribute("data-archived")};const o=e.closest("a, code[data-path]");if(!o)return null;const i=o.getAttribute("data-path");if(i)return{kind:"path",path:i};const a=o.getAttribute("href");if(!a)return null;const c=t?rT(t,a):null;if(c)return{kind:"file",file:c};const u=oT(a);return u?{kind:"outside",href:a,...u}:{kind:"out",href:a}}function Gw(e,t,n,r){const o=Hh(e.target,t),i=o&&o.kind!=="path"?Uh(o,n,r):null;i&&(e.preventDefault(),i())}const nF=150,rF=e=>({side:e,align:"center",offset:12,flip:"side",margin:8});function sT({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)},f=()=>{window.clearTimeout(u),u=window.setTimeout(()=>o(!0),nF)};return c.addEventListener("mouseenter",f),c.addEventListener("mouseleave",h),c.addEventListener("mousedown",h),()=>{window.clearTimeout(u),c.removeEventListener("mouseenter",f),c.removeEventListener("mouseleave",h),c.removeEventListener("mousedown",h)}},[e]);const a=()=>{var f;const c=e.current;if(!c)return null;const u=c.getBoundingClientRect(),h=((f=c.closest(".chat-log"))==null?void 0:f.getBoundingClientRect())??u;return{left:h.left,right:h.right,top:u.top,bottom:u.bottom}};return r?d.jsx(Ls,{className:He("chip-peek",t),anchor:a,placement:rF(i==="left"?"right":"left"),track:!0,children:n}):null}function Vw({className:e,label:t,tip:n,peek:r,full:o,menu:i,removeLabel:a,onRemove:c}){const u=S.useRef(null),h=wn("chat"),f=o!==void 0,m=R6(u,f);return d.jsxs("div",{ref:u,className:He("pick-chip row row-sm",e),"data-tip":f?"Open full size":n,"data-tip-placement":"follow",...h.contextMenu(()=>i({open:f?m.show:void 0,remove:c})),children:[f?d.jsx("button",{type:"button",className:"chip-link",onClick:m.show,children:t}):t,c&&d.jsx(Rt,{icon:"close",label:a,tone:"quiet",onClick:c}),f&&r!==void 0&&d.jsx(sT,{chip:u,children:r}),m.open&&f&&d.jsx(Zw,{owner:"chat",onClose:m.close,menu:()=>i(),nav:m.nav,children:o})]})}/*! @license DOMPurify 3.4.14 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.4.14/LICENSE */function Nx(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 oF(e){if(Array.isArray(e))return e}function sF(e,t){var n=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var r,o,i,a,c=[],u=!0,h=!1;try{if(i=(n=n.call(e)).next,t!==0)for(;!(u=(r=i.call(n)).done)&&(c.push(r.value),c.length!==t);u=!0);}catch(f){h=!0,o=f}finally{try{if(!u&&n.return!=null&&(a=n.return(),Object(a)!==a))return}finally{if(h)throw o}}return c}}function iF(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
129
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function aF(e,t){return oF(e)||sF(e,t)||lF(e,t)||iF()}function lF(e,t){if(e){if(typeof e=="string")return Nx(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)?Nx(e,t):void 0}}const iT=Object.entries,Tx=Object.setPrototypeOf,cF=Object.isFrozen,uF=Object.getPrototypeOf,dF=Object.getOwnPropertyDescriptor;let kr=Object.freeze,Tr=Object.seal,ml=Object.create,aT=typeof Reflect<"u"&&Reflect,Jg=aT.apply,ek=aT.construct;kr||(kr=function(t){return t});Tr||(Tr=function(t){return t});Jg||(Jg=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)});ek||(ek=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 aa=dr(Array.prototype.forEach),fF=dr(Array.prototype.lastIndexOf),jx=dr(Array.prototype.pop),Rc=dr(Array.prototype.push),hF=dr(Array.prototype.splice),Cl=Array.isArray,Bc=dr(String.prototype.toLowerCase),Zm=dr(String.prototype.toString),$x=dr(String.prototype.match),Oc=dr(String.prototype.replace),Cx=dr(String.prototype.indexOf),pF=dr(String.prototype.trim),mF=dr(Number.prototype.toString),gF=dr(Boolean.prototype.toString),Ax=typeof BigInt>"u"?null:dr(BigInt.prototype.toString),Ix=typeof Symbol>"u"?null:dr(Symbol.prototype.toString),lo=dr(Object.prototype.hasOwnProperty),Mc=dr(Object.prototype.toString),zr=dr(RegExp.prototype.test),sa=kF(TypeError);function dr(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 Jg(e,t,r)}}function kF(e){return function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return ek(e,n)}}function pn(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Bc;if(Tx&&Tx(e,null),!Cl(t))return e;let r=t.length;for(;r--;){let o=t[r];if(typeof o=="string"){const i=n(o);i!==o&&(cF(t)||(t[r]=i),o=i)}e[o]=!0}return e}function wF(e){for(let t=0;t<e.length;t++)lo(e,t)||(e[t]=null);return e}function vo(e){const t=ml(null);for(const r of iT(e)){var n=aF(r,2);const o=n[0],i=n[1];lo(e,o)&&(Cl(i)?t[o]=wF(i):i&&typeof i=="object"&&i.constructor===Object?t[o]=vo(i):t[o]=i)}return t}function yF(e){switch(typeof e){case"string":return e;case"number":return mF(e);case"boolean":return gF(e);case"bigint":return Ax?Ax(e):"0";case"symbol":return Ix?Ix(e):"Symbol()";case"undefined":return Mc(e);case"function":case"object":{if(e===null)return Mc(e);const t=e,n=Qo(t,"toString");if(typeof n=="function"){const r=n(t);return typeof r=="string"?r:Mc(r)}return Mc(e)}default:return Mc(e)}}function Qo(e,t){for(;e!==null;){const r=dF(e,t);if(r){if(r.get)return dr(r.get);if(typeof r.value=="function")return dr(r.value)}e=uF(e)}function n(){return null}return n}function vF(e){try{return zr(e,""),!0}catch{return!1}}const Rx=kr(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),qm=kr(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),Gm=kr(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),bF=kr(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),Vm=kr(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),xF=kr(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),Ox=kr(["#text"]),Mx=kr(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","command","commandfor","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns"]),Ym=kr(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dominant-baseline","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","pointer-events","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-orientation","text-rendering","textlength","type","u1","u2","unicode","values","vector-effect","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),Px=kr(["accent","accentunder","align","bevelled","close","columnalign","columnlines","columnspacing","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lquote","lspace","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),cf=kr(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),EF=Tr(/{{[\w\W]*|^[\w\W]*}}/g),SF=Tr(/<%[\w\W]*|^[\w\W]*%>/g),_F=Tr(/\${[\w\W]*/g),NF=Tr(/^data-[\-\w.\u00B7-\uFFFF]+$/),TF=Tr(/^aria-[\-\w]+$/),Lx=Tr(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),jF=Tr(/^(?:\w+script|data):/i),$F=Tr(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),CF=Tr(/^html$/i),AF=Tr(/^[a-z][.\w]*(-[.\w]+)+$/i),Dx=Tr(/<[/\w!]/g),zx=Tr(/<[/\w]/g),IF=Tr(/<\/no(script|embed|frames)/i),RF=Tr(/\/>/i),yo={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},lT=["style","script","xmp","iframe","noembed","noframes","plaintext","noscript"],OF=kr(pn({},lT)),MF=(function(){const e={};return aa(lT,t=>{e[t]=Tr(new RegExp("</"+t+"(?=[\\t\\n\\f\\r />])","i"))}),kr(e)})(),PF=function(){return typeof window>"u"?null:window},LF=function(t,n){if(typeof t!="object"||typeof t.createPolicy!="function")return null;let r=null;const o="data-tt-policy-suffix";n&&n.hasAttribute(o)&&(r=n.getAttribute(o));const i="dompurify"+(r?"#"+r:"");try{return t.createPolicy(i,{createHTML(a){return a},createScriptURL(a){return a}})}catch{return console.warn("TrustedTypes policy "+i+" could not be created."),null}},Fx=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},fi=function(t,n,r,o){return lo(t,n)&&Cl(t[n])?pn(o.base?vo(o.base):{},t[n],o.transform):r},Xm=function(t,n,r){const o=lo(t,n)?t[n]:void 0;return o&&typeof o=="object"?vo(o):r()};function cT(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:PF();const t=Ne=>cT(Ne);if(t.version="3.4.14",t.removed=[],!e||!e.document||e.document.nodeType!==yo.document||!e.Element)return t.isSupported=!1,t;let n=e.document;const r=n,o=r.currentScript;e.DocumentFragment;const i=e.HTMLTemplateElement,a=e.Node,c=e.Element,u=e.NodeFilter,h=e.NamedNodeMap;h===void 0&&(e.NamedNodeMap||e.MozNamedAttrMap),e.HTMLFormElement;const f=e.DOMParser,m=e.trustedTypes,g=c.prototype,w=Qo(g,"cloneNode"),y=Qo(g,"remove"),v=Qo(g,"nextSibling"),N=Qo(g,"childNodes"),x=Qo(g,"parentNode"),_=Qo(g,"shadowRoot"),T=Qo(g,"attributes"),j=a&&a.prototype?Qo(a.prototype,"nodeType"):null,C=a&&a.prototype?Qo(a.prototype,"nodeName"):null,M=a&&a.prototype?Qo(a.prototype,"ownerDocument"):null,I=function(F){return j?j(F):F.nodeType},O=function(F){return C?C(F):F.nodeName};if(typeof i=="function"){const Ne=n.createElement("template");Ne.content&&Ne.content.ownerDocument&&(n=Ne.content.ownerDocument)}let A,z="",B,U=!1,Q=0;const ae=function(){if(Q>0)throw sa('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.')},ee=function(F){ae(),Q++;try{return A.createHTML(F)}finally{Q--}},de=function(F){ae(),Q++;try{return A.createScriptURL(F)}finally{Q--}},$=function(){return U||(B=LF(m,o),U=!0),B},K=n,V=K.implementation,X=K.createNodeIterator,W=K.createDocumentFragment,se=K.getElementsByTagName,ce=r.importNode;let he=Fx();t.isSupported=typeof iT=="function"&&typeof x=="function"&&V&&V.createHTMLDocument!==void 0;const je=EF,$e=SF,q=_F,H=NF,ve=TF,Se=jF,ye=$F,J=AF;let we=Lx,ge=null;const Be=pn({},[...Rx,...qm,...Gm,...Vm,...Ox]);let Ie=null;const We=pn({},[...Mx,...Ym,...Px,...cf]);let pt=Object.seal(ml(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}})),rn=null,qt=null;const Ue=Object.seal(ml(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let Qt=!0,an=!0,Ft=!1,Qe=!0,Wt=!1,ln=!0,wt=!1,mt=!1,Vt=null,kn=null,Lt=!1,Pn=!1,_t=!1,yn=!1,er=!0,te=!1;const me="user-content-";let Ge=!0,ot=!1,Dt={},Ct=null;const mn=pn({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","selectedcontent","style","svg","template","thead","title","video","xmp"]);let L=null;const re=pn({},["audio","video","img","source","image","track"]);let be=null;const Xe=pn({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Nt="http://www.w3.org/1998/Math/MathML",Ot="http://www.w3.org/2000/svg",ze="http://www.w3.org/1999/xhtml";let Me=ze,Ze=!1,Xt=null;const Bt=pn({},[Nt,Ot,ze],Zm),vn=kr(["mi","mo","mn","ms","mtext"]);let Ut=pn({},vn);const cn=kr(["annotation-xml"]);let Yt=pn({},cn);const Kt=pn({},["title","style","font","a","script"]);let Sn=null;const An=["application/xhtml+xml","text/html"],fr="text/html";let oe=null,Le=null;const Ve=n.createElement("form"),jt=function(F){return F instanceof RegExp||F instanceof Function},ft=function(){let F=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(Le&&Le===F)return;(!F||typeof F!="object")&&(F={}),F=vo(F),Sn=An.indexOf(F.PARSER_MEDIA_TYPE)===-1?fr:F.PARSER_MEDIA_TYPE,oe=Sn==="application/xhtml+xml"?Zm:Bc,ge=fi(F,"ALLOWED_TAGS",Be,{transform:oe}),Ie=fi(F,"ALLOWED_ATTR",We,{transform:oe}),Xt=fi(F,"ALLOWED_NAMESPACES",Bt,{transform:Zm}),be=fi(F,"ADD_URI_SAFE_ATTR",Xe,{transform:oe,base:Xe}),L=fi(F,"ADD_DATA_URI_TAGS",re,{transform:oe,base:re}),Ct=fi(F,"FORBID_CONTENTS",mn,{transform:oe}),rn=fi(F,"FORBID_TAGS",vo({}),{transform:oe}),qt=fi(F,"FORBID_ATTR",vo({}),{transform:oe}),Dt=lo(F,"USE_PROFILES")?F.USE_PROFILES&&typeof F.USE_PROFILES=="object"?vo(F.USE_PROFILES):F.USE_PROFILES:!1,Qt=F.ALLOW_ARIA_ATTR!==!1,an=F.ALLOW_DATA_ATTR!==!1,Ft=F.ALLOW_UNKNOWN_PROTOCOLS||!1,Qe=F.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Wt=F.SAFE_FOR_TEMPLATES||!1,ln=F.SAFE_FOR_XML!==!1,wt=F.WHOLE_DOCUMENT||!1,Pn=F.RETURN_DOM||!1,_t=F.RETURN_DOM_FRAGMENT||!1,yn=F.RETURN_TRUSTED_TYPE||!1,Lt=F.FORCE_BODY||!1,er=F.SANITIZE_DOM!==!1,te=F.SANITIZE_NAMED_PROPS||!1,Ge=F.KEEP_CONTENT!==!1,ot=F.IN_PLACE||!1,we=vF(F.ALLOWED_URI_REGEXP)?F.ALLOWED_URI_REGEXP:Lx,Me=typeof F.NAMESPACE=="string"?F.NAMESPACE:ze,Ut=Xm(F,"MATHML_TEXT_INTEGRATION_POINTS",()=>pn({},vn)),Yt=Xm(F,"HTML_INTEGRATION_POINTS",()=>pn({},cn));const Z=Xm(F,"CUSTOM_ELEMENT_HANDLING",()=>ml(null));if(pt=ml(null),lo(Z,"tagNameCheck")&&jt(Z.tagNameCheck)&&(pt.tagNameCheck=Z.tagNameCheck),lo(Z,"attributeNameCheck")&&jt(Z.attributeNameCheck)&&(pt.attributeNameCheck=Z.attributeNameCheck),lo(Z,"allowCustomizedBuiltInElements")&&typeof Z.allowCustomizedBuiltInElements=="boolean"&&(pt.allowCustomizedBuiltInElements=Z.allowCustomizedBuiltInElements),Tr(pt),Wt&&(an=!1),_t&&(Pn=!0),Dt&&(ge=pn({},Ox),Ie=ml(null),Dt.html===!0&&(pn(ge,Rx),pn(Ie,Mx)),Dt.svg===!0&&(pn(ge,qm),pn(Ie,Ym),pn(Ie,cf)),Dt.svgFilters===!0&&(pn(ge,Gm),pn(Ie,Ym),pn(Ie,cf)),Dt.mathMl===!0&&(pn(ge,Vm),pn(Ie,Px),pn(Ie,cf))),Ue.tagCheck=null,Ue.attributeCheck=null,lo(F,"ADD_TAGS")&&(typeof F.ADD_TAGS=="function"?Ue.tagCheck=F.ADD_TAGS:Cl(F.ADD_TAGS)&&(ge===Be&&(ge=vo(ge)),pn(ge,F.ADD_TAGS,oe))),lo(F,"ADD_ATTR")&&(typeof F.ADD_ATTR=="function"?Ue.attributeCheck=F.ADD_ATTR:Cl(F.ADD_ATTR)&&(Ie===We&&(Ie=vo(Ie)),pn(Ie,F.ADD_ATTR,oe))),lo(F,"ADD_FORBID_CONTENTS")&&Cl(F.ADD_FORBID_CONTENTS)&&(Ct===mn&&(Ct=vo(Ct)),pn(Ct,F.ADD_FORBID_CONTENTS,oe)),Ge&&(ge["#text"]=!0),wt&&pn(ge,["html","head","body"]),ge.table&&(pn(ge,["tbody"]),delete rn.tbody),F.TRUSTED_TYPES_POLICY){if(typeof F.TRUSTED_TYPES_POLICY.createHTML!="function")throw sa('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof F.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw sa('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');const le=A;A=F.TRUSTED_TYPES_POLICY;try{z=ee("")}catch(xe){throw A=le,xe}}else F.TRUSTED_TYPES_POLICY===null?(A=void 0,z=""):(A===void 0&&(A=$()),A&&typeof z=="string"&&(z=ee("")));kr&&kr(F),Le=F},bn=pn({},[...qm,...Gm,...bF]),jr=pn({},[...Vm,...xF]),ir=function(F,Z,le){return Z.namespaceURI===ze?F==="svg":Z.namespaceURI===Nt?F==="svg"&&(le==="annotation-xml"||Ut[le]):!!bn[F]},Zt=function(F,Z,le){return Z.namespaceURI===ze?F==="math":Z.namespaceURI===Ot?F==="math"&&Yt[le]:!!jr[F]},Qr=function(F,Z,le){return Z.namespaceURI===Ot&&!Yt[le]||Z.namespaceURI===Nt&&!Ut[le]?!1:!jr[F]&&(Kt[F]||!bn[F])},dt=function(F){let Z=x(F);(!Z||!Z.tagName)&&(Z={namespaceURI:Me,tagName:"template"});const le=Bc(F.tagName),xe=Bc(Z.tagName);return Xt[F.namespaceURI]?F.namespaceURI===Ot?ir(le,Z,xe):F.namespaceURI===Nt?Zt(le,Z,xe):F.namespaceURI===ze?Qr(le,Z,xe):!!(Sn==="application/xhtml+xml"&&Xt[F.namespaceURI]):!1},Hn=function(F){Rc(t.removed,{element:F});try{x(F).removeChild(F)}catch{if(y(F),!x(F))throw sa("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},rt=function(F,Z,le){try{F.removeAttributeNode(Z)}catch{try{F.removeAttribute(le)}catch{}}},_e=function(F){it(F);const Z=N(F);if(Z){const xe=[];aa(Z,Re=>{Rc(xe,Re)}),aa(xe,Re=>{try{y(Re)}catch{}})}const le=T(F);if(le)for(let xe=le.length-1;xe>=0;--xe){const Re=le[xe],Te=Re&&Re.name;typeof Te=="string"&&rt(F,Re,Te)}},qe=function(F,Z,le){if(!le)try{le=Z.getAttributeNode(F)}catch{le=null}Rc(t.removed,{attribute:le||null,from:Z});try{le?Z.removeAttributeNode(le):Z.removeAttribute(F)}catch{try{Z.removeAttribute(F)}catch{}}if(F==="is")if(Pn||_t)try{Hn(Z)}catch{}else try{Z.setAttribute(F,"")}catch{}},bt=function(F){const Z=T(F);if(Z)for(let le=Z.length-1;le>=0;--le){const xe=Z[le],Re=xe&&xe.name;typeof Re!="string"||Ie[oe(Re)]||rt(F,xe,Re)}},it=function(F){const Z=[F];for(;Z.length>0;){const le=Z.pop();I(le)===yo.element&&bt(le);const Re=N(le);if(Re)for(let Te=Re.length-1;Te>=0;--Te)Z.push(Re[Te])}},fn=function(F,Z){return ln?F==="patchsrc"?!0:F==="for"&&Z!=="label"&&Z!=="output":!1},Ht=function(F){if(!ln)return;const Z=[F];for(;Z.length>0;){const le=Z.pop(),xe=I(le);if(xe===yo.processingInstruction||xe===yo.comment&&zr(zx,le.data)){try{y(le)}catch{}continue}if(xe===yo.element){const Te=le,$t=oe(O(le));try{Te.hasAttribute&&Te.hasAttribute("patchsrc")&&Te.removeAttribute("patchsrc"),Te.hasAttribute&&Te.hasAttribute("for")&&fn("for",$t)&&Te.removeAttribute("for")}catch{}}const Re=N(le);if(Re)for(let Te=Re.length-1;Te>=0;--Te)Z.push(Re[Te])}},un=function(F){let Z=null,le=null;if(Lt)F="<remove></remove>"+F;else{const Te=$x(F,/^[\r\n\t ]+/);le=Te&&Te[0]}Sn==="application/xhtml+xml"&&Me===ze&&(F='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+F+"</body></html>");const xe=A?ee(F):F;if(Me===ze)try{Z=new f().parseFromString(xe,Sn)}catch{}if(!Z||!Z.documentElement){Z=V.createDocument(Me,"template",null);try{Z.documentElement.innerHTML=Ze?z:xe}catch{}}const Re=Z.body||Z.documentElement;return F&&le&&Re.insertBefore(n.createTextNode(le),Re.childNodes[0]||null),Me===ze?se.call(Z,wt?"html":"body")[0]:wt?Z.documentElement:Re},Kr=function(F){const Z=M?M(F):F.ownerDocument;return X.call(Z||F,F,u.SHOW_ELEMENT|u.SHOW_COMMENT|u.SHOW_TEXT|u.SHOW_PROCESSING_INSTRUCTION|u.SHOW_CDATA_SECTION,null)},In=function(F){return F=Oc(F,je," "),F=Oc(F,$e," "),F=Oc(F,q," "),F},Wn=function(F){var Z;F.normalize();const le=M?M(F):F.ownerDocument,xe=X.call(le||F,F,u.SHOW_TEXT|u.SHOW_COMMENT|u.SHOW_CDATA_SECTION|u.SHOW_PROCESSING_INSTRUCTION,null);let Re=xe.nextNode();for(;Re;)Re.data=In(Re.data),Re=xe.nextNode();const Te=(Z=F.querySelectorAll)===null||Z===void 0?void 0:Z.call(F,"template");Te&&aa(Te,$t=>{Kn($t.content)&&Wn($t.content)})},yr=function(F){const Z=C?C(F):null;return typeof Z!="string"||oe(Z)!=="form"?!1:typeof F.nodeName!="string"||typeof F.textContent!="string"||typeof F.removeChild!="function"||F.attributes!==T(F)||typeof F.removeAttribute!="function"||typeof F.setAttribute!="function"||typeof F.namespaceURI!="string"||typeof F.insertBefore!="function"||typeof F.hasChildNodes!="function"||F.nodeType!==j(F)||F.childNodes!==N(F)},Kn=function(F){if(!j||typeof F!="object"||F===null)return!1;try{return j(F)===yo.documentFragment}catch{return!1}},Y=function(F){if(!j||typeof F!="object"||F===null)return!1;try{return typeof j(F)=="number"}catch{return!1}};function pe(Ne,F,Z){Ne.length!==0&&aa(Ne,le=>{le.call(t,F,Z,Le)})}const Je=function(F,Z){return!!(ln&&F.hasChildNodes()&&!Y(F.firstElementChild)&&zr(Dx,F.textContent)&&zr(Dx,F.innerHTML)||ln&&F.namespaceURI===ze&&OF[Z]&&(Y(F.firstElementChild)||typeof F.textContent=="string"&&zr(MF[Z],F.textContent))||F.nodeType===yo.processingInstruction||ln&&F.nodeType===yo.comment&&zr(zx,F.data))},gt=function(F,Z){if(F instanceof RegExp)return zr(F,Z);if(F instanceof Function){for(var le=arguments.length,xe=new Array(le>2?le-2:0),Re=2;Re<le;Re++)xe[Re-2]=arguments[Re];return!!F(Z,...xe)}return!1},Tt=function(F,Z,le){if(!rn[Z]&&xt(Z)&>(pt.tagNameCheck,Z))return!1;if(Ge&&!Ct[Z]){const xe=x(F),Re=N(F);if(Re&&xe){const Te=Re.length;for(let $t=Te-1;$t>=0;--$t){const on=F===le?w(Re[$t],!0):Re[$t];xe.insertBefore(on,v(F))}}}return Hn(F),!0},xn=function(F,Z,le,xe){return F.length===0?Z:Z===le||Z===xe?vo(Z):Z},Zn=function(F,Z){return F===Z||x(F)!==null?!1:(ot&&it(F),!0)},ar=function(F,Z){if(pe(he.beforeSanitizeElements,F,null),Zn(F,Z))return!0;if(yr(F))return Hn(F),!0;const le=oe(O(F));if(ge=xn(he.uponSanitizeElement,ge,Be,Vt),pe(he.uponSanitizeElement,F,{tagName:le,allowedTags:ge}),Zn(F,Z))return!0;if(Je(F,le))return Hn(F),!0;if(rn[le]||!(Ue.tagCheck instanceof Function&&Ue.tagCheck(le))&&!ge[le]){const Re=Tt(F,le,Z);return Re===!1&&pe(he.afterSanitizeElements,F,null),Re}if(I(F)===yo.element&&!dt(F)||(le==="noscript"||le==="noembed"||le==="noframes")&&zr(IF,F.innerHTML))return Hn(F),!0;if(Wt&&F.nodeType===yo.text){const Re=In(F.textContent);F.textContent!==Re&&(Rc(t.removed,{element:F.cloneNode()}),F.textContent=Re)}return pe(he.afterSanitizeElements,F,null),!1},$r=function(F,Z,le){if(qt[Z]||fn(Z,F)||er&&(Z==="id"||Z==="name")&&(le in n||le in Ve))return!1;const xe=Ie[Z]||Ue.attributeCheck instanceof Function&&Ue.attributeCheck(Z,F);return an&&zr(H,Z)||Qt&&zr(ve,Z)?!0:xe?be[Z]||zr(we,Oc(le,ye,""))||(Z==="src"||Z==="xlink:href"||Z==="href")&&F!=="script"&&Cx(le,"data:")===0&&L[F]||Ft&&!zr(Se,Oc(le,ye,""))?!0:!le:xt(F)&>(pt.tagNameCheck,F)&>(pt.attributeNameCheck,Z,F)||Z==="is"&&pt.allowCustomizedBuiltInElements&>(pt.tagNameCheck,le)},Gt=pn({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),xt=function(F){return!Gt[Bc(F)]&&zr(J,F)},To=function(F,Z,le,xe){if(A&&typeof m=="object"&&typeof m.getAttributeType=="function"&&!le)switch(m.getAttributeType(F,Z)){case"TrustedHTML":return ee(xe);case"TrustedScriptURL":return de(xe)}return xe},jn=function(F,Z,le,xe){try{le?F.setAttributeNS(le,Z,xe):F.setAttribute(Z,xe),yr(F)?Hn(F):jx(t.removed)}catch{qe(Z,F)}},Jt=function(F){pe(he.beforeSanitizeAttributes,F,null);const Z=F.attributes;if(!Z||yr(F))return;Ie=xn(he.uponSanitizeAttribute,Ie,We,kn);const le={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:Ie,forceKeepAttr:void 0};let xe=Z.length;const Re=oe(F.nodeName);for(;xe--;){const Te=Z[xe],$t=Te.name,on=Te.namespaceURI,tr=Te.value,Rn=oe($t),zs=tr;let En=$t==="value"?zs:pF(zs);if(le.attrName=Rn,le.attrValue=En,le.keepAttr=!0,le.forceKeepAttr=void 0,pe(he.uponSanitizeAttribute,F,le),En=le.attrValue,te&&(Rn==="id"||Rn==="name")&&Cx(En,me)!==0&&(qe($t,F,Te),En=me+En),ln&&zr(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,En)){qe($t,F,Te);continue}if(Rn==="attributename"&&$x(En,"href")){qe($t,F,Te);continue}if(!le.forceKeepAttr){if(!le.keepAttr){qe($t,F,Te);continue}if(!Qe&&zr(RF,En)){qe($t,F,Te);continue}if(Wt&&(En=In(En)),!$r(Re,Rn,En)){qe($t,F,Te);continue}En=To(Re,Rn,on,En),En!==zs&&jn(F,$t,on,En)}}pe(he.afterSanitizeAttributes,F,null)},Zr=function(F){let Z=null;const le=Kr(F);for(pe(he.beforeSanitizeShadowDOM,F,null);Z=le.nextNode();)if(pe(he.uponSanitizeShadowNode,Z,null),ar(Z,F),Jt(Z),Kn(Z.content)&&Zr(Z.content),I(Z)===yo.element){const xe=_(Z);Kn(xe)&&(Or(xe),Zr(xe))}pe(he.afterSanitizeShadowDOM,F,null)},Or=function(F){const Z=[{node:F,shadow:null}];for(;Z.length>0;){const le=Z.pop();if(le.shadow){Zr(le.shadow);continue}const xe=le.node,Te=I(xe)===yo.element,$t=N(xe);if($t)for(let on=$t.length-1;on>=0;--on)Z.push({node:$t[on],shadow:null});if(Te){const on=C?C(xe):null;if(typeof on=="string"&&oe(on)==="template"){const tr=xe.content;Kn(tr)&&Z.push({node:tr,shadow:null})}}if(Te){const on=_(xe);Kn(on)&&Z.push({node:null,shadow:on},{node:on,shadow:null})}}};return t.sanitize=function(Ne){let F=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},Z=null,le=null,xe=null,Re=null;if(Ze=!Ne,Ze&&(Ne="<!-->"),typeof Ne!="string"&&!Y(Ne)&&(Ne=yF(Ne),typeof Ne!="string"))throw sa("dirty is not a string, aborting");if(!t.isSupported)return Ne;mt?(ge=Vt,Ie=kn):ft(F),(he.uponSanitizeElement.length>0||he.uponSanitizeAttribute.length>0)&&(ge=vo(ge)),he.uponSanitizeAttribute.length>0&&(Ie=vo(Ie)),t.removed=[];const Te=ot&&typeof Ne!="string"&&Y(Ne);if(Te){Ht(Ne);const tr=O(Ne);if(typeof tr=="string"){const Rn=oe(tr);if(!ge[Rn]||rn[Rn])throw _e(Ne),sa("root node is forbidden and cannot be sanitized in-place")}if(yr(Ne))throw _e(Ne),sa("root node is clobbered and cannot be sanitized in-place");try{Or(Ne)}catch(Rn){throw _e(Ne),Rn}}else if(Y(Ne))Z=un("<!---->"),le=Z.ownerDocument.importNode(Ne,!0),le.nodeType===yo.element&&le.nodeName==="BODY"||le.nodeName==="HTML"?Z=le:Z.appendChild(le),Or(le);else{if(!Pn&&!Wt&&!wt&&Ne.indexOf("<")===-1)return A&&yn?ee(Ne):Ne;if(Z=un(Ne),!Z)return Pn?null:yn?z:""}Z&&Lt&&Hn(Z.firstChild);const $t=Te?Ne:Z;try{const tr=Kr($t);for(;xe=tr.nextNode();)ar(xe,$t),Jt(xe),Kn(xe.content)&&Zr(xe.content)}catch(tr){throw Te&&(_e(Ne),aa(t.removed,Rn=>{Rn.element&&it(Rn.element)})),tr}if(Te)return aa(t.removed,tr=>{tr.element&&it(tr.element)}),Wt&&Wn(Ne),Ne;if(Pn){if(Wt&&Wn(Z),_t)for(Re=W.call(Z.ownerDocument);Z.firstChild;)Re.appendChild(Z.firstChild);else Re=Z;return(Ie.shadowroot||Ie.shadowrootmode)&&(Re=ce.call(r,Re,!0)),Re}let on=wt?Z.outerHTML:Z.innerHTML;return wt&&ge["!doctype"]&&Z.ownerDocument&&Z.ownerDocument.doctype&&Z.ownerDocument.doctype.name&&zr(CF,Z.ownerDocument.doctype.name)&&(on="<!DOCTYPE "+Z.ownerDocument.doctype.name+`>
|
|
130
|
+
`+on),Wt&&(on=In(on)),A&&yn?ee(on):on},t.setConfig=function(){let Ne=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};ft(Ne),mt=!0,Vt=ge,kn=Ie},t.clearConfig=function(){Le=null,mt=!1,Vt=null,kn=null,A=B,z=""},t.isValidAttribute=function(Ne,F,Z){Le||ft({});const le=oe(Ne),xe=oe(F);return $r(le,xe,Z)},t.addHook=function(Ne,F){typeof F=="function"&&lo(he,Ne)&&Rc(he[Ne],F)},t.removeHook=function(Ne,F){if(lo(he,Ne)){if(F!==void 0){const Z=fF(he[Ne],F);return Z===-1?void 0:hF(he[Ne],Z,1)[0]}return jx(he[Ne])}},t.removeHooks=function(Ne){lo(he,Ne)&&(he[Ne]=[])},t.removeAllHooks=function(){he=Fx()},t}var DF=cT();function Yw(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var ja=Yw();function uT(e){ja=e}var ca={exec:()=>null};function fl(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 sn(e,t=""){let n=typeof e=="string"?e:e.source,r={replace:(o,i)=>{let a=typeof i=="string"?i:i.source;return a=a.replace(Ur.caret,"$1"),n=n.replace(o,a),r},getRegex:()=>new RegExp(n,t)};return r}var zF=((e="")=>{try{return!!new RegExp("(?<=1)(?<!1)"+e)}catch{return!1}})(),Ur={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:fl(e=>new RegExp(`^ {0,${e}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`)),hrRegex:fl(e=>new RegExp(`^ {0,${e}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`)),fencesBeginRegex:fl(e=>new RegExp(`^ {0,${e}}(?:\`\`\`|~~~)`)),headingBeginRegex:fl(e=>new RegExp(`^ {0,${e}}#`)),htmlBeginRegex:fl(e=>new RegExp(`^ {0,${e}}<(?:[a-z].*>|!--)`,"i")),blockquoteBeginRegex:fl(e=>new RegExp(`^ {0,${e}}>`))},FF=/^(?:[ \t]*(?:\n|$))+/,BF=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,UF=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Iu=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,HF=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,Xw=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,dT=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,fT=sn(dT).replace(/bull/g,Xw).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(),WF=sn(dT).replace(/bull/g,Xw).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(),Qw=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table|[ \t]+\n)[^\n]+)*)/,KF=/^[^\n]+/,Jw=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,ZF=sn(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Jw).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),qF=sn(/^(bull)([ \t][^\n]*?)?(?:\n|$)/).replace(/bull/g,Xw).getRegex(),Wh="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",ey=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,GF=sn("^ {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",ey).replace("tag",Wh).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),hT=e=>sn(Qw).replace("hr",Iu).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",Wh).getRegex(),VF=hT(/ {0,3}(?:[*+-]|1[.)])[ \t]+[^ \t\n]/),YF=hT(/ {0,3}(?:[*+-]|\d{1,9}[.)])(?:[ \t]|\n|$)/),XF=sn(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",YF).getRegex(),ty={blockquote:XF,code:BF,def:ZF,fences:UF,heading:HF,hr:Iu,html:GF,lheading:fT,list:qF,newline:FF,paragraph:VF,table:ca,text:KF},Bx=sn("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",Iu).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",Wh).getRegex(),QF={...ty,lheading:WF,table:Bx,paragraph:sn(Qw).replace("hr",Iu).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",Bx).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",Wh).getRegex()},JF={...ty,html:sn(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",ey).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:ca,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:sn(Qw).replace("hr",Iu).replace("heading",` *#{1,6} *[^
|
|
131
|
+
]`).replace("lheading",fT).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},e8=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,t8=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,pT=/^( {2,}|\\)\n(?!\s*$)/,n8=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,Ds=/[\p{P}\p{S}]/u,Gl=/[\s\p{P}\p{S}]/u,Ru=/[^\s\p{P}\p{S}]/u,r8=sn(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,Gl).getRegex(),o8=/[\p{Pi}\p{Ps}"']/u,mT=/(?!~)[\p{P}\p{S}]/u,s8=/(?!~)[\s\p{P}\p{S}]/u,i8=/(?:[^\s\p{P}\p{S}]|~)/u,a8=sn(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",zF?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),gT=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,l8=sn(gT,"u").replace(/punct/g,Ds).getRegex(),c8=sn(gT,"u").replace(/punct/g,mT).getRegex(),u8=/^(?:\*+(?:((?!\*)(?!openQuote)punct)|([^\s*]))?)|^_+(?:((?!_)(?!openQuote)punct)|([^\s_]))?/,d8=sn(u8,"u").replace(/openQuote/g,o8).replace(/punct/g,Ds).getRegex(),kT="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",f8=sn(kT,"gu").replace(/notPunctSpace/g,Ru).replace(/punctSpace/g,Gl).replace(/punct/g,Ds).getRegex(),h8=sn(kT,"gu").replace(/notPunctSpace/g,i8).replace(/punctSpace/g,s8).replace(/punct/g,mT).getRegex(),p8="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)[\\s](\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|(?:(?!\\*)punct|notPunctSpace)(\\*+)(?!\\*)(?=notPunctSpace)",m8=sn(p8,"gu").replace(/notPunctSpace/g,Ru).replace(/punctSpace/g,Gl).replace(/punct/g,Ds).getRegex(),g8=sn("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,Ru).replace(/punctSpace/g,Gl).replace(/punct/g,Ds).getRegex(),k8="^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)[\\s](_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)|(?:(?!_)punct|notPunctSpace)(_+)(?!_)(?=notPunctSpace)",w8=sn(k8,"gu").replace(/notPunctSpace/g,Ru).replace(/punctSpace/g,Gl).replace(/punct/g,Ds).getRegex(),y8=sn(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,Ds).getRegex(),v8="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",b8=sn(v8,"gu").replace(/notPunctSpace/g,Ru).replace(/punctSpace/g,Gl).replace(/punct/g,Ds).getRegex(),x8=sn(/\\(punct)/,"gu").replace(/punct/g,Ds).getRegex(),E8=sn(/^<(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(),S8=sn(ey).replace("(?:-->|$)","-->").getRegex(),_8=sn("^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",S8).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),Vf=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,N8=sn(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",Vf).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]+|(?=\))/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),wT=sn(/^!?\[(label)\]\[(ref)\]/).replace("label",Vf).replace("ref",Jw).getRegex(),yT=sn(/^!?\[(ref)\](?:\[\])?/).replace("ref",Jw).getRegex(),T8=sn("reflink|nolink(?!\\()","g").replace("reflink",wT).replace("nolink",yT).getRegex(),Ux=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,ny={_backpedal:ca,anyPunctuation:x8,autolink:E8,blockSkip:a8,br:pT,code:t8,del:ca,delLDelim:ca,delRDelim:ca,emStrongLDelim:l8,emStrongRDelimAst:f8,emStrongRDelimUnd:g8,escape:e8,link:N8,nolink:yT,punctuation:r8,reflink:wT,reflinkSearch:T8,tag:_8,text:n8,url:ca},j8={...ny,emStrongLDelim:d8,emStrongRDelimAst:m8,emStrongRDelimUnd:w8,link:sn(/^!?\[(label)\]\((.*?)\)/).replace("label",Vf).getRegex(),reflink:sn(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",Vf).getRegex()},tk={...ny,emStrongRDelimAst:h8,emStrongLDelim:c8,delLDelim:y8,delRDelim:b8,url:sn(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",Ux).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:sn(/^(`+|~+|[^`~])(?:(?=[`~])|(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",Ux).getRegex()},$8={...tk,br:sn(pT).replace("{2,}","*").getRegex(),text:sn(tk.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},uf={normal:ty,gfm:QF,pedantic:JF},Pc={normal:ny,gfm:tk,breaks:$8,pedantic:j8},C8={"&":"&","<":"<",">":">",'"':""","'":"'"},Hx=e=>C8[e];function hs(e,t){if(t){if(Ur.escapeTest.test(e))return e.replace(Ur.escapeReplace,Hx)}else if(Ur.escapeTestNoEncode.test(e))return e.replace(Ur.escapeReplaceNoEncode,Hx);return e}function Wx(e){try{e=encodeURI(e).replace(Ur.percentDecode,"%")}catch{return null}return e}function Kx(e,t){var i;let n=e.replace(Ur.findPipe,(a,c,u)=>{let h=!1,f=c;for(;--f>=0&&u[f]==="\\";)h=!h;return h?"|":" |"}),r=n.split(Ur.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(Ur.slashPipe,"|");return r}function hi(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 Zx(e){let t=e.split(`
|
|
132
|
+
`),n=t.length-1;for(;n>=0&&Ur.blankLine.test(t[n]);)n--;return t.length-n<=2?e:t.slice(0,n+1).join(`
|
|
133
|
+
`)}function A8(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 I8(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 qx(e,t,n,r,o){let i=t.href,a=t.title||null,c=e[1].replace(o.other.outputLinkReplace,"$1"),u=e[0].charAt(0)==="!";r.state.inLink=!0;let h=r.state.linkEmitted,f=r.state.inRawBlock;r.state.linkEmitted=!1;let m=r.inlineTokens(c),g=r.state.linkEmitted;if(r.state.linkEmitted=h,r.state.inLink=!1,!u){if(g){r.state.inRawBlock=f;return}r.state.linkEmitted=!0}return{type:u?"image":"link",raw:n,href:i,title:a,text:c,tokens:m}}function R8(e,t,n){let r=e.match(n.other.indentCodeCompensation);if(r===null)return t;let o=r[1];return t.split(`
|
|
134
|
+
`).map(i=>{let a=i.match(n.other.beginningSpace);if(a===null)return i;let[c]=a;return c.length>=o.length?i.slice(o.length):i}).join(`
|
|
135
|
+
`)}var Yf=class{constructor(e){Et(this,"options");Et(this,"rules");Et(this,"lexer");this.options=e||ja}space(e){let t=this.rules.block.newline.exec(e);if(t&&t[0].length>0)return{type:"space",raw:t[0]}}code(e){let t=this.rules.block.code.exec(e);if(t){let n=this.options.pedantic?t[0]:Zx(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=R8(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=hi(n,"#");(this.options.pedantic||!r||this.rules.other.endingSpaceChar.test(r))&&(n=r.trim())}return{type:"heading",raw:hi(t[0],`
|
|
136
|
+
`),depth:t[1].length,text:n,tokens:this.lexer.inline(n)}}}hr(e){let t=this.rules.block.hr.exec(e);if(t)return{type:"hr",raw:hi(t[0],`
|
|
137
|
+
`)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let n=hi(t[0],`
|
|
138
|
+
`).split(`
|
|
139
|
+
`),r="",o="",i=[];for(;n.length>0;){let a=!1,c=[],u;for(u=0;u<n.length;u++)if(this.rules.other.blockquoteStart.test(n[u]))c.push(n[u]),a=!0;else if(!a)c.push(n[u]);else break;n=n.slice(u);let h=c.join(`
|
|
140
|
+
`),f=h.replace(this.rules.other.blockquoteSetextReplace,`
|
|
141
|
+
$1`).replace(this.rules.other.blockquoteSetextReplace2,"");r=r?`${r}
|
|
142
|
+
${h}`:h,o=o?`${o}
|
|
143
|
+
${f}`:f;let m=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(f,i,!0),this.lexer.state.top=m,n.length===0)break;let g=i.at(-1);if((g==null?void 0:g.type)==="code")break;if((g==null?void 0:g.type)==="blockquote"){let w=g,y=n.join(`
|
|
144
|
+
`),v=w.raw+`
|
|
145
|
+
`+y.replace(this.rules.other.blockquoteSetextReplace2,""),N=this.blockquote(v);i[i.length-1]=N,r=`${r}
|
|
146
|
+
${y}`,o=o.substring(0,o.length-w.text.length)+N.text;break}else if((g==null?void 0:g.type)==="list"){let w=g,y=w.raw+`
|
|
147
|
+
`+n.join(`
|
|
148
|
+
`),v=this.list(y);i[i.length-1]=v,r=r.substring(0,r.length-g.raw.length)+v.raw,o=o.substring(0,o.length-w.raw.length)+v.raw,n=y.substring(i.at(-1).raw.length).split(`
|
|
149
|
+
`);continue}}return{type:"blockquote",raw:r,tokens:i,text:o}}}list(e){let t=this.rules.block.list.exec(e);if(t){let n=t[1].trim(),r=n.length>1,o={type:"list",raw:"",ordered:r,start:r?+n.slice(0,-1):"",loose:!1,items:[]};n=r?`\\d{1,9}\\${n.slice(-1)}`:`\\${n}`,this.options.pedantic&&(n=r?n:"[*+-]");let i=this.rules.other.listItemRegex(n),a=!1;for(;e;){let u=!1,h="",f="";if(!(t=i.exec(e))||this.rules.block.hr.test(e))break;h=t[0],e=e.substring(h.length);let m=I8(t[2].split(`
|
|
150
|
+
`,1)[0],t[1].length),g=e.split(`
|
|
151
|
+
`,1)[0],w=!m.trim(),y=0;if(this.options.pedantic?(y=2,f=m.trimStart()):w?y=t[1].length+1:(y=m.search(this.rules.other.nonSpaceChar),y=y>4?1:y,f=m.slice(y),y+=t[1].length),w&&this.rules.other.blankLine.test(g)&&(h+=g+`
|
|
152
|
+
`,e=e.substring(g.length+1),u=!0),!u){let v=this.rules.other.nextBulletRegex(y),N=this.rules.other.hrRegex(y),x=this.rules.other.fencesBeginRegex(y),_=this.rules.other.headingBeginRegex(y),T=this.rules.other.htmlBeginRegex(y),j=this.rules.other.blockquoteBeginRegex(y);for(;e;){let C=e.split(`
|
|
153
|
+
`,1)[0],M;if(g=C,this.options.pedantic?(g=g.replace(this.rules.other.listReplaceNesting," "),M=g):M=g.replace(this.rules.other.tabCharGlobal," "),x.test(g)||_.test(g)||T.test(g)||j.test(g)||v.test(g)||N.test(g))break;if(M.search(this.rules.other.nonSpaceChar)>=y||!g.trim())f+=`
|
|
154
|
+
`+M.slice(y);else{if(w||m.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||x.test(m)||_.test(m)||N.test(m))break;f+=`
|
|
155
|
+
`+g}w=!g.trim(),h+=C+`
|
|
156
|
+
`,e=e.substring(C.length+1),m=M.slice(y)}}o.loose||(a?o.loose=!0:this.rules.other.doubleBlankLine.test(h)&&(a=!0)),o.items.push({type:"list_item",raw:h,task:!!this.options.gfm&&this.rules.other.listIsTask.test(f),loose:!1,text:f,tokens:[]}),o.raw+=h}let c=o.items.at(-1);if(c)c.raw=c.raw.trimEnd(),c.text=c.text.trimEnd();else return;o.raw=o.raw.trimEnd();for(let u of o.items)if(this.lexer.state.top=!1,u.tokens=this.lexer.blockTokens(u.text,[]),!o.loose){let h=u.tokens.filter(m=>m.type==="space"),f=h.length>0&&h.some(m=>this.rules.other.anyLine.test(m.raw));o.loose=f}for(let u of o.items){let h=u.tokens[0];if(u.task&&((h==null?void 0:h.type)==="text"||(h==null?void 0:h.type)==="paragraph")){u.text=u.text.replace(this.rules.other.listReplaceTask,""),h.raw=h.raw.replace(this.rules.other.listReplaceTask,""),h.text=h.text.replace(this.rules.other.listReplaceTask,"");for(let m=this.lexer.inlineQueue.length-1;m>=0;m--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[m].src)){this.lexer.inlineQueue[m].src=this.lexer.inlineQueue[m].src.replace(this.rules.other.listReplaceTask,"");break}let f=this.rules.other.listTaskCheckbox.exec(u.raw);if(f){let m={type:"checkbox",raw:f[0]+" ",checked:f[0]!=="[ ]"};u.checked=m.checked,o.loose?u.tokens[0]&&["paragraph","text"].includes(u.tokens[0].type)&&"tokens"in u.tokens[0]&&u.tokens[0].tokens?(u.tokens[0].raw=m.raw+u.tokens[0].raw,u.tokens[0].text=m.raw+u.tokens[0].text,u.tokens[0].tokens.unshift(m)):u.tokens.unshift({type:"paragraph",raw:m.raw,text:m.raw,tokens:[m]}):u.tokens.unshift(m)}}else u.task&&(u.task=!1)}if(o.loose)for(let u of o.items){u.loose=!0;for(let h of u.tokens)h.type==="text"&&(h.type="paragraph")}return o}}html(e){let t=this.rules.block.html.exec(e);if(t){let n=Zx(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:hi(t[0],`
|
|
157
|
+
`),href:r,title:o}}}table(e){var a;let t=this.rules.block.table.exec(e);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let n=Kx(t[1]),r=t[2].replace(this.rules.other.tableAlignChars,"").split("|"),o=(a=t[3])!=null&&a.trim()?t[3].replace(this.rules.other.tableRowBlankLine,"").split(`
|
|
158
|
+
`):[],i={type:"table",raw:hi(t[0],`
|
|
159
|
+
`),header:[],align:[],rows:[]};if(n.length===r.length){for(let c of r)this.rules.other.tableAlignRight.test(c)?i.align.push("right"):this.rules.other.tableAlignCenter.test(c)?i.align.push("center"):this.rules.other.tableAlignLeft.test(c)?i.align.push("left"):i.align.push(null);for(let c=0;c<n.length;c++)i.header.push({text:n[c],tokens:this.lexer.inline(n[c]),header:!0,align:i.align[c]});for(let c of o)i.rows.push(Kx(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:hi(t[0],`
|
|
160
|
+
`),depth:t[2].charAt(0)==="="?1:2,text:n,tokens:this.lexer.inline(n)}}}paragraph(e){let t=this.rules.block.paragraph.exec(e);if(t){let n=t[1].charAt(t[1].length-1)===`
|
|
161
|
+
`?t[1].slice(0,-1):t[1];return{type:"paragraph",raw:t[0],text:n,tokens:this.lexer.inline(n)}}}text(e){let t=this.rules.block.text.exec(e);if(t)return{type:"text",raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(e){let t=this.rules.inline.escape.exec(e);if(t)return{type:"escape",raw:t[0],text:t[1]}}tag(e){let t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&this.rules.other.startATag.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(e){let t=this.rules.inline.link.exec(e);if(t){let n=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(n)){if(!this.rules.other.endAngleBracket.test(n))return;let i=hi(n.slice(0,-1),"\\");if((n.length-i.length)%2===0)return}else{let i=A8(t[2],"()");if(i===-2)return;if(i>-1){let a=(t[0].indexOf("!")===0?5:4)+t[1].length+i;t[2]=t[2].substring(0,i),t[0]=t[0].substring(0,a).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)),qx(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 qx(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,a,c=o,u=0,h=r[0][0],f=n===h,m=h==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(m.lastIndex=0,t=t.slice(-1*e.length+o);(r=m.exec(t))!==null;){if(i=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!i)continue;if(a=[...i].length,r[3]||r[4]){c+=a;continue}else if(r[5]||r[6]){if(o%3&&!((o+a)%3)){u+=a;continue}if(f)break}if(c-=a,c>0)continue;a=Math.min(a,a+c+u);let g=[...r[0]][0].length,w=e.slice(0,o+r.index+g+a);if(Math.min(o,a)%2){let v=w.slice(1,-1);return{type:"em",raw:w,text:v,tokens:this.lexer.inlineTokens(v)}}let y=w.slice(2,-2);return{type:"strong",raw:w,text:y,tokens:this.lexer.inlineTokens(y)}}}}codespan(e){let t=this.rules.inline.code.exec(e);if(t){let n=t[2].replace(this.rules.other.newLineCharGlobal," "),r=this.rules.other.nonSpaceChar.test(n),o=this.rules.other.startingSpaceChar.test(n)&&this.rules.other.endingSpaceChar.test(n);return r&&o&&(n=n.substring(1,n.length-1)),{type:"codespan",raw:t[0],text:n}}}br(e){let t=this.rules.inline.br.exec(e);if(t)return{type:"br",raw:t[0]}}del(e,t,n=""){let r=this.rules.inline.delLDelim.exec(e);if(r&&(!r[1]||!n||this.rules.inline.punctuation.exec(n))){let o=[...r[0]].length-1,i,a,c=o,u=this.rules.inline.delRDelim;for(u.lastIndex=0,t=t.slice(-1*e.length+o);(r=u.exec(t))!==null;){if(i=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!i||(a=[...i].length,a!==o))continue;if(r[3]||r[4]){c+=a;continue}if(c-=a,c>0)continue;a=Math.min(a,a+c);let h=[...r[0]][0].length,f=e.slice(0,o+r.index+h+a),m=f.slice(o,-o);return{type:"del",raw:f,text:m,tokens:this.lexer.inlineTokens(m)}}}}autolink(e){let t=this.rules.inline.autolink.exec(e);if(t){let n,r;return t[2]==="@"?(n=t[1],r="mailto:"+n):(n=t[1],r=n),{type:"link",raw:t[0],text:n,href:r,tokens:[{type:"text",raw:n,text:n}]}}}url(e){var n;let t;if(t=this.rules.inline.url.exec(e)){let r,o;if(t[2]==="@")r=t[0],o="mailto:"+r;else{let 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}}}},es=class nk{constructor(t){Et(this,"tokens");Et(this,"options");Et(this,"state");Et(this,"inlineQueue");Et(this,"tokenizer");this.tokens=[],this.tokens.links=Object.create(null),this.options=t||ja,this.options.tokenizer=this.options.tokenizer||new Yf,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:Ur,block:uf.normal,inline:Pc.normal};this.options.pedantic?(n.block=uf.pedantic,n.inline=Pc.pedantic):this.options.gfm&&(n.block=uf.gfm,this.options.breaks?n.inline=Pc.breaks:n.inline=Pc.gfm),this.tokenizer.rules=n}static get rules(){return{block:uf,inline:Pc}}static lex(t,n){return new nk(n).lex(t)}static lexInline(t,n){return new nk(n).inlineTokens(t)}lex(t){t=t.replace(Ur.carriageReturn,`
|
|
162
|
+
`),this.blockTokens(t,this.tokens);for(let n=0;n<this.inlineQueue.length;n++){let r=this.inlineQueue[n];this.inlineTokens(r.src,r.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(t,n=[],r=!1){var i,a,c;this.tokenizer.lexer=this,this.options.pedantic&&(t=t.replace(Ur.tabCharGlobal," ").replace(Ur.spaceLine,""));let o=1/0;for(;t;){if(t.length<o)o=t.length;else{this.infiniteLoopError(t.charCodeAt(0));break}let u;if((a=(i=this.options.extensions)==null?void 0:i.block)!=null&&a.some(f=>(u=f.call({lexer:this},t,n))?(t=t.substring(u.raw.length),n.push(u),!0):!1))continue;if(u=this.tokenizer.space(t)){t=t.substring(u.raw.length);let f=n.at(-1);u.raw.length===1&&f!==void 0?f.raw+=`
|
|
163
|
+
`:n.push(u);continue}if(u=this.tokenizer.code(t)){t=t.substring(u.raw.length);let f=n.at(-1);(f==null?void 0:f.type)==="paragraph"||(f==null?void 0:f.type)==="text"?(f.raw+=(f.raw.endsWith(`
|
|
164
|
+
`)?"":`
|
|
165
|
+
`)+u.raw,f.text+=`
|
|
166
|
+
`+u.text,this.inlineQueue.at(-1).src=f.text):n.push(u);continue}if(u=this.tokenizer.fences(t)){t=t.substring(u.raw.length),n.push(u);continue}if(u=this.tokenizer.heading(t)){t=t.substring(u.raw.length),n.push(u);continue}if(u=this.tokenizer.hr(t)){t=t.substring(u.raw.length),n.push(u);continue}if(u=this.tokenizer.blockquote(t)){t=t.substring(u.raw.length),n.push(u);continue}if(u=this.tokenizer.list(t)){t=t.substring(u.raw.length),n.push(u);continue}if(u=this.tokenizer.html(t)){t=t.substring(u.raw.length),n.push(u);continue}if(u=this.tokenizer.def(t)){t=t.substring(u.raw.length);let f=n.at(-1);(f==null?void 0:f.type)==="paragraph"||(f==null?void 0:f.type)==="text"?(f.raw+=(f.raw.endsWith(`
|
|
167
|
+
`)?"":`
|
|
168
|
+
`)+u.raw,f.text+=`
|
|
169
|
+
`+u.raw,this.inlineQueue.at(-1).src=f.text):this.tokens.links[u.tag]||(this.tokens.links[u.tag]={href:u.href,title:u.title},n.push(u));continue}if(u=this.tokenizer.table(t)){t=t.substring(u.raw.length),n.push(u);continue}if(u=this.tokenizer.lheading(t)){t=t.substring(u.raw.length),n.push(u);continue}let h=t;if((c=this.options.extensions)!=null&&c.startBlock){let f=1/0,m=t.slice(1),g;this.options.extensions.startBlock.forEach(w=>{g=w.call({lexer:this},m),typeof g=="number"&&g>=0&&(f=Math.min(f,g))}),f<1/0&&f>=0&&(h=t.substring(0,f+1))}if(this.state.top&&(u=this.tokenizer.paragraph(h))){let f=n.at(-1);r&&(f==null?void 0:f.type)==="paragraph"?(f.raw+=(f.raw.endsWith(`
|
|
170
|
+
`)?"":`
|
|
171
|
+
`)+u.raw,f.text+=`
|
|
172
|
+
`+u.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=f.text):n.push(u),r=h.length!==t.length,t=t.substring(u.raw.length);continue}if(u=this.tokenizer.text(t)){t=t.substring(u.raw.length);let f=n.at(-1);(f==null?void 0:f.type)==="text"?(f.raw+=(f.raw.endsWith(`
|
|
173
|
+
`)?"":`
|
|
174
|
+
`)+u.raw,f.text+=`
|
|
175
|
+
`+u.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=f.text):n.push(u);continue}if(t){this.infiniteLoopError(t.charCodeAt(0));break}}return this.state.top=!0,n}inline(t,n=[]){return this.inlineQueue.push({src:t,tokens:n}),n}linkInText(t){if(!t.includes("["))return!1;let n=this.tokenizer.rules.inline.link;for(let r of t.matchAll(this.tokenizer.rules.inline.blockSkip))if(n.test(r[0])&&t.charAt(r.index-1)!=="!")return!0;for(let r of t.matchAll(this.tokenizer.rules.inline.reflinkSearch)){let o=r[0],i=o.lastIndexOf("[");if(!(o.charAt(0)==="!"||!Object.hasOwn(this.tokens.links,o.slice(i+1,-1)))&&!(i>1&&this.linkInText(o.slice(1,i-1))))return!0}return!1}inlineTokens(t,n=[]){var c,u,h,f,m;this.tokenizer.lexer=this;let r=t;if(this.tokens.links&&t.includes("[")){let g=this.tokenizer.rules.inline.reflinkSearch,w=y=>{let v=y.lastIndexOf("[");if(!Object.hasOwn(this.tokens.links,y.slice(v+1,-1)))return y;if(v>1&&y.charAt(0)!=="!"){let N=y.slice(1,v-1);if(this.linkInText(N))return"["+N.replace(g,w)+"]["+"a".repeat(y.length-v-2)+"]"}return"["+"a".repeat(y.length-2)+"]"};r=r.replace(g,w)}r=r.replace(this.tokenizer.rules.inline.anyPunctuation,g=>"+".repeat(g.length)),r=r.replace(this.tokenizer.rules.inline.blockSkip,(g,w,y)=>{let v=y?y.length:0;return g.slice(0,v)+"["+"a".repeat(g.length-v-2)+"]"}),r=((u=(c=this.options.hooks)==null?void 0:c.emStrongMask)==null?void 0:u.call({lexer:this},r))??r;let o=!1,i="",a=1/0;for(;t;){if(t.length<a)a=t.length;else{this.infiniteLoopError(t.charCodeAt(0));break}o||(i=""),o=!1;let g;if((f=(h=this.options.extensions)==null?void 0:h.inline)!=null&&f.some(y=>(g=y.call({lexer:this},t,n))?(t=t.substring(g.raw.length),n.push(g),!0):!1))continue;if(g=this.tokenizer.escape(t)){t=t.substring(g.raw.length),n.push(g);continue}if(g=this.tokenizer.tag(t)){t=t.substring(g.raw.length),n.push(g);continue}if(g=this.tokenizer.link(t)){t=t.substring(g.raw.length),n.push(g);continue}if(g=this.tokenizer.reflink(t,this.tokens.links)){t=t.substring(g.raw.length);let y=n.at(-1);g.type==="text"&&(y==null?void 0:y.type)==="text"?(y.raw+=g.raw,y.text+=g.text):n.push(g);continue}if(g=this.tokenizer.emStrong(t,r,i)){t=t.substring(g.raw.length),n.push(g);continue}if(g=this.tokenizer.codespan(t)){t=t.substring(g.raw.length),n.push(g);continue}if(g=this.tokenizer.br(t)){t=t.substring(g.raw.length),n.push(g);continue}if(g=this.tokenizer.del(t,r,i)){t=t.substring(g.raw.length),n.push(g);continue}if(g=this.tokenizer.autolink(t)){t=t.substring(g.raw.length),n.push(g);continue}if(!this.state.inLink&&(g=this.tokenizer.url(t))){t=t.substring(g.raw.length),n.push(g);continue}let w=t;if((m=this.options.extensions)!=null&&m.startInline){let y=1/0,v=t.slice(1),N;this.options.extensions.startInline.forEach(x=>{N=x.call({lexer:this},v),typeof N=="number"&&N>=0&&(y=Math.min(y,N))}),y<1/0&&y>=0&&(w=t.substring(0,y+1))}if(g=this.tokenizer.inlineText(w)){t=t.substring(g.raw.length),g.raw.slice(-1)!=="_"&&(i=g.raw.slice(-1)),o=!0;let y=n.at(-1);(y==null?void 0:y.type)==="text"?(y.raw+=g.raw,y.text+=g.text):n.push(g);continue}if(t){this.infiniteLoopError(t.charCodeAt(0));break}}return n}infiniteLoopError(t){let n="Infinite loop on byte: "+t;if(this.options.silent)console.error(n);else throw new Error(n)}},fu=class{constructor(e){Et(this,"options");Et(this,"parser");this.options=e||ja}space(e){return""}code({text:e,lang:t,escaped:n}){var i;let r=(i=(t||"").match(Ur.notSpaceStart))==null?void 0:i[0],o=e.replace(Ur.endingNewline,"")+`
|
|
176
|
+
`;return r?'<pre><code class="language-'+hs(r)+'">'+(n?o:hs(o,!0))+`</code></pre>
|
|
177
|
+
`:"<pre><code>"+(n?o:hs(o,!0))+`</code></pre>
|
|
178
|
+
`}blockquote({tokens:e}){return`<blockquote>
|
|
179
|
+
${this.parser.parse(e)}</blockquote>
|
|
180
|
+
`}html({text:e}){return e}def(e){return""}heading({tokens:e,depth:t}){return`<h${t}>${this.parser.parseInline(e)}</h${t}>
|
|
181
|
+
`}hr(e){return`<hr>
|
|
182
|
+
`}list(e){let t=e.ordered,n=e.start,r="";for(let a=0;a<e.items.length;a++){let c=e.items[a];r+=this.listitem(c)}let o=t?"ol":"ul",i=t&&n!==1?' start="'+n+'"':"";return"<"+o+i+`>
|
|
183
|
+
`+r+"</"+o+`>
|
|
184
|
+
`}listitem(e){return`<li>${this.parser.parse(e.tokens)}</li>
|
|
185
|
+
`}checkbox({checked:e}){return"<input "+(e?'checked="" ':"")+'disabled="" type="checkbox"> '}paragraph({tokens:e}){return`<p>${this.parser.parseInline(e)}</p>
|
|
186
|
+
`}table(e){let t="",n="";for(let o=0;o<e.header.length;o++)n+=this.tablecell(e.header[o]);t+=this.tablerow({text:n});let r="";for(let o=0;o<e.rows.length;o++){let i=e.rows[o];n="";for(let a=0;a<i.length;a++)n+=this.tablecell(i[a]);r+=this.tablerow({text:n})}return r&&(r=`<tbody>${r}</tbody>`),`<table>
|
|
187
|
+
<thead>
|
|
188
|
+
`+t+`</thead>
|
|
189
|
+
`+r+`</table>
|
|
190
|
+
`}tablerow({text:e}){return`<tr>
|
|
191
|
+
${e}</tr>
|
|
192
|
+
`}tablecell(e){let t=this.parser.parseInline(e.tokens),n=e.header?"th":"td";return(e.align?`<${n} align="${e.align}">`:`<${n}>`)+t+`</${n}>
|
|
193
|
+
`}strong({tokens:e}){return`<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return`<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return`<code>${hs(e,!0)}</code>`}br(e){return"<br>"}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,tokens:n}){let r=this.parser.parseInline(n),o=Wx(e);if(o===null)return r;e=o;let i='<a href="'+e+'"';return t&&(i+=' title="'+hs(t)+'"'),i+=">"+r+"</a>",i}image({href:e,title:t,text:n,tokens:r}){r&&(n=this.parser.parseInline(r,this.parser.textRenderer));let o=Wx(e);if(o===null)return hs(n);e=o;let i=`<img src="${e}" alt="${hs(n)}"`;return t&&(i+=` title="${hs(t)}"`),i+=">",i}text(e){return"tokens"in e&&e.tokens?this.parser.parseInline(e.tokens):"escaped"in e&&e.escaped?e.text:hs(e.text)}},ry=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}},ts=class rk{constructor(t){Et(this,"options");Et(this,"renderer");Et(this,"textRenderer");this.options=t||ja,this.options.renderer=this.options.renderer||new fu,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new ry}static parse(t,n){return new rk(n).parse(t)}static parseInline(t,n){return new rk(n).parseInline(t)}parse(t){var r,o;this.renderer.parser=this;let n="";for(let i=0;i<t.length;i++){let a=t[i];if((o=(r=this.options.extensions)==null?void 0:r.renderers)!=null&&o[a.type]){let u=a,h=this.options.extensions.renderers[u.type].call({parser:this},u);if(h!==!1||!["space","hr","heading","code","table","blockquote","list","checkbox","html","def","paragraph","text"].includes(u.type)){n+=h||"";continue}}let c=a;switch(c.type){case"space":{n+=this.renderer.space(c);break}case"hr":{n+=this.renderer.hr(c);break}case"heading":{n+=this.renderer.heading(c);break}case"code":{n+=this.renderer.code(c);break}case"table":{n+=this.renderer.table(c);break}case"blockquote":{n+=this.renderer.blockquote(c);break}case"list":{n+=this.renderer.list(c);break}case"checkbox":{n+=this.renderer.checkbox(c);break}case"html":{n+=this.renderer.html(c);break}case"def":{n+=this.renderer.def(c);break}case"paragraph":{n+=this.renderer.paragraph(c);break}case"text":{n+=this.renderer.text(c);break}default:{let u='Token with "'+c.type+'" type was not found.';if(this.options.silent)return console.error(u),"";throw new Error(u)}}}return n}parseInline(t,n=this.renderer){var o,i;this.renderer.parser=this;let r="";for(let a=0;a<t.length;a++){let c=t[a];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}},mf,Uc=(mf=class{constructor(e){Et(this,"options");Et(this,"block");this.options=e||ja}preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(e=this.block){return e?es.lex:es.lexInline}provideParser(e=this.block){return e?ts.parse:ts.parseInline}},Et(mf,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens","emStrongMask"])),Et(mf,"passThroughHooksRespectAsync",new Set(["preprocess","postprocess","processAllTokens"])),mf),O8=class{constructor(...e){Et(this,"defaults",Yw());Et(this,"options",this.setOptions);Et(this,"parse",this.parseMarkdown(!0));Et(this,"parseInline",this.parseMarkdown(!1));Et(this,"Parser",ts);Et(this,"Renderer",fu);Et(this,"TextRenderer",ry);Et(this,"Lexer",es);Et(this,"Tokenizer",Yf);Et(this,"Hooks",Uc);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 a=i;for(let c of a.header)n=n.concat(this.walkTokens(c.tokens,t));for(let c of a.rows)for(let u of c)n=n.concat(this.walkTokens(u.tokens,t));break}case"list":{let a=i;n=n.concat(this.walkTokens(a.items,t));break}default:{let a=i;(o=(r=this.defaults.extensions)==null?void 0:r.childTokens)!=null&&o[a.type]?this.defaults.extensions.childTokens[a.type].forEach(c=>{let u=a[c].flat(1/0);n=n.concat(this.walkTokens(u,t))}):a.tokens&&(n=n.concat(this.walkTokens(a.tokens,t)))}}return n}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(n=>{let r={...n};if(r.async=this.defaults.async||r.async||!1,n.extensions&&(n.extensions.forEach(o=>{if(!o.name)throw new Error("extension name required");if("renderer"in o){let i=t.renderers[o.name];i?t.renderers[o.name]=function(...a){let c=o.renderer.apply(this,a);return c===!1&&(c=i.apply(this,a)),c}:t.renderers[o.name]=o.renderer}if("tokenizer"in o){if(!o.level||o.level!=="block"&&o.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let 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 fu(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 a=i,c=n.renderer[a],u=o[a];o[a]=(...h)=>{let f=c.apply(o,h);return f===!1&&(f=u.apply(o,h)),f||""}}r.renderer=o}if(n.tokenizer){let o=this.defaults.tokenizer||new Yf(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 a=i,c=n.tokenizer[a],u=o[a];o[a]=(...h)=>{let f=c.apply(o,h);return f===!1&&(f=u.apply(o,h)),f}}r.tokenizer=o}if(n.hooks){let o=this.defaults.hooks||new Uc;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 a=i,c=n.hooks[a],u=o[a];Uc.passThroughHooks.has(i)?o[a]=h=>{if(this.defaults.async&&Uc.passThroughHooksRespectAsync.has(i))return(async()=>{let m=await c.call(o,h);return u.call(o,m)})();let f=c.call(o,h);return u.call(o,f)}:o[a]=(...h)=>{if(this.defaults.async)return(async()=>{let m=await c.apply(o,h);return m===!1&&(m=await u.apply(o,h)),m})();let f=c.apply(o,h);return f===!1&&(f=u.apply(o,h)),f}}r.hooks=o}if(n.walkTokens){let o=this.defaults.walkTokens,i=n.walkTokens;r.walkTokens=function(a){let c=[];return c.push(i.call(this,a)),o&&(c=c.concat(o.call(this,a))),c}}this.defaults={...this.defaults,...r}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return es.lex(e,t??this.defaults)}parser(e,t){return ts.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 a=o.hooks?await o.hooks.preprocess(t):t,c=await(o.hooks?await o.hooks.provideLexer(e):e?es.lex:es.lexInline)(a,o),u=o.hooks?await o.hooks.processAllTokens(c):c;o.walkTokens&&await Promise.all(this.walkTokens(u,o.walkTokens));let h=await(o.hooks?await o.hooks.provideParser(e):e?ts.parse:ts.parseInline)(u,o);return o.hooks?await o.hooks.postprocess(h):h})().catch(i);try{o.hooks&&(t=o.hooks.preprocess(t));let a=(o.hooks?o.hooks.provideLexer(e):e?es.lex:es.lexInline)(t,o);o.hooks&&(a=o.hooks.processAllTokens(a)),o.walkTokens&&this.walkTokens(a,o.walkTokens);let c=(o.hooks?o.hooks.provideParser(e):e?ts.parse:ts.parseInline)(a,o);return o.hooks&&(c=o.hooks.postprocess(c)),c}catch(a){return i(a)}}}onError(e,t){return n=>{if(n.message+=`
|
|
194
|
+
Please report this to https://github.com/markedjs/marked.`,e){let r="<p>An error occurred:</p><pre>"+hs(n.message+"",!0)+"</pre>";return t?Promise.resolve(r):r}if(t)return Promise.reject(n);throw n}}},xa=new O8;function _n(e,t){return xa.parse(e,t)}_n.options=_n.setOptions=function(e){return xa.setOptions(e),_n.defaults=xa.defaults,uT(_n.defaults),_n};_n.getDefaults=Yw;_n.defaults=ja;function M8(...e){return xa.use(...e),_n.defaults=xa.defaults,uT(_n.defaults),_n}_n.use=M8;_n.walkTokens=function(e,t){return xa.walkTokens(e,t)};_n.parseInline=xa.parseInline;_n.Parser=ts;_n.parser=ts.parse;_n.Renderer=fu;_n.TextRenderer=ry;_n.Lexer=es;_n.lexer=es.lex;_n.Tokenizer=Yf;_n.Hooks=Uc;_n.parse=_n;_n.options;_n.setOptions;_n.walkTokens;_n.parseInline;ts.parse;es.lex;const Ea=100,P8=e=>e.type==="text-delta"||e.type==="thinking-delta"||e.type==="tool-delta";function L8(e,t){if(e.worktreeId!==t.worktreeId||e.event.type!==t.event.type)return!1;switch(e.event.type){case"text-delta":return e.event.messageId===t.event.messageId;case"tool-delta":return e.event.toolId===t.event.toolId;default:return!0}}const D8={now:()=>performance.now(),after:(e,t)=>void setTimeout(t,e)};function z8(e,t=D8){let n=[],r=!1,o=Number.NEGATIVE_INFINITY;const i=()=>{if(r=!1,n.length===0)return;const a=n;n=[],o=t.now();for(const c of a)e(c)};return a=>{if(a.t==="agent"&&P8(a.event)){const c={...a,event:{...a.event}},u=t.now();if(n.length===0&&u-o>=Ea){o=u,e(c);return}const h=n[n.length-1];h&&L8(h,c)?h.event={...h.event,text:h.event.text+c.event.text}:n.push(c),r||(r=!0,t.after(Math.max(0,o+Ea-u),i));return}i(),e(a)}}const vT="#toyon-link-pending",F8=/!?\[([^[\]\n]*)(?:\]\(([^()\s]*))?$/;function B8(e){const t=e.lastIndexOf(`
|
|
195
|
+
`)+1,n=e.slice(t),r=F8.exec(n);return!r||U8(e.slice(0,t))||H8(n.slice(0,r.index))?e:`${e.slice(0,t)}${n.slice(0,r.index)}[${r[1]}](${vT})`}function U8(e){let t=!1;for(const n of e.split(`
|
|
196
|
+
`))/^\s*(```|~~~)/.test(n)&&(t=!t);return t}function H8(e){let t=0;for(const n of e)n==="`"&&t++;return t%2===1}const Qm="__[a-z][a-z0-9_]*[a-z0-9]__",W8=new RegExp(`^(?:${Qm}\\.)+${Qm}|^${Qm}(?=\\.\\w|\\(|["'])`),K8={name:"dunder",level:"inline",start:e=>e.indexOf("__"),tokenizer(e){const t=W8.exec(e);if(t)return{type:"dunder",raw:t[0],text:t[0]}},renderer:e=>e.text},ma=e=>e.replace(/[&<>]/g,t=>t==="&"?"&":t==="<"?"<":">");function Z8({text:e}){return ma(e)}function q8(e){return`<div class="md-table">${G8.call(this,e)}</div>
|
|
197
|
+
`}function G8(e){if(e.header.some(n=>n.text.trim()))return fu.prototype.table.call(this,e);let t="";for(const n of e.rows){let r="";for(const o of n)r+=this.tablecell(o);t+=this.tablerow({text:r})}return`<table>
|
|
198
|
+
<tbody>${t}</tbody></table>
|
|
199
|
+
`}function ok(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 bT(e,t,n){const r=h=>e.map((f,m)=>h(f)&&f.id!==t?m:-1).filter(f=>f>=0),i=[()=>r(h=>h.agent==="waiting"),()=>r(h=>!!h.unseen),()=>r(h=>h.agent==="working")].reduce((h,f)=>h.length>0?h:f(),[]),a=e.findIndex(h=>h.id===t),c=n>0?i.find(h=>h>a)??i[0]:i.findLast(h=>h<a)??i[i.length-1],u=c===void 0?void 0:e[c];return u?{activate:u.id}:null}function oy(e,t,n){const r=bT(e,t,n);if(r)return r;const o=e[0];return o&&o.id!==t?{activate:o.id}:null}function V8(e,t,n){const r=[ok(e,t),...n.map(o=>ok(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 Y8(e,t,n){const r=[i=>i.agent==="waiting",i=>!!i.unseen];for(const i of r){if(e.some(a=>i(a)&&a.id!==t)){const a=bT(e,t,1);return a&&{origin:null,activate:a.activate}}for(const a of n){const c=a.rows.find(i);if(c)return{origin:a.origin,activate:c.id}}}const o=oy(e,t,1);return o&&{origin:null,activate:o.activate}}function xT(e,{sock:t,dispatch:n}){var m,g;const r=w=>w?"hide":"show",o=e.repos.some(w=>w.id===e.activeRepoId),i=(m=nn(e,e.activeId))==null?void 0:m.worktree.id,a=[];o&&(a.push({id:"new",label:"new worktree…",key:zt("new"),onClick:()=>n({a:"open-draft"})}),a.push({id:"refs",label:"open a branch or PR…",key:zt("refs"),onClick:()=>n({a:"open",overlay:{kind:"refs"}})})),i&&(a.push({id:"jump",label:"jump to file…",key:zt("quick-open"),onClick:()=>n({a:"open",overlay:{kind:"quick-open"}})}),a.push({id:"search",label:"search in files…",key:zt("search"),onClick:()=>n({a:"open",overlay:{kind:"search"}})})),Hf(e)&&a.push({id:"routes",label:"go to page…",key:zt("routes"),onClick:()=>n({a:"open",overlay:{kind:"routes"}})}),o&&a.push({id:"chats",label:"search chats…",key:zt("chats"),onClick:()=>n({a:"open",overlay:{kind:"chats"}})});const c=oy(e.visible,e.activeId,1);c&&a.push({id:"wt-unseen-next",label:"next that needs you",key:zt("wt-unseen-next"),onClick:()=>n({a:"activate",id:c.activate})}),a.push({id:"project",label:e.repos.length>1?"switch project…":"open project…",key:zt("project"),onClick:()=>n({a:"open",overlay:{kind:"projects",form:"center"}})});const u=[{id:"changes",label:`${r(e.layout.changes)} changes panel`,key:zt("changes"),onClick:()=>n({a:"toggle-changes"})},{id:"files",label:`${r(e.layout.changes&&Dl(e)==="files")} files`,key:zt("files"),onClick:()=>n(e.layout.changes&&Dl(e)==="files"?{a:"toggle-changes"}:{a:"focus-changes",tab:"files"})},{id:"chat",label:`${r(e.layout.chat)} chat panel`,key:zt("composer"),onClick:()=>n({a:"toggle-chat"})},{id:"terminal",label:`${r(e.layout.term)} terminal`,key:zt("terminal"),onClick:()=>n({a:"toggle-terminal"})},{id:"rail",label:`${r(e.railOpen)} worktree panel`,key:zt("rail"),onClick:()=>n({a:"toggle-rail"})},{id:"design",label:`${r(e.layout.design)} design system`,key:zt("design"),onClick:()=>n({a:"toggle-design"})},{id:"zen",label:"full-bleed preview",key:zt("zen"),onClick:()=>n({a:"toggle-zen"})}],h=[{id:"commands",label:"command palette",key:zt("commands"),onClick:()=>n({a:"open",overlay:{kind:"commands"}})},{id:"keys",label:"settings & shortcuts",key:zt("keys"),onClick:()=>n({a:"open",overlay:{kind:"keys"}})}];(g=e.self)!=null&&g.restart&&h.push({id:"restart-daemon",label:"restart Toyon",onClick:()=>t==null?void 0:t.send({t:"restart-daemon"})}),h.push({id:"devices",label:e.knocks.length>0?`let a device in (${e.knocks.length})`:"your devices",onClick:()=>n({a:"open",overlay:{kind:"devices"}})});const f=rs(e)?new Set(["chat","design","zen"]):null;return Bn([a,f?u.filter(w=>!f.has(w.id)):u,h])}function sk(e,t){const n=e.get(t);if(!n||n.serving)return[];const r=e.displayName(t),o=[];e.active().origin!==t&&o.push({id:`machine:${t}`,label:`switch to ${r}`,onClick:()=>e.activate(t)});const i=[{id:`forget-machine:${t}`,label:`forget ${r}…`,danger:!0,onClick:()=>{window.confirm(`Forget ${r}?
|
|
200
|
+
|
|
201
|
+
It leaves your list, here and in every browser Toyon on this machine serves, and this browser forgets what it had selected there. Toyon on that machine is not touched; pair again to list it.`)&&e.serving().sock.send({t:"forget-machine",origin:t})}}];return Bn([o,i])}function sy(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 ET(e,{sock:t}){return[{id:"restart:shell",label:"restart shell",onClick:()=>t==null?void 0:t.send({t:"term-restart",worktreeId:e,stream:Po})}]}function X8(e,t,n,r){return Bn([[...e.flatMap(o=>sy(o,t,r)),...ET(t,r)],[{id:"terminal",label:`${n?"hide":"show"} terminal`,onClick:()=>r.dispatch({a:"toggle-terminal"})}]])}const hu=e=>/^(~|\/|\.\.?\/)/.test(e.trim());function iy(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 Q8(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("/")),a=new Map;for(const h of r)a.set(h,(a.get(h)??0)+1);let c="",u=0;for(const[h,f]of[...a].sort(([m],[g])=>m.localeCompare(g)))(f>u||f===u&&h===i)&&(c=h,u=f);return c?ST(c,n):`~/${tS}`}function ST(e,t){return t&&(e===t||e.startsWith(`${t}/`))?`~${e.slice(t.length)}`:e}function _T(e,t){return`${e.replace(/\/+$/,"")}/${t.trim()}`}function J8(e){const t=e.query.trim(),n=()=>e.entries.map(a=>({kind:a.isFile?"file":"dir",entry:a}));if(!hu(t)){const a=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=[...a,...c],h=(e.others??[]).flatMap(g=>g.repos.length===0?ns(t,g.name)?[{kind:"machine",machine:g}]:[]:g.repos.filter(w=>ns(t,w.name,w.path,g.name)).map(w=>({kind:"repo",repo:w,machine:g})));if(!t){const g=a.find(y=>y.kind==="repo"&&y.repo.id===e.current);return[...g?[g,...a.filter(y=>y!==g)]:a,...c,{kind:"new"},{kind:"disk"},{kind:"add-machine"},...h]}const f=_P(t);if(f)return u.length>0?u:[{kind:"clone",url:f.url,name:f.name}];const m=g=>g.toLowerCase()===t.toLowerCase();return e.repos.some(g=>m(g.name))||e.pending.some(g=>m(g.name))?[...u,...h]:nu(t)?[...u,...h]:[...u,{kind:"create",name:t,parent:null},...h]}if(e.answered.trim()!==t||!e.target)return n();const{target:r}=e;if(r.exists){const a=t.replace(/\/+$/,"")||"/";if(r.isRepo)return[...n(),{kind:"open",path:a}];if(!r.isDir)return n();const c=Fl(a,e.home);return c==="/"||c===e.home||e.repos.some(h=>h.path.startsWith(`${c}/`))?n():[...n(),{kind:"init",path:a}]}if(t.endsWith("/"))return n();if(!r.parentExists)return[];const{parent:o,name:i}=iy(t);return nu(i)?n():[...n(),{kind:"create",name:i,parent:o}]}function Fl(e,t){return t&&(e==="~"||e.startsWith("~/"))?`${t}${e.slice(1)}`:e}function NT(e,t){const n=Fl(e,t).replace(/\/+$/,"");return n.startsWith("/")?ST(n.slice(0,n.lastIndexOf("/"))||"/",t):null}function ik(e,t){const n=Fl(e,t).replace(/\/+$/,"");return n.slice(n.lastIndexOf("/")+1)||"/"}function e9(e){const t=e.query.trim(),n=t.lastIndexOf("/"),r=n<0?"":t.slice(0,n)||"/",o=Fl(r,e.home);if(!hu(t)||!o.startsWith("/"))return[];const i=t.slice(n+1).toLowerCase(),a=e.answered.trim()===t?e.target:null,c=!a||(i?a.parentExists:a.exists&&a.isDir&&!a.isRepo),u=e.entries.filter(f=>{if(f.isRepo||f.isFile)return!1;const m=Fl(f.path,e.home);return(m.slice(0,m.lastIndexOf("/"))||"/")===o&&f.name.toLowerCase().startsWith(i)}),h=NT(r,e.home);return[...c?[{kind:"here",path:r}]:[],...h?[{kind:"up",path:h}]:[],...u.map(f=>({kind:"dir",entry:f}))]}function pu({sock:e,dispatch:t},n){t({a:"open-repo"}),e==null||e.send(n)}function TT(e,t){const{parent:n,name:r}=iy(t);pu(e,{t:"create-repo",mode:"init",parent:n,name:r})}function t9(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 Kh(e,t,{sock:n,dispatch:r}){const o=[];e.id!==t&&o.push({id:`repo:${e.id}`,label:`switch to ${e.name}`,onClick:()=>r({a:"activate-repo",id:e.id})});const i=[{id:`setup:${e.id}`,label:"project settings…",detail:e.configFile,onClick:()=>r({a:"open",overlay:{kind:"setup",repoId:e.id}})},{id:`archived:${e.id}`,label:"archived worktrees…",onClick:()=>{r({a:"activate-repo",id:e.id}),r({a:"open",overlay:{kind:"chats",names:!0}})}},{id:`forget:${e.id}`,label:"forget project…",danger:!0,onClick:()=>{window.confirm(`Forget ${e.name}?
|
|
202
|
+
|
|
203
|
+
Its procs stop, it leaves the project list, and the chat on main is deleted. The checkout is not touched, and archived worktrees come back when you open it again.`)&&(n==null||n.send({t:"forget-repo",repoId:e.id}))}}];return Bn([o,i])}const Xf={dark:"dark",light:"light",system:"follow system",daylight:"follow daylight"},Qf={use:"while in use",always:"always",off:"off"};function n9(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 jT(e,{sock:t,dispatch:n}){var a;const r=e.themePrefs,o=c=>{var u;return((u=e.themes.find(h=>h.id===c))==null?void 0:u.name)??c},i=lz();return Bn([[{id:"theme",label:"theme…",detail:xh(r,e.themes,RS(e)).name,sub:!0,onClick:()=>n({a:"open",overlay:{kind:"theme",slot:"theme"}})},{id:"appearance",topic:"theme",label:"light or dark…",detail:Xf[r.mode],sub:!0,onClick:()=>n({a:"open",overlay:{kind:"appearance"}})}],[{id:"agent",label:"default agent…",detail:((a=e.agents.find(c=>c.id===e.defaultAgent))==null?void 0:a.name)??e.defaultAgent,sub:!0,onClick:()=>n({a:"open",overlay:{kind:"agent"}})}],[{id:"chat-side",label:"chat side",detail:e.chatSide,onClick:()=>n({a:"toggle-chat-side"})},...e.frame==="phone"?[{id:"black-ground",topic:"theme",label:"OLED black",detail:e.blackGround?"on":"off",onClick:()=>n({a:"toggle-black-ground"})}]:[],...i.access==="none"?[]:[{id:"clipboard-offer",label:"offer what is copied",detail:i.access==="denied"?"blocked in site settings":i.on?"on":"off",onClick:()=>cz(!i.on)}]],...e.keepAwake===null?[]:[[{id:"keep-awake",label:"keep awake…",detail:Qf[e.keepAwake],sub:!0,onClick:()=>n({a:"open",overlay:{kind:"keep-awake"}})}]],[{id:"theme-import",topic:"theme",label:"import a VS Code theme…",onClick:()=>n9((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 r9(e,t,n,r,o,i={machines:[],switchTo:()=>{},forget:()=>{}}){const a=[],c=(g,w,y,v,N)=>a.push({id:g,label:w,hint:v,run:y,sub:N}),u=(g,w)=>{for(const y of g){if(!gs(y)||y.disabled!==void 0||y.checked)continue;const v=y.key??(typeof y.detail=="string"?y.detail:void 0),N=w?`${w.scope}:${y.id}`:y.id,x=y.topic?`${y.topic}: ${y.label}`:y.label;c(N,w?`${x} · ${w.name}`:x,y.onClick,v,y.sub)}},h={sock:n,dispatch:t},f=r,m=f==null?void 0:f.worktree.id;if(u(xT(e,h).filter(g=>!gs(g)||g.id!=="commands")),o&&u(Kh(o,o.id,h),{scope:"project",name:o.name}),m&&!rs(e)){c("pick",e.picking==="chat"?"cancel element picker":"pick an element for the chat",()=>au(m,e.picking,t,"chat"),zt("pick")),c("inspect",e.picking==="code"?"cancel element picker":"pick an element to open its code",()=>au(m,e.picking,t,"code"),zt("inspect"));const g=Ag(e);(g==null?void 0:g.act)==="start"?c("reload","start the preview",()=>n==null?void 0:n.send({t:"preview-start",worktreeId:g.id})):c("reload","reload preview",()=>dn.post(m,{type:"reload"}))}if(u(jT(e,h)),f&&m){const g=e.repos.find(w=>w.id===f.worktree.repoId)??null;u(_N(f,g,e,h,{hostname:e.hostname,palette:!0}),{scope:"wt",name:jg(f,g)});for(const w of f.procs)u(sy(w,m,h))}e.visible.forEach((g,w)=>{var N;if(g.worktree.id===m)return;const v=!!e.activeRepoId&&g.repoId!==e.activeRepoId?` in ${((N=e.repos.find(x=>x.id===g.repoId))==null?void 0:N.name)??g.repoId}`:"";c(`go:${g.worktree.id}`,`switch to ${jg(g,o)}${v}`,()=>t({a:"activate",id:g.worktree.id}),aA(w,e.visible.length))});for(const g of e.repos)g.id!==(o==null?void 0:o.id)&&c(`repo:${g.id}`,`switch to project ${g.name}`,()=>t({a:"activate-repo",id:g.id}));for(const g of i.machines){for(const w of g.repos)c(`machine:${g.origin}:${w.id}`,`switch to project ${w.name} on ${g.name}`,()=>i.switchTo(g.origin,w.id));c(`forget-machine:${g.origin}`,`forget ${g.name}`,()=>i.forget(g.origin))}return a}function $T(){const e=lt(),t=tt(),{host:n}=Wr(),r=Un(),o=is(),i=i_(),a=P($=>$.picking),c=P($=>$.layout),u=P($=>$.chatSide),h=P($=>$.blackGround),f=P($=>$.keepAwake),m=P($=>$.railOpen),g=P($=>$.themePrefs),w=P($=>$.themes),y=P($=>$.systemDark),v=P($=>$.daylight),N=P($=>$.rows),x=P($=>$.visible),_=P($=>$.activeId),T=P($=>$.activeRepoId),j=P($=>$.repos),C=P($=>$.agents),M=P($=>$.defaultAgent),I=P($=>$.shipping),O=P($=>$.remote),A=P($=>$.managed),z=P($=>$.frame),B=P($=>$.self),U=P($=>$.archivedPage),Q=P($=>$.notesPage),ae=P($=>$.archived),ee=P($=>$.knocks),de=P($=>$.tailscale);return S.useMemo(()=>{const $={picking:a,layout:c,chatSide:u,blackGround:h,keepAwake:f,railOpen:m,themePrefs:g,themes:w,systemDark:y,daylight:v,rows:N,visible:x,activeId:_,activeRepoId:T,repos:j,agents:C,defaultAgent:M,shipping:I,frame:z,self:B,archivedPage:U,notesPage:Q,archived:ae,knocks:ee,hostname:n,drafted:V=>dw(r.getState(),V)},K={machines:i,switchTo:(V,X)=>{var W;(W=o.get(V))==null||W.store.dispatch({a:"activate-repo",id:X}),o.activate(V)},forget:V=>{const X=sk(o,V).find(W=>gs(W)&&W.id.startsWith("forget-machine:"));X&&gs(X)&&X.onClick()}};return r9($,e,t,nn($,_),Ii($,T),K)},[a,c,u,h,f,m,g,w,y,v,N,x,_,T,j,C,M,I,O,A,z,B,U,Q,ae,ee,de,e,t,n,r,o,i])}function CT(e,t){const n=t.trim().toLowerCase();if(!n)return e;const r=[];for(const o of e){const i=ak(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 ak(e,t){const n=ay(e,t);if(!n)return 0;let r=0,o=0,i=-1;for(const a of n)o=a===i+1?o+1:1,r+=o+(AT(e,a)?3:0),i=a;return r+Math.max(0,40-e.length/4)}const AT=(e,t)=>t===0||/[\s:\-–—·/.(]/.test(e[t-1]);function ay(e,t){const n=e.toLowerCase(),r=[];let o=0;for(const i of t.toLowerCase()){let a=-1;if(n[o]===i)a=o;else if(i===" ")a=n.indexOf(" ",o);else for(let c=n.indexOf(i,o);c!==-1;c=n.indexOf(i,c+1))if(AT(n,c)){a=c;break}if(a===-1)return null;r.push(a),o=a+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))},o9=/^[^\s]*$/,s9=e=>e.split(/\s+/).slice(1).every(t=>!t||/[a-z0-9]/i.test(t));function Jm(e,t,n){if(e.startsWith("!"))return null;if(e.startsWith("/")){const a=e.indexOf(" "),c=a===-1?e.length:a;if(!(e.indexOf("/",1)!==-1&&e.indexOf("/",1)<c)&&t<=c)return{kind:"command",query:e.slice(1,t),from:0,to:c}}const r=e.lastIndexOf("@",Math.max(0,t-1));if(r===-1||r>=t||r>0&&!/\s/.test(e[r-1]??""))return null;const o=e.slice(r+1,t);if(!o9.test(o)&&!(s9(o)&&(n!=null&&n(o))))return null;let i=t;for(;i<e.length&&!/\s/.test(e[i]??"");)i++;return{kind:"file",query:o,from:r,to:i}}const lk=new Map,Gx={files:new Set,folders:new Set,worktrees:lk,titled:[]},Vx=new WeakMap;function IT(e,t=lk){let n;if(e?(n=Vx.get(e),n||(n={...Gx,files:new Set(e),folders:new Set(TS(e))},Vx.set(e,n))):n=Gx,t===lk)return n;const r=[...t].map(([o,i])=>({...i,branch:o})).sort((o,i)=>i.title.length-o.title.length);return{...n,worktrees:t,titled:r}}function RT(e,t){const n=new Map;for(const{branch:r,...o}of e)n.set(r,o);for(const r of t??[])n.has(r.branch)||n.set(r.branch,{id:r.id,title:r.title,archived:!0});return n}const i9=/(^|\s)(@\S+)/g,a9=/[.,;:!?)\]}'"]$/,l9=/^[.,;:!?)\]}'"]*(\s|$)/;function Yx(e,t){if(e==="changes")return{kind:"changes",text:"@changes"};if(t.files.has(e))return{kind:"file",text:`@${e}`,path:e};const n=e.replace(/\/+$/,"");if(n&&t.folders.has(n))return{kind:"folder",text:`@${e}`,path:n};const r=t.worktrees.get(e);return r?{kind:"worktree",text:`@${e}`,branch:e,...r}:null}function c9(e,t){const n=e.toLowerCase();for(const r of t.titled){const o=r.title.toLowerCase();if(o&&n.startsWith(o)&&l9.test(e.slice(o.length)))return{kind:"worktree",text:`@${e.slice(0,o.length)}`,...r}}return null}function Zh(e){const t=[];return e.archived?t.push("archived"):(e.state&&t.push(e.state),e.at!==void 0&&t.push(`last sent ${bo(sr(e.at))}`)),e.branch&&t.push(e.branch),e.dir&&t.push(e.dir),{text:e.title,detail:t,dot:e.archived?"archived":e.dot}}function u9(e,t,n){let r=0;for(const o of ly(e,n)){if(r===t)return o.kind!=="text";r+=o.text.length}return!1}function ly(e,t){const n=[];let r=0;const o=i=>{if(!i)return;const a=n.at(-1);(a==null?void 0:a.kind)==="text"?a.text+=i:n.push({kind:"text",text:i})};for(const i of e.matchAll(i9)){const a=i.index+(i[1]??"").length;if(a<r)continue;const c=c9(e.slice(a+1),t);let u=(i[2]??"").slice(1),h=c&&/\s/.test(c.text)?c:Yx(u,t);for(;!h&&a9.test(u);)u=u.slice(0,-1),h=u?Yx(u,t):null;h??(h=c),h&&(o(e.slice(r,a)),n.push(h),r=a+h.text.length)}return o(e.slice(r)),n}function Xx(e,t){return ly(e,t).map(n=>n.kind==="worktree"?`@${n.branch}`:n.text).join("")}function d9(e,t,n){return{text:e.slice(0,t.from)+n+e.slice(t.to),caret:t.from+n.length}}function f9(e,t){const n=t.trim().toLowerCase();if(!n)return e;const r=i=>e.map((a,c)=>({c:a,i:c,score:i(a)})).filter(a=>a.score>0).sort((a,c)=>c.score-a.score||a.i-c.i).map(a=>a.c),o=r(i=>ak(i.name,n));return o.length>0?o:r(i=>ak(i.description,n))}const Qx=e=>e.slice(e.lastIndexOf("/")+1);function h9(e,t,n){const r=[],o=new Set;for(const i of e){const a=i.worktree;if(a.repoId!==n)continue;const c=Qx(a.path);o.has(c)||(o.add(c),r.push({dir:c,id:a.id,title:a.title,branch:a.branch}))}for(const i of t??[]){const a=Qx(i.path);i.repoId!==n||o.has(a)||(o.add(a),r.push({dir:a,id:i.id,title:i.title,branch:i.branch,archived:!0}))}return r}const Jx=new WeakMap;function p9(e,t){let n=Jx.get(e.visible);n||(n=new Map,Jx.set(e.visible,n));const r=e.archived[t],o=n.get(t);if(o&&o.archived===r)return o.key;const i=JSON.stringify(h9(e.visible,r,t));return n.set(t,{archived:r,key:i}),i}function m9(e){const t=new Map;for(const n of JSON.parse(e))t.set(n.dir,n);return n=>t.get(n)??null}const OT="wt-[0-9a-f]{4}",g9=new RegExp(`(^|[^\\w\\-/\`])\`?${OT}(?![\\w\\-/\`])`),k9=new RegExp(`^(\`?)(${OT})\\1(?![\\w\\-/\`])`),ia=e=>ma(e).replace(/"/g,""");function w9(e){return{name:"worktree",level:"inline",start:t=>{const n=g9.exec(t);return n?n.index+n[1].length:void 0},tokenizer(t){const n=k9.exec(t);if(n)return{type:"worktree",raw:n[0],text:n[2],code:n[1]!==""}},renderer(t){var c;const n=t.text,r=((c=e())==null?void 0:c(n))??null;if(!r)return t.code?`<code>${n}</code>`:n;const o=Zh({id:r.id,title:r.title,branch:r.branch,dir:n,...r.archived?{archived:!0}:{}}),i=r.archived?' data-archived=""':"",a=o.dot?` data-tip-dot="${ia(o.dot)}"`:"";return`<span class="chat-mention" data-worktree="${ia(r.id)}" data-branch="${ia(r.branch)}" data-dir="${ia(n)}"${i} data-tip="${ia(o.text)}" data-tip-detail="${ia(o.detail.join(`
|
|
204
|
+
`))}"${a} data-tip-placement="follow">@${ma(r.title)}<span class="chat-mention-dot"><span class="dot${o.dot?` ${ia(o.dot)}`:""}"></span></span></span>`}}}const y9=4*Ea;function v9(e,t,n){if(!e)return{from:t,to:t,at:n,span:Ea};const r=Math.min(MT(e,n),t),o=Math.min(Math.max(n-e.at,Ea),y9);return{from:r,to:t,at:n,span:o}}function MT(e,t){const n=t-e.at;return n>=e.span?e.to:e.from+Math.floor((e.to-e.from)*Math.max(0,n)/e.span)}function b9(e,t){if(t>=e.length)return e;const n=e.charCodeAt(t);return e.slice(0,n>=56320&&n<=57343?t+1:t)}function x9(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"}}),a={begin:/<<-?\s*(?=\w+)/,starts:{contains:[e.END_SAME_AS_BEGIN({begin:/(\w+)/,end:/(\w+)/,className:"string"})]}},c={className:"string",begin:/"/,end:/"/,contains:[e.BACKSLASH_ESCAPE,n,o]};o.contains.push(c);const u={match:/\\"/},h={className:"string",begin:/'/,end:/'/},f={match:/\\'/},m={begin:/\$?\(\(/,end:/\)\)/,contains:[{begin:/\d+#[0-9a-f]+/,className:"number"},e.NUMBER_MODE,n]},g=["fish","bash","zsh","sh","csh","ksh","tcsh","dash","scsh"],w=e.SHEBANG({binary:`(${g.join("|")})`,relevance:10}),y={className:"function",begin:/\w[\w\d_]*\s*\(\s*\)\s*\{/,returnBegin:!0,contains:[e.inherit(e.TITLE_MODE,{begin:/\w[\w\d_]*/})],relevance:0},v=["if","then","else","elif","fi","time","for","while","until","in","do","done","case","esac","coproc","function","select"],N=["true","false"],x={match:/(\/[a-z._-]+)+/},_=["break","cd","continue","eval","exec","exit","export","getopts","hash","pwd","readonly","return","shift","test","times","trap","umask","unset"],T=["alias","bind","builtin","caller","command","declare","echo","enable","help","let","local","logout","mapfile","printf","read","readarray","source","sudo","type","typeset","ulimit","unalias"],j=["autoload","bg","bindkey","bye","cap","chdir","clone","comparguments","compcall","compctl","compdescribe","compfiles","compgroups","compquote","comptags","comptry","compvalues","dirs","disable","disown","echotc","echoti","emulate","fc","fg","float","functions","getcap","getln","history","integer","jobs","kill","limit","log","noglob","popd","print","pushd","pushln","rehash","sched","setcap","setopt","stat","suspend","ttyctl","unfunction","unhash","unlimit","unsetopt","vared","wait","whence","where","which","zcompile","zformat","zftp","zle","zmodload","zparseopts","zprof","zpty","zregexparse","zsocket","zstyle","ztcp"],C=["chcon","chgrp","chown","chmod","cp","dd","df","dir","dircolors","ln","ls","mkdir","mkfifo","mknod","mktemp","mv","realpath","rm","rmdir","shred","sync","touch","truncate","vdir","b2sum","base32","base64","cat","cksum","comm","csplit","cut","expand","fmt","fold","head","join","md5sum","nl","numfmt","od","paste","ptx","pr","sha1sum","sha224sum","sha256sum","sha384sum","sha512sum","shuf","sort","split","sum","tac","tail","tr","tsort","unexpand","uniq","wc","arch","basename","chroot","date","dirname","du","echo","env","expr","factor","groups","hostid","id","link","logname","nice","nohup","nproc","pathchk","pinky","printenv","printf","pwd","readlink","runcon","seq","sleep","stat","stdbuf","stty","tee","test","timeout","tty","uname","unlink","uptime","users","who","whoami","yes"];return{name:"Bash",aliases:["sh","zsh"],keywords:{$pattern:/\b[a-z][a-z0-9._-]+\b/,keyword:v,literal:N,built_in:[..._,...T,"set","shopt",...j,...C]},contains:[w,e.SHEBANG(),y,m,i,a,x,c,u,h,f,n]}}const E9=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_-]*/}}),S9=["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"],_9=["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"],N9=[...S9,..._9],T9=["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(),j9=["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(),$9=["after","backdrop","before","cue","cue-region","first-letter","first-line","grammar-error","marker","part","placeholder","selection","slotted","spelling-error"].sort().reverse(),C9=["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 A9(e){const t=e.regex,n=E9(e),r={begin:/-(webkit|moz|ms|o)-(?=[a-z])/},o="and or not only",i=/@-?\w[\w]*(-\w+)*/,a="[a-zA-Z-][a-zA-Z0-9_-]*",c=[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE];return{name:"CSS",case_insensitive:!0,illegal:/[=|'\$]/,keywords:{keyframePosition:"from to"},classNameAliases:{keyframePosition:"selector-tag"},contains:[n.BLOCK_COMMENT,r,n.CSS_NUMBER_MODE,{className:"selector-id",begin:/#[A-Za-z0-9_-]+/,relevance:0},{className:"selector-class",begin:"\\."+a,relevance:0},n.ATTRIBUTE_SELECTOR_MODE,{className:"selector-pseudo",variants:[{begin:":("+j9.join("|")+")"},{begin:":(:)?("+$9.join("|")+")"}]},n.CSS_VARIABLE,{className:"attribute",begin:"\\b("+C9.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:T9.join(" ")},contains:[{begin:/[a-z-]+(?=:)/,className:"attribute"},...c,n.CSS_NUMBER_MODE]}]},{className:"selector-tag",begin:"\\b("+N9.join("|")+")\\b"}]}}function I9(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 R9(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/},a={className:"string",contains:[e.BACKSLASH_ESCAPE],variants:[{begin:"'''",end:"'''",relevance:10},{begin:'"""',end:'"""',relevance:10},{begin:'"',end:'"'},{begin:"'",end:"'"}]},c={begin:/\[/,end:/\]/,contains:[r,i,o,a,n,"self"],relevance:0},u=/[A-Za-z0-9_-]+/,h=/"(\\"|[^"])*"/,f=/'[^']*'/,m=t.either(u,h,f),g=t.concat(m,"(\\s*\\.\\s*",m,")*",t.lookahead(/\s*=\s*[^#\s]/));return{name:"TOML, also INI",aliases:["toml"],case_insensitive:!0,illegal:/\S/,contains:[r,{className:"section",begin:/\[+/,end:/\]+/},{begin:g,className:"attr",starts:{end:/$/,contains:[r,c,i,o,a,n]}}]}}const e1="[A-Za-z$_][0-9A-Za-z$_]*",O9=["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"],M9=["true","false","null","undefined","NaN","Infinity"],PT=["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"],LT=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],DT=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],P9=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","self","global"],L9=[].concat(DT,PT,LT);function D9(e){const t=e.regex,n=(K,{after:V})=>{const X="</"+K[0].slice(1);return K.input.indexOf(X,V)!==-1},r=e1,o={begin:"<>",end:"</>"},i=/<[A-Za-z0-9\\._:-]+\s*\/>/,a={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(K,V)=>{const X=K[0].length+K.index,W=K.input[X];if(W==="<"||W===","){V.ignoreMatch();return}W===">"&&(n(K,{after:X})||V.ignoreMatch());let se;const ce=K.input.substring(X);if(se=ce.match(/^\s*=/)){V.ignoreMatch();return}if((se=ce.match(/^\s+extends\s+/))&&se.index===0){V.ignoreMatch();return}}},c={$pattern:e1,keyword:O9,literal:M9,built_in:L9,"variable.language":P9},u="[0-9](_?[0-9])*",h=`\\.(${u})`,f="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",m={className:"number",variants:[{begin:`(\\b(${f})((${h})|\\.)?|(${h}))[eE][+-]?(${u})\\b`},{begin:`\\b(${f})\\b((${h})\\b|\\.)?|(${h})\\b`},{begin:"\\b(0|[1-9](_?[0-9])*)n\\b"},{begin:"\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*n?\\b"},{begin:"\\b0[bB][0-1](_?[0-1])*n?\\b"},{begin:"\\b0[oO][0-7](_?[0-7])*n?\\b"},{begin:"\\b0[0-7]+n?\\b"}],relevance:0},g={className:"subst",begin:"\\$\\{",end:"\\}",keywords:c,contains:[]},w={begin:".?html`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,g],subLanguage:"xml"}},y={begin:".?css`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,g],subLanguage:"css"}},v={begin:".?gql`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,g],subLanguage:"graphql"}},N={className:"string",begin:"`",end:"`",contains:[e.BACKSLASH_ESCAPE,g]},_={className:"comment",variants:[e.COMMENT(/\/\*\*(?!\/)/,"\\*/",{relevance:0,contains:[{begin:"(?=@[A-Za-z]+)",relevance:0,contains:[{className:"doctag",begin:"@[A-Za-z]+"},{className:"type",begin:"\\{",end:"\\}",excludeEnd:!0,excludeBegin:!0,relevance:0},{className:"variable",begin:r+"(?=\\s*(-)|$)",endsParent:!0,relevance:0},{begin:/(?=[^\n])\s/,relevance:0}]}]}),e.C_BLOCK_COMMENT_MODE,e.C_LINE_COMMENT_MODE]},T=[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,w,y,v,N,{match:/\$\d+/},m];g.contains=T.concat({begin:/\{/,end:/\}/,keywords:c,contains:["self"].concat(T)});const j=[].concat(_,g.contains),C=j.concat([{begin:/(\s*)\(/,end:/\)/,keywords:c,contains:["self"].concat(j)}]),M={className:"params",begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:c,contains:C},I={variants:[{match:[/class/,/\s+/,r,/\s+/,/extends/,/\s+/,t.concat(r,"(",t.concat(/\./,r),")*")],scope:{1:"keyword",3:"title.class",5:"keyword",7:"title.class.inherited"}},{match:[/class/,/\s+/,r],scope:{1:"keyword",3:"title.class"}}]},O={relevance:0,match:t.either(/\bJSON/,/\b[A-Z][a-z]+([A-Z][a-z]*|\d)*/,/\b[A-Z]{2,}([A-Z][a-z]+|\d)+([A-Z][a-z]*)*/,/\b[A-Z]{2,}[a-z]+([A-Z][a-z]+|\d)*([A-Z][a-z]*)*/),className:"title.class",keywords:{_:[...PT,...LT]}},A={label:"use_strict",className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},z={variants:[{match:[/function/,/\s+/,r,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:"keyword",3:"title.function"},label:"func.def",contains:[M],illegal:/%/},B={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"};function U(K){return t.concat("(?!",K.join("|"),")")}const Q={match:t.concat(/\b/,U([...DT,"super","import","await"].map(K=>`${K}\\s*\\(`)),r,t.lookahead(/\s*\(/)),className:"title.function",relevance:0},ae={begin:t.concat(/\./,t.lookahead(t.concat(r,/(?![0-9A-Za-z$_(])/))),end:r,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},ee={match:[/get|set/,/\s+/,r,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},M]},de="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+e.UNDERSCORE_IDENT_RE+")\\s*=>",$={match:[/const|var|let/,/\s+/,r,/\s*/,/=\s*/,/(async\s*)?/,t.lookahead(de)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[M]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:c,exports:{PARAMS_CONTAINS:C,CLASS_REFERENCE:O},illegal:/#(?![$_A-Za-z])/,contains:[e.SHEBANG({label:"shebang",binary:"node",relevance:5}),A,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,w,y,v,N,_,{match:/\$\d+/},m,O,{scope:"attr",match:r+t.lookahead(":"),relevance:0},$,{begin:"("+e.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",relevance:0,contains:[_,e.REGEXP_MODE,{className:"function",begin:de,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:C}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:o.begin,end:o.end},{match:i},{begin:a.begin,"on:begin":a.isTrulyOpeningTag,end:a.end}],subLanguage:"xml",contains:[{begin:a.begin,end:a.end,skip:!0,contains:["self"]}]}]},z,{beginKeywords:"while if switch catch for"},{begin:"\\b(?!function)"+e.UNDERSCORE_IDENT_RE+"\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",returnBegin:!0,label:"func.def",contains:[M,e.inherit(e.TITLE_MODE,{begin:r,className:"title.function"})]},{match:/\.\.\./,relevance:0},ae,{match:"\\$"+r,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[M]},Q,B,I,ee,{match:/\$[(.]/}]}}const z9="([-+]?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)|NaN|[-+]?Infinity",F9={scope:"number",match:z9,relevance:0};function B9(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,F9,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE],illegal:"\\S"}}function U9(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},a={begin:/^\[[^\n]+\]:/,returnBegin:!0,contains:[{className:"symbol",begin:/\[/,end:/\]/,excludeBegin:!0,excludeEnd:!0},{className:"link",begin:/:\s*/,end:/$/,excludeBegin:!0}]},c=/[A-Za-z][A-Za-z0-9+.-]*/,u={variants:[{begin:/\[.+?\]\[.*?\]/,relevance:0},{begin:/\[.+?\]\(((data|javascript|mailto):|(?:http|ftp)s?:\/\/).*?\)/,relevance:2},{begin:t.concat(/\[.+?\]\(/,c,/:\/\/.*?\)/),relevance:2},{begin:/\[.+?\]\([./?&#].*?\)/,relevance:1},{begin:/\[.*?\]\(.*?\)/,relevance:0}],returnBegin:!0,contains:[{match:/\[(?=\])/},{className:"string",relevance:0,begin:"\\[",end:"\\]",excludeBegin:!0,returnEnd:!0},{className:"link",relevance:0,begin:"\\]\\(",end:"\\)",excludeBegin:!0,excludeEnd:!0},{className:"symbol",relevance:0,begin:"\\]\\[",end:"\\]",excludeBegin:!0,excludeEnd:!0}]},h={className:"strong",contains:[],variants:[{begin:/_{2}(?!\s)/,end:/_{2}/},{begin:/\*{2}(?!\s)/,end:/\*{2}/}]},f={className:"emphasis",contains:[],variants:[{begin:/\*(?![*\s])/,end:/\*/},{begin:/_(?![_\s])/,end:/_/,relevance:0}]},m=e.inherit(h,{contains:[]}),g=e.inherit(f,{contains:[]});h.contains.push(g),f.contains.push(m);let w=[n,u];return[h,f,m,g].forEach(x=>{x.contains=x.contains.concat(w)}),w=w.concat(h,f),{name:"Markdown",aliases:["md","mkdown","mkd"],contains:[{className:"section",variants:[{begin:"^#{1,6}",end:"$",contains:w},{begin:"(?=^.+?\\n[=-]{2,}$)",contains:[{begin:"^[=-]*$"},{begin:"^",end:"\\n",contains:w}]}]},n,i,r,h,f,{className:"quote",begin:"^>\\s+",contains:w,end:"$"},o,u,a,{scope:"literal",match:/&([a-zA-Z0-9]+|#[0-9]{1,7}|#[Xx][0-9a-fA-F]{1,6});/}]}}function H9(e){const t=e.regex,n=new RegExp("[\\p{XID_Start}_]\\p{XID_Continue}*","u"),r=["and","as","assert","async","await","break","case","class","continue","def","del","elif","else","except","finally","for","from","global","if","import","in","is","lambda","lazy","match","nonlocal|10","not","or","pass","raise","return","try","while","with","yield"],c={$pattern:/[A-Za-z]\w+|__\w+__/,keyword:r,built_in:["__import__","abs","aiter","all","anext","any","ascii","bin","bool","breakpoint","bytearray","bytes","callable","chr","classmethod","compile","complex","delattr","dict","dir","divmod","enumerate","eval","exec","filter","float","format","frozendict","frozenset","getattr","globals","hasattr","hash","help","hex","id","input","int","isinstance","issubclass","iter","len","list","locals","map","max","memoryview","min","next","object","oct","open","ord","pow","print","property","range","repr","reversed","round","sentinel","set","setattr","slice","sorted","staticmethod","str","sum","super","tuple","type","vars","zip"],literal:["__debug__","Ellipsis","False","None","NotImplemented","True"],type:["Any","Callable","Coroutine","Dict","List","Literal","Generic","Optional","Sequence","Set","Tuple","Type","Union"]},u={className:"meta",begin:/^(>>>|\.\.\.) /},h={className:"subst",begin:/\{/,end:/\}/,keywords:c,illegal:/#/},f={begin:/\{\{/,relevance:0},m={className:"string",contains:[e.BACKSLASH_ESCAPE],variants:[{begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?'''/,end:/'''/,contains:[e.BACKSLASH_ESCAPE,u],relevance:10},{begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?"""/,end:/"""/,contains:[e.BACKSLASH_ESCAPE,u],relevance:10},{begin:/([fFtT][rR]|[rR][fFtT]|[fFtT])'''/,end:/'''/,contains:[e.BACKSLASH_ESCAPE,u,f,h]},{begin:/([fFtT][rR]|[rR][fFtT]|[fFtT])"""/,end:/"""/,contains:[e.BACKSLASH_ESCAPE,u,f,h]},{begin:/([uU]|[rR])'/,end:/'/,relevance:10},{begin:/([uU]|[rR])"/,end:/"/,relevance:10},{begin:/([bB]|[bB][rR]|[rR][bB])'/,end:/'/},{begin:/([bB]|[bB][rR]|[rR][bB])"/,end:/"/},{begin:/([fFtT][rR]|[rR][fFtT]|[fFtT])'/,end:/'/,contains:[e.BACKSLASH_ESCAPE,f,h]},{begin:/([fFtT][rR]|[rR][fFtT]|[fFtT])"/,end:/"/,contains:[e.BACKSLASH_ESCAPE,f,h]},e.APOS_STRING_MODE,e.QUOTE_STRING_MODE]},g="[0-9](_?[0-9])*",w=`(\\b(${g}))?\\.(${g})|\\b(${g})\\.`,y=`\\b|${r.join("|")}`,v={className:"number",relevance:0,variants:[{begin:`(\\b(${g})|(${w}))[eE][+-]?(${g})[jJ]?(?=${y})`},{begin:`(${w})[jJ]?`},{begin:`\\b([1-9](_?[0-9])*|0+(_?0)*)[lLjJ]?(?=${y})`},{begin:`\\b0[bB](_?[01])+[lL]?(?=${y})`},{begin:`\\b0[oO](_?[0-7])+[lL]?(?=${y})`},{begin:`\\b0[xX](_?[0-9a-fA-F])+[lL]?(?=${y})`},{begin:`\\b(${g})[jJ](?=${y})`}]},N={className:"comment",begin:t.lookahead(/# type:/),end:/$/,keywords:c,contains:[{begin:/# type:/},{begin:/#/,end:/\b\B/,endsWithParent:!0}]},x={className:"params",variants:[{className:"",begin:/\(\s*\)/,skip:!0},{begin:/\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:c,contains:["self",u,v,m,e.HASH_COMMENT_MODE]}]};return h.contains=[m,v,u],{name:"Python",aliases:["py","gyp","ipython"],unicodeRegex:!0,keywords:c,illegal:/(<\/|\?)|=>/,contains:[u,v,{scope:"variable.language",match:/\bself\b/},{beginKeywords:"if",relevance:0},{match:/\bor\b/,scope:"keyword"},m,N,e.HASH_COMMENT_MODE,{match:[/\bdef/,/\s+/,n],scope:{1:"keyword",3:"title.function"},contains:[x]},{variants:[{match:[/\bclass/,/\s+/,n,/\s*/,/\(\s*/,n,/\s*\)/]},{match:[/\bclass/,/\s+/,n]}],scope:{1:"keyword",3:"title.class",6:"title.class.inherited"}},{className:"meta",begin:/^[\t ]*@/,end:/(?=#)|$/,contains:[v,x,m]}]}}function W9(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*\(/))},a="([ui](8|16|32|64|128|size)|f(16|32|64|128))?",c=["abstract","as","async","await","become","box","break","const","continue","crate","do","dyn","else","enum","extern","false","final","fn","for","if","impl","in","let","loop","macro","match","mod","move","mut","override","priv","pub","raw","ref","return","self","Self","static","struct","super","trait","true","try","type","typeof","union","unsafe","unsized","use","virtual","where","while","yield"],u=["true","false","Some","None","Ok","Err"],h=["drop ","Copy","Send","Sized","Sync","Drop","Fn","FnMut","FnOnce","ToOwned","Clone","Debug","PartialEq","PartialOrd","Eq","Ord","AsRef","AsMut","Into","From","Default","Iterator","Extend","IntoIterator","DoubleEndedIterator","ExactSizeIterator","SliceConcatExt","ToString","assert!","assert_eq!","bitflags!","bytes!","cfg!","col!","concat!","concat_idents!","debug_assert!","debug_assert_eq!","env!","eprintln!","panic!","file!","format!","format_args!","include_bytes!","include_str!","line!","local_data_key!","module_path!","option_env!","print!","println!","select!","stringify!","try!","unimplemented!","unreachable!","vec!","write!","writeln!","macro_rules!","assert_ne!","debug_assert_ne!"],f=["i8","i16","i32","i64","i128","isize","u8","u16","u32","u64","u128","usize","f16","f32","f64","f128","str","char","bool","Box","Option","Result","String","Vec"];return{name:"Rust",aliases:["rs"],keywords:{$pattern:e.IDENT_RE+"!?",type:f,keyword:c,literal:u,built_in:h},illegal:"</",contains:[e.C_LINE_COMMENT_MODE,e.COMMENT("/\\*","\\*/",{contains:["self"]}),e.inherit(e.QUOTE_STRING_MODE,{begin:/b?"/,illegal:null}),{scope:"symbol",begin:/'[a-zA-Z_][a-zA-Z0-9_]*(?!')/},{scope:"string",variants:[{begin:/b?r(#*)"(.|\n)*?"\1(?!#)/},{begin:/b?'/,end:/'/,contains:[{scope:"char.escape",match:/\\('|"|\\|\w|x\w{2}|u\w{4}|U\w{8})/}]}]},{scope:"number",variants:[{begin:"\\b0b([01_]+)"+a},{begin:"\\b0o([0-7_]+)"+a},{begin:"\\b0x([A-Fa-f0-9_]+)"+a},{begin:"\\b(\\d[\\d_]*(\\.[0-9_]+)?([eE][+-]?[0-9_]+)?)"+a}],relevance:0},{begin:[/\bsafe/,/\s+/,/extern/],scope:{1:"keyword",3:"keyword"}},{begin:[/fn/,/\s+/,r],scope:{1:"keyword",3:"title.function"}},{scope:"meta",begin:"#!?\\[",end:"\\]",contains:[{scope:"string",begin:/"/,end:/"/,contains:[e.BACKSLASH_ESCAPE]}]},{begin:[/let/,/\s+/,/(?:mut\s+)?/,r],scope:{1:"keyword",3:"keyword",4:"variable"}},{begin:[/for/,/\s+/,r,/\s+/,/in/],scope:{1:"keyword",3:"variable",5:"keyword"}},{begin:[/type/,/\s+/,r],scope:{1:"keyword",3:"title.class"}},{begin:[/(?:trait|enum|struct|union|impl|for)/,/\s+/,r],scope:{1:"keyword",3:"title.class"}},{begin:e.IDENT_RE+"::",keywords:{keyword:"Self",built_in:h,type:f}},{scope:"punctuation",begin:"->"},i]}}const Jf="[A-Za-z$_][0-9A-Za-z$_]*",zT=["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"],FT=["true","false","null","undefined","NaN","Infinity"],BT=["Object","Function","Boolean","Symbol","Math","Date","Number","BigInt","String","RegExp","Array","Float32Array","Float64Array","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Int32Array","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array","Set","Map","WeakSet","WeakMap","ArrayBuffer","SharedArrayBuffer","Atomics","DataView","JSON","Promise","Generator","GeneratorFunction","AsyncFunction","Reflect","Proxy","Intl","WebAssembly"],UT=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],HT=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],WT=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","self","global"],KT=[].concat(HT,BT,UT);function K9(e){const t=e.regex,n=(K,{after:V})=>{const X="</"+K[0].slice(1);return K.input.indexOf(X,V)!==-1},r=Jf,o={begin:"<>",end:"</>"},i=/<[A-Za-z0-9\\._:-]+\s*\/>/,a={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(K,V)=>{const X=K[0].length+K.index,W=K.input[X];if(W==="<"||W===","){V.ignoreMatch();return}W===">"&&(n(K,{after:X})||V.ignoreMatch());let se;const ce=K.input.substring(X);if(se=ce.match(/^\s*=/)){V.ignoreMatch();return}if((se=ce.match(/^\s+extends\s+/))&&se.index===0){V.ignoreMatch();return}}},c={$pattern:Jf,keyword:zT,literal:FT,built_in:KT,"variable.language":WT},u="[0-9](_?[0-9])*",h=`\\.(${u})`,f="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",m={className:"number",variants:[{begin:`(\\b(${f})((${h})|\\.)?|(${h}))[eE][+-]?(${u})\\b`},{begin:`\\b(${f})\\b((${h})\\b|\\.)?|(${h})\\b`},{begin:"\\b(0|[1-9](_?[0-9])*)n\\b"},{begin:"\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*n?\\b"},{begin:"\\b0[bB][0-1](_?[0-1])*n?\\b"},{begin:"\\b0[oO][0-7](_?[0-7])*n?\\b"},{begin:"\\b0[0-7]+n?\\b"}],relevance:0},g={className:"subst",begin:"\\$\\{",end:"\\}",keywords:c,contains:[]},w={begin:".?html`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,g],subLanguage:"xml"}},y={begin:".?css`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,g],subLanguage:"css"}},v={begin:".?gql`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,g],subLanguage:"graphql"}},N={className:"string",begin:"`",end:"`",contains:[e.BACKSLASH_ESCAPE,g]},_={className:"comment",variants:[e.COMMENT(/\/\*\*(?!\/)/,"\\*/",{relevance:0,contains:[{begin:"(?=@[A-Za-z]+)",relevance:0,contains:[{className:"doctag",begin:"@[A-Za-z]+"},{className:"type",begin:"\\{",end:"\\}",excludeEnd:!0,excludeBegin:!0,relevance:0},{className:"variable",begin:r+"(?=\\s*(-)|$)",endsParent:!0,relevance:0},{begin:/(?=[^\n])\s/,relevance:0}]}]}),e.C_BLOCK_COMMENT_MODE,e.C_LINE_COMMENT_MODE]},T=[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,w,y,v,N,{match:/\$\d+/},m];g.contains=T.concat({begin:/\{/,end:/\}/,keywords:c,contains:["self"].concat(T)});const j=[].concat(_,g.contains),C=j.concat([{begin:/(\s*)\(/,end:/\)/,keywords:c,contains:["self"].concat(j)}]),M={className:"params",begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:c,contains:C},I={variants:[{match:[/class/,/\s+/,r,/\s+/,/extends/,/\s+/,t.concat(r,"(",t.concat(/\./,r),")*")],scope:{1:"keyword",3:"title.class",5:"keyword",7:"title.class.inherited"}},{match:[/class/,/\s+/,r],scope:{1:"keyword",3:"title.class"}}]},O={relevance:0,match:t.either(/\bJSON/,/\b[A-Z][a-z]+([A-Z][a-z]*|\d)*/,/\b[A-Z]{2,}([A-Z][a-z]+|\d)+([A-Z][a-z]*)*/,/\b[A-Z]{2,}[a-z]+([A-Z][a-z]+|\d)*([A-Z][a-z]*)*/),className:"title.class",keywords:{_:[...BT,...UT]}},A={label:"use_strict",className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},z={variants:[{match:[/function/,/\s+/,r,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:"keyword",3:"title.function"},label:"func.def",contains:[M],illegal:/%/},B={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"};function U(K){return t.concat("(?!",K.join("|"),")")}const Q={match:t.concat(/\b/,U([...HT,"super","import","await"].map(K=>`${K}\\s*\\(`)),r,t.lookahead(/\s*\(/)),className:"title.function",relevance:0},ae={begin:t.concat(/\./,t.lookahead(t.concat(r,/(?![0-9A-Za-z$_(])/))),end:r,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},ee={match:[/get|set/,/\s+/,r,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},M]},de="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+e.UNDERSCORE_IDENT_RE+")\\s*=>",$={match:[/const|var|let/,/\s+/,r,/\s*/,/=\s*/,/(async\s*)?/,t.lookahead(de)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[M]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:c,exports:{PARAMS_CONTAINS:C,CLASS_REFERENCE:O},illegal:/#(?![$_A-Za-z])/,contains:[e.SHEBANG({label:"shebang",binary:"node",relevance:5}),A,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,w,y,v,N,_,{match:/\$\d+/},m,O,{scope:"attr",match:r+t.lookahead(":"),relevance:0},$,{begin:"("+e.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",relevance:0,contains:[_,e.REGEXP_MODE,{className:"function",begin:de,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:C}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:o.begin,end:o.end},{match:i},{begin:a.begin,"on:begin":a.isTrulyOpeningTag,end:a.end}],subLanguage:"xml",contains:[{begin:a.begin,end:a.end,skip:!0,contains:["self"]}]}]},z,{beginKeywords:"while if switch catch for"},{begin:"\\b(?!function)"+e.UNDERSCORE_IDENT_RE+"\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",returnBegin:!0,label:"func.def",contains:[M,e.inherit(e.TITLE_MODE,{begin:r,className:"title.function"})]},{match:/\.\.\./,relevance:0},ae,{match:"\\$"+r,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[M]},Q,B,I,ee,{match:/\$[(.]/}]}}function Z9(e){const t=e.regex,n=K9(e),r=Jf,o=["any","void","number","boolean","string","object","never","symbol","bigint","unknown"],i={begin:[/namespace/,/\s+/,e.IDENT_RE],beginScope:{1:"keyword",3:"title.class"}},a={beginKeywords:"interface",end:/\{/,excludeEnd:!0,keywords:{keyword:"interface extends",built_in:o},contains:[n.exports.CLASS_REFERENCE]},c={className:"meta",relevance:10,begin:/^\s*['"]use strict['"]/},u=["type","interface","public","private","protected","implements","declare","abstract","readonly","enum","override","satisfies"],h={$pattern:Jf,keyword:zT.concat(u),literal:FT,built_in:KT.concat(o),"variable.language":WT},f={className:"meta",begin:"@"+r},m=(v,N,x)=>{const _=v.contains.findIndex(T=>T.label===N);if(_===-1)throw new Error("can not find mode to replace");v.contains.splice(_,1,x)};Object.assign(n.keywords,h),n.exports.PARAMS_CONTAINS.push(f);const g=n.contains.find(v=>v.scope==="attr"),w=Object.assign({},g,{match:t.concat(r,t.lookahead(/\s*\?:/))});n.exports.PARAMS_CONTAINS.push([n.exports.CLASS_REFERENCE,g,w]),n.contains=n.contains.concat([f,i,a,w]),m(n,"shebang",e.SHEBANG()),m(n,"use_strict",c);const y=n.contains.find(v=>v.label==="func.def");return y.relevance=0,Object.assign(n,{name:"TypeScript",aliases:["ts","tsx","mts","cts"]}),n}function q9(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/}]},a=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,a,{begin:/\[/,end:/\]/,contains:[{className:"meta",begin:/<![a-z]/,end:/>/,contains:[i,a,u,c]}]}]},e.COMMENT(/<!--/,/-->/,{relevance:10}),{begin:/<!\[CDATA\[/,end:/\]\]>/,relevance:10},o,{className:"meta",end:/\?>/,variants:[{begin:/<\?xml/,relevance:10,contains:[u]},{begin:/<\?[a-z][a-z0-9]+/}]},{className:"tag",begin:/<style(?=\s|>)/,end:/>/,keywords:{name:"style"},contains:[h],starts:{end:/<\/style>/,returnEnd:!0,subLanguage:"css"}},{className:"tag",begin:/<script(?=\s|>)/,end:/>/,keywords:{name:"script"},contains:[h],starts:{end:/<\/script>/,returnEnd:!0,subLanguage:"javascript"}},{className:"tag",begin:/<>|<\/>/},{className:"tag",begin:t.concat(/</,t.lookahead(t.concat(n,t.either(/\/>/,/>/,/\s/)))),end:/\/?>/,contains:[{className:"name",begin:n,relevance:0,starts:h}]},{className:"tag",begin:t.concat(/<\//,t.lookahead(t.concat(n,/>/))),contains:[{className:"name",begin:n,relevance:0},{begin:/>/,relevance:0,endsParent:!0}]}]}}function G9(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}]},a={className:"string",relevance:0,variants:[{begin:/"/,end:/"/},{begin:/\S+/}],contains:[e.BACKSLASH_ESCAPE,o]},c=e.inherit(a,{variants:[{begin:/'/,end:/'/,contains:[{begin:/''/,relevance:0}]},{begin:/"/,end:/"/},{begin:/[^\s,{}[\]]+/}]}),g={className:"number",begin:"\\b"+"[0-9]{4}(-[0-9][0-9]){0,2}"+"([Tt \\t][0-9][0-9]?(:[0-9][0-9]){2})?"+"(\\.[0-9]*)?"+"([ \\t])*(Z|[-+][0-9][0-9]?(:[0-9][0-9])?)?"+"\\b"},w={end:",",endsWithParent:!0,excludeEnd:!0,keywords:t,relevance:0},y={begin:/\{/,end:/\}/,contains:[w],illegal:"\\n",relevance:0},v={begin:"\\[",end:"\\]",contains:[w],illegal:"\\n",relevance:0},N=[r,{className:"meta",begin:"^---\\s*$",relevance:10},{className:"string",begin:"[\\|>]([1-9]?[+-])?[ ]*\\n( +)[^ ][^\\n]*\\n(\\2[^\\n]+\\n?)*"},{begin:"<%[%=-]?",end:"[%-]?%>",subLanguage:"ruby",excludeBegin:!0,excludeEnd:!0,relevance:0},{className:"type",begin:"!\\w+!"+n},{className:"type",begin:"!<"+n+">"},{className:"type",begin:"!"+n},{className:"type",begin:"!!"+n},{className:"meta",begin:"&"+e.UNDERSCORE_IDENT_RE+"$"},{className:"meta",begin:"\\*"+e.UNDERSCORE_IDENT_RE+"$"},{className:"bullet",begin:"-(?=[ ]|$)",relevance:0},e.HASH_COMMENT_MODE,{beginKeywords:t,keywords:{literal:t}},g,{className:"number",begin:e.C_NUMBER_RE+"\\b",relevance:0},y,v,i,a],x=[...N];return x.pop(),x.push(c),w.contains=x,{name:"YAML",case_insensitive:!0,aliases:["yml"],contains:N}}var eg,t1;function V9(){if(t1)return eg;t1=1;function e(L){return L instanceof Map?L.clear=L.delete=L.set=function(){throw new Error("map is read-only")}:L instanceof Set&&(L.add=L.clear=L.delete=function(){throw new Error("set is read-only")}),Object.freeze(L),Object.getOwnPropertyNames(L).forEach(re=>{const be=L[re],Xe=typeof be;(Xe==="object"||Xe==="function")&&!Object.isFrozen(be)&&e(be)}),L}class t{constructor(re){re.data===void 0&&(re.data={}),this.data=re.data,this.isMatchIgnored=!1}ignoreMatch(){this.isMatchIgnored=!0}}function n(L){return L.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function r(L,...re){const be=Object.create(null);for(const Xe in L)be[Xe]=L[Xe];return re.forEach(function(Xe){for(const Nt in Xe)be[Nt]=Xe[Nt]}),be}const o="</span>",i=L=>!!L.scope,a=(L,{prefix:re})=>{if(L.startsWith("language:"))return L.replace("language:","language-");if(L.includes(".")){const be=L.split(".");return[`${re}${be.shift()}`,...be.map((Xe,Nt)=>`${Xe}${"_".repeat(Nt+1)}`)].join(" ")}return`${re}${L}`};class c{constructor(re,be){this.buffer="",this.classPrefix=be.classPrefix,re.walk(this)}addText(re){this.buffer+=n(re)}openNode(re){if(!i(re))return;const be=a(re.scope,{prefix:this.classPrefix});this.span(be)}closeNode(re){i(re)&&(this.buffer+=o)}value(){return this.buffer}span(re){this.buffer+=`<span class="${re}">`}}const u=(L={})=>{const re={children:[]};return Object.assign(re,L),re};class h{constructor(){this.rootNode=u(),this.stack=[this.rootNode]}get top(){return this.stack[this.stack.length-1]}get root(){return this.rootNode}add(re){this.top.children.push(re)}openNode(re){const be=u({scope:re});this.add(be),this.stack.push(be)}closeNode(){if(this.stack.length>1)return this.stack.pop()}closeAllNodes(){for(;this.closeNode(););}toJSON(){return JSON.stringify(this.rootNode,null,4)}walk(re){return this.constructor._walk(re,this.rootNode)}static _walk(re,be){return typeof be=="string"?re.addText(be):be.children&&(re.openNode(be),be.children.forEach(Xe=>this._walk(re,Xe)),re.closeNode(be)),re}static _collapse(re){typeof re!="string"&&re.children&&(re.children.every(be=>typeof be=="string")?re.children=[re.children.join("")]:re.children.forEach(be=>{h._collapse(be)}))}}class f extends h{constructor(re){super(),this.options=re}addText(re){re!==""&&this.add(re)}startScope(re){this.openNode(re)}endScope(){this.closeNode()}__addSublanguage(re,be){const Xe=re.root;be&&(Xe.scope=`language:${be}`),this.add(Xe)}toHTML(){return new c(this,this.options).value()}finalize(){return this.closeAllNodes(),!0}}function m(L){return L?typeof L=="string"?L:L.source:null}function g(L){return v("(?=",L,")")}function w(L){return v("(?:",L,")*")}function y(L){return v("(?:",L,")?")}function v(...L){return L.map(be=>m(be)).join("")}function N(L){const re=L[L.length-1];return typeof re=="object"&&re.constructor===Object?(L.splice(L.length-1,1),re):{}}function x(...L){return"("+(N(L).capture?"":"?:")+L.map(Xe=>m(Xe)).join("|")+")"}function _(L){return new RegExp(L.toString()+"|").exec("").length-1}function T(L,re){const be=L&&L.exec(re);return be&&be.index===0}const j=/\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)|\\./;function C(L,{joinWith:re}){let be=0;return L.map(Xe=>{be+=1;const Nt=be;let Ot=m(Xe),ze="";for(;Ot.length>0;){const Me=j.exec(Ot);if(!Me){ze+=Ot;break}ze+=Ot.substring(0,Me.index),Ot=Ot.substring(Me.index+Me[0].length),Me[0][0]==="\\"&&Me[1]?ze+="\\"+String(Number(Me[1])+Nt):(ze+=Me[0],Me[0]==="("&&be++)}return ze}).map(Xe=>`(${Xe})`).join(re)}const M=/\b\B/,I="[a-zA-Z]\\w*",O="[a-zA-Z_]\\w*",A="\\b\\d+(\\.\\d+)?",z="(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)",B="\\b(0b[01]+)",U="!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~",Q=(L={})=>{const re=/^#![ ]*\//;return L.binary&&(L.begin=v(re,/.*\b/,L.binary,/\b.*/)),r({scope:"meta",begin:re,end:/$/,relevance:0,"on:begin":(be,Xe)=>{be.index!==0&&Xe.ignoreMatch()}},L)},ae={begin:"\\\\[\\s\\S]",relevance:0},ee={scope:"string",begin:"'",end:"'",illegal:"\\n",contains:[ae]},de={scope:"string",begin:'"',end:'"',illegal:"\\n",contains:[ae]},$={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/},K=function(L,re,be={}){const Xe=r({scope:"comment",begin:L,end:re,contains:[]},be);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 Nt=x("I","a","is","so","us","to","at","if","in","it","on",/[A-Za-z]+['](d|ve|re|ll|t|s|n)/,/[A-Za-z]+[-][a-z]+/,/[A-Za-z][a-z]{2,}/);return Xe.contains.push({begin:v(/[ ]+/,"(",Nt,/[.]?[:]?([.][ ]|[ ])/,"){3}")}),Xe},V=K("//","$"),X=K("/\\*","\\*/"),W=K("#","$"),se={scope:"number",begin:A,relevance:0},ce={scope:"number",begin:z,relevance:0},he={scope:"number",begin:B,relevance:0},je={scope:"regexp",begin:/\/(?=[^/\n]*\/)/,end:/\/[gimuy]*/,contains:[ae,{begin:/\[/,end:/\]/,relevance:0,contains:[ae]}]},$e={scope:"title",begin:I,relevance:0},q={scope:"title",begin:O,relevance:0},H={begin:"\\.\\s*"+O,relevance:0};var Se=Object.freeze({__proto__:null,APOS_STRING_MODE:ee,BACKSLASH_ESCAPE:ae,BINARY_NUMBER_MODE:he,BINARY_NUMBER_RE:B,COMMENT:K,C_BLOCK_COMMENT_MODE:X,C_LINE_COMMENT_MODE:V,C_NUMBER_MODE:ce,C_NUMBER_RE:z,END_SAME_AS_BEGIN:function(L){return Object.assign(L,{"on:begin":(re,be)=>{be.data._beginMatch=re[1]},"on:end":(re,be)=>{be.data._beginMatch!==re[1]&&be.ignoreMatch()}})},HASH_COMMENT_MODE:W,IDENT_RE:I,MATCH_NOTHING_RE:M,METHOD_GUARD:H,NUMBER_MODE:se,NUMBER_RE:A,PHRASAL_WORDS_MODE:$,QUOTE_STRING_MODE:de,REGEXP_MODE:je,RE_STARTERS_RE:U,SHEBANG:Q,TITLE_MODE:$e,UNDERSCORE_IDENT_RE:O,UNDERSCORE_TITLE_MODE:q});function ye(L,re){L.input[L.index-1]==="."&&re.ignoreMatch()}function J(L,re){L.className!==void 0&&(L.scope=L.className,delete L.className)}function we(L,re){re&&L.beginKeywords&&(L.begin="\\b("+L.beginKeywords.split(" ").join("|")+")(?!\\.)(?=\\b|\\s)",L.__beforeBegin=ye,L.keywords=L.keywords||L.beginKeywords,delete L.beginKeywords,L.relevance===void 0&&(L.relevance=0))}function ge(L,re){Array.isArray(L.illegal)&&(L.illegal=x(...L.illegal))}function Be(L,re){if(L.match){if(L.begin||L.end)throw new Error("begin & end are not supported with match");L.begin=L.match,delete L.match}}function Ie(L,re){L.relevance===void 0&&(L.relevance=1)}const We=(L,re)=>{if(!L.beforeMatch)return;if(L.starts)throw new Error("beforeMatch cannot be used with starts");const be=Object.assign({},L);Object.keys(L).forEach(Xe=>{delete L[Xe]}),L.keywords=be.keywords,L.begin=v(be.beforeMatch,g(be.begin)),L.starts={relevance:0,contains:[Object.assign(be,{endsParent:!0})]},L.relevance=0,delete be.beforeMatch},pt=["of","and","for","in","not","or","if","then","parent","list","value"],rn="keyword";function qt(L,re,be=rn){const Xe=Object.create(null);return typeof L=="string"?Nt(be,L.split(" ")):Array.isArray(L)?Nt(be,L):Object.keys(L).forEach(function(Ot){Object.assign(Xe,qt(L[Ot],re,Ot))}),Xe;function Nt(Ot,ze){re&&(ze=ze.map(Me=>Me.toLowerCase())),ze.forEach(function(Me){const Ze=Me.split("|");Xe[Ze[0]]=[Ot,Ue(Ze[0],Ze[1])]})}}function Ue(L,re){return re?Number(re):Qt(L)?0:1}function Qt(L){return pt.includes(L.toLowerCase())}const an={},Ft=L=>{console.error(L)},Qe=(L,...re)=>{console.log(`WARN: ${L}`,...re)},Wt=(L,re)=>{an[`${L}/${re}`]||(console.log(`Deprecated as of ${L}. ${re}`),an[`${L}/${re}`]=!0)},ln=new Error;function wt(L,re,{key:be}){let Xe=0;const Nt=L[be],Ot={},ze={};for(let Me=1;Me<=re.length;Me++)ze[Me+Xe]=Nt[Me],Ot[Me+Xe]=!0,Xe+=_(re[Me-1]);L[be]=ze,L[be]._emit=Ot,L[be]._multi=!0}function mt(L){if(Array.isArray(L.begin)){if(L.skip||L.excludeBegin||L.returnBegin)throw Ft("skip, excludeBegin, returnBegin not compatible with beginScope: {}"),ln;if(typeof L.beginScope!="object"||L.beginScope===null)throw Ft("beginScope must be object"),ln;wt(L,L.begin,{key:"beginScope"}),L.begin=C(L.begin,{joinWith:""})}}function Vt(L){if(Array.isArray(L.end)){if(L.skip||L.excludeEnd||L.returnEnd)throw Ft("skip, excludeEnd, returnEnd not compatible with endScope: {}"),ln;if(typeof L.endScope!="object"||L.endScope===null)throw Ft("endScope must be object"),ln;wt(L,L.end,{key:"endScope"}),L.end=C(L.end,{joinWith:""})}}function kn(L){L.scope&&typeof L.scope=="object"&&L.scope!==null&&(L.beginScope=L.scope,delete L.scope)}function Lt(L){kn(L),typeof L.beginScope=="string"&&(L.beginScope={_wrap:L.beginScope}),typeof L.endScope=="string"&&(L.endScope={_wrap:L.endScope}),mt(L),Vt(L)}function Pn(L){function re(ze,Me){return new RegExp(m(ze),"m"+(L.case_insensitive?"i":"")+(L.unicodeRegex?"u":"")+(Me?"g":""))}class be{constructor(){this.matchIndexes={},this.regexes=[],this.matchAt=1,this.position=0}addRule(Me,Ze){Ze.position=this.position++,this.matchIndexes[this.matchAt]=Ze,this.regexes.push([Ze,Me]),this.matchAt+=_(Me)+1}compile(){this.regexes.length===0&&(this.exec=()=>null);const Me=this.regexes.map(Ze=>Ze[1]);this.matcherRe=re(C(Me,{joinWith:"|"}),!0),this.lastIndex=0}exec(Me){this.matcherRe.lastIndex=this.lastIndex;const Ze=this.matcherRe.exec(Me);if(!Ze)return null;const Xt=Ze.findIndex((vn,Ut)=>Ut>0&&vn!==void 0),Bt=this.matchIndexes[Xt];return Ze.splice(0,Xt),Object.assign(Ze,Bt)}}class Xe{constructor(){this.rules=[],this.multiRegexes=[],this.count=0,this.lastIndex=0,this.regexIndex=0}getMatcher(Me){if(this.multiRegexes[Me])return this.multiRegexes[Me];const Ze=new be;return this.rules.slice(Me).forEach(([Xt,Bt])=>Ze.addRule(Xt,Bt)),Ze.compile(),this.multiRegexes[Me]=Ze,Ze}resumingScanAtSamePosition(){return this.regexIndex!==0}considerAll(){this.regexIndex=0}addRule(Me,Ze){this.rules.push([Me,Ze]),Ze.type==="begin"&&this.count++}exec(Me){const Ze=this.getMatcher(this.regexIndex);Ze.lastIndex=this.lastIndex;let Xt=Ze.exec(Me);if(this.resumingScanAtSamePosition()&&!(Xt&&Xt.index===this.lastIndex)){const Bt=this.getMatcher(0);Bt.lastIndex=this.lastIndex+1,Xt=Bt.exec(Me)}return Xt&&(this.regexIndex+=Xt.position+1,this.regexIndex===this.count&&this.considerAll()),Xt}}function Nt(ze){const Me=new Xe;return ze.contains.forEach(Ze=>Me.addRule(Ze.begin,{rule:Ze,type:"begin"})),ze.terminatorEnd&&Me.addRule(ze.terminatorEnd,{type:"end"}),ze.illegal&&Me.addRule(ze.illegal,{type:"illegal"}),Me}function Ot(ze,Me){const Ze=ze;if(ze.isCompiled)return Ze;[J,Be,Lt,We].forEach(Bt=>Bt(ze,Me)),L.compilerExtensions.forEach(Bt=>Bt(ze,Me)),ze.__beforeBegin=null,[we,ge,Ie].forEach(Bt=>Bt(ze,Me)),ze.isCompiled=!0;let Xt=null;return typeof ze.keywords=="object"&&ze.keywords.$pattern&&(ze.keywords=Object.assign({},ze.keywords),Xt=ze.keywords.$pattern,delete ze.keywords.$pattern),Xt=Xt||/\w+/,ze.keywords&&(ze.keywords=qt(ze.keywords,L.case_insensitive)),Ze.keywordPatternRe=re(Xt,!0),Me&&(ze.begin||(ze.begin=/\B|\b/),Ze.beginRe=re(Ze.begin),!ze.end&&!ze.endsWithParent&&(ze.end=/\B|\b/),ze.end&&(Ze.endRe=re(Ze.end)),Ze.terminatorEnd=m(Ze.end)||"",ze.endsWithParent&&Me.terminatorEnd&&(Ze.terminatorEnd+=(ze.end?"|":"")+Me.terminatorEnd)),ze.illegal&&(Ze.illegalRe=re(ze.illegal)),ze.contains||(ze.contains=[]),ze.contains=[].concat(...ze.contains.map(function(Bt){return yn(Bt==="self"?ze:Bt)})),ze.contains.forEach(function(Bt){Ot(Bt,Ze)}),ze.starts&&Ot(ze.starts,Me),Ze.matcher=Nt(Ze),Ze}if(L.compilerExtensions||(L.compilerExtensions=[]),L.contains&&L.contains.includes("self"))throw new Error("ERR: contains `self` is not supported at the top-level of a language. See documentation.");return L.classNameAliases=r(L.classNameAliases||{}),Ot(L)}function _t(L){return L?L.endsWithParent||_t(L.starts):!1}function yn(L){return L.variants&&!L.cachedVariants&&(L.cachedVariants=L.variants.map(function(re){return r(L,{variants:null},re)})),L.cachedVariants?L.cachedVariants:_t(L)?r(L,{starts:L.starts?r(L.starts):null}):Object.isFrozen(L)?r(L):L}var er="11.11.2";class te extends Error{constructor(re,be){super(re),this.name="HTMLInjectionError",this.html=be}}const me=n,Ge=r,ot=Symbol("nomatch"),Dt=7,Ct=function(L){const re=Object.create(null),be=Object.create(null),Xe=[];let Nt=!0;const Ot="Could not find the language '{}', did you forget to load/include a language module?",ze={disableAutodetect:!0,name:"Plain text",contains:[]};let Me={ignoreUnescapedHTML:!1,throwUnescapedHTML:!1,noHighlightRe:/^(no-?highlight)$/i,languageDetectRe:/\blang(?:uage)?-([\w-]+)\b/i,classPrefix:"hljs-",cssSelector:"pre code",languages:null,__emitter:f};function Ze(_e){return Me.noHighlightRe.test(_e)}function Xt(_e){let qe=_e.className+" ";qe+=_e.parentNode?_e.parentNode.className:"";const bt=Me.languageDetectRe.exec(qe);if(bt){const it=bn(bt[1]);return it||(Qe(Ot.replace("{}",bt[1])),Qe("Falling back to no-highlight mode for this block.",_e)),it?bt[1]:"no-highlight"}return qe.split(/\s+/).find(it=>Ze(it)||bn(it))}function Bt(_e,qe,bt){let it="",fn="";typeof qe=="object"?(it=_e,bt=qe.ignoreIllegals,fn=qe.language):(Wt("10.7.0","highlight(lang, code, ...args) has been deprecated."),Wt("10.7.0",`Please use highlight(code, options) instead.
|
|
205
|
+
https://github.com/highlightjs/highlight.js/issues/2277`),fn=_e,it=qe),bt===void 0&&(bt=!0);const Ht={code:it,language:fn};Hn("before:highlight",Ht);const un=Ht.result?Ht.result:vn(Ht.language,Ht.code,bt);return un.code=Ht.code,Hn("after:highlight",un),un}function vn(_e,qe,bt,it){const fn=Object.create(null);function Ht(Z,le){return Z.keywords[le]}function un(){if(!xt.keywords){jn.addText(Jt);return}let Z=0;xt.keywordPatternRe.lastIndex=0;let le=xt.keywordPatternRe.exec(Jt),xe="";for(;le;){xe+=Jt.substring(Z,le.index);const Re=ar.case_insensitive?le[0].toLowerCase():le[0],Te=Ht(xt,Re);if(Te){const[$t,on]=Te;if(jn.addText(xe),xe="",fn[Re]=(fn[Re]||0)+1,fn[Re]<=Dt&&(Zr+=on),$t.startsWith("_"))xe+=le[0];else{const tr=ar.classNameAliases[$t]||$t;Wn(le[0],tr)}}else xe+=le[0];Z=xt.keywordPatternRe.lastIndex,le=xt.keywordPatternRe.exec(Jt)}xe+=Jt.substring(Z),jn.addText(xe)}function Kr(){if(Jt==="")return;let Z=null;if(typeof xt.subLanguage=="string"){if(!re[xt.subLanguage]){jn.addText(Jt);return}Z=vn(xt.subLanguage,Jt,!0,To[xt.subLanguage]),To[xt.subLanguage]=Z._top}else Z=cn(Jt,xt.subLanguage.length?xt.subLanguage:null);xt.relevance>0&&(Zr+=Z.relevance),jn.__addSublanguage(Z._emitter,Z.language)}function In(){xt.subLanguage!=null?Kr():un(),Jt=""}function Wn(Z,le){Z!==""&&(jn.startScope(le),jn.addText(Z),jn.endScope())}function yr(Z,le){let xe=1;const Re=le.length-1;for(;xe<=Re;){if(!Z._emit[xe]){xe++;continue}const Te=ar.classNameAliases[Z[xe]]||Z[xe],$t=le[xe];Te?Wn($t,Te):(Jt=$t,un(),Jt=""),xe++}}function Kn(Z,le){return Z.scope&&typeof Z.scope=="string"&&jn.openNode(ar.classNameAliases[Z.scope]||Z.scope),Z.beginScope&&(Z.beginScope._wrap?(Wn(Jt,ar.classNameAliases[Z.beginScope._wrap]||Z.beginScope._wrap),Jt=""):Z.beginScope._multi&&(yr(Z.beginScope,le),Jt="")),xt=Object.create(Z,{parent:{value:xt}}),xt}function Y(Z,le,xe){let Re=T(Z.endRe,xe);if(Re){if(Z["on:end"]){const Te=new t(Z);Z["on:end"](le,Te),Te.isMatchIgnored&&(Re=!1)}if(Re){for(;Z.endsParent&&Z.parent;)Z=Z.parent;return Z}}if(Z.endsWithParent)return Y(Z.parent,le,xe)}function pe(Z){return xt.matcher.regexIndex===0?(Jt+=Z[0],1):(F=!0,0)}function Je(Z){const le=Z[0],xe=Z.rule,Re=new t(xe),Te=[xe.__beforeBegin,xe["on:begin"]];for(const $t of Te)if($t&&($t(Z,Re),Re.isMatchIgnored))return pe(le);return xe.skip?Jt+=le:(xe.excludeBegin&&(Jt+=le),In(),!xe.returnBegin&&!xe.excludeBegin&&(Jt=le)),Kn(xe,Z),xe.returnBegin?0:le.length}function gt(Z){const le=Z[0],xe=qe.substring(Z.index),Re=Y(xt,Z,xe);if(!Re)return ot;const Te=xt;xt.endScope&&xt.endScope._wrap?(In(),Wn(le,xt.endScope._wrap)):xt.endScope&&xt.endScope._multi?(In(),yr(xt.endScope,Z)):Te.skip?Jt+=le:(Te.returnEnd||Te.excludeEnd||(Jt+=le),In(),Te.excludeEnd&&(Jt=le));do xt.scope&&jn.closeNode(),!xt.skip&&!xt.subLanguage&&(Zr+=xt.relevance),xt=xt.parent;while(xt!==Re.parent);return Re.starts&&Kn(Re.starts,Z),Te.returnEnd?0:le.length}function Tt(){const Z=[];for(let le=xt;le!==ar;le=le.parent)le.scope&&Z.unshift(le.scope);Z.forEach(le=>jn.openNode(le))}let xn={};function Zn(Z,le){const xe=le&&le[0];if(Jt+=Z,xe==null)return In(),0;if(xn.type==="begin"&&le.type==="end"&&xn.index===le.index&&xe===""){if(Jt+=qe.slice(le.index,le.index+1),!Nt){const Re=new Error(`0 width match regex (${_e})`);throw Re.languageName=_e,Re.badRule=xn.rule,Re}return 1}if(xn=le,le.type==="begin")return Je(le);if(le.type==="illegal"&&!bt){const Re=new Error('Illegal lexeme "'+xe+'" for mode "'+(xt.scope||"<unnamed>")+'"');throw Re.mode=xt,Re}else if(le.type==="end"){const Re=gt(le);if(Re!==ot)return Re}if(le.type==="illegal"&&xe==="")return le.index===qe.length||(Jt+=`
|
|
206
|
+
`),1;if(Ne>1e5&&Ne>le.index*3)throw new Error("potential infinite loop, way more iterations than matches");return Jt+=xe,xe.length}const ar=bn(_e);if(!ar)throw Ft(Ot.replace("{}",_e)),new Error('Unknown language: "'+_e+'"');const $r=Pn(ar);let Gt="",xt=it||$r;const To={},jn=new Me.__emitter(Me);Tt();let Jt="",Zr=0,Or=0,Ne=0,F=!1;try{if(ar.__emitTokens)ar.__emitTokens(qe,jn);else{for(xt.matcher.considerAll();;){Ne++,F?F=!1:xt.matcher.considerAll(),xt.matcher.lastIndex=Or;const Z=xt.matcher.exec(qe);if(!Z)break;const le=qe.substring(Or,Z.index),xe=Zn(le,Z);Or=Z.index+xe}Zn(qe.substring(Or))}return jn.finalize(),Gt=jn.toHTML(),{language:_e,value:Gt,relevance:Zr,illegal:!1,_emitter:jn,_top:xt}}catch(Z){if(Z.message&&Z.message.includes("Illegal"))return{language:_e,value:me(qe),illegal:!0,relevance:0,_illegalBy:{message:Z.message,index:Or,context:qe.slice(Or-100,Or+100),mode:Z.mode,resultSoFar:Gt},_emitter:jn};if(Nt)return{language:_e,value:me(qe),illegal:!1,relevance:0,errorRaised:Z,_emitter:jn,_top:xt};throw Z}}function Ut(_e){const qe={value:me(_e),illegal:!1,relevance:0,_top:ze,_emitter:new Me.__emitter(Me)};return qe._emitter.addText(_e),qe}function cn(_e,qe){qe=qe||Me.languages||Object.keys(re);const bt=Ut(_e),it=qe.filter(bn).filter(ir).map(In=>vn(In,_e,!1));it.unshift(bt);const fn=it.sort((In,Wn)=>{if(In.relevance!==Wn.relevance)return Wn.relevance-In.relevance;if(In.language&&Wn.language){if(bn(In.language).supersetOf===Wn.language)return 1;if(bn(Wn.language).supersetOf===In.language)return-1}return 0}),[Ht,un]=fn,Kr=Ht;return Kr.secondBest=un,Kr}function Yt(_e,qe,bt){const it=qe&&be[qe]||bt;_e.classList.add("hljs"),_e.classList.add(`language-${it}`)}function Kt(_e){let qe=null;const bt=Xt(_e);if(Ze(bt))return;if(Hn("before:highlightElement",{el:_e,language:bt}),_e.dataset.highlighted){console.log("Element previously highlighted. To highlight again, first unset `dataset.highlighted`.",_e);return}if(_e.children.length>0&&(Me.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(_e)),Me.throwUnescapedHTML))throw new te("One of your code blocks includes unescaped HTML.",_e.innerHTML);qe=_e;const it=qe.textContent,fn=bt?Bt(it,{language:bt,ignoreIllegals:!0}):cn(it);_e.innerHTML=fn.value,_e.dataset.highlighted="yes",Yt(_e,bt,fn.language),_e.result={language:fn.language,re:fn.relevance,relevance:fn.relevance},fn.secondBest&&(_e.secondBest={language:fn.secondBest.language,relevance:fn.secondBest.relevance}),Hn("after:highlightElement",{el:_e,result:fn,text:it})}function Sn(_e){Me=Ge(Me,_e)}const An=()=>{Le(),Wt("10.6.0","initHighlighting() deprecated. Use highlightAll() now.")};function fr(){Le(),Wt("10.6.0","initHighlightingOnLoad() deprecated. Use highlightAll() now.")}let oe=!1;function Le(){function _e(){Le()}if(document.readyState==="loading"){oe||window.addEventListener("DOMContentLoaded",_e,!1),oe=!0;return}document.querySelectorAll(Me.cssSelector).forEach(Kt)}function Ve(_e,qe){let bt=null;try{bt=qe(L)}catch(it){if(Ft("Language definition for '{}' could not be registered.".replace("{}",_e)),Nt)Ft(it);else throw it;bt=ze}bt.name||(bt.name=_e),re[_e]=bt,bt.rawDefinition=qe.bind(null,L),bt.aliases&&jr(bt.aliases,{languageName:_e})}function jt(_e){delete re[_e];for(const qe of Object.keys(be))be[qe]===_e&&delete be[qe]}function ft(){return Object.keys(re)}function bn(_e){return _e=(_e||"").toLowerCase(),re[_e]||re[be[_e]]}function jr(_e,{languageName:qe}){typeof _e=="string"&&(_e=[_e]),_e.forEach(bt=>{be[bt.toLowerCase()]=qe})}function ir(_e){const qe=bn(_e);return qe&&!qe.disableAutodetect}function Zt(_e){_e["before:highlightBlock"]&&!_e["before:highlightElement"]&&(_e["before:highlightElement"]=qe=>{_e["before:highlightBlock"](Object.assign({block:qe.el},qe))}),_e["after:highlightBlock"]&&!_e["after:highlightElement"]&&(_e["after:highlightElement"]=qe=>{_e["after:highlightBlock"](Object.assign({block:qe.el},qe))})}function Qr(_e){Zt(_e),Xe.push(_e)}function dt(_e){const qe=Xe.indexOf(_e);qe!==-1&&Xe.splice(qe,1)}function Hn(_e,qe){const bt=_e;Xe.forEach(function(it){it[bt]&&it[bt](qe)})}function rt(_e){return Wt("10.7.0","highlightBlock will be removed entirely in v12.0"),Wt("10.7.0","Please use highlightElement now."),Kt(_e)}Object.assign(L,{highlight:Bt,highlightAuto:cn,highlightAll:Le,highlightElement:Kt,highlightBlock:rt,configure:Sn,initHighlighting:An,initHighlightingOnLoad:fr,registerLanguage:Ve,unregisterLanguage:jt,listLanguages:ft,getLanguage:bn,registerAliases:jr,autoDetection:ir,inherit:Ge,addPlugin:Qr,removePlugin:dt}),L.debugMode=function(){Nt=!1},L.safeMode=function(){Nt=!0},L.versionString=er,L.regex={concat:v,lookahead:g,either:x,optional:y,anyNumberOfTimes:w};for(const _e in Se)typeof Se[_e]=="object"&&e(Se[_e]);return Object.assign(L,Se),L},mn=Ct({});return mn.newInstance=()=>Ct({}),eg=mn,mn.HighlightJS=mn,mn.default=mn,eg}var Y9=V9();const X9=eE(Y9),n1={},Q9="hljs-";function J9(e){const t=X9.newInstance();return e&&i(e),{highlight:n,highlightAuto:r,listLanguages:o,register:i,registerAlias:a,registered:c};function n(u,h,f){const m=f||n1,g=typeof m.prefix=="string"?m.prefix:Q9;if(!t.getLanguage(u))throw new Error("Unknown language: `"+u+"` is not registered");t.configure({__emitter:eB,classPrefix:g});const w=t.highlight(h,{ignoreIllegals:!0,language:u});if(w.errorRaised)throw new Error("Could not highlight with `Highlight.js`",{cause:w.errorRaised});const y=w._emitter.root,v=y.data;return v.language=w.language,v.relevance=w.relevance,y}function r(u,h){const m=(h||n1).subset||o();let g=-1,w=0,y;for(;++g<m.length;){const v=m[g];if(!t.getLanguage(v))continue;const N=n(v,u,h);N.data&&N.data.relevance!==void 0&&N.data.relevance>w&&(w=N.data.relevance,y=N)}return y||{type:"root",children:[],data:{language:void 0,relevance:w}}}function o(){return t.listLanguages()}function i(u,h){if(typeof u=="string")t.registerLanguage(u,h);else{let f;for(f in u)Object.hasOwn(u,f)&&t.registerLanguage(f,u[f])}}function a(u,h){if(typeof u=="string")t.registerAliases(typeof h=="string"?h:[...h],{languageName:u});else{let f;for(f in u)if(Object.hasOwn(u,f)){const m=u[f];t.registerAliases(typeof m=="string"?m:[...m],{languageName:f})}}}function c(u){return!!t.getLanguage(u)}}class eB{constructor(t){this.options=t,this.root={type:"root",children:[],data:{language:void 0,relevance:0}},this.stack=[this.root]}addText(t){if(t==="")return;const n=this.stack[this.stack.length-1],r=n.children[n.children.length-1];r&&r.type==="text"?r.value+=t:n.children.push({type:"text",value:t})}startScope(t){this.openNode(String(t))}endScope(){this.closeNode()}__addSublanguage(t,n){const r=this.stack[this.stack.length-1],o=t.root.children;n?r.children.push({type:"element",tagName:"span",properties:{className:[n]},children:o}):r.children.push(...o)}openNode(t){const n=this,r=t.split(".").map(function(a,c){return c?a+"_".repeat(c):n.options.classPrefix+a}),o=this.stack[this.stack.length-1],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 ZT=J9({bash:x9,css:A9,go:I9,ini:R9,javascript:D9,json:B9,markdown:U9,python:H9,rust:W9,typescript:Z9,xml:q9,yaml:G9}),r1={ts:"typescript",tsx:"typescript",mts:"typescript",cts:"typescript",js:"javascript",jsx:"javascript",mjs:"javascript",cjs:"javascript",json:"json",jsonc:"json",css:"css",scss:"css",less:"css",html:"xml",htm:"xml",xml:"xml",svg:"xml",vue:"xml",md:"markdown",mdx:"markdown",markdown:"markdown",py:"python",pyi:"python",rs:"rust",go:"go",java:"javascript",kt:"javascript",c:"javascript",h:"javascript",cc:"javascript",cpp:"javascript",hpp:"javascript",cs:"javascript",swift:"javascript",yml:"yaml",yaml:"yaml",toml:"ini",ini:"ini",env:"ini",sh:"bash",bash:"bash",zsh:"bash",fish:"bash"};function cy(e,t){const n=e&&(r1[e]??(ZT.registered(e)?e:null));if(n)return n;const r=t.lastIndexOf("."),o=r<0?"":t.slice(r+1).toLowerCase();return(o?r1[o]:null)??null}const tB=/^(?:diff --git a\/\S+ b\/(\S+)|\+\+\+ (?:b\/)?(\S+))$/gm;function nB(e){const t=new Set;for(const n of e.matchAll(tB)){const r=n[1]??n[2]??"";r&&r!=="/dev/null"&&t.add(r)}return t.size===1?[...t][0]:""}const rB={comment:"comment",quote:"comment",doctag:"comment",keyword:"keyword",literal:"keyword",meta:"keyword","meta-keyword":"keyword",operator:"keyword","selector-tag":"keyword",tag:"keyword",string:"string",regexp:"string","meta-string":"string","template-tag":"string",symbol:"string",number:"number",type:"type",built_in:"type",class:"type",class_:"type","selector-class":"type","selector-id":"type",title:"function",function_:"function",function:"function",variable:"variable",language_:"variable",constant_:"variable",attr:"variable",attribute:"variable",property:"variable",params:"variable",name:"variable"};function qT(e,t){const n=[[]],r=(i,a)=>{const c=i.split(`
|
|
207
|
+
`);for(const[u,h]of c.entries()){if(u>0&&n.push([]),!h)continue;const f=n[n.length-1],m=f[f.length-1];m&&m.scope===a?m.text+=h:f.push({text:h,scope:a})}},o=(i,a)=>{for(const c of i)c.type==="text"?r(c.value,a):c.type==="element"&&o(c.children,oB(c)??a)};try{o(ZT.highlight(t,e).children,"")}catch{return e.split(`
|
|
208
|
+
`).map(i=>i?[{text:i,scope:""}]:[])}return n}function oB(e){var r;const t=((r=e.properties)==null?void 0:r.className)??[];let n=null;for(const o of t){const i=rB[o.startsWith("hljs-")?o.slice(5):o];i&&(n=i)}return n}const o1=/^\d+\t/;function uy(e,t){if(!t)return[];const n=e.split(`
|
|
209
|
+
`),r=o1.test(n[0]??""),o=r?n.map(a=>{var c;return((c=o1.exec(a))==null?void 0:c[0])??""}):[],i=r?n.map((a,c)=>a.slice(o[c].length)).join(`
|
|
210
|
+
`):e;return qT(i,t).map((a,c)=>{const u=a.map(f=>({text:f.text,changed:!1,scope:f.scope})),h=o[c];return h?[{text:h,changed:!1,scope:""},...u]:u})}function sB(e,t){var r;const n=new Array(e.length);if(t){let o=0;for(let i=0;i<=e.length;i++){const a=(r=e[i])==null?void 0:r.kind;i<e.length&&a!=="hunk"&&a!=="meta"||(iB(e,o,i,t,n),o=i+1)}}return e.map((o,i)=>uB(o.spans,n[i],o.text))}function iB(e,t,n,r,o){var i,a;for(const c of["del","add"]){const u=[];for(let m=t;m<n;m++){const g=(i=e[m])==null?void 0:i.kind;(g===""||g===c)&&u.push(m)}if(u.length===0)continue;const h=u.map(m=>{var g;return((g=e[m])==null?void 0:g.text)??""}).join(`
|
|
211
|
+
`),f=qT(h,r);for(const[m,g]of u.entries())(c==="add"||((a=e[g])==null?void 0:a.kind)==="del")&&(o[g]=f[m])}}const qh="link",aB=/https?:\/\/[^\s<>"'`]+/g,GT=/https?:\/\//;function lB(e){const t=[];for(const n of e.matchAll(aB)){const r=n.index+cB(n[0]).length;r>n.index&&t.push({start:n.index,end:r})}return t}const s1={")":"(","]":"[","}":"{"};function cB(e){let t=e.length;for(;t>0;){const n=e[t-1];if(".,;:!?".includes(n))t--;else if(s1[n]&&i1(e.slice(0,t),s1[n])<i1(e.slice(0,t),n))t--;else break}return e.slice(0,t)}function i1(e,t){let n=0;for(const r of e)r===t&&n++;return n}function VT(e){const t=e.map(c=>c.text).join("");if(!GT.test(t))return e;const n=lB(t);if(!n.length)return e;const r=[];let o=0,i=0,a=null;for(const c of e){let u=0;for(;u<c.text.length;){const h=n[i],f=o+u;if(h&&f>=h.start){const m=Math.min(h.end,o+c.text.length)-f;a||(a={text:"",changed:!1,scope:qh},r.push(a)),a.text+=c.text.slice(u,u+m),a.changed||(a.changed=c.changed),u+=m,f+m>=h.end&&(a=null,i++)}else{const m=h?Math.min(h.start-o,c.text.length):c.text.length;r.push({text:c.text.slice(u,m),changed:c.changed,scope:c.scope}),u=m}}o+=c.text.length}return r}const ck=e=>e.map(VT);function YT(e){return GT.test(e)?e.split(`
|
|
212
|
+
`).map(t=>VT(t?[{text:t,changed:!1,scope:""}]:[])):[]}function XT(e){const t=e[e.length-1],n=t==null?void 0:t[t.length-1];return!n||n.scope!==qh?e:[...e.slice(0,-1),[...t.slice(0,-1),{...n,scope:""}]]}function uB(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 a=0,c=0,u=0,h=0;for(;a<o.length&&c<i.length;){const f=o[a],m=i[c],g=Math.min(f.text.length-u,m.text.length-h);if(g>0){const w={text:f.text.slice(u,u+g),changed:f.changed,scope:m.scope},y=r[r.length-1];y&&y.changed===w.changed&&y.scope===w.scope?y.text+=w.text:r.push(w)}u+=g,h+=g,u>=f.text.length&&(a++,u=0),h>=m.text.length&&(c++,h=0)}return r}_n.use({extensions:[K8,w9(()=>_r==null?void 0:_r.worktrees)],renderer:{code({text:e,lang:t}){const n=cy((t??"").trim().toLowerCase().split(/\s+/)[0]??"","");let r=n?ck(uy(e,n)):YT(e);return r.length?(_r!=null&&_r.streaming&&Ef.trimEnd().endsWith(e.trimEnd())&&(r=XT(r)),`<pre><code>${r.map(i=>i.map(a=>a.scope===qh?`<a href="${ma(a.text)}">${ma(a.text)}</a>`:a.scope?`<span class="sy-${a.scope}">${ma(a.text)}</span>`:ma(a.text)).join("")).join(`
|
|
213
|
+
`)}</code></pre>
|
|
214
|
+
`):!1},html(e){return _r!=null&&_r.keepHtml?!1:Z8(e)},table:q8}});const QT=DF(window);let _r=null,Ef="";QT.addHook("afterSanitizeAttributes",e=>{const t=e.tagName==="A"?e.getAttribute("href")??"":"";if(t===vT){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=_r!=null&&_r.fileRoot?rT(_r.fileRoot,t):null,r=n?null:oT(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=tF(e.textContent??"");i&&e.setAttribute("data-path",i)}const o=_r==null?void 0:_r.base;if(e.tagName==="IMG"&&o){const i=qw(o.dir,e.getAttribute("src")??"");i&&e.setAttribute("src",o.urls.worktreeFile(o.worktreeId,i,o.version))}});function Al(e,t){_r=t??null,Ef=t!=null&&t.streaming?B8(e):e;try{return QT.sanitize(_n.parse(Ef,{async:!1}))}finally{_r=null,Ef=""}}function dB(e,t){const[n,r]=S.useState(e),o=S.useRef(null);return S.useEffect(()=>{if(!t){o.current=null;return}o.current=v9(o.current,e.length,performance.now());let i=0;const a=()=>{const c=o.current;if(!c)return;const u=MT(c,performance.now());r(b9(e,u)),u<c.to&&(i=requestAnimationFrame(a))};return a(),()=>cancelAnimationFrame(i)},[e,t]),t?n:e}function Gh(e,t){var y,v,N,x;const[n,r]=S.useState(()=>Al(e,t)),o=S.useRef(0),i=(y=t==null?void 0:t.base)==null?void 0:y.worktreeId,a=(v=t==null?void 0:t.base)==null?void 0:v.dir,c=(N=t==null?void 0:t.base)==null?void 0:N.version,u=(x=t==null?void 0:t.base)==null?void 0:x.urls,h=t==null?void 0:t.fileRoot,f=t==null?void 0:t.worktrees,m=!!(t!=null&&t.keepHtml),g=!!(t!=null&&t.streaming),w=dB(e,g);return S.useEffect(()=>{const _=i!==void 0&&a!==void 0&&u!==void 0?{worktreeId:i,dir:a,version:c??null,urls:u}:void 0,T=_||h||f||m||g?{base:_,fileRoot:h,worktrees:f,keepHtml:m,streaming:g}:void 0,j=performance.now()-o.current;if(g||j>=Ea){o.current=performance.now(),r(Al(w,T));return}const C=setTimeout(()=>{o.current=performance.now(),r(Al(w,T))},Ea-j);return()=>clearTimeout(C)},[w,i,a,c,u,h,f,m,g]),n}const fB=/^ {0,3}(`{3,}|~{3,})/,hB=/^#{1,6} \S/,pB=/^\s*(?:[-*+]|\d+[.)]) \S/,mB=/^> ?\S/,gB=/^\s*\|?\s*:?-{3,}:?\s*(?:\|\s*:?-{3,}:?\s*)+\|?\s*$/,kB=/\[[^\]\n]+\]\((?:https?:|\.{0,2}\/|#)[^)\s]*\)/,wB=/\*\*[^\s*][^*\n]*\*\*/;function yB(e){var i,a;const t=e.split(`
|
|
215
|
+
`),n=new Set;let r=null,o=0;for(let c=0;c<t.length;c++){const u=t[c],h=(i=fB.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}hB.test(u)&&!((a=t[c+1])!=null&&a.trim())&&n.add("heading"),pB.test(u)&&++o===2&&n.add("list"),mB.test(u)&&n.add("quote"),gB.test(u)&&n.add("table"),kB.test(u)&&n.add("link"),wB.test(u)&&n.add("bold")}return n.size}function vB(e,t){if(t)return Eh(t)==="markdown"?"rendered":"plain";const n=yB(e);return n>=2?"rendered":n===1?"source":"plain"}function Vh({n:e,name:t,source:n,lines:r,chars:o,preview:i,text:a,href:c,onRemove:u,className:h=""}){const f=(n==null?void 0:n.path)??t??"",m=f.includes("/")?f.slice(0,f.lastIndexOf("/")):"",g=n?[m,n.ref?`at ${n.ref.slice(0,7)}`:""].filter(Boolean).join(" "):[m,`${r} ${r===1?"line":"lines"}`,`${o.toLocaleString()} chars`,i].filter(Boolean).join(" · "),w=d.jsxs(d.Fragment,{children:[d.jsx(St,{name:"text",className:"icon-inline"}),d.jsxs("span",{className:"pick-target",children:[d.jsx("b",{children:t?t.slice(t.lastIndexOf("/")+1):n?vP(n):cE("paste",e)}),g&&d.jsxs("span",{className:"pick-file row-dim",children:[" · ",g]})]})]}),y=a!==void 0||c!==void 0;return d.jsx(Vw,{className:He("paste-chip",h),label:w,tip:i||void 0,peek:y?d.jsx(tj,{text:a,href:c}):void 0,full:y?d.jsx(ej,{text:a,href:c,path:f||void 0}):void 0,menu:v=>z6({text:a,href:c},v),removeLabel:"Remove attachment",onRemove:u})}function JT(e,t){const[n,r]=S.useState(e??null),[o,i]=S.useState(!1);return S.useEffect(()=>{if(e!==void 0||!t)return;let a=!0;return fetch(t).then(c=>c.ok?c.text():Promise.reject(new Error(String(c.status)))).then(c=>{a&&r(c)}).catch(()=>{a&&i(!0)}),()=>{a=!1}},[e,t]),{text:e??n,failed:o}}function ej({text:e,href:t,path:n}){const{text:r,failed:o}=JT(e,t),i=S.useMemo(()=>r?vB(r,n):"plain",[r,n]),[a,c]=S.useState(null);if(o)return d.jsx("p",{className:"paste-full hint",children:"Toyon could not read that back."});if(!r||i==="plain")return d.jsx("pre",{className:"paste-full paste-text",children:r});const u=a??i==="rendered";return d.jsxs("div",{className:"paste-full paste-doc",children:[d.jsx("div",{className:"paste-doc-head",children:d.jsxs(De,{variant:"outline",tone:"quiet",mono:!0,className:"deep-link",onClick:()=>c(!u),"data-tip":u?"Text: read it as it was sent":"Preview: read it rendered",children:[d.jsx(St,{name:u?"text":"book",className:"icon-inline"})," ",u?"text":"preview"]})}),u?d.jsx(bB,{text:r}):d.jsx("pre",{className:"paste-doc-body paste-text",children:r})]})}function bB({text:e}){const t=S.useMemo(()=>Al(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 xB=2e4;function tj({text:e,href:t}){const{text:n}=JT(e,t);return n?d.jsx("pre",{className:"paste-peek paste-text",children:n.slice(0,xB)}):null}function Yh({name:e,bytes:t,href:n,kept:r,uploading:o,progress:i,onRemove:a,className:c=""}){const u=tt();return d.jsx(Vw,{className:He("file-chip",c),label:d.jsxs(d.Fragment,{children:[d.jsx(St,{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:[" ","· ",Mk(t),i!==void 0?d.jsxs(d.Fragment,{children:[" ","· ",d.jsxs("span",{className:"pick-progress",children:[i,"%"]})]}):o&&" · uploading"]})]})]}),tip:e,peek:n?d.jsx(tj,{href:n}):void 0,full:n?d.jsx(ej,{href:n,path:e}):void 0,menu:h=>F6({href:n},h,r&&{...r,sock:u}),removeLabel:"Remove attachment",onRemove:a})}function nj(e){return e.replace(/^([\t ]*)\*\*(\S(?:[^\n]*\S)?)\*\*([\t ]*)$/gm,"$1$2$3")}const rj=120,EB=/^\*\*(\S(?:[^\n]*\S)?)\*\*$/;function oj(e){var n,r;const t=[];for(const o of e.split(/\n[\t ]*\n/)){const i=o.trim();if(!i)continue;const a=((r=(n=EB.exec(i))==null?void 0:n[1])==null?void 0:r.replace(/`/g,""))??"";if(!a||a.length>rj)return[];t.push(a)}return t}function sj(e){const t=oj(e);if(t.length)return t.at(-1);const n=nj(e).trim().replace(/`/g,"");return n&&!n.includes(`
|
|
216
|
+
`)&&n.length<=rj?n:""}const SB={read:"read",edit:"edit",delete:"delete",move:"move",search:"search",execute:"run",think:"think",fetch:"fetch",switch_mode:"mode",other:"tool"},a1={read:"book",edit:"edit",delete:"trash",move:"move",search:"search",execute:"run",think:"bulb",fetch:"globe",switch_mode:"swap",other:"dot"},ij="Skill",aj="ScheduleWakeup",tg=new Map([[Ck,"chat"],["Monitor","clock"],[aj,"clock"],["TaskOutput","terminal"],[ij,"layers"]]);function _B(e){if(e.name!==ij)return"";const t=Br(e,"skill").trim();if(!t)return"";const n=Br(e,"args").trim();return n?`/${t} ${n}`:`/${t}`}const uk={grep:"search",rg:"search",ag:"search",ack:"search",find:"search",fd:"search",cat:"book",head:"book",tail:"book",nl:"book",less:"book",bat:"book",ls:"folder",tree:"folder",mkdir:"folder",rm:"trash",rmdir:"trash",mv:"move",curl:"globe",wget:"globe",git:"branch"},NB=/(^|\s)(-[A-Za-z]*[iI]|--in-place)/,l1=String.raw`(?:"[^"]*"|'[^']*'|[^\s;&|]+)`,c1=new RegExp(String.raw`^\s*(?:(?:cd|echo)\s+${l1}\s*(?:&&|;)|mkdir(?:\s+${l1})+\s*(?:&&|;)|(?:export\s+)?[A-Za-z_]\w*=(?:"[^"]*"|'[^']*'|[^\s;&|()\`]*)\s*(?:&&|;|(?=\s)))\s*`),TB=/^python[\d.]*$/,jB=new RegExp(`open\\([^)]*,\\s*["'][wax]|(?<!std(?:out|err))\\.write\\(|\\.write_text\\(`);function lj(e){let t=e;for(let n=t.replace(c1,"");n!==t;n=t.replace(c1,""))t=n;return t}const $B=new RegExp("(?<![0-9&])>{1,2}\\s*(?!\\/dev\\/null|&)[^\\s&>]"),cj=/&&|;|\n|\|/;function CB(e){return e.split(cj).some(t=>/^\s*(?:\S*\/)?sed\s/.test(t)&&NB.test(t))}function AB(e){return e.split(/&&|;|\n/).map(t=>lj(t).trim().split(/\s+/)[0]??"").filter(Boolean).every(t=>uk[t.slice(t.lastIndexOf("/")+1)]==="trash")}function IB(e){const t=lj(e).trim(),n=t.split(/\s+/)[0]??"",r=n.slice(n.lastIndexOf("/")+1),o=r==="sed"?CB(e)?void 0:"book":uk[r];if(o==="book"||o==="search"){const i=t.split(cj)[0]??"";if($B.test(i))return r==="cat"&&i.includes("<<")?"edit":void 0}if(!(o==="trash"&&!AB(t)))return o||(TB.test(r)?t.includes("<<")&&jB.test(t)?"edit":void 0:uk[r])}function Br(e,t){const n=e.input,r=n?n[t]:void 0;return typeof r=="string"?r:""}const RB=/^(?:\/(?:usr\/)?bin\/)?(?:ba|z|da)?sh\s+(?:-[a-zA-Z]+\s+)*(?:'([^']*)'|"((?:[^"\\]|\\.)*)")\s*$/;function uj(e){const t=RB.exec(e.trim());return t?t[1]!==void 0?t[1]:(t[2]??"").replace(/\\(["\\$`])/g,"$1"):e}const OB="Guardian Review";function dj(e){return e.toolKind==="think"&&e.title===OB}function MB(e){const t=o=>{var a,c;return((c=(a=[...e.matchAll(new RegExp(`^${o}:[ \\t]*(.+)$`,"gm"))].at(-1))==null?void 0:a[1])==null?void 0:c.trim().toLowerCase())??""},n=t("Status"),r=t("Risk");return!n||n==="in progress"?"reviewing":r?`${n}, ${r} risk`:n}function mu(e,t=[]){const n=uj(Br(e,"command")),r=e.name===$f?"":Br(e,"query"),o=e.name===aj?Br(e,"reason"):"",i=fj(e)||n||Br(e,"path")||Br(e,"pattern")||r||o,a=KC(e.name),c=i||_B(e)||(e.title&&e.title!==e.name?e.title:"")||(a?a.tool:""),u=Xh(Br(e,"description")||(a?Br(e,"rationale"):"")||c,t),h=e.toolKind&&e.toolKind in a1?e.toolKind:"other",f=SB[h],m=e.name===Ck,g=h!=="other"||tg.has(e.name),w=e.name===e.title||e.name===Si||e.name===rE,y=a?a.server:u&&(g||w||e.name===$f)?"":e.name,v=y&&y.toLowerCase()!==f?y:u?"":f,N=(h==="execute"||h==="other")&&n?IB(n):void 0;return{label:m?"ask":f,name:v,icon:tg.get(e.name)??tg.get(e.title??"")??N??(a&&h==="other"?"cube":a1[h]),hint:u===v?"":u,command:n&&n!==u?n:""}}const PB=/^Async agent launched/m;function LB(e){if(!e.subagent)return!1;const t=e.input;return!!e.detached||(t==null?void 0:t.run_in_background)===!0||!!e.output&&PB.test(e.output)}const DB={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 zB(e){const t=e.toolKind;return e.subagent?Br(e,"prompt")?"":"writing the brief":!ch(e.input)||!sE({name:e.name,kind:t},e.input)?"":Ak(t)?DB[t]:"writing the question"}function dk(e,t){const n=hj(t),r=n[0],o=Br(e,"description");return o&&r&&!r.code&&r.text===o?n.slice(1):n}function Bl(e){return fj(e)||Br(e,"path")}function FB(e){return Br(e,"description")}function fj(e){return Br(e,"file_path")||Br(e,"filepath")||Br(e,"filePath")||BB(e)}function BB(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 Xh(e,t){if(!e.startsWith("/"))return e;for(const n of t)if(n&&e.startsWith(`${n}/`))return e.slice(n.length+1);return e}const UB=/^(`{3,})([\w+#.-]*)\s*$/;function hj(e){var c;const t=[];let n=[],r="",o=!1,i=0;const a=()=>{const u=n.join(`
|
|
217
|
+
`).replace(/^\n+|\n+$/g,"");u.trim()&&t.push({code:o,diff:HB(u,r),lang:o?r:"",text:u}),n=[]};for(const u of e.split(`
|
|
218
|
+
`)){const h=UB.exec(u),f=((c=h==null?void 0:h[1])==null?void 0:c.length)??0;if(!h||o&&(f<i||h[2])){n.push(u);continue}a(),o=!o,i=o?f:0,r=o?(h[2]??"").toLowerCase():""}return a(),t}function HB(e,t){return t==="diff"||t==="patch"||/^diff --git /m.test(e)||/^@@ .*@@/m.test(e)?!0:/^--- /m.test(e)&&/^[+-]/m.test(e)}const WB=/^(diff --git |index [0-9a-f]+\.\.|new file mode |deleted file mode |similarity index |rename (from|to) |Binary files )/;function KB(e){const t=[];for(const n of e.split(`
|
|
219
|
+
`)){const r=qB(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 ZB(t),t}function ZB(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 a=i;for(;((r=e[a])==null?void 0:r.kind)==="del";)a++;let c=a;for(;((o=e[c])==null?void 0:o.kind)==="add";)c++;const u=e.slice(i,a),h=e.slice(a,c),f=u.length>0&&h.length>0?MA(u.map(m=>m.text).join(`
|
|
220
|
+
`),h.map(m=>m.text).join(`
|
|
221
|
+
`)):null;f&&(u1(u,O0(f.before)),u1(h,O0(f.after)));for(const m of[...u,...h])m.spans??(m.spans=[]);i=c}}function u1(e,t){if(t.length===e.length)for(const[n,r]of e.entries())r.spans=t[n]}function qB(e){return e.startsWith("@@")?"hunk":e.startsWith("+++")||e.startsWith("---")||WB.test(e)?"meta":e.startsWith("+")?"add":e.startsWith("-")?"del":""}function GB(e){const t=e.tools.at(-1);return t.done||t.parentToolId?!1:t.name===Si?!t.background:!!t.background}const pj=new Set(["read","edit","fetch"]);function dy(e,t){if(e.isError||!e.toolKind||!pj.has(e.toolKind)||Ak(e.toolKind)&&ch(e.input))return"";const{hint:n}=mu(e,t);return n?`${e.parentToolId??""}
|
|
222
|
+
${e.toolKind}
|
|
223
|
+
${n}`:""}function d1(e,t,n){if(!t||!("tools"in t)||e.done||e.isError||!e.toolKind||!pj.has(e.toolKind))return!1;const r=t.tools[0];return r.toolKind===e.toolKind&&r.parentToolId===e.parentToolId&&dy(r,n)!==""}function VB(e,t){const n=e.length-1,r=e[n];if(!r||!("tools"in r)||r.next)return-1;const o=r.tools[0],i=r.tools.at(-1);return o.toolKind!=="edit"||o.parentToolId||!i.done||i.isError?-1:dy(o,t)?n:-1}function mj(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 YB(e){return!e.done||e.isError?!1:!!e.cut||!e.output&&sE({name:e.name,kind:e.toolKind},e.input)}function XB(e,t){return e.name===$f&&e.done&&!e.isError&&!t}function QB(e,t){const n=mj(e),r=[],o=new Map;let i="";for(const[a,c]of e.entries()){if(c.kind!=="tool"){i="",r.push({at:a,item:c});continue}if(YB(c)||XB(c,a===e.length-1))continue;if(n.has(c.id)){i="";const m={at:a,spawn:c,run:[],end:a};o.set(c.id,{entry:m,key:""}),r.push(m);continue}const u=dy(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&&d1(c,g,t)?g.next=c:m.push({at:a,tools:[c]}),h.key=u,h.entry.end=a;continue}const f=r.at(-1);if(u&&u===i&&f&&"tools"in f){f.tools.push(c);continue}if(!u&&d1(c,f,t)){f.next=c;continue}i=u,r.push({at:a,tools:[c]})}return r}function JB(e){return e.reduce((t,n)=>t+n.tools.length,0)}function eU(e){const t=new Set,n=new Set;let r=!0;for(let i=e.length-1;i>=0;i--){const a=e[i];if(a.kind!=="tool"||!a.parentToolId){r=!1;continue}n.add(a.parentToolId),(r||!a.done)&&t.add(a.parentToolId)}let o=!0;for(let i=e.length-1;i>=0;i--){const a=e[i];_u(a)&&(o=!1),!(a.kind!=="tool"||!a.subagent)&&(a.isError?t.delete(a.id):a.done?LB(a)?o&&!n.has(a.id)&&t.add(a.id):t.delete(a.id):t.add(a.id))}return t}function tU(e,t){const n=[],r=[];let o=-1;for(const i of e)"spawn"in i?t.has(i.spawn.id)?n.push(i):(o=Math.max(o,i.end),r.push({key:o,entry:i})):"tools"in i&&GB(i)?n.push(i):r.push({key:i.at,entry:i});return r.sort((i,a)=>i.key-a.key),{flow:r.map(i=>i.entry),floating:n}}function nU(e){const t=mj(e);return e.some(n=>n.kind==="tool"&&!n.done&&!n.parentToolId&&!n.background&&(!t.has(n.id)||ch(n.input)))}function gj(e,t=!1){const n=new Set;let r=!1,o=!1;return e.forEach((i,a)=>{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=oE({name:c.name,kind:c.toolKind});(o||r&&u)&&n.add(a),r=!0,o||(o=u)}),n}function rU(e){return e.findIndex(t=>!t.tools.at(-1).done)}function fy(e,t){return e.length===t.length&&e.every((n,r)=>n===t[r])}function kj(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)&&fy(n.tools,t[r].tools)})}function oU(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,a)=>{const c=n.get(i.at),u=c!==void 0&&sU(c,i)?c:i;return u!==e[a]&&(r=!1),u});return r?e:o}function sU(e,t){return"spawn"in e?"spawn"in t&&e.spawn===t.spawn&&e.end===t.end&&kj(e.run,t.run):"tools"in e?"tools"in t&&e.next===t.next&&fy(e.tools,t.tools):"item"in t&&e.item===t.item}function iU(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"&&!dj(r))return t;continue}if(n.item.kind==="thinking"){if(!n.item.text.trim())continue;return sj(n.item.text)?-1:t}if(aU(n.item))return-1}}return-1}function aU(e){return e.kind==="assistant"?!!e.text.trim():e.kind==="ask"?e.ask.kind==="question"||!!e.outcome:!0}function lU(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 Qh(e,t,n){if(!t)return[];const r=[];for(const o of e){const i=o.worktree;i.repoId!==t||i.id===n||i.kind!=="worktree"||r.push({id:i.id,title:i.title,branch:i.branch,dir:i.path.slice(i.path.lastIndexOf("/")+1),dot:ks(o),state:Nh(o),at:_i(i)})}return r}function wj(e,t){const n=e.trim();if(!n||/\s/.test(n))return null;const r=t.find(o=>o.branch===n||o.dir===n);return r?`@${r.title} `:null}function cU(e,t){return/[/-]/.test(e)?wj(e,t):null}const f1=e=>e.toLowerCase().replace(/[^a-z0-9]/g,"");function h1(e,t){const n=f1(e);if(!n)return!e.trim();const r=/\s$/.test(e);return[t.title,t.branch].some(o=>{const i=f1(o);return i.includes(n)&&(!r||!i.endsWith(n))})}function Eo({id:e,title:t,inert:n}){const r=tt(),o=lt(),i=P(w=>w.visible),a=P(w=>nn(w,e)),c=P(w=>a?null:Object.values(w.archived).flat().find(y=>y.id===e)??null),u=S.useMemo(()=>a?Qh(i,a.worktree.repoId,null).find(w=>w.id===e)??null:null,[i,a,e]),h=(u==null?void 0:u.branch)??(c==null?void 0:c.branch);if(!h)return d.jsx("span",{children:t??e});const f=Zh(u??{title:(c==null?void 0:c.title)??t??h,archived:!0,branch:h}),m=Pt(f.text,void 0,{placement:"follow",dot:f.dot,detail:f.detail}),g=Uh({kind:"worktree",id:e,archived:!u},null,{sock:r,dispatch:o});return d.jsxs("span",{className:"chat-mention","data-worktree":e,"data-branch":h,"data-archived":u?void 0:"",...m,onClick:n?void 0:w=>{w.stopPropagation(),g==null||g()},children:["@",f.text,f.dot&&d.jsx("span",{className:"chat-mention-dot",children:d.jsx("span",{className:`dot ${f.dot}`})})]})}function uU(e){const t=e.body??"";return e.note?`${t.trimEnd()}
|
|
224
|
+
|
|
225
|
+
---
|
|
226
|
+
|
|
227
|
+
You added: ${e.note}
|
|
228
|
+
`:t}function dU({item:e,worktreeId:t,marked:n,children:r}){tt();const o=lt(),i=e.via==="plan",a=()=>{if(i&&e.path&&t){Fn({dispatch:o},{worktreeId:t,path:e.path,view:"preview"});return}o({a:"open-loose",v:{worktreeId:t??e.origin.id,name:`${e.origin.title}.md`,text:uU(e),binary:!1,tooLarge:!1,source:{kind:"text"},seq:Lo()}})};return d.jsx(Rr,{icon:"spawn",word:i?"plan":"piece",tone:"accent",at:e.ts,"data-state":ur({cursor:n}),below:[e.note?`you added: ${e.note}`:void 0,r],children:d.jsxs("span",{className:"daemon-text",children:["from ",d.jsx(Eo,{id:e.origin.id,title:e.origin.title}),e.origin.project?` in ${e.origin.project}`:""," · ",d.jsx(De,{variant:"inline","data-tip":i?"Read the plan this worktree was given, beside the chat":"Read the message beside the chat",onClick:a,children:i?"the plan":"the message"})]})})}function Jh({src:e,n:t,name:n,width:r,height:o,bytes:i,kept:a,uploading:c,progress:u,onRemove:h,className:f=""}){const m=tt();return d.jsx(Vw,{className:He("image-chip",f),label:d.jsxs(d.Fragment,{children:[d.jsx("img",{className:"image-thumb",src:e,alt:n,width:40,height:40}),d.jsxs("span",{className:"pick-target",children:[d.jsx("b",{children:cE("image",t)}),d.jsxs("span",{className:"pick-file row-dim",children:[" ","· ",n," · ",r,"×",o," · ",Mk(i),u!==void 0?d.jsxs(d.Fragment,{children:[" ","· ",d.jsxs("span",{className:"pick-progress",children:[u,"%"]})]}):c&&" · uploading"]})]})]}),peek:d.jsx("img",{src:e,alt:n,style:{aspectRatio:`${r} / ${o}`}}),full:d.jsx("img",{src:e,alt:n}),menu:g=>du(e,g,a&&{...a,sock:m}),removeLabel:"Remove image",onRemove:h})}function fU({img:e,worktreeId:t,src:n}){return d.jsx(Jh,{className:"in-chat",src:n,...e,kept:{worktreeId:t,file:e.file}})}const hU=/(^|\s)@\S/;function hy({text:e,worktreeId:t,root:n,inField:r}){const o=Un(),i=tt(),a=P(y=>{var v;return t?(v=y.local[t])==null?void 0:v.files:void 0}),c=P(y=>y.visible),u=P(y=>{var v;return(v=nn(y,t))==null?void 0:v.worktree.repoId}),h=P(y=>u?y.archived[u]:void 0),f=S.useMemo(()=>RT(Qh(c,u,t),h),[c,h,u,t]),m=S.useMemo(()=>IT(a,f),[a,f]),g=S.useMemo(()=>ly(e,m),[e,m]),w=a===void 0&&t&&hU.test(e)?t:null;return S.useEffect(()=>{w&&Oh(w,o.getState(),{sock:i,dispatch:o.dispatch})},[w,o,i]),d.jsx(d.Fragment,{children:g.map((y,v)=>{if(y.kind==="text")return y.text;if(y.kind==="changes"){const T=Pt("this worktree's uncommitted files",void 0,{placement:"follow"});return d.jsx("span",{className:"chat-mention","data-changes":"",...T,children:y.text},v)}if(y.kind==="worktree"){const T=Zh(y),j=Pt(T.text,void 0,{placement:"follow",dot:T.dot,detail:T.detail});return d.jsx("span",{className:"chat-mention","data-worktree":y.id,"data-branch":y.branch,"data-archived":y.archived?"":void 0,...j,children:r?y.text:d.jsxs(d.Fragment,{children:["@",T.text,T.dot&&d.jsx("span",{className:"chat-mention-dot",children:d.jsx("span",{className:`dot ${T.dot}`})})]})},v)}if(!n||!t)return y.text;const N=y.kind==="folder",x=`${n}/${y.path}${N?"/":""}`,_=Pt(N?`${y.path}/`:y.path,void 0,{placement:"follow"});return d.jsx("a",{className:"chat-mention",href:x,tabIndex:r?-1:void 0,..._,children:y.text},v)})})}function py(e,t,n,r){if(e.target.closest("[data-changes]")){n&&r.dispatch({a:"focus-changes",tab:"changes"});return}Gw(e,t,n,r)}function pU(e){return e.length<2||!e.every(t=>{var n;return t.length===1&&((n=t[0])==null?void 0:n.diff)})?null:gU(e.map(t=>t[0].text))}const mU=/^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@/;function gU(e,t=3){let n=[];for(const r of e){const o=kU(r);if(!o)return null;const i=wU(n,o);if(!i)return null;n=i}return n.some(r=>r.kind!=="same")?yU(n,t):null}function kU(e){const t=[];let n=null;for(const r of e.split(`
|
|
229
|
+
`)){const o=mU.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 wU(e,t){const n=[];let r=0,o=0,i=0,a=0;const c=f=>{f.kind==="same"?o=f.a-f.c:f.kind==="add"?o-=1:o+=1},u=()=>{for(;r<e.length&&e[r].kind==="del";)n.push(e[r]),c(e[r]),r++},h=f=>{for(let m=f;m<e.length;m++){const g=e[m];if(g.kind!=="del")return g.c}return Number.POSITIVE_INFINITY};for(const f of t){if(f.oldStart<=a)return null;for(;r<e.length;){const w=e[r];if((w.kind==="del"?h(r):w.c)>=f.oldStart)break;n.push(w.kind==="del"?w:{...w,c:w.c+i}),c(w),r++}let m=f.oldStart,g=f.newStart;for(const w of f.ops){if(u(),w.mark==="+"){n.push({kind:"add",c:g,text:w.text}),g++;continue}const y=e[r],v=y&&y.kind!=="del"&&y.c===m?y:void 0;if(v){if(v.text!==w.text)return null;r++,c(v),w.mark===" "?n.push({...v,c:g}):v.kind==="same"&&n.push({kind:"del",a:v.a,text:v.text})}else w.mark===" "?n.push({kind:"same",a:m+o,c:g,text:w.text}):n.push({kind:"del",a:m+o,text:w.text});w.mark===" "&&g++,m++}i=g-m,a=m-1}for(;r<e.length;r++){const f=e[r];n.push(f.kind==="del"?f:{...f,c:f.c+i})}return n}function yU(e,t){const n=[];for(const r of bU(e))for(const[o,i]of xU(r.rows,t)){const a=vU(r.rows.slice(o,i)),c=a.filter(m=>m.kind!=="add").length,u=a.filter(m=>m.kind!=="del").length,h=a.find(m=>m.kind!=="add"),f=a.find(m=>m.kind!=="del");n.push(`@@ -${h?h.a:r.oldAt[o]},${c} +${f?f.c:r.newAt[o]},${u} @@`,...a.map(m=>`${m.kind==="add"?"+":m.kind==="del"?"-":" "}${m.text}`))}return n.join(`
|
|
230
|
+
`)}function vU(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 bU(e){const t=[];let n=null,r=1,o=1;for(const i of e){const a=i.kind==="add"?r:i.a,c=i.kind==="del"?o:i.c;(!n||a!==r||c!==o)&&(n={rows:[],oldAt:[],newAt:[]},t.push(n)),n.rows.push(i),n.oldAt.push(a),n.newAt.push(c),r=a+(i.kind==="add"?0:1),o=c+(i.kind==="del"?0:1)}return t}function xU(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 a=0;for(;i+a<e.length&&e[i+a].kind==="same";)a++;if(a>t*2||i+a>=e.length)break;i+=a}n.push([Math.max(0,r-t),Math.min(e.length,o+t+1)]),r=o+t+1}return n}function Sf({pieces:e}){return d.jsx(d.Fragment,{children:e.map((t,n)=>{if(t.scope===qh)return d.jsx("a",{className:t.changed?"ch":void 0,href:t.text,target:"_blank",rel:"noreferrer",children:t.text},n);const r=`${t.changed?"ch ":""}${t.scope?`sy-${t.scope}`:""}`.trim();return r?d.jsx("span",{className:r,children:t.text},n):d.jsx(S.Fragment,{children:t.text},n)})})}function ep({pick:e,worktreeId:t,tipText:n,onHover:r,onOpen:o,onRemove:i,className:a=""}){const c=e.callFile,u=e.file,h=c?{path:c,line:e.callLine}:u?{path:u,line:e.line}:null,f=c&&u?{path:u,line:e.line}:null,m=(_,T)=>`${_}${T?`:${T}`:""}`,g=_=>_.split("/").pop()??_,w=(_,T,j,C)=>o?d.jsx("button",{className:"pick-open","data-tip":C,onClick:()=>o(_,T??1),children:j}):j,y=wn("chat"),{host:v}=Wr(),N=S.useRef(null),x=i?()=>{r==null||r(!1),i()}:void 0;return d.jsxs("div",{ref:N,className:He("pick-chip row row-sm",a),"data-tip":n,onMouseEnter:()=>r==null?void 0:r(!0),onMouseLeave:()=>r==null?void 0:r(!1),...y.contextMenu(()=>H6(e,{remove:x,host:v})),children:[d.jsxs("span",{className:"pick-target",children:[d.jsx(St,{name:"pick",className:"icon-inline"})," ",iw(e),h&&d.jsxs("span",{className:"pick-file row-dim",children:[" ","· ",w(h.path,h.line,m(g(h.path),h.line),`Open ${m(h.path,h.line)}`)]}),f&&d.jsxs("span",{className:"pick-file row-dim",children:[" ","·"," ",w(f.path,f.line,m(f.path.split("/").pop()??f.path,f.line),`Open the component: ${m(f.path,f.line)}`)]})]}),x&&d.jsx(Rt,{icon:"close",label:"Remove attachment",tone:"quiet",onClick:x}),t&&(h==null?void 0:h.line)&&d.jsx(sT,{chip:N,children:d.jsx(_U,{worktreeId:t,path:h.path,line:h.line})})]})}const EU=6,SU=16;function _U({worktreeId:e,path:t,line:n}){const r=ww(),o=tt(),i=P(m=>{var g;return((g=Fo(m))==null?void 0:g.id)===e}),a=P(m=>{var g;return i?0:(g=Xr(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||a===void 0)return null;const m=c.split(`
|
|
231
|
+
`),g=n-a,w=Math.max(1,g-EU),y=Math.min(m.length,g+SU);if(w>y)return null;const v=m.slice(w-1,y);return{from:w,at:g,slice:v,painted:uy(v.join(`
|
|
232
|
+
`),cy("",t))}},[c,a,n,t]);if(!h)return null;const f=String(h.from+h.slice.length-1).length;return d.jsx("pre",{className:"pick-peek",children:h.slice.map((m,g)=>{const w=h.from+g,y=h.painted[g];return d.jsxs("span",{className:"pick-peek-line","data-state":w===h.at?"current":void 0,children:[d.jsx("span",{className:"pick-peek-n",children:String(w).padStart(f)}),y!=null&&y.length?d.jsx(Sf,{pieces:y}):m||" "]},w)})})}function NU({item:e,worktreeId:t}){var w;tt();const n=lt();if(e.state==="held"||e.state==="proposed")return null;if(e.state==="going")return d.jsx(Rr,{icon:"spawn",word:"split",tone:"accent",at:e.ts,children:d.jsx("span",{className:"daemon-text live-text",children:"starting the worktrees"})});if(e.state==="declined")return d.jsx(Rr,{icon:"close",word:"not split",tone:"quiet",at:e.ts,below:e.reason,children:d.jsx("span",{className:"daemon-text",children:"nothing started"})});const r=y=>e.pieces.find(v=>v.id===y),o=y=>{var v;return((v=r(y))==null?void 0:v.title)??y},i=e.outcomes.filter(y=>y.fate==="worktree"&&y.worktreeId),a=e.outcomes.filter(y=>y.fate==="worktree"&&y.after),c=e.outcomes.filter(y=>y.fate==="send"&&y.worktreeId),u=e.outcomes.filter(y=>y.fate==="here").length,h=e.outcomes.filter(y=>y.error),f=[];for(const y of i)f.push(d.jsxs("span",{children:[d.jsx(Eo,{id:y.worktreeId,title:y.title??o(y.pieceId)}),y.repoName?` in ${y.repoName}`:""]},y.pieceId));for(const y of a){const v=(w=r(y.pieceId))==null?void 0:w.after;f.push(d.jsxs("span",{children:[o(y.pieceId)," queued after"," ",v&&"id"in v?v.id===t?"this branch":d.jsx(Eo,{id:v.id,title:v.branch}):y.after]},y.pieceId))}for(const y of c)f.push(d.jsxs("span",{children:[o(y.pieceId)," sent to ",d.jsx(Eo,{id:y.worktreeId,title:y.title}),y.repoName?` in ${y.repoName}`:""]},y.pieceId));u&&f.push(d.jsx("span",{children:`${u} here`},"here"));const m=e.plan,g=m&&t?d.jsx(De,{variant:"inline",onClick:()=>Fn({dispatch:n},{worktreeId:t,path:m,view:"preview"}),children:e.companion?"the plan":"the list"}):null;return d.jsx(Rr,{icon:"spawn",word:"split",tone:"accent",at:e.ts,below:h.length?h.map(y=>`${o(y.pieceId)}: ${y.error}`).join("; "):void 0,children:d.jsxs("span",{className:"daemon-text",children:[f.length===0?"nothing started":f.map((y,v)=>d.jsxs("span",{children:[v>0&&", ",y]},v)),g&&d.jsxs(d.Fragment,{children:[" · ",g]})]})})}function TU({item:e}){return e.worktreeId?d.jsx(Rr,{icon:"spawn",word:"split",tone:"accent",at:e.ts,children:d.jsxs("span",{className:"daemon-text",children:[d.jsx(Eo,{id:e.worktreeId,title:e.title??"the worktree"})," started, its branch having landed"]})}):d.jsx(Rr,{icon:"close",word:"dropped",tone:"quiet",at:e.ts,below:e.reason,children:d.jsx("span",{className:"daemon-text",children:e.title??"a queued piece"})})}function jU({item:e}){return d.jsx(Rr,{icon:"check",word:e.again?"landed again":"landed",tone:"aqua",at:e.ts,children:d.jsxs("span",{className:"daemon-text",children:[e.same?d.jsx(Eo,{id:e.worktreeId,title:e.title}):`${e.title} in ${e.repoName}`,e.awaited&&", which the work here waited for",e.url&&d.jsxs(d.Fragment,{children:[" ","·"," ",d.jsx(De,{variant:"inline",onClick:()=>window.open(e.url,"_blank"),children:"the PR"})]})]})})}function $U(e){return e.startsWith("!")?e.slice(1).trim():null}function my(e){if(e.kind!=="tool"||e.name!==Si&&e.name!==rE)return null;const t=e.input;return typeof(t==null?void 0:t.command)=="string"?t.command:null}function yj(e){var t;return e.kind!=="tool"||e.name!==Si||(t=e.input)!=null&&t.landing?null:my(e)}function CU(e){return e.length>0&&e.every(t=>t.kind==="tool"&&yj(t)!==null&&t.done&&!t.isError)}function AU(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(_u(o))break;if(o.kind!=="tool"||!o.done||n.has(o.id))continue;const i=my(o);if(i===null)continue;const a=hj(o.output??"").map(u=>u.text).join(`
|
|
233
|
+
`),c=cP(a);t.unshift(`$ ${i}${c?`
|
|
234
|
+
${c}`:""}`)}if(t.length!==0)return`Shell commands the user ran since their last message, and what each printed:
|
|
235
|
+
${t.join(`
|
|
236
|
+
`)}`}const p1={diff:"Open this file's diff in the editor pane",file:"Open this file in the editor pane",preview:"Read this file rendered in the editor pane"};function vj(e,t,n,r){const o=e[0];if(!o||!n)return[];const i=Xh(Bl(o),t);return i?i.startsWith("/")?[{label:"open",tip:p1.file,open:()=>Xg(r,n.id,{href:i,path:i})}]:[...ji(i)==="preview"?["preview"]:[],...o.toolKind==="edit"?["diff"]:[],"file"].map(c=>({label:`open ${c}`,tip:p1[c],open:()=>Fn(r,{worktreeId:n.id,path:i,view:c})})):[]}const IU=(...e)=>vj(...e)[0]??null;function RU(e,t,n,r,o,i){const{sock:a}=r,c=e[0];if(!c)return[];const u=i?eT(i):[],h=[],f=Xh(Bl(c),t),m=vj(e,t,n,r).map(_=>({id:_.label.replace(" ","-"),label:_.label,onClick:_.open}));f&&!f.startsWith("/")&&n?h.push(...m,...Uo(()=>a==null?void 0:a.send({t:"reveal",worktreeId:n.id,path:f}),Bo(a))):f.startsWith("/")&&h.push(...m,...Uo(()=>a==null?void 0:a.send({t:"reveal-path",path:f}),Bo(a)));const g=[],w=Bl(c);f&&w&&g.push({id:"copy-path",label:"copy path",onClick:()=>tn(w)});const y=mu(c,t).command,v=FB(c);v&&v!==y&&g.push({id:"copy-description",label:"copy description",onClick:()=>tn(v)}),y&&g.push({id:"copy-command",label:"copy command",onClick:()=>tn(y)});const N=e.map(_=>_.output??"").filter(Boolean).join(`
|
|
237
|
+
`);N&&g.push({id:"copy-output",label:"copy output",onClick:()=>tn(N)});const x=o.leaf?[]:[{id:"fold",label:o.open?"collapse":"expand",onClick:o.toggle}];return Bn([u,h,g,x])}const bj=e=>e.replace(/\n$/,""),OU=1500,m1=4;function xj(e){return e.closest(".md pre, .card-code pre")}function fk(e){const t=xj(e);return t?bj(t.textContent??""):null}function MU(e,t){const n=e.getBoundingClientRect(),r=t.getBoundingClientRect();return{pre:t,top:r.top-n.top+e.scrollTop+m1,right:n.left+e.clientLeft+e.clientWidth-r.right+m1}}function gy(e){const[t,n]=S.useState(null),[r,o]=S.useState(null);if(S.useEffect(()=>{const h=e.current;if(!h)return;const f=g=>{if(!(g.target instanceof Element)||g.target.closest(".code-copy"))return;const w=xj(g.target);n(w&&h.contains(w)?MU(h,w):null)},m=()=>n(null);return h.addEventListener("pointerover",f),h.addEventListener("pointerleave",m),()=>{h.removeEventListener("pointerover",f),h.removeEventListener("pointerleave",m)}},[e]),S.useEffect(()=>{if(!r)return;const h=setTimeout(()=>o(null),OU);return()=>clearTimeout(h)},[r]),!(t!=null&&t.pre.isConnected))return null;const{pre:i,top:a,right:c}=t,u=r===i;return d.jsx(Rt,{className:"code-copy",style:{top:a,right:c},icon:u?"check":"copy",label:u?"Copied":"Copy code",onClick:()=>{tn(bj(i.textContent??"")),o(i)}})}function PU(e){for(const t of e.split(`
|
|
238
|
+
`)){const n=/^#{1,6}\s+(.+?)\s*#*\s*$/.exec(t);if(n)return n[1];if(t.trim()&&!t.startsWith("<!--"))return null}return null}function LU(e){return e.slice(e.lastIndexOf("/")+1).replace(/\.md$/,"")}function ky(e,t){var c;const n=ww(),r=(c=It(e,"git"))==null?void 0:c.version,[o,i]=S.useState(null);return ut([n,e,t,r],()=>{if(!n||!e||!t)return;let u=!0;return n.look(e,t).then(h=>{u&&i({plan:t,title:h?PU(h):null})}),()=>{u=!1}}),(o&&o.plan===t?o.title:null)??(t?LU(t):"")}function Ej(e){const t=P(r=>{var o;return(o=nn(r,e))==null?void 0:o.worktree.repoId}),n=P(r=>t?p9(r,t):"");return S.useMemo(()=>n?m9(n):void 0,[n])}function ng({text:e,menu:t,marked:n,worktreeId:r,fileRoot:o,streaming:i}){const a=Ej(r),c=Gh(e,{fileRoot:o,streaming:i,worktrees:a}),u=tt(),h=lt(),f=wn("chat"),m=S.useRef(null);u_(m,c);const g=P(v=>{var N;return r?(N=v.local[r])==null?void 0:N.refusedLink:void 0});ut([c,g],()=>{var N;const v=m.current;if(v)for(const x of v.querySelectorAll("a.file-link, code[data-path]")){const _=x.getAttribute("href")??x.dataset.path,T=g!==void 0&&_===g.href;x.classList.toggle("file-link-refused",T),T?((N=x.dataset).tipWas??(N.tipWas=x.dataset.tip??""),x.dataset.tip=g.message,x.dataset.tipPlacement="bottom",x.dispatchEvent(new MouseEvent("mouseover",{bubbles:!0}))):x.dataset.tipWas!==void 0&&(x.dataset.tipWas?(x.dataset.tip=x.dataset.tipWas,x.dataset.tipPlacement="follow"):(delete x.dataset.tip,delete x.dataset.tipPlacement),delete x.dataset.tipWas)}});const w=S.useRef(null),y=gy(w);return d.jsxs("div",{ref:w,className:"msg-assistant md row-edge","data-state":ur({cursor:n}),...f.contextMenu((v,N)=>t(Hh(N,o),fk(N))),onClick:v=>Gw(v,o,r,{sock:u,dispatch:h}),children:[d.jsx("div",{ref:m}),y]})}const rg=40;function Sj(e,t,n=!1){return e.map((r,o)=>{const i=cy(r.lang,t||(r.diff?nB(r.text):"")),a=r.diff?KB(r.text):[];let c=r.diff?ck(sB(a,i)):r.code&&i?ck(uy(r.text,i)):YT(r.text);return n&&o===e.length-1&&(c=XT(c)),{...r,lines:a,painted:c}})}function _j({blocks:e,path:t,worktreeId:n}){tt();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,rg).map((a,c)=>{var u;return a.kind==="hunk"?d.jsx("span",{className:"dl hunk",title:a.text},c):d.jsx("span",{className:`dl ${a.kind}`,children:(u=o.painted[c])!=null&&u.length?d.jsx(Sf,{pieces:o.painted[c]}):a.text||" "},c)}),o.lines.length>rg&&d.jsxs("button",{type:"button",className:"dl more",disabled:!t||!n,"data-tip":t&&n?"Open this file's diff":void 0,onClick:()=>n&&Fn({dispatch:r},{worktreeId:n,path:t,view:"diff"}),children:[o.lines.length-rg," more lines"]})]},i):o.code?d.jsx("pre",{className:"tool-block",children:o.painted.length?o.painted.map((a,c)=>d.jsxs(S.Fragment,{children:[c>0?`
|
|
239
|
+
`:null,d.jsx(Sf,{pieces:a})]},c)):o.text},i):d.jsx("p",{className:"tool-note",children:o.painted.length?o.painted.map((a,c)=>d.jsxs(S.Fragment,{children:[c>0?`
|
|
240
|
+
`:null,d.jsx(Sf,{pieces:a})]},c)):o.text},i))})}function DU({image:e,worktreeId:t}){const n=Wr().attachment(t,e.file),r={worktreeId:t,file:e.file,sock:tt()},[o,i]=S.useState(!1),a=wn("chat");return d.jsxs(d.Fragment,{children:[d.jsx("button",{type:"button",className:"tool-image","data-tip":"Open full size","data-tip-placement":"follow",onClick:()=>i(!0),...a.contextMenu(()=>du(n,{open:()=>i(!0)},r)),children:d.jsx("img",{src:n,alt:e.file})}),o&&d.jsx(Zw,{owner:"chat",onClose:()=>i(!1),menu:()=>du(n,{},r),children:d.jsx("img",{src:n,alt:e.file})})]})}const zU=S.memo(function({item:t,roots:n,worktreeId:r}){const o=S.useMemo(()=>Sj(dk(t,t.output??""),Bl(t),!t.done),[t]),i=mu(t,n).command,a=r?t.images??[]:[];return!i&&o.length===0&&a.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(_j,{blocks:o,path:Nj(t,n),worktreeId:r}),a.length>0&&r&&d.jsx("div",{className:"tool-out",children:a.map(c=>d.jsx(DU,{image:c,worktreeId:r},c.file))})]})});function Nj(e,t){const n=Xh(Bl(e),t??[]);return n.startsWith("/")?"":n}const FU=S.memo(function({text:t,item:n,roots:r,worktreeId:o}){const i=Bl(n),a=S.useMemo(()=>Sj([{code:!0,diff:!0,lang:"diff",text:t}],i),[t,i]);return d.jsx("div",{className:"tool-part",children:d.jsx(_j,{blocks:a,path:Nj(n,r),worktreeId:o})})});function hk({className:e,state:t,auto:n,leaf:r,growing:o,label:i,summary:a,menu:c,children:u}){const[h,f]=S.useState(null),m=S.useRef(null),g=S.useRef(null),w=c_(g),y=ID(".chat-log"),v=!r&&(h??n),[N,x]=S.useState(v);S.useEffect(()=>{v&&x(!0)},[v]);const _=()=>{r||(v||y(m.current),f(!v))},T=wn("chat");return d.jsxs("details",{ref:m,className:He(e,r&&"leaf"),"data-state":t,open:v,onToggle:j=>{if(!j.currentTarget.open||o)return;const C=g.current;C&&(C.scrollTop=0,w.read())},...T.contextMenu((j,C)=>c({open:v,leaf:!!r,toggle:_},C)),tabIndex:-1,onPointerDown:()=>{var j;return(j=m.current)==null?void 0:j.focus({preventScroll:!0})},onKeyDown:j=>{if((j.key==="ArrowLeft"||j.key==="ArrowRight")&&!r){if(j.shiftKey||j.altKey||j.metaKey||j.ctrlKey)return;Dh([{depth:0,open:v}],0,j.key)&&_();return}j.key!=="Escape"||!v||(j.stopPropagation(),f(!1))},children:[d.jsx("summary",{"aria-label":i,tabIndex:r?-1:void 0,onClick:j=>{j.preventDefault(),_()},children:a}),d.jsx("div",{className:"tool-body",ref:g,children:v||N?u:null})]})}function BU({markdown:e,streaming:t,worktreeId:n,fileRoot:r}){const o=Ej(n),i=Gh(e,r||t||o?{fileRoot:r,streaming:t,worktrees:o}:void 0),a=tt(),c=lt(),u=S.useRef(null);u_(u,i);const h=S.useRef(null),f=gy(h);return d.jsx("div",{className:"tool-part",children:d.jsxs("div",{ref:h,className:"tool-out thought-out md",onClick:m=>Gw(m,r,n,{sock:a,dispatch:c}),children:[d.jsx("div",{ref:u}),f]})})}const UU=S.memo(function({item:t,open:n,streaming:r,worktreeId:o,fileRoot:i}){const a=oj(t.text),c=a.slice(0,-1),u=r?"Thinking":"Thought",h=d.jsx(BU,{markdown:a.length?c.join(`
|
|
241
|
+
|
|
242
|
+
`):nj(t.text),streaming:r,worktreeId:o,fileRoot:i}),f=a.at(-1)??(r?"":sj(t.text));if(f){const m=c.length===0;return d.jsx(hk,{className:"tool-row",auto:!1,leaf:m,growing:r,label:f,menu:(g,w)=>Bn([Qg(fk(w)),[{id:"copy",label:"copy thought",onClick:()=>tn(t.text)}],...m?[]:[[{id:"fold",label:g.open?"collapse":"expand",onClick:g.toggle}]]]),summary:d.jsxs(d.Fragment,{children:[d.jsx(St,{name:"bulb",className:"tool-icon"}),d.jsx("span",{className:He("tool-hint thought-line",r&&"live-text"),children:f})]}),children:m?null:h})}return d.jsx(hk,{className:"tool-row",auto:!!n,growing:r,label:u,menu:(m,g)=>Bn([Qg(fk(g)),[{id:"copy",label:"copy thought",onClick:()=>tn(t.text)}],[{id:"fold",label:m.open?"collapse":"expand",onClick:m.toggle}]]),summary:d.jsxs(d.Fragment,{children:[d.jsx(St,{name:"bulb",className:"tool-icon"}),d.jsx("span",{className:He("tool-name",r&&"live-text"),children:u})]}),children:h})}),la=6,HU={land:"the land",commit:"the commit","sync-main":"the sync","pull-main":"the pull"},df=S.memo(function e({tools:t,run:n,next:r,live:o,working:i,held:a,since:c,queued:u,roots:h,worktreeId:f,marked:m}){const g=t[0],w=S.useMemo(()=>pU(t.map(q=>dk(q,q.output??""))),[t]),y=t.at(-1)??g,v=!y.done,N=v&&!!y.background,_=(v||!!r||!!a)&&!u||!!i,T=v&&!!u,j=xi(v||i?c:void 0),C=n?rU(n):-1,M=S.useMemo(()=>n?gj(n,!0):void 0,[n]),I=!!o,O=mu(g,h),A=v?zB(g):"",{label:z,icon:B}=O,U=dj(g),Q=A?"":U?"Guardian":O.name,ae=A&&g.subagent?O.hint:"",ee=ae||A||(U?MB(g.output??""):O.hint),de=!(n&&n.length>0)&&!w&&t.every(q=>{var H;return!mu(q,h).command&&dk(q,q.output??"").length===0&&!((H=q.images)!=null&&H.length)}),$=n?JB(n):0,K=CU(t),V=N?y.until?`wakes ${_h(y.until)}`:"in the background":"",X=[z,ee].filter(Boolean).join(" ")+(V?`, ${V}`:"")+(T?", queued":"")+(K?", done":""),W=A?"":n?`${$} ${$===1?"call":"calls"}`:t.length>1?`×${t.length}`:"",se=Un(),ce=tt(),he=P(q=>{var H;return f?(H=q.shipping[f])==null?void 0:H.op:void 0}),je=v&&g.name===Si&&f?{worktreeId:f,toolId:y.id}:null,$e=v?null:(()=>{const q=nn(se.getState(),f);return IU(t,h??[],q?{id:q.worktree.id}:null,{sock:ce,dispatch:se.dispatch})})();return d.jsxs(hk,{className:He("tool-row",t.some(q=>q.isError)&&"error",g.parentToolId&&"nested",n&&"spawn",T&&"queued"),state:ur({cursor:m}),auto:I,leaf:de,growing:_,label:n&&W?`${X}, ${W}`:t.length>1?`${X}, ${t.length} calls`:X,menu:(q,H)=>{const ve=nn(se.getState(),f),Se=ve?{id:ve.worktree.id}:null,ye=Hh(H,null),J=(ye==null?void 0:ye.kind)==="out"?ye.href:null;return RU(t,h??[],Se,{sock:ce,dispatch:se.dispatch},q,J)},summary:d.jsxs(d.Fragment,{children:[d.jsx(St,{name:n?"spawn":B,className:"tool-icon"}),Q&&d.jsx("span",{className:He("tool-name",_&&!ee&&"live-text"),children:Q}),A&&!ae?d.jsx("span",{className:"tool-writing","data-tip":ee,children:d.jsx(Kf,{})}):ee&&d.jsx("span",{className:He("tool-hint",_&&"live-text"),children:ee}),V&&d.jsx("span",{className:"tool-status",children:V}),T&&d.jsx("span",{className:"tool-status",children:"queued"}),K&&d.jsx(St,{name:"check",className:"tool-done"}),j>=la&&d.jsx("span",{className:He("tool-age",C>=0&&"tool-age-folded"),children:fa(j)}),W&&d.jsx("span",{className:"tool-count",children:W}),ae&&d.jsx("span",{className:"tool-writing","data-tip":A,children:d.jsx(Kf,{})}),je&&d.jsx(Rt,{icon:"stop",className:"tool-stop",label:he?`Stop ${HU[he]}: this step is killed, and what it printed so far stays`:N?"Kill what the command left running; what it printed so far stays":"Kill the command and everything it started; what it printed so far stays",onClick:q=>{q.preventDefault(),q.stopPropagation(),ce==null||ce.send({t:"exec-stop",...je})}}),$e&&d.jsx(Rt,{icon:"eye",className:"tool-open",label:$e.tip,onClick:q=>{q.preventDefault(),q.stopPropagation(),$e.open()}})]}),children:[n&&n.length>0&&d.jsx("div",{className:"spawn-run",children:n.map((q,H)=>d.jsx(e,{tools:q.tools,next:q.next,since:H===C?c:void 0,queued:M==null?void 0:M.has(H),roots:h,worktreeId:f},q.at))}),w?d.jsx(FU,{text:w,item:g,roots:h,worktreeId:f}):t.map(q=>d.jsx(zU,{item:q,roots:h,worktreeId:f},q.id))]})},(e,t)=>e.live===t.live&&e.working===t.working&&e.held===t.held&&e.since===t.since&&e.queued===t.queued&&e.next===t.next&&e.roots===t.roots&&e.worktreeId===t.worktreeId&&e.marked===t.marked&&fy(e.tools,t.tools)&&kj(e.run,t.run));function WU({item:e}){const t=tt(),n=lt(),r=P(v=>v.activeId),o=P(v=>v.layout.term),i=P(v=>{var N;return((N=v.rows.find(x=>x.id===v.activeId))==null?void 0:N.login)??!1}),a=P(v=>v.managed.problem),[c,u]=S.useState(""),[h,f]=S.useState(null),m=S.useRef(!1);if(ut([i],()=>{i&&m.current&&r&&n({a:"term-stream",id:r,stream:Os,tall:!0})}),ut([e.done],()=>{e.done&&m.current&&o&&n({a:"toggle-terminal"}),m.current=!1}),!r)return null;const g=e.provider==="aws",w=(v,N)=>{t==null||t.send({t:"agent-auth",worktreeId:r,methodId:v,...N?{apiKey:N}:{}})},y=e.methods.find(v=>v.id===h);return d.jsxs("div",{className:`auth-card ${e.done?"done":""}`,children:[d.jsx("div",{className:"auth-title","data-tip":e.done?void 0:e.detail,children:e.done?`${e.agentName} is logged in`:e.provider==="aws"?`${e.agentName}'s AWS session expired`:e.rejected?`${e.agentName}'s credentials were refused`:`${e.agentName} is not logged in`}),!e.done&&d.jsxs("div",{className:"auth-methods",children:[e.methods.map((v,N)=>v.needsKey?d.jsx(De,{variant:"outline",on:h===v.id,"data-tip":v.description,onClick:()=>f(h===v.id?null:v.id),children:v.name},v.id):d.jsx(De,{variant:"outline",tone:g&&N===0?"primary":void 0,"data-tip":v.kind==="terminal"&&!v.description?"opens in the terminal pane":v.description,onClick:()=>{w(v.id),v.kind==="terminal"&&(m.current=!0)},children:v.name},v.id)),d.jsx(De,{variant:g?"ghost":"outline",tone:g?"quiet":void 0,"data-tip":"after logging in elsewhere (the terminal, another window)",onClick:()=>t==null?void 0:t.send({t:"agent-retry",worktreeId:r}),children:"send again"})]}),!e.done&&i&&d.jsx("div",{className:"hint auth-hint",children:e.provider==="aws"?"the login tab below opens the browser to sign in. Your message sends once you are in.":"paste the code into the login tab below and press Enter; it stays hidden as you paste. Your message sends once you are in."}),!e.done&&e.refresh&&d.jsxs("div",{className:"hint auth-hint",children:["your Claude settings refresh it with ",d.jsx("code",{children:e.refresh}),", which got no session this time"]}),!e.done&&e.withheld&&d.jsx("div",{className:"hint auth-hint",children:a?"the policy file on this machine is invalid, so signing in with a Claude plan is off until it is fixed; toyon doctor says why":"signing in with a Claude plan is managed by your organization"}),!e.done&&y&&d.jsxs("form",{className:"auth-key",onSubmit:v=>{v.preventDefault(),c.trim()&&(w(y.id,c.trim()),u(""),f(null))},children:[d.jsx(Do,{type:"password",autoFocus:!0,placeholder:`${y.name} for ${e.agentName}`,value:c,onChange:v=>u(v.target.value)}),d.jsx(De,{type:"submit",children:"use key"})]})]})}const KU=S.memo(function({item:t,worktreeId:n,onPickHover:r,marked:o,streaming:i}){const a=Un(),c=tt(),u=Wr(),h=wn("chat"),f={sock:c,dispatch:a.dispatch},m=()=>{var w;return(w=nn(a.getState(),n))==null?void 0:w.worktree.path},g=w=>w&&n&&d.jsx(Bh,{children:d.jsx("div",{className:"msg-attachments",children:w.map(y=>y.kind==="image"?d.jsx(fU,{img:y,worktreeId:n,src:u.attachment(n,y.file)},`${y.kind}-${y.n}`):y.kind==="file"?d.jsx(Yh,{className:"in-chat",name:y.name,bytes:y.bytes,href:y.text?u.attachment(n,y.file):void 0,kept:{worktreeId:n,file:y.file}},`${y.kind}-${y.n}`):y.kind==="paste"?d.jsx(Vh,{className:"in-chat",n:y.n,name:y.name,source:y.source,lines:y.lines,chars:y.chars,preview:y.preview,href:u.attachment(n,y.file)},`${y.kind}-${y.n}`):d.jsx(ep,{pick:y,className:"in-chat",tipText:"Hover to highlight on the page",onHover:v=>r==null?void 0:r(y,v),worktreeId:n,onOpen:(v,N)=>wa(a,c,n,v,N)},`${y.kind}-${y.n}`))})});switch(t.kind){case"user":{const w=g(t.attachments),y=m();return d.jsxs("div",{className:"msg-user row-edge","data-state":ur({cursor:o}),...h.contextMenu((v,N)=>oa(t,n??null,f,{link:Hh(N,y)})),onClick:v=>py(v,y,n,f),children:[w,d.jsx(hy,{text:t.text,worktreeId:n,root:y})]})}case"assistant":return d.jsx(ng,{text:t.text,menu:(w,y)=>oa(t,n??null,f,{link:w,code:y}),marked:o,worktreeId:n,fileRoot:m(),streaming:i});case"error":return d.jsx("div",{className:"msg-assistant msg-error",...h.contextMenu(()=>oa(t,n??null,f)),children:t.text});case"auth":return d.jsx(WU,{item:t});case"ask":{const w=n4(t);if(w){const x=Jk(w.questions,w.answers),T={kind:"assistant",text:x.join(`
|
|
243
|
+
`)};return d.jsxs(d.Fragment,{children:[d.jsx(ng,{text:w.message,menu:(j,C)=>oa({kind:"assistant",text:w.message},n??null,f,{link:j,code:C}),worktreeId:n,fileRoot:m()}),d.jsx("div",{className:"msg-user row-edge","data-state":ur({cursor:o}),...h.contextMenu(()=>oa(T,n??null,f)),children:w.questions.map((j,C)=>{var M;return d.jsxs("div",{children:[x[C],t4(j,(M=w.answers)==null?void 0:M[C]).map((I,O)=>d.jsx("div",{children:I},O))]},j.id)})})]})}const y=o4(t);if(!y)return d.jsx(eF,{item:t});const v=y.file,N={kind:"assistant",text:y.choice};return d.jsxs(d.Fragment,{children:[v?d.jsx(ZU,{file:v,worktreeId:n}):y.text&&d.jsx(ng,{text:y.text,menu:(x,_)=>oa({kind:"assistant",text:y.text},n??null,f,{link:x,code:_}),worktreeId:n,fileRoot:m()}),d.jsx("div",{className:"msg-user",...h.contextMenu(()=>oa(N,n??null,f)),children:y.choice})]})}case"blocked":return d.jsxs(Rr,{icon:"lock",word:"blocked",tone:"red",below:t.reason,...h.contextMenu(()=>Kw(t.path,void 0,Bo(f.sock))),children:[d.jsx("span",{className:"tool-name",children:t.tool}),t.path&&d.jsx("span",{className:"tool-hint",children:t.path})]});case"grafted":return d.jsx(Rr,{icon:"layers",word:"grafted",tone:"accent",below:t.branch,"data-tip":`what follows was said in ${t.title} before it was merged in here`,"data-tip-placement":"follow",children:d.jsx("span",{className:"daemon-text",children:t.title})});case"asked":return d.jsx(Rr,{icon:"send",word:"asked",tone:"quiet",children:d.jsx("span",{className:"daemon-text",children:t.why})});case"stopped":return d.jsx(Rr,{icon:"stop",word:"stopped",tone:"quiet"});case"landed":return d.jsx(GU,{item:t});case"handed":return d.jsx(dU,{item:t,worktreeId:n,marked:o,children:g(t.attachments)});case"piece-landed":return d.jsx(jU,{item:t});case"pieces":return d.jsx(NU,{item:t,worktreeId:n});case"piece-later":return d.jsx(TU,{item:t});case"restored":return d.jsx(qU,{item:t});case"adopted":return d.jsx(Rr,{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 ZU({file:e,worktreeId:t}){const n=tt(),r=lt(),o=wn("chat"),i=ky(t??void 0,e);return d.jsx(Rr,{icon:"file",word:"plan",tone:"quiet",...o.contextMenu(()=>Kw(e,t?()=>n==null?void 0:n.send({t:"reveal",worktreeId:t,path:e}):void 0,Bo(n))),children:d.jsx("span",{className:"daemon-text",children:d.jsx(De,{variant:"inline",tone:"strong","data-tip":e,onClick:()=>t&&Fn({dispatch:r},{worktreeId:t,path:e,view:"preview"}),children:i})})})}function qU({item:e}){return d.jsx(Rr,{icon:"reload",word:"restored",tone:"quiet",at:e.ts,children:d.jsxs("span",{className:"daemon-text",children:["after ",aw(e.ts-e.archivedAt)," in the archive, back on ",e.branch,e.uncommitted?" with its uncommitted changes":""]})})}function GU({item:e}){const t=HN(e.ts),n=e.mark&&Pw(e.mark),r=`${e.text}, ${t}`,o=e.url&&d.jsx(De,{variant:"inline",onClick:()=>window.open(e.url,"_blank"),children:"the PR"});return d.jsx(Rr,{icon:"check",word:"landed",tone:"aqua",at:e.ts,below:n?r:void 0,children:d.jsxs("span",{className:"daemon-text",children:[n??r,o&&d.jsxs(d.Fragment,{children:[" · ",o]})]})})}const tp=".jump-seat, .draft-intro, .chat-input";function VU(e){const t=e instanceof Element?e:e.parentElement;return!!(t!=null&&t.closest(tp))}function g1(e,t){const n=new Map(t.map(r=>[r.id,r]));for(const r of e.querySelectorAll(`.chat-mention[data-dir]:not([data-archived], :is(${tp}) *)`)){const o=n.get(r.dataset.worktree??"");if(!o)continue;const i=Zh({...o,dir:r.dataset.dir}),a=r.querySelector(".dot"),c=`dot ${o.dot}`;a&&a.className!==c&&(a.className=c);const u=i.detail.join(`
|
|
244
|
+
`);r.dataset.tipDetail!==u&&(r.dataset.tipDetail=u),r.dataset.tipDot!==o.dot&&(r.dataset.tipDot=o.dot)}}function YU(e,t){const n=P(o=>o.visible),r=P(o=>{var i;return(i=nn(o,t))==null?void 0:i.worktree.repoId});S.useEffect(()=>{const o=e.current;if(!o||!r)return;const i=Qh(n,r,null);g1(o,i);let a=0;const c=new MutationObserver(u=>{u.every(h=>VU(h.target))||(cancelAnimationFrame(a),a=requestAnimationFrame(()=>g1(o,i)))});return c.observe(o,{childList:!0,subtree:!0}),()=>{c.disconnect(),cancelAnimationFrame(a)}},[e,n,r])}const Tj=e=>e===""||e==="!";function k1(e,t){const n=new Set,r=[];for(let o=e.length-1;o>=0;o--){const i=e[o],a=yj(i),c=a!==null?`!${a}`:t?null:i.kind==="user"?i.text:i.kind==="ask"?r4(i):null;c===null||!c.trim()||n.has(c)||(n.add(c),r.push({text:c,at:o}))}return r}function XU(e,t,n,r){if(!t){if(r!=="up"&&r!=="first"||!Tj(n))return null;const c=k1(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=k1(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 a=o[i];return a?{walk:{at:a.at,from:t.from},text:a.text}:{walk:t,text:n}}function QU(e,t,n,r){const o=new Map;return{rows:t.map((a,c)=>{const u=n(a,c),h=e.get(a.at),f=h&&h.row.kind===u.kind&&JU(h.row.props,u.props)?h.el:r(a,u);return o.set(a.at,{row:u,el:f}),f}),cache:o}}function JU(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],a=t[o];if(!Object.is(i,a)&&(!Array.isArray(i)||!Array.isArray(a)||i.length!==a.length||!i.every((c,u)=>Object.is(c,a[u]))))return!1}return!0}const e7=4;function t7(e,t,n){const r=Math.max(t,0);return n?e>=r+1:e>=r+e7}function n7(e,t,n){S.useEffect(()=>{const r=e.current,o=r==null?void 0:r.parentElement,i=r==null?void 0:r.querySelector(":scope > .chat-input");if(!r||!o||!i){n(!1);return}let a=0,c=!1,u=0,h=0;const f=()=>o.style.setProperty("--cover",`${c?h:u}px`),m=()=>{if(u=i.offsetHeight,h=u,t&&i.classList.contains("foldable")){const N=r.scrollTop;i.classList.add("fold-measure"),h=i.offsetHeight,i.classList.remove("fold-measure"),r.scrollTop=N}a=u-h,o.style.setProperty("--box-h",`${u}px`),o.style.setProperty("--fold",`${a}px`),o.style.setProperty("--keep",`${h}px`),f()},g=()=>{if(!t)return;const N=t7(r.scrollHeight-r.scrollTop-r.clientHeight,a,c);N!==c&&(c=N,f(),n(c))};m(),g(),r.addEventListener("scroll",g,{passive:!0});const w=new ResizeObserver(()=>{m(),g()});w.observe(i);let y=i.className;const v=new MutationObserver(()=>{i.className!==y&&(y=i.className,m(),g())});return v.observe(i,{attributes:!0,attributeFilter:["class"]}),()=>{r.removeEventListener("scroll",g),w.disconnect(),v.disconnect();for(const N of["--box-h","--fold","--keep","--cover"])o.style.removeProperty(N);n(!1)}},[e,t,n])}const r7={get current(){return Gc.el}},o7={upTo:e=>e.querySelector(":scope > .jump-seat"),except:tp};function pk({items:e,next:t,worktreeId:n,onOpen:r}){const o=Wr();return d.jsx(Bh,{children:d.jsx("div",{className:"msg-attachments",children:Ok(e,t).map(([i,a])=>i.kind==="image"?d.jsx(Jh,{className:"in-chat",src:"local"in i&&i.local||o.upload(i.upload),n:a,name:i.name,width:i.width,height:i.height,bytes:i.bytes,progress:"progress"in i?i.progress:void 0},`image-${a}`):i.kind==="file"?d.jsx(Yh,{className:"in-chat",name:i.name,bytes:i.bytes,href:i.text&&i.upload?o.upload(i.upload):void 0,progress:"progress"in i?i.progress:void 0},`file-${a}`):i.kind==="paste"?d.jsx(Vh,{className:"in-chat",n:a,name:i.name,source:i.source,...qk(i.text),text:i.text},`paste-${a}`):d.jsx(ep,{className:"in-chat",pick:i,worktreeId:n,onOpen:r},`pick-${a}`))})})}function s7({entry:e,next:t,worktreeId:n,onOpen:r}){const o=lt(),i=It(e.id,"draft"),a=It(e.id,"attachments");return d.jsxs("div",{className:"msg-user queued-msg",children:[d.jsxs("span",{className:"queued-tag",children:[d.jsx(St,{name:"clock",className:"icon-inline"}),d.jsx("span",{className:"live-text",children:"uploading"})]}),d.jsxs("span",{className:"queued-actions",children:[d.jsx(Rt,{icon:"edit",label:"Edit: puts it back in the input",onClick:()=>o({a:"unsend",id:e.id})}),d.jsx(Rt,{icon:"close",label:"Remove: it is not sent",onClick:()=>o({a:"drop-out",id:e.id})})]}),d.jsxs("div",{className:"queued-text",children:[a.length>0&&d.jsx(pk,{items:a,next:t,worktreeId:n,onOpen:r}),i]})]})}const i7=new Set;function og({active:e,archived:t,found:n,lead:r,tail:o,foot:i}){var mn;const a=tt(),c=Un(),u=lt(),h=P(L=>L.frame==="phone"),f=(e==null?void 0:e.worktree.id)??(t==null?void 0:t.id)??(n==null?void 0:n.id)??null,m=It(f,"chat"),g=It(f,"queue"),w=It(f,"sending"),y=S.useMemo(()=>mg(CS(m)),[m]),v=S.useMemo(()=>{let L=y;return g.map(re=>{const be=L;return L=Kc(L,re.attachments??[]),be})},[g,y]),N=P(L=>L.outbox),x=S.useMemo(()=>{let L=g.reduce((re,be)=>Kc(re,be.attachments??[]),y);return N.filter(re=>re.log===f).map(re=>{const be=L;return L=Kc(L,re.kinds.map(Xe=>({kind:Xe}))),{entry:re,next:be}})},[N,f,g,y]),_=w!=null&&w.message?g.findIndex(L=>{var re;return L.text===((re=w.message)==null?void 0:re.text)}):-1,T=S.useRef(null);YU(T,f),$6(T,o7);const[j,C]=S.useState(null),M=S.useCallback(()=>{const L=(T.current&&Yg(T.current))??"";C(re=>({seed:L||(re==null?void 0:re.seed)||"",seq:((re==null?void 0:re.seq)??0)+1}))},[]),I=S.useCallback(L=>!(L!=null&&L.closest("[data-pane]"))&&!c.getState().overlay,[c]);VN(r7,Hw,M,I);const O=L=>{if(C(null),L){const re=window.getSelection();re==null||re.removeAllRanges(),re==null||re.addRange(L)}},A=c_(T,m);ut([f],()=>A.jump());const z=A.offStart&&A.moving==="up",B=A.offEnd&&(A.moving==="down"||A.away),U=L=>L.preventDefault(),Q=(z||B)&&d.jsxs("div",{className:He("jump",A.away&&"jump-news"),children:[z&&d.jsx("button",{className:"jump-up",onMouseDown:U,onClick:A.start,"data-tip":"Jump to start",children:d.jsx(St,{name:"caret-up",className:"icon-inline"})}),B&&d.jsxs("button",{className:"jump-down",onMouseDown:U,onClick:A.jump,"data-tip":"Jump to latest",children:[d.jsx(St,{name:"caret",className:"icon-inline"}),A.away&&" new messages"]})]}),ae=S.useCallback(L=>u({a:"reading",on:L}),[u]);n7(T,h,ae);const ee=It(f,"mark"),de=(ee==null?void 0:ee.by)==="walk"?ee.at:void 0,$=S.useRef(null),K=()=>{const L=T.current,re=L==null?void 0:L.querySelector(':scope > [data-state~="cursor"]');if(!L||!re)return;const be=parseFloat(getComputedStyle(L).paddingTop)||0;L.scrollTop+=re.getBoundingClientRect().top-L.getBoundingClientRect().top-be,A.read()};ut([de],()=>{const L=T.current;if(L){if(de===void 0){const re=$.current;if($.current=null,!re||!Tj(Xr(c.getState(),f).draft))return;re.bottom?A.jump():(L.scrollTop=re.top,A.read());return}$.current??($.current={bottom:A.pinned(),top:L.scrollTop}),K()}});const V=It(f,"sent");ut([V],()=>{V&&A.jump()});const X=x.length,W=S.useRef(X);ut([X],()=>{X>W.current&&A.jump(),W.current=X});const se=(ee==null?void 0:ee.by)==="reveal"?ee:void 0,ce=S.useMemo(()=>se?lU(m,se.seq):-1,[m,se]),he=de??(ce>=0?ce:void 0);ut([se==null?void 0:se.n,ce],()=>{ce>=0&&K()});const je=S.useCallback((L,re)=>{f&&(re?dn.post(f,{type:"highlight-selector",selector:L.selector,label:iw(L)}):dn.post(f,{type:"highlight-clear"}))},[f]),$e=zo(e==null?void 0:e.agent),q=It(f,"cardParked"),H=S.useMemo(()=>{const L=Aw(m);return!!L&&q!==L.id},[m,q]),ve=e==null?void 0:e.worktree,Se=(ve==null?void 0:ve.path)??(t==null?void 0:t.path)??(n==null?void 0:n.path),ye=S.useMemo(()=>Se?[Se]:[],[Se]),J=S.useMemo(()=>QB(m,ye),[m,ye]),we=S.useMemo(()=>$e?eU(m):i7,[$e,m]),ge=S.useMemo(()=>tU(J,we),[J,we]),Be=ge.floating,Ie=S.useRef([]),We=S.useMemo(()=>(Ie.current=oU(Ie.current,ge.flow),Ie.current),[ge]),pt=(e==null?void 0:e.agent)==="working",rn=pt||(e==null?void 0:e.agent)==="waiting",qt=S.useMemo(()=>rn?iU(We):-1,[rn,We]),Ue=We.at(-1),Qt=pt&&Ue&&"item"in Ue&&(Ue.item.kind==="thinking"||Ue.item.kind==="assistant")?We.length-1:-1,an=(mn=J.findLast(L=>{var re;return"tools"in L&&((re=L.tools[0])==null?void 0:re.name)===Si}))==null?void 0:mn.at,Ft=It(f,"chatAt"),Qe=xi($e?Ft:void 0),Wt=It(f,"usage"),ln=(Wt==null?void 0:Wt.heard)!==void 0&&Ft!==void 0&&Wt.heard>Ft?Wt.heard:void 0,wt=xi($e?ln:void 0),mt=xi(w&&!$e?w.at:void 0),Vt=nU(m),kn=Be.length>0,Lt=Qt>=0||Vt||kn,Pn=pt&&!Lt&&Qe<la?VB(We,ye):-1,_t=S.useMemo(()=>gj(We),[We]),yn=It(f,"running"),er=L=>yn&&L.tools.some(re=>re.id===yn.id)?yn.at:void 0,te=e==null?void 0:e.worktree.path,me=L=>`${f??""}:${L}`,Ge=(L,re)=>"spawn"in L?{kind:"tool",props:{tools:[L.spawn],run:L.run,roots:ye,worktreeId:f}}:"tools"in L?{kind:"tool",props:{tools:L.tools,next:L.next,live:re===qt||L.at===an,held:re===Pn,since:er(L),queued:_t.has(re),roots:ye,worktreeId:f,marked:L.at===he}}:L.item.kind==="thinking"?{kind:"thought",props:{item:L.item,open:re===qt,streaming:re===Qt,worktreeId:f,fileRoot:te}}:{kind:"item",props:{item:L.item,worktreeId:f,onPickHover:je,marked:L.at===he,streaming:pt&&re===We.length-1}},ot=S.useRef(new Map),Dt=QU(ot.current,We,Ge,(L,re)=>re.kind==="tool"?d.jsx(df,{...re.props},me(L.at)):re.kind==="thought"?d.jsx(UU,{...re.props},me(L.at)):d.jsx(KU,{...re.props},me(L.at)));ot.current=Dt.cache;const Ct=d.jsxs("div",{className:"chat-wrap",children:[d.jsxs("div",{className:"chat-log",ref:T,children:[r,Dt.rows,Be.map(L=>{var re;return"spawn"in L?d.jsx(df,{tools:[L.spawn],run:L.run,working:!0,since:Ft,roots:ye,worktreeId:f},me(L.at)):((re=L.tools[0])==null?void 0:re.name)===Si?d.jsx(df,{tools:L.tools,live:L.at===an,since:er(L),roots:ye,worktreeId:f,marked:L.at===he},me(L.at)):d.jsx(df,{tools:L.tools,since:Ft,roots:ye,worktreeId:f},me(L.at))}),f&&(w==null?void 0:w.message)&&d.jsxs("div",{className:"msg-user",onClick:L=>py(L,Se,f,{sock:a,dispatch:u}),children:[w.message.attachments&&d.jsx(pk,{items:w.message.attachments,next:y,worktreeId:f,onOpen:(L,re)=>wa(c,a,f,L,re)}),d.jsx(hy,{text:w.message.text,worktreeId:f,root:Se})]}),e&&(w||$e&&!(e.agent==="waiting"&&H)&&!Vt&&!kn&&Pn<0&&!(Lt&&Qe<la))&&d.jsx("div",{className:"working-row",children:e.agent==="waiting"?"waiting for your answer…":Lt?Qe>=la&&d.jsxs("span",{children:["quiet for",d.jsx("span",{className:"working-num",children:fa(Qe)})]}):d.jsxs("span",{className:"working-mark",children:[d.jsx(Kf,{}),!$e&&w?mt>=la&&d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"working-word",children:"waiting for the agent"}),d.jsx("span",{className:"working-num",children:fa(mt)})]}):ln!==void 0?wt>=la&&d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"working-word",children:"thinking"}),d.jsx("span",{className:"working-num",children:fa(wt)})]}):Qe>=la&&d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"working-word",children:"waiting for the model"}),d.jsx("span",{className:"working-num",children:fa(Qe)})]})]})}),f&&g.map((L,re)=>re===_?null:d.jsxs("div",{className:"msg-user queued-msg",children:[d.jsxs("span",{className:"queued-tag",children:[d.jsx(St,{name:"clock",className:"icon-inline"}),"queued"]}),d.jsxs("span",{className:"queued-actions",children:[d.jsx(Rt,{icon:"edit",label:"Edit: removes from queue, puts it back in the input",onClick:()=>R_(c,a,f,re)}),d.jsx(Rt,{icon:"close",label:"Remove from queue",onClick:()=>a==null?void 0:a.send({t:"unqueue",worktreeId:f,index:re})})]}),d.jsxs("div",{className:"queued-text",children:[L.attachments&&d.jsx(pk,{items:L.attachments,next:v[re]??y,worktreeId:f,onOpen:(be,Xe)=>wa(c,a,f,be,Xe)}),L.text]})]},`q-${re}`)),f&&x.map(({entry:L,next:re})=>d.jsx(s7,{entry:L,next:re,worktreeId:f,onOpen:(be,Xe)=>wa(c,a,f,be,Xe)},L.id)),o,d.jsx("div",{className:"jump-seat",children:Q}),h&&i]}),j&&d.jsx(qN,{root:T,body:T,skip:tp,seed:j.seed,seq:j.seq,onClose:O,onReveal:A.read})]});return h?Ct:d.jsxs(d.Fragment,{children:[Ct,i]})}function a7(){try{return localStorage.getItem(Ke.installOffered)==="1"}catch{return!1}}let eh={prompt:null,offered:typeof localStorage<"u"&&a7()};const mk=new Set;function gk(e){eh={...eh,...e};for(const t of mk)t()}typeof window<"u"&&(window.addEventListener("beforeinstallprompt",e=>{e.preventDefault(),gk({prompt:e})}),window.addEventListener("appinstalled",()=>gk({prompt:null})));function jj(e){return mk.add(e),()=>{mk.delete(e)}}function $j(){return S.useSyncExternalStore(jj,()=>eh.prompt)}function l7(){return S.useSyncExternalStore(jj,()=>eh.offered)}function w1(){try{localStorage.setItem(Ke.installOffered,"1")}catch{}gk({offered:!0})}function c7(e){return!e.prompt||e.offered||e.agent!=="idle"?!1:e.chat.some(t=>t.kind==="assistant")}function Cj({hints:e,note:t,className:n=""}){return d.jsxs("div",{className:`key-hints ${n}`.trim(),children:[e.map(([r,o])=>d.jsxs("span",{className:"key-hint",children:[d.jsx(os,{k:r}),o]},r)),t&&d.jsx("span",{className:"key-note",children:t})]})}const u7={side:"top",align:"start",offset:4,alignOffset:-10,matchWidth:-20,flip:"side",margin:8};function d7({results:e,keyOf:t,row:n,rowClass:r,nav:o,listRef:i,empty:a,note:c,groupOf:u,groupHead:h}){const f=new Set(u?e.map(u):[]);return d.jsxs(Ls,{className:"inline-picker",anchor:"parent",placement:u7,children:[d.jsxs("div",{className:"picker-list",ref:i,children:[e.map((m,g)=>{const w=u==null?void 0:u(m),y=w!==void 0&&f.size>1&&(g===0||(u==null?void 0:u(e[g-1]))!==w)?d.jsx("div",{className:"picker-group",children:(h==null?void 0:h(w))??w}):null;return d.jsxs(S.Fragment,{children:[y,d.jsx("button",{className:He("picker-item",r==null?void 0:r(m)),"data-state":ur({cursor:g===o.index}),onMouseMove:()=>g!==o.index&&o.setIndex(g),onMouseDown:v=>v.preventDefault(),onClick:()=>o.pick(m),children:n(m,g===o.index)})]},t(m))}),e.length===0&&d.jsx("div",{className:"empty",children:a})]}),d.jsx(Cj,{hints:[["↑↓","moves"],["tab","inserts"],["esc","dismisses"]],note:c})]})}const y1=e=>Math.max(0,Math.min(1,Number.isFinite(e)?e:0));function f7({fraction:e,level:t,className:n}){const o=2*Math.PI*5.5,i=y1(e),a=S.useId(),c=3.5,u=2*c*y1(t);return d.jsxs("svg",{className:He("ring",n),viewBox:"0 0 14 14",width:"14",height:"14","aria-hidden":"true",children:[t!==void 0&&d.jsxs(d.Fragment,{children:[d.jsx("clipPath",{id:a,children:d.jsx("circle",{cx:"7",cy:"7",r:c})}),d.jsx("rect",{className:"ring-level",clipPath:`url(#${a})`,x:"0",y:7+c-u,width:"14",height:u})]}),d.jsx("circle",{className:"ring-track",cx:"7",cy:"7",r:5.5}),d.jsx("circle",{className:"ring-fill",cx:"7",cy:"7",r:5.5,strokeDasharray:`${o*i} ${o}`})]})}function h7(e,t=Qc.folder.shared){return`New project: ${e}. The repository is empty apart from a root commit. Pick the mainstream stack for what the message describes, and say which in your first sentence; if the message names a stack, that wins. Scaffold it in this directory, write its .gitignore before installing anything, make it start on $PORT, and write ${t}.`}function wy(e,{sock:t}){var o;const n=[];e.canLogout&&((o=e.auth)==null?void 0:o.kind)!=="none"&&n.push({id:"logout",label:"log out",danger:!0,onClick:()=>t==null?void 0:t.send({t:"agent-logout",agent:e.id})});const r=Aj(e);return r&&n.push({id:"install",label:r,onClick:()=>t==null?void 0:t.send({t:"install-agent",agent:e.id})}),n}function Aj(e){return e.install?e.install==="missing"?"install":"install again":null}const np=e=>e.reason??"not installed",ps="";function p7(e){var h;const t=g7(e.name);if(t){const f=[t.qualifier,e.description||e.name].filter(Boolean).join(" · ");return{label:t.label,version:t.version,description:f}}const n=e.name.match(/^([A-Za-z]+)-(\d+(?:\.\d+)*)(?:-([A-Z][a-z]+))?$/);if(n!=null&&n[1]&&n[2])return{label:n[3]??n[1],version:n[2],...e.description?{description:e.description}:{}};const[r="",...o]=(e.description??"").split(" · "),i=e.name.replace(/\s*\([^)]*\)$/,""),a=r.match(/^(.+?) (\d+(?:\.\d+)*)(?: with (.+))?$/);if(!(a!=null&&a[2])||a[1]!==i)return{label:e.name,...e.description?{description:e.description}:{}};const u=[a[3]??((h=e.name.match(/\(([^)]*)\)$/))==null?void 0:h[1]),...o].filter(Boolean).join(" · ");return{label:i,version:a[2],...u?{description:u}:{}}}const m7=/(?:^|[./])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 g7(e){const t=e.match(m7),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 Ij(e,t,n,r,o){const i=iE(e),a=XC(e,o),c=v=>a&&v===(i==null?void 0:i.id)?a.id:v,u=c(t||n||(i==null?void 0:i.id)||ps),h=c(t||(i==null?void 0:i.id)||ps),f=a?e.filter(v=>v!==i):e,m=f.some(v=>v.id===u),g=f.map(v=>({c:v,words:p7(v)})),w=v=>[v.label,v.version].filter(Boolean).join(" "),y=[...i?[]:[{id:ps,label:r.label,description:r.description}],...g.map(({c:v,words:N})=>{const x=g.filter(T=>w(T.words)===w(N)).length===1?N:void 0,_=x?x.description:v.description;return{id:v.id,label:x?x.label:v.name,...x!=null&&x.version?{suffix:x.version}:{},...x!=null&&x.version&&g.some(T=>T.c!==v&&T.words.label===x.label)?{chip:w(x)}:{},description:v===a?["default",_].filter(Boolean).join(" · "):_}}),...u&&!m?[{id:u,label:u}]:[]];if(u!==h){const v=y.find(_=>_.id===u),N=y.findIndex(_=>_.id===h),x=y[N];if(x){const _=(v==null?void 0:v.chip)??(v==null?void 0:v.label)??u;y[N]={...x,description:[`${_} now`,x.description].filter(Boolean).join(" · ")}}}return{rows:y,shown:u,picked:h}}const Lc=(e,t)=>`${e} ${t}`;function k7(e){const t=e.indexOf(" ");return t<0?{agent:e,model:ps}:{agent:e.slice(0,t),model:e.slice(t+1)}}function w7(e,t,n){const r=e.length>1;let o=Lc(t,n);return{rows:e.flatMap(a=>{var f;const c=a.short??a.name,u=a.id===t;if(!a.available||!((f=a.models)!=null&&f.length))return u&&(o=Lc(a.id,ps)),[{id:Lc(a.id,ps),label:c,description:a.available?a.checkFailed??"its own default model; the rest are listed once it has run":np(a),disabled:!a.available}];const h=Ij(a.models,u?n:ps,void 0,{label:`${c} default`,description:`whatever ${a.name} runs when nothing is asked for`},a.defaultModel);return u&&(o=Lc(a.id,h.shown)),h.rows.map(m=>({...m,id:Lc(a.id,m.id),...r&&m.id!==ps?{prefix:c}:{}}))}),shown:o}}function gu({anchored:e=!1,...t}){return e?d.jsx(y7,{...t,anchored:e===!0?{}:e}):d.jsx(v7,{...t})}function y7({onClose:e,onEscape:t,boxClass:n="",bare:r=!1,anchored:o,coverBy:i,id:a,children:c}){const{onKey:u,back:h}=Rj(t);return d.jsx(Ls,{className:He(r?"":"overlay-box","anchored",n),id:a,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 v7({onClose:e,onEscape:t,boxClass:n="",bare:r=!1,id:o,children:i}){const{onKey:a,back:c}=Rj(t);return d.jsx(Ls,{className:"overlay scrim",id:o,onDismiss:e?()=>e():void 0,onKey:a,onBack:()=>c()||(e==null?void 0:e()),onClick:u=>{e&&u.target===u.currentTarget&&e()},children:d.jsx("div",{className:He(r?"":"overlay-box",n),children:i})})}function Rj(e){const t=Un(),n=()=>{if(e)return e(),!0;const o=t.getState();return!o.overlay||o.choosingFolder?!1:(t.dispatch({a:"close",back:WS(o.overlay)}),!0)};return{onKey:o=>{o.key==="Escape"&&n()&&o.stopPropagation()},back:n}}function b7(e){const t=e.value.length;e.setSelectionRange(t,t)}function x7({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 Hr({items:e,filter:t,keyOf:n,row:r,rowClass:o,rowTitle:i,onPick:a,onBack:c,onActive:u,onSide:h,onTab:f,onQuery:m,completionOf:g,narrowTo:w,placeholder:y,initialQuery:v="",initialIndex:N,selectOnMount:x=!1,idleWhen:_,onIdlePick:T,anchored:j=!1,onEscape:C,lead:M,trailing:I,empty:O="no matches",footer:A,keys:z,rowMenu:B,groupOf:U,groupHead:Q,headAlone:ae=!1,field:ee}){const de=wn("picker"),[$,K]=S.useState(v),V=S.useMemo(()=>t(e,$),[e,$,t]),X=S.useRef(null),W=Na(),se=$D(x,!W&&!ee);S.useEffect(()=>{if(!m)return;const ge=setTimeout(()=>m($),150);return()=>clearTimeout(ge)},[$,m]);const ce=aN({results:V,keyOf:n,q:$,onPick:a,listRef:X,onActive:u,onSide:h,completionOf:g,narrowTo:w,setQ:K,initialIndex:N,idle:(_==null?void 0:_(v))??!1,onIdlePick:T}),{index:he,ghost:je}=ce,$e=ee?ee.open:!0;ut([$e,v],()=>{!ee||$e||(K(v),ce.setIndex(_!=null&&_(v)?-1:0))}),ut([$e],()=>{if(!ee||!$e||W)return;const ge=()=>{const Ie=se.current;!Ie||document.activeElement===Ie||(Ie.focus(),x&&Ie.select())};ge();const Be=requestAnimationFrame(ge);return()=>cancelAnimationFrame(Be)});const q=S.useRef(!1),H=typeof z=="function"?z(ce.active,$):z,ve=[];H!=null&&H.nav&&ve.push(["↑↓",H.nav]),H!=null&&H.side&&h&&ve.push(["←→",H.side]),H!=null&&H.complete&&(je!=null&&je.accept)&&ve.push(["tab",H.complete]),H!=null&&H.tab&&f&&ve.push(["tab",H.tab]),H!=null&&H.pick&&ve.push(["enter",H.pick]),H!=null&&H.back&&ve.push(["esc",H.back]);const Se=ge=>d.jsxs("div",{...ee==null?void 0:ee.attrs,className:He("picker-input",ee&&"picker-field",ee==null?void 0:ee.className),"data-open":(ee==null?void 0:ee.open)||void 0,onMouseDown:Be=>{var Ie;Be.target.closest("input, .float")||(Be.preventDefault(),(Ie=se.current)==null||Ie.focus())},children:[M,d.jsxs("div",{className:"picker-caret",children:[d.jsx(Do,{font:"mono",bare:!0,ref:se,value:$,spellCheck:!1,"aria-controls":ee==null?void 0:ee.id,"aria-expanded":ee?ee.open:void 0,onFocus:()=>{ee&&!ee.open&&ee.onOpen()},onBlur:Be=>{const Ie=Be.relatedTarget;ee!=null&&ee.open&&Ie instanceof Element&&!Ie.closest(".float")&&c()},onMouseDown:Be=>{const Ie=document.activeElement!==Be.currentTarget;if(q.current=Ie,ee&&Ie){const We=document.getSelection();We&&(!We.isCollapsed||We.toString()!=="")&&We.removeAllRanges()}},onClick:Be=>{if(!ee||!q.current)return;q.current=!1;const Ie=Be.currentTarget;setTimeout(()=>{document.activeElement===Ie&&Ie.selectionStart===Ie.selectionEnd&&Ie.select()},0)},onChange:Be=>{K(Be.target.value),ce.setIndex(_!=null&&_(Be.target.value)?-1:0),ee&&!ee.open&&ee.onOpen()},onKeyDown:Be=>{var Ie;if(ee&&!ee.open){if(Be.key==="ArrowDown"||Be.key==="ArrowUp")ee.onOpen();else if(Be.key==="Escape"){b7(Be.currentTarget),Be.currentTarget.blur();return}}if(B&&ce.active&&(Be.key==="ContextMenu"||Be.key==="F10"&&Be.shiftKey)){const We=(Ie=X.current)==null?void 0:Ie.querySelector('[data-state~="cursor"]');if(We){Be.preventDefault(),Be.stopPropagation(),uo.open({items:B(ce.active),owner:"picker",target:We,anchor:We.getBoundingClientRect()});return}}ce.onKeyDown(Be)||!f||Be.key!=="Tab"||Be.shiftKey||(Be.preventDefault(),f())},placeholder:y}),je&&d.jsxs("div",{className:"picker-ghost","aria-hidden":"true",children:[d.jsx("span",{className:"picker-typed",children:$}),x7(je)]})]}),I,ge]}),ye=new Map;if(U)for(const ge of V)ye.set(U(ge),(ye.get(U(ge))??0)+1);const J=d.jsxs("div",{className:"picker-list",ref:X,onMouseDown:ge=>{ee&&ge.target!==ge.currentTarget&&ge.preventDefault()},children:[V.map((ge,Be)=>{const Ie=U==null?void 0:U(ge),We=Ie!==void 0&&(ae||ye.size>1)&&(Be===0||(U==null?void 0:U(V[Be-1]))!==Ie)?d.jsx("div",{className:"picker-group",children:(Q==null?void 0:Q(Ie,ye.get(Ie)??0))??Ie}):null;return d.jsxs(S.Fragment,{children:[We,d.jsx("button",{className:He("picker-item",o==null?void 0:o(ge)),"data-state":ur({cursor:Be===he}),title:i==null?void 0:i(ge),onMouseMove:()=>Be!==he&&ce.setIndex(Be),onClick:()=>{var pt;ce.pick(ge),(pt=se.current)==null||pt.focus()},...de.contextMenu(()=>(B==null?void 0:B(ge))??[]),children:r(ge,Be===he,$)})]},n(ge))}),V.length===0&&d.jsx("div",{className:"empty",children:typeof O=="function"?O($):O}),A==null?void 0:A($,V)]}),we=ve.length>0&&d.jsx(Cj,{hints:ve});return ee?Se(ee.open&&d.jsxs(gu,{onClose:c,onEscape:C,boxClass:"picker",anchored:j,id:ee.id,children:[J,we]})):d.jsxs(gu,{onClose:c,onEscape:C,boxClass:"picker",anchored:j,coverBy:M?".picker-input > *:first-child":I?".picker-input > *:last-child":void 0,children:[Se(),J,we]})}function yi({value:e,reads:t,options:n,onChange:r,placeholder:o,hint:i,className:a,onClose:c}){const[u,h]=S.useState(!1),f=()=>{h(!1),c==null||c()},m=t??e,g=n.find(y=>y.id===m),w=(g==null?void 0:g.chip)??(g==null?void 0:g.label)??m;return d.jsxs("span",{className:"chip-picker",children:[d.jsx(De,{variant:"ghost",tone:"chrome",mono:!0,on:u,className:He("chip-picker-btn",a),...Pt(i),onClick:()=>u?f():h(!0),children:w}),u&&d.jsx(Hr,{anchored:{flip:"both",margin:0},onEscape:f,items:n,filter:(y,v)=>{const N=v.trim().toLowerCase().split(/\s+/).filter(Boolean);return y.filter(x=>{const _=`${x.prefix??""} ${x.label??x.id} ${x.suffix??""} ${x.id}`.toLowerCase();return N.every(T=>_.includes(T))})},keyOf:y=>y.id,initialIndex:y=>Math.max(0,y.findIndex(v=>v.id===e)),lead:d.jsx(De,{tone:"chrome",mono:!0,on:!0,className:"chip-picker-lead",onClick:f,children:w}),placeholder:o,rowClass:()=>"picker-row",row:y=>d.jsxs(d.Fragment,{children:[y.id===e&&d.jsx("span",{className:"row-current","aria-hidden":"true"}),d.jsxs("span",{className:He("chip-option",y.disabled&&"chip-option-off"),"aria-disabled":y.disabled,children:[d.jsxs("span",{className:"chip-option-name",children:[y.prefix?`${y.prefix} `:null,y.label??y.id,y.suffix?d.jsx("span",{className:"chip-option-suffix",children:` ${y.suffix}`}):null]}),y.description&&d.jsx("span",{className:"chip-option-desc row-dim",children:y.description})]})]}),onPick:y=>{y.disabled||(r(y.id),f())},onBack:f})]})}function Oj({choices:e,value:t,current:n,runs:r,what:o,defaultLabel:i,defaultDescription:a,placeholder:c,className:u,onChange:h,onClose:f}){const{rows:m,shown:g,picked:w}=S.useMemo(()=>Ij(e,t,n,{label:i,description:a},r),[e,t,n,r,i,a]);if(e.length===0)return null;const y=m.find(N=>N.id===g),v=(y==null?void 0:y.chip)??(y==null?void 0:y.label)??g;return d.jsx(yi,{value:w,reads:g,options:m,onChange:h,onClose:f,className:u,hint:t?`asked for ${v}; click to change`:`${v}, the agent's choice; click to pick ${o}`,placeholder:c})}function E7(e){const[t,n]=xo(Ke.effortPrefix+(e??""),ps,r=>r??"",mo().storage);return[t,n]}function v1({efforts:e,value:t,current:n,runs:r,onChange:o,onClose:i}){return d.jsx(Oj,{choices:e,value:t,current:n,runs:r,what:"an effort level",defaultLabel:"default effort",defaultDescription:"the level the agent runs at when nothing is asked for",placeholder:"how hard the agent thinks here",className:"effort-chip",onChange:o,onClose:i})}function S7(e){const[t,n]=xo(Ke.modePrefix+((e==null?void 0:e.id)??""),Cf,r=>xu.some(o=>o.id===r)?r:Cf,mo().storage);return[t,n]}const _7=e=>{var t;return((t=xu.find(n=>n.id===e))==null?void 0:t.description)??""};function b1({value:e,onChange:t,onClose:n}){return d.jsx(yi,{value:e,options:xu.map(r=>({id:r.id,label:r.name,description:r.description})),onChange:t,onClose:n,className:He("mode-chip",e!=="auto"&&"mode-held"),hint:`${e}: ${_7(e)}. Click to change`,placeholder:"what the agent may do without asking"})}function N7(e){const[t,n]=xo(Ke.modelPrefix+(e??""),ps,r=>r??"",mo().storage);return[t,n]}function T7(e,t,n){e.set(Ke.modelPrefix+t,n)}function x1({models:e,value:t,current:n,runs:r,onChange:o,onClose:i}){return d.jsx(Oj,{choices:e,value:t,current:n,runs:r,what:"a model",defaultLabel:"default model",defaultDescription:"whatever the agent runs when nothing is asked for",placeholder:"which model answers here",className:"model-chip",onChange:o,onClose:i})}function j7({agents:e,agent:t,model:n,onChange:r,onClose:o}){const{rows:i,shown:a}=S.useMemo(()=>w7(e,t,n),[e,t,n]);if(i.length===0)return null;const c=i.find(h=>h.id===a),u=c?[c.prefix,c.label,c.suffix].filter(Boolean).join(" "):n;return d.jsx(yi,{value:a,options:i,onChange:h=>{const f=k7(h);r(f.agent,f.model)},onClose:o,className:"model-chip",hint:`${u} works on the new worktree; click to change`,placeholder:"which agent and model work on it"})}function Mj(e){const t=zh(e),[n,r]=xo(Ke.profilePrefix+((e==null?void 0:e.id)??""),(e==null?void 0:e.config.defaultProfile)??"",i=>i??void 0,mo().storage);return[t.length===0?void 0:t.includes(n)?n:e==null?void 0:e.config.defaultProfile,r]}function $7({repo:e,value:t,onChange:n,onClose:r}){const o=zh(e);if(o.length===0||!t)return null;const i=(e==null?void 0:e.config.profiles)??{},a=(e==null?void 0:e.configFile)??"the settings",c=u=>{var m;const h=((m=i[u])==null?void 0:m.run)??[],f=h.length>0?`runs ${h.join(", ")}`:"runs nothing";return u===(e==null?void 0:e.config.defaultProfile)?`${f}; the default in ${a}`:f};return d.jsx(yi,{value:t,options:o.map(u=>({id:u,description:c(u)})),onChange:n,onClose:r,hint:o.length>1?`${t}: ${c(t)}. Click to change`:`the only profile in ${a}`,placeholder:"the profile the worktree runs"})}function ku(e,t,n){if(!t)return e;const r=new Set(t.map(a=>a-n)),o=[];let i="";for(let a=0;a<e.length;a++)r.has(a)?(i&&o.push(i),i="",o.push(d.jsx("b",{className:"hit",children:e[a]},a))):i+=e[a];return i&&o.push(i),o}function C7({c:e,query:t}){const n=t.trim();return d.jsxs(d.Fragment,{children:[d.jsxs("span",{className:"picker-name",children:["/",ku(e.name,n?ay(e.name,n):null,0)]}),d.jsx("span",{className:"picker-desc row-dim",children:e.description})]})}function Cn({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 A7(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 I7=/ \| | - | \u2013 | \u2014 | \u00b7 |: /,R7=/^(\d+|[0-9a-f]{8}-[0-9a-f-]{27}|[0-9a-f]{12,})$/i,O7=/^[[:$*{]|\[/;function M7(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(I7).map(a=>a.trim()).filter(Boolean)})),o=new Map;for(const{path:i,parts:a}of r)for(const c of a)o.set(c,(o.get(c)??new Set).add(i));for(const{path:i,parts:a}of r){const c=a.filter(u=>{var h;return(((h=o.get(u))==null?void 0:h.size)??0)<2});c.length>0&&t.set(i,c.join(" "))}return t}function yy(e){const t=e.replace(/\?[^#]*/,"").split(/[/#]/).filter(Boolean);for(let n=t.length-1;n>=0;n--){let r=t[n];try{r=decodeURIComponent(r)}catch{}if(R7.test(r)||O7.test(r))continue;const o=r.replace(/[-_.]+/g," ").trim();if(o)return o[0].toUpperCase()+o.slice(1)}return"Home"}const sg=8,P7=3,L7=50,D7=3;function z7(e,t,n=[]){const r=new Map,o=[],i=new Map;for(const a of(t==null?void 0:t.routes)??[]){if(a.endpoint)continue;const c=a.dynamic?zP(a.path):null;c?(o.push(c),i.set(a.path,a)):r.set(a.path,a)}return{history:e,statics:r,templates:o,templateRoutes:i,unseen:(t==null?void 0:t.unseen)??{},titles:M7(e),links:new Map(n.map(a=>[a.path,a.text]))}}function F7(e){if(!e)return"/";try{const t=new URL(e);return t.pathname+t.search+t.hash}catch{return"/"}}function B7(e){const t=e.trim();return/^[/?#]/.test(t)?t:`/${t}`}function U7(e,t){const n=/^[/?#]/.test(t)?e:e.replace(/^\//,"");return t&&n.toLowerCase().startsWith(t.toLowerCase())?n:null}const Pj=e=>/^\[\[?\.\.\.|^\*$|^\$$/.test(e),Hc=e=>Pj(e)||/[[:$*{]/.test(e)&&!/^[^[{:$*]+\?$/.test(e),H7=e=>bh(`/${e}`).text.slice(1),vy=e=>e.split("/").filter(Boolean);function by(e,t){const n=t.startsWith("/"),r=t.replace(/^\//,"").split("/"),o=vy(e);let i="";const a=[],c=m=>{const g=H7(m);a.push([i.length,i.length+g.length]),i+=g};for(let m=0;m<r.length;m++){const g=r[m],w=o[m];if(w===void 0)return null;if(m<r.length-1){if(Pj(w))return{show:t,accept:t};if(Hc(w)){if(!g)return null}else if(g.toLowerCase()!==w.toLowerCase())return null;i+=`${Hc(w)?g:w}/`;continue}if(Hc(w))g?i+=g:c(w);else{if(!w.toLowerCase().startsWith(g.toLowerCase()))return null;i+=w}}for(const m of o.slice(r.length))i+="/",Hc(m)?c(m):i+=m;const u=n?1:0,h=(n?"/":"")+i,f=a[0];return{show:h,accept:f?h.slice(0,f[0]+u):h,params:a.map(([m,g])=>[m+u,g+u])}}function W7(e,t){const n=by(e,t);return n?n.accept.length>t.length?n.accept:t:bh(e).literal}function Lj(e,t){if(e.kind==="go")return null;if(e.template){const n=by(e.path,t);return n&&n.show.length>t.length?n:null}return U7(e.path,t)}const K7=e=>e.trim().replace(/^\//,"").toLowerCase();function Dj(e,t){for(let n=0;n<e.length;n++)if("/-_.#".includes(e[n])&&e.startsWith(t,n+1))return!0;return!1}function Z7(e,t,n){const r=e.replace(/^\//,"").toLowerCase(),o=t.toLowerCase();return r===n?100:r.startsWith(n)?80:Dj(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 q7(e,t){const{text:n,literal:r}=bh(e);return r.replace(/^\//,"").toLowerCase().startsWith(t)?80:by(e,t)?70:Dj(n.replace(/^\//,"").toLowerCase(),t)?60:0}function G7(e,t){const n=vy(e).findIndex(Hc);return n>=0&&t.split("/").length>n}function Vc(e,t,n){var c;const r=e.statics.get(t),o=r?null:FP(e.templates,t),i=(r==null?void 0:r.file)??(o?(c=e.templateRoutes.get(o.path))==null?void 0:c.file:void 0),a=i?e.unseen[i]:void 0;return{kind:"page",path:t,title:e.titles.get(t)||e.links.get(t)||yy(t),template:!1,visited:n<Number.POSITIVE_INFINITY,...i?{file:i}:{},...a?{badge:a}:{},rank:n,group:(o==null?void 0:o.path)??t,score:0}}function zj(e,t){const n=e.unseen[t.file];return{kind:"page",path:t.path,title:yy(t.path),template:!0,visited:!1,file:t.file,...n?{badge:n}:{},rank:Number.POSITIVE_INFINITY,group:t.path,score:0}}function _f({rank:e,group:t,score:n,...r}){return r}const th=e=>vy(e).length,nh=e=>e.badge==="new"?0:e.badge==="changed"?1:2;function V7(e,t){const n=new Set,r=[];e.history.forEach((f,m)=>{if(f.path===t)return;const g=Vc(e,f.path,m);n.has(g.group)||(n.add(g.group),r.push(g))});const o=new Set(r.map(f=>f.path)),i=r.filter(f=>f.badge);for(const[f,m]of e.statics)e.unseen[m.file]&&f!==t&&!o.has(f)&&i.push(Vc(e,f,Number.POSITIVE_INFINITY));for(const f of e.templateRoutes.values())e.unseen[f.file]&&!n.has(f.path)&&i.push(zj(e,f));i.sort((f,m)=>nh(f)-nh(m)||f.rank-m.rank);const a=r.filter(f=>!f.badge),c=i.slice(0,sg-Math.min(P7,a.length));for(const f of a)c.length<sg&&c.push(f);const u=new Set(c.map(f=>f.path)),h=[...e.statics.keys(),...[...e.links.keys()].filter(f=>!e.statics.has(f))].filter(f=>f!==t&&!u.has(f)&&!o.has(f)).sort((f,m)=>th(f)-th(m)||(f<m?-1:f>m?1:0));for(const f of h){if(c.length>=sg)break;c.push(Vc(e,f,Number.POSITIVE_INFINITY))}return c.map(_f)}function Y7(e,t,n){const r=K7(t),o=B7(t),i=new Map;e.history.forEach((w,y)=>{w.path!==n&&i.set(w.path,Vc(e,w.path,y))});for(const w of[...e.statics.keys(),...e.links.keys()])w!==n&&!i.has(w)&&i.set(w,Vc(e,w,Number.POSITIVE_INFINITY));const a=[];for(const w of i.values()){const y=Z7(w.path,w.title,r);y>0&&a.push({...w,score:y})}let c=null;for(const w of e.templates){const y=e.templateRoutes.get(w.path);if(!c&&!e.statics.has(o)&&w.re.test(o)){c=y;continue}const v=q7(w.path,r);v>=60&&a.push({...zj(e,y),score:v})}a.sort((w,y)=>y.score-w.score||w.rank-y.rank||nh(w)-nh(y)||th(w.path)-th(y.path)||(w.path<y.path?-1:w.path>y.path?1:0));const u=new Map,h=[];for(const w of a){if(!w.template&&w.group!==w.path){const y=u.get(w.group)??0;if(y>=D7&&!G7(w.group,r))continue;u.set(w.group,y+1)}if(h.push(w),h.length>=L7)break}if(h.some(w=>w.score===100))return h.map(_f);const f={kind:"go",path:o,...c?{title:yy(c.path)}:{}},m=h[0];return!c&&m!==void 0&&m.score>=80&&X7(m.path,r)?[...h.map(_f),f]:[f,...h.map(_f)]}function X7(e,t){const n=e.replace(/^\//,"").toLowerCase().slice(t.length);return!t.endsWith("/")&&n.length>0&&!/^[/?#]/.test(n)}function Fj(e,{query:t,current:n,here:r}){return t===n||t.trim()===""?V7(e,r):Y7(e,t,r)}const Q7=[],J7=[];function Bj(e,t){const n=P(i=>(t?i.visits[t]:void 0)??Q7),r=It(e,"pages"),o=It(e,"links");return ut([e],()=>{jS(r)&&dn.post(e,{type:"links"})}),S.useMemo(()=>z7(n,r,o),[n,r,o])}function eH({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}=bh(e.path),r=[];let o=0;for(const[i,a]of n)i>o&&r.push(t.slice(o,i)),r.push(d.jsx("span",{className:"bar-route-param",children:t.slice(i,a)},i)),o=a;return o<t.length&&r.push(t.slice(o)),d.jsx("span",{className:"bar-route-path row-dim",children:r})}function Uj({row:e}){return e.kind==="go"?d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"picker-label",children:e.path}),e.title?d.jsx("span",{className:"bar-route-path row-dim",children:e.title}):null,d.jsx("span",{className:"picker-hint row-dim",children:"as typed"})]}):d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"picker-label",children:e.title}),d.jsx(eH,{row:e}),e.badge?d.jsx("span",{className:e.badge==="new"?"badge-new":"badge-changed",children:e.badge}):null]})}const Hj=e=>e.kind==="page"&&e.file?e.file:e.path,Wj=(e,t)=>e.kind==="page"&&e.template?W7(e.path,t):null,Kj=e=>e.kind==="page"&&e.template?"fills in the parameter":"goes there";function Zj(e,t,n){return e.kind!=="page"?[]:Rh([...e.file&&t.dir?Rs({id:t.worktreeId,dir:t.dir},e.file,{},n):[],x_,...e.visited?A7(t.repoId,e.path,n):[]])}function tH({worktreeId:e,repoId:t,url:n,open:r}){const o=lt(),i=tt(),a=P(y=>{const v=nn(y,e);return v?v.worktree.path:null}),c=Bj(e,t),u=F7(n),h=n?vh(n):null,f=S.useCallback((y,v)=>Fj(c,{query:v,current:u,here:h}),[c,u,h]),m=S.useCallback(y=>y===u||y.trim()==="",[u]),g=()=>o({a:"close"}),w=S.useMemo(()=>({open:r,onOpen:()=>o({a:"open",overlay:{kind:"routes"}}),id:"routes",className:"bar-path",attrs:Pt("Go to a page",zt("routes"))}),[r,o]);return d.jsx(Hr,{anchored:{matchWidth:0,cover:!1,offset:-1},field:w,items:J7,filter:f,initialQuery:u,selectOnMount:!0,idleWhen:m,onIdlePick:y=>{y.trim()===""?dn.post(e,{type:"navigate",path:"/"}):dn.post(e,{type:"reload"}),g()},keyOf:y=>`${y.kind}:${y.path}`,rowClass:()=>"picker-row",rowTitle:Hj,completionOf:(y,v)=>m(v)?null:Lj(y,v),narrowTo:Wj,onPick:y=>{dn.post(e,{type:"navigate",path:y.path}),g()},onBack:g,rowMenu:y=>Zj(y,{worktreeId:e,repoId:t,dir:a},{sock:i,dispatch:o}),placeholder:"type a path",keys:(y,v)=>({complete:"completes the path",pick:y?Kj(y):v.trim()===""?"goes to the root":"reloads",back:"closes"}),empty:"no pages yet; type a path",row:y=>d.jsx(Uj,{row:y})})}function qj(e,t){const n=t.trim();return d.jsx(Cn,{label:ku(e.label,n?ay(e.label,n):null,0),hint:e.hint&&d.jsx(os,{k:e.hint})})}function Gj({anchored:e,trailing:t}){const n=lt(),r=$T(),o=P(i=>{var a;return((a=i.paletteReturn)==null?void 0:a.mode)==="commands"?i.paletteReturn.q:""});return d.jsx(Hr,{anchored:e,trailing:t,items:r,filter:CT,rowClass:()=>"picker-row",keyOf:i=>i.id,onPick:(i,a)=>{i.sub?n({a:"palette-return",v:{mode:"commands",q:a}}):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,a,c)=>qj(i,c)})}function Vj(e,t){const n=new Map(t.map(a=>[a.path,a])),r=t.filter(a=>a.xy==="??"&&a.path.endsWith("/")).map(a=>a.path),o=e.map(a=>{const c=n.get(a)??(r.some(u=>a.startsWith(u))?{path:a,xy:"??"}:void 0);return c?{path:a,status:c}:{path:a}}),i=new Set(e);for(const a of t)!i.has(a.path)&&!a.path.endsWith("/")&&o.push({path:a.path,status:a});return o}function E1(e,t){const n=e.split("/"),r=t.split("/");for(let o=0;;o++){const i=n[o],a=r[o];if(i===void 0||a===void 0)return n.length-r.length;const c=o===n.length-1,u=o===r.length-1;if(c!==u)return c?-1:1;if(i!==a)return i<a?-1:1}}function Yj(e,t,n,r=50){const o=Vj(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)||E1(m.path,g.path)),f=o.filter(m=>!m.status).sort((m,g)=>E1(m.path,g.path));return{rows:[...h,...f].slice(0,r),changed:Math.min(h.length,r)}}const a=Qj(o,i);return a.sort((c,u)=>u.score-c.score||c.row.path.localeCompare(u.row.path)),{rows:a.slice(0,r).map(c=>c.row),changed:0}}function Xj(e,t){const n=e.toLowerCase(),r=S1(n,t);return r<=0?0:S1(n.slice(n.lastIndexOf("/")+1),t)>0?r+10:r}function Qj(e,t){const n=[];for(const r of e){const o=Xj(r.path,t);o>0&&n.push({row:r,score:r.status?o+4:o})}return n}function nH(e,t,n,r,o){const i=r.trim().toLowerCase();if(!i)return Yj(e,n,r,o).rows.map(u=>({kind:"file",path:u.path,status:u.status}));const a=Qj(Vj(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=Xj(u,i);h>0&&a.push({row:{kind:"folder",path:u},score:h})}const c=u=>u.kind==="folder"?1:0;return a.sort((u,h)=>h.score-u.score||c(u.row)-c(h.row)||u.row.path.localeCompare(h.row.path)),a.slice(0,o).map(u=>u.row)}function rH(e,t){const n=e.toLowerCase(),r=[];let o=0;for(const i of t.toLowerCase()){const a=n.indexOf(i,o);if(a===-1)return null;r.push(a),o=a+1}return r}function S1(e,t){let n=0,r=0,o=0;for(const i of t){const a=e.indexOf(i,r);if(a===-1)return 0;o=a===r?o+1:1,n+=o+(a===0||e[a-1]==="/"||e[a-1]==="."?3:0),r=a+1}return n+Math.max(0,40-e.length/4)}function oH(e){const t=e.lastIndexOf("/");return t===-1?[e,""]:[e.slice(t+1),e.slice(0,t+1)]}const _1=[],sH=[],iH=[];function aH({worktreeId:e}){var N;const t=lt(),n=tt(),r=Un(),o=P(x=>x.connected);ut([e,o,n],()=>Oh(e,r.getState(),{sock:n,dispatch:t}));const i=k_(e),a=i.files??sH,c=((N=i.git)==null?void 0:N.files)??iH,u=$T(),h=P(x=>{var _;return((_=x.paletteReturn)==null?void 0:_.mode)==="quick-open"?x.paletteReturn.q:""}),f=P(x=>{var T;const _=(T=nn(x,e))==null?void 0:T.worktree;return _?_.path:null}),m=P(x=>{var _;return((_=nn(x,e))==null?void 0:_.repoId)??null}),g=P(x=>{var _;return((_=Hf(x))==null?void 0:_.worktreeId)===e}),w=Bj(e,m),y=i.page.url?vh(i.page.url):null,v=S.useCallback((x,_)=>_.startsWith(">")?CT(u,_.slice(1)).map(T=>({kind:"cmd",c:T})):_.startsWith("/")?g?Fj(w,{query:_,current:"/",here:y}).map(T=>({kind:"page",page:T})):_1:Yj(a,c,_).rows.map(T=>({kind:"file",path:T.path,status:T.status})),[u,a,c,g,w,y]);return d.jsx(Hr,{items:_1,filter:v,keyOf:x=>x.kind==="cmd"?`c:${x.c.id}`:x.kind==="page"?`p:${x.page.kind}:${x.page.path}`:`f:${x.path}`,rowClass:x=>x.kind==="file"?"qo-file":"picker-row",rowTitle:x=>x.kind==="page"?Hj(x.page):void 0,completionOf:(x,_)=>x.kind==="page"?Lj(x.page,_):null,narrowTo:(x,_)=>x.kind==="page"?Wj(x.page,_):null,onPick:(x,_)=>{x.kind==="cmd"?(x.c.sub?t({a:"palette-return",v:{mode:"quick-open",q:_}}):t({a:"close"}),x.c.run()):x.kind==="page"?(dn.post(e,{type:"navigate",path:x.page.path}),t({a:"close"})):(Fn({dispatch:t},{worktreeId:e,path:x.path,view:ji(x.path)}),t({a:"close"}))},onBack:()=>t({a:"close"}),rowMenu:x=>x.kind==="file"&&f?Rs({id:e,dir:f},x.path,{},{sock:n,dispatch:t}):x.kind==="page"&&m?Zj(x.page,{worktreeId:e,repoId:m,dir:f},{sock:n,dispatch:t}):[],placeholder:"jump to file · type > for commands, / for pages",keys:(x,_)=>_.startsWith("/")?{complete:"completes the path",pick:(x==null?void 0:x.kind)==="page"?Kj(x.page):void 0,back:"closes"}:{pick:"opens",back:"closes"},initialQuery:h,empty:x=>x.startsWith(">")?"no matching command":x.startsWith("/")?g?"no pages yet; type a path":"no preview running":"no matches",row:(x,_,T)=>x.kind==="cmd"?qj(x.c,T.slice(1)):x.kind==="page"?d.jsx(Uj,{row:x.page}):kk(x.path,x.status,T,{gutter:c.length>0})})}function kk(e,t,n,{folder:r=!1,gutter:o=!0}={}){const[i,a]=oH(e),c=n.trim()?rH(e,n.trim()):null;return d.jsxs(d.Fragment,{children:[o&&d.jsx("span",{className:`xy ${t?rw(t.xy):""}`,children:t?ow(t.xy):""}),d.jsxs("span",{className:"name",children:[ku(i,c,a.length),r&&"/"]}),d.jsx("span",{className:"dir row-dim",children:a&&d.jsxs(d.Fragment,{children:["",ku(a,c,0),""]})}),t&&d.jsx(LN,{f:t})]})}function lH(e,t,n){var a;if(!e)return null;if(e.available)return e.checkFailed?{kind:"unready",text:e.checkFailed,retry:null}:((a=e.auth)==null?void 0:a.kind)==="none"?{kind:"unready",text:e.loginHint??`${e.name} is not logged in`,retry:null}:null;const r=n?t.find(c=>c.available&&c.id!==e.id):void 0,o=r?{other:r}:{};return e.installing?{kind:"installing",text:`${e.name} is installing`,retry:null,...o}:{kind:"failed",text:typeof e.install=="object"?`${e.name} did not install: ${e.install.failed}`:`${e.name} is not ready: ${np(e)}`,retry:Aj(e),...o}}function Dc({icon:e,verb:t,tip:n,onPress:r,onDismiss:o,className:i,children:a}){return d.jsxs("div",{className:He("composer-offer",i),children:[d.jsx(St,{name:e,className:"icon-inline"}),d.jsxs("span",{className:"composer-offer-line",children:[d.jsx(De,{variant:"inline",tone:"strong","data-tip":n,onClick:r,children:t})," ",a]}),o&&d.jsx(Rt,{icon:"close",tone:"quiet",className:"composer-offer-close",label:"Not this one",onClick:o})]})}function Jj({item:e,n:t,onRemove:n}){const r=Wr();return e.kind==="image"?d.jsx(Jh,{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(Yh,{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(Vh,{n:t,name:e.name,source:e.source,lines:e.lines,chars:e.chars,preview:e.preview,text:e.text,onRemove:n})}function cH(e,t){if(t.queued>0||t.sending||t.card)return null;const n=e.at(-1);if(!n)return null;if(n.kind==="stopped"||n.kind==="error"){if(n.seq===void 0)return null;const o=`${n.kind}:${n.seq}`;return t.dismissed.has(o)?null:n.kind==="stopped"?{verb:"continue",key:o,after:"stop"}:{verb:"continue",key:o,after:"error",...uH(e)?{again:!0}:{}}}if(n.kind!=="tool"||!n.done||!n.fixable||t.dismissed.has(n.id)||e.some(o=>o.kind==="asked"&&o.toolId===n.id))return null;const r=my(n);return r===null?null:{verb:"fix",key:n.id,toolId:n.id,command:r}}function uH(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 wk=new Set;const yk=new Set;function dH(e){return yk.add(e),()=>{yk.delete(e)}}function N1(e){wk=new Set(wk).add(e);for(const t of yk)t()}function fH(){return S.useSyncExternalStore(dH,()=>wk)}const hH=e=>xu.some(t=>t.id===e);function pH(e){return[...xu.map(t=>({name:t.id,description:t.description,hint:"[<description>]"})),{name:"check",description:"run the repo's check here and write the recap and the commit message",hint:"[<note for the commit message>]"},{name:"land",description:e},{name:"archive",description:"archive this worktree once its work has landed"},{name:"split",description:"a new worktree for part of this work, here or in another project, born with a plan for it",hint:"[<project>] [<message>]"}]}function mH(e,t,n){const r=e.trim();if(!r)return{pick:!0};const o=t.find(f=>f.id===n),i=r.search(/\s/),a=i===-1?r:r.slice(0,i),c=i===-1?void 0:r.slice(i).trim()||void 0,u=a.toLowerCase(),h=u==="here"?o:t.find(f=>f.name.toLowerCase()===u);return h?{repo:h,...c?{text:c}:{}}:o?{repo:o,text:r}:{pick:!0}}function e$(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 gH(e,t){const n=e$(e,t);return[...n.yours,...n.own,...n.rest]}function T1(e,t){const n=e$(e,t);return{rows:[...n.yours,...n.own],more:n.rest.length}}function kH(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 wu({rows:e,cursor:t,onCursor:n,onPick:r,onHint:o,hover:i=!1}){const a=Na(),c=S.useRef(null),[u,h]=S.useState(null),f=a&&!!o;dN(c,{rowOf:g=>{if(!f||g.closest("textarea"))return null;const w=g.closest(".slide"),y=w==null?void 0:w.dataset.row,v=y===void 0?void 0:e[Number(y)];return w&&y!==void 0&&(v!=null&&v.hint)&&!v.field?{el:w,key:y,rungs:1,rung:120}:null},onSlide:h,onPick:g=>o==null?void 0:o(Number(g))});const m=g=>{var w;g.target instanceof HTMLTextAreaElement||(g.preventDefault(),(w=g.currentTarget.querySelector("textarea"))==null||w.focus())};return d.jsx("div",{className:He("choices",i&&"choices-hover",a&&"choices-touch"),ref:c,children:e.map((g,w)=>{const y=!a&&t===w,v=ur({cursor:y,checked:g.checked}),N=g.tone==="deny"&&"choice-deny",x=()=>n==null?void 0:n(w),_=j=>{var I;if(!f)return j;const C=(u==null?void 0:u.key)===String(w)?u.step:null,M=C!==null&&C>0&&((I=g.hint)==null?void 0:I.on)!==!1;return d.jsxs("div",{className:"slide","data-row":w,children:[j,C!==null&&g.hint&&d.jsxs("span",{className:"slide-verb","data-rung":M?"hint":void 0,"aria-hidden":"true",children:[d.jsx("span",{className:"slide-word",children:g.hint.label}),d.jsx(St,{name:g.hint.icon})]})]},w)},T=d.jsxs(d.Fragment,{children:[!a&&d.jsx(os,{k:String(w+1),className:"choice-num row-dim"}),d.jsx("span",{className:"choice-label",children:g.label}),!a&&g.hint&&d.jsxs("span",{className:He("choice-hint row-dim",y&&g.hint.on!==!1&&"on"),children:[d.jsx(os,{k:g.hint.k})," ",g.hint.label]}),g.description&&d.jsx("span",{className:"choice-desc",children:g.description}),g.sample&&d.jsx("pre",{className:"choice-sample",children:g.sample})]});return g.field?_(d.jsxs("div",{className:He("picker-item choice row-edge",N),"data-state":v,onMouseMove:x,onMouseDown:m,children:[T,d.jsx(cu,{ref:g.field.ref,bare:!0,font:"ui",rows:1,className:"choice-field",enterKeyHint:g.field.enterKeyHint,placeholder:g.field.placeholder,value:g.field.value,onChange:j=>{var C;return(C=g.field)==null?void 0:C.onChange(j.target.value)}}),a&&g.field.onSend&&d.jsx(Rt,{className:"choice-send",icon:"send",tone:"primary",label:"Send",onClick:g.field.onSend})]},w)):_(d.jsx("button",{type:"button",className:He("picker-item choice row-edge",N),"data-state":v,disabled:g.disabled,onMouseMove:x,onClick:()=>r(w),children:T},w))})})}function t$(e){return Nf(e.key)&&(e.metaKey||e.ctrlKey)&&!e.altKey?!1:e.metaKey||e.ctrlKey||e.altKey}const n$=e=>e.length===1&&e>="1"&&e<="9",Nf=e=>e==="Enter"||e==="NumpadEnter";function wH(e,t,n){const r=Nf(e.key)&&(e.metaKey||e.ctrlKey);return t?e.key==="Escape"||e.key==="Tab"&&!e.shiftKey?{kind:"field-leave"}:r?{kind:"submit"}:Nf(e.key)&&!e.shiftKey?{kind:"field-enter"}:{kind:"typing"}:t$(e)?{kind:"chord"}:e.key==="Escape"?{kind:"escape"}:r?{kind:"submit"}:Nf(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:$u(n.cursor,e.key==="ArrowUp"?-1:1,n.count)}:n$(e.key)&&Number(e.key)<=n.count?{kind:"pick",at:Number(e.key)-1,by:"digit"}:null}function xy(e,t){var o,i,a,c;const n=e.target instanceof HTMLTextAreaElement,r=wH(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(),(a=t.onCursor)==null||a.call(t,r.to),!0;case"field-enter":return e.preventDefault(),(c=t.onFieldEnter)==null||c.call(t),!0}}function r$(e){return!e||e===document.body?!1:e.closest(".monaco-editor, .xterm")?!0:(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement)&&!e.closest(".chat-input")}function yH(e,t){ut([t],()=>{const o=requestAnimationFrame(()=>{var i;r$(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 rh(e){var n,r;const t=document.activeElement;r$(t)||t&&((n=e.current)!=null&&n.contains(t))||(r=e.current)==null||r.focus({preventScroll:!0})}function oh({root:e,id:t,onKeyDown:n,onKeyUp:r,onPaste:o,children:i}){const a=yH(e,t);return d.jsx("div",{ref:e,className:"card",tabIndex:-1,onKeyDown:n,onKeyUp:r,onPaste:o,onBlur:a,children:i})}function yu({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 vk(e){const t=S.useRef(null),n=gy(t);return"html"in e?d.jsxs("div",{ref:t,className:"card-band md",children:[d.jsx("div",{dangerouslySetInnerHTML:{__html:e.html}}),n]}):d.jsxs("div",{ref:t,className:"card-band card-code",children:[d.jsx("pre",{children:e.code}),n]})}function vH({children:e}){return d.jsx("div",{className:"card-foot",children:e})}function bH(e){const t=e.findIndex(n=>n.kind.startsWith("reject"));return t<0?null:t}function xH(e){const{key:t}=e;return t.length!==1||t===" "||t==="n"||n$(t)||t$(e)?null:t}const j1=[{selected:[]}];function EH({item:e,ask:t,worktreeId:n,rootRef:r}){var U;const o=tt(),i=lt(),a=P(Q=>Q.activeId),c=It(n,"card"),u=(c==null?void 0:c.id)===e.id?c.draft:j1,h=(U=u[0])==null?void 0:U.note,f=h!==void 0,m=f?t.choices.findIndex(Q=>{var ae;return Q.id===((ae=u[0])==null?void 0:ae.selected[0])}):-1,g=S.useRef(null),[w,y]=S.useState(0),v=t.plan,N=S.useMemo(()=>t.detail&&!v?Al(t.detail):"",[t.detail,v]),x=P(Q=>Q.frame==="phone"),_=()=>{v&&a===n&&!x&&Fn({dispatch:i},{worktreeId:n,path:v,view:"preview",focus:!1})};ut([e.id,v],_);const T=t.pieces,j=P(Q=>{var ee;const ae=T?(ee=Xr(Q,n).chat)==null?void 0:ee.find(de=>de.kind==="pieces"&&de.id===T):null;return(ae==null?void 0:ae.kind)==="pieces"?ae:null}),C=Q=>i({a:"card-draft",id:n,card:{id:e.id,draft:Q,current:0}}),M=(Q,ae)=>{const ee=t.choices[Q];ee&&(C([{selected:[ee.id],note:ae}]),y(Q),requestAnimationFrame(()=>{const de=g.current;de&&(de.focus(),de.setSelectionRange(de.value.length,de.value.length))}))},I=Q=>{const ae=t.choices[Q];if(!ae)return;const ee=h==null?void 0:h.trim();o==null||o.send({t:"agent-decide",worktreeId:n,askId:e.id,choiceId:ae.id,...ee?{note:ee}:{}}),i({a:"answered",id:n})},O=()=>i({a:"card-park",id:n,cardId:e.id}),A=()=>{var Q;h!=null&&h.trim()||C(j1),(Q=r.current)==null||Q.focus()},z=Q=>{if(xy(Q,{count:t.choices.length,cursor:w,onCursor:y,onPick:I,onEscape:O,onFieldEnter:()=>I(m),onFieldLeave:A}))return;if(Q.key==="n"){Q.preventDefault(),M(w,h??"");return}const ae=xH(Q);ae!==null&&(Q.preventDefault(),M(f?m:bH(t.choices)??w,(h??"")+ae))},B=t.choices.map((Q,ae)=>{const ee=Q.kind.startsWith("reject"),de=f&&ae===m;return{label:Q.name,tone:ee?"deny":void 0,hint:{k:"n",label:"add context",icon:"edit",on:!f},checked:de,field:de?{ref:g,value:h,placeholder:ee?"what to change, sent with your no":"a note for the work, sent with your yes",enterKeyHint:"send",onChange:$=>C([{selected:[Q.id],note:$}]),onSend:()=>I(m)}:void 0}});return d.jsxs(oh,{root:r,id:e.id,onKeyDown:z,children:[d.jsx(yu,{sub:j?d.jsxs(d.Fragment,{children:[Uz(j,n)," ",d.jsx(De,{variant:"inline","data-tip":"Read the list at the head of the plan; any row can still be moved",onClick:()=>v&&Fn({dispatch:i},{worktreeId:n,path:v,view:"preview"}),children:"The list is on the plan"}),"."]}):void 0,children:t.title}),t.command&&d.jsx(vk,{code:uj(t.command)}),N&&d.jsx(vk,{html:N}),d.jsx(wu,{rows:B,cursor:w,onCursor:Q=>{y(Q),rh(r)},onPick:I,onHint:Q=>M(Q,h??"")})]})}const SH=[{selected:[]}];function _H({item:e,worktreeId:t,rootRef:n}){var ee,de;const r=tt(),o=lt(),i=It(t,"card"),a=P($=>{var K;return(K=nn($,t))==null?void 0:K.worktree.mode})??e.mode,c=a==="plan"?"auto":a,u=(i==null?void 0:i.id)===e.id?i.draft:SH,h=(ee=u[0])==null?void 0:ee.note,f=h!==void 0,m=f?Number(((de=u[0])==null?void 0:de.selected[0])??0):-1,g=($,K=0)=>o({a:"card-draft",id:t,card:{id:e.id,draft:[{...$[0]??{selected:[]},selected:[String(K)]}],current:0}}),w=S.useRef(null),[y,v]=S.useState(0),[N,x]=S.useState(null),_=N!==null,T=e.pieces.length===1?e.pieces[0]:void 0,j=e.plan,C=()=>{j&&Fn({dispatch:o},{worktreeId:t,path:j,view:"preview"})},M=S.useMemo(()=>T?Al(T.plan):"",[T]),I=S.useMemo(()=>T?Hz(e,T):[{fate:"worktree",label:"go",notes:!0},{fate:null,label:"not now",notes:!1}],[e,T]),O=$=>{if(_||!r)return;const K=I[$];K&&(K.fate===null?r.send(Yb(e,t,!1,void 0)):(T&&K.fate!==Ri(e,T)&&r.send(U_(e,t,T.id,K.fate)),r.send(Yb(e,t,!0,h)),x($)),o({a:"answered",id:t}))},A=()=>{var K;const $=(K=I[y])!=null&&K.notes?y:I.findIndex(V=>V.notes);$!==-1&&((!f||m!==$)&&g(Ff(u,0,h??""),$),v($),requestAnimationFrame(()=>{var V;return(V=w.current)==null?void 0:V.focus()}))},z=()=>o({a:"card-park",id:t,cardId:e.id}),B=()=>{var K;const $=vf(u,0);$!==u&&g($,m),(K=n.current)==null||K.focus()},U=$=>{xy($,{count:I.length,cursor:y,onCursor:v,onPick:O,onEscape:z,onFieldEnter:()=>O(m),onFieldLeave:B})||($.key==="n"?($.preventDefault(),A()):$.key==="r"&&j&&!T&&($.preventDefault(),C()))},Q=I.map(($,K)=>({label:$.label,...N===K?{description:"starting"}:$.description?{description:$.description}:{},...$.notes?{hint:{k:"n",label:"add context",icon:"edit",on:!f}}:{},tone:$.fate===null?"deny":void 0,checked:f&&K===m,field:f&&K===m?{ref:w,value:h??"",placeholder:T?"a note for the agent there, sent with it":"a note for every piece's agent, sent with go",enterKeyHint:"send",onChange:V=>g(Ff(u,0,V),m),onSend:()=>O(m)}:void 0,disabled:_}));if(T)return d.jsxs(oh,{root:n,id:e.id,onKeyDown:U,children:[d.jsx(yu,{sub:d.jsxs(d.Fragment,{children:[T.project?`Starts a worktree in ${T.project.name}, in ${c} mode${c==="auto"?", which runs without asking":""}, with this as its plan. `:"","Nothing has started yet."]}),children:zg(e)}),d.jsx(vk,{html:M}),d.jsx(wu,{rows:Q,cursor:y,onCursor:$=>{v($),rh(n)},onPick:O})]});const ae=j?d.jsx(De,{variant:"inline","data-tip":"Open it beside the box (r)",onClick:C,children:"Read the list"}):"The list is the agent's";return d.jsxs(oh,{root:n,id:e.id,onKeyDown:U,children:[d.jsx(yu,{sub:d.jsxs(d.Fragment,{children:[ae," and change any row's fate there. Nothing has started yet."]}),children:zg(e)}),d.jsx(wu,{rows:Q,cursor:y,onCursor:$=>{v($),rh(n)},onPick:O})]})}function NH({item:e,ask:t,worktreeId:n,rootRef:r,numbers:o,onAnswer:i}){const a=tt(),c=lt(),u=Un(),h=P(q=>q.clientId),{message:f,questions:m}=t,g=Sl(e.id),w=It(g,"attachments"),y=X_(g,n),v=It(n,"card"),N=S.useMemo(()=>(v==null?void 0:v.id)===e.id?v:{id:e.id,draft:YL(m),current:0},[v,e.id,m]),{draft:x,current:_}=N,T=_===yl(m),j=m[_],C=x[_],M=!!(j!=null&&j.multi),[I,O]=S.useState(()=>wl(j,C)),A=S.useRef(null);S.useEffect(()=>{const q=window.visualViewport;if(!q)return;const H=()=>{A.current&&A.current===document.activeElement&&A.current.scrollIntoView({block:"nearest"})};return q.addEventListener("resize",H),()=>q.removeEventListener("resize",H)},[]);const z=(q,H)=>c({a:"card-draft",id:n,card:{id:e.id,draft:q,current:H}}),B=m_(),U=q=>{if(B)return;if(i){q&&i(q);return}const H=q?w:[],ve={t:"agent-answer",worktreeId:n,askId:e.id,...q?{answers:q}:{}};H.some(Ti)?c({a:"hold-send",id:g,log:n,text:Jk(m,q).join(`
|
|
245
|
+
`),frame:ve}):(a==null||a.send({...ve,...H.length?{attachments:H.map(Tl),boxId:g,clientId:h}:{}}),H.length&&c({a:"clear-attachments",id:g})),c({a:"answered",id:n})},Q=()=>c(i?{a:"ask-revive",id:n}:{a:"card-park",id:n,cardId:e.id}),ae=()=>{Qd(m,x)&&U(x)},ee=q=>{O(wl(m[q],x[q])),z(x,q)},de=q=>{j!=null&&j.note&&(z(Tb(x,_,q,M),_),requestAnimationFrame(()=>{var H;return(H=A.current)==null?void 0:H.focus()}))},$=q=>{if(!(j!=null&&j.note))return;const H=j.options[q];if(O(q),!H||M)return de(!H);z(Tb(Nb(x,_,H.value,!1),_,!1,!1),_),requestAnimationFrame(()=>{var ve;return(ve=A.current)==null?void 0:ve.focus()})},K=()=>$(I),V=q=>{if(QL(j,q))return O(q),de(!0);const H=j==null?void 0:j.options[q];if(!j||!H)return;const ve=Nb(vf(x,_),_,H.value,M);if(M){O(q),z(ve,_);return}const Se=jb(m,ve,_);O(Se.cursor),z(ve,Se.current),Se.send&&Qd(m,ve)&&U(ve)},X=()=>{var H;const q=vf(x,_);q!==x&&(z(q,_),O(wl(j,q[_]))),(H=r.current)==null||H.focus()},W=()=>{var ve;const q=vf(x,_);if((ve=r.current)==null||ve.focus(),!Nl(q[_])){q!==x&&(z(q,_),O(wl(j,q[_])));return}const H=jb(m,q,_);O(H.cursor),z(q,H.current),H.send&&Qd(m,q)&&U(q)},se=q=>{if(y.onPasteKey(q),!xy(q,{count:T?m.length:XL(j),cursor:T?void 0:I,spacePicks:M,onCursor:O,onPick:H=>T?ee(H):V(H),onSubmit:ae,onEscape:Q,onFieldEnter:W,onFieldLeave:X})){if(q.key==="ArrowLeft"||q.key==="ArrowRight"||q.key==="Tab"){q.preventDefault();const H=q.key==="ArrowLeft"||q.key==="Tab"&&q.shiftKey;return ee(s4(_,H?-1:1,a4(m)))}if(q.key==="n"&&(j!=null&&j.note))return q.preventDefault(),K();if(q.key==="s"&&!i)return q.preventDefault(),U()}},ce=q=>m.length===1&&!q.multi,he=(q,H)=>d.jsxs(vH,{children:[(!q||!ce(q))&&d.jsx(De,{variant:"outline",size:"md",disabled:B||!Qd(m,x),onClick:ae,children:"send"}),(q==null?void 0:q.note)&&H&&H.selected.length>0&&H.note===void 0&&d.jsxs(De,{tone:"quiet",size:"md",onClick:()=>de(!1),children:[d.jsx(os,{k:"n",chip:!0}),"add a note"]}),!i&&d.jsxs(De,{tone:"quiet",size:"md",onClick:()=>U(),children:[d.jsx(os,{k:"s",chip:!0}),"skip"]}),d.jsx(Rt,{className:"card-attach",icon:"attach",tone:"chrome",label:"Attach a picture or a file",onClick:()=>q_(u,g)})]}),je=w.length>0&&d.jsx(Bh,{children:d.jsx("div",{className:"card-chips",children:Ok(w,o).map(([q,H])=>{const ve=()=>c({a:"detach",id:g,key:q.key});return q.kind==="pick"?null:d.jsx(Jj,{item:q,n:H,onRemove:ve},q.key)})})}),$e=(q,H)=>{const ve=H===_,Se=x[H],ye=yS(Se,!!q.multi),J=ge=>({ref:ve?A:void 0,value:(Se==null?void 0:Se.note)??"",placeholder:ge,enterKeyHint:yl(m)===-1?"send":"next",onChange:Be=>z(Ff(x,H,Be),H),...yl(m)===-1?{onSend:W}:{}}),we=q.options.map(ge=>{const Be=!!(Se!=null&&Se.selected.includes(ge.value));return{label:d.jsxs(d.Fragment,{children:[ew(ge.label),l4(ge.label)&&d.jsx("span",{className:"badge-recommended",children:"recommended"})]}),description:ge.description,sample:ge.preview,hint:q.note&&!q.multi?{k:"n",label:"add a note",icon:"edit",on:(Se==null?void 0:Se.note)===void 0}:void 0,checked:Be,field:Be&&!ye&&(Se==null?void 0:Se.note)!==void 0?J("a note for the agent, sent with your pick"):void 0}});return q.note&&we.push({label:q.note.label,description:ye?void 0:"your own answer",checked:ye,field:ye?J("your own answer"):void 0}),d.jsxs("div",{className:He("card-page",!ve&&"card-page-off"),children:[d.jsx(yu,{children:q.text||f}),ve&&je,d.jsx(wu,{rows:we,cursor:ve?I:void 0,onCursor:ge=>{O(ge),rh(r)},onPick:ge=>{var Be;V(ge),(Be=r.current)==null||Be.focus()},onHint:$}),he(q,Se)]},q.id)};return d.jsxs(oh,{root:r,id:e.id,onKeyDown:se,onKeyUp:y.onPasteKeyUp,onPaste:y.onPaste,children:[m.length>1&&d.jsx("div",{className:"card-tabs",children:d.jsx(Lh,{label:"questions",owner:"ask",items:[...m.map((q,H)=>({id:String(H),label:q.header||`question ${H+1}`,lead:d.jsx("span",{className:He("dot card-step",Nl(x[H])&&"answered")})})),{id:String(m.length),label:"send",far:!0}],current:String(_),onPick:q=>{var H;ee(Number(q)),(H=r.current)==null||H.focus()}})}),d.jsxs("div",{className:"card-pages",children:[m.map($e),yl(m)!==-1&&d.jsxs("div",{className:He("card-page",!T&&"card-page-off"),children:[d.jsx(yu,{children:"Send these answers?"}),T&&je,d.jsx(wu,{hover:!0,rows:m.map((q,H)=>{const ve=Nl(x[H])?e4(q,x[H]):void 0;return{label:d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"row-dim",children:q.header||`question ${H+1}`})," ",d.jsx("span",{className:He(!ve&&"row-dim"),children:ve?ve.pick:"no answer yet"})]}),description:ve==null?void 0:ve.note}}),onPick:q=>{var H;ee(q),(H=r.current)==null||H.focus()}}),he()]})]})]})}const TH=rN("top"),jH=5*6e4;function o$({usage:e,limits:t,auth:n,now:r}){const o=t?f6(t,r):[],i=o.length?o6(n):void 0,a=t&&r-t.at>jH?aw(r-t.at):null,c=(e==null?void 0:e.cost)!==void 0?` · ${Au(e.cost)}`:"";return d.jsxs("div",{className:"usage-figures",children:[e&&d.jsx($1,{name:"context",used:e.used/e.size,sub:`${wx(e.used)} of ${wx(e.size)}${c}`}),i&&d.jsx("div",{className:"usage-who section-title",children:i}),o.map(u=>d.jsx($1,{name:u.name,used:u.used,sub:u.sub},u.key)),a&&d.jsxs("div",{className:"usage-stale hint",children:["read ",a," ago"]})]})}function $H({onClose:e,...t}){return d.jsx(Ls,{className:"usage-panel",anchor:"parent",placement:TH,onDismiss:e,onKey:n=>{n.key==="Escape"&&(n.stopPropagation(),e())},children:d.jsx(o$,{...t})})}function $1({name:e,used:t,sub:n}){const r=Math.max(0,Math.min(1,t));return d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"usage-row",children:[d.jsx("span",{className:"usage-name",children:e}),d.jsx("span",{className:"meter",children:d.jsx("span",{className:"meter-fill",style:{"--meter":r}})}),d.jsxs("span",{className:"usage-fig",children:[Math.round(100*t),"%"]})]}),d.jsx("div",{className:"usage-sub hint",children:n})]})}function s$(e,t,n){const r=S.useRef(n);r.current=n,ut([e,t,n==null?void 0:n.id],()=>{if(!e||!t)return;const o=()=>{const i=r.current;i!=null&&i.available&&e.send({t:"agent-check",agent:i.id})};return o(),window.addEventListener("focus",o),()=>window.removeEventListener("focus",o)})}const C1="not answering; send once Toyon is back",A1=[],CH=[],AH=new Set(["ArrowLeft","ArrowRight","Home","End","PageUp","PageDown"]),IH=150,RH=3,I1=e=>({kind:"cmd",c:e});function OH(e,t){var r;const n=e.after;return"id"in n?n.branch:((r=t.find(o=>o.proposalId===e.proposalId&&o.pieceId===n.piece))==null?void 0:r.title)??"another piece"}function MH(e,t,n,r){return e==="command"?r?n===0?d.jsx("span",{className:"live-text",children:"starting the agent to see what it offers"}):"no matching command":"no session has run this agent yet, so it has offered no commands":t?"no matches":d.jsx("span",{className:"live-text",children:"listing files"})}function PH(e){return e.kind==="cmd"?`/${e.c.name} `:e.kind==="folder"?`@${e.path}/ `:e.kind==="worktree"?`@${e.title} `:e.kind==="changes"?"@changes ":`@${e.path} `}function Yc({active:e,draft:t,archived:n,found:r,project:o,greenfield:i,placement:a="dock"}){var Xu,Qu,Ju,Jr,Ys,lc,cc;const c=a==="screen",u=lt(),h=tt(),{storage:f}=mo(),m=Un(),g=!!t,w=(e==null?void 0:e.worktree.id)??null,y=e==null?void 0:e.worktree.repoId,v=o?Ml:n?n.id:r?r.id:Kl(e),N=!!n||!!r,x=n?n.restorable:!!r&&!r.locked,_=It(v,"draft"),T=It(v,"attachments"),j=It(v,"notice"),C=((Xu=e==null?void 0:e.worktree.owns)==null?void 0:Xu.join(", "))??"",M=S.useRef({id:w,owns:C});ut([w,C],()=>{const D=M.current;M.current={id:w,owns:C},!(D.id!==w||D.owns===C||!C||!v||n)&&u({a:"notice",id:v,text:`Running its own ${C} here now: this branch changed it.`})});const I=It(v,"mark"),O=(I==null?void 0:I.by)==="walk"?I:void 0,A=It(w,"chat"),z=It(w,"queue"),B=S.useMemo(()=>w&&!g?Aw(A):null,[w,g,A]),U=It(w,"cardParked"),Q=It(w,"sending"),ae=S.useMemo(()=>w&&!g&&!Q?wS(A):null,[w,g,Q,A]),ee=It(w,"askRevived"),de=!B&&ae&&ee===ae.id?ae:null,$=B&&U!==B.id?B:de,K=de?Sl(de.id):null,V=It(K,"attachments"),X=B?U===B.id?B:null:ae&&!de?ae:null,W=S.useRef(null),se=Na(),ce=Sw(),he=It(ce,"page"),je=Tu(),$e=dz(),q=$j(),H=l7(),ve=fH(),Se=S.useMemo(()=>w&&!g?cH(A,{queued:z.length,sending:!!Q,card:!!($||X),dismissed:ve}):null,[w,g,A,z.length,Q,$,X,ve]),ye=D=>v&&u({a:"set-draft",id:v,text:D}),J=P(D=>D.clientId),we=P(D=>D.repos),ge=P(D=>D.repos.find(Pe=>Pe.id===(e==null?void 0:e.worktree.repoId))??null),Be=P(D=>D.defaultAgent),Ie=P(D=>D.agentChosen),We=g||!!i||!!o,pt=!We&&!!e&&!e.worktree.agent,rn=We||pt,qt=(t==null?void 0:t.agent)??Be,Ue=P(D=>D.agents.find(Pe=>Pe.id===(rn?qt:e==null?void 0:e.worktree.agent)));s$(h,w??(We?"new":null),Ue);const Qt=!!(Ue!=null&&Ue.quick),an=(Ue==null?void 0:Ue.models)??A1,Ft=(Ue==null?void 0:Ue.efforts)??A1,Qe=Ue==null?void 0:Ue.defaultModel,Wt=Ue==null?void 0:Ue.defaultEffort,[ln,wt]=N7(qt),[mt,Vt]=E7(qt),kn=P(D=>D.agents),Lt=(D,Pe)=>{if(D===qt){wt(Pe);return}T7(f,D,Pe),Pn(D)},Pn=D=>{g?u({a:"draft-agent",id:D}):h==null||h.send({t:"set-default-agent",agent:D})},_t=lH(Ue,kn,rn),yn=_t==null?void 0:_t.other,er=It(w,"model"),te=It(w,"effort"),me=It(w,"usage")??(e==null?void 0:e.usage),[Ge]=Mj(ge),ot=(t==null?void 0:t.profile)??Ge,[Dt,Ct]=S7(ge),mn=(e==null?void 0:e.worktree.mode)??Cf,L=P(D=>D.picking),re=P(D=>D.layout.term),be=_S((e==null?void 0:e.procs)??[]),Xe=wn("composer"),Nt=It(w,"files"),Ot=S.useMemo(()=>TS(Nt??CH),[Nt]),ze=P(D=>D.visible),Me=S.useMemo(()=>Qh(ze,y,w),[ze,y,w]),Ze=P(D=>y?D.archived[y]:void 0),Xt=S.useMemo(()=>RT(Me,Ze),[Me,Ze]),Bt=S.useMemo(()=>IT(Nt,Xt),[Nt,Xt]),vn=S.useMemo(()=>[...Me,...(Ze??[]).map(D=>({title:D.title,branch:D.branch,dir:D.path.slice(D.path.lastIndexOf("/")+1)}))],[Me,Ze]),Ut=It(w,"git"),cn=(Ut==null?void 0:Ut.files.length)??(e==null?void 0:e.dirty)??0,Yt=(Ut==null?void 0:Ut.unpushed)??(e==null?void 0:e.unpushed)??0,Kt=P(D=>{var Pe;return w?(Pe=D.shipping[w])==null?void 0:Pe.op:void 0}),Sn=P(D=>{var Pe;return w?(Pe=D.shipping[w])==null?void 0:Pe.step:void 0}),An=P(D=>Pl(D,y)),fr=P(D=>{var Pe;return An?(Pe=D.shipping[An.id])==null?void 0:Pe.op:void 0}),oe=An&&ge&&We?bS(ge.defaultBranch,An):null,Le=P(D=>g?v4(D.rows,y,qt,Be):w),Ve=It(Le,"commands"),jt=Ve.some(D=>D.name==="compact"),ft=zo(e==null?void 0:e.agent),bn=P(D=>OS(D,w)),jr=ft&&!!w&&!g,ir=e==null?void 0:e.worktree.lastTurn,Zt=!_.trim()&&T.length===0,Qr=!g&&!i&&Zt&&!ft?ir:void 0,dt=!g&&!i&&e&&ua(e.worktree)?e.worktree.landing:void 0,Hn=!!(dt!=null&&dt.ready)&&!dt.stale&&!nf(dt,cn,Qt,Ue==null?void 0:Ue.name),rt=Zt&&(!ft||Hn)?dt:void 0,_e=cn>0&&!!(rt!=null&&rt.subject),qe=cn||(((Qu=Ut==null?void 0:Ut.extras)==null?void 0:Qu.committed.length)??0),bt=!g&&!i&&Zt&&!ft&&!!e,it=!!(e!=null&&e.worktree.landed)&&cn===0,fn=bt&&it,Ht=e?fh({...e.worktree,landed:it}):void 0,un=bt&&!fn?Ht:void 0,Kr=!it&&(Ht==null?void 0:Ht.state)==="open"?Ht:void 0,In=!!Kr&&(cn>0||Yt>0),Wn=(Ht==null?void 0:Ht.state)==="closed",yr=vi((ge==null?void 0:ge.config)??{}),Kn=S.useMemo(()=>pH(Af(vi((ge==null?void 0:ge.config)??{}),ge==null?void 0:ge.defaultBranch)),[ge]),Y=()=>w&&(h==null?void 0:h.send({t:"chat",worktreeId:w,text:"/compact"})),pe=We?"nothing to compact until the first reply":jt?ft?"wait for the turn to end":void 0:"this agent offers no compact command",Je=jt&&me?i6(me.used/me.size):void 0,gt=Ue==null?void 0:Ue.limits,Tt=We?void 0:me,xn=(!!w||We)&&!!(Tt||gt),Zn=Date.now(),[ar,$r]=S.useState(!1),Gt=S.useRef(0),xt=se?()=>d.jsx(o$,{usage:Tt,limits:gt,auth:Ue==null?void 0:Ue.auth,now:Date.now()}):void 0,To=()=>{window.clearTimeout(Gt.current),$r(!1)};ut([w],To);const jn=_w(),Jt=(jn==null?void 0:jn.owner)==="composer"&&jn.key==="usage";ut([Jt],()=>{Jt&&To()});const Zr=()=>[{id:"compact",label:"compact the context",detail:pe||!me?void 0:s6(me.used/me.size),disabled:pe,onClick:Y}],[Or,Ne]=S.useState(0),[F,Z]=S.useState(null),[le,xe]=S.useState(null),Re=S.useRef(null),Te=v&&!N&&!o?Jm(_,Or,D=>Me.some(Pe=>h1(D,Pe))):null,$t=Te==null?void 0:Te.kind,on=Te==null?void 0:Te.query,tr=S.useMemo(()=>{if(on===void 0)return[];if($t==="command")return on.trim()?f9(gH(Kn,Ve),on).slice(0,8).map(I1):T1(Kn,Ve).rows.map(I1);const D=[],Pe=(Ut==null?void 0:Ut.files.length)??0;Pe>0&&"changes".startsWith(on.toLowerCase())&&D.push({kind:"changes",n:Pe});const ht=on.trim(),At=ht?Me.filter(rr=>h1(ht,rr)):Me.slice(0,RH);return D.push(...At.map(rr=>({kind:"worktree",...rr}))),D.push(...nH(Nt??[],Ot,(Ut==null?void 0:Ut.files)??[],on,8)),D},[$t,on,Nt,Ot,Ut,Ve,Kn,Me]),Rn=Te!==null&&Te.from!==F&&!O&&!(Te.kind==="file"&&u9(_,Te.from,Bt)),zs=$t==="command"&&on!==void 0&&!on.trim()?T1(Kn,Ve).more:0,En=S.useRef(null),Oi=S.useRef(null),$a=S.useRef(null),Mu=(D,Pe,ht,At)=>{var xs;const{text:rr,caret:On}=M_(_.slice(0,Pe)+_.slice(ht),Pe,At);ye(rr),Z(((xs=Jm(rr,On))==null?void 0:xs.from)??null),requestAnimationFrame(()=>{D.focus(),D.setSelectionRange(On,On),Ne(On)})},Fs=D=>{const Pe=En.current;return!D||!Pe?!1:(Mu(Pe,Pe.selectionStart,Pe.selectionEnd,D),!0)},{onPaste:Mi,onPasteKey:Bs,onPasteKeyUp:Ca}=X_(v,w,D=>Fs(wj(D,vn)));y3(Oi,En,D=>Fs(cU(D,vn)));const Aa=()=>{var D;return(D=W.current??En.current)==null?void 0:D.focus()},vs=Aa;ut([i?e==null?void 0:e.worktree.id:null],()=>{if(!i)return;const D=requestAnimationFrame(()=>{var ht;const Pe=document.activeElement;(!Pe||Pe===document.body)&&((ht=En.current)==null||ht.focus())});return()=>cancelAnimationFrame(D)});const Us=P(D=>D.focusChat),Pi=S.useRef(Us),Hs=!!w_();ut([Us],()=>{if(Us===Pi.current||(Pi.current=Us,Hs!==!!i))return;const D=requestAnimationFrame(Aa);return()=>cancelAnimationFrame(D)});const Li=$==null?void 0:$.id,Wo=S.useRef({id:w,cardUpId:Li});ut([w,Li],()=>{const D=Wo.current;if(Wo.current={id:w,cardUpId:Li},Li||!D.cardUpId||D.id!==w||Hs!==!!i||se&&!X)return;const Pe=requestAnimationFrame(()=>{var At;const ht=document.activeElement;(!ht||ht===document.body)&&((At=En.current)==null||At.focus())});return()=>cancelAnimationFrame(Pe)});const Ws=P(D=>D.walked),Di=S.useRef(Ws);ut([Ws],()=>{if(Ws===Di.current||(Di.current=Ws,Hs!==!!i))return;const D=requestAnimationFrame(()=>{const Pe=document.activeElement;(!Pe||Pe===document.body||Pe.closest(".rail"))&&Aa()});return()=>cancelAnimationFrame(D)});const Ia=aN({results:tr,keyOf:D=>D.kind==="cmd"?`c:${D.c.name}`:D.kind==="changes"?"changes":D.kind==="worktree"?`w:${D.id}`:`f:${D.path}`,q:(Te==null?void 0:Te.query)??"",listRef:Re,tabPicks:!0,onPick:D=>{if(!Te)return;const{text:Pe,caret:ht}=d9(_,Te,PH(D));ye(Pe),Z(Te.from),xe(D.kind==="cmd"&&D.c.hint?{name:D.c.name,hint:D.c.hint}:null),requestAnimationFrame(()=>{const At=En.current;At&&(At.focus(),At.setSelectionRange(ht,ht),Ne(ht))})}}),hr=w||N?$U(_):null,Ra=le&&_===`/${le.name} `?le.hint:null,Pu=hr===""&&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,Cr=Ra??Pu,as=(e==null?void 0:e.worktree.title)??"untitled",ls=(Ju=ir==null?void 0:ir.recap)==null?void 0:Ju.text,bs=()=>{w&&Ei(h,u,{t:"land",worktreeId:w})},Lu=D=>{w&&(h==null||h.send({t:"judge",worktreeId:w,...D?{note:D}:{}}))},Yl=!!((Jr=ge==null?void 0:ge.config.check)!=null&&Jr.trim()),zi=zw(dt,cn,Qt),Fi=bt&&!Kt&&!We&&ua(e.worktree)&&!it&&!Wn&&qe>0&&(!dt||!!dt.stale||zi==="unanswered"),Bi="Archive this worktree when you are done here; the rail's archived section brings it back with its chat.",Du=In?"update":Lk(yr,(e==null?void 0:e.worktree)??{}),zu=ge?dh(ge):"main",op=In&&Kr?`Commit, take ${zu} in and push the branch; PR #${Kr.number} takes the new commits.`:`${Af(yr,ge==null?void 0:ge.defaultBranch)}.`,Fu=un&&!ls?{links:$5(un)}:{},vr=w?fn?{word:"archive",kind:"archive",line:(Ht==null?void 0:Ht.state)==="merged"?As(Ht):`landed on ${(ge==null?void 0:ge.defaultBranch)??"main"}.`,tip:Bi,run:()=>$l(h,u,[w])}:(un==null?void 0:un.state)==="open"&&!In?CN(un)?{word:"land",kind:"merge",line:rf(ls??As(un)),tip:`${As(un)} Merge the PR now, by the method the repo allows.`,...Fu,run:bs,ships:!0}:{word:"view",kind:"view",line:rf(ls??As(un)),tip:`${As(un)} Open the PR on GitHub.`,...Fu,run:()=>window.open(un.url,"_blank")}:(un==null?void 0:un.state)==="closed"?{word:"archive",kind:"archive",line:As(un),tip:`${As(un)} ${Bi}`,run:()=>$l(h,u,[w])}:Fi?{word:"check",kind:"check",line:(dt==null?void 0:dt.subject)??rf(ls??O5(qe)),tip:AN(dt,Yl,zi),run:Lu}:rt!=null&&rt.ready&&!nf(rt,cn,Qt,Ue==null?void 0:Ue.name)?{word:Du,kind:"ship",line:rt.subject??rf(ls??(lx(rt,qe)||"ready")),tip:[lx(rt,qe),R5(zu,e==null?void 0:e.behind),op,rt.subject&&cn>0?"Tab from the word edits the message first.":""].filter(Boolean).join(" "),run:bs,ships:!0}:null:null,Bu=(Ys=e==null?void 0:e.worktree.lands)==null?void 0:Ys.at(-1),Uu=Bu&&Pw(Bu),Oa=S.useMemo(()=>{const D=A?D_(A):null;return(D?Gz(D):[]).filter(Pe=>{const ht=ze.find(At=>At.worktree.id===Pe.id);return!!ht&&!ht.worktree.landed})},[A,ze]),sp=Oa.length>0?d.jsxs(d.Fragment,{children:["After"," ",Oa.map((D,Pe)=>d.jsxs(S.Fragment,{children:[Pe>0&&(Pe===Oa.length-1?" and ":", "),d.jsx(Eo,{id:D.id,title:D.title})]},D.id))," ",Oa.length===1?"lands":"land","."]}):null,Xl=((vr==null?void 0:vr.kind)==="ship"||(vr==null?void 0:vr.kind)==="check")&&rt?sp??M5(rt,zi):(vr==null?void 0:vr.word)==="archive"&&Uu?ho(Uu):null,Ma=S.useRef(null);Kt!=="land"&&(Ma.current=w&&(vr!=null&&vr.ships)?{id:w,verb:vr,under:Xl}:null);const Pa=Kt==="land"&&Zt&&((lc=Ma.current)==null?void 0:lc.id)===w?Ma.current:null,Ln=Pa?Pa.verb:vr,Hu=(cc=Ln==null?void 0:Ln.links)!=null&&cc.length?C5(Ln.line,Ln.links):null,La=!!(Ln!=null&&Ln.ships)&&Kt==="land",Ui=yw(Sn,vw),Da=uu(e,"commit"),za=uu(e,"check"),Ks=RN(La?Da:za),Ql=xi(Bw(Ks)?Ks==null?void 0:Ks.since:void 0),Jl=rt?rt.check==="pending"&&za&&Ks===za?qf("Checking the work",za,Ql):nf(rt,cn,Qt,Ue==null?void 0:Ue.name):null,ec=Ln&&La?Ui?`${Ln.word}: ${Ui}`:`${Ln.word} ${Ln.line}`:null,Wu=ec&&Da&&Ks===Da?qf(ec,Da,Ql):ec,Ku=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?Ln?"":Jl||(un?As(un):Qr?Fw(Qr):i?`describe ${as}…`:We?"describe a change":c?`message agent on ${as}`:`message agent on ${as}; / for a command, ! for a shell command`):"no worktree selected",Fa=_!==""||Cr||!e?null:La?Ui?null:Pa?Pa.under:Xl:Ln?Xl:un||Jl?ls??(rt==null?void 0:rt.subject)??null:null,Zu=S.useRef(!1);S.useEffect(()=>{const D=Rn&&!Zu.current;Zu.current=Rn,D&&((Te==null?void 0:Te.kind)==="file"&&w?Oh(w,m.getState(),{sock:h,dispatch:u}):(Te==null?void 0:Te.kind)==="command"&&Le&&Ve.length===0&&(h==null||h.send({t:"list-commands",worktreeId:Le})))},[Rn,Te==null?void 0:Te.kind,Ve.length,w,Le,h,m,u]);const Ba=()=>{if(!e)return;const D=[],Pe=he;if(Pe.url)try{const rr=new URL(Pe.url);D.push(`current route: ${rr.pathname}${rr.search}`)}catch{}Pe.title&&D.push(`page title: ${Pe.title}`);const ht=[];i&&ht.push(h7(e.worktree.title,ge==null?void 0:ge.configFile)),D.length>0&&ht.push(`What the user is looking at right now:
|
|
246
|
+
${D.join(`
|
|
247
|
+
`)}`);const At=AU(A);return At&&ht.push(At),ht.length>0?ht:void 0},Zs=D=>{We?Ct(D):w&&D!==mn&&(h==null||h.send({t:"set-worktree-mode",worktreeId:w,mode:D}))},pr=D=>v&&u({a:"notice",id:v,text:D}),Hi=m_(),qu=(D,Pe="")=>{if(!e||!w)return;if(D==="split"){if(We)return pr("a new worktree has nothing to continue yet");const At=mH(Pe,we,e.worktree.repoId);"pick"in At?u({a:"open",overlay:{kind:"split",worktreeId:w}}):h==null||h.send({t:"pieces-ask",worktreeId:w,repoId:At.repo.id,...At.text?{text:At.text}:{}});return}if(D==="archive"){it||Wn?$l(h,u,[w]):pr("archive is for a landed worktree; this one has not landed");return}if(D==="check"){We||!ua(e.worktree)?pr("nothing to check from here"):ft?pr("wait for the turn to end"):qe===0?pr("nothing to check: no changes here"):Lu(Pe||void 0);return}const ht=dt?nf(dt,cn,Qt,Ue==null?void 0:Ue.name):null;We||!ua(e.worktree)?pr("nothing to land from here"):it?pr(`already landed on ${(ge==null?void 0:ge.defaultBranch)??"main"}`):ht?pr(ht):ft&&(!dt||dt.stale)?pr("wait for the turn to end"):dt!=null&&dt.stale?pr("the work changed since this was checked; check again first"):bs()},Wi=T.some(Ti),tc=()=>{var D;se&&((D=En.current)==null||D.blur())},qs=()=>{v&&(h==null||h.send({t:"set-draft",boxId:v,text:_,clientId:J})),tc()},jo=(D,Pe,ht,At)=>{u({a:"hold-send",id:D,log:Pe,text:ht,frame:At}),tc()},nc=()=>{if(!v)return;const D=kH(_,Kn),Pe=D&&hH(D.name)?D.name:void 0;if(o){if(o.busy)return;if(Hi)return pr(C1);if(o.why)return pr(o.why);(qt!==Be||!Ie)&&(h==null||h.send({t:"set-default-agent",agent:qt})),qs(),o.create();return}if(Zt)return;if(Hi&&!(Pe&&!(D!=null&&D.args)))return pr(C1);const ht=hr===null&&(!D||!!Pe&&!!D.args);if(_t&&_t.kind!=="unready"&&Ue&&ht){pr(_t.kind==="installing"?`${Ue.name} is still installing`:_t.retry?`nothing runs here until ${Ue.name} is installed`:_t.text);return}const At=Xx(_.trim(),Bt),rr=()=>({text:At,attachments:T.length?T.map(Tl):void 0});if(n){if(!n.restorable)return;if(hr!==null){pr("nothing runs here until it is restored");return}const eo={t:"restore-worktree",archiveId:n.id,clientId:J};if(Wi)return jo(v,v,At,eo);qs(),h==null||h.send(Fc(eo,v,At,T)),u({a:"sending",id:v,message:rr()}),u({a:"sent-box",id:v});return}if(r){if(r.locked)return;if(hr!==null){pr("nothing runs here until Toyon takes it over; its menu on the rail opens a shell");return}const eo={t:"adopt-worktree",worktreeId:r.id,clientId:J};if(Wi)return jo(v,v,At,eo);qs(),h==null||h.send(Fc(eo,v,At,T)),u({a:"sending",id:v,message:rr()}),u({a:"sent-box",id:v});return}if(!e||!w)return;if(hr!==null){if(hr&&Kt&&!g){pr(`${BA(Kt)} is running here; run the command once it is done`);return}hr&&g?u({a:"term-run",id:w,command:hr}):hr&&(h==null||h.send({t:"exec",worktreeId:w,command:hr})),ye("");return}if(D&&!Pe){qu(D.name,D.args),ye("");return}if(Pe&&!(D!=null&&D.args)){Zs(Pe),ye("");return}const On=D?Xx(D.args,Bt):At,xs=Ba(),Xs=T.length?T.map(Tl):void 0;if(Pe&&Zs(Pe),We){const eo=Eu(e.worktree)?{worktreeId:w}:{},ed={clientId:J,repoId:e.worktree.repoId,context:xs,agent:qt,profile:ot,mode:Pe??Dt,...ln?{model:ln}:{},...mt?{effort:mt}:{},...t!=null&&t.carry?{carry:!0}:{}};(qt!==Be||!Ie)&&(h==null||h.send({t:"set-default-agent",agent:qt}));const Ki={t:"create-worktree",...ed,...eo};Wi?jo(v,v,On,Ki):(qs(),h==null||h.send(Fc(Ki,v,On,T)),u({a:"sending",id:v,message:{text:On,attachments:Xs}}),u({a:"sent-box",id:v}))}else{pt&&(h==null||h.send({t:"set-worktree-model",worktreeId:w,model:ln}),h==null||h.send({t:"set-worktree-effort",worktreeId:w,effort:mt}));const eo={t:"chat",worktreeId:w,clientId:J,context:xs};Wi?jo(v,w,On,eo):(qs(),h==null||h.send(Fc(eo,v,On,T)),bn||u({a:"sending",id:w,message:{text:On,attachments:Xs}}),u({a:"sent-box",id:v}))}i&&u({a:"show-chat"})},ip=D=>{if(!w||(de==null?void 0:de.ask.kind)!=="question")return;if(!D.some(Nl))return u({a:"ask-revive",id:w});const Pe=Jk(de.ask.questions,D).join(`
|
|
248
|
+
`),ht={t:"chat",worktreeId:w,clientId:J,context:Ba()};if(K&&V.some(Ti))jo(K,w,Pe,ht);else{const At=V.length?V.map(Tl):void 0,rr=At&&K?{attachments:At,boxId:K}:{};h==null||h.send({...ht,text:Pe,...rr}),At&&K&&u({a:"clear-attachments",id:K}),u({a:"sending",id:w,message:{text:Pe,attachments:At}})}u({a:"answered",id:w}),u({a:"ask-revive",id:w})},rc=P(D=>D.autoSend);ut([rc,w],()=>{!rc||rc!==w||Zt||Hs!==!!i||(u({a:"auto-sent"}),nc())});const Gu=()=>{const D=T[T.length-1];return!v||!D?!1:(u({a:"detach",id:v,key:D.key}),!0)},oc=D=>{v&&(u({a:"walk",id:v,walk:D.walk,text:D.text}),requestAnimationFrame(()=>{var Pe;(Pe=En.current)==null||Pe.setSelectionRange(D.text.length,D.text.length),Ne(D.text.length)}))},Gs=()=>{v&&O&&u({a:"walk",id:v,walk:null,text:_})},Vs=We?[]:CS(A),Vu=We?[]:z.flatMap(D=>D.attachments??[]),Ko=e==null?void 0:e.worktree.plan,ap=ky(e==null?void 0:e.worktree.id,Ko),Ua=(e==null?void 0:e.worktree.queued)??[],Ha=jr&&!$,sc=P(D=>D.reading),[Wa,ic]=S.useState(!1),ac=c&&!X&&($?!Wa:Zt&&!$e),Yu=ac&≻S.useEffect(()=>{if(c)return u({a:"typing",on:Wa}),()=>u({a:"typing",on:!1})},[c,Wa,u]);const lp=D=>{if(!Yu||D.target instanceof Element&&D.target.closest("button, a, [role=button]"))return;const Pe=D.currentTarget.closest(".chat-log");Pe&&(Pe.scrollTop=Pe.scrollHeight)};return d.jsxs("div",{ref:Oi,className:He("composer chat-input",Ha&&"stopping",ac&&"foldable",Yu&&"lean"),onClick:lp,onFocus:D=>ic(D.target instanceof HTMLTextAreaElement),onBlur:()=>ic(!1),children:[Ko&&e&&d.jsxs("div",{className:"composer-plan",...Xe.contextMenu(()=>Kw(Ko,()=>h==null?void 0:h.send({t:"reveal",worktreeId:e.worktree.id,path:Ko}),Bo(h))),children:[d.jsx(St,{name:"text",className:"icon-inline"}),d.jsx(De,{variant:"inline",className:"composer-plan-path","data-tip":Ko,onClick:()=>Fn({dispatch:u},{worktreeId:e.worktree.id,path:Ko,view:"preview"}),children:ap})]}),X&&w&&d.jsx(Dc,{icon:"chat",verb:"answer",tip:"Bring the question back into the box",onPress:()=>{u(X.kind==="ask"&&X.outcome?{a:"ask-revive",id:w,askId:X.id}:{a:"card-unpark",id:w}),u({a:"focus-chat"})},children:Yz(X)}),(Se==null?void 0:Se.verb)==="fix"&&"toolId"in Se&&w&&d.jsxs(Dc,{icon:"run",verb:Se.verb,tip:"Send the agent what it printed and ask for a fix",onPress:()=>h==null?void 0:h.send({t:"fix",worktreeId:w,toolId:Se.toolId}),onDismiss:()=>N1(Se.key),children:["what failed in ",d.jsx("code",{children:Se.command})]}),(Se==null?void 0:Se.verb)==="continue"&&w&&d.jsx(Dc,{icon:"send",verb:Se.verb,tip:Se.after==="stop"?"Send the agent on from where its turn stopped":Se.again?"The last press ended in this same error. Send the agent on once more, or wait it out.":"Send the agent on from where its turn failed",onPress:()=>h==null?void 0:h.send({t:"continue",worktreeId:w}),onDismiss:()=>N1(Se.key),children:Se.after==="stop"?"where it stopped":Se.again?"after the same error again":"after the error"}),$e&&v&&!$&&(e||x||o)&&d.jsx(Dc,{icon:"copy",verb:"attach",tip:"Attach it, as a paste would",onPress:()=>{d3(m,v,$e),Aa()},onDismiss:y_,children:$e.kind==="image"?"the image you copied":`the text you copied, ${$e.text.split(`
|
|
249
|
+
`).length} lines`}),q&&w&&!g&&!$&&c7({prompt:q,offered:H,agent:e==null?void 0:e.agent,chat:A})&&d.jsx(Dc,{icon:"download",verb:"install",tip:"Install Toyon as an app: a window of its own, with a Dock icon and no browser bar",onPress:()=>{w1(),q.prompt()},onDismiss:w1,children:"Toyon as a window of its own, with a Dock icon and no browser bar"}),v&&!$&&hr===null&&d.jsx(Bh,{children:Ok(T,Kc(mg(Vs),Vu)).map(([D,Pe])=>{const ht=()=>u({a:"detach",id:v,key:D.key});return D.kind!=="pick"?d.jsx(Jj,{item:D,n:Pe,onRemove:ht},D.key):d.jsx(ep,{pick:D,tipText:D.html,onHover:At=>ce&&dn.post(ce,At?{type:"highlight-selector",selector:D.selector,label:iw(D)}:{type:"highlight-clear"}),worktreeId:w,onOpen:(At,rr)=>w&&wa(m,h,w,At,rr),onRemove:ht},D.key)})}),Rn&&Te&&d.jsx(d7,{results:tr,keyOf:D=>D.kind==="cmd"?`c:${D.c.name}`:D.kind==="changes"?"changes":D.kind==="worktree"?`w:${D.id}`:D.kind==="folder"?`d:${D.path}`:`f:${D.path}`,rowClass:D=>D.kind==="file"||D.kind==="folder"?"qo-file":D.kind==="changes"||D.kind==="worktree"?"picker-row":"picker-row picker-cmd",nav:Ia,listRef:Re,empty:MH(Te.kind,Nt,Ve.length,Le!==null),note:zs>0?`type to find ${zs} more`:void 0,groupOf:D=>D.kind==="worktree"?"worktrees":D.kind==="cmd"?"commands":"files",row:D=>{const Pe=((Ut==null?void 0:Ut.files.length)??0)>0;return D.kind==="file"?kk(D.path,D.status,Te.query,{gutter:Pe}):D.kind==="folder"?kk(D.path,void 0,Te.query,{folder:!0,gutter:Pe}):D.kind==="changes"?d.jsx(Cn,{label:"@changes",hint:`${D.n} uncommitted ${D.n===1?"file":"files"}`}):D.kind==="worktree"?d.jsxs(d.Fragment,{children:[d.jsx("span",{className:`dot ${D.dot}`}),d.jsx(Cn,{label:D.title,hint:sr(D.at)})]}):d.jsx(C7,{c:D.c,query:Te.query})}}),$&&w?$.kind==="pieces"?d.jsx(_H,{item:$,worktreeId:w,rootRef:W},$.id):$.ask.kind==="question"?d.jsx(NH,{item:$,ask:$.ask,worktreeId:w,rootRef:W,numbers:Kc(mg(Vs),Vu),onAnswer:de?ip:void 0},$.id):d.jsx(EH,{item:$,ask:$.ask,worktreeId:w,rootRef:W},$.id):d.jsxs("div",{className:He("composer-field",hr!==null&&"shell",O&&"recalled"),children:[d.jsx(cu,{size:"lg",bare:!0,font:hr!==null?"mono":"ui",ref:En,value:_,onChange:D=>{var On;const Pe=D.target.value,ht=D.target.selectionStart??Pe.length;ye(Pe),Ne(ht),Ia.setIndex(0);const{inputType:At}=D.nativeEvent;Z(At==="insertFromPaste"||At==="insertFromDrop"?((On=Jm(Pe,ht))==null?void 0:On.from)??null:null)},onKeyUp:D=>{Ca(),Ne(D.currentTarget.selectionStart??0)},onClick:D=>{Ne(D.currentTarget.selectionStart??0),Gs()},onPaste:Mi,onDrop:D=>{const Pe=vN(m,D);if(!Pe)return;D.stopPropagation();const ht=D.currentTarget,At=E5(ht,D.clientX,D.clientY)??_.length;Mu(ht,At,At,Pe.words)},onScroll:D=>{$a.current&&($a.current.scrollTop=D.currentTarget.scrollTop)},onKeyDown:D=>{var Pe;if(Bs(D),!D.nativeEvent.isComposing){if(Rn){if(D.key==="Escape"){D.preventDefault(),D.stopPropagation(),Z((Te==null?void 0:Te.from)??null);return}if(Ia.onKeyDown(D))return}if((D.key==="ArrowUp"||D.key==="ArrowDown")&&!D.altKey&&!D.ctrlKey){const ht=D.key==="ArrowUp",At=z.at(-1);if(ht&&!D.metaKey&&!O&&_===""&&w&&!g&&At!==void 0){D.preventDefault(),R_(m,h,w,z.length-1);return}const rr=D.metaKey?ht?"first":"box":ht?"up":"down",On=w?XU(A,O??null,_,rr):null;if(On){D.preventDefault(),(On.walk!==O||On.text!==_)&&oc(On);return}}if(O&&D.key==="Escape"){D.preventDefault(),D.stopPropagation(),oc({walk:null,text:O.from});return}if(D.key==="Escape"&&ft&&w&&!g){D.preventDefault(),D.stopPropagation(),h==null||h.send({t:"stop-agent",worktreeId:w});return}if(O&&AH.has(D.key)&&Gs(),D.key==="Tab"&&!D.shiftKey&&_===""){const ht=(Pe=D.currentTarget.closest(".composer"))==null?void 0:Pe.querySelector(".composer-verb");if(ht&&!ht.disabled){D.preventDefault(),ht.focus();return}if(_e){D.preventDefault(),u({a:"edit-commit"});return}}D.key==="Enter"&&(se?D.metaKey||D.ctrlKey:!D.shiftKey)?(D.preventDefault(),nc()):D.key==="Backspace"&&_===""&&Gu()&&D.preventDefault()}},placeholder:Fa||Ln?"":Ku,disabled:o?o.busy:!e&&!x}),Cr&&d.jsxs("div",{className:"composer-ghost","aria-hidden":"true",children:[d.jsx("span",{className:"picker-typed",children:_}),Cr]}),w&&hr===null&&_.includes("@")&&d.jsx("div",{ref:$a,className:"composer-ghost composer-marks","aria-hidden":"true",onClick:D=>py(D,e==null?void 0:e.worktree.path,w,{sock:h,dispatch:u}),children:d.jsx(hy,{text:_,worktreeId:w,root:e==null?void 0:e.worktree.path,inField:!0})}),(Fa||Ln)&&d.jsxs("div",{className:"composer-ghost composer-standing","aria-hidden":Ln?void 0:"true",children:[d.jsx("span",{className:He("composer-placeholder",La&&"live-text"),children:Wu||(Ln?d.jsxs(d.Fragment,{children:[d.jsx(De,{variant:"inline",tone:"strong",className:"composer-verb",disabled:!!Ln.ships&&!!Kt||Hi,...Pt(Ln.tip,void 0,{placement:"top"}),onClick:()=>{var D;Ln.run(),se||(D=En.current)==null||D.focus()},onKeyDown:D=>{D.key==="Tab"&&!D.shiftKey&&_e&&(D.preventDefault(),u({a:"edit-commit"}))},children:Ln.word})," ",d.jsx("span",{className:"composer-verb-line",children:Hu?Hu.map(D=>typeof D=="string"?D:d.jsxs(De,{variant:"inline",className:"composer-verb-tail",...Pt(D.tip,void 0,{placement:"top"}),onClick:()=>{var Pe;window.open(D.url,"_blank"),se||(Pe=En.current)==null||Pe.focus()},...Xe.contextMenu(()=>[{id:"open-link",label:D.open,onClick:()=>window.open(D.url,"_blank")},{id:"copy-link",label:"copy link",onClick:()=>tn(D.url)}]),children:[D.text," ",d.jsx(St,{name:"external",className:"icon-inline"})]},D.text)):Ln.line})]}):Ku)}),Fa&&d.jsxs(d.Fragment,{children:[`
|
|
250
|
+
`,d.jsx("span",{className:"composer-subline",children:Fa})]})]}),Ha&&d.jsx(Rt,{icon:"stop",tone:"danger",className:He("composer-stop",(e==null?void 0:e.stopping)&&"pending"),label:e!=null&&e.stopping?"Stopping: the agent is winding down; press again to send the stop once more":`Stop the agent (context up to here is kept${z.length?"; queued messages go next":""})`,hint:"esc",onClick:()=>w&&(h==null?void 0:h.send({t:"stop-agent",worktreeId:w}))})]}),j&&d.jsx("div",{className:"hint composer-notice",role:"status",children:j}),!$&&d.jsxs("div",{className:"hint composer-knobs",children:[d.jsxs("span",{className:"spawn-left",children:[rn?kn.length>1?d.jsx(j7,{agents:kn,agent:qt,model:ln,onChange:Lt,onClose:vs}):d.jsx(x1,{models:an,value:ln,runs:Qe,onChange:wt,onClose:vs}):e&&d.jsx(x1,{models:an,value:e.worktree.model??"",current:er,runs:Qe,onChange:D=>h==null?void 0:h.send({t:"set-worktree-model",worktreeId:e.worktree.id,model:D}),onClose:vs}),rn?d.jsx(v1,{efforts:Ft,value:mt,runs:Wt,onChange:Vt,onClose:vs}):e&&d.jsx(v1,{efforts:Ft,value:e.worktree.effort??"",current:te,runs:Wt,onChange:D=>h==null?void 0:h.send({t:"set-worktree-effort",worktreeId:e.worktree.id,effort:D}),onClose:vs}),We?!o&&d.jsx(b1,{value:Dt,onChange:Ct,onClose:vs}):e&&d.jsx(b1,{value:mn,onChange:D=>h==null?void 0:h.send({t:"set-worktree-mode",worktreeId:e.worktree.id,mode:D}),onClose:vs}),xn&&d.jsxs("span",{className:"usage-knob",onMouseEnter:()=>{Jt||(window.clearTimeout(Gt.current),Gt.current=window.setTimeout(()=>$r(!0),IH))},onMouseLeave:()=>{window.clearTimeout(Gt.current),$r(!1)},onFocus:D=>{Jt||!D.target.matches(":focus-visible")||(window.clearTimeout(Gt.current),$r(!0))},onBlur:To,children:[d.jsx(Rt,{icon:d.jsx(f7,{fraction:Tt?Tt.used/Tt.size:0,level:gt?c6(gt,Zn):void 0}),tone:"chrome",on:Jt,silent:!0,label:Tt?`${Math.round(100*Tt.used/Tt.size)}% of context`:gt?yx(gt,Zn):"",detail:[...Tt&>?[yx(gt,Zn)]:[],...Je?[Je]:[]],...Xe.dropdown(Zr,"left","usage",xt),...Xe.contextMenu(Zr,"usage")}),ar&&d.jsx($H,{usage:Tt,limits:gt,auth:Ue==null?void 0:Ue.auth,now:Zn,onClose:To})]})]}),d.jsxs("span",{className:"spawn-tools",children:[v&&(e||x||o)&&d.jsx(Rt,{icon:"attach",tone:"chrome",label:c?"Attach a picture or a file":"Attach a picture or a file, or drop one here",onClick:()=>q_(m,v)}),!i&&!N&&!c&&!o&&d.jsx(Rt,{icon:"terminal",tone:"chrome",on:re,className:"composer-term",disabled:!e,label:be?be.tip:"Terminal",hint:zt("terminal"),badge:be&&d.jsx("span",{className:"composer-term-dot"}),onClick:()=>{u(be&&!re&&w?{a:"term-stream",id:w,stream:be.stream}:{a:"toggle-terminal"})},...Xe.contextMenu(()=>e&&w?X8(e.procs,w,re,{sock:h,dispatch:m.dispatch}):[])}),!i&&!je&&!N&&!c&&!o&&d.jsx(Rt,{icon:"pick",label:"Pick an element on the page to attach",hint:zt("pick"),on:L==="chat",disabled:!ce,onClick:()=>ce&&au(ce,L,u,"chat")}),se&&v&&(e||x||o)&&d.jsx(Rt,{icon:"send",tone:"primary",label:o?"Create the project":"Send",disabled:Hi||(o?o.busy:Zt),onMouseDown:D=>D.preventDefault(),onClick:nc})]})]}),(_t||oe&&An||Ua.length>0)&&d.jsxs("div",{className:"composer-notes",children:[Ua.map(D=>d.jsx("div",{className:"hint composer-note",children:d.jsxs("span",{children:[D.title," starts when"," ","id"in D.after?D.after.id===(e==null?void 0:e.worktree.id)?"this branch":d.jsx(Eo,{id:D.after.id,title:D.after.branch}):OH(D,Ua)," ","lands"]})},`${D.proposalId}/${D.pieceId}`)),_t&&Ue&&d.jsxs("div",{className:"hint composer-note",role:"status",children:[d.jsx("span",{children:_t.text}),(_t.retry||yn)&&d.jsxs("span",{className:"composer-note-actions",children:[_t.retry&&d.jsx(De,{variant:"outline",onClick:()=>h==null?void 0:h.send({t:"install-agent",agent:Ue.id}),children:_t.retry}),yn&&d.jsxs(De,{variant:"outline","data-tip":`${yn.name} is installed and takes this message instead`,onClick:()=>Pn(yn.id),children:["use ",yn.name]})]})]}),oe&&An&&d.jsxs("div",{className:"hint composer-note",children:[d.jsx("span",{children:oe}),d4(An)&&d.jsx(De,{variant:"outline",busy:fr==="pull-main",disabled:!!fr,"data-tip":"Fast-forward main to origin",onClick:()=>Ei(h,u,{t:"pull-main",worktreeId:An.id}),children:"pull"})]})]})]})}function i$({children:e,className:t,tip:n,...r}){return d.jsxs("label",{className:He("check",t),"data-tip":n,children:[d.jsx("input",{type:"checkbox",className:"check-box",...r}),d.jsx("span",{children:e})]})}function LH({draft:e,lead:t}){const n=lt(),r=P(u=>Ii(u,t==null?void 0:t.repoId)),[o]=Mj(r),i=e.profile??o,a=P(u=>{var h;return((h=Pl(u,t==null?void 0:t.repoId))==null?void 0:h.dirty)??0}),c=!!t&&!!r&&a>0;return!i&&!c?null:d.jsxs("div",{className:"draft-intro",children:[i&&d.jsx("div",{className:"draft-row hint",children:d.jsx($7,{repo:r,value:i,onChange:u=>n({a:"draft-profile",profile:u})})}),c&&d.jsx("div",{className:"draft-notes",children:d.jsxs(i$,{className:"hint draft-note",checked:!!e.carry,tip:`Move the ${a} uncommitted ${a===1?"file":"files"} into the new worktree, leaving ${r.defaultBranch} clean`,onChange:u=>n({a:"draft-carry",v:u.currentTarget.checked}),children:[d.jsxs("span",{className:"badge-dirty",children:["~",a]})," on ",r.defaultBranch," come along"]})})]})}function DH({row:e}){const t=tt(),n=P(a=>a.clientId),r=P(a=>a.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(Rr,{icon:e.locked?"lock":"branch",word:e.locked?"held":"discovered",tone:"quiet",below:i,children:[d.jsxs("span",{className:"daemon-text",children:[e.locked&&`by ${e.lockReason??"another tool"}, at `,d.jsx("span",{className:"tool-hint",children:o})]}),!e.locked&&d.jsx(De,{variant:"inline",tone:"strong",onClick:()=>t==null?void 0:t.send({t:"adopt-worktree",worktreeId:e.id,clientId:n}),children:"take over"})]})}function Xc({placement:e,className:t,width:n,archived:r,found:o}){const i=lt(),a=Ps(),c=ez(),u=It(a==null?void 0:a.worktree.id,"sending"),h=ql(),f=e==="centre"&&!r&&(h!=null&&h.assumed)?h:null,m=P(v=>{var N;return((N=v.dragFiles)==null?void 0:N.at)==="chat"}),g=Un(),w=S.useMemo(()=>({onDragOver:v=>x5(g,v),onDrop:v=>{const N=vN(g,v);N&&P_(g,N.boxId,N.words)}}),[g]),y=d.jsxs(d.Fragment,{children:[!r&&!o&&c&&!u&&d.jsx(LH,{draft:c,lead:a}),r?d.jsx(Yc,{active:null,archived:r,placement:e}):o?d.jsx(Yc,{active:null,found:o,placement:e}):d.jsx(Yc,{active:a,draft:c,placement:e})]});return d.jsx("div",{className:He(e==="dock"?"chat-dock":e==="centre"?"chat-centre":"chat-screen",t,m&&"drop-over"),style:n===void 0?void 0:{width:n},...w,ref:v=>{var N;v?Gc.el=v:(N=Gc.el)!=null&&N.isConnected||(Gc.el=null)},children:r?d.jsx(og,{active:null,archived:r,tail:d.jsx(m6,{item:r}),foot:y}):o?d.jsx(og,{active:null,found:o,tail:d.jsx(DH,{row:o}),foot:y}):d.jsx(og,{active:a,lead:f&&d.jsxs("p",{className:"hint chat-centre-note",children:[f.name," has ",d.jsx("code",{children:f.assumed})," and no dev server, so it is chat only for now."," ",d.jsx(De,{variant:"inline",onClick:()=>i({a:"open",overlay:{kind:"setup",repoId:f.id}}),children:"add a dev server"})]}),foot:y})})}const zH="modulepreload",FH=function(e){return"/"+e},R1={},bk=function(t,n,r){let o=Promise.resolve();if(n&&n.length>0){let a=function(h){return Promise.all(h.map(f=>Promise.resolve(f).then(m=>({status:"fulfilled",value:m}),m=>({status:"rejected",reason:m}))))};document.getElementsByTagName("link");const c=document.querySelector("meta[property=csp-nonce]"),u=(c==null?void 0:c.nonce)||(c==null?void 0:c.getAttribute("nonce"));o=a(n.map(h=>{if(h=FH(h),h in R1)return;R1[h]=!0;const f=h.endsWith(".css"),m=f?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${h}"]${m}`))return;const g=document.createElement("link");if(g.rel=f?"stylesheet":zH,f||(g.as="script"),g.crossOrigin="",g.href=h,u&&g.setAttribute("nonce",u),document.head.appendChild(g),f)return new Promise((w,y)=>{g.addEventListener("load",w),g.addEventListener("error",()=>y(Error(`Unable to preload CSS for ${h}`)))})}))}function i(a){const c=new Event("vite:preloadError",{cancelable:!0});if(c.payload=a,window.dispatchEvent(c),!c.defaultPrevented)throw a}return o.then(a=>{for(const c of a||[])c.status==="rejected"&&i(c.reason);return t().catch(i)})},Ey=800;function BH(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 Xo=e=>`${e.worktreeId}
|
|
251
|
+
${e.ref??""}
|
|
252
|
+
${e.since??""}
|
|
253
|
+
${e.path}`;class UH{constructor(t){Et(this,"files",new Map);Et(this,"looks",new Map);this.d=t}start(){var i,a;let t=this.d.store.getState();const n=this.d.store.subscribe(()=>{const c=this.d.store.getState(),u=t;t=c,this.follow(u,c)}),r=()=>{const c=this.d.store.getState().editor;c&&!c.loose&&this.refresh(Xo(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(a=this.d.win)==null||a.addEventListener("pagehide",o),()=>{var c,u;n(),(c=this.d.win)==null||c.removeEventListener("focus",r),(u=this.d.win)==null||u.removeEventListener("pagehide",o)}}receive(t){const n=t.t==="file-read"?this.looks.get(t.seq):void 0;if(n&&t.t==="file-read"){this.looks.delete(t.seq),n(t.error||t.binary||t.tooLarge||t.version===null?null:t.after);return}const r=this.files.get(Xo(t));if(!r)return;if(t.t==="file-blame"){this.blamed(r,t);return}const o=r.out;!o||o.seq!==t.seq||(r.out=null,t.t==="file-read"?this.read(r,t):o.write!==void 0&&this.written(r,o.write,t),this.next(r))}look(t,n){if(!this.d.store.getState().connected)return Promise.resolve(null);const r=Lo();return new Promise(o=>{this.looks.set(r,o),this.d.send({t:"read-file",worktreeId:t,path:n,seq:r})})}bind(t){const n=Xo(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(Xo(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(Xo(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,a,c,u;t.connected&&!n.connected&&this.dropped();const r=(i=n.editor)!=null&&i.loose?null:n.editor,o=(a=t.editor)!=null&&a.loose?null:t.editor;if(o&&(!r||Xo(o)!==Xo(r))&&this.closed(Xo(o)),r&&(!o||o.seq!==r.seq)&&this.opened(r),!t.connected&&n.connected)for(const h of this.files.values())h.reread=!0,this.next(h);else r&&o&&o.seq===r.seq&&((c=Xr(t,r.worktreeId).git)==null?void 0:c.version)!==((u=Xr(n,r.worktreeId).git)==null?void 0:u.version)&&this.refresh(Xo(r))}opened(t){const n=Xo(t);let r=this.files.get(n);r||(r={file:{worktreeId:t.worktreeId,path:t.path,...t.ref?{ref:t.ref}:{},...t.since?{since:t.since}:{}},open:!0,base:null,out:null,pending:null,reread:!1,writable:!1,conflict:null,buffer:null,timer:void 0,blame:null},this.files.set(n,r)),r.open=!0,r.reread=!0,r.conflict&&this.d.store.dispatch({a:"editor-conflict",file:r.file,theirs:r.conflict}),this.next(r)}closed(t){const n=this.files.get(t);n&&(n.open=!1,this.next(n))}refresh(t){const n=this.files.get(t);!n||n.file.ref||(n.reread=!0,this.next(n))}dropped(){for(const t of this.looks.values())t(null);this.looks.clear();for(const t of this.files.values())t.out&&(t.out.write!==void 0&&(t.pending??(t.pending=t.out.write)),t.out=null,t.reread=!0)}next(t){var a;if(t.out||!this.d.store.getState().connected)return;const{worktreeId:n,path:r,ref:o,since:i}=t.file;if(t.reread){t.reread=!1;const c=Lo();t.out={seq:c},this.d.send({t:"read-file",worktreeId:n,path:r,ref:o,since:i,seq:c});return}if(t.pending!==null&&t.base&&t.pending===t.base.text&&(t.pending=null),t.pending!==null&&t.writable&&!t.conflict&&!o){const c=t.pending,u=Lo();t.pending=null,t.out={seq:u,write:c},this.d.send({t:"write-file",worktreeId:n,path:r,content:c,base:((a=t.base)==null?void 0:a.version)??null,seq:u});return}!t.open&&!t.buffer&&t.pending===null&&!t.conflict&&this.files.delete(Xo(t.file))}read(t,n){var g,w;const{file:r}=t;if(n.error){t.open&&this.d.store.dispatch({a:"editor-read",file:r,disk:null,error:n.error});return}const{before:o,after:i,version:a,writable:c,binary:u,tooLarge:h}=n;t.writable=c,t.open&&(this.d.store.dispatch({a:"editor-read",file:r,disk:{before:o,after:i,version:a,writable:c,binary:u,tooLarge:h}}),!u&&!h&&(a!==null||r.ref)&&this.askBlame(t,a));const f={after:t.buffer?t.buffer.normalize(i):i,version:a};if(!t.base){t.base={text:f.after,version:a};return}const m=((g=t.buffer)==null?void 0:g.text())??t.pending??t.base.text;switch(BH(t.base,m,t.pending,f)){case"same":break;case"adopt":t.base={text:f.after,version:a};break;case"apply":(w=t.buffer)==null||w.replace(f.after),t.base={text:f.after,version:a};break;case"gone":t.base={text:"",version:null},t.open&&this.d.store.dispatch({a:"close-editor"});break;case"conflict":this.setConflict(t,f);return}this.setConflict(t,null)}askBlame(t,n){const r=Lo();t.blame={seq:r,version:n};const{worktreeId:o,path:i,ref:a}=t.file;this.d.send({t:"blame-file",worktreeId:o,path:i,ref:a,seq:r})}blamed(t,n){const r=t.blame;if(!r||r.seq!==n.seq||(t.blame=null,!t.open))return;const{commits:o,lines: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)},Ey))}saveNow(t){const n=this.files.get(t);if(!(n!=null&&n.buffer))return;this.cancelTimer(n);const r=n.buffer.text();r.length>Lf||(n.pending=r,this.next(n))}cancelTimer(t){t.timer!==void 0&&(this.d.timers.clear(t.timer),t.timer=void 0)}}const a$={attach:()=>{},edited:()=>{},saveNow:()=>{}},HH=e=>({timers:{set:(t,n)=>setTimeout(t,n),clear:t=>clearTimeout(t)},win:typeof window>"u"?null:window,send:e}),xk=new Map;function WH(e){const t=xk.get(e.seq);return t?(xk.delete(e.seq),t(e),!0):!1}function KH(e,t,n,r){if(e.kind==="bytes"||e.kind==="text")return a$;if(e.kind==="grant")return ZH(e,t,n,r);const o=e.handle;let i=null,a,c=null,u=Promise.resolve(),h=!1;const f=()=>(c??(c=(async()=>await o.queryPermission({mode:"readwrite"})==="granted"?!0:await o.requestPermission({mode:"readwrite"})==="granted")().catch(()=>!1)),c),m=()=>{a!==void 0&&r.timers.clear(a),a=void 0},g=()=>{h||(h=!0,m(),n(`read-only: the browser would not save ${t}`))},w=async N=>{if(!await f())return g();const x=await o.createWritable();await x.write(N),await x.close()},y=()=>{if(!i||h)return;m();const N=i.text();u=u.then(()=>w(N)).catch(g)},v=()=>{a!==void 0&&y()};return{attach(N){var x,_;if(N){i=N,(x=r.win)==null||x.addEventListener("pagehide",v);return}a!==void 0&&y(),i=null,(_=r.win)==null||_.removeEventListener("pagehide",v)},edited(){!i||h||(f().then(N=>{N||g()}),m(),a=r.timers.set(y,Ey))},saveNow:y}}function ZH(e,t,n,r){let o=null,i,a=e.version,c=!1,u=null,h=!1;const f=()=>{i!==void 0&&r.timers.clear(i),i=void 0},m=v=>{h||(h=!0,f(),u=null,n(v))},g=v=>{if(!r.send)return;const N=Lo();c=!0,xk.set(N,x=>{if(c=!1,x.ok?a=x.version:x.reason==="changed"?m(`read-only: ${t} changed on disk; open it again to edit`):m(x.message??`not saved: ${t}`),u!==null&&!h){const _=u;u=null,g(_)}}),r.send({t:"write-loose",id:e.id,content:v,base:a,seq:N})},w=()=>{if(!o||h)return;f();const v=o.text();v.length>Lf||(c?u=v:g(v))},y=()=>{i!==void 0&&w()};return{attach(v){var N,x;if(v){o=v,(N=r.win)==null||N.addEventListener("pagehide",y);return}i!==void 0&&w(),o=null,(x=r.win)==null||x.removeEventListener("pagehide",y)},edited(){!o||h||(f(),i=r.timers.set(w,Ey))},saveNow:w}}function Sy({kind:e,className:t,height:n,resizable:r=!0,onDragStart:o,title:i,tabs:a,actions:c,menu:u,full:h,onToggleFull:f,onClose:m,closeHint:g="esc",children:w}){const y=wn("pane"),v=f&&d.jsxs(De,{variant:"outline",tone:"quiet",mono:!0,className:"deep-link",onClick:f,"data-tip":h?"Split view: show the preview above":"Full height: hide the preview",children:[d.jsx(St,{name:h?"split":"full",className:"icon-inline"})," ",h?"split":"full"]}),N=d.jsxs("span",{className:"pane-shape",children:[v,d.jsx(Rt,{icon:"close",label:"Close",hint:g,onClick:m})]});return d.jsxs("div",{className:`pane ${t}`,"data-pane":e,tabIndex:-1,style:n===void 0?void 0:{height:n},children:[r&&d.jsx("div",{className:"pane-resize",onPointerDown:o}),d.jsx("div",{className:He("pane-head",a&&"pane-head-tabs"),...y.contextMenu(()=>(u==null?void 0:u())??[]),children:a?d.jsx(Lh,{...a,end:d.jsxs(d.Fragment,{children:[c,N]})}):d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"pane-title",children:i}),c,N]})}),w]})}function qH({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(()=>du(e,{open:()=>r(!0)})),children:d.jsx("img",{src:e,alt:t})}),n&&d.jsx(Zw,{owner:"editor",onClose:()=>r(!1),menu:()=>du(e),children:d.jsx("img",{src:e,alt:t})})]})}const GH={image:qH};function VH({kind:e,src:t,path:n,openSeq:r,focus:o,full:i,onFull:a}){const c=S.useRef(null);ut([r],()=>{var h;o&&((h=c.current)==null||h.focus())});const u=GH[e];return d.jsx("div",{ref:c,className:"editor-viewer",tabIndex:-1,children:d.jsx(u,{src:t,path:n,full:i,onFull:a})})}const YH="img[src], source[src], video[src], audio[src], video[poster], link[href], object[data]";function XH(e,t){if(!t)return e;const n=new DOMParser().parseFromString(e,"text/html");let r=!1;for(const o of n.querySelectorAll(YH))for(const i of["src","href","poster","data"]){const a=o.getAttribute(i),c=a===null?null:qw(t.dir,a);c&&(o.setAttribute(i,t.urls.worktreeFile(t.worktreeId,c,t.version)),r=!0)}return r?`${n.doctype?`<!doctype html>
|
|
254
|
+
`:""}${n.documentElement.outerHTML}`:e}function QH({text:e,path:t,worktreeId:n,version:r,openSeq:o,focus:i}){const a=S.useRef(null);ut([o],()=>{var f;i&&((f=a.current)==null||f.focus())});const c=Wr(),u=nT(t),h=S.useMemo(()=>XH(e,r===void 0?null:{worktreeId:n,dir:u,version:r,urls:c}),[e,n,u,r,c]);return d.jsx("div",{ref:a,className:"editor-viewer",tabIndex:-1,children:d.jsx("iframe",{className:"editor-frame",title:t,sandbox:"",srcDoc:h})})}function JH(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 eW(e){const t=new Map,n=Array.from(e.querySelectorAll("h1, h2, h3, h4, h5, h6")),r=JH(n.map(o=>Number(o.tagName[1])));return n.map((o,i)=>{var u;const a=((u=o.textContent)==null?void 0:u.trim())??"",c=t.get(a)??0;return t.set(a,c+1),{id:`${c}
|
|
255
|
+
${a}`,level:Number(o.tagName[1]),depth:r[i],text:a,el:o}})}const tW=48,nW=16;function l$({html:e,openSeq:t=0,focus:n=!0,onLink:r,onChat:o,lead:i}){const a=S.useRef(null),c=S.useRef(null),[u,h]=S.useState([]),[f,m]=S.useState(-1),[g,w]=S.useState(null),y=_=>{var T;if(w(null),_){const j=window.getSelection();j==null||j.removeAllRanges(),j==null||j.addRange(_)}(T=a.current)==null||T.focus()};ut([t],()=>{var _;n&&((_=a.current)==null||_.focus())}),ut([e],()=>{h(c.current?eW(c.current):[])}),S.useLayoutEffect(()=>{const _=a.current;if(!_)return;let T=0;const j=()=>{if(T=0,_.scrollTop+_.clientHeight>=_.scrollHeight-1){m(u.length-1);return}const M=_.scrollTop+tW;let I=-1;for(let O=0;O<u.length;O++)u[O].el.offsetTop<=M&&(I=O);m(I)},C=()=>{T||(T=requestAnimationFrame(j))};return j(),_.addEventListener("scroll",C),()=>{_.removeEventListener("scroll",C),T&&cancelAnimationFrame(T)}},[u]);const v=_=>{var j,C;const T=(j=u[_])==null?void 0:j.el;(C=a.current)==null||C.scrollTo({top:Math.max(0,T?T.offsetTop-nW:0),behavior:"smooth"})},N=_=>{const T=_.target.closest("a"),j=T==null?void 0:T.getAttribute("href");!j||(T==null?void 0:T.target)==="_blank"||(_.preventDefault(),r==null||r(j))},x=_=>{var T;if(Hw(_)){_.preventDefault(),_.stopPropagation();const j=(c.current&&Yg(c.current))??"";w(C=>({seed:j||(C==null?void 0:C.seed)||"",seq:((C==null?void 0:C.seq)??0)+1}));return}if(_.key==="Escape"&&g){_.stopPropagation(),y(null);return}if(GN(_)&&c.current){_.preventDefault(),YN(c.current);return}if(o&&((T=uE(_))==null?void 0:T.id)==="composer"&&c.current){const j=Yg(c.current);if(!j)return;_.preventDefault(),_.stopPropagation(),o(j)}};return d.jsxs(d.Fragment,{children:[d.jsxs("div",{ref:a,className:"document",tabIndex:-1,onClick:N,onKeyDown:x,children:[i,d.jsx("div",{ref:c,className:"md md-preview",dangerouslySetInnerHTML:{__html:e}})]}),g&&d.jsx(qN,{root:a,body:c,seed:g.seed,seq:g.seq,onClose:y}),d.jsx(rW,{heads:u,at:f,onJump:v})]})}function rW({heads:e,at:t,onJump:n}){const[r,o]=S.useState(!1),i=S.useRef(null);return e.length<2?null:d.jsxs(d.Fragment,{children:[d.jsx("div",{ref:i,className:"document-outline","aria-hidden":!0,onPointerEnter:a=>{a.pointerType==="mouse"&&o(!0)},onClick:()=>o(a=>!a),children:e.map((a,c)=>d.jsx("span",{className:"document-outline-tick","data-level":a.level,"data-state":ur({current:c===t})},a.id))}),r&&d.jsx(Ls,{className:"document-outline-list",anchor:()=>{var a;return((a=i.current)==null?void 0:a.getBoundingClientRect())??null},placement:{side:"right",align:"center",cover:!0},trigger:i.current,onDismiss:()=>o(!1),onPointerLeave:a=>{a.pointerType==="mouse"&&o(!1)},children:e.map((a,c)=>d.jsx("button",{type:"button",className:"row document-outline-row","data-level":a.level,"data-state":ur({current:c===t}),onClick:()=>n(c),children:d.jsx("span",{className:"document-outline-label",style:{"--outline-depth":a.depth},children:a.text})},a.id))})]})}function c$({text:e,path:t,worktreeId:n,version:r,openSeq:o,focus:i,onChat:a,lead:c}){tt();const u=Wr(),h=lt(),f=nT(t),m=Gh(e,{keepHtml:!0,base:r===void 0?void 0:{worktreeId:n,dir:f,version:r,urls:u}}),g=w=>{const y=qw(f,w);y&&Fn({dispatch:h},{worktreeId:n,path:y,view:ji(y)})};return d.jsx(l$,{html:m,openSeq:o,focus:i,onLink:g,onChat:a,lead:c})}function oW({refs:e,worktreeId:t}){const n=Wr();return e.length===0?null:d.jsx("div",{className:"editor-piece-chips",children:e.map(r=>r.kind==="image"?d.jsx(Jh,{className:"in-chat",src:n.attachment(t,r.file),n:r.n,name:r.name,width:r.width,height:r.height,bytes:r.bytes},`image-${r.n}`):r.kind==="file"?d.jsx(Yh,{className:"in-chat",name:r.name,bytes:r.bytes,href:r.text?n.attachment(t,r.file):void 0},`file-${r.n}`):r.kind==="paste"?d.jsx(Vh,{className:"in-chat",n:r.n,name:r.name,source:r.source,lines:r.lines,chars:r.chars,preview:r.preview,href:n.attachment(t,r.file)},`paste-${r.n}`):d.jsx(ep,{className:"in-chat",pick:r,worktreeId:t},`pick-${r.n}`))})}function u$(e){const t="repoName"in e&&e.repoName?` in ${e.repoName}`:"";switch(e.kind){case"starting":return"Starting.";case"failed":return`Could not start: ${e.error}`;case"here":return"This worktree's agent does it.";case"skipped":return"Skipped: nothing happened to this piece.";case"dropped":return e.reason;case"sent":return`Sent to ${e.title??"the worktree"}${t}.`;case"worktree":return`A worktree of its own${t}: ${e.title??"open it from the line above its text"}.`;case"queued":return`Queued until ${e.after?e.after.kind==="branch"?e.after.branch:e.after.title:e.said??"its turn"} lands.`}}function sW(e,t,n,r){const o=P(f=>f.visible),i=P(f=>f.archived),a=t==null?void 0:t.label,c=t==null?void 0:t.path,[u,h]=S.useState(0);return S.useEffect(()=>{const f=setInterval(()=>h(m=>m+1),6e4);return()=>clearInterval(f)},[]),S.useMemo(()=>{if(!e)return;const f=[];a!==void 0&&c!==void 0&&f.push({id:"plan",label:a,tip:Pt(c)});for(const m of H_(e)){const g=Zz(e,m);let w=null,y;if("worktreeId"in g){const N=o.find(x=>x.worktree.id===g.worktreeId);N?(w=d.jsx("span",{className:`dot ${ks(N)}`}),y=sr(_i(N.worktree))):y=Object.values(i).flat().some(_=>_.id===g.worktreeId)?"archived":"gone"}else y=g.word;const v=ou(e)?B_(m,Ri(e,m),ju(e,m)):u$(su(e,m));f.push({id:m.id,lead:w,label:d.jsxs(d.Fragment,{children:[m.title,d.jsx("span",{className:"editor-tab-mark",children:y})]}),tip:Pt(v)})}return{items:f,current:n,onPick:r,owner:"pieces",label:"the plan and its pieces"}},[e,a,c,n,r,o,i,u])}function iW({item:e,piece:t}){var o,i;const n=su(e,t),r="repoName"in n&&n.repoName?` in ${n.repoName}`:"";switch(n.kind){case"starting":return d.jsx("span",{className:"live-text",children:"starting"});case"failed":case"skipped":case"dropped":return d.jsx(d.Fragment,{children:u$(n)});case"sent":return d.jsxs(d.Fragment,{children:["Sent to ",n.worktreeId?d.jsx(Eo,{id:n.worktreeId,title:n.title}):n.title??"the worktree",r,"."]});case"worktree":return d.jsxs(d.Fragment,{children:["A worktree of its own",r,": ",d.jsx(Eo,{id:n.worktreeId,title:n.title}),"."]});case"queued":return d.jsxs(d.Fragment,{children:["Queued until"," ",((o=n.after)==null?void 0:o.kind)==="branch"?d.jsx(Eo,{id:n.after.id,title:n.after.branch}):((i=n.after)==null?void 0:i.title)??n.said??"its turn"," ","lands."]});case"here":{const a=t.after,c=a&&"piece"in a?e.pieces.find(f=>f.id===a.piece):void 0,u=c?su(e,c):null,h=a&&"id"in a?d.jsx(Eo,{id:a.id,title:a.title}):u&&(u.kind==="worktree"||u.kind==="sent")&&u.worktreeId?d.jsx(Eo,{id:u.worktreeId,title:u.title??(c==null?void 0:c.title)}):c?c.title:null;return h?d.jsxs(d.Fragment,{children:["This worktree's agent does it, once ",h," lands."]}):d.jsx(d.Fragment,{children:"This worktree's agent does it."})}}}function aW({item:e,piece:t,worktreeId:n,path:r,version:o,openSeq:i,focus:a,onChat:c}){const u=tt(),h=y=>u==null?void 0:u.send(U_(e,n,t.id,y)),f=Ri(e,t),m=ju(e,t),g=ou(e)?Kz(t,e.pieces).filter(y=>y!==f):[],w=d.jsxs("div",{className:"editor-piece-lead",children:[d.jsx("p",{className:"editor-piece-line hint",children:ou(e)?d.jsxs(d.Fragment,{children:[e.stale&&"The plan changed since these were read. ",B_(t,f,m),g.length>0&&d.jsxs(d.Fragment,{children:[" ","Instead:"," ",g.map((y,v)=>d.jsxs("span",{children:[v>0&&" · ",d.jsx(De,{variant:"inline",onClick:()=>h(y),children:y==="send"&&t.to?`send to ${t.to.title}`:Wz(t,y)})]},y))]})]}):d.jsx(iW,{item:e,piece:t})}),d.jsx(oW,{refs:t.attachments,worktreeId:n})]});return d.jsx(c$,{text:t.plan,path:r,worktreeId:n,version:o,openSeq:i,focus:a,onChat:c,lead:w})}const lW=S.lazy(async()=>{const[e]=await Promise.all([bk(()=>import("./Editor--Z8ktewC.js").then(t=>t.E),__vite__mapDeps([0,1,2])),bk(()=>import("./grammar-CQ1uaD6_.js"),[]).then(t=>t.grammarsReady)]);return e});function O1({what:e}){return l_(!0,3e3)?d.jsx("div",{className:"empty",children:d.jsxs("span",{className:"live-text",children:["loading ",e]})}):null}const cW=()=>{},uW=[],dW={diff:"diff",file:"text",preview:"book"};function fW({path:e,note:t,title:n,worktreeId:r}){const o=Un(),i=nw(e),a=n??i.name,c=n?"":i.dir;return d.jsxs("span",{className:"editor-title","data-tip":c||n?e:void 0,draggable:!!r,onDragStart:r?u=>lu(u,{kind:"paths",worktreeId:r,items:[{path:e,folder:!1}]}):void 0,onDragEnd:r?()=>Cu(o):void 0,children:[d.jsxs("span",{className:"editor-name",children:[a,t]}),c&&d.jsx("span",{className:"editor-dir row-dim",children:c})]})}function hW(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 d$({editor:e,height:t,full:n=!1,onToggleFull:r,onDragStart:o,placement:i="stack"}){const a=i==="screen",c=lt(),u=Un(),h=tt(),f=Wr(),m=ww(),g=Ch(),{worktreeId:w,path:y,ref:v,since:N}=e,x=e.loose,_=P(J=>{var we;return((we=Fo(J))==null?void 0:we.id)===w}),T=P(J=>{var ge,Be;const we=(ge=nn(J,w))==null?void 0:ge.worktree;return we?we.path:(Be=Fo(J))==null?void 0:Be.path}),j=v!==void 0,C=P(J=>{var we;return(we=nn(J,w))==null?void 0:we.worktree.plan}),M=!x&&!j&&C===y,I=ky(M?w:void 0,M?y:void 0),O=P(J=>D_(Xr(J,w).chat??uW)),A=S.useMemo(()=>{if(j||x||e.view!=="preview"||!O)return null;const J=O.plan??C;return J&&y===J?O:null},[j,x,e.view,C,y,O]),[z,B]=S.useState(null);ut([A==null?void 0:A.id,y],()=>B(null));const U=!!A&&!Fz(A),Q=A?z!==null&&(z==="plan"?U:A.pieces.some(J=>J.id===z))?z:qz(A,U):"plan",ae=A&&Q!=="plan"?A.pieces.find(J=>J.id===Q)??null:null,ee=S.useMemo(()=>U?{label:M&&I?I:nw(y).name,path:y}:null,[U,M,I,y]),de=sW(A,ee,Q,B),$=S.useMemo(()=>x?KH(x.source,y,J=>c({a:"editor-refused",file:{worktreeId:w,path:y},message:J}),HH(h?J=>h.send(J):null)):(m==null?void 0:m.bind({worktreeId:w,path:y,...v?{ref:v}:{},...N?{since:N}:{}}))??a$,[m,w,y,v,N,x,c,h]),K=P(J=>Xr(J,w).changedRanges[y]);S.useEffect(()=>{!K&&!j&&!_&&!x&&(h==null||h.send({t:"changed-ranges",worktreeId:w,path:y}))},[w,y,K,j,_,x,h]);const V=(K==null?void 0:K.offset)??0,X=e.disk,W=e.view??"diff",se=!!X&&(X.before===""||X.before===X.after),ce=j_(y,se).filter(J=>J!==W&&!(x&&J==="diff")),he=(x==null?void 0:x.source.kind)==="grant"?x.source:null,je=j||_||x&&!he?null:EL(y),[$e,q]=S.useState(!1),[H,ve]=xo(Ke.editorWrap,!1,J=>J===null?void 0:J==="1"),Se=!!X&&!je&&!X.binary&&!X.tooLarge&&W!=="preview",ye=e.line&&!e.line.fiber?e.line.n:void 0;return d.jsxs(Sy,{kind:"editor",className:He("editor-pane",n&&"full"),height:n||a?void 0:t,resizable:!n&&!a,onDragStart:o??cW,tabs:de,title:d.jsx(fW,{path:y,note:j?` at ${v==null?void 0:v.slice(0,7)}`:N?", last turn":void 0,title:M&&I?I:void 0,worktreeId:x?void 0:w}),menu:()=>T&&!x?Rs({id:w,dir:T},y,{discard:!j&&!_,kept:_,ref:v,showing:e.view??void 0,noDiff:se},{sock:h,dispatch:c}):[],onClose:()=>c({a:"close-editor"}),full:n,onToggleFull:a?void 0:r,actions:d.jsxs(d.Fragment,{children:[!je&&ce.length>0&&d.jsx("span",{className:"editor-views",children:ce.map(J=>d.jsxs(De,{variant:"outline",tone:"quiet",mono:!0,className:"deep-link",onClick:()=>c({a:"editor-view",v:J}),"data-tip":hW(J,W),children:[d.jsx(St,{name:dW[J],className:"icon-inline"})," ",J]},J))}),je==="image"&&d.jsxs(De,{variant:"outline",tone:"quiet",mono:!0,className:"deep-link",onClick:()=>q(!0),"data-tip":"Full size: see the picture over the window",children:[d.jsx(St,{name:"zen",className:"icon-inline"})," full size"]}),Se&&d.jsxs(De,{variant:"outline",tone:"quiet",mono:!0,className:"deep-link",onClick:()=>ve(!H),"data-tip":H?"Unwrap lines: one line per row, scroll sideways for the rest":"Wrap lines: fold a long line at the pane's edge",children:[d.jsx(St,{name:"wrap",className:"icon-inline"})," ",H?"unwrap":"wrap"]})]}),children:[X&&d.jsx(pW,{editor:e,disk:X,files:m}),d.jsx("div",{className:"editor-body",children:X?je?d.jsx(VH,{kind:je,src:he?f.loose(he.id,he.version):f.worktreeFile(w,y,X.version),path:y,openSeq:e.seq,focus:e.focus,full:$e,onFull:q}):X.binary?d.jsx("div",{className:"empty",children:"not a text file: open it in another editor"}):X.tooLarge?d.jsx("div",{className:"empty",children:"too large to open here: open it in another editor"}):W==="preview"&&A&&ae?d.jsx(aW,{item:A,piece:ae,worktreeId:w,path:y,version:j||_||x?void 0:X.version,openSeq:e.seq,focus:e.focus,onChat:J=>Bm(u,{worktreeId:w,text:J,name:y})}):W==="preview"&&Eh(y)==="html"?d.jsx(QH,{text:X.after,path:y,worktreeId:w,version:j||_||x?void 0:X.version,openSeq:e.seq,focus:e.focus}):W==="preview"?d.jsx(c$,{text:X.after,path:y,worktreeId:w,version:j||_||x?void 0:X.version,openSeq:e.seq,focus:e.focus,onChat:J=>Bm(u,{worktreeId:w,text:J,name:y})}):d.jsx(Mw,{pane:!0,children:d.jsx(S.Suspense,{fallback:d.jsx(O1,{what:W}),children:d.jsx(lW,{file:{worktreeId:w,path:y,...v?{ref:v}:{},...N?{since:N}:{}},disk:X,blame:e.blame,view:W,openSeq:e.seq,line:ye,focus:e.focus,readOnly:j||!X.writable||a,numbers:!a,wrap:H,theme:g,sync:$,onCopy:x?void 0:(J,we,ge)=>fz(ge,{worktreeId:w,path:J,...we,...v?{ref:v}:{}}),onChat:(J,we)=>Bm(u,we&&(x?{worktreeId:w,text:we.text,name:J}:{worktreeId:w,text:we.text,source:{path:J,startLine:we.startLine,endLine:we.endLine,...v?{ref:v}:{}}})),onNew:()=>u.dispatch({a:"open-draft"}),onLineHover:j||x?void 0:J=>{J==null?dn.post(w,{type:"highlight-clear"}):dn.post(w,{type:"highlight-file",path:y,ranges:[[J+V,J+V]]})}},`${w}
|
|
256
|
+
${x?"loose":v??N??""}
|
|
257
|
+
${y}`)})}):d.jsx(O1,{what:y},y)})]})}function pW({editor:e,disk:t,files:n}){var h;const{worktreeId:r,path:o,ref:i,since:a,conflict:c}=e,u={worktreeId:r,path:o,...i?{ref:i}:{},...a?{since:a}:{}};if(c){const f=c.version===null;return d.jsxs("div",{className:"editor-note",children:[d.jsx("span",{className:"editor-note-text",children:f?"deleted on disk; your edits are not saved":"changed on disk; your edits are not saved"}),d.jsx(De,{variant:"outline",onClick:()=>n==null?void 0:n.reload(u),"data-tip":f?"Close the file; your edits go with it":"Take the file as it is on disk; undo brings your edits back",children:f?"close":"reload"}),d.jsx(De,{variant:"outline",tone:"danger",onClick:()=>n==null?void 0:n.keepMine(u),"data-tip":f?"Save your edits as the file again":"Save your edits over the file on disk",children:"keep mine"})]})}return e.refused?d.jsx("div",{className:"editor-note",children:d.jsx("span",{className:"hint",children:e.refused})}):((h=e.loose)==null?void 0:h.source.kind)==="text"&&!t.writable?d.jsx("div",{className:"editor-note",children:d.jsx("span",{className:"hint",children:"read-only: the message as it was sent, kept in the chat and not in a file"})}):e.loose&&!t.writable&&!t.tooLarge&&!t.binary?d.jsx("div",{className:"editor-note",children:d.jsxs("span",{className:"hint",children:["read-only: ",o," is not in a project; drop it on a folder in files to add it"]})}):i===void 0&&!t.writable&&!t.binary&&!t.tooLarge?d.jsx("div",{className:"editor-note",children:d.jsx("span",{className:"hint",children:"read-only: Toyon does not run this worktree"})}):null}function f$(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 mW=(e,t)=>{const n=Ng(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"}},sh="https://github.com/toyon-dev/toyon",gW=e=>`${sh}/releases/tag/v${e}`,kW=`${sh}/releases/latest`,wW=4e3;function yW(e,t,n,r){if(r==="asking")return{value:`${e} checking`,text:`Asking ${Ng(n)} for the newest version`,act:"check",busy:!0};const o=Ng(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(cS(r.latest,e)){const a=t==="none"?"This copy runs from a checkout, so pull to get it":t==="npx"?`This copy runs with npx, so run npx toyon@${r.latest} to use it`:"It installs once no chat is replying";return{...i,value:`${r.latest} out`,text:`Toyon ${r.latest} is out. ${a}`}}return{...i,value:`${e} up to date`,text:`Toyon ${e} is the newest version ${o} lists. Press to ask again`,settles:!0}}function vW(e,t,n,r,o,i=!1,a=null,c=null){if(n){if(n.restarting){const h=n.installed??n.running,f=n.restarting.length>0?hN(n.restarting):"Toyon is restarting; this page reloads when it is back";return{value:`${h} restarting`,text:f,act:"restart",busy:!0}}if(n.installing){const h=n.latest??n.installed??n.running;return{value:`${h} installing`,text:`Installing Toyon ${h}`,act:"update",busy:!0}}if(n.failed){const h=n.failed.line.replace(/\.$/,"");return{value:`${n.running} update failed`,text:`Installing Toyon ${n.failed.version} stopped: ${h}. Press to try again, or run ${n.failed.command}`,act:"update",busy:!1}}if(n.installed)return{value:`${n.installed} ready`,text:`Toyon ${n.installed} is installed and ${n.running} is still running. It restarts onto the new one when nothing is busy; press to restart now`,act:"restart",busy:!1};if(n.latest)return{value:`${n.latest} out`,text:n.method==="npx"?`Toyon ${n.latest} is out. This copy runs with npx, so run npx toyon@${n.latest} to use it`:`Toyon ${n.latest} is out and installs when nothing is busy; press to install now`,act:"update",busy:!1}}const u=f$(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?yW(e,t,a,c):{value:e,text:`Toyon ${e}, ${mW(t,a)}`,act:"check",busy:!1}}function bW(e,t,n){const r=o=>()=>window.open(o,"_blank");return Bn([t?[{id:"check-update",label:"check for updates",...t.off?{disabled:t.off}:{},onClick:t.run}]:[],[n?{id:"release-notes",label:"release notes",onClick:n}:{id:"release-notes",label:`release notes for ${e}`,onClick:r(gW(e))},{id:"latest-release",label:"latest release",onClick:r(kW)},{id:"repo",label:"Toyon on GitHub",onClick:r(sh)},{id:"report",label:"report a problem",onClick:r(`${sh}/issues/new`)}],[{id:"copy-version",label:"copy version",onClick:()=>tn(e)}]])}const xW=fA.map(e=>({title:e,rows:mA(e).map(t=>[zt(t),Zc[t].label])}));function EW(){const e=lt(),t=tt(),n=wn("keys"),r=P(m=>m.themePrefs),o=P(m=>m.themes),i=P(m=>m.chatSide),a=P(m=>m.keepAwake),c=kw(),u=P(m=>m.agents),h=ql(),f=m=>{e({a:"palette-return",v:{mode:"keys",q:""}}),e(m)};return d.jsxs(gu,{bare:!0,boxClass:"keys-stack",id:"keys-help",onClose:()=>e({a:"close"}),children:[d.jsxs("div",{className:"keys-card",children:[d.jsxs("div",{children:[h&&d.jsxs(d.Fragment,{children:[d.jsx("div",{className:"section-title keys-h",children:h.name}),d.jsxs("div",{className:"keys-setting",children:[d.jsx("span",{className:"keys-d",children:"processes"}),d.jsx(De,{variant:"field",mono:!0,className:"keys-chip","data-tip":`edit the install + start commands in ${h.configFile}`,onClick:()=>e({a:"open",overlay:{kind:"setup",repoId:h.id}}),...n.contextMenu(()=>Kh(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(NW,{agent:m},m.id))]}),d.jsxs("div",{children:[d.jsx("div",{className:"section-title keys-h",children:"Appearance"}),d.jsxs("div",{className:"keys-setting",children:[d.jsx("span",{className:"keys-d",children:"mode"}),d.jsx(De,{variant:"field",mono:!0,onClick:()=>f({a:"open",overlay:{kind:"appearance"}}),children:Xf[r.mode]})]}),d.jsxs("div",{className:"keys-setting",children:[d.jsx("span",{className:"keys-d",children:"theme"}),d.jsx(De,{variant:"field",mono:!0,onClick:()=>f({a:"open",overlay:{kind:"theme",slot:"theme"}}),children:xh(r,o,c).name})]}),d.jsxs("div",{className:"keys-setting",children:[d.jsx("span",{className:"keys-d",children:"chat side"}),d.jsx(De,{variant:"field",mono:!0,onClick:()=>e({a:"toggle-chat-side"}),children:i})]}),d.jsx("div",{className:"section-title keys-h",children:"Toyon"}),a!==null&&d.jsxs("div",{className:"keys-setting",children:[d.jsx("span",{className:"keys-d",children:"keep awake"}),d.jsx(De,{variant:"field",mono:!0,onClick:()=>f({a:"open",overlay:{kind:"keep-awake"}}),children:Qf[a]})]}),d.jsx(SW,{}),d.jsx(_W,{})]})]}),d.jsx("div",{className:"keys-card",children:xW.map(m=>d.jsxs("div",{children:[d.jsx("div",{className:"section-title keys-h",children:m.title}),m.rows.map(([g,w])=>d.jsxs("div",{className:"keys-row",children:[d.jsx(os,{k:g}),d.jsx("span",{className:"keys-d",children:w})]},g))]},m.title))})]})}function SW(){const e=tt(),t=lt(),n=wn("keys"),r=P(T=>T.version),o=P(T=>T.install),i=P(T=>T.registry),a=P(T=>T.update),c=P(T=>T.self),u=P(T=>T.rebuilt),h=P(T=>T.repos),f=P(T=>T.managed.updates),m=P(T=>T.updateCheck),g=P(T=>T.frame),w=P(T=>T.newProject!==null),y=vW(r,o,a,c,h,u,i,m),v=!f&&(y.act==="update"||y.act==="check"),N=y.settles&&m&&m!=="asking"?m:null;S.useEffect(()=>{if(!N)return;const T=()=>t({a:"update-check-settle",check:N}),j=setTimeout(T,wW);return()=>{clearTimeout(j),T()}},[N,t]);const x=()=>{y.act==="restart"?e==null||e.send({t:"restart-daemon"}):y.act==="reload"?window.location.reload():y.act==="rebuild"&&c?e==null||e.send({t:"run-after-land",repoId:c.repoId}):y.act==="update"?e==null||e.send({t:"update-now"}):y.act==="check"&&e&&(t({a:"update-check"}),e.send({t:"check-update"}))},_=()=>bW(r,y.act==="check"&&!y.busy?{run:x,...v?{off:"managed by your organization"}:{}}:null,g==="phone"||w?void 0:()=>t({a:"open-release-notes"}));return d.jsxs("div",{className:"keys-setting",...n.contextMenu(_),children:[d.jsx("span",{className:"keys-d",children:"version"}),d.jsx(De,{variant:"field",mono:!0,busy:y.busy,disabled:v,onClick:x,...Pt(v?"updates are managed by your organization":y.text,void 0,{detail:y.detail}),children:y.value})]})}function _W(){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: ${lP(e).join(", ")||"nothing turned off"}`;return d.jsx("div",{className:"hint",children:t})}function h$(e){return e.available?e.auth?e.auth.kind==="none"?"not logged in":e.auth.label:e.checkFailed?"not ready":"ready":e.installing?"installing":"not installed"}function p$(e){var n,r;return e.available?e.checkFailed?e.checkFailed:e.auth?[e.auth.detail,(n=e.auth.account)==null?void 0:n.email,(r=e.auth.account)==null?void 0:r.organization].filter(Boolean).join(" · ")||e.auth.label:"installed; it names the account it runs on the first time it runs":np(e)}function NW({agent:e}){const t=lt(),n=tt(),r=wn("keys");return d.jsxs("div",{className:"keys-setting",children:[d.jsx("span",{className:"keys-d",children:e.name}),d.jsx(De,{variant:"field",mono:!0,"data-tip":p$(e),...r.contextMenu(()=>wy(e,{sock:n})),onClick:()=>{t({a:"palette-return",v:{mode:"keys",q:""}}),t({a:"open",overlay:{kind:"agent-page",agent:e.id}})},children:h$(e)})]})}function TW({agentId:e}){const t=lt(),n=tt(),r=ql(),o=P(g=>g.home),i=P(g=>g.agents.find(w=>w.id===e)??null),a=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]),s$(n,e,i??void 0),!i)return null;const u=wy(i,{sock:n}),h=()=>t({a:"close",back:!0}),f=g=>o&&g.startsWith(`${o}/`)?`~${g.slice(o.length)}`:g,m=g=>n==null?void 0:n.send({t:"reveal-agent-file",agent:e,file:g.id,...r?{repoId:r.id}:{}});return d.jsx(gu,{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(Rt,{icon:"back",label:"back to settings",hint:"esc",onClick:h})}),d.jsx("div",{className:"section-title keys-h",children:i.name}),d.jsxs("div",{className:"keys-setting",children:[d.jsx("span",{className:"keys-d",children:"signed in"}),d.jsx(De,{variant:"field",mono:!0,"data-tip":p$(i),disabled:u.length===0,...c.dropdown(()=>u,"right"),children:h$(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 offers no small model, so you write them in the changes panel"})]}),d.jsx("div",{className:"section-title keys-h",children:"MCP servers it will load"}),a===null?d.jsx("div",{className:"keys-setting",children:d.jsx("span",{className:"keys-d live-text",children:"reading"})}):a.servers.length===0?d.jsxs("div",{className:"keys-setting",children:[d.jsx("span",{className:"keys-d",children:"none configured"}),d.jsx("span",{className:"keys-d",children:"add one with the agent's own CLI, or a .mcp.json in the repo"})]}):a.servers.map(g=>d.jsx(jW,{s:g},`${g.scope}:${g.name}`)),a&&a.files.length>0&&d.jsxs(d.Fragment,{children:[d.jsx("div",{className:"section-title keys-h",children:"the files it reads"}),a.files.map(g=>d.jsxs("div",{className:"keys-setting",children:[d.jsx("span",{className:"keys-d",children:g.label}),g.exists?d.jsx(De,{variant:"field",mono:!0,"data-tip":`reveal ${f(g.path)} in Finder`,onClick:()=>m(g),children:f(g.path)}):d.jsxs("span",{className:"keys-d",children:["not present: ",f(g.path)]})]},g.id))]})]})})}function jW({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 $W(){const e=lt(),t=tt(),n=P(o=>o.agents),r=P(o=>o.defaultAgent);return d.jsx(Hr,{items:n,filter:(o,i)=>o.filter(a=>ns(i,a.name,a.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=>wy(o,{sock:t}),placeholder:"default agent for new worktrees",keys:{pick:"sets",back:"closes"},row:o=>d.jsx(Cn,{label:o.name,current:o.id===r,hint:o.available?o.checkFailed??(o.sandboxed?void 0:"unsandboxed"):np(o)})})}const CW=["dark","light","system","daylight"],AW=new Intl.DateTimeFormat(void 0,{hour:"numeric",minute:"2-digit"});function IW(){const e=lt(),t=tt(),n=P(u=>u.themePrefs),r=P(u=>u.themes),o=kw(),i=P(u=>u.daylight),a=u=>{var h;return((h=r.find(f=>f.id===n[Yk({...n,mode:u},o)]))==null?void 0:h.name)??""},c=u=>{if(u==="system")return`${o.system?"dark":"light"} now · ${a(u)}`;if(u!=="daylight")return a(u);const h=i&&i.until>Date.now()?` · ${o.daylight?"light":"dark"} at ${AW.format(i.until)}`:"";return`${o.daylight?"dark":"light"} now${h} · ${a(u)}`};return d.jsx(Hr,{items:CW,filter:(u,h)=>u.filter(f=>ns(h,Xf[f])),rowClass:()=>"picker-row",keyOf:u=>u,initialIndex:u=>u.indexOf(n.mode),onActive:u=>e({a:"preview-theme",theme:u?xh({...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(Cn,{label:Xf[u],current:u===n.mode,hint:c(u)})})}const RW=2,Ek=e=>oS(e).join(" ").length<RW,OW=e=>({kind:"chat",id:e.id,name:e.name,hint:e.branch??"",fields:[e.name,e.branch??""]}),MW=e=>({kind:"chat",id:e.id,name:e.title,hint:BN(e),fields:[e.title,e.branch],prompt:e.prompt,archived:e});function PW(e,t,n){const r=oS(t),o=n==="all"&&!Ek(t);return e.filter(i=>{if(i.kind==="hit")return o;const a=n==="names"&&i.prompt?[...i.fields,i.prompt]:i.fields;return r.every(c=>a.some(u=>u.toLowerCase().includes(c)))})}const LW=e=>e.flatMap(([t,n])=>Array.from({length:n},(r,o)=>t+o));function DW({repoId:e,scope:t}){const n=lt(),r=tt(),o=P(j=>j.clientId),i=P(j=>j.frame),a=P(j=>j.chats[e]),c=xw(),u=P(j=>j.archived[e]),[h,f]=S.useState(t),m=S.useCallback(()=>f(j=>j==="all"?"names":"all"),[]);S.useEffect(()=>{r==null||r.send({t:"list-archived",repoId:e})},[r,e]);const g=S.useMemo(()=>[...c.filter(j=>!Nr(j.worktree)).map(OW),...(u??[]).map(MW)],[c,u]),w=S.useMemo(()=>new Map(g.map(j=>[j.id,j])),[g]),y=S.useMemo(()=>[...g,...((a==null?void 0:a.hits)??[]).map(j=>({kind:"hit",hit:j}))],[g,a]),v=S.useMemo(()=>{const j=new Map;for(const C of(a==null?void 0:a.hits)??[])j.set(C.worktreeId,Math.max(j.get(C.worktreeId)??0,C.ts));return j},[a]),N=S.useCallback((j,C)=>PW(j,C,h),[h]),x=S.useCallback(j=>{h==="all"&&!Ek(j)&&(r==null||r.send({t:"search-chats",repoId:e,query:j.trim()}))},[r,e,h]),_=j=>!a||a.query!==j.trim(),T=j=>h==="all"&&!Ek(j);return d.jsx(Hr,{items:y,filter:N,onQuery:x,onTab:m,trailing:d.jsx(De,{tone:"chrome",on:h==="names","aria-pressed":h==="names",onClick:m,children:"names only"}),keyOf:j=>j.kind==="hit"?`h:${j.hit.worktreeId}:${j.hit.seq}`:`w:${j.id}`,rowClass:j=>j.kind==="hit"?"chats-hit":He("picker-row",j.archived&&!j.archived.restorable&&"dim"),rowTitle:j=>{var C;return j.kind==="hit"?j.hit.text:((C=j.archived)==null?void 0:C.prompt)??j.name},groupOf:j=>j.kind==="hit"?`h:${j.hit.worktreeId}`:j.archived?"archived":"open",groupHead:(j,C)=>{if(!j.startsWith("h:"))return`${j} · ${C}`;const M=j.slice(2),I=w.get(M),O=a==null?void 0:a.asks[M],A=v.get(M)??0;return d.jsxs(d.Fragment,{children:[d.jsxs("span",{className:"chats-name",children:[(I==null?void 0:I.name)??"a worktree",(I==null?void 0:I.archived)&&d.jsxs(d.Fragment,{children:[" ",d.jsx("span",{className:"row-dim",children:"archived"})]})]}),A>0&&d.jsx("span",{className:"picker-group-tail",children:sr(A)}),O&&d.jsx("span",{className:"picker-group-line",children:Fh(O,TN*2)})]})},headAlone:!0,onPick:j=>{const C=j.kind==="hit"?j.hit.worktreeId:j.id,M=j.kind==="hit"?j.hit.archived:!!j.archived;n(M?{a:"open-archived",id:C}:{a:"activate",id:C}),j.kind==="hit"&&n({a:"reveal",id:C,seq:j.hit.seq}),n({a:"close"})},onBack:()=>n({a:"close"}),rowMenu:j=>j.kind==="chat"&&j.archived?xf(j.archived,{clientId:o,frame:i},{sock:r,dispatch:n}):[],placeholder:h==="names"?"find a chat by name…":"search in chats…",keys:j=>({nav:"moves",tab:h==="names"?"searches messages too":"searches names only",pick:j?j.kind==="hit"?"opens the chat there":"opens its chat":void 0,back:"closes"}),empty:j=>j.trim()?T(j)?_(j)?d.jsx("span",{className:"live-text",children:"searching"}):"no chat says that":"no chat is named that":u?"no chats yet":d.jsx("span",{className:"live-text",children:"looking"}),footer:(j,C)=>{const M=C.filter(I=>I.kind==="hit").length;return a!=null&&a.truncated&&!_(j)&&M>0?d.jsxs("div",{className:"empty",children:["showing the first ",M,"; narrow the search"]}):null},row:j=>j.kind==="chat"?d.jsx(Cn,{label:j.name,hint:j.hint}):d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"chats-text",children:ku(j.hit.text,LW(j.hit.match),0)}),d.jsxs("span",{className:"chats-said row-dim",children:[j.hit.role==="user"?"you":"the agent",j.hit.ts>0&&sr(j.hit.ts)!==sr(v.get(j.hit.worktreeId)??0)?` · ${sr(j.hit.ts)}`:""]})]})})}const Vl=function(e,t){let o=e;const i=Wc[t];let a=null,c=0,u=null;const h=[],f={},m=function(I,O){c=o*4+17,a=(function(A){const z=new Array(A);for(let B=0;B<A;B+=1){z[B]=new Array(A);for(let U=0;U<A;U+=1)z[B][U]=null}return z})(c),g(0,0),g(c-7,0),g(0,c-7),v(),y(),x(I,O),o>=7&&N(I),u==null&&(u=j(o,i,h)),_(u,O)},g=function(I,O){for(let A=-1;A<=7;A+=1)if(!(I+A<=-1||c<=I+A))for(let z=-1;z<=7;z+=1)O+z<=-1||c<=O+z||(0<=A&&A<=6&&(z==0||z==6)||0<=z&&z<=6&&(A==0||A==6)||2<=A&&A<=4&&2<=z&&z<=4?a[I+A][O+z]=!0:a[I+A][O+z]=!1)},w=function(){let I=0,O=0;for(let A=0;A<8;A+=1){m(!0,A);const z=mi.getLostPoint(f);(A==0||I>z)&&(I=z,O=A)}return O},y=function(){for(let I=8;I<c-8;I+=1)a[I][6]==null&&(a[I][6]=I%2==0);for(let I=8;I<c-8;I+=1)a[6][I]==null&&(a[6][I]=I%2==0)},v=function(){const I=mi.getPatternPosition(o);for(let O=0;O<I.length;O+=1)for(let A=0;A<I.length;A+=1){const z=I[O],B=I[A];if(a[z][B]==null)for(let U=-2;U<=2;U+=1)for(let Q=-2;Q<=2;Q+=1)U==-2||U==2||Q==-2||Q==2||U==0&&Q==0?a[z+U][B+Q]=!0:a[z+U][B+Q]=!1}},N=function(I){const O=mi.getBCHTypeNumber(o);for(let A=0;A<18;A+=1){const z=!I&&(O>>A&1)==1;a[Math.floor(A/3)][A%3+c-8-3]=z}for(let A=0;A<18;A+=1){const z=!I&&(O>>A&1)==1;a[A%3+c-8-3][Math.floor(A/3)]=z}},x=function(I,O){const A=i<<3|O,z=mi.getBCHTypeInfo(A);for(let B=0;B<15;B+=1){const U=!I&&(z>>B&1)==1;B<6?a[B][8]=U:B<8?a[B+1][8]=U:a[c-15+B][8]=U}for(let B=0;B<15;B+=1){const U=!I&&(z>>B&1)==1;B<8?a[8][c-B-1]=U:B<9?a[8][15-B-1+1]=U:a[8][15-B-1]=U}a[c-8][8]=!I},_=function(I,O){let A=-1,z=c-1,B=7,U=0;const Q=mi.getMaskFunction(O);for(let ae=c-1;ae>0;ae-=2)for(ae==6&&(ae-=1);;){for(let ee=0;ee<2;ee+=1)if(a[z][ae-ee]==null){let de=!1;U<I.length&&(de=(I[U]>>>B&1)==1),Q(z,ae-ee)&&(de=!de),a[z][ae-ee]=de,B-=1,B==-1&&(U+=1,B=7)}if(z+=A,z<0||c<=z){z-=A,A=-A;break}}},T=function(I,O){let A=0,z=0,B=0;const U=new Array(O.length),Q=new Array(O.length);for(let $=0;$<O.length;$+=1){const K=O[$].dataCount,V=O[$].totalCount-K;z=Math.max(z,K),B=Math.max(B,V),U[$]=new Array(K);for(let ce=0;ce<U[$].length;ce+=1)U[$][ce]=255&I.getBuffer()[ce+A];A+=K;const X=mi.getErrorCorrectPolynomial(V),se=vu(U[$],X.getLength()-1).mod(X);Q[$]=new Array(X.getLength()-1);for(let ce=0;ce<Q[$].length;ce+=1){const he=ce+se.getLength()-Q[$].length;Q[$][ce]=he>=0?se.getAt(he):0}}let ae=0;for(let $=0;$<O.length;$+=1)ae+=O[$].totalCount;const ee=new Array(ae);let de=0;for(let $=0;$<z;$+=1)for(let K=0;K<O.length;K+=1)$<U[K].length&&(ee[de]=U[K][$],de+=1);for(let $=0;$<B;$+=1)for(let K=0;K<O.length;K+=1)$<Q[K].length&&(ee[de]=Q[K][$],de+=1);return ee},j=function(I,O,A){const z=M1.getRSBlocks(I,O),B=P1();for(let Q=0;Q<A.length;Q+=1){const ae=A[Q];B.put(ae.getMode(),4),B.put(ae.getLength(),mi.getLengthInBits(ae.getMode(),I)),ae.write(B)}let U=0;for(let Q=0;Q<z.length;Q+=1)U+=z[Q].dataCount;if(B.getLengthInBits()>U*8)throw"code length overflow. ("+B.getLengthInBits()+">"+U*8+")";for(B.getLengthInBits()+4<=U*8&&B.put(0,4);B.getLengthInBits()%8!=0;)B.putBit(!1);for(;!(B.getLengthInBits()>=U*8||(B.put(236,8),B.getLengthInBits()>=U*8));)B.put(17,8);return T(B,z)};f.addData=function(I,O){O=O||"Byte";let A=null;switch(O){case"Numeric":A=zW(I);break;case"Alphanumeric":A=FW(I);break;case"Byte":A=BW(I);break;case"Kanji":A=UW(I);break;default:throw"mode:"+O}h.push(A),u=null},f.isDark=function(I,O){if(I<0||c<=I||O<0||c<=O)throw I+","+O;return a[I][O]},f.getModuleCount=function(){return c},f.make=function(){if(o<1){let I=1;for(;I<40;I++){const O=M1.getRSBlocks(I,i),A=P1();for(let B=0;B<h.length;B++){const U=h[B];A.put(U.getMode(),4),A.put(U.getLength(),mi.getLengthInBits(U.getMode(),I)),U.write(A)}let z=0;for(let B=0;B<O.length;B++)z+=O[B].dataCount;if(A.getLengthInBits()<=z*8)break}o=I}m(!1,w())},f.createTableTag=function(I,O){I=I||2,O=typeof O>"u"?I*4:O;let A="";A+='<table style="',A+=" border-width: 0px; border-style: none;",A+=" border-collapse: collapse;",A+=" padding: 0px; margin: "+O+"px;",A+='">',A+="<tbody>";for(let z=0;z<f.getModuleCount();z+=1){A+="<tr>";for(let B=0;B<f.getModuleCount();B+=1)A+='<td style="',A+=" border-width: 0px; border-style: none;",A+=" border-collapse: collapse;",A+=" padding: 0px; margin: 0px;",A+=" width: "+I+"px;",A+=" height: "+I+"px;",A+=" background-color: ",A+=f.isDark(z,B)?"#000000":"#ffffff",A+=";",A+='"/>';A+="</tr>"}return A+="</tbody>",A+="</table>",A},f.createSvgTag=function(I,O,A,z){let B={};typeof arguments[0]=="object"&&(B=arguments[0],I=B.cellSize,O=B.margin,A=B.alt,z=B.title),I=I||2,O=typeof O>"u"?I*4:O,A=typeof A=="string"?{text:A}:A||{},A.text=A.text||null,A.id=A.text?A.id||"qrcode-description":null,z=typeof z=="string"?{text:z}:z||{},z.text=z.text||null,z.id=z.text?z.id||"qrcode-title":null;const U=f.getModuleCount()*I+O*2;let Q,ae,ee,de,$="",K;for(K="l"+I+",0 0,"+I+" -"+I+",0 0,-"+I+"z ",$+='<svg version="1.1" xmlns="http://www.w3.org/2000/svg"',$+=B.scalable?"":' width="'+U+'px" height="'+U+'px"',$+=' viewBox="0 0 '+U+" "+U+'" ',$+=' preserveAspectRatio="xMinYMin meet"',$+=z.text||A.text?' role="img" aria-labelledby="'+C([z.id,A.id].join(" ").trim())+'"':"",$+=">",$+=z.text?'<title id="'+C(z.id)+'">'+C(z.text)+"</title>":"",$+=A.text?'<description id="'+C(A.id)+'">'+C(A.text)+"</description>":"",$+='<rect width="100%" height="100%" fill="white" cx="0" cy="0"/>',$+='<path d="',ee=0;ee<f.getModuleCount();ee+=1)for(de=ee*I+O,Q=0;Q<f.getModuleCount();Q+=1)f.isDark(ee,Q)&&(ae=Q*I+O,$+="M"+ae+","+de+K);return $+='" stroke="transparent" fill="black"/>',$+="</svg>",$},f.createDataURL=function(I,O){I=I||2,O=typeof O>"u"?I*4:O;const A=f.getModuleCount()*I+O*2,z=O,B=A-O;return ZW(A,A,function(U,Q){if(z<=U&&U<B&&z<=Q&&Q<B){const ae=Math.floor((U-z)/I),ee=Math.floor((Q-z)/I);return f.isDark(ee,ae)?0:1}else return 1})},f.createImgTag=function(I,O,A){I=I||2,O=typeof O>"u"?I*4:O;const z=f.getModuleCount()*I+O*2;let B="";return B+="<img",B+=' src="',B+=f.createDataURL(I,O),B+='"',B+=' width="',B+=z,B+='"',B+=' height="',B+=z,B+='"',A&&(B+=' alt="',B+=C(A),B+='"'),B+="/>",B};const C=function(I){let O="";for(let A=0;A<I.length;A+=1){const z=I.charAt(A);switch(z){case"<":O+="<";break;case">":O+=">";break;case"&":O+="&";break;case'"':O+=""";break;default:O+=z;break}}return O},M=function(I){I=typeof I>"u"?2:I;const A=f.getModuleCount()*1+I*2,z=I,B=A-I;let U,Q,ae,ee,de;const $={"██":"█","█ ":"▀"," █":"▄"," ":" "},K={"██":"▀","█ ":"▀"," █":" "," ":" "};let V="";for(U=0;U<A;U+=2){for(ae=Math.floor((U-z)/1),ee=Math.floor((U+1-z)/1),Q=0;Q<A;Q+=1)de="█",z<=Q&&Q<B&&z<=U&&U<B&&f.isDark(ae,Math.floor((Q-z)/1))&&(de=" "),z<=Q&&Q<B&&z<=U+1&&U+1<B&&f.isDark(ee,Math.floor((Q-z)/1))?de+=" ":de+="█",V+=I<1&&U+1>=B?K[de]:$[de];V+=`
|
|
258
|
+
`}return A%2&&I>0?V.substring(0,V.length-A-1)+Array(A+1).join("▀"):V.substring(0,V.length-1)};return f.createASCII=function(I,O){if(I=I||1,I<2)return M(O);I-=1,O=typeof O>"u"?I*2:O;const A=f.getModuleCount()*I+O*2,z=O,B=A-O;let U,Q,ae,ee;const de=Array(I+1).join("██"),$=Array(I+1).join(" ");let K="",V="";for(U=0;U<A;U+=1){for(ae=Math.floor((U-z)/I),V="",Q=0;Q<A;Q+=1)ee=1,z<=Q&&Q<B&&z<=U&&U<B&&f.isDark(ae,Math.floor((Q-z)/I))&&(ee=0),V+=ee?de:$;for(ae=0;ae<I;ae+=1)K+=V+`
|
|
259
|
+
`}return K.substring(0,K.length-1)},f.renderTo2dContext=function(I,O){O=O||2;const A=f.getModuleCount();for(let z=0;z<A;z++)for(let B=0;B<A;B++)I.fillStyle=f.isDark(z,B)?"black":"white",I.fillRect(B*O,z*O,O,O)},f};Vl.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};Vl.createStringToBytes=function(e,t){const n=(function(){const o=WW(e),i=function(){const u=o.read();if(u==-1)throw"eof";return u};let a=0;const c={};for(;;){const u=o.read();if(u==-1)break;const h=i(),f=i(),m=i(),g=String.fromCharCode(u<<8|h),w=f<<8|m;c[g]=w,a+=1}if(a!=t)throw a+" != "+t;return c})(),r=63;return function(o){const i=[];for(let a=0;a<o.length;a+=1){const c=o.charCodeAt(a);if(c<128)i.push(c);else{const u=n[o.charAt(a)];typeof u=="number"?(u&255)==u?i.push(u):(i.push(u>>>8),i.push(u&255)):i.push(r)}}return i}};const Fr={MODE_NUMBER:1,MODE_ALPHA_NUM:2,MODE_8BIT_BYTE:4,MODE_KANJI:8},Wc={L:1,M:0,Q:3,H:2},pi={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7},mi=(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(a){let c=0;for(;a!=0;)c+=1,a>>>=1;return c};return o.getBCHTypeInfo=function(a){let c=a<<10;for(;i(c)-i(t)>=0;)c^=t<<i(c)-i(t);return(a<<10|c)^r},o.getBCHTypeNumber=function(a){let c=a<<12;for(;i(c)-i(n)>=0;)c^=n<<i(c)-i(n);return a<<12|c},o.getPatternPosition=function(a){return e[a-1]},o.getMaskFunction=function(a){switch(a){case pi.PATTERN000:return function(c,u){return(c+u)%2==0};case pi.PATTERN001:return function(c,u){return c%2==0};case pi.PATTERN010:return function(c,u){return u%3==0};case pi.PATTERN011:return function(c,u){return(c+u)%3==0};case pi.PATTERN100:return function(c,u){return(Math.floor(c/2)+Math.floor(u/3))%2==0};case pi.PATTERN101:return function(c,u){return c*u%2+c*u%3==0};case pi.PATTERN110:return function(c,u){return(c*u%2+c*u%3)%2==0};case pi.PATTERN111:return function(c,u){return(c*u%3+(c+u)%2)%2==0};default:throw"bad maskPattern:"+a}},o.getErrorCorrectPolynomial=function(a){let c=vu([1],0);for(let u=0;u<a;u+=1)c=c.multiply(vu([1,wi.gexp(u)],0));return c},o.getLengthInBits=function(a,c){if(1<=c&&c<10)switch(a){case Fr.MODE_NUMBER:return 10;case Fr.MODE_ALPHA_NUM:return 9;case Fr.MODE_8BIT_BYTE:return 8;case Fr.MODE_KANJI:return 8;default:throw"mode:"+a}else if(c<27)switch(a){case Fr.MODE_NUMBER:return 12;case Fr.MODE_ALPHA_NUM:return 11;case Fr.MODE_8BIT_BYTE:return 16;case Fr.MODE_KANJI:return 10;default:throw"mode:"+a}else if(c<41)switch(a){case Fr.MODE_NUMBER:return 14;case Fr.MODE_ALPHA_NUM:return 13;case Fr.MODE_8BIT_BYTE:return 16;case Fr.MODE_KANJI:return 12;default:throw"mode:"+a}else throw"type:"+c},o.getLostPoint=function(a){const c=a.getModuleCount();let u=0;for(let m=0;m<c;m+=1)for(let g=0;g<c;g+=1){let w=0;const y=a.isDark(m,g);for(let v=-1;v<=1;v+=1)if(!(m+v<0||c<=m+v))for(let N=-1;N<=1;N+=1)g+N<0||c<=g+N||v==0&&N==0||y==a.isDark(m+v,g+N)&&(w+=1);w>5&&(u+=3+w-5)}for(let m=0;m<c-1;m+=1)for(let g=0;g<c-1;g+=1){let w=0;a.isDark(m,g)&&(w+=1),a.isDark(m+1,g)&&(w+=1),a.isDark(m,g+1)&&(w+=1),a.isDark(m+1,g+1)&&(w+=1),(w==0||w==4)&&(u+=3)}for(let m=0;m<c;m+=1)for(let g=0;g<c-6;g+=1)a.isDark(m,g)&&!a.isDark(m,g+1)&&a.isDark(m,g+2)&&a.isDark(m,g+3)&&a.isDark(m,g+4)&&!a.isDark(m,g+5)&&a.isDark(m,g+6)&&(u+=40);for(let m=0;m<c;m+=1)for(let g=0;g<c-6;g+=1)a.isDark(g,m)&&!a.isDark(g+1,m)&&a.isDark(g+2,m)&&a.isDark(g+3,m)&&a.isDark(g+4,m)&&!a.isDark(g+5,m)&&a.isDark(g+6,m)&&(u+=40);let h=0;for(let m=0;m<c;m+=1)for(let g=0;g<c;g+=1)a.isDark(g,m)&&(h+=1);const f=Math.abs(100*h/c/c-50)/5;return u+=f*10,u},o})(),wi=(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})(),vu=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 a=0;a<e.length-o;a+=1)i[a]=e[a+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 a=0;a<r.getLength();a+=1)for(let c=0;c<o.getLength();c+=1)i[a+c]^=wi.gexp(wi.glog(r.getAt(a))+wi.glog(o.getAt(c)));return vu(i,0)},r.mod=function(o){if(r.getLength()-o.getLength()<0)return r;const i=wi.glog(r.getAt(0))-wi.glog(o.getAt(0)),a=new Array(r.getLength());for(let c=0;c<r.getLength();c+=1)a[c]=r.getAt(c);for(let c=0;c<o.getLength();c+=1)a[c]^=wi.gexp(wi.glog(o.getAt(c))+i);return vu(a,0).mod(o)},r},M1=(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 a={};return a.totalCount=o,a.dataCount=i,a},n={},r=function(o,i){switch(i){case Wc.L:return e[(o-1)*4+0];case Wc.M:return e[(o-1)*4+1];case Wc.Q:return e[(o-1)*4+2];case Wc.H:return e[(o-1)*4+3];default:return}};return n.getRSBlocks=function(o,i){const a=r(o,i);if(typeof a>"u")throw"bad rs block @ typeNumber:"+o+"/errorCorrectionLevel:"+i;const c=a.length/3,u=[];for(let h=0;h<c;h+=1){const f=a[h*3+0],m=a[h*3+1],g=a[h*3+2];for(let w=0;w<f;w+=1)u.push(t(m,g))}return u},n})(),P1=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},zW=function(e){const t=Fr.MODE_NUMBER,n=e,r={};r.getMode=function(){return t},r.getLength=function(a){return n.length},r.write=function(a){const c=n;let u=0;for(;u+2<c.length;)a.put(o(c.substring(u,u+3)),10),u+=3;u<c.length&&(c.length-u==1?a.put(o(c.substring(u,u+1)),4):c.length-u==2&&a.put(o(c.substring(u,u+2)),7))};const o=function(a){let c=0;for(let u=0;u<a.length;u+=1)c=c*10+i(a.charAt(u));return c},i=function(a){if("0"<=a&&a<="9")return a.charCodeAt(0)-48;throw"illegal char :"+a};return r},FW=function(e){const t=Fr.MODE_ALPHA_NUM,n=e,r={};r.getMode=function(){return t},r.getLength=function(i){return n.length},r.write=function(i){const a=n;let c=0;for(;c+1<a.length;)i.put(o(a.charAt(c))*45+o(a.charAt(c+1)),11),c+=2;c<a.length&&i.put(o(a.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},BW=function(e){const t=Fr.MODE_8BIT_BYTE,n=Vl.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},UW=function(e){const t=Fr.MODE_KANJI,n=Vl.stringToBytes;(function(i,a){const c=n(i);if(c.length!=2||(c[0]<<8|c[1])!=a)throw"sjis not supported."})("友",38726);const r=n(e),o={};return o.getMode=function(){return t},o.getLength=function(i){return~~(r.length/2)},o.write=function(i){const a=r;let c=0;for(;c+1<a.length;){let u=(255&a[c])<<8|255&a[c+1];if(33088<=u&&u<=40956)u-=33088;else if(57408<=u&&u<=60351)u-=49472;else throw"illegal char at "+(c+1)+"/"+u;u=(u>>>8&255)*192+(u&255),i.put(u,13),c+=2}if(c<a.length)throw"illegal char at "+(c+1)},o},m$=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},HW=function(){let e=0,t=0,n=0,r="";const o={},i=function(c){r+=String.fromCharCode(a(c&63))},a=function(c){if(c<0)throw"n:"+c;if(c<26)return 65+c;if(c<52)return 97+(c-26);if(c<62)return 48+(c-52);if(c==62)return 43;if(c==63)return 47;throw"n:"+c};return o.writeByte=function(c){for(e=e<<8|c&255,t+=8,n+=1;t>=6;)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},WW=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|a(u.charCodeAt(0)),o+=6}const c=r>>>o-8&255;return o-=8,c};const a=function(c){if(65<=c&&c<=90)return c-65;if(97<=c&&c<=122)return c-97+26;if(48<=c&&c<=57)return c-48+52;if(c==43)return 62;if(c==47)return 63;throw"c:"+c};return i},KW=function(e,t){const n=e,r=t,o=new Array(e*t),i={};i.setPixel=function(h,f,m){o[f*n+h]=m},i.write=function(h){h.writeString("GIF87a"),h.writeShort(n),h.writeShort(r),h.writeByte(128),h.writeByte(0),h.writeByte(0),h.writeByte(0),h.writeByte(0),h.writeByte(0),h.writeByte(255),h.writeByte(255),h.writeByte(255),h.writeString(","),h.writeShort(0),h.writeShort(0),h.writeShort(n),h.writeShort(r),h.writeByte(0);const f=2,m=c(f);h.writeByte(f);let g=0;for(;m.length-g>255;)h.writeByte(255),h.writeBytes(m,g,255),g+=255;h.writeByte(m.length-g),h.writeBytes(m,g,m.length-g),h.writeByte(0),h.writeString(";")};const a=function(h){const f=h;let m=0,g=0;const w={};return w.write=function(y,v){if(y>>>v)throw"length over";for(;m+v>=8;)f.writeByte(255&(y<<m|g)),v-=8-m,y>>>=8-m,g=0,m=0;g=y<<m|g,m=m+v},w.flush=function(){m>0&&f.writeByte(g)},w},c=function(h){const f=1<<h,m=(1<<h)+1;let g=h+1;const w=u();for(let _=0;_<f;_+=1)w.add(String.fromCharCode(_));w.add(String.fromCharCode(f)),w.add(String.fromCharCode(m));const y=m$(),v=a(y);v.write(f,g);let N=0,x=String.fromCharCode(o[N]);for(N+=1;N<o.length;){const _=String.fromCharCode(o[N]);N+=1,w.contains(x+_)?x=x+_:(v.write(w.indexOf(x),g),w.size()<4095&&(w.size()==1<<g&&(g+=1),w.add(x+_)),x=_)}return v.write(w.indexOf(x),g),v.write(m,g),v.flush(),y.toByteArray()},u=function(){const h={};let f=0;const m={};return m.add=function(g){if(m.contains(g))throw"dup key:"+g;h[g]=f,f+=1},m.size=function(){return f},m.indexOf=function(g){return h[g]},m.contains=function(g){return typeof h[g]<"u"},m};return i},ZW=function(e,t,n){const r=KW(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=m$();r.write(o);const i=HW(),a=o.toByteArray();for(let c=0;c<a.length;c+=1)i.writeByte(a[c]);return i.flush(),"data:image/gif;base64,"+i};Vl.stringToBytes;function qW(e){const t=Vl(0,"M");t.addData(e,"Byte"),t.make();const n=t.getModuleCount();return Array.from({length:n},(r,o)=>Array.from({length:n},(i,a)=>t.isDark(o,a)))}const cr={title:"Your devices",scan:"Scan with your phone's camera to open this machine there, then let the phone in here.",turnOn:"Turn on, and your phone opens this machine at its tailnet name. Anyone on your tailnet you let in gets a shell here.",hereOff:"Tailscale on this machine is not connected, so nothing on your tailnet can reach it.",noneOnTailnet:"No other device is on your tailnet yet.",noPhone:"No phone has joined your tailnet. Install Tailscale on it and sign in to the same account.",knocking:"Let in the one whose words match the other screen.",missing:"A machine with no Toyon needs the phone button pressed on it, or `toyon remote --tailscale`.",listed:"listed",request:"request access",notAnswering:"not answering right now",offline:"offline",noToyon:"no Toyon",placeholder:"https://",notAnAddress:"That is not a Toyon address. It is https:// and the machine's name, as its screen shows it.",asking:e=>`Asking ${ih(e)}.`,waiting:(e,t)=>`Toyon on ${ih(e)} is asking whether to let ${t} in.`,added:e=>`Added ${e}.`,notKept:e=>`Let in, but not listed: ${e}`,add:"add"};function GW(e,t){return e.reached?e.toyon&&!e.toyon.answering?cr.notAnswering:t?cr.listed:e.toyon?null:cr.noToyon:cr.offline}function L1(e){var t;return(t=e.toyon)!=null&&t.answering?0:e.toyon?1:e.reached?2:3}function ih(e){try{return new URL(e).host}catch{return e}}function g$(e,t,n){const r=ih(t);switch(e){case"refused":return`${r} did not let ${n} in.`;case"gone":return`${r} stopped waiting. Ask again, and answer there within five minutes.`;case"full":return`${r} has too many devices waiting already. Answer or turn those away there first.`;case"not-toyon":return`${r} is not a Toyon machine, or has no remote name set up.`;case"unreachable":return`${r} did not answer. Is Tailscale on here, and is Toyon running there?`}}function VW(e,t,n){const r=(o,i)=>({word:o,note:i,offer:null});switch(t==null?void 0:t.state){case"not-installed":return r("no Tailscale","Tailscale is not installed on this machine, so nothing on your tailnet can reach it.");case"not-running":return r("Tailscale not running","Tailscale is not running on this machine, so nothing on your tailnet can reach it.");case"disconnected":return{word:null,note:"Tailscale on this machine is switched off, so nothing on your tailnet can reach it.",offer:"connect"};case"signed-out":return{word:null,note:"Tailscale on this machine is signed out, so nothing on your tailnet can reach it.",offer:"sign-in"};case"needs-approval":return r("not approved",t.line)}if(e===null)return r("not asked","Toyon could not ask Tailscale here just now.");if(e!==void 0&&!e.here)return r("not connected",cr.hereOff);if(n===null&&t!==null&&t.state!=="ready")switch(t.state){case"magicdns-off":return r("MagicDNS off",t.line);case"https-off":return r("HTTPS off",t.line);default:return r(null,t.line)}return r(null,null)}const YW=e=>e==="phone"?"phone":"laptop";function D1({rows:e}){return d.jsx("div",{className:"tailnet-list",children:e.map(t=>d.jsxs("div",{className:"tailnet-row",children:[d.jsxs("div",{className:"tailnet-peer",children:[d.jsx("span",{className:He("dot tailnet-dot",t.reached===null?"tailnet-asking":t.reached?"tailnet-reached":"tailnet-unreached"),role:"img","aria-label":t.reached===null?"asking":t.reached?"connected":"not connected"}),d.jsx(St,{name:t.icon,className:"tailnet-kind"}),d.jsx("span",{className:"tailnet-name",children:t.name}),t.host&&d.jsx("span",{className:"hint tailnet-host",children:t.host})]}),t.right!==void 0&&t.right!==null&&d.jsx("span",{className:He("tailnet-right",typeof t.right=="string"&&"hint"),children:t.right})]},t.key))})}const z1=(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:YW(e.kind),right:t}},ig=4;function XW({text:e}){const{size:t,d:n}=S.useMemo(()=>{const r=qW(e);let o="";return r.forEach((i,a)=>{i.forEach((c,u)=>{c&&(o+=`M${u+ig} ${a+ig}h1v1h-1z`)})}),{size:r.length+ig*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 QW=5e3;function JW(e){return e.from===null?"A device that opened this address":`A Toyon page at ${ih(e.from)}`}function eK({knock:e,letIn:t,onAnswer:n}){return d.jsxs("div",{className:He("devices-knock",t!==null&&"devices-knock-done"),children:[d.jsxs("div",{className:"devices-knock-line",children:[d.jsx("span",{className:"knock-word",children:e.word}),d.jsx("span",{className:"devices-from",children:t===null?`${JW(e)} wants in.`:t?"is in.":"was turned away."})]}),t===null&&d.jsxs("div",{className:"devices-actions",children:[d.jsx(De,{tone:"primary",onClick:()=>n(!0),children:"let in"}),d.jsx(De,{variant:"outline",onClick:()=>n(!1),children:"not now"})]})]})}function tK({host:e,noPhone:t}){return d.jsxs("div",{className:"devices-address",children:[d.jsx("div",{className:"devices-frame",children:d.jsx(XW,{text:EA(e)})}),d.jsxs("div",{className:"devices-about",children:[d.jsx("p",{className:"devices-line",children:cr.scan}),t&&d.jsx("p",{className:"devices-note",children:cr.noPhone})]})]})}function nK(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)=>L1(r.d)-L1(o.d)||r.i-o.i).map(({d:r})=>r);return[...t,...n]}function rK(){const e=lt(),t=is(),n=Wr(),r=P(ye=>ye.frame==="desk"),o=P(ye=>{var J;return((J=ye.remote)==null?void 0:J.host)??null}),i=P(ye=>ye.machine),a=P(ye=>ye.tailscale),c=P(ye=>ye.knocks),[u,h]=S.useState(""),[f,m]=S.useState({kind:"idle"}),[g,w]=S.useState([]),y=()=>e({a:"close"}),v=f.kind==="asking"||f.kind==="waiting",N=HD(()=>ML(n),QW,!v),x=S.useRef(new AbortController);S.useEffect(()=>()=>x.current.abort(),[]);const _=async ye=>{if(v)return;const J=x.current.signal;m({kind:"asking",origin:ye});const we=await kS(ye,J,Ie=>m({kind:"waiting",origin:ye,word:Ie}));if(J.aborted)return;if(typeof we=="string"){m({kind:"failed",line:g$(we,ye,"this page")});return}const ge=t.serving(),Be=await FL(Xk(ge.origin,ge.token),ye,we.token);m(Be?{kind:"failed",line:cr.notKept(Be)}:{kind:"added",name:t.displayName(ye)})},T=()=>{const ye=SA(u);ye?_(ye):m({kind:"failed",line:cr.notAnAddress})},j=()=>{x.current.abort(),x.current=new AbortController,m({kind:"idle"})},C=(ye,J)=>{w(we=>we.some(ge=>ge.knock.id===ye.id)?we:[...we,{knock:ye,letIn:J}]),BL(n,ye.id,J)},M=c.filter(ye=>!g.some(J=>J.knock.id===ye.id)),I=[...g,...M.map(ye=>({knock:ye,letIn:null}))],[O,A]=S.useState(!1),[z,B]=S.useState(null),U=async ye=>{A(!0),B(null);const J=await(ye?PL(n):LL(n));A(!1),J&&B(J)},Q=(N==null?void 0:N.here)===!0,ae=VW(N,a,o),ee=o!==null,de=r&&(Q||N===void 0)?d.jsx(De,{variant:"outline",size:"sm",on:ee,"aria-pressed":ee,busy:O,disabled:!ee&&(a==null?void 0:a.state)!=="ready",onClick:()=>void U(!ee),...Pt(ee?"Take this machine's name off your tailnet":"Give this machine a name on your tailnet"),children:ee?"on":"off"}):null,[$,K]=S.useState(!1),[V,X]=S.useState(null),W=ye=>{window.open(ye,"_blank","noopener")===null?X(ye):X(null)},se=async ye=>{if(K(!0),B(null),ye==="connect"){const J=await DL(n);J&&B(J)}else{const J=await zL(n);"url"in J?W(J.url):B(J.why)}K(!1)},ce=r&&ae.offer!==null?V!==null?d.jsx(De,{variant:"outline",size:"sm",onClick:()=>W(V),children:"open the sign-in page"}):d.jsx(De,{variant:"outline",size:"sm",busy:$,onClick:()=>void se(ae.offer??"connect"),...ae.note?Pt(ae.note):{},children:ae.offer==="connect"?"connect":"sign in"}):null,he=ae.word===null&&de===null&&ce===null?"this machine":d.jsxs(d.Fragment,{children:[ae.word&&d.jsx("span",{className:"hint",children:ae.word}),de??ce]}),je=[{key:"self",name:i??"This machine",host:o??void 0,reached:N===void 0?null:Q,icon:"laptop",right:he}],$e=N?nK(N).map(ye=>{if(ye.kind==="phone"||ye.host==="")return z1(ye,ye.reached?void 0:"not answering");const J=`https://${ye.host}`,we=GW(ye,t.get(J)!==null);return z1(ye,we??d.jsx(De,{variant:"outline",size:"sm",disabled:v,onClick:()=>void _(J),children:cr.request}))}):[],q=r&&o!==null&&N!==null&&(N===void 0||N.here),H=N==null?void 0:N.devices.some(ye=>ye.kind==="machine"&&ye.host!==""&&ye.reached&&ye.toyon===null),ve=q&&N!==void 0&&!N.devices.some(ye=>ye.kind==="phone"),Se=(()=>{switch(f.kind){case"asking":return cr.asking(f.origin);case"waiting":return cr.waiting(f.origin,f.word);case"added":return cr.added(f.name);case"failed":return f.line;case"idle":return null}})();return d.jsxs(gu,{boxClass:"devices-card",onClose:y,children:[d.jsx("div",{className:"devices-title",children:cr.title}),d.jsx(D1,{rows:je}),ae.note&&ae.offer===null&&d.jsx("p",{className:"devices-note",children:ae.note}),z&&d.jsx("p",{className:"devices-note",children:z}),r&&!ee&&(a==null?void 0:a.state)==="ready"&&d.jsx("p",{className:"devices-note",children:cr.turnOn}),q&&o!==null&&d.jsx(tK,{host:o,noPhone:ve}),f.kind==="waiting"&&d.jsx("div",{className:"knock-word devices-word",children:f.word}),Se&&d.jsx("p",{className:He("devices-line",f.kind==="failed"&&"devices-failed"),children:Se}),N!==void 0&&d.jsxs(d.Fragment,{children:[$e.length>0&&d.jsx("div",{className:"devices-others",children:d.jsx(D1,{rows:$e})}),(N==null?void 0:N.devices.length)===0&&d.jsx("p",{className:"devices-note",children:cr.noneOnTailnet}),H&&d.jsx("p",{className:"devices-note",children:cr.missing})]}),!v&&d.jsxs("form",{className:"devices-form",onSubmit:ye=>{ye.preventDefault(),T()},children:[d.jsx(Do,{size:"md",font:"ui",value:u,placeholder:cr.placeholder,"aria-label":"Address of the other machine",onChange:ye=>h(ye.target.value),className:"devices-field"}),d.jsx(De,{type:"submit",variant:"outline",disabled:!u.trim(),children:cr.add})]}),v&&d.jsx("div",{className:"devices-actions",children:d.jsx(De,{tone:"quiet",onClick:j,children:"cancel"})}),M.length>0&&d.jsx("p",{className:"devices-line devices-centred",children:cr.knocking}),I.map(ye=>d.jsx(eK,{knock:ye.knock,letIn:ye.letIn,onAnswer:J=>C(ye.knock,J)},ye.knock.id))]})}function oK({worktreeId:e,hits:t}){const n=lt(),r=tt(),o=P(c=>c.layout.changes),i=P(c=>{var h;const u=(h=nn(c,e))==null?void 0:h.worktree;return u?u.path:null}),a=S.useCallback((c,u)=>{const h=u.trim().toLowerCase();return h?c.filter(f=>`${f.path}:${f.line} ${f.text}`.toLowerCase().includes(h)):c},[]);return d.jsx(Hr,{items:t,filter:a,keyOf:c=>`${c.path}:${c.line}`,rowClass:()=>"search-hit",rowTitle:c=>`${c.path}:${c.line}`,onPick:c=>{Fn({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?Rs({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 sK({project:e}){const t=lt(),n=tt(),r=P(h=>h.paths),o=P(h=>h.home),i=S.useCallback(h=>{hu(h)&&(n==null||n.send({t:"browse-path",path:h}))},[n]),a=S.useCallback((h,f)=>e9({query:f,entries:r.entries,target:r.target,answered:r.query,home:o}),[r,o]),c=nu(e.name)?null:e.name.trim(),u=h=>`${h.replace(/\/+$/,"")}/`;return d.jsx(Hr,{initialQuery:u(e.parent),lead:d.jsx("span",{className:"picker-chip",children:c??"new project"}),items:[],filter:a,keyOf:h=>h.kind==="dir"?`d:${h.entry.path}`:`${h.kind}:${h.path}`,rowClass:()=>"picker-row folder-row",onQuery: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(Cn,{label:`put ${c??"it"} in ${ik(h.path,o)}`,hint:d.jsx("bdi",{children:c?_T(h.path,c):h.path})}):h.kind==="up"?d.jsx(Cn,{label:`up to ${ik(h.path,o)}`,hint:d.jsx("bdi",{children:h.path})}):d.jsx(Cn,{label:h.entry.name})})}const iK={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 aK(){const e=lt(),t=tt(),n=P(r=>r.keepAwake);return d.jsx(Hr,{items:[...YC],filter:(r,o)=>r.filter(i=>ns(o,Qf[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(Cn,{label:Qf[r],current:r===n,hint:iK[r]})})}function lK(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=ok(t.rows,null);return n?`${n.n} ${n.tier==="waiting"?"waiting":"unread"}`:"all quiet"}function Sk(e){try{return _A(new URL(e).hostname)}catch{return!1}}function cK(e){const t=new Set,n=e.build({...e.serving,serving:!0}),r=[];let o=n,i=[n];const a=()=>{i=[n,...r];for(const y of t)y()},c=new Map,u=y=>{var N;if(y.serving)return;(((N=y.store.getState().remote)==null?void 0:N.front)==="edge"||Sk(y.origin))&&y!==o?y.sock.suspend():y.sock.resume()},h=y=>{var N;let v=(N=y.store.getState().remote)==null?void 0:N.front;c.set(y.origin,y.store.subscribe(()=>{var _;const x=(_=y.store.getState().remote)==null?void 0:_.front;x!==v&&(v=x,u(y))}))},f=()=>i,m={list:f,active:()=>o,serving:()=>n,get:y=>f().find(v=>v.origin===y)??null,displayName(y){const v=f().find(x=>x.origin===y);return v?f().filter(x=>x.name===v.name).length>1?`${v.name} (${new URL(v.origin).host})`:v.name:y},activate(y){const v=f().find(x=>x.origin===y);if(!v||v===o)return;const N=o;o=v,u(N),u(v),a()},add(y){var x;const v=r.find(_=>_.origin===y.origin);if(y.origin===n.origin)return n;if(v){if(v.token===y.token)return v;(x=c.get(v.origin))==null||x(),v.dispose(),r.splice(r.indexOf(v),1),o===v&&(o=n)}const N=e.build({...y,serving:!1});return r.push(N),h(N),Sk(N.origin)&&N.sock.suspend(),a(),N},remove(y){var N;const v=r.find(x=>x.origin===y);v&&((N=c.get(y))==null||N(),c.delete(y),v.dispose(),v.storage.clear(),v.forget(),r.splice(r.indexOf(v),1),o===v&&(o=n),a())},broadcast(y){for(const v of f())v.store.dispatch(y)},subscribe(y){return t.add(y),()=>t.delete(y)}},g=y=>{for(const v of y)m.add(v);for(const v of[...r])y.some(N=>N.origin===v.origin)||m.remove(v.origin)};let w=n.store.getState().handed;return n.store.subscribe(()=>{const y=n.store.getState().handed;y!==w&&(w=y,g(w))}),g(w),m}function _y({form:e,anchored:t}){var de;const n=lt(),r=tt(),o=is(),i=mo(),a=o.displayName(i.origin),c=P($=>$.repos),u=P($=>$.newProject?null:$.activeRepoId),h=P($=>$.rows),f=P($=>$.paths),m=P($=>$.home),g=P($=>$.pending),w=P($=>$.folderDialog),y=S.useRef(""),v=S.useMemo(()=>$0(c,h),[c,h]),N=i_(),x=a_(),_=S.useMemo(()=>N.map($=>{var K;return{...$,repos:$0($.repos,((K=x.find(V=>V.origin===$.origin))==null?void 0:K.rows)??[])}}),[N,x]),T=S.useCallback($=>{y.current=$,hu($)&&(r==null||r.send({t:"browse-path",path:$}))},[r]),j=S.useCallback(($,K)=>J8({query:K,repos:v,pending:g,entries:[...f.entries].sort((V,X)=>Number(X.isRepo)-Number(V.isRepo)),target:f.target,answered:f.query,home:m,others:_,current:u}),[v,f,g,m,_,u]),C=$=>k$(h,$),M=()=>n({a:"close"}),I=()=>n({a:"close",back:!0}),O={sock:r,dispatch:n},A=$=>pu(O,{t:"register-repo",path:$}),z=($,K)=>pu(O,{t:"create-repo",mode:"create",parent:$,name:K}),B=($,K,V)=>n({a:"new-project",v:cw({mode:$,name:K,parent:Q8(c,u,m),...V?{url:V}:{}})}),U=()=>n({a:"open",overlay:{kind:"projects",form:"disk"}}),Q=()=>{const $=y.current.trim(),K=$.lastIndexOf("/"),V=hu($)&&K>=0?$.slice(0,K)||"/":"~";r==null||r.send({t:"choose-file",start:V}),M()},ae=()=>n({a:"open",overlay:{kind:"devices"}}),ee=($,K)=>{const V=o.get($);V&&(V.store.dispatch({a:"activate-repo",id:K}),o.activate($))};return d.jsx(Hr,{anchored:e==="pill"&&(t??!0),initialQuery:e==="disk"?"~/":"",lead:e==="disk"?void 0:d.jsx("span",{className:"picker-chip",children:((de=c.find($=>$.id===u))==null?void 0:de.name)??"no project"}),trailing:e==="disk"?w?d.jsx(Rt,{icon:"file",label:"Open a file from Finder",onClick:Q}):void 0:d.jsx(Rt,{icon:"folder",label:"Find a project or file on disk",onClick:U}),items:[],filter:j,initialIndex:$=>$.findIndex(K=>K.kind==="repo"&&!K.machine&&K.repo.id===u),groupOf:$=>$.kind==="machine"||$.kind==="repo"&&$.machine?$.machine.origin:i.origin,groupHead:$=>$===i.origin?a:d.jsx(uK,{origin:$}),keyOf:$=>$.kind==="repo"?$.machine?`${$.machine.origin}:${$.repo.id}`:$.repo.id:$.kind==="dir"?`d:${$.entry.path}`:$.kind==="file"?`f:${$.entry.path}`:$.kind==="open"?`open:${$.path}`:$.kind==="init"?`init:${$.path}`:$.kind==="pending"?`p:${$.pending.id}`:$.kind==="clone"?`clone:${$.url}`:$.kind==="new"?"new-project":$.kind==="disk"?"open-folder":$.kind==="add-machine"?"add-machine":$.kind==="machine"?`machine:${$.machine.origin}`:`new:${$.parent??""}/${$.name}`,rowClass:$=>He("picker-row",($.kind==="new"||$.kind==="disk"||$.kind==="add-machine")&&"new-project-row"),onQuery:T,completionOf:$=>$.kind==="dir"?$.entry.isRepo?$.entry.path:`${$.entry.path}/`:$.kind==="file"?$.entry.path:null,narrowTo:$=>$.kind==="dir"&&!$.entry.isRepo?`${$.entry.path}/`:null,onPick:$=>{if($.kind==="clone")return B("clone",$.name,$.url);if($.kind==="create"&&!$.parent)return B("create",$.name);if($.kind==="new")return B("create","");if($.kind==="disk")return U();if($.kind==="add-machine")return ae();$.kind==="machine"?o.activate($.machine.origin):$.kind==="pending"?n({a:"watch-import",id:$.pending.id}):$.kind==="repo"&&$.machine?ee($.machine.origin,$.repo.id):$.kind==="repo"?n({a:"activate-repo",id:$.repo.id}):$.kind==="open"?A($.path):$.kind==="file"?P6(r,$.entry.path):$.kind==="init"?TT(O,$.path):$.kind==="dir"?A($.entry.path):$.parent&&z($.parent,$.name),M()},onBack:I,rowMenu:$=>$.kind==="machine"||$.kind==="repo"&&$.machine?sk(o,$.machine.origin):$.kind==="repo"?Kh($.repo,u,O):$.kind==="pending"?t9($.pending,O):[],placeholder:c.length>1?"switch project, or type a name or path":"type a name or a path to start",keys:$=>({complete:"completes the path",pick:($==null?void 0:$.kind)==="dir"&&!$.entry.isRepo?"descends":($==null?void 0:$.kind)==="pending"?"watches it":($==null?void 0:$.kind)==="create"?$.parent?"creates it":"names it":($==null?void 0:$.kind)==="clone"?"clones it":($==null?void 0:$.kind)==="new"?"starts one":($==null?void 0:$.kind)==="disk"?"browses":($==null?void 0:$.kind)==="add-machine"?"adds one":($==null?void 0:$.kind)==="machine"||($==null?void 0:$.kind)==="repo"&&$.machine?"switches machine":"opens",back:"closes"}),empty:"nothing here; keep typing a path (~/… or /…)",row:$=>$.kind==="repo"&&$.machine?d.jsx(Cn,{label:$.repo.name,hint:d.jsx(dK,{origin:$.machine.origin,repo:$.repo})}):$.kind==="repo"?d.jsx(Cn,{label:$.repo.name,current:$.repo.id===u,hint:C($.repo)}):$.kind==="pending"?d.jsx(Cn,{label:$.pending.name,hint:$.pending.error?"import failed":d.jsx("span",{className:"live-text",children:"importing"})}):$.kind==="dir"?d.jsx(Cn,{label:$.entry.name,hint:$.entry.isRepo?"git repo":void 0}):$.kind==="file"?d.jsx(Cn,{label:$.entry.name,hint:"file"}):$.kind==="open"?d.jsx(Cn,{label:`open ${$.path}`,hint:"register with this daemon"}):$.kind==="init"?d.jsx(Cn,{label:`open ${$.path}`,hint:"no git yet; starts it here with the files in it"}):$.kind==="clone"?d.jsx(Cn,{label:`clone ${$.name}`,hint:fK($.url)}):$.kind==="new"?d.jsx(Cn,{label:d.jsxs(d.Fragment,{children:[d.jsx(St,{name:"plus",className:"icon-inline"}),"new project"]})}):$.kind==="disk"?d.jsx(Cn,{label:d.jsxs(d.Fragment,{children:[d.jsx(St,{name:"folder",className:"icon-inline"}),"open folder or file"]})}):$.kind==="add-machine"?d.jsx(Cn,{label:d.jsxs(d.Fragment,{children:[d.jsx(St,{name:"devices",className:"icon-inline"}),"add a machine"]})}):$.kind==="machine"?d.jsx(Cn,{label:`switch to ${o.displayName($.machine.origin)}`}):d.jsx(Cn,{label:`create ${$.name}`,hint:$.parent?`in ${$.parent}`:"new project"})})}function k$(e,t){const n=e.filter(u=>u.repoId===t.id),r=n.filter(Nn).filter(u=>u.worktree.kind!=="spare"),o=r.filter(u=>zo(u.agent)).length,i=r.length-1,a=n.length-n.filter(Nn).length;return[i>0?`${i} worktree${i===1?"":"s"}`:null,o>0?`${o} working`:null,a>0?`${a} discovered`:null].filter(Boolean).join(" · ")||void 0}function uK({origin:e}){const t=is(),n=t.get(e)??t.active(),r=pl(n,m=>m.rows),o=pl(n,m=>m.connected),i=pl(n,m=>m.connectFailure),a=pl(n,m=>m.incompatible),c=pl(n,m=>{var g;return(g=m.remote)==null?void 0:g.front}),u=t.displayName(e),h=lK(u,{rows:r.filter(Nn),connected:o,connectFailure:i,incompatible:a,suspended:(c==="edge"||Sk(e))&&!o}),f=/^\d+ /.test(h);return d.jsxs(d.Fragment,{children:[u,d.jsx("span",{className:He("picker-group-tail",f&&"picker-group-owed"),children:h})]})}function dK({origin:e,repo:t}){const n=is(),r=n.get(e),o=pl(r??n.active(),i=>i.rows);return d.jsx(d.Fragment,{children:r?k$(o,t):null})}function fK(e){const t=e.match(/^[a-z+]+:\/\/(?:[^@/]*@)?([^/:]+)/i)??e.match(/^[^@]+@([^:]+):/);return(t==null?void 0:t[1])??"git remote"}function hK(e){const t=[];if(e.pr){const r=e.pr.url;t.push({id:"open-pr",label:"open on GitHub",onClick:()=>window.open(r,"_blank")}),t.push({id:"copy-link",label:"copy link",onClick:()=>tn(r)})}const n=[{id:"copy-ref",label:e.kind==="pr"?"copy PR number":"copy branch name",onClick:()=>tn(e.ref)}];return Bn([t,n])}const pK=[],mK={branch:"branch",remote:"globe",pr:"pr"},F1={pr:0,branch:1,remote:2},gK={pr:"pull requests",branch:"branches",remote:"remote branches"};function kK({repoId:e}){const t=lt(),n=tt(),r=P(m=>m.clientId),o=P(m=>m.refs[e]),i=P(m=>m.rows),a=m=>{var g;return((g=i.find(w=>w.id===m))==null?void 0:g.name)??"a worktree"},c=S.useCallback(m=>[...m].sort((g,w)=>F1[g.kind]-F1[w.kind]),[]),u=S.useCallback(m=>n==null?void 0:n.send({t:"search-refs",repoId:e,query:m.trim()}),[n,e]),h=m=>!o||o.query!==m.trim(),f=m=>m.openIn?`open in ${a(m.openIn)}`:m.merged?"merged":m.pr?`${m.pr.author}${m.pr.draft?" · draft":""}${m.pr.fork?" · fork":""}`:m.subject??"";return d.jsx(Hr,{items:(o==null?void 0:o.refs)??pK,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:hK,groupOf:m=>m.kind,groupHead:(m,g)=>`${gK[m]} · ${g}`,placeholder:"open a branch or PR…",keys:m=>({nav:"moves",pick:m!=null&&m.openIn?"switches to it":"opens it as a worktree",back:"closes"}),empty:m=>h(m)?d.jsx("span",{className:"live-text",children:"looking"}):m.trim()?"no branch or PR matches":"no unmerged branches or open PRs",row:m=>d.jsx(Cn,{label:d.jsxs(d.Fragment,{children:[d.jsx(St,{name:mK[m.kind],className:"icon-inline"}),d.jsx("span",{className:"ref-name",children:m.name})]}),hint:f(m)})})}const B1=[],ag=2;function wK({worktreeId:e}){const t=lt(),n=tt(),r=k_(e).search,o=P(h=>h.layout.changes),i=P(h=>{var m;const f=(m=nn(h,e))==null?void 0:m.worktree;return f?f.path:null}),a=S.useCallback((h,f)=>f.trim().length>=ag?h:B1,[]),c=S.useCallback(h=>{const f=h.trim();f.length>=ag&&(n==null||n.send({t:"search",worktreeId:e,query:f}))},[n,e]),u=h=>!r||r.query.trim()!==h.trim();return S.useEffect(()=>()=>n==null?void 0:n.send({t:"search-stop"}),[n]),d.jsx(Hr,{items:(r==null?void 0:r.hits)??B1,filter:a,onQuery:c,keyOf:h=>`${h.path}:${h.line}`,rowClass:()=>"search-hit",rowTitle:h=>`${h.path}:${h.line}`,onPick:h=>{Fn({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?Rs({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<ag?"type at least two characters":u(h)?d.jsx("span",{className:"live-text",children:"searching"}):"no matches",footer:(h,f)=>r!=null&&r.truncated&&!u(h)&&f.length>0?d.jsx("div",{className:"empty",children:"not every match is shown; narrow the search"}):null,row:h=>d.jsxs(d.Fragment,{children:[d.jsxs("span",{className:"search-loc",children:[h.path,":",h.line]}),d.jsx("span",{className:"search-text",children:h.text})]})})}function yK({worktreeId:e}){const t=lt(),n=tt(),r=P(g=>g.clientId),o=P(g=>nn(g,e)),i=P(g=>g.repos),c=It(e,"draft").trim(),u=o==null?void 0:o.worktree.repoId,h=S.useMemo(()=>[...i.filter(g=>g.id===u),...i.filter(g=>g.id!==u)],[i,u]),f=()=>t({a:"close"}),m=g=>{if(!o)return f();n==null||n.send({t:"pieces-ask",worktreeId:e,repoId:g.id,...c?{text:c}:{}}),c&&(n==null||n.send({t:"set-draft",boxId:e,text:"",clientId:r}),t({a:"set-draft",id:e,text:""})),f()};return d.jsx(Hr,{lead:d.jsx("span",{className:"picker-chip",children:(o==null?void 0:o.worktree.title)??"worktree"}),items:h,filter:(g,w)=>g.filter(y=>y.id===u&&ns(w,"here")||ns(w,y.name,y.path)),keyOf:g=>g.id,row:g=>d.jsx(Cn,{label:g.id===u?"a new worktree here":g.name,hint:g.path}),onPick:m,onBack:()=>t({a:"close",back:!0}),placeholder:"continue where?",empty:"no project is open",keys:{pick:"continues there",back:"closes"},footer:c?()=>d.jsxs("div",{className:"empty",children:["with your message: ",c.split(`
|
|
260
|
+
`)[0]]}):void 0})}const U1=e=>e.source==="file"?"~/.toyon/themes":e.source==="vscode"?"VS Code":"";function vK({slot:e}){const t=lt(),n=tt(),r=P(_=>_.themePrefs),o=P(_=>_.themes),i=kw(),a=Yk(r,i),c=r[e==="theme"?a:e],u=()=>t({a:"close"}),h=()=>t({a:"close",back:!0}),f=_=>t({a:"preview-theme",theme:_}),[m,g]=S.useState(null),[w,y]=S.useState(null),v=(_,T)=>_[T??a]??_.dark??_.light??null,N=S.useMemo(()=>gL(o),[o]),x=S.useMemo(()=>o.filter(_=>_.kind===e),[o,e]);return ut([m,w],()=>{e==="theme"&&f(m?v(m,w):null)}),e!=="theme"?d.jsx(Hr,{items:x,filter:(_,T)=>_.filter(j=>ns(T,j.name,j.id)),rowClass:()=>"picker-row",keyOf:_=>_.id,initialIndex:_=>_.findIndex(T=>T.id===c),onActive:f,onPick:_=>{n==null||n.send({t:"set-theme",prefs:{...r,[e]:_.id}}),u()},onBack:h,placeholder:`${e} slot override`,keys:{nav:"preview",pick:"keeps",back:"reverts"},empty:"no matching theme",row:_=>d.jsx(Cn,{label:_.name,current:_.id===c,hint:U1(_)})}):d.jsx(Hr,{items:N,filter:(_,T)=>_.filter(j=>{var C,M;return ns(T,j.name,(C=j.dark)==null?void 0:C.name,(M=j.light)==null?void 0:M.name)}),rowClass:()=>"picker-row",keyOf:_=>{var T,j;return _.name+(((T=_.dark)==null?void 0:T.id)??((j=_.light)==null?void 0:j.id))},initialIndex:_=>_.findIndex(T=>{var j,C;return((j=T.dark)==null?void 0:j.id)===c||((C=T.light)==null?void 0:C.id)===c}),onActive:g,onSide:_=>{var T;_.dark&&_.light&&y((((T=v(_,w))==null?void 0:T.kind)??a)==="dark"?"light":"dark")},onPick:_=>{n==null||n.send({t:"set-theme",prefs:kL(r,_)}),u()},onBack:h,placeholder:"theme",keys:{nav:"preview",side:"dark/light",pick:"keeps",back:"reverts"},empty:"no matching theme",row:(_,T)=>{var I,O;const j=v(_,T?w:null),C=U1(_.dark??_.light),M=((I=_.dark)==null?void 0:I.id)===c||((O=_.light)==null?void 0:O.id)===c;return d.jsx(Cn,{label:_.name,current:M,hint:d.jsxs("span",{className:"theme-kinds",children:[C&&d.jsx("span",{children:C}),d.jsx("span",{className:"kind","data-state":ur({current:T&&(j==null?void 0:j.kind)==="dark"}),children:_.dark?"dark":""}),d.jsx("span",{className:"kind","data-state":ur({current:T&&(j==null?void 0:j.kind)==="light"}),children:_.light?"light":""})]})})}})}function w$(){const e=QD(),t=P(i=>i.frame==="phone"),n=Zl(),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(aH,{worktreeId:n}),(e==null?void 0:e.kind)==="search"&&n&&d.jsx(wK,{worktreeId:n}),(e==null?void 0:e.kind)==="element-sources"&&d.jsx(oK,{worktreeId:e.worktreeId,hits:e.hits}),(e==null?void 0:e.kind)==="refs"&&r&&d.jsx(kK,{repoId:r}),(e==null?void 0:e.kind)==="chats"&&r&&d.jsx(DW,{repoId:r,scope:e.names?"names":"all"}),(e==null?void 0:e.kind)==="keys"&&d.jsx(EW,{}),(e==null?void 0:e.kind)==="devices"&&d.jsx(rK,{}),(e==null?void 0:e.kind)==="theme"&&d.jsx(vK,{slot:e.slot}),(e==null?void 0:e.kind)==="appearance"&&d.jsx(IW,{}),(e==null?void 0:e.kind)==="keep-awake"&&d.jsx(aK,{}),(e==null?void 0:e.kind)==="agent"&&d.jsx($W,{}),(e==null?void 0:e.kind)==="agent-page"&&d.jsx(TW,{agentId:e.agent}),(e==null?void 0:e.kind)==="split"&&d.jsx(yK,{worktreeId:e.worktreeId}),(e==null?void 0:e.kind)==="commands"&&!t&&d.jsx(Gj,{}),(e==null?void 0:e.kind)==="projects"&&e.form!=="pill"&&d.jsx(_y,{form:e.form},e.form),(e==null?void 0:e.kind)==="choose-folder"&&o&&d.jsx(sK,{project:o})]})}const Tf="Lost the daemon; retrying",H1="Not answering";function bK(e,t){return e!=="down"&&e!=="blocked"?Tf:t===null?H1:`${H1}; as of ${bo(sr(t))}`}const xK="Not run by Toyon",y$="new worktree",EK=(e,t)=>`in ${e}, started from ${t}`,SK=e=>`in ${e}, here while it needs you`,_K=new Set(["waiting","stopping","working","background","starting","failed","crashed"]);function _k(e,t){if(!Nn(e))return e.locked?`Held by ${e.lockReason??"another tool"}`:t.path;if(t.op)return tw(t.op);if(Nr(e.worktree))return y$;const n=Nh(e,t.needsSetup),r=e.worktree.lastTurn;return!_K.has(ks(e))&&r?Fw(r):t.at&&t.at!=="now"?`${n} · ${t.at}`:n}function NK(e,t){if(!Nn(e)||t)return!1;const n=ks(e);return(n==="idle"||n==="asleep")&&!e.unseen}function TK(e){const t=e.worktree.lastTurn,n=e.worktree.landed?Lw(e.worktree.lands):[],r=t?(zo(e.agent)?L5:Fw)(t):void 0,o=fh(e.worktree),i=o&&!e.worktree.landed?As(o):void 0;return[...n,r,i].filter(a=>!!a)}function jK(e,t,n,r){let o;const i=(f,m)=>{const g=m==null?void 0:m[m.length-1];g&&(!o||g.at>o.mark.at)&&(o={title:f,mark:g})};for(const f of e)f.worktree&&i(f.worktree.title,f.worktree.lands);for(const f of t)i(f.title,f.lands);const a=o&&jN(o.mark),c=o?`Landed ${o.title} ${bo(sr(o.mark.at))}${a?`: ${ho(a)}`:"."}`:void 0,u=n?bS(r,n):null,h=u?ho(`${u.charAt(0).toUpperCase()}${u.slice(1)}`):n!=null&&n.fetchedAt?`Level with origin, fetched ${bo(sr(n.fetchedAt))}.`:void 0;return[c,h].filter(f=>!!f)}function $K(e){const t=e.prompt?Fh(e.prompt):"";return[...t?[t]:[],...Lw(e.lands)]}function CK(e){const n=[e.auto&&AK(e.auto,!!e.landed),e.cost!==void 0?Au(e.cost):void 0].filter(r=>!!r);return n.length?n:void 0}function AK(e,t){const{what:n,idle:r}=eA(e);return r?`${t?"":`${n}, `}${r} idle`:n}const W1=25;function IK(e,t){if(e.length<=W1+1)return{shown:e,rest:0};const n=e.slice(0,W1),r=t?e.find(o=>o.id===t):void 0;return r&&!n.includes(r)&&n.push(r),{shown:n,rest:e.length-n.length}}function RK(e,t,n){const r=e.indexOf(t);return r<0?null:e[r+(n?1:-1)]??null}const OK=.5;function MK(e){const t=e.usage,n=t&&t.size>0?t.used/t.size:0,r=[n>=OK?`${Math.round(100*n)}% of context`:void 0,e.queued?`${e.queued} queued`:void 0,(t==null?void 0:t.cost)!==void 0?Au(t.cost):void 0].filter(o=>!!o);return r.length?r:void 0}function PK(e){const t=e.filter(gs).find(n=>n.id==="archive")??null;return[...t?[{id:"archive",label:t.label,icon:"archive",item:t}]:[],{id:"more",label:"more",icon:"more",item:null}]}function LK(e){return e.altKey?"Alt":e.ctrlKey?"Control":e.metaKey?"Meta":null}function DK(e,t){return t==="Alt"?e.altKey:t==="Control"?e.ctrlKey:e.metaKey}const zK=200,v$={set:(e,t)=>setTimeout(e,t),clear:e=>clearTimeout(e)};function FK(e,t=v$){let n=null,r=!1,o=null;const i=()=>{r||(r=!0,e(!0))},a=()=>{o!==null&&(t.clear(o),o=null)},c=()=>{a(),n=null,r&&(r=!1,e(!1))};return{press(u){const h=n!==null;n=LK(u),a(),n&&(h?i():o=t.set(()=>{o=null,i()},zK))},keyup(u){n&&u===n&&c()},mods(u){n&&!DK(u,n)&&c()},end:c}}const BK=350,UK=80,HK=2e3;function WK(e,t=v$){let n=!1,r=null,o=null,i=null,a=null;const c=()=>{r&&(t.clear(r.pending),r=null)},u=()=>{i!==null&&t.clear(i),a!==null&&t.clear(a),i=null,a=null},h=()=>{c(),u(),o=null,n&&(n=!1,e(!1))};return{over(f){u(),a=t.set(h,HK),n||(n=!0,e(!0)),(r==null?void 0:r.id)!==(f==null?void 0:f.id)&&(c(),!(!f||f.id===o)&&(o=null,r={id:f.id,pending:t.set(()=>{r=null,o=f.id,f.land()},BK)}))},leave(){n&&(i!==null&&t.clear(i),i=t.set(h,UK))},end:h}}const ff=e=>e>999?"1k+":String(e);function b$({width:e,placement:t="strip"}){const n=t==="screen",r=Na(),o=P(te=>te.chatSide)==="left"?"right":"left",i=lt(),a=tt(),{host:c}=Wr(),u=xw(),h=u[0]&&Nr(u[0].worktree)?u[0]:null,f=h?u.slice(1):u,m=P(te=>Pl(te,te.activeRepoId)),g=te=>h&&te.id===h.id&&m?{behind:m.behind,dirty:m.dirty}:te,[,w]=S.useState(0);S.useEffect(()=>{const te=setInterval(()=>w(me=>me+1),6e4);return()=>clearInterval(te)},[]);const y=KD(),v=ZD(),N=qD(),x=GD(),_=(te,me,Ge)=>{te.key!=="ArrowLeft"&&te.key!=="ArrowRight"||te.shiftKey||te.altKey||te.metaKey||te.ctrlKey||(te.preventDefault(),Dh([{depth:0,open:me}],0,te.key)&&i({a:Ge}))},T=_a(),j=P(te=>te.notesPage),C=P(te=>te.clientId),M=P(te=>te.frame),I=P(te=>te.activeRepoId),O=P(te=>te.connected);S.useEffect(()=>{a&&O&&I&&a.send({t:"list-archived",repoId:I})},[a,O,I]);const A=Zl(),z=p_(),B=P(te=>te.layout),U=P(te=>te.railOpen),Q=P(te=>te.railPeek),ae=S.useRef(null),[ee,de]=S.useState(!1);ut([Q],()=>{var te;Q&&!n&&!r&&!((te=ae.current)!=null&&te.matches(":hover"))&&de(!0)}),S.useEffect(()=>{if(!ee)return;let te=null;const me=Ge=>{if(!te){te={x:Ge.clientX,y:Ge.clientY};return}Math.abs(Ge.clientX-te.x)+Math.abs(Ge.clientY-te.y)<3||de(!1)};return window.addEventListener("pointermove",me),()=>window.removeEventListener("pointermove",me)},[ee]);const[$,K]=S.useState(!1),V=S.useMemo(()=>WK(K),[]);S.useEffect(()=>()=>V.end(),[V]);const X=P(te=>{var me;return((me=te.dragFiles)==null?void 0:me.at)==="rail"?te.dragFiles.worktreeId:null}),W=P(te=>te.focusRail),se=S.useRef(W),ce=S.useRef(null);ut([W],()=>{if(W===se.current)return;se.current=W;const te=requestAnimationFrame(()=>{var me,Ge;return(Ge=(me=ce.current)==null?void 0:me.querySelector('[data-state~="current"]'))==null?void 0:Ge.focus()});return()=>cancelAnimationFrame(te)});const he=(te,me,Ge,ot,Dt)=>{var mn,L;if(te.key!=="ArrowUp"&&te.key!=="ArrowDown"||te.altKey||te.ctrlKey||te.metaKey)return;te.preventDefault();const Ct=RK(me,Ge,te.key==="ArrowDown");Ct!==null&&(Dt(Ct),(L=(mn=ce.current)==null?void 0:mn.querySelector(`[${ot}="${Ct}"]`))==null||L.focus())},je=P(te=>te.repos),$e=P(te=>te.shipping),q=P(te=>te.rows),H=te=>je.find(me=>me.id===te.repoId)??null,ve=te=>I?hw(te,I,q):null,Se=te=>I&&te.repoId!==I?H(te):null,ye=wn("rail"),J=Un(),we=_w(),ge=P(te=>te.home),Be=te=>{const me=te.worktree?te.worktree.path:te.path;return ge&&me.startsWith(`${ge}/`)?`~${me.slice(ge.length)}`:me},[Ie,We]=S.useState(!1),[pt,rn]=S.useState([]),qt=te=>{!gf(te.worktree)||Se(te)||(We(!0),rn(me=>me.includes(te.worktree.id)?me.filter(Ge=>Ge!==te.worktree.id):[...me,te.worktree.id]))},Ue=()=>{We(!1),rn([])};ut([Ie],()=>{const te=me=>me.key==="Escape"&&Ue();return Ie&&window.addEventListener("keydown",te),()=>window.removeEventListener("keydown",te)});const Qt={sock:a,dispatch:i},an=te=>dw(J.getState(),te),Ft=te=>{We(!0),rn(me=>te===A||me.includes(te)?me:[...me,te])},Qe=te=>Nn(te)?_N(te,H(te),{layout:B,shipping:$e,frame:M,drafted:an},Qt,{...Se(te)?{}:{graft:Ft},hostname:c}):_5(te,{clientId:C,frame:M},Qt,c),[Wt,ln]=S.useState(null),wt=te=>Nn(te)?PK(Qe(te)):[],mt=P(te=>te.left);dN(ce,{rowOf:te=>{if(!n||Ie||HS({left:mt},Date.now()))return null;const me=te.closest(".slide"),Ge=me==null?void 0:me.dataset.row,ot=Ge?u.find(Dt=>Dt.id===Ge):void 0;return me&&Ge&&ot?{el:me,key:Ge,rungs:wt(ot).length}:null},onSlide:ln,onPick:(te,me)=>{var Dt;const Ge=u.find(Ct=>Ct.id===te),ot=Ge?wt(Ge)[me-1]:void 0;if(!(!Ge||!ot)){if(ot.id==="more"){const Ct=(Dt=ce.current)==null?void 0:Dt.querySelector(`.slide[data-row="${te}"]`);Ct&&ye.openUnder(Ct,()=>Qe(Ge),te)}else if(ot.item&&!ot.item.disabled){const Ct=ot.item.onClick;window.setTimeout(Ct,cN)}}}});const Vt=IK(N,(T==null?void 0:T.id)??null),kn=Vt.shown.some(te=>(te.dirty??0)>0),Lt=te=>d.jsxs("button",{type:"button",className:He("row row-edge row-quiet rail-disc-item rail-arch-item",(we==null?void 0:we.owner)==="rail"&&we.key===te.id&&"menu-open"),"data-state":ur({current:!n&&(T==null?void 0:T.id)===te.id}),"data-arch":te.id,...Pt(h6(te),void 0,{placement:o,card:!0,detail:$K(te),aside:CK(te)}),onClick:()=>i({a:"open-archived",id:te.id}),onKeyDown:me=>he(me,Vt.shown.map(Ge=>Ge.id),te.id,"data-arch",Ge=>i({a:"open-archived",id:Ge})),...ye.contextMenu(()=>xf(te,{clientId:C,frame:M},Qt),te.id),children:[d.jsxs("span",{className:"rail-gut",onClick:r?me=>{me.stopPropagation(),ye.openUnder(me.currentTarget,()=>xf(te,{clientId:C,frame:M},Qt),te.id)}:void 0,children:[d.jsx("span",{className:"rail-at row-dim",children:sr(te.archivedAt)}),d.jsx("span",{className:"rail-more",...Pt("Actions"),onClick:me=>{me.stopPropagation(),ye.openUnder(me.currentTarget,()=>xf(te,{clientId:C,frame:M},Qt),te.id)},children:d.jsx(St,{name:"more"})})]}),d.jsx("span",{className:"branch",children:te.title}),kn&&d.jsx("span",{className:"rail-counts",children:d.jsx("span",{className:"rail-count row-dim","data-tip":te.dirty?`${te.dirty} uncommitted, kept`:void 0,children:te.dirty?`~${ff(te.dirty)}`:""})}),te.auto?d.jsx("span",{className:"rail-glyph rail-auto row-dim",children:d.jsx(St,{name:"clock",className:"icon-inline"})}):d.jsx("span",{className:"dot"}),n&&d.jsx("span",{className:"rail-at rail-at-end row-dim",children:sr(te.archivedAt)})]},te.id),Pn=[...u,...y].map(g),_t=["ahead","dirty","behind"].filter(te=>Pn.some(me=>(me[te]??0)>0)),yn=te=>{const me=_t.findIndex(Ge=>(te[Ge]??0)>0);return new Set(me<0?[]:_t.slice(me))},er=te=>{var cn;const me=Nn(te)?te:null,Ge=!!me&&Nr(me.worktree),ot=g(te),Dt=je.find(Yt=>Yt.id===te.repoId)??null,Ct=Dt?dh(Dt):"main",mn=Dt&&zA(Dt)&&(m!=null&&m.fetchedAt)?` as of ${_h(m.fetchedAt)}`:"",L=yn(ot),re=!!ot.ahead&&!ot.dirty,be=te.id,Xe=(we==null?void 0:we.owner)==="rail"&&we.key===be,Nt=me?ve(me):null,Ot=me?Se(me):null,ze=me&&!Ot&&Ie&&gf(me.worktree)&&be!==A,Me=me&&me.worktree.kind==="worktree"&&!Ot?{title:me.worktree.title,branch:me.worktree.branch}:null,Ze=SS(te,(cn=$e[be])==null?void 0:cn.op),Xt=d.jsxs("button",{type:"button",className:He("row row-edge",me?"rail-item":"row-quiet rail-disc-item",n&&NK(te,Ze)&&"row-quiet",Xe&&"menu-open",X===be&&"drop-over"),"data-state":ur({current:!n&&be===A&&!T&&!j,checked:pt.includes(be)}),...me?Pt(z?Tf:Ze?tw(Ze):Nh(te,Uf(H(me))),void 0,{placement:o,card:!0,aside:MK(te),detail:Nr(me.worktree)?jK(u,N,m,Ct):[...Ot?[Nt?EK(Ot.name,Nt.worktree.title):SK(Ot.name)]:[],...TK(me)],dot:z?void 0:Ze?"background":ks(te)}):Pt(z?Tf:te.locked?`Held by ${te.lockReason??"another tool"}`:xK,void 0,{placement:o,card:!0,detail:Be(te),dot:z||te.locked?void 0:"discovered"}),"data-wt":be,draggable:Me!==null,onDragStart:Me!==null?Yt=>lu(Yt,{kind:"worktree",worktreeId:be,...Me}):void 0,onDragEnd:()=>Cu(J),onKeyDown:Yt=>{if(Ie)return;const Kt=(me?u:y).map(Sn=>Sn.id);he(Yt,Kt,be,"data-wt",Sn=>i({a:"activate",id:Sn}))},onClick:Yt=>{me&&!Ot&&(Ie||Yt.shiftKey)?be===A?We(!0):qt(me):Ge&&!n?i({a:"open-draft"}):(i({a:"activate",id:be}),me&&!r&&i({a:"walked"}))},...ye.contextMenu(()=>Qe(te),be),children:[d.jsx("span",{className:"rail-gut",onClick:r&&!Ie?Yt=>{Yt.stopPropagation(),ye.openUnder(Yt.currentTarget,()=>Qe(te),be)}:void 0,children:ze?d.jsx("input",{type:"checkbox",className:"rail-graft-check",checked:pt.includes(be),readOnly:!0,tabIndex:-1}):!Ie&&d.jsxs(d.Fragment,{children:[me&&!Ge&&d.jsx("span",{className:"rail-at row-dim",children:sr(_i(me.worktree))}),d.jsx("span",{className:"rail-more",...Pt("Actions"),onClick:Yt=>{Yt.stopPropagation(),ye.openUnder(Yt.currentTarget,()=>Qe(te),be)},children:d.jsx(St,{name:"more"})})]})}),Ge?d.jsxs("span",{className:"branch rail-main-label",children:[d.jsx(St,{name:"plus",className:"icon-inline"}),"new worktree"]}):d.jsx("span",{className:He("branch",(me==null?void 0:me.worktree.unnamed)&&"row-dim"),children:jg(te,me?H(me):null)}),(me==null?void 0:me.worktree.mode)&&me.worktree.mode!=="auto"&&d.jsx("span",{className:"rail-badge badge-mode","data-tip":`${me.worktree.mode} mode: the agent waits for you`,children:me.worktree.mode}),me&&(()=>{const Yt=H(me),Kt=bN(me.worktree,Yt);return Kt&&Kt!==(Yt==null?void 0:Yt.config.defaultProfile)?d.jsx("span",{className:"rail-badge badge-profile","data-tip":`runs the ${Kt} profile`,children:Kt}):null})(),Ot&&d.jsx("span",{className:"rail-guest row-dim",children:Ot.name}),d.jsxs("span",{className:"rail-counts",children:[L.has("ahead")&&d.jsx("span",{className:"rail-count badge-ahead","data-tip":ot.ahead?`${ot.ahead} ahead of ${Ct}`:void 0,children:ot.ahead?`+${ff(ot.ahead)}`:""}),L.has("dirty")&&!re&&d.jsx("span",{className:"rail-count badge-dirty","data-tip":ot.dirty?`${ot.dirty} uncommitted${Ge?" on main":""}`:void 0,children:ot.dirty?`~${ff(ot.dirty)}`:""}),L.has("behind")&&d.jsx("span",{className:"rail-count rail-behind row-dim","data-tip":ot.behind?`${ot.behind} behind ${Ge?"origin":Ct}${Ge?"":mn}`:void 0,children:ot.behind?ff(ot.behind):""}),n&&me&&d.jsx("span",{className:"rail-at row-dim",children:Ge?"":sr(_i(me.worktree))})]}),(()=>{if(Ze)return d.jsx("span",{className:"dot background"});if(te.locked)return d.jsx("span",{className:"rail-glyph rail-lock row-dim",children:d.jsx(St,{name:"lock",className:"icon-inline"})});if(!me)return d.jsx("span",{className:"dot discovered"});const Yt=Ie||z?null:_S(te.procs),Kt=te.unseen?" unseen":"",Sn=ks(te);return Ge&&!Yt&&Sn!=="crashed"&&!z?d.jsxs(d.Fragment,{children:[d.jsx("span",{className:`dot ${Sn} rail-main-dot`}),d.jsx("span",{className:"rail-glyph rail-main-strip",children:d.jsx(St,{name:"plus"})})]}):!Yt||Sn!=="crashed"?d.jsx("span",{className:`dot ${Sn}${Kt}`}):d.jsx("span",{className:`dot crashed clickable${Kt}`,...Pt(Yt.tip),onClick:An=>{An.stopPropagation(),i({a:"activate",id:be}),i({a:"term-stream",id:be,stream:Yt.stream})}})})(),n&&d.jsx("span",{className:"rail-say row-dim",children:_k(te,{needsSetup:Uf(me?H(me):null),path:Be(te),op:Ze})})]},be);if(!n||!me)return Xt;const Bt=(Wt==null?void 0:Wt.key)===be?Wt.step:null,vn=Bt===null?null:wt(te)[Math.max(0,Bt-1)],Ut=!!vn&&Bt!==null&&Bt>0&&(vn.id==="more"||!!vn.item&&!vn.item.disabled);return d.jsxs("div",{className:"slide","data-row":be,children:[Xt,vn&&d.jsxs("span",{className:"slide-verb","data-rung":Ut?vn.id:void 0,"aria-hidden":"true",children:[d.jsx("span",{className:"slide-word",children:vn.label}),d.jsx(St,{name:vn.icon})]})]},be)};return d.jsx("div",{ref:ae,className:He("rail",n&&"rail-screen",!n&&(Ie||(we==null?void 0:we.owner)==="rail"||Q||$)&&"hold",ee&&"quiet",(n||U)&&"pinned",z&&"offline"),style:e!==void 0&&!n?{"--rail-width":`${e}px`}:void 0,onClick:r&&!n&&!U?te=>{te.target instanceof Element&&te.target.closest("button, .rail-gut")||i({a:"toggle-rail"})}:void 0,onDragOver:te=>{var Dt;if(!Ug(te.dataTransfer))return;const me=te.target instanceof Element?(Dt=te.target.closest("[data-wt]"))==null?void 0:Dt.dataset.wt:void 0,Ge=me?[...u,...y].find(Ct=>Ct.id===me):void 0;if(!Ge||Ie||Ge.id===A)return V.over(null);const ot=!n&&Nn(Ge)&&Nr(Ge.worktree);V.over({id:Ge.id,land:()=>i(ot?{a:"open-draft"}:{a:"activate",id:Ge.id})})},onDragLeave:V.leave,onDrop:V.end,children:d.jsxs("div",{className:"rail-panel","data-tip":z?Tf:void 0,"data-tip-placement":"follow",children:[d.jsxs("div",{className:"rail-list",ref:ce,children:[h&&!n&&er(h),f.map(er),Ie&&d.jsxs("div",{className:"rail-graft",children:[(()=>{const te=u.find(ot=>ot.worktree.id===A&&gf(ot.worktree)&&!Se(ot)),me=pt.filter(ot=>ot!==(te==null?void 0:te.worktree.id)),Ge=me.map(ot=>{var Dt;return((Dt=u.find(Ct=>Ct.worktree.id===ot))==null?void 0:Dt.worktree.title)??ot}).join(", ");return d.jsxs(De,{size:"md",tone:"primary",disabled:!te||me.length===0,"data-tip":te?`Merge the checked worktrees into ${te.worktree.title} and remove them`:"Select a worktree to graft onto",onClick:()=>{te&&window.confirm(`Graft ${Ge} onto ${te.worktree.title}?
|
|
261
|
+
|
|
262
|
+
Their branches are merged in, then their directories and branches are removed.`)&&(a==null||a.send({t:"graft",targetId:te.worktree.id,sourceIds:me}),Ue())},children:["graft ",me.length]})})(),d.jsxs(De,{size:"md",disabled:!pt.some(te=>{var me;return(((me=u.find(Ge=>Ge.worktree.id===te))==null?void 0:me.behind)??0)>0}),"data-tip":"Pull main into every selected worktree that's behind",onClick:()=>{for(const te of pt){const me=u.find(Ge=>Ge.worktree.id===te);((me==null?void 0:me.behind)??0)>0&&Ei(a,i,{t:"sync-main",worktreeId:te})}Ue()},children:[d.jsx(St,{name:"pull",className:"icon-inline"})," sync"]}),d.jsx(De,{size:"md",tone:"danger",disabled:pt.length===0,"data-tip":"Archive all selected worktrees; their chats and work are kept",onClick:()=>{window.confirm(`Archive ${pt.length} worktree(s)?
|
|
263
|
+
|
|
264
|
+
Their directories and branches go. The chats, commits and any uncommitted changes are kept, and each can be restored.`)&&($l(a,i,pt),Ue())},children:"archive…"}),d.jsx(Rt,{icon:"close",label:"Cancel",hint:"esc",onClick:Ue})]}),!Ie&&y.length>0&&d.jsxs(d.Fragment,{children:[d.jsxs("button",{className:"section-title section-row section-fold rail-disc-head","aria-expanded":v,...Pt(`${y.length} worktree${y.length===1?"":"s"} here that Toyon did not make`,void 0,{placement:o}),onClick:()=>i({a:"toggle-discovered"}),onKeyDown:te=>_(te,v,"toggle-discovered"),children:[d.jsx("span",{className:"rail-gut",children:d.jsx(St,{name:"caret",className:He("icon-inline disc-caret",!v&&"shut")})}),d.jsx("span",{className:"rail-label",children:"discovered"})]}),v&&y.map(er)]}),!Ie&&N.length>0&&d.jsxs(d.Fragment,{children:[d.jsxs("button",{type:"button",className:"section-title section-row section-fold rail-disc-head","aria-expanded":x,...Pt(`${N.length} archived worktree${N.length===1?"":"s"}, kept with ${N.length===1?"its chat":"their chats"}`,void 0,{placement:o}),onClick:()=>i({a:"toggle-archived"}),onKeyDown:te=>_(te,x,"toggle-archived"),children:[d.jsx("span",{className:"rail-gut",children:d.jsx(St,{name:"caret",className:He("icon-inline disc-caret",!x&&"shut")})}),d.jsx("span",{className:"rail-label",children:"archived"})]}),x&&Vt.shown.map(Lt),x&&Vt.rest>0&&I&&d.jsxs("button",{type:"button",className:"row row-quiet rail-disc-item rail-arch-item",...Pt("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:[Vt.rest," more"]}),d.jsx("span",{className:"dot"})]})]})]}),!n&&d.jsx("div",{className:"rail-foot",children:d.jsx(Rt,{icon:"worktrees",label:"Worktree panel",hint:zt("rail"),tone:"chrome",on:U,onClick:()=>i({a:"toggle-rail"})})})]})})}const ah=["home","chat","preview","changes"],KK=(e,t)=>ah.indexOf(t)<ah.indexOf(e)?"left":"right";function ZK(e,t,n,r=null){if(e==="home")return t!=="left"||!r||r==="home"?null:r==="preview"&&!n?"chat":r;const o=ah.filter(a=>a!=="preview"||n),i=o.indexOf(e);return i<0?null:o[i+(t==="right"?-1:1)]??null}function qK({screen:e,tabs:t,fold:n,beside:r=!1,away:o=!1}){const i=lt(),a=is(),c=mo(),u=P(he=>he.reading),h=P(he=>he.typing),f=XD(),m=ql(),g=P(he=>he.repos),w=Ps(),y=Zl(),v=_a(),N=Ew(),x=xw(),_=p_(),T=P(he=>he.connectFailure),j=P(he=>he.recalledAt??he.heardAt);xi(_&&j!==null?j:void 0);const C=bK(T,j),M=a_(),I=V8(x,y,M),O=x.find(he=>Nr(he.worktree)),A=e==="home",z=!A&&!v&&!!w&&Nr(w.worktree),B=P(he=>{var je;return z&&w?SS(w,(je=he.shipping[w.id])==null?void 0:je.op):null}),U=gw().length,Q=a.displayName(c.origin),ae=A?(f==null?void 0:f.name)??Q:z?y$:(v==null?void 0:v.title)??(w==null?void 0:w.worktree.title)??(N==null?void 0:N.name)??null,ee=x.filter(he=>!Nr(he.worktree)).length,de=ee===0?"no worktrees yet":`${ee} ${ee===1?"worktree":"worktrees"}`,$=P(he=>he.sharing),K=A?_?C:$||(f&&U>1?`${Q} · ${de}`:de):v?BN(v):_?C:z?B?tw(B):(f==null?void 0:f.name)??null:w?_k(w,{needsSetup:Uf(m),path:w.worktree.path,at:sr(_i(w.worktree))}):N?_k(N,{needsSetup:!1,path:N.path}):null,V=!A&&!v&&!!w&&ks(w)==="waiting",X=P(he=>{var je;return((je=he.overlay)==null?void 0:je.kind)==="projects"&&he.overlay.form==="pill"})&&!r,W=P(he=>{var je;return((je=he.overlay)==null?void 0:je.kind)==="commands"})&&!r,se=d.jsxs("div",{className:"phone-title",children:[A&&(g.length>1||U>1)?d.jsxs("span",{className:"phone-drop phone-switch",children:[d.jsxs(De,{tone:"chrome",on:X,onClick:()=>i({a:"toggle",overlay:{kind:"projects",form:"pill"}}),children:[d.jsx("span",{className:"phone-name",children:ae}),d.jsx(St,{name:"caret",className:"icon-inline"})]}),X&&d.jsx(_y,{form:"pill",anchored:{margin:6}})]}):d.jsx("span",{className:"phone-name",children:ae}),K&&d.jsx("span",{className:He("phone-sub",V&&"phone-sub-asks"),children:K})]}),ce=I&&d.jsxs(De,{size:"md",tone:"primary",onClick:()=>{const he=Y8(x,y,M);if(!he)return;if(he.origin===null)return i({a:"activate",id:he.activate});const je=a.get(he.origin);je&&(je.store.dispatch({a:"activate",id:he.activate}),a.activate(he.origin))},children:[I.n," ",I.tier]});return d.jsxs("div",{className:"phone-bar",children:[d.jsxs("div",{className:"phone-bar-row",children:[!A&&d.jsx(Rt,{icon:"back",label:"Worktrees",tone:"chrome",onClick:()=>i({a:"screen",to:"home"})}),t?d.jsx("div",{className:"phone-tabs",children:t}):se,!t&&ce,A&&O&&d.jsx(Rt,{icon:"plus",label:"New worktree",tone:"chrome",onClick:()=>i({a:"activate",id:O.id})}),d.jsxs("span",{className:"phone-drop",children:[d.jsx(Rt,{icon:"more",label:"Menu",tone:"chrome",on:W,onClick:()=>i({a:"toggle",overlay:{kind:"commands"}})}),W&&d.jsx(Gj,{anchored:{flip:"align",margin:6},trailing:d.jsx(Rt,{icon:"close",label:"Close",tone:"chrome",onClick:()=>i({a:"close"})})})]})]}),t&&!n&&d.jsx("div",{className:"phone-title-seat","data-away":u||h||o||void 0,children:d.jsxs("div",{className:"phone-title-strip",children:[se,ce]})})]})}const jf="toyonDepth",x$="toyonOver",lg=-1;function cg(e){return e.frame!=="phone"||!e.heard&&e.recalledAt===null?null:e.screen!=="home"&&(No(e,e.activeId)!==null||Fo(e)!==null)?1+(e.editor?1:0):0}const E$=(()=>{const e=new Set;return{watch(t){return e.add(t),()=>e.delete(t)},tell(t){for(const n of e)n(t)}}})(),ug=e=>{const t=e&&typeof e=="object"?e[jf]:void 0;return typeof t=="number"?t:null},GK=e=>!!e&&typeof e=="object"&&e[x$]===!0;function VK(e,t=window,n=zl,r=E$){const o=t.history;let i=ug(o.state)??lg,a=ug(o.state)!==null,c=null;const u=()=>{const T=n.open();c&&!T.includes(c)&&(c=null);for(let j=T.length-1;j>=0;j--){const C=T[j];if(C!=null&&C.dismiss&&C!==c)return C}return null};let h=!1;const f=()=>{const T=cg(e.getState());if(T===null||h)return;a||(o.replaceState({[jf]:lg},""),a=!0);const j=T+(u()?1:0);if(j!==i)if(j>i){for(let C=i+1;C<=j;C++)o.pushState({[jf]:C,[x$]:C>T},"");i=j}else o.go(-1),h=!0};let m=!1;const g=()=>{m||(m=!0,queueMicrotask(()=>{m=!1,f()}))},w=(T,j)=>{const C=u();if(C){c=C,n.shut(C);return}const M=j===0?"home":T.screen;e.dispatch({a:"screen",to:M})},y=T=>{const j=h;h=!1,i=ug(T.state)??lg;const C=e.getState(),M=cg(C);if(M===null)return;if(i<0){o.pushState({[jf]:0},""),i=0,f();return}if(j){f();return}const I=M+(u()?1:0);I!==i&&(I>i?w(C,i):I===0&&C.activeId&&!GK(T.state)&&e.dispatch({a:"screen",to:"chat"}),f())},v=T=>{if(h){h=!1,f();return}const j=e.getState(),C=cg(j);C===null||C===0||j.screen==="preview"&&!j.editor&&C===1||T.dir==="forward"||w(j,C+(u()?1:0)-1)};t.addEventListener("popstate",y);const N=e.subscribe(f),x=n.watch(g),_=r.watch(v);return f(),()=>{t.removeEventListener("popstate",y),N(),x(),_()}}function YK({gated:e,active:t,url:n,onTouch:r}){const o=jh(t),i=_3(mo(),o?n:null,e),a=S.useRef(null),c=S.useRef(r);return c.current=r,S.useEffect(()=>{if(!i)return;const u=new URL(i,location.href).origin,h=f=>{var w,y;const m=(w=a.current)==null?void 0:w.contentWindow;if(!m||f.source!==m||f.origin!==u||!((y=f.data)!=null&&y.__toyon))return;const g=rS(f.data);(g==null?void 0:g.type)==="traversed"?E$.tell({dir:g.dir??null}):(g==null?void 0:g.type)==="touch"?c.current(g):(g==null?void 0:g.type)==="loaded"&&m.postMessage({__toyon:!0,type:"touches",on:!0},u)};return window.addEventListener("message",h),()=>window.removeEventListener("message",h)},[i]),d.jsx("div",{className:"phone-preview",children:o&&i?d.jsx("iframe",{ref:a,className:"phone-preview-frame",src:i,title:t.worktree.title}):d.jsx(ys,{wide:!0,children:d.jsx("p",{className:"status-line",children:Nh(t)})})})}function XK(e){return e.incompatible?{kind:"updated",foreign:e.serving?null:e.machine}:e.said?{kind:"say"}:e.onWorktree?e.editor?{kind:"editor"}:{kind:"tab",tab:e.tab}:{kind:"home"}}const QK=zf(),JK=!eN(),eZ={current:null};function tZ(){const e=S.useRef(null),t=S.useRef(null),n=S.useRef(null);FD(e),BD(e);const r=lt(),o=P(ce=>ce.screen),i=Ps(),a=_a(),c=Ew(),u=P(ce=>ce.editor),h=P(ce=>ce.left),f=P(ce=>ce.remote),m=Tu(),g=P(ce=>ce.connected),w=P(ce=>ce.heard),y=P(ce=>ce.recalledAt!==null||ce.heard),v=P(ce=>ce.connectFailure),N=Na(),x=mo(),_=is(),[T,j]=S.useState(null),[C,M]=S.useState(null),I=P(ce=>ce.incompatible),O=mN({connected:g,heard:w,standing:y,connectFailure:v,hasToken:x.serving?QK:!0,projectChord:zt("project"),title:(i==null?void 0:i.worktree.title)??null,machine:x.serving?null:_.displayName(x.origin)}),A=o!=="home"&&(i!==null||a!==null||c!==null),z=!A&&T!==null&&T!=="home",B=!m&&!a?i:null,U=A||z?B:null,{host:Q}=Wr(),ae=U?xS(U.worktree.id,U.worktree.proxyPort,f,Q):null,ee=o==="preview"&&!U?"chat":o,de=XK({incompatible:I,serving:x.serving,machine:_.displayName(x.origin),said:O!==null,onWorktree:A,editor:u!==null,tab:ee}),$=de.kind==="home"?"home":de.kind==="tab"?de.tab:null,K=U!==null&&ae!==null,V=a5(JK?e:eZ,{take:(ce,he)=>{if(T!==null)return null;const je=de.kind==="tab"?de.tab:de.kind==="home"?"home":null;if(!je)return null;const $e=je==="home"?HS({left:h},Date.now()):null;if(he==="left"&&!$e&&ce.closest(".slide"))return null;const q=ZK(je,he,B!==null,$e);return q?(j(q),(q==="home"||je==="home"?t:n).current):null},onSettle:ce=>{ce&&T&&M(T)},onEnd:ce=>{ce&&T&&r({a:"screen",to:T}),j(null),M(null)}}),X=(ce,he)=>d.jsx(qK,{screen:ce==="home"?"home":"chat",beside:he,fold:ce!=="chat"||u!==null,away:!he&&T!==null&&T!=="home",tabs:ce!=="home"&&O===null&&d.jsx(Lh,{fill:!0,segmented:!0,owner:"phone-tabs",label:"worktree",items:se,current:C&&C!=="home"?C:ce,onPick:je=>r({a:"screen",to:je})})}),W=de.kind==="updated"?d.jsx(pN,{foreign:de.foreign??void 0}):de.kind==="say"&&O?d.jsx(ys,{wide:!0,children:d.jsx("p",{className:He("status-line",O.live&&"live-text"),children:O.text})}):de.kind==="editor"&&u?d.jsx(d$,{editor:u,placement:"screen"}):null,se=[{id:"chat",label:"chat"},...U&&ae?[{id:"preview",label:"preview",trail:d.jsx(Rt,{icon:"external",label:"Open in browser",tone:"chrome",onClick:()=>N3(x,ae,Hg(x,f))})}]:[],{id:"changes",label:"code"}];return d.jsxs("div",{ref:e,className:"app phone","data-chat-side":"left","data-touch":N||void 0,"data-hover":!N||void 0,children:[d.jsx(oN,{}),d.jsx(lN,{}),d.jsx("div",{className:"phone-screen",children:d.jsxs("div",{className:"center-root",children:[d.jsxs("div",{className:"phone-track",ref:t,children:[(!A||T==="home")&&d.jsxs("div",{className:"phone-face","data-side":A?"left":void 0,children:[X("home",A),!A&&$===null?W:d.jsx(b$,{placement:"screen"})]},"home"),(A||z)&&d.jsxs("div",{className:"phone-face","data-side":z?"right":void 0,children:[X(z&&T?T:ee,z),d.jsxs("div",{className:"phone-track",ref:n,children:[$===null&&d.jsx("div",{className:"phone-face",children:W},"cover"),ah.map(ce=>{if(ce==="home")return null;const he=z?ce===T:ce===$,je=ce===T&&!he;return!he&&!je&&!(ce==="preview"&&K)?null:d.jsx("div",{className:"phone-face",hidden:!he&&!je,"data-side":je&&$?KK($,ce):void 0,children:ce==="chat"?d.jsx(Xc,{placement:"screen",archived:a,found:c}):ce==="changes"?d.jsx(DN,{placement:"screen"}):U&&ae?d.jsx(YK,{gated:Hg(x,f),active:U,url:ae,onTouch:V},U.worktree.id):null},ce)})]})]},"worktree")]}),d.jsx(w$,{})]})})]})}function nZ(){try{const e=localStorage.getItem(Ke.theme);if(e){const t=JSON.parse(e);if(t!=null&&t.colors&&typeof t.colors.surface0=="string")return t}}catch{}return Su}function rZ(){if(Ow()!=="phone")return"surface0";try{const e=sessionStorage.getItem(Ke.ground);if(e==="surface0"||e==="surface1")return e}catch{}return"surface1"}function S$(e,t={}){var i,a;const n=document.documentElement;for(const[c,u]of Object.entries(fL(e)))n.style.setProperty(c,u);n.style.colorScheme=e.kind,n.dataset.theme=e.kind;const r=t.ground??rZ();n.dataset.ground=r;const o=Ow()==="phone"?e.colors[r]:e.colors.surface1;if((i=document.querySelector('meta[name="theme-color"]'))==null||i.setAttribute("content",o),(a=document.querySelector('link[rel="manifest"]'))==null||a.setAttribute("href",t.black?"/manifest.json?black=1":"/manifest.json"),t.remember!==!1)try{localStorage.setItem(Ke.theme,JSON.stringify(e))}catch{}}function _$(e){const t=Vk(e);return{type:"theme",accent:t,accentFg:bL(t)}}function oZ(){var e;return((e=window.matchMedia)==null?void 0:e.call(window,"(prefers-color-scheme: dark)").matches)??!0}const sZ=12*36e5;function iZ(){try{const e=localStorage.getItem(Ke.daylight);if(!e)return null;const t=JSON.parse(e);if(typeof(t==null?void 0:t.dark)!="boolean"||typeof t.until!="number")return null;const n=Date.now()-t.until;return n<0?t:n<sZ?{dark:!t.dark,until:0}:null}catch{return null}}function aZ(e){try{localStorage.setItem(Ke.daylight,JSON.stringify(e))}catch{}}function lZ(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 cZ(e,t){return{word:`what's new in ${t}`,text:`Toyon updated from ${e} to ${t} since you last opened it here. Press to read what changed`}}function K1(e,t){return t==="reading"?"Reading the release notes":`No release notes could be read from Toyon ${e}.`}function uZ(){const e=Wr(),t=P(i=>i.version),[n,r]=S.useState(void 0);S.useEffect(()=>{let i=!0;return RL(e).then(a=>{i&&r(a)}),()=>{i=!1}},[e]);const o=Gh(n??"",{keepHtml:!0});return n?d.jsx("div",{className:"notes-page",children:d.jsx(l$,{html:o})}):d.jsx(ys,{wide:!0,children:d.jsx("p",{className:"status-line",children:n===void 0?d.jsx("span",{className:"live-text",children:K1(t,"reading")}):K1(t,"missing")})})}function Nk(e,t){return[{id:"copy-name",label:"copy name",detail:e,onClick:()=>tn(e)},{id:"copy-value",label:"copy value",detail:t,onClick:()=>tn(t)}]}function Tk(e){return[{id:"copy-value",label:"copy value",detail:e,onClick:()=>tn(e)}]}function dZ(e,t,{sock:n},r){return t?Bn([[{id:"source",label:"open source",onClick:r}],Uo(()=>n==null?void 0:n.send({t:"reveal",worktreeId:e.id,path:t}),Bo(n)),[{id:"copy-path",label:"copy path",onClick:()=>tn(t)}]]):[]}function bu(e){const t=/^#([0-9a-f]{3,8})$/i.exec(e.trim());if(!t)return null;const n=t[1],r=n.length===3||n.length===4?[...n].map(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 fZ(e){const t=/^#([0-9a-f]{3,8})$/i.exec(e.trim());return t?t[1].length===4||t[1].length===8:!1}function Z1([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 N$(e,t){if(fZ(e))return null;const n=bu(e);if(!n)return null;const r=bu(t);if(!r)return null;const[o,i]=[Z1(n),Z1(r)];return`${((Math.max(o,i)+.05)/(Math.min(o,i)+.05)).toFixed(2)}:1`}function hZ({worktreeId:e,height:t,full:n,onToggleFull:r,onDragStart:o}){const i=lt(),a=tt(),c=P(h=>Xr(h,e).design);S.useEffect(()=>{c||a==null||a.send({t:"design-scan",worktreeId:e})},[c,e,a]),S.useEffect(()=>()=>dn.post(e,{type:"highlight-clear"}),[e]);const u={outline:h=>dn.post(e,h),clear:()=>dn.post(e,{type:"highlight-clear"}),open:h=>Fn({dispatch:i},{worktreeId:e,path:h})};return d.jsx(Sy,{kind:"design",className:He("design-pane",n&&"full"),height:n?void 0:t,resizable:!n,onDragStart:o,title:c?d.jsx("span",{children:kZ(c)}):void 0,onClose:()=>i({a:"toggle-design"}),closeHint:zt("design"),full:n,onToggleFull:r,actions:d.jsxs(De,{variant:"outline",onClick:()=>a==null?void 0:a.send({t:"design-scan",worktreeId:e}),"data-tip":"Scan this worktree again",children:[d.jsx(St,{name:"reload",className:"icon-inline"})," rescan"]}),children:c?d.jsxs("div",{className:"design-body",style:gZ,onMouseLeave:u.clear,children:[c.tokens.length===0&&c.literals.length>0?d.jsx(EZ,{literals:c.literals,outline:u.outline,clear:u.clear}):d.jsx(bZ,{tokens:c.tokens,coverage:c.coverage,outline:u.outline,clear:u.clear}),d.jsx(IZ,{index:c,outline:u.outline,clear:u.clear,onOpen:u.open}),d.jsx(RZ,{index:c,outline:u.outline,clear:u.clear,onOpen:u.open})]}):d.jsx("div",{className:"empty",children:d.jsx("span",{className:"live-text",children:"reading the design system"})})})}const pZ=720,mZ=132,gZ={"--design-column":`${pZ}px`,"--design-cell":`${mZ}px`};function kZ(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 El=e=>`${e} use${e===1?"":"s"}`;function rp({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 lh({children:e}){return d.jsx("p",{className:"design-gap",children:e})}const wZ=[{kind:"font",label:"type"},{kind:"color",label:"color"},{kind:"length",label:"size & radius"},{kind:"shadow",label:"shadow"},{kind:"other",label:"computed"}];function yZ(e){return e.find(t=>t.kind==="color"&&bu(t.resolved??t.value)!==null)}function vZ(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 bZ({tokens:e,coverage:t,outline:n,clear:r}){const o=yZ(e),i=o&&(o.resolved??o.value),a=new Map;for(const u of e){const h=(u.resolved??u.value).trim().toLowerCase();a.set(h,[...a.get(h)??[],u.name])}const c=u=>(a.get((u.resolved??u.value).trim().toLowerCase())??[]).filter(h=>h!==u.name);return d.jsx(rp,{title:"Tokens",children:e.length===0?d.jsx(lh,{children:vZ(t)}):wZ.map(({kind:u,label:h})=>{const f=e.filter(g=>g.kind===u);if(f.length===0)return null;const m=j$(f.map(g=>g.value));return d.jsxs("div",{className:"design-group",children:[u!=="font"&&d.jsx("span",{className:"design-group-name",children:h}),u==="font"?d.jsx($$,{groups:jZ(f),outline:n,clear:r}):d.jsx("div",{className:"design-breakout",style:T$(f.length),children:d.jsx("div",{className:"design-grid",children:f.map(g=>{const w=g.resolved??g.value,y=g.kind==="color"&&i?N$(w,i):null;return d.jsx(C$,{kind:g.kind,name:g.name,lines:g.resolved?[g.value,g.resolved]:[g.value],actual:w,ratio:y,largest:m,tipText:CZ(g,y,o,c(g)),menu:()=>Nk(g.name,w),outline:n,clear:r},g.name)})})})]},u)})})}const xZ=[{role:"color",kind:"color",label:"color"},{role:"radius",kind:"length",label:"radius"},{role:"shadow",kind:"shadow",label:"shadow"}];function EZ({literals:e,outline:t,clear:n}){const r=e.find(i=>i.ground&&bu(i.value)!==null),o=$Z(e);return d.jsxs(rp,{title:"Values",note:"written out in the rules; no custom properties",children:[o.length>0&&d.jsx("div",{className:"design-group",children:d.jsx($$,{groups:o,outline:t,clear:n})}),xZ.map(({role:i,kind:a,label:c})=>{const u=e.filter(f=>f.role===i);if(u.length===0)return null;const h=j$(u.map(f=>f.value));return d.jsxs("div",{className:"design-group",children:[d.jsx("span",{className:"design-group-name",children:c}),d.jsx("div",{className:"design-breakout",style:T$(u.length),children:d.jsx("div",{className:"design-grid",children:u.map(f=>{const m=a==="color"&&r?N$(f.value,r.value):null;return d.jsx(C$,{kind:a,name:f.value,lines:[El(f.uses)],actual:f.value,ratio:m,largest:h,tipText:AZ(f,m,r),menu:()=>Tk(f.value),outline:t,clear:n},f.value)})})})]},i)})]})}function T$(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 j$(e){return e.reduce((t,n)=>Math.max(t,Math.abs(Number.parseFloat(n))||0),0)}const SZ=["color","background-color","border-top-color","border-right-color","border-bottom-color","border-left-color","outline-color"];function _Z(e,t){if(!e)return[];const n=getComputedStyle(e);return t.map(r=>[r,n.getPropertyValue(r)])}const jk=e=>(e.split(",")[0]??e).replace(/["']/g,"").trim();function NZ(e){const t=/^[1-9]00\s+([\d.]+)px(?:\s*\/\s*([\d.]+)(px)?)?\s+(.+)$/.exec(e.trim());if(!t)return{family:jk(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:jk(t[4]??""),size:n,lead:o}}function dg(e){const t=Number.parseFloat(e);return e.endsWith("em")?t*16:e.endsWith("pt")?t*4/3:e.endsWith("%")?t/100*16:t}function TZ(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 jZ(e){const t=e.map(n=>({token:n,actual:n.resolved??n.value,...NZ(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}
|
|
265
|
+
${o.actual}`:void 0,menu:()=>o?Nk(o.token.name,o.actual):[],rows:r.filter(i=>i.size!==null).sort((i,a)=>(a.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}
|
|
266
|
+
${i.actual}`,menu:()=>Nk(i.token.name,i.actual)}))}})}function $Z(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),a=o==="initial"?"default face":jk(o);return{family:a,stack:o,name:i?El(i.uses):void 0,label:a,tipText:i?`${i.value}
|
|
267
|
+
${El(i.uses)}: ${i.selectors.join(", ")}`:void 0,menu:()=>i?Tk(i.value):[],rows:n.filter(c=>(c.family??"initial")===o).sort((c,u)=>dg(u.value)-dg(c.value)).map(c=>{const u=dg(c.value),h=TZ(c.lead,u),f=c.value.endsWith("px")?`${u}`:c.value;return{key:`${c.value}/${c.lead??""}`,sample:`${a} ${f}${h===null?"":`/${h}`}`,style:{fontFamily:o,fontSize:c.value,lineHeight:c.lead},name:El(c.uses),label:c.value,tipText:`${c.value}${c.lead?` / ${c.lead}`:""}
|
|
268
|
+
${El(c.uses)}: ${c.selectors.join(", ")}`,menu:()=>Tk(c.value)}})}})}function $$({groups:e,outline:t,clear:n}){const r=(i,a,c)=>t({type:"highlight-computed",props:_Z(i.currentTarget.querySelector(".design-face-sample"),a?["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:a=>r(a,!1,i.label),onMouseLeave:n,...o.contextMenu(i.menu),...i.tipText?Pt(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(a=>d.jsxs("div",{className:"design-face row-edge",onMouseEnter:c=>r(c,!0,a.label),onMouseLeave:n,...o.contextMenu(a.menu),...Pt(a.tipText,void 0,{placement:"follow"}),children:[d.jsx("span",{className:"design-face-sample",style:a.style,children:a.sample}),d.jsx("span",{className:"design-face-name row-dim",children:a.name})]},a.key))]},i.stack))})}function C$({kind:e,name:t,lines:n,actual:r,ratio:o,largest:i,tipText:a,menu:c,outline:u,clear:h}){const f=e==="color"&&bu(r)!==null,m=e==="length"?Number.parseFloat(r):Number.NaN,g=wn("design");return d.jsxs("div",{className:"design-cell","data-kind":e,...g.contextMenu(c),onMouseEnter:f?w=>{const y=w.currentTarget.querySelector(".design-fill"),v=y?getComputedStyle(y).backgroundColor:"";u({type:"highlight-computed",props:SZ.map(N=>[N,v]),match:"any",label:t})}:void 0,onMouseLeave:f?h:void 0,...Pt(a),children:[e==="color"&&d.jsx("div",{className:"design-sample",children:f&&d.jsx("span",{className:"design-fill",style:{background:r}})}),d.jsxs("div",{className:"design-plate",children:[d.jsx("span",{className:"design-cell-name",children:t}),n.map((w,y)=>d.jsxs("span",{className:"design-cell-line",children:[d.jsx("span",{className:"design-cell-value",children:w}),y===0&&o&&d.jsx("span",{className:"design-cell-note",children:o})]},w)),Number.isFinite(m)&&i>0&&d.jsx("span",{className:"design-scale",style:{width:`${Math.max(2,Math.abs(m)/i*100)}%`}})]})]})}function CZ(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(`
|
|
269
|
+
`)}function AZ(e,t,n){const r=[e.value,`${El(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(`
|
|
270
|
+
`)}function A$({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 IZ({index:e,outline:t,clear:n,onOpen:r}){const{components:o,typed:i}=e;if(o.length===0)return null;const a=o.filter(h=>h.imports>=2),c=o.filter(h=>h.imports<2),u=h=>d.jsx(I$,{count:h.imports,name:h.name,path:h.path,onEnter:()=>t({type:"highlight-file",path:h.path,ranges:null}),onLeave:n,onOpen:()=>r(h.path),children:h.variants.length>0&&d.jsx("span",{className:"design-variants",children:h.variants.map(f=>d.jsxs("span",{className:"design-variant",children:[f.prop,": ",f.values.join(" · ")]},f.prop))})},`${h.path}:${h.name}`);return d.jsxs(rp,{title:"Components",note:`${a.length} reused of ${o.length}`,children:[!i&&d.jsx(lh,{children:"No TypeScript in this project, so the values each prop allows are not listed."}),d.jsx(A$,{shared:a.map(u),rest:c.map(u)})]})}function RZ({index:e,outline:t,clear:n,onOpen:r}){const{classes:o,coverage:i}=e,a=o.filter(g=>g.uses>0),c=o.filter(g=>g.uses>=2),u=o.filter(g=>g.uses<2),h=c.filter(g=>g.unwrapped).length,f=o.length?`${c.length} reused of ${o.length}`+(h?`, ${h} with no component of their name`:""):void 0,m=g=>d.jsx(OZ,{cls:g,outline:t,clear:n,onOpen:r},g.name);return d.jsx(rp,{title:"Classes",note:f,children:o.length===0?d.jsx(lh,{children:"No stylesheet in this project defines a class. Utility-first CSS generates its own."}):a.length===0?d.jsx(lh,{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(A$,{shared:c.map(m),rest:u.map(m)})})}function OZ({cls:e,outline:t,clear:n,onOpen:r}){return d.jsx(I$,{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 I$({count:e,name:t,path:n,onEnter:r,onLeave:o,onOpen:i,children:a}){const c=Ps(),u=tt();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?dZ({id:c.worktree.id},n,{sock:u},i):[]),children:[d.jsx("span",{className:"design-count row-dim",children:e}),d.jsx("span",{className:"design-name",children:t}),d.jsx("span",{className:"design-path row-dim",children:n}),a]})})}function MZ({worktreeId:e,procs:t,borrowed:n,login:r,current:o,onRestart:i}){const a=tt();lt();const c={sock:a},u=(f,m)=>d.jsx(Rt,{icon:"reload",label:m,onClick:()=>i(f)}),h={id:Os,label:"login",tip:Pt("The agent's login; it closes once you are in",void 0,{placement:"top"}),trail:u(Os,"Run the login again")};return r&&o===Os?[h]:[{id:Po,label:"shell",tip:Pt("A shell in this worktree",void 0,{placement:"top"}),menu:()=>ET(e,c),trail:u(Po,"Restart the shell")},...r?[h]:[],...t.map(f=>({id:f.name,label:f.name,lead:d.jsx("span",{className:`dot ${f.status}`}),tip:Pt(m4(f.status),void 0,{placement:"top",dot:f.status,name:f.name,detail:f.command,aside:[`:${f.port}`]}),menu:()=>sy(f,e,c),trail:u(f.name,`Restart ${f.name}`)})),...n.map(f=>({id:f,label:f,lead:d.jsx("span",{className:"dot borrowed"}),tip:Pt(`${f} runs on main for every worktree; this one reaches it at its usual address`,void 0,{placement:"top"})}))]}const PZ=S.lazy(()=>bk(()=>import("./XTerm-DsUQ0Xew.js"),__vite__mapDeps([3,4]))),LZ=[];function DZ({worktreeId:e,opened:t,height:n,onDragStart:r}){const o=lt(),i=tt(),a=Ch(),c=P(B=>B.connected),u=P(B=>B.focusTerm),h=Ps(),f=(h==null?void 0:h.procs)??[],m=(h==null?void 0:h.borrowed)??LZ,g=(h==null?void 0:h.login)??!1,w=It(e,"termStream"),y=P(B=>{var U;return((U=B.termRun)==null?void 0:U.id)===e&&w===Po?B.termRun.command:null}),[v,N]=S.useState(null),x=m.includes(w);S.useEffect(()=>{w===Po||(w===Os?g:f.some(U=>U.name===w)||m.includes(w))||o({a:"term-stream",id:e,stream:Po})},[f,m,g,w,e,o]);const _=B=>{B!==w&&(N(null),o({a:"term-stream",id:e,stream:B}))},T=S.useRef(!1),[j,C]=S.useState(0),M=B=>{B===Po&&B===w&&(T.current=!0),i==null||i.send({t:"term-restart",worktreeId:e,stream:B}),B===Os&&B===w&&(N(null),C(U=>U+1))},I=(B,U)=>{if(B)return N(null);if(T.current){T.current=!1,C(Q=>Q+1);return}N({code:U})},O=MZ({worktreeId:e,procs:f,borrowed:m,login:g,current:w,onRestart:M}),A=S.useRef(!t),z=!A.current;return S.useEffect(()=>{A.current=!1},[]),d.jsxs(Sy,{kind:"terminal",className:"term-pane",height:n,onDragStart:r,tabs:{items:O,current:w,onPick:_,font:"mono",owner:"terminal",label:"terminal streams"},onClose:()=>o({a:"toggle-terminal"}),closeHint:zt("terminal"),children:[d.jsxs("div",{className:"term-body",children:[x&&d.jsx(iu,{pane:!0,title:`${w} runs on main`,body:"Every worktree reaches main's copy until its own changes touch it, or until asked.",action:d.jsx(De,{variant:"outline",onClick:()=>i==null?void 0:i.send({t:"own-procs",worktreeId:e,names:[w]}),children:"run it here"})}),d.jsx(Mw,{pane:!0,children:d.jsx(S.Suspense,{fallback:d.jsx("div",{className:"empty",children:d.jsx("span",{className:"live-text",children:"loading terminal"})}),children:d.jsx(PZ,{worktreeId:e,stream:w,theme:a,sock:i,connected:c,focusOnMount:z,focusReq:u,onAlive:I,run:y,onRan:()=>o({a:"term-ran"}),onEscape:()=>o({a:"toggle-terminal"})},`${w}:${j}`)})})]}),v!==null&&!x&&d.jsx(iu,{pane:!0,title:w===Po?"the shell exited":w===Os?"the login did not finish":`${w} exited`,body:v.code===void 0?void 0:`exit code ${v.code}`,action:d.jsx(De,{variant:"outline",onClick:()=>M(w),children:"restart"})})]})}function zZ(e){return e==="reserved"?"checking out a fresh worktree":e==="warming"?"copying dependencies and running setup":"starting dev servers"}const FZ="preview off; it starts when the agent writes a file";function BZ({worktree:e,log:t}){const n=tt(),r=lt(),o=e.procs,i=v=>n==null?void 0:n.send({t:"term-restart",worktreeId:e.id,stream:v.name}),a=o.some(v=>v.status==="crashed"||v.status==="unreachable"),c=P(v=>v.clientId),u=uu(e,"setup"),h=u&&u.status!=="terminated"?u:null,f=xi(Bw(h??void 0)?h==null?void 0:h.since:void 0),m=!!e.worktree.parked&&o.length===0,g=()=>n==null?void 0:n.send({t:"preview-start",worktreeId:e.id}),w=h&&(h.status==="running"||h.status==="detached"),y=()=>n==null?void 0:n.send({t:"fix-preview",worktreeId:e.id,clientId:c});return d.jsxs(ys,{wide:!0,children:[o.length===0?d.jsx("div",{className:"status-line",children:h?d.jsx("span",{className:"live-text","data-tip":qg[h.status],children:qf("setup",h,f)}):m?FZ:d.jsx("span",{className:"live-text",children:zZ(e.worktree.phase)})}):d.jsx("ul",{className:"boot-procs",children:o.map(v=>d.jsxs("li",{className:He("boot-proc",(v.status==="crashed"||v.status==="unreachable")&&"boot-bad"),children:[d.jsx("span",{className:"boot-name",children:v.name}),d.jsx("span",{className:"boot-status",children:UZ(v)}),(v.status==="crashed"||v.status==="unreachable")&&d.jsx(De,{variant:"outline",onClick:()=>i(v),children:"restart"}),v.detail&&v.status!=="asleep"&&d.jsx("div",{className:"boot-detail",children:v.detail})]},v.name))}),m&&d.jsx("div",{className:"status-actions",children:d.jsx(De,{variant:"outline",size:"lg",onClick:g,children:"start preview"})}),w&&d.jsx("div",{className:"status-actions",children:d.jsx(De,{variant:"outline","data-tip":MN("setup"),onClick:()=>n==null?void 0:n.send({t:"run-stop",worktreeId:e.id,kind:"setup"}),children:"stop setup"})}),a&&d.jsxs("div",{className:"status-actions",children:[e.agent==="idle"&&d.jsx(De,{variant:"outline",size:"lg",onClick:y,children:"ask the agent to fix it"}),d.jsx(De,{onClick:()=>r({a:"open",overlay:{kind:"setup",repoId:e.repoId}}),children:"edit setup"})]}),t.length>0&&d.jsx("pre",{className:"status-tail",children:t.slice(-30).map(v=>`[${v.proc}] ${v.line}`).join(`
|
|
271
|
+
`)})]})}function UZ(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 HZ(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 q1(e){if(!e)return"/";try{const t=new URL(e);return`${t.pathname}${t.search}${t.hash}`}catch{return"/"}}function WZ(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 KZ({active:e}){const t=lt(),n=tt(),r=ql(),o=P(c=>c.home),i=e.worktree.title,a=()=>{r!=null&&r.made&&(t({a:"new-project",v:{...cw({mode:r.made==="git"?"init":"create",name:r.name,parent:NT(r.path,o)??r.path}),phase:"unmaking",repoId:r.id}}),t({a:"move-box",from:e.worktree.id,to:Ml}),n==null||n.send({t:"unmake-repo",repoId:r.id}))};return d.jsx(ys,{anchor:"line",foot:d.jsx("div",{className:"composer view-foot",children:d.jsx(Yc,{active:e,greenfield:!0})}),children:d.jsx("p",{className:"form-title",children:r!=null&&r.made?d.jsx(De,{variant:"inline",onClick:a,...Pt("Rename or move this project"),children:i}):i})})}function ZZ({pending:e}){const t=lt(),n=tt(),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 a;return(a=i.current)==null?void 0:a.scrollTo({top:i.current.scrollHeight})},[e.lines.length]),d.jsxs(ys,{wide:!0,children:[d.jsxs("p",{className:"status-line",children:[r?"could not import":"importing"," ",e.name]}),d.jsxs("p",{children:["from ",d.jsx("code",{children:e.url})," into ",d.jsx("code",{children:e.parent})]}),r?d.jsx("p",{className:"import-error",children:e.error}):d.jsx("p",{className:"hint",children:"the whole history is cloned, so worktrees, land and graft all work on it straight away."}),d.jsx("div",{className:"status-tail",ref:i,children:e.lines.length===0&&!r?d.jsx("span",{className:"live-text",children:"starting git"}):e.lines.map((a,c)=>d.jsx("div",{children:a},c))}),d.jsx("div",{className:"status-actions",children:d.jsx(De,{variant:"outline",size:"lg",onClick:o,children:r?"dismiss":"stop"})})]})}const qZ=150,GZ=/^[^\s@]+@[^\s@]+$/,VZ=14;function YZ({project:e}){var V;const t=lt(),n=tt(),r=P(X=>X.repos),o=P(X=>X.home),i=P(X=>X.folderDialog),a=P(X=>X.gitIdentity),c=P(X=>X.choosingFolder),u=P(X=>X.chosenFolder),h=P(X=>X.paths),[f,m]=S.useState({name:"",email:""}),[g,w]=S.useState(null),y=S.useRef(null),{mode:v,name:N,parent:x}=e,_=v==="clone",T=v==="init",j=e.phase==="editing",C=N.trim(),M=T||!C?null:nu(N),I=!T&&C&&!M?_T(x,C):null,O=ik(x,o),A=I!==null&&h.query===I&&((V=h.target)==null?void 0:V.exists)===!0,z=!a&&!_,B=!z||f.name.trim()!==""&&GZ.test(f.email.trim()),U=j?g?"the folder you chose is already a project: open it, or choose another":!T&&!C?"name the project first":M??(A?`${O} already has a folder called ${C}`:B?null:"git needs your name and email first"):null;S.useEffect(()=>{if(!I)return;const X=setTimeout(()=>n==null?void 0:n.send({t:"browse-path",path:I}),qZ);return()=>clearTimeout(X)},[I,n]),ut([e.phase],()=>{var X;e.phase==="editing"&&((X=y.current)==null||X.focus())}),ut([e.error],()=>{e.error&&t({a:"notice",id:Ml,text:e.error})});const Q={sock:n,dispatch:t},ae=()=>{U||!j||(t({a:"new-project-set",v:{phase:"creating"}}),pu(Q,{t:"create-repo",mode:v,parent:x.trim(),name:C,..._&&e.url?{url:e.url}:{},...z?{identity:{name:f.name.trim(),email:f.email.trim()}}:{}}))},ee=X=>{const W=r.find(se=>se.path===Fl(X,o));W?t({a:"activate-repo",id:W.id}):pu(Q,{t:"register-repo",path:X})},de=X=>{const W=iy(X);t({a:"new-project-set",v:{mode:"init",parent:W.parent,name:W.name}})},$=X=>{i?(t({a:"choosing-folder",v:X}),n==null||n.send({t:"choose-folder",start:x,purpose:X})):t(X==="location"?{a:"open",overlay:{kind:"choose-folder"}}:{a:"open",overlay:{kind:"projects",form:"disk"}})};ut([u==null?void 0:u.seq],()=>{var W,se;if(!c||!u)return;t({a:"choosing-folder",v:!1});const X=u.folder;if(!X){(W=y.current)==null||W.focus();return}if(c==="open"){X.kind==="project"?ee(X.path):z?de(X.path):TT(Q,X.path);return}if(w(X.kind==="project"?X.path:null),X.kind!=="project"){if(X.kind==="empty"&&!_){de(X.path);return}t({a:"new-project-set",v:{mode:_?"clone":"create",parent:X.path}}),(se=y.current)==null||se.focus()}});const K=T?"the folder you chose becomes the project":g?null:A?`${O} already has a folder called ${C}`:M;return d.jsxs(ys,{anchor:"line",foot:d.jsx("div",{className:"composer view-foot",children:d.jsx(Yc,{active:null,project:{name:C,why:U,busy:!j,create:ae}})}),children:[_&&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:N}):d.jsx(Do,{ref:y,bare:!0,font:"lead",className:"new-project-field",autoFocus:!0,spellCheck:!1,autoComplete:"off",value:N,placeholder:"Project name",disabled:!j,style:{width:`${Math.max(N.length+1,VZ)}ch`},onChange:X=>t({a:"new-project-set",v:{name:X.target.value}}),onKeyDown:X=>{X.key==="Enter"&&(X.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",...Pt(x),children:O}),d.jsx(Rt,{icon:"folder",label:i?"Choose in Finder":"Choose a folder",className:"new-project-folder",on:c==="location",disabled:!j,onClick:()=>$("location")})]})]}),K&&d.jsx("p",{className:"hint",children:K}),g&&d.jsxs("p",{className:"hint",children:["the folder you chose is already a project:"," ",d.jsx(De,{variant:"inline",autoFocus:!0,onClick:()=>ee(g),children:"open it"}),", or choose another"]}),z&&d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"new-project-identity",children:[d.jsx(Do,{size:"md",font:"ui",rule:!0,value:f.name,placeholder:"Your name",autoComplete:"name",disabled:!j,onChange:X=>m({...f,name:X.target.value})}),d.jsx(Do,{size:"md",font:"ui",rule:!0,type:"email",value:f.email,placeholder:"Email",autoComplete:"email",disabled:!j,onChange:X=>m({...f,email:X.target.value})})]}),d.jsx("p",{className:"hint",children:"git labels the work you save with these, and asks only once"})]}),!_&&j&&d.jsx(De,{tone:"quiet",className:"new-project-open",onClick:()=>$("open"),children:"or open a folder you already have"})]})}function hl({label:e,hint:t,children:n}){return d.jsxs("label",{className:"form-row",children:[d.jsx("span",{className:"form-label",children:e}),d.jsxs("div",{className:"form-control",children:[n,t&&d.jsx("span",{className:"hint",children:t})]})]})}function XZ(e,t,n){const r=[n.envUrl?`\`${n.envUrl.name}\` in \`${n.envUrl.file}\``:null,n.compose?`the compose stack in \`${n.compose}\``:null].filter(Boolean).join(" and ");return[`Toyon runs several worktrees of this repo (${e.name}) at once, each with its own copy of the code, and right now they would all share ${r}: a migration run in one worktree changes the database every other worktree is using.`,"",`Give each worktree its own. Every command Toyon runs gets \`TOYON_WORKTREE\` (the worktree's id, empty in the main checkout, which never runs setup) and \`TOYON_ROOT\` (the main checkout). Edit \`${t}\` so that:`,'- `setup` makes the worktree\'s own database with the same schema and seed data. Postgres refuses to copy a database with connections open, so copy from a template nothing serves: `createdb -T <db>_template "<db>_$TOYON_WORKTREE"`, making `<db>_template` once from the seed if it does not exist. Keep it seed-sized, since every worktree copies it. A hosted database that branches (the repo already uses one, or its README says so) gets a branch named for the worktree instead. A compose stack: bring it up under `-p "<name>_$TOYON_WORKTREE"` and seed it the way the README does.',"- `teardown` drops it again (`dropdb --if-exists ...`, the branch deleted, or `docker compose -p ... down -v`).","- the running commands point at it, with the base database in the main checkout: put the URL in front of the command in `run`, or in a profile's `env`, named `<db>${TOYON_WORKTREE:+_$TOYON_WORKTREE}`. `setup` does not see what `run` sets, so a migration step in `setup` needs the URL in front of it too.",'- a database container the worktrees share (each with its own database inside it) is marked `{ "cmd": ..., "from": "trunk", "paths": [] }` in `run`, so the main checkout runs it once for everyone.',"","Read the README and the existing env files for the database's name and credentials. Do not run any migration yourself, and do not start any server; Toyon picks the file up as soon as it is written."].join(`
|
|
272
|
+
`)}function QZ(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(`
|
|
273
|
+
`)}let JZ=1;const fg=(e,t,n=!1)=>({id:JZ++,name:e,cmd:t,shared:n}),eq=[{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 tq({repo:e,onClose:t}){const n=tt(),r=Un(),o=P(q=>q.clientId),i=P(q=>q.rows.find(H=>{var ve;return Nn(H)&&H.id===((ve=Pl(q,e.id))==null?void 0:ve.id)})??null),a=P(q=>{var H;return((H=Pl(q,e.id))==null?void 0:H.id)??null});S.useEffect(()=>{if(!t)return;const q=H=>H.key==="Escape"&&t();return window.addEventListener("keydown",q),()=>window.removeEventListener("keydown",q)},[t]);const[c]=S.useState(()=>Object.keys(e.config.run).length>0),[u,h]=S.useState(()=>{const q=Object.entries(e.config.run).map(([H,ve])=>fg(H,fE(ve),wA(ve)));return q.length>0?q:[fg("web","")]}),[f,m]=S.useState(()=>(e.config.setup??[]).join(`
|
|
274
|
+
`)),[g,w]=S.useState(()=>(e.config.teardown??[]).join(`
|
|
275
|
+
`)),[y,v]=S.useState(()=>e.config.check??""),[N,x]=S.useState(()=>vi(e.config).land),[_,T]=S.useState(()=>vi(e.config).automerge),[j,C]=S.useState(()=>vi(e.config).merge??"default"),[M,I]=S.useState(()=>bA(e.configFile)),O=xA(e.configFile,M),A=!!e.remote&&N==="pr",z=u.length>1,B=u.some(q=>q.name.trim()&&q.cmd.trim()),Q=!!i&&!t&&!c&&!B,ae=(q,H)=>h(u.map((ve,Se)=>Se===q?{...ve,...H}:ve)),ee=q=>q.split(`
|
|
276
|
+
`).map(H=>H.trim()).filter(Boolean),de=()=>ee(f),$=()=>ee(g),K=()=>{const{check:q,land:H,teardown:ve,...Se}=e.config,ye=e.remote?N:gg,J=j==="default"||ye!=="pr"&&j===kg?void 0:j,we={...ye!==gg?{route:ye}:{},...ye==="pr"&&_?{automerge:!0}:{},...J?{method:J}:{}};return{...Se,setup:de(),...$().length>0?{teardown:$()}:{},...y.trim()?{check:y.trim()}:{},...Object.keys(we).length>0?{land:we}:{}}},V=()=>{n==null||n.send({t:"confirm-config",repoId:e.id,config:{...K(),run:Object.fromEntries(u.filter(q=>q.name.trim()&&q.cmd.trim()).map((q,H)=>[q.name.trim(),q.shared&&H>0?{cmd:q.cmd.trim(),from:"trunk"}:q.cmd.trim()]))},kind:M}),t==null||t()},X=()=>{n==null||n.send({t:"confirm-config",repoId:e.id,config:{...K(),run:{}},kind:M}),t==null||t()},W=()=>n==null?void 0:n.send({t:"create-worktree",clientId:o,repoId:e.id,prompt:QZ(e,O)}),se=e.services,ce=[f,g,...u.map(q=>q.cmd)].some(q=>q.includes("TOYON_WORKTREE"))||yA(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 "):"",je=()=>se&&(n==null?void 0:n.send({t:"create-worktree",clientId:o,repoId:e.id,prompt:XZ(e,O,se)})),$e=(q,H)=>d.jsxs("div",{className:"setup-proc",children:[z&&d.jsx(Do,{size:"md",rule:!0,className:"setup-name",value:q.name,placeholder:"name",...Pt("Process name, shown in the status bar"),onChange:ve=>ae(H,{name:ve.target.value})}),d.jsx(Do,{size:"md",rule:!0,className:"setup-cmd",value:q.cmd,placeholder:"npm run dev",onChange:ve=>ae(H,{cmd:ve.target.value})}),z&&d.jsx(Rt,{icon:"close",label:"Remove",onClick:()=>h(u.filter((ve,Se)=>Se!==H))}),z&&H>0&&d.jsx(i$,{className:"setup-shared",checked:q.shared,onChange:ve=>ae(H,{shared:ve.target.checked}),tip:"Main runs it once for every worktree; a worktree whose changes touch it runs its own",children:"shared from main"})]},q.id);return d.jsxs(ys,{children:[d.jsxs("p",{className:"form-title",children:["how does ",e.name," start?"]}),se&&!ce&&d.jsxs("p",{className:"hint setup-shared-note",children:["Worktrees will share ",he,", migrations included."," ",d.jsx(De,{tone:"quiet",disabled:!i,onClick:je,children:"ask the agent to keep them apart"})]}),d.jsx(hl,{label:"install",hint:"once per new worktree; one command per line",children:d.jsx(cu,{size:"md",rule:!0,rows:Math.max(1,f.split(`
|
|
277
|
+
`).length),value:f,placeholder:"bun install",onChange:q=>m(q.target.value)})}),d.jsx(hl,{label:"remove",hint:"once when a worktree goes, before its directory does; one command per line",children:d.jsx(cu,{size:"md",rule:!0,rows:Math.max(1,g.split(`
|
|
278
|
+
`).length),value:g,placeholder:'dropdb --if-exists "app_$TOYON_WORKTREE"',onChange:q=>w(q.target.value)})}),d.jsx(hl,{label:"check",hint:"runs after each of the agent's turns; the work lands only when it passes",children:d.jsx(Do,{size:"md",rule:!0,value:y,placeholder:"bun run check",onChange:q=>v(q.target.value)})}),e.remote&&d.jsx(hl,{label:"land",hint:"where a worktree's finished work goes; one way per repo",children:d.jsxs("div",{className:"setup-land",children:[d.jsx(yi,{value:N,options:PA.map(q=>({id:q.id,label:q.name,description:q.description})),onChange:x,hint:"where the work goes",placeholder:"where work lands"}),A&&d.jsx(yi,{value:_?"github":"you",options:DA.map(q=>({id:q.id,label:q.name,description:q.description})),onChange:q=>T(q==="github"),hint:"who merges the pull request",placeholder:"who merges it"})]})}),d.jsx(hl,{label:"merge",hint:A?"how GitHub merges the pull request; only what the repo allows":"how the commits arrive on main",children:d.jsx(yi,{value:j==="default"&&!A?kg:j,options:[...A?[{id:"default",label:"what the repo allows",description:"the repo's allowed methods on GitHub: squash, else a merge commit, else rebase"}]:[],...LA.map(q=>({id:q.id,label:q.name,description:q.description}))],onChange:C,hint:"how the commits arrive on main",placeholder:"how the commits arrive"})}),d.jsx(hl,{label:"start",hint:d.jsxs(d.Fragment,{children:["must listen on ",d.jsx("code",{...Pt("Toyon sets a different port for each worktree"),children:"$PORT"}),e.guess&&a&&d.jsxs(d.Fragment,{children:[" · from ",d.jsx(De,{mono:!0,tone:"quiet",...Pt(`open ${e.guess} in the editor pane`),onClick:()=>wa(r,n,a,e.guess??"",1),children:e.guess})]})]}),children:u[0]&&$e(u[0],0)}),u.slice(1).map((q,H)=>d.jsxs("div",{className:"form-row",children:[d.jsx("span",{className:"form-label"}),d.jsx("div",{className:"form-control",children:$e(q,H+1)})]},q.id)),d.jsxs("div",{className:"form-row",children:[d.jsx("span",{className:"form-label"}),d.jsxs(De,{tone:"quiet",onClick:()=>h([...u,fg("","")]),children:[d.jsx(St,{name:"plus",className:"icon-inline"})," another process"]})]}),d.jsxs("div",{className:"form-knobs",children:[d.jsx(yi,{value:M,options:eq,onChange:I,hint:"whether the settings file is committed with the repo or kept out of git",placeholder:"committed or kept local"}),d.jsx("span",{className:"form-sign",children:O}),t&&d.jsx(De,{onClick:t,children:"cancel"}),(!c||t)&&d.jsx(De,{...Pt("This project has no dev server: chat, changes and the terminal work, the preview stays empty"),onClick:X,children:"no dev server"}),Q&&i?d.jsx(De,{variant:"outline",size:"lg",disabled:i.agent!=="idle",...Pt("The agent reads the repo and writes the settings file; the daemon picks it up as soon as it lands"),onClick:W,children:"let the agent work it out"}):d.jsxs(De,{variant:"outline",size:"lg",disabled:!B,...t?Pt("Restarts every worktree of this repo. Profiles and other keys in the file are kept."):{},onClick:V,children:[t?"save + restart":"start"," ",d.jsx(St,{name:"forward",className:"icon-inline"})]})]})]})}function nq(e){return`${Math.round(e.w)} × ${Math.round(e.h)}`}function rq(e){return e.w>0&&e.h>0}function oq(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 a={w:i.width,h:i.height};n(rq(a)?nq(a):null)});return r.observe(e),()=>{r.disconnect(),n(null)}},[e,t,n])}const sq=1500,iq={set:(e,t)=>setTimeout(e,t),clear:e=>clearTimeout(e)};class aq{constructor(t,n,r=iq){Et(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=yb(r));const i=vh(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)},sq)}title(t,n){const r=this.frame(t);r.title=yb(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 lq=zf(),cq=2*6e4;function G1(e){e==null||e.setAttribute("src",e.src)}const uq=8e3;function dq(e,t){try{const n=new URL(e,t);return n.origin===new URL(t).origin?n.href:null}catch{return null}}function fq({onRoot:e}){const t=S.useRef(null),n=S.useCallback(oe=>{t.current=oe,e(oe)},[e]),r=lt(),o=Un(),i=tt(),a=S.useRef(i);a.current=i;const[c]=S.useState(()=>new aq((oe,Le,Ve)=>{var jt,ft;(jt=a.current)==null||jt.send({t:"visit",worktreeId:oe,path:Le,title:Ve}),jS((ft=o.getState().local[oe])==null?void 0:ft.pages)&&dn.post(oe,{type:"links"})},(oe,Le,Ve)=>{var jt;return(jt=a.current)==null?void 0:jt.send({t:"page-title",worktreeId:oe,path:Le,title:Ve})}));S.useEffect(()=>()=>c.dispose(),[c]);const u=g_(),h=Zl(),f=Ps(),m=P(oe=>oe.connected),g=P(oe=>oe.heard),w=P(oe=>oe.recalledAt!==null),y=P(oe=>oe.connectFailure),v=P(oe=>oe.remote),{host:N}=Wr(),x=mo(),_=is(),T=P(oe=>oe.editor),j=w_(),C=JD(),M=P(oe=>oe.notesPage),I=Nu(),O=P(oe=>oe.layout.term)&&!I,A=P(oe=>oe.focusTerm),z=S.useRef(!1),B=S.useRef(A),U=!z.current||A!==B.current;S.useEffect(()=>{z.current=O&&!!h,B.current=A});const Q=Tu(),ae=P(oe=>oe.layout.design)&&!I&&!Q,ee=P(oe=>oe.reloadReq),de=Ch(),$=S.useRef(de);$.current=de;const K=P(oe=>oe.zen),V=P(oe=>{var Le;return((Le=oe.dragFiles)==null?void 0:Le.at)==="centre"}),X=S.useRef(K);X.current=K;const W=It(h,"log"),se=P(oe=>oe.incompatible),ce=tz(),he=P(oe=>{var Le;return((Le=oe.overlay)==null?void 0:Le.kind)==="setup"?oe.repos.find(Ve=>Ve.id===oe.overlay.repoId)??null:null}),je=(f==null?void 0:f.worktree.empty)===!0,$e=zo(f==null?void 0:f.agent),q=ce&&!je&&!$e?ce:null,H=q??he,ve=P(oe=>oe.pending.find(Le=>Le.id===oe.activeImportId)??null),[Se,ye]=S.useState([]),J=S.useMemo(()=>Se.map(oe=>oe.id),[Se]),we=S.useRef(new Map),ge=S.useRef(new Map),[Be,Ie]=S.useState([]),We=S.useRef(new Set),pt=S.useRef(new Set),rn=S.useRef(oe=>G1(we.current.get(oe)));S.useEffect(()=>{dn.post=(oe,Le)=>{var Ve,jt;if(Le.type==="reload"&&We.current.has(oe))return rn.current(oe);(jt=(Ve=we.current.get(oe))==null?void 0:Ve.contentWindow)==null||jt.postMessage({__toyon:!0,...Le},ge.current.get(oe)??"*")},dn.broadcast=oe=>{var Le;for(const[Ve,jt]of we.current)(Le=jt.contentWindow)==null||Le.postMessage({__toyon:!0,...oe},ge.current.get(Ve)??"*")}},[]),S.useEffect(()=>{let oe=null;const Le=ft=>{ft.target instanceof HTMLElement&&ft.target.tagName!=="IFRAME"&&(oe=ft.target)},Ve=ft=>{ft.relatedTarget===null&&setTimeout(()=>{document.activeElement===document.body&&(oe=null)},0)},jt=ft=>{var bn,jr,ir,Zt,Qr;if((bn=ft.data)!=null&&bn.__toyon)for(const[dt,Hn]of we.current){if(Hn.contentWindow!==ft.source)continue;if(ft.origin!==ge.current.get(dt))return;const rt=rS(ft.data);if(!rt)return;switch(rt.type){case"key":window.dispatchEvent(new KeyboardEvent(rt.up?"keyup":"keydown",{key:rt.key,code:rt.code,metaKey:rt.meta,ctrlKey:!!rt.ctrl,shiftKey:!!rt.shift,altKey:!!rt.alt}));break;case"hmr":r({a:"hmr",id:dt}),(jr=a.current)==null||jr.send({t:"page-loaded",worktreeId:dt});break;case"loaded":We.current.delete(dt),pt.current.add(dt),Ie(_e=>_e.includes(dt)?_e:[..._e,dt]),dn.post(dt,_$($.current)),dn.post(dt,{type:"zen",on:X.current}),r({a:"hmr",id:dt}),r({a:"page",id:dt,url:rt.url,title:rt.title}),(ir=a.current)==null||ir.send({t:"page-loaded",worktreeId:dt}),c.note(dt,rt.url,rt.title);break;case"navigated":r({a:"page",id:dt,url:rt.url,...rt.title!==void 0?{title:rt.title}:{}}),c.note(dt,rt.url,rt.title);break;case"title":r({a:"page",id:dt,title:rt.title}),c.title(dt,rt.title);break;case"links":r({a:"links",id:dt,links:rt.links});break;case"page-error":{const _e=f4(rt);_e&&((Zt=a.current)==null||Zt.send({t:"page-error",worktreeId:dt,message:_e}));break}case"picked":{const{type:_e,verb:qe,site:bt,...it}=rt,fn=bt==="call"?{file:it.callFile,line:it.callLine}:{file:it.file,line:it.line};if(qe==="code"){r({a:"set-picking",v:!1});const Ht=(Qr=nn(o.getState(),dt))==null?void 0:Qr.worktree;fn.file?wa(o,i,dt,ES(fn.file,Ht==null?void 0:Ht.path),fn.line??1):i==null||i.send({t:"find-element",worktreeId:dt,seq:Lo(),element:it.element})}else Mz(o,dt,it);break}case"pick-cancel":r({a:"set-picking",v:!1});break;case"drag-files":rt.over?Iw(o,o.getState().activeId?{at:"centre"}:null):Z_(o);break;case"drop-files":Y_(o,i,o.getState().activeId?{at:"centre"}:null,h3(rt.files));break;case"focus":rt.gesture?oe=null:document.activeElement===Hn&&(oe!=null&&oe.isConnected)&&oe!==document.body&&oe.focus();break;case"highlight-miss":console.warn(`[toyon] highlight miss on ${rt.path}: ${rt.fileMatched} elements from this file, ${rt.withSource} elements with source info on page, ranges=${JSON.stringify(rt.ranges)}`);break}return}};return window.addEventListener("message",jt),document.addEventListener("focusin",Le),document.addEventListener("focusout",Ve),()=>{window.removeEventListener("message",jt),document.removeEventListener("focusin",Le),document.removeEventListener("focusout",Ve)}},[r,o,i,c]),S.useEffect(()=>{dn.broadcast({type:"zen",on:K})},[K]);const qt=S.useRef(new Map);ut([ee==null?void 0:ee.id,ee==null?void 0:ee.n],()=>{if(!ee)return;const{id:oe}=ee;clearTimeout(qt.current.get(oe)),qt.current.set(oe,setTimeout(()=>{qt.current.delete(oe),dn.post(oe,{type:"reload"})},1200))});const Ue=bw(),Qt=Ue&&!Nn(Ue)?Ue:null,an=_a(),Ft=!!f&&f.procs.some(oe=>oe.status==="running"),Qe=Sw(),Wt=Qe!==null&&Qe===h&&Ft;S.useEffect(()=>{var oe;if(Qe&&Wt&&!J.includes(Qe)){const Le=q1((oe=o.getState().local[Qe])==null?void 0:oe.page.url);ye(Ve=>[...Ve,{id:Qe,path:Le}])}},[Qe,Wt,J,o]);const ln=u.filter(oe=>Nn(oe)&&oe.procs.some(Le=>Le.status==="asleep")).map(oe=>oe.id).join(" ");S.useEffect(()=>{const oe=new Set(ln.split(" ").filter(Boolean));J.some(Le=>oe.has(Le))&&ye(Le=>Le.filter(Ve=>!oe.has(Ve.id)))},[ln,J]);const wt=J.join(" ");S.useEffect(()=>{const oe=wt.split(" ").filter(Le=>Le&&Le!==Qe).map(Le=>setTimeout(()=>ye(Ve=>Ve.filter(jt=>jt.id!==Le)),cq));return()=>{for(const Le of oe)clearTimeout(Le)}},[wt,Qe]),S.useEffect(()=>{Ie(oe=>oe.every(Le=>J.includes(Le))?oe:oe.filter(Le=>J.includes(Le)))},[J]);const mt=S.useMemo(()=>u.filter(Nn).flatMap(oe=>{const Le=Se.find(jt=>jt.id===oe.id);if(!Le)return[];const Ve=xS(oe.worktree.id,oe.worktree.proxyPort,v,N);return[{id:oe.worktree.id,port:oe.worktree.proxyPort,title:oe.worktree.title,url:dq(Le.path,Ve)??Ve}]}),[u,Se,v,N]),Vt=Hg(x,v),kn=nN(x,mt,Vt);rn.current=oe=>{var Ve;const Le=q1((Ve=o.getState().local[oe])==null?void 0:Ve.page.url);if(Se.some(jt=>jt.id===oe&&jt.path!==Le)){ye(jt=>jt.map(ft=>ft.id===oe?{...ft,path:Le}:ft));return}Vt?kn.renew(oe):G1(we.current.get(oe))};const Lt=mt.filter(oe=>{var Le;return(Le=u.find(Ve=>Ve.id===oe.id))==null?void 0:Le.procs.some(Ve=>Ve.status==="running")}).map(oe=>oe.id).join(" ");ut([Lt],()=>{for(const oe of Lt.split(" "))We.current.has(oe)&&rn.current(oe)});const Pn=P(oe=>oe.carryTo),[_t,yn]=S.useState(null),[er,te]=S.useState(Qe),me=S.useRef(null);er!==Qe&&(te(Qe),yn(HZ({leaving:me.current,arriving:Qe,carryTo:Pn,repoOf:oe=>{var Le;return((Le=u.find(Ve=>Ve.id===oe))==null?void 0:Le.repoId)??null}}))),S.useEffect(()=>{if(!_t)return;const oe=setTimeout(()=>yn(null),uq);return()=>clearTimeout(oe)},[_t]);const Ge=Qe!==null&&Be.includes(Qe),ot=WZ({previewId:Qe,painted:Ge,ready:Wt,carry:_t,mounted:J}),Dt=ot!==null&&ot!==Qe;S.useEffect(()=>{me.current=ot});const Ct=ot!==null&&!H&&!ve&&!M&&!I&&!Q,[mn,L]=S.useState(null),re=S.useCallback(oe=>r({a:"preview-size",text:oe}),[r]);oq(mn,Ct,re);const[be,Xe]=xo(Ke.editorHeight,0,oe=>{const Le=Number(oe);return Number.isFinite(Le)&&Le>=120?Le:0}),[Nt,Ot]=xo(Ke.designHeight,0,oe=>{const Le=Number(oe);return Number.isFinite(Le)&&Le>0?Le:0}),[ze,Me]=xo(Ke.designFull,!1,oe=>oe===null?void 0:oe==="1"),[Ze,Xt]=xo(Ke.editorFull,!1,oe=>oe===null?void 0:oe==="1"),[Bt,vn]=xo(Ke.termHeight,240,oe=>{const Le=Number(oe);return Number.isFinite(Le)&&Le>=140?Le:void 0}),Ut=P(oe=>oe.termTall);ut([Ut],()=>{const oe=t.current;Ut&&oe&&vn(Math.max(Bt,Math.round(oe.clientHeight/2)))});const cn=oe=>(Le,Ve)=>{const jt=Ve.parentElement,ft=t.current;if(!jt||!ft)return null;let bn=0;for(const ir of Array.from(ft.querySelectorAll(":scope > .pane")))ir!==jt&&!ir.classList.contains("full")&&(bn+=ir.offsetHeight);const jr=Math.max(ft.clientHeight-bn-80,oe);return Math.min(Math.max(jt.getBoundingClientRect().bottom-Le.clientY,oe),jr)},Yt=jl(cn(120),oe=>Xe(Math.round(oe))),Kt=jl(cn(160),oe=>Ot(Math.round(oe))),Sn=jl(cn(140),oe=>vn(Math.round(oe))),An=P(oe=>{var Le,Ve;return f&&Nr(f.worktree)?((Ve=(Le=oe.rows.find(jt=>{var ft;return jt.repoId===f.worktree.repoId&&((ft=jt.worktree)==null?void 0:ft.kind)==="worktree"}))==null?void 0:Le.worktree)==null?void 0:Ve.title)??null:null}),fr=y5({connected:m,heard:g,standing:w,connectFailure:y,hasToken:x.serving?lq:!0,projectChord:zt("project"),title:(f==null?void 0:f.worktree.title)??null,machine:x.serving?null:_.displayName(x.origin),needsSetup:!!ce,busy:$e,treeEmpty:je,landsFrom:An});return d.jsxs("div",{className:"center-root",ref:n,children:[d.jsx("div",{className:He("center-area",V&&"drop-over"),style:{display:!(K&&!Q)&&!an&&!M&&(T&&Ze||ae&&ze)?"none":void 0},children:d.jsxs("div",{className:"frames-wrap",ref:L,children:[mt.map(oe=>d.jsx("iframe",{ref:Le=>{Le?(we.current.set(oe.id,Le),ge.current.set(oe.id,new URL(oe.url).origin)):(we.current.delete(oe.id),ge.current.delete(oe.id),We.current.delete(oe.id),pt.current.delete(oe.id))},onLoad:()=>{pt.current.delete(oe.id)?We.current.delete(oe.id):We.current.add(oe.id)},src:kn.urlOf(oe.id)??void 0,title:oe.title,style:{display:Ct&&oe.id===ot?"block":"none"}},oe.id)),C?d.jsx(YZ,{project:C}):M?d.jsx(uZ,{}):d.jsxs(d.Fragment,{children:[ve&&d.jsx(ZZ,{pending:ve},ve.id),j&&f&&!ve&&d.jsx(KZ,{active:f},f.worktree.id),H&&!ve&&!j&&d.jsx(tq,{repo:H,onClose:q?void 0:()=>r({a:"close"})},`${H.id}:${JSON.stringify(H.config)}`),Qt&&!H&&!ve&&!an&&d.jsx(Xc,{placement:"centre",found:Qt},Qt.id),an&&!H&&!ve&&d.jsx(Xc,{placement:"centre",archived:an},an.id),!Ft&&!Qt&&!an&&!H&&!ve&&!j&&se&&d.jsx(pN,{foreign:x.serving?void 0:_.displayName(x.origin)}),!Ft&&!Qt&&!an&&!H&&!ve&&!j&&!se&&(fr!==null?d.jsx(ys,{wide:!0,children:d.jsx("p",{className:He("status-line",fr.live&&"live-text"),children:fr.text})}):Q?d.jsx(Xc,{placement:"centre"}):Dt?null:f&&d.jsx(BZ,{worktree:f,log:W}))]})]})}),T&&d.jsx(d$,{editor:T,height:Ze?"100%":be>0?be:"45%",full:Ze,onToggleFull:()=>Xt(!Ze),onDragStart:Yt}),ae&&h&&!an&&!M&&d.jsx(hZ,{worktreeId:h,height:ze?"100%":Nt>0?Nt:"55%",full:ze,onToggleFull:()=>Me(!ze),onDragStart:Kt},`design:${h}`),O&&h&&!an&&!M&&d.jsx(DZ,{worktreeId:h,opened:U,height:Bt,onDragStart:Sn},`term:${h}`),d.jsx(w$,{})]})}function hq({width:e}){const t=P(r=>r.layout.chat),n=Nu();return d.jsx(Xc,{placement:"dock",className:!t||n?"collapsed":void 0,width:e})}function pq(e,t){const n=[];return e&&(n.push(S_(e)),n.push({id:"copy-url",label:"copy URL",onClick:()=>tn(e)})),Bn([n,[{id:"reload",label:"reload preview",key:zt("reload"),onClick:t.reload}]])}const mq=520,hg=8;function gq({winW:e,centre:t,leadRight:n,toolsLeft:r}){const o=t.right-t.left,i=Math.max(0,Math.min(mq,Math.floor(e*.4),o-2*hg)),a=t.left+(o-i)/2,c=n+hg,u=r-hg-i,h=Math.max(Math.min(a,u),c);return{left:Math.round(h),width:i}}function kq({center:e}){const t=AD(),n=d_(e),r=S.useRef(null);UD(r);const o=M3(),[i,a]=zb(),[c,u]=zb(),h=gq({winW:t,centre:n,leadRight:a.right,toolsLeft:u.left}),f=lt(),m=tt(),g=Un(),w=wn("bar"),y=Ps(),v=Tu(),N=P(Q=>Q.zen)&&!v,x=P(Q=>Q.layout.changes),_=P(Q=>Q.layout.chat),T=Nu(),j=P(Q=>Q.layout.design),C=P(Q=>{var ae;return((ae=Q.overlay)==null?void 0:ae.kind)==="keys"}),M=$j(),I=(y==null?void 0:y.worktree.id)??null,O=P(Q=>Q.archivedPage!==null||Q.notesPage),A=!!y&&jh(y)&&!O,z=P(Q=>Q.chatSide)==="left",B=!T&&d.jsx(Rt,{icon:"branch",label:"Changes panel",hint:zt("changes"),tone:"chrome",on:x,onClick:()=>f({a:"toggle-changes"})}),U=!T&&!v&&d.jsx(Rt,{icon:"chat",label:"Chat panel",hint:zt("composer"),tone:"chrome",on:_,onClick:()=>f({a:"toggle-chat"})});return d.jsxs("div",{className:"top-bar",ref:r,"data-float-up":o||void 0,children:[N&&d.jsx("span",{className:"bar-zen-title",children:(y==null?void 0:y.worktree.title)??"Toyon"}),d.jsxs("span",{className:"bar-lead",ref:i,children:[z?U:B,d.jsx(wq,{}),M&&d.jsx(Ou,{icon:"download","data-tip":"Install Toyon as an app (own window, dock icon)",onClick:()=>void M.prompt(),children:"install app"}),d.jsx(vq,{}),d.jsx(bq,{}),d.jsx(xq,{})]}),!v&&d.jsx(yq,{worktreeId:I,repoId:(y==null?void 0:y.repoId)??null,ready:A,left:h.left,width:h.width}),d.jsx("span",{className:"bar-grow"}),d.jsxs("span",{className:"bar-tools",ref:c,children:[d.jsx(Eq,{}),d.jsx(Rt,{icon:"settings",label:"Settings & shortcuts",hint:zt("keys"),tone:"chrome",on:C,"aria-controls":"keys-help","aria-expanded":C,onClick:()=>f({a:"toggle",overlay:{kind:"keys"}}),...w.contextMenu(()=>jT(g.getState(),{sock:m,dispatch:f}))}),!T&&!v&&d.jsx(Rt,{icon:"palette",label:"Design system",hint:zt("design"),tone:"chrome",on:j,onClick:()=>f({a:"toggle-design"})}),z?B:U,!v&&d.jsx(Rt,{icon:"zen",className:"bar-zen",label:"Full-bleed preview",hint:zt("zen"),tone:"chrome",on:N,onClick:()=>f({a:"toggle-zen"})})]})]})}function wq(){const e=lt(),t=tt(),n=ql(),r=P(f=>f.activeRepoId),o=P(f=>f.repos),i=wn("bar"),a=()=>Bn([[{id:"project",label:o.length>1?"switch project…":"open project…",key:zt("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?Kh(n,r,{sock:t,dispatch:e}):[]]),c=P(f=>{var m;return((m=f.overlay)==null?void 0:m.kind)==="projects"&&f.overlay.form==="pill"}),u=P(f=>f.heard),h=P(f=>f.newProject!==null);return d.jsxs("span",{className:"bar-project",children:[d.jsx(De,{tone:"chrome",className:"bar-pill",on:c,...Pt(o.length>1?"Switch project":"Open a project",zt("project")),onClick:()=>e({a:"toggle",overlay:{kind:"projects",form:"pill"}}),...i.contextMenu(a),children:d.jsx("span",{className:"bar-project-name",children:h?"new project":(n==null?void 0:n.name)??(u?"open project":"")})}),c&&d.jsx(_y,{form:"pill"})]})}function yq({worktreeId:e,repoId:t,ready:n,left:r,width:o}){const i=It(e,"page").url,a=lt(),c=P(w=>{var y;return((y=w.overlay)==null?void 0:y.kind)==="routes"}),u=P(w=>w.previewSize);ut([e,n],()=>{c&&a({a:"close"})});const f=wn("bar").contextMenu(()=>n?pq(i,{reload:()=>e&&dn.post(e,{type:"reload"})}):[]),m=P(w=>w.picking),g=Sw();return d.jsxs("div",{className:"bar-center",style:{left:r,width:o},children:[d.jsx(Rt,{icon:"back",label:"Back",hint:zt("back"),disabled:!n,onClick:()=>e&&dn.post(e,{type:"back"}),...f}),d.jsx(Rt,{icon:"forward",label:"Forward",hint:zt("forward"),disabled:!n,onClick:()=>e&&dn.post(e,{type:"forward"}),...f}),d.jsx(Rt,{icon:"reload",label:"Reload preview",hint:zt("reload"),disabled:!n,onClick:()=>e&&dn.post(e,{type:"reload"}),...f}),d.jsxs("span",{className:"bar-route",children:[n&&e&&t?d.jsx(tH,{worktreeId:e,repoId:t,url:i,open:c},e):d.jsx(Do,{className:"bar-path",value:"",readOnly:!0,disabled:!0}),u&&d.jsx("span",{className:"bar-size",children:u})]}),d.jsx(Rt,{icon:"inspect",label:"Pick an element to open its code",hint:zt("inspect"),also:{text:"Add an element to chat",key:zt("pick")},on:m==="code",disabled:!n||!g,onClick:()=>g&&au(g,m,a,"code")})]})}function Ou({icon:e,busy:t,children:n,...r}){return d.jsxs(De,{disabled:t,...r,children:[!t&&d.jsx(St,{name:e,className:"icon-inline"}),d.jsx("span",{className:He(t&&"live-text"),children:n})]})}function vq(){const e=P(u=>u.self),t=P(u=>u.rebuilt),n=P(u=>u.repos),r=tt(),o=P(u=>{var h;return((h=u.update)==null?void 0:h.restarting)!=null}),i=f$(e,n,t);if(!i||o)return null;const a=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(Ou,{icon:"reload",busy:i.busy,onClick:c,...Pt(i.text,void 0,{detail:i.detail}),children:a})}function bq(){const e=P(o=>o.update),t=P(o=>o.managed.updates),n=tt(),r=d5(e);return!r||!t?null:d.jsx(Ou,{icon:"reload",busy:r.busy,onClick:()=>{r.retry&&(n==null||n.send({t:"update-now"}))},...Pt(r.text),children:r.word})}function xq(){const e=lt(),t=P(V4),n=P(a=>a.ranBefore),r=P(a=>a.newProject!==null);if(!t||!n||r)return null;const{word:o,text:i}=cZ(n,t);return d.jsx(Ou,{icon:"book",onClick:()=>e({a:"open-release-notes"}),...Pt(i),children:o})}function Eq(){const e=lt(),t=P(uD),n=P(i=>i.letIn),r=P(i=>{var a;return((a=i.overlay)==null?void 0:a.kind)==="devices"});if(!t)return null;const o=()=>e({a:"toggle",overlay:{kind:"devices"}});return n?d.jsx(Rt,{icon:"devices",label:"Your devices",tone:"chrome",on:r,"aria-expanded":r,onClick:o}):d.jsx(Ou,{icon:"devices","aria-expanded":r,onClick:o,...Pt("Open this machine on your phone, and let it in"),children:"open on phone"})}function Sq(e,t,n){return t==="left"?n-e.left:e.right-n}const _q="input, textarea, [contenteditable], .monaco-editor, .xterm, iframe";function Nq(){const e=Un(),t=lt(),n=tt(),r=Nu(),o=Na(),i=Tu(),a=P(V=>V.zen)&&!i,c=_a(),u=P(V=>V.notesPage),h=!!Ew()||!!c||u,f=P(V=>V.layout.changes)&&!r,m=P(V=>V.layout.chat)&&!r&&!i&&!h,g=P(V=>V.chatSide),w=P(V=>V.railOpen),[y,v]=xo(Ke.changesWidth,220,V=>V?Jd(Number(V),220):void 0),[N,x]=xo(Ke.chatWidth,380,V=>V?Jd(Number(V),380):void 0),[_,T]=xo(Ke.railWidth,280,V=>V?Jd(Number(V),280):void 0),j=(V,X,W)=>{const se=X.classList.contains("left")?"left":"right",ce=se==="left"?X.previousElementSibling:X.nextElementSibling;return ce?Jd(Sq(ce.getBoundingClientRect(),se,V.clientX),W):null},C=jl((V,X)=>j(V,X,220),v),M=jl((V,X)=>j(V,X,380),x),I=jl((V,X)=>j(V,X,280),T),[O,A]=S.useState(null),B=wn("app").contextMenu(()=>xT(e.getState(),{sock:n,dispatch:t})),U=d.jsx(DN,{width:y}),Q=!i&&!h&&d.jsx(hq,{width:N}),ae=!r&&d.jsx(b$,{width:_}),ee=V=>!r&&w&&d.jsx("div",{className:`dock-resize ${V}`,onPointerDown:I}),de=g==="left",$=de?{dock:Q,open:m,drag:M}:{dock:U,open:f,drag:C},K=de?{dock:U,open:f,drag:C}:{dock:Q,open:m,drag:M};return d.jsxs("div",{className:He("app",a&&"zen"),"data-chat-side":g,"data-touch":o||void 0,"data-hover":!o||void 0,onContextMenu:V=>{V.defaultPrevented||V.target instanceof Element&&V.target.closest(_q)||B.onContextMenu(V)},children:[d.jsx(oN,{}),d.jsx(lN,{}),d.jsx(kq,{center:O}),d.jsxs("div",{className:"docks",children:[de&&ae,de&&ee("left"),$.dock,$.open&&d.jsx("div",{className:"dock-resize left",onPointerDown:$.drag}),d.jsx(fq,{onRoot:A}),K.open&&d.jsx("div",{className:"dock-resize right",onPointerDown:K.drag}),K.dock,!de&&ee("right"),!de&&ae]})]})}function Tq(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 a=t[i+r];if(a)return{activate:a.id};const c=e[e.length-1];return r<0&&c?{activate:c.id}:null}const jq=new Set(["design","chats"]),$q=new Set(["back","forward"]),Cq=new Set(["project","commands","keys","zen"]);function Aq(){const e=Un(),t=tt();S.useEffect(()=>{const n=FK(f=>e.dispatch({a:"rail-peek",on:f})),r=n.end,o=f=>{e.getState().railOpen||n.press(f)},i=f=>n.keyup(f.key),a=f=>n.mods(f),c=()=>{var w,y;const f=e.getState(),g=((y=(w=document.activeElement)==null?void 0:w.closest("[data-pane]"))==null?void 0:y.dataset.pane)??(f.layout.term?"terminal":f.editor?"editor":f.layout.design?"design":null);g==="terminal"?e.dispatch({a:"toggle-terminal"}):g==="editor"?e.dispatch({a:"close-editor"}):g==="design"&&e.dispatch({a:"toggle-design"})},u=f=>{f.key!=="Escape"||!e.getState().choosingFolder||(f.stopImmediatePropagation(),t==null||t.send({t:"cancel-folder"}),e.dispatch({a:"choosing-folder",v:!1}))},h=f=>{var N,x,_,T;a(f),iA(f)&&!f.defaultPrevented&&f.preventDefault();const m=e.getState(),{dispatch:g}=e,w=j=>{const C=document.activeElement,M=!C||C===document.body||!!C.closest(".rail, .chat-input");g({a:"activate",id:j}),M&&g({a:"walked"})},y=uE(f,{guest:!!((N=document.activeElement)!=null&&N.closest(".xterm"))});if(!(m.zen&&!rs(m)&&!m.overlay&&!m.picking&&!(y&&sA.has(y.id))||(y==null?void 0:y.id)==="close"&&!sw()||(x=document.activeElement)!=null&&x.closest(".monaco-editor")&&y&&jq.has(y.id))&&!(y&&dA(y.id,document.activeElement))&&!(y&&$q.has(y.id)&&!(vl(m)&&Hf(m)))&&!((y==null?void 0:y.id)==="reload"&&!Ag(m))){if(y){const j=f.defaultPrevented;if(f.preventDefault(),m.newProject&&!Cq.has(y.id))return;switch(y.id){case"worktree":{const C=lA(y.digit,m.visible.length),M=C===null?void 0:m.visible[C];M&&w(M.id);break}case"wt-prev":case"wt-next":{const C=Tq(m.visible,m.visibleDiscovered,m.activeId,y.id==="wt-next"?1:-1);C&&w(C.activate),o(f);break}case"wt-unseen-prev":case"wt-unseen-next":{const C=oy(m.visible,m.activeId,y.id==="wt-unseen-next"?1:-1);C&&w(C.activate),o(f);break}case"mark-unread":m.activeId&&!m.draft&&m.visible.some(C=>C.id===m.activeId)&&EN(t,g,m.activeId);break;case"wt-archive":{if(f.repeat||j)break;const C=m.draft||m.archivedPage?void 0:m.visible.find(M=>M.id===m.activeId);C&&SN(t,g,M=>dw(m,M)).archive(C);break}case"new":g({a:"open-draft"});break;case"project":g({a:"toggle",overlay:{kind:"projects",form:"center"}});break;case"quick-open":((_=m.overlay)==null?void 0:_.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"}):Hf(m)&&g({a:"open",overlay:{kind:"routes"}});break;case"reload":{const C=Ag(m);if(!C)break;C.act==="frame"?dn.post(C.id,{type:"reload"}):t==null||t.send({t:"preview-start",worktreeId:C.id});break}case"back":case"forward":{const C=vl(m);C&&dn.post(C,{type:y.id});break}case"pick":case"inspect":{const C=vl(m);C&&au(C,m.picking,g,y.id==="pick"?"chat":"code");break}case"search":m.activeId&&g({a:"toggle",overlay:{kind:"search"}});break;case"refs":m.activeRepoId&&g({a:"toggle",overlay:{kind:"refs"}});break;case"chats":m.activeRepoId&&g({a:"toggle",overlay:{kind:"chats"}});break;case"commands":g({a:"toggle",overlay:{kind:"commands"}});break;case"zen":g({a:"toggle-zen"});break;case"close":!(m.zen&&!rs(m))&&!m.overlay&&c();break;case"changes":g(m.layout.changes&&(Dl(m)==="changes"||Fo(m)!==null)?{a:"toggle-changes"}:{a:"focus-changes",tab:"changes"});break;case"files":g(m.layout.changes&&Dl(m)==="files"?{a:"toggle-changes"}:{a:"focus-changes",tab:"files"});break;case"panel-tab-prev":case"panel-tab-next":if(Th(m))break;g(m.layout.changes?{a:"focus-changes",tab:G4(m,y.id==="panel-tab-next"?1:-1)}:{a:"focus-changes"});break;case"composer":g(PS(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 C=m.rows.find(A=>A.id===m.activeId);if(!C)break;const M=Xr(m,m.activeId).termStream;if(C.login&&M===Os)break;const I=[Po,...C.login?[Os]:[],...C.procs.map(A=>A.name)],O=I.indexOf(M);g({a:"term-stream",id:C.id,stream:I[(O+1)%I.length]??Po});break}}}else if(f.key==="Escape")if(m.newProject)m.newProject.phase==="editing"&&g({a:"close-new-project"});else if(m.picking){const j=vl(m);j&&dn.post(j,{type:"pick-cancel"}),g({a:"set-picking",v:!1})}else m.notesPage?g({a:"close-release-notes"}):m.archivedPage?g({a:"close-archived"}):m.activeImportId?g({a:"watch-import",id:null}):c()}};return window.addEventListener("keydown",u,!0),window.addEventListener("keydown",h),window.addEventListener("keyup",i),window.addEventListener("pointermove",a),window.addEventListener("pointerdown",a),window.addEventListener("blur",r),()=>{window.removeEventListener("keydown",u,!0),window.removeEventListener("keydown",h),window.removeEventListener("keyup",i),window.removeEventListener("pointermove",a),window.removeEventListener("pointerdown",a),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&&dn.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 Iq=3,Rq=2e3,Oq=200,Mq=5e3;function Pq(){const e=lt(),t=tt(),n=mo(),{storage:r}=n,o=Zl(),i=P(H=>H.activeRepoId),a=Ps(),c=bw(),u=P(H=>H.connected),h=P(H=>H.daylight),f=P(H=>{var ve;return((ve=H.daylight)==null?void 0:ve.until)??0}),m=_a(),g=P(H=>H.notesPage),w=P(H=>H.version),y=P(H=>H.railOpen),v=P(H=>H.chatSide),N=P(H=>H.layouts),x=P(H=>H.lastActive),_=P(H=>H.discoveredOpen),T=P(H=>H.archivedOpen),j=P(H=>H.committedShut),C=P(H=>H.turnOpen),M=P(H=>H.treeOpen),I=Ch(),O=P(H=>H.previewTheme!==null),A=P(H=>H.openUrl),z=g_();S.useEffect(()=>zl.install(window),[]);const B=S.useRef([]),U=S.useCallback(H=>t==null?void 0:t.send({t:"subscribe",worktreeId:H,since:n.since(H)}),[t,n]);S.useEffect(()=>{if(!t||!u||!o)return;const H=[o,...B.current.filter(ve=>ve!==o)];for(const ve of H.splice(Iq))t.send({t:"unsubscribe",worktreeId:ve});B.current.includes(o)||U(o),B.current=H},[o,u,t,U]),S.useEffect(()=>{if(!(!t||!u))for(const H of B.current)U(H)},[u,t,U]);const Q=S.useRef(void 0);S.useEffect(()=>{if(!t||!u)return;let H;const ve=()=>{const J=document.visibilityState==="visible"?o:null;t.send({t:"view",worktreeId:J}),Q.current=J},Se=()=>{clearTimeout(H),H=setTimeout(ve,Oq)};Q.current===void 0||Q.current===o||document.visibilityState!=="visible"?ve():Se();const ye=()=>document.visibilityState==="visible"?Se():ve();return document.addEventListener("visibilitychange",ye),()=>{clearTimeout(H),document.removeEventListener("visibilitychange",ye)}},[o,u,t]);const ae=(m==null?void 0:m.id)??null;S.useEffect(()=>{if(!(!t||!u||!ae))return U(ae),()=>t.send({t:"unsubscribe",worktreeId:ae})},[ae,u,t,U]),S.useEffect(()=>{const H=new Set(z.map(Se=>Se.id)),ve=B.current.filter(Se=>!H.has(Se));if(ve.length!==0&&(B.current=B.current.filter(Se=>H.has(Se)),!(!t||!u)))for(const Se of ve)t.send({t:"unsubscribe",worktreeId:Se})},[z,u,t]);const ee=g?"Release notes":(m==null?void 0:m.title)??(c==null?void 0:c.name)??null;S.useEffect(()=>{document.title=ee?`${ee} · Toyon`:"Toyon"},[ee]);const de=!!(a!=null&&a.unseen),$=P(H=>H.unreadHold!==null&&H.unreadHold===H.activeId);S.useEffect(()=>{if(!t||!o||!de||$)return;let H;const ve=()=>document.visibilityState==="visible"&&document.hasFocus(),Se=()=>{clearTimeout(H),ve()&&(H=setTimeout(()=>{ve()&&t.send({t:"seen",worktreeId:o})},Rq))},ye=()=>clearTimeout(H);return Se(),window.addEventListener("focus",Se),window.addEventListener("blur",ye),()=>{ye(),window.removeEventListener("focus",Se),window.removeEventListener("blur",ye)}},[t,o,de,$]);const K=S.useRef(0),V=P(H=>fw(H));S.useEffect(()=>{if(!t||!u||!i)return;const H=()=>{Date.now()-K.current<Mq||(K.current=Date.now(),t.send({t:"refresh-git",repoId:i}),V&&V!==i&&t.send({t:"refresh-git",repoId:V}))};return window.addEventListener("focus",H),()=>window.removeEventListener("focus",H)},[t,u,i,V]);const X=P(H=>H.frame==="phone"&&H.screen==="home"?"surface1":"surface0");S.useEffect(()=>{try{sessionStorage.setItem(Ke.ground,X)}catch{}},[X]);const W=P(H=>H.frame==="phone"),se=P(H=>H.blackGround),ce=S.useMemo(()=>W&&se?uL(I):I,[W,se,I]);S.useEffect(()=>{try{localStorage.setItem(Ke.blackGround,se?"1":"0")}catch{}},[se]),S.useEffect(()=>{S$(ce,{remember:!O,ground:X,black:ce!==I}),dn.broadcast(_$(ce))},[ce,I,O,X]);const he=S.useCallback(()=>{t==null||t.send({t:"zone",tz:Intl.DateTimeFormat().resolvedOptions().timeZone})},[t]);S.useEffect(()=>{if(!u)return;he();const H=()=>{document.visibilityState==="visible"&&he()};return document.addEventListener("visibilitychange",H),()=>document.removeEventListener("visibilitychange",H)},[u,he]),S.useEffect(()=>{if(!u||f<=Date.now())return;const H=setTimeout(he,f-Date.now()+1e3);return()=>clearTimeout(H)},[u,f,he]),S.useEffect(()=>{h&&h.until>0&&aZ(h)},[h]),S.useEffect(()=>{o&&r.set(Ke.active,o)},[o,r]),S.useEffect(()=>{w&&r.set(Ke.version,w)},[w,r]);const je=P(H=>H.frame==="phone"?H.screen!=="home":null);S.useEffect(()=>{je!==null&&r.session.set(Ke.phoneRow,je?"1":"0")},[je,r]),S.useEffect(()=>{i&&r.set(Ke.repo,i)},[i,r]),S.useEffect(()=>{try{localStorage.setItem(Ke.rail,y?"1":"0")}catch{}},[y]),S.useEffect(()=>{try{localStorage.setItem(Ke.chatSide,v)}catch{}},[v]),S.useEffect(()=>{try{localStorage.setItem(Ke.layouts,JSON.stringify(N))}catch{}},[N]),S.useEffect(()=>{r.set(Ke.lastActive,JSON.stringify(x))},[x,r]),S.useEffect(()=>{r.set(Ke.discoveredOpen,JSON.stringify(_))},[_,r]),S.useEffect(()=>{r.set(Ke.archivedOpen,JSON.stringify(T))},[T,r]),S.useEffect(()=>{r.set(Ke.committedShut,JSON.stringify(j))},[j,r]),S.useEffect(()=>{r.set(Ke.turnOpen,JSON.stringify(C))},[C,r]),S.useEffect(()=>{r.set(Ke.treeOpen,JSON.stringify(M))},[M,r]),Aq(),w3();const $e=S.useRef(null);return S.useEffect(()=>{!A||$e.current===A||($e.current=A,window.open(A,"_blank"),e({a:"opened-url"}))},[A,e]),P(H=>H.frame)==="phone"?d.jsx(tZ,{}):d.jsx(Nq,{})}function Lq({origin:e,machine:t,onToken:n}){const[r,o]=S.useState({kind:"asking"}),[i,a]=S.useState(0);return ut([i],()=>{const c=new AbortController;return o({kind:"asking"}),kS(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(ys,{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.":g$(r.failure,e,"this device")}),r.kind==="failed"&&d.jsx("div",{className:"status-actions",children:d.jsx(De,{variant:"outline",onClick:()=>a(c=>c+1),children:"ask again"})})]})}const pg="toyon-shared",Dq="x-toyon-name";async function zq(e=globalThis.caches){var t;try{if(!e||!await e.has(pg))return[];const n=await e.open(pg),r=[];for(const o of await n.keys()){const i=await n.match(o);if(!i)continue;const a=decodeURIComponent(i.headers.get(Dq)??"")||"shared",c=((t=(i.headers.get("content-type")??"").split(";")[0])==null?void 0:t.trim())??"";r.push(new File([await i.blob()],a,{type:c}))}return await e.delete(pg),r}catch{return[]}}function V1(e,t=()=>!0){const n=()=>t()?Ta(e):null;return new Promise(r=>{const o=n();if(o)return r(o);const i=e.subscribe(()=>{const a=n();a&&(i(),r(a))})})}function Fq(e){const[t]=e;if(e.length===1&&t)return`pick a chat for ${t.name}`;const n=e.every(r=>r.type.startsWith("image/"))?"images":"files";return`pick a chat for ${e.length} ${n}`}async function Bq(e,t){const n=await zq(t);if(n.length===0)return;if(e.getState().frame!=="phone"){Wf(e,await V1(e),n);return}e.dispatch({a:"screen",to:"home"}),e.dispatch({a:"sharing",v:Fq(n)});const r=await V1(e,()=>e.getState().screen!=="home");e.dispatch({a:"sharing",v:null}),Wf(e,r,n)}function Uq(){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(GC(t.worktreeId,t.stream))??[])n(t)}}}const Hq=2e3,Wq=1500;function Kq(e,t,n,r={}){const o=r.timers??{set:(M,I)=>setTimeout(M,I),clear:M=>clearTimeout(M)},i=r.now??(()=>Date.now()),a=r.win??(typeof window>"u"?null:window),c=new Map,u=M=>{let I=c.get(M);return I||(I=new P4,c.set(M,I)),I},h=new Map,f=new Map,m=M=>{var z;o.clear(f.get(M)),f.delete(M);const I=e.getState();if(M===""){if(!I.heard)return;const B=$4(I,i());if(!B)return;const U=M4(Object.fromEntries([...h].map(([Q,ae])=>[Q,{at:ae}])),I.rows);for(const Q of U)h.delete(Q),c.delete(Q);t.putHello(n,B).then(()=>U.length?t.dropChats(n,U):void 0);return}const O=c.get(M);if(!O||!I.rows.some(B=>B.id===M))return;const A=i();h.set(M,A),t.putChat(n,M,O.snapshot((z=I.local[M])==null?void 0:z.draft,A))},g=M=>{f.has(M)||f.set(M,o.set(()=>m(M),Hq))},w=()=>{for(const M of[...f.keys()])m(M)};let y=e.getState();const v=new Map,N=e.subscribe(()=>{var I;const M=e.getState();if(M.heard&&(!y.heard||M.rows!==y.rows||M.repos!==y.repos||M.trunks!==y.trunks||M.handed!==y.handed||M.visits!==y.visits)&&g(""),M.local!==y.local)for(const O of c.keys()){const A=((I=M.local[O])==null?void 0:I.draft)??"";(v.get(O)??"")!==A&&(v.set(O,A),g(O))}y=M}),x=()=>{var M;((M=a==null?void 0:a.document)==null?void 0:M.visibilityState)==="hidden"&&w()};a==null||a.addEventListener("visibilitychange",x),a==null||a.addEventListener("pagehide",w);const _=Promise.all([t.hello(n),t.chats(n)]);let T;const j=new Promise(M=>{T=o.set(()=>M(null),Wq)});return{recalled:Promise.race([_,j]).then(M=>{if(o.clear(T),!M)return;const[I,O]=M;for(const[z,B]of Object.entries(O))h.set(z,B.at);if(!I||!Cb(I)||e.getState().heard)return;const A={};for(const[z,B]of Object.entries(O))Cb(B)&&(A[z]=B);try{e.dispatch({a:"recall",hello:I,chats:A})}catch(z){console.error("the last-known machine could not be recalled; dropping it",z),h.clear(),t.clear(n);return}for(const[z,B]of Object.entries(A))u(z).reset(B.events,B.seq,!1),v.set(z,B.draft??"")}).catch(M=>{console.error("the last-known machine could not be read",M)}),hear(M){var I;if(M.t==="backfill"){const O=u(M.worktreeId);g(M.worktreeId);const A=(((I=e.getState().local[M.worktreeId])==null?void 0:I.chat.length)??0)>0;if(M.after!==void 0&&M.after===O.since()&&A)return O.extend(M.events,M.last),M;if(O.reset(M.events,M.last,M.after===void 0),M.after===void 0)return M;const{after:z,...B}=M;return B}return M.t==="agent"&&(u(M.worktreeId).add(M.seq,M.event),g(M.worktreeId)),M},since:M=>{var I;return(I=c.get(M))==null?void 0:I.since()},forget(){for(const M of[...f.keys()])o.clear(f.get(M)),f.delete(M);c.clear(),h.clear(),t.clear(n)},dispose(){N(),a==null||a.removeEventListener("visibilitychange",x),a==null||a.removeEventListener("pagehide",w),w()}}}function Zq(){const e=new Map,t=n=>{const r=co.chats(n),o={};for(const[i,a]of e)i.startsWith(r)&&(o[i.slice(r.length)]=a);return o};return{hello:async n=>e.get(co.hello(n))??null,putHello:async(n,r)=>void e.set(co.hello(n),r),chats:async n=>t(n),putChat:async(n,r,o)=>void e.set(co.chat(n,r),o),dropChats:async(n,r)=>{for(const o of r)e.delete(co.chat(n,o))},clear:async n=>{e.delete(co.hello(n));for(const r of[...e.keys()])r.startsWith(co.chats(n))&&e.delete(r)}}}function R$(){if(typeof indexedDB>"u")return Zq();let e=null;const t=()=>(e??(e=new Promise((i,a)=>{const c=indexedDB.open(TL,1);c.onupgradeneeded=()=>c.result.createObjectStore(Ac),c.onsuccess=()=>i(c.result),c.onerror=()=>a(c.error),c.onblocked=()=>a(new Error("blocked"))}).catch(i=>{throw e=null,i})),e),n=async(i,a)=>{const c=(await t()).transaction(Ac,i).objectStore(Ac);return new Promise((u,h)=>{const f=a(c);f.onsuccess=()=>u(f.result),f.onerror=()=>h(f.error)})},r=i=>{const a=co.chats(i);return IDBKeyRange.bound(a,`${a}`)},o=async(i,a)=>{try{return await i}catch{return a}};return{hello:i=>o(n("readonly",a=>a.get(co.hello(i))),void 0).then(a=>a??null),putHello:(i,a)=>o(n("readwrite",c=>c.put(a,co.hello(i))),void 0).then(()=>{}),chats:async i=>{const a=co.chats(i),[c,u]=await o((async()=>{const f=(await t()).transaction(Ac,"readonly").objectStore(Ac),m=g=>new Promise((w,y)=>{g.onsuccess=()=>w(g.result),g.onerror=()=>y(g.error)});return Promise.all([m(f.getAllKeys(r(i))),m(f.getAll(r(i)))])})(),[[],[]]),h={};return c.forEach((f,m)=>{const g=u[m];typeof f=="string"&&g&&(h[f.slice(a.length)]=g)}),h},putChat:(i,a,c)=>o(n("readwrite",u=>u.put(c,co.chat(i,a))),void 0).then(()=>{}),dropChats:async(i,a)=>{for(const c of a)await o(n("readwrite",u=>u.delete(co.chat(i,c))),void 0)},clear:async i=>{await o(n("readwrite",a=>a.delete(co.hello(i))),void 0),await o(n("readwrite",a=>a.delete(r(i))),void 0)}}}function qq(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 Gq(e){const t={};try{const n=JSON.parse(e??"{}");if(!n||typeof n!="object")return t;for(const[r,o]of Object.entries(n))z4(o)&&(t[r]=o)}catch{}return t}function Vq(e){const t={};try{const n=JSON.parse(e??"{}");if(!n||typeof n!="object")return t;for(const[r,o]of Object.entries(n))typeof o=="string"&&o&&(t[r]=o)}catch{}return t}function hf(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 Yq(e){const t={};try{const n=JSON.parse(e??"{}");if(!n||typeof n!="object")return t;for(const[r,o]of Object.entries(n))Array.isArray(o)&&o.every(i=>typeof i=="string")&&o.length>0&&(t[r]=o)}catch{}return t}const Xq=400,Qq=2e3;function O$(){const e=new Map;return{another(t,n=0){return(e.get(t)??0)===n?!1:(e.set(t,n),!0)}}}function M$(e,t,n){const r=e.getState(),o=[];for(const[i,a]of t){if(a===n||r.local[i])continue;const c=ms(i);c&&c.clientId!==r.clientId||o.push(i)}return o}function Jq(e,t){const n=new Map,r=new Map,o=O$(),i=u=>{var f,m;clearTimeout((f=r.get(u))==null?void 0:f.timer),r.delete(u);const h=e.getState().local[u];!h||((m=h.mark)==null?void 0:m.by)==="walk"||(n.get(u)??"")!==h.draft&&(n.set(u,h.draft),t.send({t:"set-draft",boxId:u,text:h.draft,clientId:e.getState().clientId}))},a=()=>{for(const u of[...r.keys()])i(u)},c=e.subscribe(()=>{var u,h,f;for(const[m,g]of Object.entries(e.getState().local)){if(o.another(m,g.sent)&&(clearTimeout((u=r.get(m))==null?void 0:u.timer),r.delete(m),n.set(m,"")),((h=g.mark)==null?void 0:h.by)==="walk"||(n.get(m)??"")===g.draft)continue;if(!g.draft){i(m);continue}const w=r.get(m);if((w==null?void 0:w.text)===g.draft)continue;clearTimeout(w==null?void 0:w.timer);const y=(w==null?void 0:w.since)??Date.now(),v=Math.max(0,Math.min(Xq,y+Qq-Date.now()));r.set(m,{text:g.draft,timer:setTimeout(i,v,m),since:y})}for(const m of M$(e,n,""))clearTimeout((f=r.get(m))==null?void 0:f.timer),r.delete(m),n.set(m,""),t.send({t:"set-draft",boxId:m,text:"",clientId:e.getState().clientId})});return window.addEventListener("focusout",a),window.addEventListener("pagehide",a),{hello(u){n.clear();for(const[h,f]of Object.entries(u))n.set(h,f)},heard(u,h){return r.has(u)?!1:(n.set(u,h),!0)},dispose(){c();for(const u of r.values())clearTimeout(u.timer);r.clear(),window.removeEventListener("focusout",a),window.removeEventListener("pagehide",a)}}}function eG(e,t){const n=new Map,r=new Map,o=O$(),i=e.subscribe(()=>{const a=[];for(const[c,u]of Object.entries(e.getState().local)){if(o.another(c,u.sent)&&r.set(c,"[]"),n.get(c)===u.attachments)continue;n.set(c,u.attachments);const h=lw(u.attachments),f=JSON.stringify(h),m=r.get(c)??"[]";m!==f&&(r.set(c,f),a.push({id:c,items:h,before:$S(JSON.parse(m))}))}for(const c of M$(e,r,"[]"))r.set(c,"[]"),a.push({id:c,items:[],before:[]});for(const c of N4(a))t.send({t:"set-attachments",boxId:c.id,items:c.items,clientId:e.getState().clientId})});return{hello(a){r.clear(),n.clear();for(const[c,u]of Object.entries(a))r.set(c,JSON.stringify(u))},heard(a,c){r.set(a,JSON.stringify(c))},dispose:i}}function tG(e,t){return e.subscribe(()=>{for(const n of _4(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(Fc(o.outgoing.frame,n,o.draft,o.attachments)),e.dispatch({a:"sent-out",id:n}))}})}const Y1="not sent: the page reloaded while an upload was on its way; attach it again and send";function X1(e,t,n){var a;const r=e.getState(),o=new Set([...Object.keys(n.drafts),...Object.keys(n.attachments)]),i=[];for(const c of o){const u=ms(c);if((u==null?void 0:u.clientId)!==r.clientId||(a=r.local[c])!=null&&a.outgoing)continue;const h=n.drafts[c]??"",f=n.attachments[c]??[],m=n.drafts[u.source]??"",g=[...f,...n.attachments[u.source]??[]],w=m||h,y=r.clientId;g.length&&t.send({t:"set-attachments",boxId:u.source,items:g,clientId:y}),w!==m&&t.send({t:"set-draft",boxId:u.source,text:w,clientId:y}),t.send({t:"set-attachments",boxId:c,items:[],clientId:y}),t.send({t:"set-draft",boxId:c,text:"",clientId:y}),delete n.drafts[c],delete n.attachments[c],w&&(n.drafts[u.source]=w),g.length&&(n.attachments[u.source]=g),i.push(u.source)}return i}function nG(e,t){const n=(t.storage??jL)(e.origin),r=ND(B4({cached:t.cached,systemDark:t.systemDark,daylight:t.daylight,storedActive:n.get(Ke.active),storedPhoneRow:n.session.get(Ke.phoneRow)==="1",storedRepo:n.get(Ke.repo),storedVersion:n.get(Ke.version),storedRailOpen:pf(Ke.rail)==="1",storedChatSide:pf(Ke.chatSide)==="right"?"right":"left",storedBlackGround:pf(Ke.blackGround)==="1",storedLayouts:Gq(pf(Ke.layouts)),storedLastActive:Vq(n.get(Ke.lastActive)),storedDiscoveredOpen:hf(n.get(Ke.discoveredOpen)),storedArchivedOpen:hf(n.get(Ke.archivedOpen)),storedCommittedShut:hf(n.get(Ke.committedShut)),storedTurnOpen:hf(n.get(Ke.turnOpen)),storedTreeOpen:Yq(n.get(Ke.treeOpen)),clientId:t.clientId,frame:t.frame,touch:t.touch})),o=Uq(),i={version:null,protocol:null},a=z8(v=>r.dispatch({a:"server",msg:v}));let c,u,h;const f=Kq(r,t.snapshots??R$(),e.origin);let m=[];const g=new GL(e,v=>{if(v.t==="hello"){if(i.protocol=v.protocol,e.serving){const{rebuilt:x,update:_}=r.getState(),T=x&&(_==null?void 0:_.restarting)!=null;if(i.version!==null&&(T||v.version!==i.version||v.protocol!==da)){g.dispose(),t.reload();return}if(v.protocol!==da){r.dispatch({a:"incompatible"}),g.dispose();return}}else if(v.protocol!==da){r.dispatch({a:"incompatible"}),g.suspend();return}else r.getState().incompatible&&r.dispatch({a:"incompatible",v:!1});i.version=v.version;const N=new Set(g.sentWhileDown());if(N.size){const x=_=>Object.fromEntries(Object.entries(_).filter(([T])=>!N.has(T)));v.drafts=x(v.drafts),v.attachments=x(v.attachments)}m=X1(r,g,v),c.hello(v.drafts),u.hello(v.attachments)}if(v.t==="attachments"&&v.clientId!==r.getState().clientId&&u.heard(v.boxId,v.items),!(v.t==="draft"&&v.clientId!==r.getState().clientId&&!c.heard(v.boxId,v.text))){if(gP(v)){o.deliver(v);return}if(kP(v)){if(v.t==="file-written"&&Nz(v))return;h.receive(v);return}if(v.t==="loose-written"){WH(v);return}if(O6(v)){D6(r,g,v);return}if(v.t==="open-refused"){L6(r,v);return}a(f.hear(v));for(const N of m.splice(0))r.dispatch({a:"notice",id:N,text:Y1})}},(v,N)=>r.dispatch({a:"connected",v,failure:N}),{},{known:()=>vD(r.getState()),held:e.serving});Cz(r,g.urls),h=new UH({store:r,send:v=>g.send(v),timers:{set:(v,N)=>setTimeout(v,N),clear:v=>clearTimeout(v)},win:window});const w=h.start();c=Jq(r,g),u=eG(r,g);const y=tG(r,g);return{origin:e.origin,serving:e.serving,token:e.token,get name(){return r.getState().machine??qq(e.origin)},store:r,sock:g,files:h,terminals:o,storage:n,heard:i,recalled:f.recalled,forget:()=>f.forget(),boot(v){try{if((v==null?void 0:v.t)==="hello"&&v.protocol===da){i.version??(i.version=v.version);const N=X1(r,g,v);u.hello(v.attachments),r.dispatch({a:"server",msg:v});for(const x of N)r.dispatch({a:"notice",id:x,text:Y1})}}finally{g.resume()}},since:v=>{var N;return(N=r.getState().local[v])!=null&&N.chat.length?f.since(v):void 0},dispose(){g.dispose(),w(),c.dispose(),u.dispose(),y(),f.dispose()}}}function pf(e){try{return localStorage.getItem(e)}catch{return null}}window.__toyonShell=!0;const P$=eN();P$&&(document.documentElement.dataset.framed="");CL(location.origin);const L$=nZ();S$(L$);function rG(e,t){try{return e.getItem(t)}catch{return null}}function oG(){const e=rG(sessionStorage,Ke.client);if(e)return e;const t=Math.random().toString(36).slice(2,10);try{sessionStorage.setItem(Ke.client,t)}catch{}return t}const sG={cached:L$,systemDark:oZ(),daylight:iZ(),clientId:oG(),frame:Ow(),touch:x3(),reload:()=>window.location.reload(),snapshots:R$()},ws=cK({serving:{origin:location.origin,token:dS()},build:e=>nG(e,sG)});E3({dispatch:e=>ws.broadcast(e)});lZ(e=>ws.broadcast({a:"system-dark",v:e}));const D$=e=>P$?()=>{}:VK(e);let Q1=D$(ws.active().store),J1=ws.active();ws.subscribe(()=>{const e=ws.active();e!==J1&&(J1=e,Q1(),e.store.getState().frame==="phone"&&e.store.dispatch({a:"screen",to:"home"}),Q1=D$(e.store))});window.addEventListener("vite:preloadError",f5);const iG=Promise.all([(window.toyonBoot??Promise.resolve(null)).then(e=>{const t=e;ws.active().boot(t&&typeof t=="object"&&t.t==="hello"?t:null)}),ws.active().recalled]).catch(e=>{console.error("boot",e)});function aG(e){fS(e),window.location.reload()}const lG=FC.createRoot(document.getElementById("root"));iG.then(()=>{var e;nE.flushSync(()=>lG.render(d.jsx(MC.StrictMode,{children:d.jsx(Mw,{children:zf()?d.jsx(jD,{machines:ws,children:d.jsx(Pq,{})}):d.jsx(Lq,{origin:location.origin,machine:location.host,onToken:aG})})}))),document.documentElement.style.removeProperty("background"),document.documentElement.style.removeProperty("--boot-ink"),(e=document.getElementById("boot"))==null||e.remove(),zf()&&Bq(ws.active().store)});"serviceWorker"in navigator&&navigator.serviceWorker.register("/sw.js").catch(()=>{});export{Ls as F,bk as _,sr as a,Vk as b,hG as c,ut as d,mG as e,dG as f,dE as g,wL as h,GC as i,d as j,v6 as k,Hw as l,uE as m,uG as n,fG as p,S as r,dL as s,Su as t,pG as u,xb as w};
|