toyon 0.13.0 → 0.15.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/README.md +2 -2
- package/dist/CHANGELOG.md +602 -0
- package/dist/bridge.js +1 -1
- package/dist/cli.js +60 -53
- package/dist/daemon.js +695 -283
- package/dist/shell/assets/{Editor-CUcgZuoM.js → Editor-jjf6IGvI.js} +3 -3
- package/dist/shell/assets/{XTerm-V6sBDIe-.js → XTerm-ClBPMY5e.js} +1 -1
- package/dist/shell/assets/{cssMode-CSyiAvIn.js → cssMode-CgTk4Slg.js} +1 -1
- package/dist/shell/assets/{freemarker2-C4-FNK3V.js → freemarker2-B4Eirl4Y.js} +1 -1
- package/dist/shell/assets/{grammar-DzHb7e7O.js → grammar-E8nWrhy3.js} +1 -1
- package/dist/shell/assets/{handlebars-DcjVaOCM.js → handlebars-C6uEGz8T.js} +1 -1
- package/dist/shell/assets/{html-Csl8cogA.js → html-tDAdsEYh.js} +1 -1
- package/dist/shell/assets/{htmlMode-rewe9UaO.js → htmlMode-DXGTr81h.js} +1 -1
- package/dist/shell/assets/index-1FLxRByi.js +267 -0
- package/dist/shell/assets/index-D-4W2x1P.css +1 -0
- package/dist/shell/assets/{javascript--pKV-E-G.js → javascript-BeM3ebwd.js} +1 -1
- package/dist/shell/assets/{jsonMode-zPVc0E6l.js → jsonMode-CXStIFU4.js} +1 -1
- package/dist/shell/assets/{liquid-jZT5xQG-.js → liquid-2UNKoWGQ.js} +1 -1
- package/dist/shell/assets/{lspLanguageFeatures-BuiqKs90.js → lspLanguageFeatures-G4xsCwWV.js} +1 -1
- package/dist/shell/assets/{mdx-DwnR-ia2.js → mdx-CoF6St9y.js} +1 -1
- package/dist/shell/assets/{python-DU3pl9Zu.js → python-rULGuAEe.js} +1 -1
- package/dist/shell/assets/{razor-BzVUPqHs.js → razor-0I41g6kD.js} +1 -1
- package/dist/shell/assets/{tsMode-ONmZhHHZ.js → tsMode-CyMsmAXC.js} +1 -1
- package/dist/shell/assets/{xml-BXW7X3BT.js → xml-BNhTd1tm.js} +1 -1
- package/dist/shell/assets/{yaml-DFE79ex1.js → yaml-Cp69rkq5.js} +1 -1
- package/dist/shell/index.html +2 -2
- package/package.json +1 -1
- package/dist/shell/assets/index-Bkn7zNFw.js +0 -267
- package/dist/shell/assets/index-iVaPr_If.css +0 -1
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/Editor-jjf6IGvI.js","assets/grammar-E8nWrhy3.js","assets/Editor-CB2SckMT.css","assets/XTerm-ClBPMY5e.js","assets/XTerm-6GBZ9nXN.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
var Uj=Object.defineProperty;var Hj=(e,t,n)=>t in e?Uj(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var zt=(e,t,n)=>Hj(e,typeof t!="symbol"?t+"":t,n);(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))r(o);new MutationObserver(o=>{for(const i of o)if(i.type==="childList")for(const l of i.addedNodes)l.tagName==="LINK"&&l.rel==="modulepreload"&&r(l)}).observe(document,{childList:!0,subtree:!0});function n(o){const i={};return o.integrity&&(i.integrity=o.integrity),o.referrerPolicy&&(i.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?i.credentials="include":o.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function r(o){if(o.ep)return;o.ep=!0;const i=n(o);fetch(o.href,i)}})();function Qx(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var xp={exports:{}},oc={},Ep={exports:{}},Vt={};/**
|
|
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 yv;function Wj(){if(yv)return Vt;yv=1;var e=Symbol.for("react.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),o=Symbol.for("react.profiler"),i=Symbol.for("react.provider"),l=Symbol.for("react.context"),c=Symbol.for("react.forward_ref"),u=Symbol.for("react.suspense"),h=Symbol.for("react.memo"),p=Symbol.for("react.lazy"),m=Symbol.iterator;function k(W){return W===null||typeof W!="object"?null:(W=m&&W[m]||W["@@iterator"],typeof W=="function"?W:null)}var g={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},y=Object.assign,b={};function S(W,ie,Te){this.props=W,this.context=ie,this.refs=b,this.updater=Te||g}S.prototype.isReactComponent={},S.prototype.setState=function(W,ie){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,ie,"setState")},S.prototype.forceUpdate=function(W){this.updater.enqueueForceUpdate(this,W,"forceUpdate")};function j(){}j.prototype=S.prototype;function E(W,ie,Te){this.props=W,this.context=ie,this.refs=b,this.updater=Te||g}var N=E.prototype=new j;N.constructor=E,y(N,S.prototype),N.isPureReactComponent=!0;var A=Array.isArray,O=Object.prototype.hasOwnProperty,P={current:null},R={key:!0,ref:!0,__self:!0,__source:!0};function T(W,ie,Te){var Ce,de={},be=null,le=null;if(ie!=null)for(Ce in ie.ref!==void 0&&(le=ie.ref),ie.key!==void 0&&(be=""+ie.key),ie)O.call(ie,Ce)&&!R.hasOwnProperty(Ce)&&(de[Ce]=ie[Ce]);var G=arguments.length-2;if(G===1)de.children=Te;else if(1<G){for(var ce=Array(G),oe=0;oe<G;oe++)ce[oe]=arguments[oe+2];de.children=ce}if(W&&W.defaultProps)for(Ce in G=W.defaultProps,G)de[Ce]===void 0&&(de[Ce]=G[Ce]);return{$$typeof:e,type:W,key:be,ref:le,props:de,_owner:P.current}}function $(W,ie){return{$$typeof:e,type:W.type,key:ie,ref:W.ref,props:W.props,_owner:W._owner}}function D(W){return typeof W=="object"&&W!==null&&W.$$typeof===e}function z(W){var ie={"=":"=0",":":"=2"};return"$"+W.replace(/[=:]/g,function(Te){return ie[Te]})}var V=/\/+/g;function se(W,ie){return typeof W=="object"&&W!==null&&W.key!=null?z(""+W.key):ie.toString(36)}function I(W,ie,Te,Ce,de){var be=typeof W;(be==="undefined"||be==="boolean")&&(W=null);var le=!1;if(W===null)le=!0;else switch(be){case"string":case"number":le=!0;break;case"object":switch(W.$$typeof){case e:case t:le=!0}}if(le)return le=W,de=de(le),W=Ce===""?"."+se(le,0):Ce,A(de)?(Te="",W!=null&&(Te=W.replace(V,"$&/")+"/"),I(de,ie,Te,"",function(oe){return oe})):de!=null&&(D(de)&&(de=$(de,Te+(!de.key||le&&le.key===de.key?"":(""+de.key).replace(V,"$&/")+"/")+W)),ie.push(de)),1;if(le=0,Ce=Ce===""?".":Ce+":",A(W))for(var G=0;G<W.length;G++){be=W[G];var ce=Ce+se(be,G);le+=I(be,ie,Te,ce,de)}else if(ce=k(W),typeof ce=="function")for(W=ce.call(W),G=0;!(be=W.next()).done;)be=be.value,ce=Ce+se(be,G++),le+=I(be,ie,Te,ce,de);else if(be==="object")throw ie=String(W),Error("Objects are not valid as a React child (found: "+(ie==="[object Object]"?"object with keys {"+Object.keys(W).join(", ")+"}":ie)+"). If you meant to render a collection of children, use an array instead.");return le}function ne(W,ie,Te){if(W==null)return W;var Ce=[],de=0;return I(W,Ce,"","",function(be){return ie.call(Te,be,de++)}),Ce}function we(W){if(W._status===-1){var ie=W._result;ie=ie(),ie.then(function(Te){(W._status===0||W._status===-1)&&(W._status=1,W._result=Te)},function(Te){(W._status===0||W._status===-1)&&(W._status=2,W._result=Te)}),W._status===-1&&(W._status=0,W._result=ie)}if(W._status===1)return W._result.default;throw W._result}var K={current:null},B={transition:null},ee={ReactCurrentDispatcher:K,ReactCurrentBatchConfig:B,ReactCurrentOwner:P};function J(){throw Error("act(...) is not supported in production builds of React.")}return Vt.Children={map:ne,forEach:function(W,ie,Te){ne(W,function(){ie.apply(this,arguments)},Te)},count:function(W){var ie=0;return ne(W,function(){ie++}),ie},toArray:function(W){return ne(W,function(ie){return ie})||[]},only:function(W){if(!D(W))throw Error("React.Children.only expected to receive a single React element child.");return W}},Vt.Component=S,Vt.Fragment=n,Vt.Profiler=o,Vt.PureComponent=E,Vt.StrictMode=r,Vt.Suspense=u,Vt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=ee,Vt.act=J,Vt.cloneElement=function(W,ie,Te){if(W==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+W+".");var Ce=y({},W.props),de=W.key,be=W.ref,le=W._owner;if(ie!=null){if(ie.ref!==void 0&&(be=ie.ref,le=P.current),ie.key!==void 0&&(de=""+ie.key),W.type&&W.type.defaultProps)var G=W.type.defaultProps;for(ce in ie)O.call(ie,ce)&&!R.hasOwnProperty(ce)&&(Ce[ce]=ie[ce]===void 0&&G!==void 0?G[ce]:ie[ce])}var ce=arguments.length-2;if(ce===1)Ce.children=Te;else if(1<ce){G=Array(ce);for(var oe=0;oe<ce;oe++)G[oe]=arguments[oe+2];Ce.children=G}return{$$typeof:e,type:W.type,key:de,ref:be,props:Ce,_owner:le}},Vt.createContext=function(W){return W={$$typeof:l,_currentValue:W,_currentValue2:W,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},W.Provider={$$typeof:i,_context:W},W.Consumer=W},Vt.createElement=T,Vt.createFactory=function(W){var ie=T.bind(null,W);return ie.type=W,ie},Vt.createRef=function(){return{current:null}},Vt.forwardRef=function(W){return{$$typeof:c,render:W}},Vt.isValidElement=D,Vt.lazy=function(W){return{$$typeof:p,_payload:{_status:-1,_result:W},_init:we}},Vt.memo=function(W,ie){return{$$typeof:h,type:W,compare:ie===void 0?null:ie}},Vt.startTransition=function(W){var ie=B.transition;B.transition={};try{W()}finally{B.transition=ie}},Vt.unstable_act=J,Vt.useCallback=function(W,ie){return K.current.useCallback(W,ie)},Vt.useContext=function(W){return K.current.useContext(W)},Vt.useDebugValue=function(){},Vt.useDeferredValue=function(W){return K.current.useDeferredValue(W)},Vt.useEffect=function(W,ie){return K.current.useEffect(W,ie)},Vt.useId=function(){return K.current.useId()},Vt.useImperativeHandle=function(W,ie,Te){return K.current.useImperativeHandle(W,ie,Te)},Vt.useInsertionEffect=function(W,ie){return K.current.useInsertionEffect(W,ie)},Vt.useLayoutEffect=function(W,ie){return K.current.useLayoutEffect(W,ie)},Vt.useMemo=function(W,ie){return K.current.useMemo(W,ie)},Vt.useReducer=function(W,ie,Te){return K.current.useReducer(W,ie,Te)},Vt.useRef=function(W){return K.current.useRef(W)},Vt.useState=function(W){return K.current.useState(W)},Vt.useSyncExternalStore=function(W,ie,Te){return K.current.useSyncExternalStore(W,ie,Te)},Vt.useTransition=function(){return K.current.useTransition()},Vt.version="18.3.1",Vt}var vv;function xg(){return vv||(vv=1,Ep.exports=Wj()),Ep.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 bv;function Kj(){if(bv)return oc;bv=1;var e=xg(),t=Symbol.for("react.element"),n=Symbol.for("react.fragment"),r=Object.prototype.hasOwnProperty,o=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,i={key:!0,ref:!0,__self:!0,__source:!0};function l(c,u,h){var p,m={},k=null,g=null;h!==void 0&&(k=""+h),u.key!==void 0&&(k=""+u.key),u.ref!==void 0&&(g=u.ref);for(p in u)r.call(u,p)&&!i.hasOwnProperty(p)&&(m[p]=u[p]);if(c&&c.defaultProps)for(p in u=c.defaultProps,u)m[p]===void 0&&(m[p]=u[p]);return{$$typeof:t,type:c,key:k,ref:g,props:m,_owner:o.current}}return oc.Fragment=n,oc.jsx=l,oc.jsxs=l,oc}var xv;function Zj(){return xv||(xv=1,xp.exports=Kj()),xp.exports}var d=Zj(),_=xg();const qj=Qx(_);var Sp={exports:{}},Jr={},_p={exports:{}},Np={};/**
|
|
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 Ev;function Gj(){return Ev||(Ev=1,(function(e){function t(B,ee){var J=B.length;B.push(ee);e:for(;0<J;){var W=J-1>>>1,ie=B[W];if(0<o(ie,ee))B[W]=ee,B[J]=ie,J=W;else break e}}function n(B){return B.length===0?null:B[0]}function r(B){if(B.length===0)return null;var ee=B[0],J=B.pop();if(J!==ee){B[0]=J;e:for(var W=0,ie=B.length,Te=ie>>>1;W<Te;){var Ce=2*(W+1)-1,de=B[Ce],be=Ce+1,le=B[be];if(0>o(de,J))be<ie&&0>o(le,de)?(B[W]=le,B[be]=J,W=be):(B[W]=de,B[Ce]=J,W=Ce);else if(be<ie&&0>o(le,J))B[W]=le,B[be]=J,W=be;else break e}}return ee}function o(B,ee){var J=B.sortIndex-ee.sortIndex;return J!==0?J:B.id-ee.id}if(typeof performance=="object"&&typeof performance.now=="function"){var i=performance;e.unstable_now=function(){return i.now()}}else{var l=Date,c=l.now();e.unstable_now=function(){return l.now()-c}}var u=[],h=[],p=1,m=null,k=3,g=!1,y=!1,b=!1,S=typeof setTimeout=="function"?setTimeout:null,j=typeof clearTimeout=="function"?clearTimeout:null,E=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function N(B){for(var ee=n(h);ee!==null;){if(ee.callback===null)r(h);else if(ee.startTime<=B)r(h),ee.sortIndex=ee.expirationTime,t(u,ee);else break;ee=n(h)}}function A(B){if(b=!1,N(B),!y)if(n(u)!==null)y=!0,we(O);else{var ee=n(h);ee!==null&&K(A,ee.startTime-B)}}function O(B,ee){y=!1,b&&(b=!1,j(T),T=-1),g=!0;var J=k;try{for(N(ee),m=n(u);m!==null&&(!(m.expirationTime>ee)||B&&!z());){var W=m.callback;if(typeof W=="function"){m.callback=null,k=m.priorityLevel;var ie=W(m.expirationTime<=ee);ee=e.unstable_now(),typeof ie=="function"?m.callback=ie:m===n(u)&&r(u),N(ee)}else r(u);m=n(u)}if(m!==null)var Te=!0;else{var Ce=n(h);Ce!==null&&K(A,Ce.startTime-ee),Te=!1}return Te}finally{m=null,k=J,g=!1}}var P=!1,R=null,T=-1,$=5,D=-1;function z(){return!(e.unstable_now()-D<$)}function V(){if(R!==null){var B=e.unstable_now();D=B;var ee=!0;try{ee=R(!0,B)}finally{ee?se():(P=!1,R=null)}}else P=!1}var se;if(typeof E=="function")se=function(){E(V)};else if(typeof MessageChannel<"u"){var I=new MessageChannel,ne=I.port2;I.port1.onmessage=V,se=function(){ne.postMessage(null)}}else se=function(){S(V,0)};function we(B){R=B,P||(P=!0,se())}function K(B,ee){T=S(function(){B(e.unstable_now())},ee)}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(B){B.callback=null},e.unstable_continueExecution=function(){y||g||(y=!0,we(O))},e.unstable_forceFrameRate=function(B){0>B||125<B?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):$=0<B?Math.floor(1e3/B):5},e.unstable_getCurrentPriorityLevel=function(){return k},e.unstable_getFirstCallbackNode=function(){return n(u)},e.unstable_next=function(B){switch(k){case 1:case 2:case 3:var ee=3;break;default:ee=k}var J=k;k=ee;try{return B()}finally{k=J}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(B,ee){switch(B){case 1:case 2:case 3:case 4:case 5:break;default:B=3}var J=k;k=B;try{return ee()}finally{k=J}},e.unstable_scheduleCallback=function(B,ee,J){var W=e.unstable_now();switch(typeof J=="object"&&J!==null?(J=J.delay,J=typeof J=="number"&&0<J?W+J:W):J=W,B){case 1:var ie=-1;break;case 2:ie=250;break;case 5:ie=1073741823;break;case 4:ie=1e4;break;default:ie=5e3}return ie=J+ie,B={id:p++,callback:ee,priorityLevel:B,startTime:J,expirationTime:ie,sortIndex:-1},J>W?(B.sortIndex=J,t(h,B),n(u)===null&&B===n(h)&&(b?(j(T),T=-1):b=!0,K(A,J-W))):(B.sortIndex=ie,t(u,B),y||g||(y=!0,we(O))),B},e.unstable_shouldYield=z,e.unstable_wrapCallback=function(B){var ee=k;return function(){var J=k;k=ee;try{return B.apply(this,arguments)}finally{k=J}}}})(Np)),Np}var Sv;function Vj(){return Sv||(Sv=1,_p.exports=Gj()),_p.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 _v;function Yj(){if(_v)return Jr;_v=1;var e=xg(),t=Vj();function n(s){for(var a="https://reactjs.org/docs/error-decoder.html?invariant="+s,f=1;f<arguments.length;f++)a+="&args[]="+encodeURIComponent(arguments[f]);return"Minified React error #"+s+"; visit "+a+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var r=new Set,o={};function i(s,a){l(s,a),l(s+"Capture",a)}function l(s,a){for(o[s]=a,s=0;s<a.length;s++)r.add(a[s])}var c=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),u=Object.prototype.hasOwnProperty,h=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,p={},m={};function k(s){return u.call(m,s)?!0:u.call(p,s)?!1:h.test(s)?m[s]=!0:(p[s]=!0,!1)}function g(s,a,f,w){if(f!==null&&f.type===0)return!1;switch(typeof a){case"function":case"symbol":return!0;case"boolean":return w?!1:f!==null?!f.acceptsBooleans:(s=s.toLowerCase().slice(0,5),s!=="data-"&&s!=="aria-");default:return!1}}function y(s,a,f,w){if(a===null||typeof a>"u"||g(s,a,f,w))return!0;if(w)return!1;if(f!==null)switch(f.type){case 3:return!a;case 4:return a===!1;case 5:return isNaN(a);case 6:return isNaN(a)||1>a}return!1}function b(s,a,f,w,v,x,C){this.acceptsBooleans=a===2||a===3||a===4,this.attributeName=w,this.attributeNamespace=v,this.mustUseProperty=f,this.propertyName=s,this.type=a,this.sanitizeURL=x,this.removeEmptyString=C}var S={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(s){S[s]=new b(s,0,!1,s,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(s){var a=s[0];S[a]=new b(a,1,!1,s[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(s){S[s]=new b(s,2,!1,s.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(s){S[s]=new b(s,2,!1,s,null,!1,!1)}),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(s){S[s]=new b(s,3,!1,s.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(s){S[s]=new b(s,3,!0,s,null,!1,!1)}),["capture","download"].forEach(function(s){S[s]=new b(s,4,!1,s,null,!1,!1)}),["cols","rows","size","span"].forEach(function(s){S[s]=new b(s,6,!1,s,null,!1,!1)}),["rowSpan","start"].forEach(function(s){S[s]=new b(s,5,!1,s.toLowerCase(),null,!1,!1)});var j=/[\-:]([a-z])/g;function E(s){return s[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(s){var a=s.replace(j,E);S[a]=new b(a,1,!1,s,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(s){var a=s.replace(j,E);S[a]=new b(a,1,!1,s,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(s){var a=s.replace(j,E);S[a]=new b(a,1,!1,s,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(s){S[s]=new b(s,1,!1,s.toLowerCase(),null,!1,!1)}),S.xlinkHref=new b("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(s){S[s]=new b(s,1,!1,s.toLowerCase(),null,!0,!0)});function N(s,a,f,w){var v=S.hasOwnProperty(a)?S[a]:null;(v!==null?v.type!==0:w||!(2<a.length)||a[0]!=="o"&&a[0]!=="O"||a[1]!=="n"&&a[1]!=="N")&&(y(a,f,v,w)&&(f=null),w||v===null?k(a)&&(f===null?s.removeAttribute(a):s.setAttribute(a,""+f)):v.mustUseProperty?s[v.propertyName]=f===null?v.type===3?!1:"":f:(a=v.attributeName,w=v.attributeNamespace,f===null?s.removeAttribute(a):(v=v.type,f=v===3||v===4&&f===!0?"":""+f,w?s.setAttributeNS(w,a,f):s.setAttribute(a,f))))}var A=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,O=Symbol.for("react.element"),P=Symbol.for("react.portal"),R=Symbol.for("react.fragment"),T=Symbol.for("react.strict_mode"),$=Symbol.for("react.profiler"),D=Symbol.for("react.provider"),z=Symbol.for("react.context"),V=Symbol.for("react.forward_ref"),se=Symbol.for("react.suspense"),I=Symbol.for("react.suspense_list"),ne=Symbol.for("react.memo"),we=Symbol.for("react.lazy"),K=Symbol.for("react.offscreen"),B=Symbol.iterator;function ee(s){return s===null||typeof s!="object"?null:(s=B&&s[B]||s["@@iterator"],typeof s=="function"?s:null)}var J=Object.assign,W;function ie(s){if(W===void 0)try{throw Error()}catch(f){var a=f.stack.trim().match(/\n( *(at )?)/);W=a&&a[1]||""}return`
|
|
35
|
+
`+W+s}var Te=!1;function Ce(s,a){if(!s||Te)return"";Te=!0;var f=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(a)if(a=function(){throw Error()},Object.defineProperty(a.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(a,[])}catch(he){var w=he}Reflect.construct(s,[],a)}else{try{a.call()}catch(he){w=he}s.call(a.prototype)}else{try{throw Error()}catch(he){w=he}s()}}catch(he){if(he&&w&&typeof he.stack=="string"){for(var v=he.stack.split(`
|
|
36
|
+
`),x=w.stack.split(`
|
|
37
|
+
`),C=v.length-1,U=x.length-1;1<=C&&0<=U&&v[C]!==x[U];)U--;for(;1<=C&&0<=U;C--,U--)if(v[C]!==x[U]){if(C!==1||U!==1)do if(C--,U--,0>U||v[C]!==x[U]){var X=`
|
|
38
|
+
`+v[C].replace(" at new "," at ");return s.displayName&&X.includes("<anonymous>")&&(X=X.replace("<anonymous>",s.displayName)),X}while(1<=C&&0<=U);break}}}finally{Te=!1,Error.prepareStackTrace=f}return(s=s?s.displayName||s.name:"")?ie(s):""}function de(s){switch(s.tag){case 5:return ie(s.type);case 16:return ie("Lazy");case 13:return ie("Suspense");case 19:return ie("SuspenseList");case 0:case 2:case 15:return s=Ce(s.type,!1),s;case 11:return s=Ce(s.type.render,!1),s;case 1:return s=Ce(s.type,!0),s;default:return""}}function be(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 R:return"Fragment";case P:return"Portal";case $:return"Profiler";case T:return"StrictMode";case se:return"Suspense";case I:return"SuspenseList"}if(typeof s=="object")switch(s.$$typeof){case z:return(s.displayName||"Context")+".Consumer";case D:return(s._context.displayName||"Context")+".Provider";case V:var a=s.render;return s=s.displayName,s||(s=a.displayName||a.name||"",s=s!==""?"ForwardRef("+s+")":"ForwardRef"),s;case ne:return a=s.displayName||null,a!==null?a:be(s.type)||"Memo";case we:a=s._payload,s=s._init;try{return be(s(a))}catch{}}return null}function le(s){var a=s.type;switch(s.tag){case 24:return"Cache";case 9:return(a.displayName||"Context")+".Consumer";case 10:return(a._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return s=a.render,s=s.displayName||s.name||"",a.displayName||(s!==""?"ForwardRef("+s+")":"ForwardRef");case 7:return"Fragment";case 5:return a;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return be(a);case 8:return a===T?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof a=="function")return a.displayName||a.name||null;if(typeof a=="string")return a}return null}function G(s){switch(typeof s){case"boolean":case"number":case"string":case"undefined":return s;case"object":return s;default:return""}}function ce(s){var a=s.type;return(s=s.nodeName)&&s.toLowerCase()==="input"&&(a==="checkbox"||a==="radio")}function oe(s){var a=ce(s)?"checked":"value",f=Object.getOwnPropertyDescriptor(s.constructor.prototype,a),w=""+s[a];if(!s.hasOwnProperty(a)&&typeof f<"u"&&typeof f.get=="function"&&typeof f.set=="function"){var v=f.get,x=f.set;return Object.defineProperty(s,a,{configurable:!0,get:function(){return v.call(this)},set:function(C){w=""+C,x.call(this,C)}}),Object.defineProperty(s,a,{enumerable:f.enumerable}),{getValue:function(){return w},setValue:function(C){w=""+C},stopTracking:function(){s._valueTracker=null,delete s[a]}}}}function re(s){s._valueTracker||(s._valueTracker=oe(s))}function Le(s){if(!s)return!1;var a=s._valueTracker;if(!a)return!0;var f=a.getValue(),w="";return s&&(w=ce(s)?s.checked?"true":"false":s.value),s=w,s!==f?(a.setValue(s),!0):!1}function Ue(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 _e(s,a){var f=a.checked;return J({},a,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:f??s._wrapperState.initialChecked})}function je(s,a){var f=a.defaultValue==null?"":a.defaultValue,w=a.checked!=null?a.checked:a.defaultChecked;f=G(a.value!=null?a.value:f),s._wrapperState={initialChecked:w,initialValue:f,controlled:a.type==="checkbox"||a.type==="radio"?a.checked!=null:a.value!=null}}function Ne(s,a){a=a.checked,a!=null&&N(s,"checked",a,!1)}function qe(s,a){Ne(s,a);var f=G(a.value),w=a.type;if(f!=null)w==="number"?(f===0&&s.value===""||s.value!=f)&&(s.value=""+f):s.value!==""+f&&(s.value=""+f);else if(w==="submit"||w==="reset"){s.removeAttribute("value");return}a.hasOwnProperty("value")?qt(s,a.type,f):a.hasOwnProperty("defaultValue")&&qt(s,a.type,G(a.defaultValue)),a.checked==null&&a.defaultChecked!=null&&(s.defaultChecked=!!a.defaultChecked)}function Ft(s,a,f){if(a.hasOwnProperty("value")||a.hasOwnProperty("defaultValue")){var w=a.type;if(!(w!=="submit"&&w!=="reset"||a.value!==void 0&&a.value!==null))return;a=""+s._wrapperState.initialValue,f||a===s.value||(s.value=a),s.defaultValue=a}f=s.name,f!==""&&(s.name=""),s.defaultChecked=!!s._wrapperState.initialChecked,f!==""&&(s.name=f)}function qt(s,a,f){(a!=="number"||Ue(s.ownerDocument)!==s)&&(f==null?s.defaultValue=""+s._wrapperState.initialValue:s.defaultValue!==""+f&&(s.defaultValue=""+f))}var jt=Array.isArray;function Ht(s,a,f,w){if(s=s.options,a){a={};for(var v=0;v<f.length;v++)a["$"+f[v]]=!0;for(f=0;f<s.length;f++)v=a.hasOwnProperty("$"+s[f].value),s[f].selected!==v&&(s[f].selected=v),v&&w&&(s[f].defaultSelected=!0)}else{for(f=""+G(f),a=null,v=0;v<s.length;v++){if(s[v].value===f){s[v].selected=!0,w&&(s[v].defaultSelected=!0);return}a!==null||s[v].disabled||(a=s[v])}a!==null&&(a.selected=!0)}}function sn(s,a){if(a.dangerouslySetInnerHTML!=null)throw Error(n(91));return J({},a,{value:void 0,defaultValue:void 0,children:""+s._wrapperState.initialValue})}function Ct(s,a){var f=a.value;if(f==null){if(f=a.children,a=a.defaultValue,f!=null){if(a!=null)throw Error(n(92));if(jt(f)){if(1<f.length)throw Error(n(93));f=f[0]}a=f}a==null&&(a=""),f=a}s._wrapperState={initialValue:G(f)}}function He(s,a){var f=G(a.value),w=G(a.defaultValue);f!=null&&(f=""+f,f!==s.value&&(s.value=f),a.defaultValue==null&&s.defaultValue!==f&&(s.defaultValue=f)),w!=null&&(s.defaultValue=""+w)}function Ze(s){var a=s.textContent;a===s._wrapperState.initialValue&&a!==""&&a!==null&&(s.value=a)}function At(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 _t(s,a){return s==null||s==="http://www.w3.org/1999/xhtml"?At(a):s==="http://www.w3.org/2000/svg"&&a==="foreignObject"?"http://www.w3.org/1999/xhtml":s}var kt,Fn=(function(s){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(a,f,w,v){MSApp.execUnsafeLocalFunction(function(){return s(a,f,w,v)})}:s})(function(s,a){if(s.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in s)s.innerHTML=a;else{for(kt=kt||document.createElement("div"),kt.innerHTML="<svg>"+a.valueOf().toString()+"</svg>",a=kt.firstChild;s.firstChild;)s.removeChild(s.firstChild);for(;a.firstChild;)s.appendChild(a.firstChild)}});function un(s,a){if(a){var f=s.firstChild;if(f&&f===s.lastChild&&f.nodeType===3){f.nodeValue=a;return}}s.textContent=a}var xn={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},$t=["Webkit","ms","Moz","O"];Object.keys(xn).forEach(function(s){$t.forEach(function(a){a=a+s.charAt(0).toUpperCase()+s.substring(1),xn[a]=xn[s]})});function Tn(s,a,f){return a==null||typeof a=="boolean"||a===""?"":f||typeof a!="number"||a===0||xn.hasOwnProperty(s)&&xn[s]?(""+a).trim():a+"px"}function Y(s,a){s=s.style;for(var f in a)if(a.hasOwnProperty(f)){var w=f.indexOf("--")===0,v=Tn(f,a[f],w);f==="float"&&(f="cssFloat"),w?s.setProperty(f,v):s[f]=v}}var pe=J({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function nt(s,a){if(a){if(pe[s]&&(a.children!=null||a.dangerouslySetInnerHTML!=null))throw Error(n(137,s));if(a.dangerouslySetInnerHTML!=null){if(a.children!=null)throw Error(n(60));if(typeof a.dangerouslySetInnerHTML!="object"||!("__html"in a.dangerouslySetInnerHTML))throw Error(n(61))}if(a.style!=null&&typeof a.style!="object")throw Error(n(62))}}function dt(s,a){if(s.indexOf("-")===-1)return typeof a.is=="string";switch(s){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var Bt=null;function Ot(s){return s=s.target||s.srcElement||window,s.correspondingUseElement&&(s=s.correspondingUseElement),s.nodeType===3?s.parentNode:s}var Ee=null,$e=null,Wt=null;function ft(s){if(s=Hl(s)){if(typeof Ee!="function")throw Error(n(280));var a=s.stateNode;a&&(a=Su(a),Ee(s.stateNode,s.type,a))}}function Z(s){$e?Wt?Wt.push(s):Wt=[s]:$e=s}function ge(){if($e){var s=$e,a=Wt;if(Wt=$e=null,ft(s),a)for(s=0;s<a.length;s++)ft(a[s])}}function Oe(s,a){return s(a)}function st(){}var Et=!1;function Mt(s,a,f){if(Et)return s(a,f);Et=!0;try{return Oe(s,a,f)}finally{Et=!1,($e!==null||Wt!==null)&&(st(),ge())}}function ze(s,a){var f=s.stateNode;if(f===null)return null;var w=Su(f);if(w===null)return null;f=w[a];e:switch(a){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(w=!w.disabled)||(s=s.type,w=!(s==="button"||s==="input"||s==="select"||s==="textarea")),s=!w;break e;default:s=!1}if(s)return null;if(f&&typeof f!="function")throw Error(n(231,a,typeof f));return f}var Se=!1;if(c)try{var Ge={};Object.defineProperty(Ge,"passive",{get:function(){Se=!0}}),window.addEventListener("test",Ge,Ge),window.removeEventListener("test",Ge,Ge)}catch{Se=!1}function Kt(s,a,f,w,v,x,C,U,X){var he=Array.prototype.slice.call(arguments,3);try{a.apply(f,he)}catch(Re){this.onError(Re)}}var Qe=!1,mn=null,Yt=!1,En=null,qn={onError:function(s){Qe=!0,mn=s}};function an(s,a,f,w,v,x,C,U,X){Qe=!1,mn=null,Kt.apply(qn,arguments)}function wn(s,a,f,w,v,x,C,U,X){if(an.apply(this,arguments),Qe){if(Qe){var he=mn;Qe=!1,mn=null}else throw Error(n(198));Yt||(Yt=!0,En=he)}}function mr(s){var a=s,f=s;if(s.alternate)for(;a.return;)a=a.return;else{s=a;do a=s,(a.flags&4098)!==0&&(f=a.return),s=a.return;while(s)}return a.tag===3?f:null}function Mn(s){if(s.tag===13){var a=s.memoizedState;if(a===null&&(s=s.alternate,s!==null&&(a=s.memoizedState)),a!==null)return a.dehydrated}return null}function tn(s){if(mr(s)!==s)throw Error(n(188))}function Gn(s){var a=s.alternate;if(!a){if(a=mr(s),a===null)throw Error(n(188));return a!==s?null:s}for(var f=s,w=a;;){var v=f.return;if(v===null)break;var x=v.alternate;if(x===null){if(w=v.return,w!==null){f=w;continue}break}if(v.child===x.child){for(x=v.child;x;){if(x===f)return tn(v),s;if(x===w)return tn(v),a;x=x.sibling}throw Error(n(188))}if(f.return!==w.return)f=v,w=x;else{for(var C=!1,U=v.child;U;){if(U===f){C=!0,f=v,w=x;break}if(U===w){C=!0,w=v,f=x;break}U=U.sibling}if(!C){for(U=x.child;U;){if(U===f){C=!0,f=x,w=v;break}if(U===w){C=!0,w=x,f=v;break}U=U.sibling}if(!C)throw Error(n(189))}}if(f.alternate!==w)throw Error(n(190))}if(f.tag!==3)throw Error(n(188));return f.stateNode.current===f?s:a}function nn(s){return s=Gn(s),s!==null?Q(s):null}function Q(s){if(s.tag===5||s.tag===6)return s;for(s=s.child;s!==null;){var a=Q(s);if(a!==null)return a;s=s.sibling}return null}var ke=t.unstable_scheduleCallback,tt=t.unstable_cancelCallback,at=t.unstable_shouldYield,dn=t.unstable_requestPaint,Gt=t.unstable_now,Tr=t.unstable_getCurrentPriorityLevel,Vn=t.unstable_ImmediatePriority,Cn=t.unstable_UserBlockingPriority,rn=t.unstable_NormalPriority,ve=t.unstable_LowPriority,Ve=t.unstable_IdlePriority,We=null,mt=null;function ln(s){if(mt&&typeof mt.onCommitFiberRoot=="function")try{mt.onCommitFiberRoot(We,s,void 0,(s.current.flags&128)===128)}catch{}}var yn=Math.clz32?Math.clz32:Be,H=Math.log,me=Math.LN2;function Be(s){return s>>>=0,s===0?32:31-(H(s)/me|0)|0}var lt=64,Nt=4194304;function Xt(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 Bn(s,a){var f=s.pendingLanes;if(f===0)return 0;var w=0,v=s.suspendedLanes,x=s.pingedLanes,C=f&268435455;if(C!==0){var U=C&~v;U!==0?w=Xt(U):(x&=C,x!==0&&(w=Xt(x)))}else C=f&~v,C!==0?w=Xt(C):x!==0&&(w=Xt(x));if(w===0)return 0;if(a!==0&&a!==w&&(a&v)===0&&(v=w&-w,x=a&-a,v>=x||v===16&&(x&4194240)!==0))return a;if((w&4)!==0&&(w|=f&16),a=s.entangledLanes,a!==0)for(s=s.entanglements,a&=w;0<a;)f=31-yn(a),v=1<<f,w|=s[f],a&=~v;return w}function Yn(s,a){switch(s){case 1:case 2:case 4:return a+250;case 8:case 16:case 32:case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return a+5e3;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return-1;case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function Dr(s,a){for(var f=s.suspendedLanes,w=s.pingedLanes,v=s.expirationTimes,x=s.pendingLanes;0<x;){var C=31-yn(x),U=1<<C,X=v[C];X===-1?((U&f)===0||(U&w)!==0)&&(v[C]=Yn(U,a)):X<=a&&(s.expiredLanes|=U),x&=~U}}function zr(s){return s=s.pendingLanes&-1073741825,s!==0?s:s&1073741824?1073741824:0}function Ro(){var s=lt;return lt<<=1,(lt&4194240)===0&&(lt=64),s}function xr(s){for(var a=[],f=0;31>f;f++)a.push(s);return a}function Zr(s,a,f){s.pendingLanes|=a,a!==536870912&&(s.suspendedLanes=0,s.pingedLanes=0),s=s.eventTimes,a=31-yn(a),s[a]=f}function Er(s,a){var f=s.pendingLanes&~a;s.pendingLanes=a,s.suspendedLanes=0,s.pingedLanes=0,s.expiredLanes&=a,s.mutableReadLanes&=a,s.entangledLanes&=a,a=s.entanglements;var w=s.eventTimes;for(s=s.expirationTimes;0<f;){var v=31-yn(f),x=1<<v;a[v]=0,w[v]=-1,s[v]=-1,f&=~x}}function qr(s,a){var f=s.entangledLanes|=a;for(s=s.entanglements;f;){var w=31-yn(f),v=1<<w;v&a|s[w]&a&&(s[w]|=a),f&=~v}}var Qt=0;function wt(s){return s&=-s,1<s?4<s?(s&268435455)!==0?16:536870912:4:1}var $o,An,on,Dt,nr,Ae=!1,M=[],F=null,ae=null,ye=null,Me=new Map,Ye=new Map,yt=[],gn="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 Xn(s,a){switch(s){case"focusin":case"focusout":F=null;break;case"dragenter":case"dragleave":ae=null;break;case"mouseover":case"mouseout":ye=null;break;case"pointerover":case"pointerout":Me.delete(a.pointerId);break;case"gotpointercapture":case"lostpointercapture":Ye.delete(a.pointerId)}}function In(s,a,f,w,v,x){return s===null||s.nativeEvent!==x?(s={blockedOn:a,domEventName:f,eventSystemFlags:w,nativeEvent:x,targetContainers:[v]},a!==null&&(a=Hl(a),a!==null&&An(a)),s):(s.eventSystemFlags|=w,a=s.targetContainers,v!==null&&a.indexOf(v)===-1&&a.push(v),s)}function Yo(s,a,f,w,v){switch(a){case"focusin":return F=In(F,s,a,f,w,v),!0;case"dragenter":return ae=In(ae,s,a,f,w,v),!0;case"mouseover":return ye=In(ye,s,a,f,w,v),!0;case"pointerover":var x=v.pointerId;return Me.set(x,In(Me.get(x)||null,s,a,f,w,v)),!0;case"gotpointercapture":return x=v.pointerId,Ye.set(x,In(Ye.get(x)||null,s,a,f,w,v)),!0}return!1}function Jn(s){var a=ji(s.target);if(a!==null){var f=mr(a);if(f!==null){if(a=f.tag,a===13){if(a=Mn(f),a!==null){s.blockedOn=a,nr(s.priority,function(){on(f)});return}}else if(a===3&&f.stateNode.current.memoizedState.isDehydrated){s.blockedOn=f.tag===3?f.stateNode.containerInfo:null;return}}}s.blockedOn=null}function hs(s){if(s.blockedOn!==null)return!1;for(var a=s.targetContainers;0<a.length;){var f=vl(s.domEventName,s.eventSystemFlags,a[0],s.nativeEvent);if(f===null){f=s.nativeEvent;var w=new f.constructor(f.type,f);Bt=w,f.target.dispatchEvent(w),Bt=null}else return a=Hl(f),a!==null&&An(a),s.blockedOn=f,!1;a.shift()}return!0}function kl(s,a,f){hs(s)&&f.delete(a)}function wl(){Ae=!1,F!==null&&hs(F)&&(F=null),ae!==null&&hs(ae)&&(ae=null),ye!==null&&hs(ye)&&(ye=null),Me.forEach(kl),Ye.forEach(kl)}function rr(s,a){s.blockedOn===a&&(s.blockedOn=null,Ae||(Ae=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,wl)))}function bi(s){function a(v){return rr(v,s)}if(0<M.length){rr(M[0],s);for(var f=1;f<M.length;f++){var w=M[f];w.blockedOn===s&&(w.blockedOn=null)}}for(F!==null&&rr(F,s),ae!==null&&rr(ae,s),ye!==null&&rr(ye,s),Me.forEach(a),Ye.forEach(a),f=0;f<yt.length;f++)w=yt[f],w.blockedOn===s&&(w.blockedOn=null);for(;0<yt.length&&(f=yt[0],f.blockedOn===null);)Jn(f),f.blockedOn===null&&yt.shift()}var Ms=A.ReactCurrentBatchConfig,Ps=!0;function yl(s,a,f,w){var v=Qt,x=Ms.transition;Ms.transition=null;try{Qt=1,Ei(s,a,f,w)}finally{Qt=v,Ms.transition=x}}function xi(s,a,f,w){var v=Qt,x=Ms.transition;Ms.transition=null;try{Qt=4,Ei(s,a,f,w)}finally{Qt=v,Ms.transition=x}}function Ei(s,a,f,w){if(Ps){var v=vl(s,a,f,w);if(v===null)fh(s,a,w,Si,f),Xn(s,w);else if(Yo(v,s,a,f,w))w.stopPropagation();else if(Xn(s,w),a&4&&-1<gn.indexOf(s)){for(;v!==null;){var x=Hl(v);if(x!==null&&$o(x),x=vl(s,a,f,w),x===null&&fh(s,a,w,Si,f),x===v)break;v=x}v!==null&&w.stopPropagation()}else fh(s,a,w,null,f)}}var Si=null;function vl(s,a,f,w){if(Si=null,s=Ot(w),s=ji(s),s!==null)if(a=mr(s),a===null)s=null;else if(f=a.tag,f===13){if(s=Mn(a),s!==null)return s;s=null}else if(f===3){if(a.stateNode.current.memoizedState.isDehydrated)return a.tag===3?a.stateNode.containerInfo:null;s=null}else a!==s&&(s=null);return Si=s,null}function la(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(Tr()){case Vn:return 1;case Cn:return 4;case rn:case ve:return 16;case Ve:return 536870912;default:return 16}default:return 16}}var Xo=null,ca=null,ua=null;function bl(){if(ua)return ua;var s,a=ca,f=a.length,w,v="value"in Xo?Xo.value:Xo.textContent,x=v.length;for(s=0;s<f&&a[s]===v[s];s++);var C=f-s;for(w=1;w<=C&&a[f-w]===v[x-w];w++);return ua=v.slice(s,1<w?1-w:void 0)}function da(s){var a=s.keyCode;return"charCode"in s?(s=s.charCode,s===0&&a===13&&(s=13)):s=a,s===10&&(s=13),32<=s||s===13?s:0}function lr(){return!0}function xl(){return!1}function jr(s){function a(f,w,v,x,C){this._reactName=f,this._targetInst=v,this.type=w,this.nativeEvent=x,this.target=C,this.currentTarget=null;for(var U in s)s.hasOwnProperty(U)&&(f=s[U],this[U]=f?f(x):x[U]);return this.isDefaultPrevented=(x.defaultPrevented!=null?x.defaultPrevented:x.returnValue===!1)?lr:xl,this.isPropagationStopped=xl,this}return J(a.prototype,{preventDefault:function(){this.defaultPrevented=!0;var f=this.nativeEvent;f&&(f.preventDefault?f.preventDefault():typeof f.returnValue!="unknown"&&(f.returnValue=!1),this.isDefaultPrevented=lr)},stopPropagation:function(){var f=this.nativeEvent;f&&(f.stopPropagation?f.stopPropagation():typeof f.cancelBubble!="unknown"&&(f.cancelBubble=!0),this.isPropagationStopped=lr)},persist:function(){},isPersistent:lr}),a}var Qo={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(s){return s.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},_i=jr(Qo),Jo=J({},Qo,{view:0,detail:0}),or=jr(Jo),Ls,Ni,es,ps=J({},Jo,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:gs,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!==es&&(es&&s.type==="mousemove"?(Ls=s.screenX-es.screenX,Ni=s.screenY-es.screenY):Ni=Ls=0,es=s),Ls)},movementY:function(s){return"movementY"in s?s.movementY:Ni}}),ms=jr(ps),ou=J({},ps,{dataTransfer:0}),El=jr(ou),Sl=J({},Jo,{relatedTarget:0}),fa=jr(Sl),yw=J({},Qo,{animationName:0,elapsedTime:0,pseudoElement:0}),su=jr(yw),ha=J({},Qo,{clipboardData:function(s){return"clipboardData"in s?s.clipboardData:window.clipboardData}}),iu=jr(ha),au=J({},Qo,{data:0}),_l=jr(au),cr={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},nh={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"},pa={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function Ds(s){var a=this.nativeEvent;return a.getModifierState?a.getModifierState(s):(s=pa[s])?!!a[s]:!1}function gs(){return Ds}var Nl=J({},Jo,{key:function(s){if(s.key){var a=cr[s.key]||s.key;if(a!=="Unidentified")return a}return s.type==="keypress"?(s=da(s),s===13?"Enter":String.fromCharCode(s)):s.type==="keydown"||s.type==="keyup"?nh[s.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:gs,charCode:function(s){return s.type==="keypress"?da(s):0},keyCode:function(s){return s.type==="keydown"||s.type==="keyup"?s.keyCode:0},which:function(s){return s.type==="keypress"?da(s):s.type==="keydown"||s.type==="keyup"?s.keyCode:0}}),rh=jr(Nl),Tl=J({},ps,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),lu=jr(Tl),cu=J({},Jo,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:gs}),uu=jr(cu),du=J({},Qo,{propertyName:0,elapsedTime:0,pseudoElement:0}),fu=jr(du),Ti=J({},ps,{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}),hu=jr(Ti),oh=[9,13,27,32],jl=c&&"CompositionEvent"in window,zs=null;c&&"documentMode"in document&&(zs=document.documentMode);var ma=c&&"TextEvent"in window&&!zs,Cl=c&&(!jl||zs&&8<zs&&11>=zs),Al=" ",Il=!1;function Rl(s,a){switch(s){case"keyup":return oh.indexOf(a.keyCode)!==-1;case"keydown":return a.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function $l(s){return s=s.detail,typeof s=="object"&&"data"in s?s.data:null}var ks=!1;function pu(s,a){switch(s){case"compositionend":return $l(a);case"keypress":return a.which!==32?null:(Il=!0,Al);case"textInput":return s=a.data,s===Al&&Il?null:s;default:return null}}function mu(s,a){if(ks)return s==="compositionend"||!jl&&Rl(s,a)?(s=bl(),ua=ca=Xo=null,ks=!1,s):null;switch(s){case"paste":return null;case"keypress":if(!(a.ctrlKey||a.altKey||a.metaKey)||a.ctrlKey&&a.altKey){if(a.char&&1<a.char.length)return a.char;if(a.which)return String.fromCharCode(a.which)}return null;case"compositionend":return Cl&&a.locale!=="ko"?null:a.data;default:return null}}var gu={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 q(s){var a=s&&s.nodeName&&s.nodeName.toLowerCase();return a==="input"?!!gu[s.type]:a==="textarea"}function Je(s,a,f,w){Z(w),a=bu(a,"onChange"),0<a.length&&(f=new _i("onChange","change",null,f,w),s.push({event:f,listeners:a}))}var Pt=null,Zt=null;function ur(s){Mw(s,0)}function Fr(s){var a=va(s);if(Le(a))return s}function ku(s,a){if(s==="change")return a}var co=!1;if(c){var Ol;if(c){var Ml="oninput"in document;if(!Ml){var Pl=document.createElement("div");Pl.setAttribute("oninput","return;"),Ml=typeof Pl.oninput=="function"}Ol=Ml}else Ol=!1;co=Ol&&(!document.documentMode||9<document.documentMode)}function vw(){Pt&&(Pt.detachEvent("onpropertychange",bw),Zt=Pt=null)}function bw(s){if(s.propertyName==="value"&&Fr(Zt)){var a=[];Je(a,Zt,s,Ot(s)),Mt(ur,a)}}function WT(s,a,f){s==="focusin"?(vw(),Pt=a,Zt=f,Pt.attachEvent("onpropertychange",bw)):s==="focusout"&&vw()}function KT(s){if(s==="selectionchange"||s==="keyup"||s==="keydown")return Fr(Zt)}function ZT(s,a){if(s==="click")return Fr(a)}function qT(s,a){if(s==="input"||s==="change")return Fr(a)}function GT(s,a){return s===a&&(s!==0||1/s===1/a)||s!==s&&a!==a}var Oo=typeof Object.is=="function"?Object.is:GT;function Ll(s,a){if(Oo(s,a))return!0;if(typeof s!="object"||s===null||typeof a!="object"||a===null)return!1;var f=Object.keys(s),w=Object.keys(a);if(f.length!==w.length)return!1;for(w=0;w<f.length;w++){var v=f[w];if(!u.call(a,v)||!Oo(s[v],a[v]))return!1}return!0}function xw(s){for(;s&&s.firstChild;)s=s.firstChild;return s}function Ew(s,a){var f=xw(s);s=0;for(var w;f;){if(f.nodeType===3){if(w=s+f.textContent.length,s<=a&&w>=a)return{node:f,offset:a-s};s=w}e:{for(;f;){if(f.nextSibling){f=f.nextSibling;break e}f=f.parentNode}f=void 0}f=xw(f)}}function Sw(s,a){return s&&a?s===a?!0:s&&s.nodeType===3?!1:a&&a.nodeType===3?Sw(s,a.parentNode):"contains"in s?s.contains(a):s.compareDocumentPosition?!!(s.compareDocumentPosition(a)&16):!1:!1}function _w(){for(var s=window,a=Ue();a instanceof s.HTMLIFrameElement;){try{var f=typeof a.contentWindow.location.href=="string"}catch{f=!1}if(f)s=a.contentWindow;else break;a=Ue(s.document)}return a}function sh(s){var a=s&&s.nodeName&&s.nodeName.toLowerCase();return a&&(a==="input"&&(s.type==="text"||s.type==="search"||s.type==="tel"||s.type==="url"||s.type==="password")||a==="textarea"||s.contentEditable==="true")}function VT(s){var a=_w(),f=s.focusedElem,w=s.selectionRange;if(a!==f&&f&&f.ownerDocument&&Sw(f.ownerDocument.documentElement,f)){if(w!==null&&sh(f)){if(a=w.start,s=w.end,s===void 0&&(s=a),"selectionStart"in f)f.selectionStart=a,f.selectionEnd=Math.min(s,f.value.length);else if(s=(a=f.ownerDocument||document)&&a.defaultView||window,s.getSelection){s=s.getSelection();var v=f.textContent.length,x=Math.min(w.start,v);w=w.end===void 0?x:Math.min(w.end,v),!s.extend&&x>w&&(v=w,w=x,x=v),v=Ew(f,x);var C=Ew(f,w);v&&C&&(s.rangeCount!==1||s.anchorNode!==v.node||s.anchorOffset!==v.offset||s.focusNode!==C.node||s.focusOffset!==C.offset)&&(a=a.createRange(),a.setStart(v.node,v.offset),s.removeAllRanges(),x>w?(s.addRange(a),s.extend(C.node,C.offset)):(a.setEnd(C.node,C.offset),s.addRange(a)))}}for(a=[],s=f;s=s.parentNode;)s.nodeType===1&&a.push({element:s,left:s.scrollLeft,top:s.scrollTop});for(typeof f.focus=="function"&&f.focus(),f=0;f<a.length;f++)s=a[f],s.element.scrollLeft=s.left,s.element.scrollTop=s.top}}var YT=c&&"documentMode"in document&&11>=document.documentMode,ga=null,ih=null,Dl=null,ah=!1;function Nw(s,a,f){var w=f.window===f?f.document:f.nodeType===9?f:f.ownerDocument;ah||ga==null||ga!==Ue(w)||(w=ga,"selectionStart"in w&&sh(w)?w={start:w.selectionStart,end:w.selectionEnd}:(w=(w.ownerDocument&&w.ownerDocument.defaultView||window).getSelection(),w={anchorNode:w.anchorNode,anchorOffset:w.anchorOffset,focusNode:w.focusNode,focusOffset:w.focusOffset}),Dl&&Ll(Dl,w)||(Dl=w,w=bu(ih,"onSelect"),0<w.length&&(a=new _i("onSelect","select",null,a,f),s.push({event:a,listeners:w}),a.target=ga)))}function wu(s,a){var f={};return f[s.toLowerCase()]=a.toLowerCase(),f["Webkit"+s]="webkit"+a,f["Moz"+s]="moz"+a,f}var ka={animationend:wu("Animation","AnimationEnd"),animationiteration:wu("Animation","AnimationIteration"),animationstart:wu("Animation","AnimationStart"),transitionend:wu("Transition","TransitionEnd")},lh={},Tw={};c&&(Tw=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 yu(s){if(lh[s])return lh[s];if(!ka[s])return s;var a=ka[s],f;for(f in a)if(a.hasOwnProperty(f)&&f in Tw)return lh[s]=a[f];return s}var jw=yu("animationend"),Cw=yu("animationiteration"),Aw=yu("animationstart"),Iw=yu("transitionend"),Rw=new Map,$w="abort auxClick cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");function Fs(s,a){Rw.set(s,a),i(a,[s])}for(var ch=0;ch<$w.length;ch++){var uh=$w[ch],XT=uh.toLowerCase(),QT=uh[0].toUpperCase()+uh.slice(1);Fs(XT,"on"+QT)}Fs(jw,"onAnimationEnd"),Fs(Cw,"onAnimationIteration"),Fs(Aw,"onAnimationStart"),Fs("dblclick","onDoubleClick"),Fs("focusin","onFocus"),Fs("focusout","onBlur"),Fs(Iw,"onTransitionEnd"),l("onMouseEnter",["mouseout","mouseover"]),l("onMouseLeave",["mouseout","mouseover"]),l("onPointerEnter",["pointerout","pointerover"]),l("onPointerLeave",["pointerout","pointerover"]),i("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),i("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),i("onBeforeInput",["compositionend","keypress","textInput","paste"]),i("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),i("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),i("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var zl="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(" "),JT=new Set("cancel close invalid load scroll toggle".split(" ").concat(zl));function Ow(s,a,f){var w=s.type||"unknown-event";s.currentTarget=f,wn(w,a,void 0,s),s.currentTarget=null}function Mw(s,a){a=(a&4)!==0;for(var f=0;f<s.length;f++){var w=s[f],v=w.event;w=w.listeners;e:{var x=void 0;if(a)for(var C=w.length-1;0<=C;C--){var U=w[C],X=U.instance,he=U.currentTarget;if(U=U.listener,X!==x&&v.isPropagationStopped())break e;Ow(v,U,he),x=X}else for(C=0;C<w.length;C++){if(U=w[C],X=U.instance,he=U.currentTarget,U=U.listener,X!==x&&v.isPropagationStopped())break e;Ow(v,U,he),x=X}}}if(Yt)throw s=En,Yt=!1,En=null,s}function Rn(s,a){var f=a[wh];f===void 0&&(f=a[wh]=new Set);var w=s+"__bubble";f.has(w)||(Pw(a,s,2,!1),f.add(w))}function dh(s,a,f){var w=0;a&&(w|=4),Pw(f,s,w,a)}var vu="_reactListening"+Math.random().toString(36).slice(2);function Fl(s){if(!s[vu]){s[vu]=!0,r.forEach(function(f){f!=="selectionchange"&&(JT.has(f)||dh(f,!1,s),dh(f,!0,s))});var a=s.nodeType===9?s:s.ownerDocument;a===null||a[vu]||(a[vu]=!0,dh("selectionchange",!1,a))}}function Pw(s,a,f,w){switch(la(a)){case 1:var v=yl;break;case 4:v=xi;break;default:v=Ei}f=v.bind(null,a,f,s),v=void 0,!Se||a!=="touchstart"&&a!=="touchmove"&&a!=="wheel"||(v=!0),w?v!==void 0?s.addEventListener(a,f,{capture:!0,passive:v}):s.addEventListener(a,f,!0):v!==void 0?s.addEventListener(a,f,{passive:v}):s.addEventListener(a,f,!1)}function fh(s,a,f,w,v){var x=w;if((a&1)===0&&(a&2)===0&&w!==null)e:for(;;){if(w===null)return;var C=w.tag;if(C===3||C===4){var U=w.stateNode.containerInfo;if(U===v||U.nodeType===8&&U.parentNode===v)break;if(C===4)for(C=w.return;C!==null;){var X=C.tag;if((X===3||X===4)&&(X=C.stateNode.containerInfo,X===v||X.nodeType===8&&X.parentNode===v))return;C=C.return}for(;U!==null;){if(C=ji(U),C===null)return;if(X=C.tag,X===5||X===6){w=x=C;continue e}U=U.parentNode}}w=w.return}Mt(function(){var he=x,Re=Ot(f),Pe=[];e:{var Ie=Rw.get(s);if(Ie!==void 0){var et=_i,ot=s;switch(s){case"keypress":if(da(f)===0)break e;case"keydown":case"keyup":et=rh;break;case"focusin":ot="focus",et=fa;break;case"focusout":ot="blur",et=fa;break;case"beforeblur":case"afterblur":et=fa;break;case"click":if(f.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":et=ms;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":et=El;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":et=uu;break;case jw:case Cw:case Aw:et=su;break;case Iw:et=fu;break;case"scroll":et=or;break;case"wheel":et=hu;break;case"copy":case"cut":case"paste":et=iu;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":et=lu}var it=(a&4)!==0,er=!it&&s==="scroll",ue=it?Ie!==null?Ie+"Capture":null:Ie;it=[];for(var te=he,fe;te!==null;){fe=te;var Fe=fe.stateNode;if(fe.tag===5&&Fe!==null&&(fe=Fe,ue!==null&&(Fe=ze(te,ue),Fe!=null&&it.push(Bl(te,Fe,fe)))),er)break;te=te.return}0<it.length&&(Ie=new et(Ie,ot,null,f,Re),Pe.push({event:Ie,listeners:it}))}}if((a&7)===0){e:{if(Ie=s==="mouseover"||s==="pointerover",et=s==="mouseout"||s==="pointerout",Ie&&f!==Bt&&(ot=f.relatedTarget||f.fromElement)&&(ji(ot)||ot[ws]))break e;if((et||Ie)&&(Ie=Re.window===Re?Re:(Ie=Re.ownerDocument)?Ie.defaultView||Ie.parentWindow:window,et?(ot=f.relatedTarget||f.toElement,et=he,ot=ot?ji(ot):null,ot!==null&&(er=mr(ot),ot!==er||ot.tag!==5&&ot.tag!==6)&&(ot=null)):(et=null,ot=he),et!==ot)){if(it=ms,Fe="onMouseLeave",ue="onMouseEnter",te="mouse",(s==="pointerout"||s==="pointerover")&&(it=lu,Fe="onPointerLeave",ue="onPointerEnter",te="pointer"),er=et==null?Ie:va(et),fe=ot==null?Ie:va(ot),Ie=new it(Fe,te+"leave",et,f,Re),Ie.target=er,Ie.relatedTarget=fe,Fe=null,ji(Re)===he&&(it=new it(ue,te+"enter",ot,f,Re),it.target=fe,it.relatedTarget=er,Fe=it),er=Fe,et&&ot)t:{for(it=et,ue=ot,te=0,fe=it;fe;fe=wa(fe))te++;for(fe=0,Fe=ue;Fe;Fe=wa(Fe))fe++;for(;0<te-fe;)it=wa(it),te--;for(;0<fe-te;)ue=wa(ue),fe--;for(;te--;){if(it===ue||ue!==null&&it===ue.alternate)break t;it=wa(it),ue=wa(ue)}it=null}else it=null;et!==null&&Lw(Pe,Ie,et,it,!1),ot!==null&&er!==null&&Lw(Pe,er,ot,it,!0)}}e:{if(Ie=he?va(he):window,et=Ie.nodeName&&Ie.nodeName.toLowerCase(),et==="select"||et==="input"&&Ie.type==="file")var ct=ku;else if(q(Ie))if(co)ct=qT;else{ct=KT;var vt=WT}else(et=Ie.nodeName)&&et.toLowerCase()==="input"&&(Ie.type==="checkbox"||Ie.type==="radio")&&(ct=ZT);if(ct&&(ct=ct(s,he))){Je(Pe,ct,f,Re);break e}vt&&vt(s,Ie,he),s==="focusout"&&(vt=Ie._wrapperState)&&vt.controlled&&Ie.type==="number"&&qt(Ie,"number",Ie.value)}switch(vt=he?va(he):window,s){case"focusin":(q(vt)||vt.contentEditable==="true")&&(ga=vt,ih=he,Dl=null);break;case"focusout":Dl=ih=ga=null;break;case"mousedown":ah=!0;break;case"contextmenu":case"mouseup":case"dragend":ah=!1,Nw(Pe,f,Re);break;case"selectionchange":if(YT)break;case"keydown":case"keyup":Nw(Pe,f,Re)}var bt;if(jl)e:{switch(s){case"compositionstart":var Tt="onCompositionStart";break e;case"compositionend":Tt="onCompositionEnd";break e;case"compositionupdate":Tt="onCompositionUpdate";break e}Tt=void 0}else ks?Rl(s,f)&&(Tt="onCompositionEnd"):s==="keydown"&&f.keyCode===229&&(Tt="onCompositionStart");Tt&&(Cl&&f.locale!=="ko"&&(ks||Tt!=="onCompositionStart"?Tt==="onCompositionEnd"&&ks&&(bt=bl()):(Xo=Re,ca="value"in Xo?Xo.value:Xo.textContent,ks=!0)),vt=bu(he,Tt),0<vt.length&&(Tt=new _l(Tt,s,null,f,Re),Pe.push({event:Tt,listeners:vt}),bt?Tt.data=bt:(bt=$l(f),bt!==null&&(Tt.data=bt)))),(bt=ma?pu(s,f):mu(s,f))&&(he=bu(he,"onBeforeInput"),0<he.length&&(Re=new _l("onBeforeInput","beforeinput",null,f,Re),Pe.push({event:Re,listeners:he}),Re.data=bt))}Mw(Pe,a)})}function Bl(s,a,f){return{instance:s,listener:a,currentTarget:f}}function bu(s,a){for(var f=a+"Capture",w=[];s!==null;){var v=s,x=v.stateNode;v.tag===5&&x!==null&&(v=x,x=ze(s,f),x!=null&&w.unshift(Bl(s,x,v)),x=ze(s,a),x!=null&&w.push(Bl(s,x,v))),s=s.return}return w}function wa(s){if(s===null)return null;do s=s.return;while(s&&s.tag!==5);return s||null}function Lw(s,a,f,w,v){for(var x=a._reactName,C=[];f!==null&&f!==w;){var U=f,X=U.alternate,he=U.stateNode;if(X!==null&&X===w)break;U.tag===5&&he!==null&&(U=he,v?(X=ze(f,x),X!=null&&C.unshift(Bl(f,X,U))):v||(X=ze(f,x),X!=null&&C.push(Bl(f,X,U)))),f=f.return}C.length!==0&&s.push({event:a,listeners:C})}var ej=/\r\n?/g,tj=/\u0000|\uFFFD/g;function Dw(s){return(typeof s=="string"?s:""+s).replace(ej,`
|
|
39
|
+
`).replace(tj,"")}function xu(s,a,f){if(a=Dw(a),Dw(s)!==a&&f)throw Error(n(425))}function Eu(){}var hh=null,ph=null;function mh(s,a){return s==="textarea"||s==="noscript"||typeof a.children=="string"||typeof a.children=="number"||typeof a.dangerouslySetInnerHTML=="object"&&a.dangerouslySetInnerHTML!==null&&a.dangerouslySetInnerHTML.__html!=null}var gh=typeof setTimeout=="function"?setTimeout:void 0,nj=typeof clearTimeout=="function"?clearTimeout:void 0,zw=typeof Promise=="function"?Promise:void 0,rj=typeof queueMicrotask=="function"?queueMicrotask:typeof zw<"u"?function(s){return zw.resolve(null).then(s).catch(oj)}:gh;function oj(s){setTimeout(function(){throw s})}function kh(s,a){var f=a,w=0;do{var v=f.nextSibling;if(s.removeChild(f),v&&v.nodeType===8)if(f=v.data,f==="/$"){if(w===0){s.removeChild(v),bi(a);return}w--}else f!=="$"&&f!=="$?"&&f!=="$!"||w++;f=v}while(f);bi(a)}function Bs(s){for(;s!=null;s=s.nextSibling){var a=s.nodeType;if(a===1||a===3)break;if(a===8){if(a=s.data,a==="$"||a==="$!"||a==="$?")break;if(a==="/$")return null}}return s}function Fw(s){s=s.previousSibling;for(var a=0;s;){if(s.nodeType===8){var f=s.data;if(f==="$"||f==="$!"||f==="$?"){if(a===0)return s;a--}else f==="/$"&&a++}s=s.previousSibling}return null}var ya=Math.random().toString(36).slice(2),ts="__reactFiber$"+ya,Ul="__reactProps$"+ya,ws="__reactContainer$"+ya,wh="__reactEvents$"+ya,sj="__reactListeners$"+ya,ij="__reactHandles$"+ya;function ji(s){var a=s[ts];if(a)return a;for(var f=s.parentNode;f;){if(a=f[ws]||f[ts]){if(f=a.alternate,a.child!==null||f!==null&&f.child!==null)for(s=Fw(s);s!==null;){if(f=s[ts])return f;s=Fw(s)}return a}s=f,f=s.parentNode}return null}function Hl(s){return s=s[ts]||s[ws],!s||s.tag!==5&&s.tag!==6&&s.tag!==13&&s.tag!==3?null:s}function va(s){if(s.tag===5||s.tag===6)return s.stateNode;throw Error(n(33))}function Su(s){return s[Ul]||null}var yh=[],ba=-1;function Us(s){return{current:s}}function $n(s){0>ba||(s.current=yh[ba],yh[ba]=null,ba--)}function jn(s,a){ba++,yh[ba]=s.current,s.current=a}var Hs={},Cr=Us(Hs),Gr=Us(!1),Ci=Hs;function xa(s,a){var f=s.type.contextTypes;if(!f)return Hs;var w=s.stateNode;if(w&&w.__reactInternalMemoizedUnmaskedChildContext===a)return w.__reactInternalMemoizedMaskedChildContext;var v={},x;for(x in f)v[x]=a[x];return w&&(s=s.stateNode,s.__reactInternalMemoizedUnmaskedChildContext=a,s.__reactInternalMemoizedMaskedChildContext=v),v}function Vr(s){return s=s.childContextTypes,s!=null}function _u(){$n(Gr),$n(Cr)}function Bw(s,a,f){if(Cr.current!==Hs)throw Error(n(168));jn(Cr,a),jn(Gr,f)}function Uw(s,a,f){var w=s.stateNode;if(a=a.childContextTypes,typeof w.getChildContext!="function")return f;w=w.getChildContext();for(var v in w)if(!(v in a))throw Error(n(108,le(s)||"Unknown",v));return J({},f,w)}function Nu(s){return s=(s=s.stateNode)&&s.__reactInternalMemoizedMergedChildContext||Hs,Ci=Cr.current,jn(Cr,s),jn(Gr,Gr.current),!0}function Hw(s,a,f){var w=s.stateNode;if(!w)throw Error(n(169));f?(s=Uw(s,a,Ci),w.__reactInternalMemoizedMergedChildContext=s,$n(Gr),$n(Cr),jn(Cr,s)):$n(Gr),jn(Gr,f)}var ys=null,Tu=!1,vh=!1;function Ww(s){ys===null?ys=[s]:ys.push(s)}function aj(s){Tu=!0,Ww(s)}function Ws(){if(!vh&&ys!==null){vh=!0;var s=0,a=Qt;try{var f=ys;for(Qt=1;s<f.length;s++){var w=f[s];do w=w(!0);while(w!==null)}ys=null,Tu=!1}catch(v){throw ys!==null&&(ys=ys.slice(s+1)),ke(Vn,Ws),v}finally{Qt=a,vh=!1}}return null}var Ea=[],Sa=0,ju=null,Cu=0,wo=[],yo=0,Ai=null,vs=1,bs="";function Ii(s,a){Ea[Sa++]=Cu,Ea[Sa++]=ju,ju=s,Cu=a}function Kw(s,a,f){wo[yo++]=vs,wo[yo++]=bs,wo[yo++]=Ai,Ai=s;var w=vs;s=bs;var v=32-yn(w)-1;w&=~(1<<v),f+=1;var x=32-yn(a)+v;if(30<x){var C=v-v%5;x=(w&(1<<C)-1).toString(32),w>>=C,v-=C,vs=1<<32-yn(a)+v|f<<v|w,bs=x+s}else vs=1<<x|f<<v|w,bs=s}function bh(s){s.return!==null&&(Ii(s,1),Kw(s,1,0))}function xh(s){for(;s===ju;)ju=Ea[--Sa],Ea[Sa]=null,Cu=Ea[--Sa],Ea[Sa]=null;for(;s===Ai;)Ai=wo[--yo],wo[yo]=null,bs=wo[--yo],wo[yo]=null,vs=wo[--yo],wo[yo]=null}var uo=null,fo=null,Pn=!1,Mo=null;function Zw(s,a){var f=Eo(5,null,null,0);f.elementType="DELETED",f.stateNode=a,f.return=s,a=s.deletions,a===null?(s.deletions=[f],s.flags|=16):a.push(f)}function qw(s,a){switch(s.tag){case 5:var f=s.type;return a=a.nodeType!==1||f.toLowerCase()!==a.nodeName.toLowerCase()?null:a,a!==null?(s.stateNode=a,uo=s,fo=Bs(a.firstChild),!0):!1;case 6:return a=s.pendingProps===""||a.nodeType!==3?null:a,a!==null?(s.stateNode=a,uo=s,fo=null,!0):!1;case 13:return a=a.nodeType!==8?null:a,a!==null?(f=Ai!==null?{id:vs,overflow:bs}:null,s.memoizedState={dehydrated:a,treeContext:f,retryLane:1073741824},f=Eo(18,null,null,0),f.stateNode=a,f.return=s,s.child=f,uo=s,fo=null,!0):!1;default:return!1}}function Eh(s){return(s.mode&1)!==0&&(s.flags&128)===0}function Sh(s){if(Pn){var a=fo;if(a){var f=a;if(!qw(s,a)){if(Eh(s))throw Error(n(418));a=Bs(f.nextSibling);var w=uo;a&&qw(s,a)?Zw(w,f):(s.flags=s.flags&-4097|2,Pn=!1,uo=s)}}else{if(Eh(s))throw Error(n(418));s.flags=s.flags&-4097|2,Pn=!1,uo=s}}}function Gw(s){for(s=s.return;s!==null&&s.tag!==5&&s.tag!==3&&s.tag!==13;)s=s.return;uo=s}function Au(s){if(s!==uo)return!1;if(!Pn)return Gw(s),Pn=!0,!1;var a;if((a=s.tag!==3)&&!(a=s.tag!==5)&&(a=s.type,a=a!=="head"&&a!=="body"&&!mh(s.type,s.memoizedProps)),a&&(a=fo)){if(Eh(s))throw Vw(),Error(n(418));for(;a;)Zw(s,a),a=Bs(a.nextSibling)}if(Gw(s),s.tag===13){if(s=s.memoizedState,s=s!==null?s.dehydrated:null,!s)throw Error(n(317));e:{for(s=s.nextSibling,a=0;s;){if(s.nodeType===8){var f=s.data;if(f==="/$"){if(a===0){fo=Bs(s.nextSibling);break e}a--}else f!=="$"&&f!=="$!"&&f!=="$?"||a++}s=s.nextSibling}fo=null}}else fo=uo?Bs(s.stateNode.nextSibling):null;return!0}function Vw(){for(var s=fo;s;)s=Bs(s.nextSibling)}function _a(){fo=uo=null,Pn=!1}function _h(s){Mo===null?Mo=[s]:Mo.push(s)}var lj=A.ReactCurrentBatchConfig;function Wl(s,a,f){if(s=f.ref,s!==null&&typeof s!="function"&&typeof s!="object"){if(f._owner){if(f=f._owner,f){if(f.tag!==1)throw Error(n(309));var w=f.stateNode}if(!w)throw Error(n(147,s));var v=w,x=""+s;return a!==null&&a.ref!==null&&typeof a.ref=="function"&&a.ref._stringRef===x?a.ref:(a=function(C){var U=v.refs;C===null?delete U[x]:U[x]=C},a._stringRef=x,a)}if(typeof s!="string")throw Error(n(284));if(!f._owner)throw Error(n(290,s))}return s}function Iu(s,a){throw s=Object.prototype.toString.call(a),Error(n(31,s==="[object Object]"?"object with keys {"+Object.keys(a).join(", ")+"}":s))}function Yw(s){var a=s._init;return a(s._payload)}function Xw(s){function a(ue,te){if(s){var fe=ue.deletions;fe===null?(ue.deletions=[te],ue.flags|=16):fe.push(te)}}function f(ue,te){if(!s)return null;for(;te!==null;)a(ue,te),te=te.sibling;return null}function w(ue,te){for(ue=new Map;te!==null;)te.key!==null?ue.set(te.key,te):ue.set(te.index,te),te=te.sibling;return ue}function v(ue,te){return ue=Qs(ue,te),ue.index=0,ue.sibling=null,ue}function x(ue,te,fe){return ue.index=fe,s?(fe=ue.alternate,fe!==null?(fe=fe.index,fe<te?(ue.flags|=2,te):fe):(ue.flags|=2,te)):(ue.flags|=1048576,te)}function C(ue){return s&&ue.alternate===null&&(ue.flags|=2),ue}function U(ue,te,fe,Fe){return te===null||te.tag!==6?(te=gp(fe,ue.mode,Fe),te.return=ue,te):(te=v(te,fe),te.return=ue,te)}function X(ue,te,fe,Fe){var ct=fe.type;return ct===R?Re(ue,te,fe.props.children,Fe,fe.key):te!==null&&(te.elementType===ct||typeof ct=="object"&&ct!==null&&ct.$$typeof===we&&Yw(ct)===te.type)?(Fe=v(te,fe.props),Fe.ref=Wl(ue,te,fe),Fe.return=ue,Fe):(Fe=td(fe.type,fe.key,fe.props,null,ue.mode,Fe),Fe.ref=Wl(ue,te,fe),Fe.return=ue,Fe)}function he(ue,te,fe,Fe){return te===null||te.tag!==4||te.stateNode.containerInfo!==fe.containerInfo||te.stateNode.implementation!==fe.implementation?(te=kp(fe,ue.mode,Fe),te.return=ue,te):(te=v(te,fe.children||[]),te.return=ue,te)}function Re(ue,te,fe,Fe,ct){return te===null||te.tag!==7?(te=zi(fe,ue.mode,Fe,ct),te.return=ue,te):(te=v(te,fe),te.return=ue,te)}function Pe(ue,te,fe){if(typeof te=="string"&&te!==""||typeof te=="number")return te=gp(""+te,ue.mode,fe),te.return=ue,te;if(typeof te=="object"&&te!==null){switch(te.$$typeof){case O:return fe=td(te.type,te.key,te.props,null,ue.mode,fe),fe.ref=Wl(ue,null,te),fe.return=ue,fe;case P:return te=kp(te,ue.mode,fe),te.return=ue,te;case we:var Fe=te._init;return Pe(ue,Fe(te._payload),fe)}if(jt(te)||ee(te))return te=zi(te,ue.mode,fe,null),te.return=ue,te;Iu(ue,te)}return null}function Ie(ue,te,fe,Fe){var ct=te!==null?te.key:null;if(typeof fe=="string"&&fe!==""||typeof fe=="number")return ct!==null?null:U(ue,te,""+fe,Fe);if(typeof fe=="object"&&fe!==null){switch(fe.$$typeof){case O:return fe.key===ct?X(ue,te,fe,Fe):null;case P:return fe.key===ct?he(ue,te,fe,Fe):null;case we:return ct=fe._init,Ie(ue,te,ct(fe._payload),Fe)}if(jt(fe)||ee(fe))return ct!==null?null:Re(ue,te,fe,Fe,null);Iu(ue,fe)}return null}function et(ue,te,fe,Fe,ct){if(typeof Fe=="string"&&Fe!==""||typeof Fe=="number")return ue=ue.get(fe)||null,U(te,ue,""+Fe,ct);if(typeof Fe=="object"&&Fe!==null){switch(Fe.$$typeof){case O:return ue=ue.get(Fe.key===null?fe:Fe.key)||null,X(te,ue,Fe,ct);case P:return ue=ue.get(Fe.key===null?fe:Fe.key)||null,he(te,ue,Fe,ct);case we:var vt=Fe._init;return et(ue,te,fe,vt(Fe._payload),ct)}if(jt(Fe)||ee(Fe))return ue=ue.get(fe)||null,Re(te,ue,Fe,ct,null);Iu(te,Fe)}return null}function ot(ue,te,fe,Fe){for(var ct=null,vt=null,bt=te,Tt=te=0,wr=null;bt!==null&&Tt<fe.length;Tt++){bt.index>Tt?(wr=bt,bt=null):wr=bt.sibling;var kn=Ie(ue,bt,fe[Tt],Fe);if(kn===null){bt===null&&(bt=wr);break}s&&bt&&kn.alternate===null&&a(ue,bt),te=x(kn,te,Tt),vt===null?ct=kn:vt.sibling=kn,vt=kn,bt=wr}if(Tt===fe.length)return f(ue,bt),Pn&&Ii(ue,Tt),ct;if(bt===null){for(;Tt<fe.length;Tt++)bt=Pe(ue,fe[Tt],Fe),bt!==null&&(te=x(bt,te,Tt),vt===null?ct=bt:vt.sibling=bt,vt=bt);return Pn&&Ii(ue,Tt),ct}for(bt=w(ue,bt);Tt<fe.length;Tt++)wr=et(bt,ue,Tt,fe[Tt],Fe),wr!==null&&(s&&wr.alternate!==null&&bt.delete(wr.key===null?Tt:wr.key),te=x(wr,te,Tt),vt===null?ct=wr:vt.sibling=wr,vt=wr);return s&&bt.forEach(function(Js){return a(ue,Js)}),Pn&&Ii(ue,Tt),ct}function it(ue,te,fe,Fe){var ct=ee(fe);if(typeof ct!="function")throw Error(n(150));if(fe=ct.call(fe),fe==null)throw Error(n(151));for(var vt=ct=null,bt=te,Tt=te=0,wr=null,kn=fe.next();bt!==null&&!kn.done;Tt++,kn=fe.next()){bt.index>Tt?(wr=bt,bt=null):wr=bt.sibling;var Js=Ie(ue,bt,kn.value,Fe);if(Js===null){bt===null&&(bt=wr);break}s&&bt&&Js.alternate===null&&a(ue,bt),te=x(Js,te,Tt),vt===null?ct=Js:vt.sibling=Js,vt=Js,bt=wr}if(kn.done)return f(ue,bt),Pn&&Ii(ue,Tt),ct;if(bt===null){for(;!kn.done;Tt++,kn=fe.next())kn=Pe(ue,kn.value,Fe),kn!==null&&(te=x(kn,te,Tt),vt===null?ct=kn:vt.sibling=kn,vt=kn);return Pn&&Ii(ue,Tt),ct}for(bt=w(ue,bt);!kn.done;Tt++,kn=fe.next())kn=et(bt,ue,Tt,kn.value,Fe),kn!==null&&(s&&kn.alternate!==null&&bt.delete(kn.key===null?Tt:kn.key),te=x(kn,te,Tt),vt===null?ct=kn:vt.sibling=kn,vt=kn);return s&&bt.forEach(function(Bj){return a(ue,Bj)}),Pn&&Ii(ue,Tt),ct}function er(ue,te,fe,Fe){if(typeof fe=="object"&&fe!==null&&fe.type===R&&fe.key===null&&(fe=fe.props.children),typeof fe=="object"&&fe!==null){switch(fe.$$typeof){case O:e:{for(var ct=fe.key,vt=te;vt!==null;){if(vt.key===ct){if(ct=fe.type,ct===R){if(vt.tag===7){f(ue,vt.sibling),te=v(vt,fe.props.children),te.return=ue,ue=te;break e}}else if(vt.elementType===ct||typeof ct=="object"&&ct!==null&&ct.$$typeof===we&&Yw(ct)===vt.type){f(ue,vt.sibling),te=v(vt,fe.props),te.ref=Wl(ue,vt,fe),te.return=ue,ue=te;break e}f(ue,vt);break}else a(ue,vt);vt=vt.sibling}fe.type===R?(te=zi(fe.props.children,ue.mode,Fe,fe.key),te.return=ue,ue=te):(Fe=td(fe.type,fe.key,fe.props,null,ue.mode,Fe),Fe.ref=Wl(ue,te,fe),Fe.return=ue,ue=Fe)}return C(ue);case P:e:{for(vt=fe.key;te!==null;){if(te.key===vt)if(te.tag===4&&te.stateNode.containerInfo===fe.containerInfo&&te.stateNode.implementation===fe.implementation){f(ue,te.sibling),te=v(te,fe.children||[]),te.return=ue,ue=te;break e}else{f(ue,te);break}else a(ue,te);te=te.sibling}te=kp(fe,ue.mode,Fe),te.return=ue,ue=te}return C(ue);case we:return vt=fe._init,er(ue,te,vt(fe._payload),Fe)}if(jt(fe))return ot(ue,te,fe,Fe);if(ee(fe))return it(ue,te,fe,Fe);Iu(ue,fe)}return typeof fe=="string"&&fe!==""||typeof fe=="number"?(fe=""+fe,te!==null&&te.tag===6?(f(ue,te.sibling),te=v(te,fe),te.return=ue,ue=te):(f(ue,te),te=gp(fe,ue.mode,Fe),te.return=ue,ue=te),C(ue)):f(ue,te)}return er}var Na=Xw(!0),Qw=Xw(!1),Ru=Us(null),$u=null,Ta=null,Nh=null;function Th(){Nh=Ta=$u=null}function jh(s){var a=Ru.current;$n(Ru),s._currentValue=a}function Ch(s,a,f){for(;s!==null;){var w=s.alternate;if((s.childLanes&a)!==a?(s.childLanes|=a,w!==null&&(w.childLanes|=a)):w!==null&&(w.childLanes&a)!==a&&(w.childLanes|=a),s===f)break;s=s.return}}function ja(s,a){$u=s,Nh=Ta=null,s=s.dependencies,s!==null&&s.firstContext!==null&&((s.lanes&a)!==0&&(Yr=!0),s.firstContext=null)}function vo(s){var a=s._currentValue;if(Nh!==s)if(s={context:s,memoizedValue:a,next:null},Ta===null){if($u===null)throw Error(n(308));Ta=s,$u.dependencies={lanes:0,firstContext:s}}else Ta=Ta.next=s;return a}var Ri=null;function Ah(s){Ri===null?Ri=[s]:Ri.push(s)}function Jw(s,a,f,w){var v=a.interleaved;return v===null?(f.next=f,Ah(a)):(f.next=v.next,v.next=f),a.interleaved=f,xs(s,w)}function xs(s,a){s.lanes|=a;var f=s.alternate;for(f!==null&&(f.lanes|=a),f=s,s=s.return;s!==null;)s.childLanes|=a,f=s.alternate,f!==null&&(f.childLanes|=a),f=s,s=s.return;return f.tag===3?f.stateNode:null}var Ks=!1;function Ih(s){s.updateQueue={baseState:s.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function ey(s,a){s=s.updateQueue,a.updateQueue===s&&(a.updateQueue={baseState:s.baseState,firstBaseUpdate:s.firstBaseUpdate,lastBaseUpdate:s.lastBaseUpdate,shared:s.shared,effects:s.effects})}function Es(s,a){return{eventTime:s,lane:a,tag:0,payload:null,callback:null,next:null}}function Zs(s,a,f){var w=s.updateQueue;if(w===null)return null;if(w=w.shared,(fn&2)!==0){var v=w.pending;return v===null?a.next=a:(a.next=v.next,v.next=a),w.pending=a,xs(s,f)}return v=w.interleaved,v===null?(a.next=a,Ah(w)):(a.next=v.next,v.next=a),w.interleaved=a,xs(s,f)}function Ou(s,a,f){if(a=a.updateQueue,a!==null&&(a=a.shared,(f&4194240)!==0)){var w=a.lanes;w&=s.pendingLanes,f|=w,a.lanes=f,qr(s,f)}}function ty(s,a){var f=s.updateQueue,w=s.alternate;if(w!==null&&(w=w.updateQueue,f===w)){var v=null,x=null;if(f=f.firstBaseUpdate,f!==null){do{var C={eventTime:f.eventTime,lane:f.lane,tag:f.tag,payload:f.payload,callback:f.callback,next:null};x===null?v=x=C:x=x.next=C,f=f.next}while(f!==null);x===null?v=x=a:x=x.next=a}else v=x=a;f={baseState:w.baseState,firstBaseUpdate:v,lastBaseUpdate:x,shared:w.shared,effects:w.effects},s.updateQueue=f;return}s=f.lastBaseUpdate,s===null?f.firstBaseUpdate=a:s.next=a,f.lastBaseUpdate=a}function Mu(s,a,f,w){var v=s.updateQueue;Ks=!1;var x=v.firstBaseUpdate,C=v.lastBaseUpdate,U=v.shared.pending;if(U!==null){v.shared.pending=null;var X=U,he=X.next;X.next=null,C===null?x=he:C.next=he,C=X;var Re=s.alternate;Re!==null&&(Re=Re.updateQueue,U=Re.lastBaseUpdate,U!==C&&(U===null?Re.firstBaseUpdate=he:U.next=he,Re.lastBaseUpdate=X))}if(x!==null){var Pe=v.baseState;C=0,Re=he=X=null,U=x;do{var Ie=U.lane,et=U.eventTime;if((w&Ie)===Ie){Re!==null&&(Re=Re.next={eventTime:et,lane:0,tag:U.tag,payload:U.payload,callback:U.callback,next:null});e:{var ot=s,it=U;switch(Ie=a,et=f,it.tag){case 1:if(ot=it.payload,typeof ot=="function"){Pe=ot.call(et,Pe,Ie);break e}Pe=ot;break e;case 3:ot.flags=ot.flags&-65537|128;case 0:if(ot=it.payload,Ie=typeof ot=="function"?ot.call(et,Pe,Ie):ot,Ie==null)break e;Pe=J({},Pe,Ie);break e;case 2:Ks=!0}}U.callback!==null&&U.lane!==0&&(s.flags|=64,Ie=v.effects,Ie===null?v.effects=[U]:Ie.push(U))}else et={eventTime:et,lane:Ie,tag:U.tag,payload:U.payload,callback:U.callback,next:null},Re===null?(he=Re=et,X=Pe):Re=Re.next=et,C|=Ie;if(U=U.next,U===null){if(U=v.shared.pending,U===null)break;Ie=U,U=Ie.next,Ie.next=null,v.lastBaseUpdate=Ie,v.shared.pending=null}}while(!0);if(Re===null&&(X=Pe),v.baseState=X,v.firstBaseUpdate=he,v.lastBaseUpdate=Re,a=v.shared.interleaved,a!==null){v=a;do C|=v.lane,v=v.next;while(v!==a)}else x===null&&(v.shared.lanes=0);Mi|=C,s.lanes=C,s.memoizedState=Pe}}function ny(s,a,f){if(s=a.effects,a.effects=null,s!==null)for(a=0;a<s.length;a++){var w=s[a],v=w.callback;if(v!==null){if(w.callback=null,w=f,typeof v!="function")throw Error(n(191,v));v.call(w)}}}var Kl={},ns=Us(Kl),Zl=Us(Kl),ql=Us(Kl);function $i(s){if(s===Kl)throw Error(n(174));return s}function Rh(s,a){switch(jn(ql,a),jn(Zl,s),jn(ns,Kl),s=a.nodeType,s){case 9:case 11:a=(a=a.documentElement)?a.namespaceURI:_t(null,"");break;default:s=s===8?a.parentNode:a,a=s.namespaceURI||null,s=s.tagName,a=_t(a,s)}$n(ns),jn(ns,a)}function Ca(){$n(ns),$n(Zl),$n(ql)}function ry(s){$i(ql.current);var a=$i(ns.current),f=_t(a,s.type);a!==f&&(jn(Zl,s),jn(ns,f))}function $h(s){Zl.current===s&&($n(ns),$n(Zl))}var Un=Us(0);function Pu(s){for(var a=s;a!==null;){if(a.tag===13){var f=a.memoizedState;if(f!==null&&(f=f.dehydrated,f===null||f.data==="$?"||f.data==="$!"))return a}else if(a.tag===19&&a.memoizedProps.revealOrder!==void 0){if((a.flags&128)!==0)return a}else if(a.child!==null){a.child.return=a,a=a.child;continue}if(a===s)break;for(;a.sibling===null;){if(a.return===null||a.return===s)return null;a=a.return}a.sibling.return=a.return,a=a.sibling}return null}var Oh=[];function Mh(){for(var s=0;s<Oh.length;s++)Oh[s]._workInProgressVersionPrimary=null;Oh.length=0}var Lu=A.ReactCurrentDispatcher,Ph=A.ReactCurrentBatchConfig,Oi=0,Hn=null,dr=null,gr=null,Du=!1,Gl=!1,Vl=0,cj=0;function Ar(){throw Error(n(321))}function Lh(s,a){if(a===null)return!1;for(var f=0;f<a.length&&f<s.length;f++)if(!Oo(s[f],a[f]))return!1;return!0}function Dh(s,a,f,w,v,x){if(Oi=x,Hn=a,a.memoizedState=null,a.updateQueue=null,a.lanes=0,Lu.current=s===null||s.memoizedState===null?hj:pj,s=f(w,v),Gl){x=0;do{if(Gl=!1,Vl=0,25<=x)throw Error(n(301));x+=1,gr=dr=null,a.updateQueue=null,Lu.current=mj,s=f(w,v)}while(Gl)}if(Lu.current=Bu,a=dr!==null&&dr.next!==null,Oi=0,gr=dr=Hn=null,Du=!1,a)throw Error(n(300));return s}function zh(){var s=Vl!==0;return Vl=0,s}function rs(){var s={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return gr===null?Hn.memoizedState=gr=s:gr=gr.next=s,gr}function bo(){if(dr===null){var s=Hn.alternate;s=s!==null?s.memoizedState:null}else s=dr.next;var a=gr===null?Hn.memoizedState:gr.next;if(a!==null)gr=a,dr=s;else{if(s===null)throw Error(n(310));dr=s,s={memoizedState:dr.memoizedState,baseState:dr.baseState,baseQueue:dr.baseQueue,queue:dr.queue,next:null},gr===null?Hn.memoizedState=gr=s:gr=gr.next=s}return gr}function Yl(s,a){return typeof a=="function"?a(s):a}function Fh(s){var a=bo(),f=a.queue;if(f===null)throw Error(n(311));f.lastRenderedReducer=s;var w=dr,v=w.baseQueue,x=f.pending;if(x!==null){if(v!==null){var C=v.next;v.next=x.next,x.next=C}w.baseQueue=v=x,f.pending=null}if(v!==null){x=v.next,w=w.baseState;var U=C=null,X=null,he=x;do{var Re=he.lane;if((Oi&Re)===Re)X!==null&&(X=X.next={lane:0,action:he.action,hasEagerState:he.hasEagerState,eagerState:he.eagerState,next:null}),w=he.hasEagerState?he.eagerState:s(w,he.action);else{var Pe={lane:Re,action:he.action,hasEagerState:he.hasEagerState,eagerState:he.eagerState,next:null};X===null?(U=X=Pe,C=w):X=X.next=Pe,Hn.lanes|=Re,Mi|=Re}he=he.next}while(he!==null&&he!==x);X===null?C=w:X.next=U,Oo(w,a.memoizedState)||(Yr=!0),a.memoizedState=w,a.baseState=C,a.baseQueue=X,f.lastRenderedState=w}if(s=f.interleaved,s!==null){v=s;do x=v.lane,Hn.lanes|=x,Mi|=x,v=v.next;while(v!==s)}else v===null&&(f.lanes=0);return[a.memoizedState,f.dispatch]}function Bh(s){var a=bo(),f=a.queue;if(f===null)throw Error(n(311));f.lastRenderedReducer=s;var w=f.dispatch,v=f.pending,x=a.memoizedState;if(v!==null){f.pending=null;var C=v=v.next;do x=s(x,C.action),C=C.next;while(C!==v);Oo(x,a.memoizedState)||(Yr=!0),a.memoizedState=x,a.baseQueue===null&&(a.baseState=x),f.lastRenderedState=x}return[x,w]}function oy(){}function sy(s,a){var f=Hn,w=bo(),v=a(),x=!Oo(w.memoizedState,v);if(x&&(w.memoizedState=v,Yr=!0),w=w.queue,Uh(ly.bind(null,f,w,s),[s]),w.getSnapshot!==a||x||gr!==null&&gr.memoizedState.tag&1){if(f.flags|=2048,Xl(9,ay.bind(null,f,w,v,a),void 0,null),kr===null)throw Error(n(349));(Oi&30)!==0||iy(f,a,v)}return v}function iy(s,a,f){s.flags|=16384,s={getSnapshot:a,value:f},a=Hn.updateQueue,a===null?(a={lastEffect:null,stores:null},Hn.updateQueue=a,a.stores=[s]):(f=a.stores,f===null?a.stores=[s]:f.push(s))}function ay(s,a,f,w){a.value=f,a.getSnapshot=w,cy(a)&&uy(s)}function ly(s,a,f){return f(function(){cy(a)&&uy(s)})}function cy(s){var a=s.getSnapshot;s=s.value;try{var f=a();return!Oo(s,f)}catch{return!0}}function uy(s){var a=xs(s,1);a!==null&&zo(a,s,1,-1)}function dy(s){var a=rs();return typeof s=="function"&&(s=s()),a.memoizedState=a.baseState=s,s={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:Yl,lastRenderedState:s},a.queue=s,s=s.dispatch=fj.bind(null,Hn,s),[a.memoizedState,s]}function Xl(s,a,f,w){return s={tag:s,create:a,destroy:f,deps:w,next:null},a=Hn.updateQueue,a===null?(a={lastEffect:null,stores:null},Hn.updateQueue=a,a.lastEffect=s.next=s):(f=a.lastEffect,f===null?a.lastEffect=s.next=s:(w=f.next,f.next=s,s.next=w,a.lastEffect=s)),s}function fy(){return bo().memoizedState}function zu(s,a,f,w){var v=rs();Hn.flags|=s,v.memoizedState=Xl(1|a,f,void 0,w===void 0?null:w)}function Fu(s,a,f,w){var v=bo();w=w===void 0?null:w;var x=void 0;if(dr!==null){var C=dr.memoizedState;if(x=C.destroy,w!==null&&Lh(w,C.deps)){v.memoizedState=Xl(a,f,x,w);return}}Hn.flags|=s,v.memoizedState=Xl(1|a,f,x,w)}function hy(s,a){return zu(8390656,8,s,a)}function Uh(s,a){return Fu(2048,8,s,a)}function py(s,a){return Fu(4,2,s,a)}function my(s,a){return Fu(4,4,s,a)}function gy(s,a){if(typeof a=="function")return s=s(),a(s),function(){a(null)};if(a!=null)return s=s(),a.current=s,function(){a.current=null}}function ky(s,a,f){return f=f!=null?f.concat([s]):null,Fu(4,4,gy.bind(null,a,s),f)}function Hh(){}function wy(s,a){var f=bo();a=a===void 0?null:a;var w=f.memoizedState;return w!==null&&a!==null&&Lh(a,w[1])?w[0]:(f.memoizedState=[s,a],s)}function yy(s,a){var f=bo();a=a===void 0?null:a;var w=f.memoizedState;return w!==null&&a!==null&&Lh(a,w[1])?w[0]:(s=s(),f.memoizedState=[s,a],s)}function vy(s,a,f){return(Oi&21)===0?(s.baseState&&(s.baseState=!1,Yr=!0),s.memoizedState=f):(Oo(f,a)||(f=Ro(),Hn.lanes|=f,Mi|=f,s.baseState=!0),a)}function uj(s,a){var f=Qt;Qt=f!==0&&4>f?f:4,s(!0);var w=Ph.transition;Ph.transition={};try{s(!1),a()}finally{Qt=f,Ph.transition=w}}function by(){return bo().memoizedState}function dj(s,a,f){var w=Ys(s);if(f={lane:w,action:f,hasEagerState:!1,eagerState:null,next:null},xy(s))Ey(a,f);else if(f=Jw(s,a,f,w),f!==null){var v=Ur();zo(f,s,w,v),Sy(f,a,w)}}function fj(s,a,f){var w=Ys(s),v={lane:w,action:f,hasEagerState:!1,eagerState:null,next:null};if(xy(s))Ey(a,v);else{var x=s.alternate;if(s.lanes===0&&(x===null||x.lanes===0)&&(x=a.lastRenderedReducer,x!==null))try{var C=a.lastRenderedState,U=x(C,f);if(v.hasEagerState=!0,v.eagerState=U,Oo(U,C)){var X=a.interleaved;X===null?(v.next=v,Ah(a)):(v.next=X.next,X.next=v),a.interleaved=v;return}}catch{}finally{}f=Jw(s,a,v,w),f!==null&&(v=Ur(),zo(f,s,w,v),Sy(f,a,w))}}function xy(s){var a=s.alternate;return s===Hn||a!==null&&a===Hn}function Ey(s,a){Gl=Du=!0;var f=s.pending;f===null?a.next=a:(a.next=f.next,f.next=a),s.pending=a}function Sy(s,a,f){if((f&4194240)!==0){var w=a.lanes;w&=s.pendingLanes,f|=w,a.lanes=f,qr(s,f)}}var Bu={readContext:vo,useCallback:Ar,useContext:Ar,useEffect:Ar,useImperativeHandle:Ar,useInsertionEffect:Ar,useLayoutEffect:Ar,useMemo:Ar,useReducer:Ar,useRef:Ar,useState:Ar,useDebugValue:Ar,useDeferredValue:Ar,useTransition:Ar,useMutableSource:Ar,useSyncExternalStore:Ar,useId:Ar,unstable_isNewReconciler:!1},hj={readContext:vo,useCallback:function(s,a){return rs().memoizedState=[s,a===void 0?null:a],s},useContext:vo,useEffect:hy,useImperativeHandle:function(s,a,f){return f=f!=null?f.concat([s]):null,zu(4194308,4,gy.bind(null,a,s),f)},useLayoutEffect:function(s,a){return zu(4194308,4,s,a)},useInsertionEffect:function(s,a){return zu(4,2,s,a)},useMemo:function(s,a){var f=rs();return a=a===void 0?null:a,s=s(),f.memoizedState=[s,a],s},useReducer:function(s,a,f){var w=rs();return a=f!==void 0?f(a):a,w.memoizedState=w.baseState=a,s={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:s,lastRenderedState:a},w.queue=s,s=s.dispatch=dj.bind(null,Hn,s),[w.memoizedState,s]},useRef:function(s){var a=rs();return s={current:s},a.memoizedState=s},useState:dy,useDebugValue:Hh,useDeferredValue:function(s){return rs().memoizedState=s},useTransition:function(){var s=dy(!1),a=s[0];return s=uj.bind(null,s[1]),rs().memoizedState=s,[a,s]},useMutableSource:function(){},useSyncExternalStore:function(s,a,f){var w=Hn,v=rs();if(Pn){if(f===void 0)throw Error(n(407));f=f()}else{if(f=a(),kr===null)throw Error(n(349));(Oi&30)!==0||iy(w,a,f)}v.memoizedState=f;var x={value:f,getSnapshot:a};return v.queue=x,hy(ly.bind(null,w,x,s),[s]),w.flags|=2048,Xl(9,ay.bind(null,w,x,f,a),void 0,null),f},useId:function(){var s=rs(),a=kr.identifierPrefix;if(Pn){var f=bs,w=vs;f=(w&~(1<<32-yn(w)-1)).toString(32)+f,a=":"+a+"R"+f,f=Vl++,0<f&&(a+="H"+f.toString(32)),a+=":"}else f=cj++,a=":"+a+"r"+f.toString(32)+":";return s.memoizedState=a},unstable_isNewReconciler:!1},pj={readContext:vo,useCallback:wy,useContext:vo,useEffect:Uh,useImperativeHandle:ky,useInsertionEffect:py,useLayoutEffect:my,useMemo:yy,useReducer:Fh,useRef:fy,useState:function(){return Fh(Yl)},useDebugValue:Hh,useDeferredValue:function(s){var a=bo();return vy(a,dr.memoizedState,s)},useTransition:function(){var s=Fh(Yl)[0],a=bo().memoizedState;return[s,a]},useMutableSource:oy,useSyncExternalStore:sy,useId:by,unstable_isNewReconciler:!1},mj={readContext:vo,useCallback:wy,useContext:vo,useEffect:Uh,useImperativeHandle:ky,useInsertionEffect:py,useLayoutEffect:my,useMemo:yy,useReducer:Bh,useRef:fy,useState:function(){return Bh(Yl)},useDebugValue:Hh,useDeferredValue:function(s){var a=bo();return dr===null?a.memoizedState=s:vy(a,dr.memoizedState,s)},useTransition:function(){var s=Bh(Yl)[0],a=bo().memoizedState;return[s,a]},useMutableSource:oy,useSyncExternalStore:sy,useId:by,unstable_isNewReconciler:!1};function Po(s,a){if(s&&s.defaultProps){a=J({},a),s=s.defaultProps;for(var f in s)a[f]===void 0&&(a[f]=s[f]);return a}return a}function Wh(s,a,f,w){a=s.memoizedState,f=f(w,a),f=f==null?a:J({},a,f),s.memoizedState=f,s.lanes===0&&(s.updateQueue.baseState=f)}var Uu={isMounted:function(s){return(s=s._reactInternals)?mr(s)===s:!1},enqueueSetState:function(s,a,f){s=s._reactInternals;var w=Ur(),v=Ys(s),x=Es(w,v);x.payload=a,f!=null&&(x.callback=f),a=Zs(s,x,v),a!==null&&(zo(a,s,v,w),Ou(a,s,v))},enqueueReplaceState:function(s,a,f){s=s._reactInternals;var w=Ur(),v=Ys(s),x=Es(w,v);x.tag=1,x.payload=a,f!=null&&(x.callback=f),a=Zs(s,x,v),a!==null&&(zo(a,s,v,w),Ou(a,s,v))},enqueueForceUpdate:function(s,a){s=s._reactInternals;var f=Ur(),w=Ys(s),v=Es(f,w);v.tag=2,a!=null&&(v.callback=a),a=Zs(s,v,w),a!==null&&(zo(a,s,w,f),Ou(a,s,w))}};function _y(s,a,f,w,v,x,C){return s=s.stateNode,typeof s.shouldComponentUpdate=="function"?s.shouldComponentUpdate(w,x,C):a.prototype&&a.prototype.isPureReactComponent?!Ll(f,w)||!Ll(v,x):!0}function Ny(s,a,f){var w=!1,v=Hs,x=a.contextType;return typeof x=="object"&&x!==null?x=vo(x):(v=Vr(a)?Ci:Cr.current,w=a.contextTypes,x=(w=w!=null)?xa(s,v):Hs),a=new a(f,x),s.memoizedState=a.state!==null&&a.state!==void 0?a.state:null,a.updater=Uu,s.stateNode=a,a._reactInternals=s,w&&(s=s.stateNode,s.__reactInternalMemoizedUnmaskedChildContext=v,s.__reactInternalMemoizedMaskedChildContext=x),a}function Ty(s,a,f,w){s=a.state,typeof a.componentWillReceiveProps=="function"&&a.componentWillReceiveProps(f,w),typeof a.UNSAFE_componentWillReceiveProps=="function"&&a.UNSAFE_componentWillReceiveProps(f,w),a.state!==s&&Uu.enqueueReplaceState(a,a.state,null)}function Kh(s,a,f,w){var v=s.stateNode;v.props=f,v.state=s.memoizedState,v.refs={},Ih(s);var x=a.contextType;typeof x=="object"&&x!==null?v.context=vo(x):(x=Vr(a)?Ci:Cr.current,v.context=xa(s,x)),v.state=s.memoizedState,x=a.getDerivedStateFromProps,typeof x=="function"&&(Wh(s,a,x,f),v.state=s.memoizedState),typeof a.getDerivedStateFromProps=="function"||typeof v.getSnapshotBeforeUpdate=="function"||typeof v.UNSAFE_componentWillMount!="function"&&typeof v.componentWillMount!="function"||(a=v.state,typeof v.componentWillMount=="function"&&v.componentWillMount(),typeof v.UNSAFE_componentWillMount=="function"&&v.UNSAFE_componentWillMount(),a!==v.state&&Uu.enqueueReplaceState(v,v.state,null),Mu(s,f,v,w),v.state=s.memoizedState),typeof v.componentDidMount=="function"&&(s.flags|=4194308)}function Aa(s,a){try{var f="",w=a;do f+=de(w),w=w.return;while(w);var v=f}catch(x){v=`
|
|
40
|
+
Error generating stack: `+x.message+`
|
|
41
|
+
`+x.stack}return{value:s,source:a,stack:v,digest:null}}function Zh(s,a,f){return{value:s,source:null,stack:f??null,digest:a??null}}function qh(s,a){try{console.error(a.value)}catch(f){setTimeout(function(){throw f})}}var gj=typeof WeakMap=="function"?WeakMap:Map;function jy(s,a,f){f=Es(-1,f),f.tag=3,f.payload={element:null};var w=a.value;return f.callback=function(){Vu||(Vu=!0,lp=w),qh(s,a)},f}function Cy(s,a,f){f=Es(-1,f),f.tag=3;var w=s.type.getDerivedStateFromError;if(typeof w=="function"){var v=a.value;f.payload=function(){return w(v)},f.callback=function(){qh(s,a)}}var x=s.stateNode;return x!==null&&typeof x.componentDidCatch=="function"&&(f.callback=function(){qh(s,a),typeof w!="function"&&(Gs===null?Gs=new Set([this]):Gs.add(this));var C=a.stack;this.componentDidCatch(a.value,{componentStack:C!==null?C:""})}),f}function Ay(s,a,f){var w=s.pingCache;if(w===null){w=s.pingCache=new gj;var v=new Set;w.set(a,v)}else v=w.get(a),v===void 0&&(v=new Set,w.set(a,v));v.has(f)||(v.add(f),s=Aj.bind(null,s,a,f),a.then(s,s))}function Iy(s){do{var a;if((a=s.tag===13)&&(a=s.memoizedState,a=a!==null?a.dehydrated!==null:!0),a)return s;s=s.return}while(s!==null);return null}function Ry(s,a,f,w,v){return(s.mode&1)===0?(s===a?s.flags|=65536:(s.flags|=128,f.flags|=131072,f.flags&=-52805,f.tag===1&&(f.alternate===null?f.tag=17:(a=Es(-1,1),a.tag=2,Zs(f,a,1))),f.lanes|=1),s):(s.flags|=65536,s.lanes=v,s)}var kj=A.ReactCurrentOwner,Yr=!1;function Br(s,a,f,w){a.child=s===null?Qw(a,null,f,w):Na(a,s.child,f,w)}function $y(s,a,f,w,v){f=f.render;var x=a.ref;return ja(a,v),w=Dh(s,a,f,w,x,v),f=zh(),s!==null&&!Yr?(a.updateQueue=s.updateQueue,a.flags&=-2053,s.lanes&=~v,Ss(s,a,v)):(Pn&&f&&bh(a),a.flags|=1,Br(s,a,w,v),a.child)}function Oy(s,a,f,w,v){if(s===null){var x=f.type;return typeof x=="function"&&!mp(x)&&x.defaultProps===void 0&&f.compare===null&&f.defaultProps===void 0?(a.tag=15,a.type=x,My(s,a,x,w,v)):(s=td(f.type,null,w,a,a.mode,v),s.ref=a.ref,s.return=a,a.child=s)}if(x=s.child,(s.lanes&v)===0){var C=x.memoizedProps;if(f=f.compare,f=f!==null?f:Ll,f(C,w)&&s.ref===a.ref)return Ss(s,a,v)}return a.flags|=1,s=Qs(x,w),s.ref=a.ref,s.return=a,a.child=s}function My(s,a,f,w,v){if(s!==null){var x=s.memoizedProps;if(Ll(x,w)&&s.ref===a.ref)if(Yr=!1,a.pendingProps=w=x,(s.lanes&v)!==0)(s.flags&131072)!==0&&(Yr=!0);else return a.lanes=s.lanes,Ss(s,a,v)}return Gh(s,a,f,w,v)}function Py(s,a,f){var w=a.pendingProps,v=w.children,x=s!==null?s.memoizedState:null;if(w.mode==="hidden")if((a.mode&1)===0)a.memoizedState={baseLanes:0,cachePool:null,transitions:null},jn(Ra,ho),ho|=f;else{if((f&1073741824)===0)return s=x!==null?x.baseLanes|f:f,a.lanes=a.childLanes=1073741824,a.memoizedState={baseLanes:s,cachePool:null,transitions:null},a.updateQueue=null,jn(Ra,ho),ho|=s,null;a.memoizedState={baseLanes:0,cachePool:null,transitions:null},w=x!==null?x.baseLanes:f,jn(Ra,ho),ho|=w}else x!==null?(w=x.baseLanes|f,a.memoizedState=null):w=f,jn(Ra,ho),ho|=w;return Br(s,a,v,f),a.child}function Ly(s,a){var f=a.ref;(s===null&&f!==null||s!==null&&s.ref!==f)&&(a.flags|=512,a.flags|=2097152)}function Gh(s,a,f,w,v){var x=Vr(f)?Ci:Cr.current;return x=xa(a,x),ja(a,v),f=Dh(s,a,f,w,x,v),w=zh(),s!==null&&!Yr?(a.updateQueue=s.updateQueue,a.flags&=-2053,s.lanes&=~v,Ss(s,a,v)):(Pn&&w&&bh(a),a.flags|=1,Br(s,a,f,v),a.child)}function Dy(s,a,f,w,v){if(Vr(f)){var x=!0;Nu(a)}else x=!1;if(ja(a,v),a.stateNode===null)Wu(s,a),Ny(a,f,w),Kh(a,f,w,v),w=!0;else if(s===null){var C=a.stateNode,U=a.memoizedProps;C.props=U;var X=C.context,he=f.contextType;typeof he=="object"&&he!==null?he=vo(he):(he=Vr(f)?Ci:Cr.current,he=xa(a,he));var Re=f.getDerivedStateFromProps,Pe=typeof Re=="function"||typeof C.getSnapshotBeforeUpdate=="function";Pe||typeof C.UNSAFE_componentWillReceiveProps!="function"&&typeof C.componentWillReceiveProps!="function"||(U!==w||X!==he)&&Ty(a,C,w,he),Ks=!1;var Ie=a.memoizedState;C.state=Ie,Mu(a,w,C,v),X=a.memoizedState,U!==w||Ie!==X||Gr.current||Ks?(typeof Re=="function"&&(Wh(a,f,Re,w),X=a.memoizedState),(U=Ks||_y(a,f,U,w,Ie,X,he))?(Pe||typeof C.UNSAFE_componentWillMount!="function"&&typeof C.componentWillMount!="function"||(typeof C.componentWillMount=="function"&&C.componentWillMount(),typeof C.UNSAFE_componentWillMount=="function"&&C.UNSAFE_componentWillMount()),typeof C.componentDidMount=="function"&&(a.flags|=4194308)):(typeof C.componentDidMount=="function"&&(a.flags|=4194308),a.memoizedProps=w,a.memoizedState=X),C.props=w,C.state=X,C.context=he,w=U):(typeof C.componentDidMount=="function"&&(a.flags|=4194308),w=!1)}else{C=a.stateNode,ey(s,a),U=a.memoizedProps,he=a.type===a.elementType?U:Po(a.type,U),C.props=he,Pe=a.pendingProps,Ie=C.context,X=f.contextType,typeof X=="object"&&X!==null?X=vo(X):(X=Vr(f)?Ci:Cr.current,X=xa(a,X));var et=f.getDerivedStateFromProps;(Re=typeof et=="function"||typeof C.getSnapshotBeforeUpdate=="function")||typeof C.UNSAFE_componentWillReceiveProps!="function"&&typeof C.componentWillReceiveProps!="function"||(U!==Pe||Ie!==X)&&Ty(a,C,w,X),Ks=!1,Ie=a.memoizedState,C.state=Ie,Mu(a,w,C,v);var ot=a.memoizedState;U!==Pe||Ie!==ot||Gr.current||Ks?(typeof et=="function"&&(Wh(a,f,et,w),ot=a.memoizedState),(he=Ks||_y(a,f,he,w,Ie,ot,X)||!1)?(Re||typeof C.UNSAFE_componentWillUpdate!="function"&&typeof C.componentWillUpdate!="function"||(typeof C.componentWillUpdate=="function"&&C.componentWillUpdate(w,ot,X),typeof C.UNSAFE_componentWillUpdate=="function"&&C.UNSAFE_componentWillUpdate(w,ot,X)),typeof C.componentDidUpdate=="function"&&(a.flags|=4),typeof C.getSnapshotBeforeUpdate=="function"&&(a.flags|=1024)):(typeof C.componentDidUpdate!="function"||U===s.memoizedProps&&Ie===s.memoizedState||(a.flags|=4),typeof C.getSnapshotBeforeUpdate!="function"||U===s.memoizedProps&&Ie===s.memoizedState||(a.flags|=1024),a.memoizedProps=w,a.memoizedState=ot),C.props=w,C.state=ot,C.context=X,w=he):(typeof C.componentDidUpdate!="function"||U===s.memoizedProps&&Ie===s.memoizedState||(a.flags|=4),typeof C.getSnapshotBeforeUpdate!="function"||U===s.memoizedProps&&Ie===s.memoizedState||(a.flags|=1024),w=!1)}return Vh(s,a,f,w,x,v)}function Vh(s,a,f,w,v,x){Ly(s,a);var C=(a.flags&128)!==0;if(!w&&!C)return v&&Hw(a,f,!1),Ss(s,a,x);w=a.stateNode,kj.current=a;var U=C&&typeof f.getDerivedStateFromError!="function"?null:w.render();return a.flags|=1,s!==null&&C?(a.child=Na(a,s.child,null,x),a.child=Na(a,null,U,x)):Br(s,a,U,x),a.memoizedState=w.state,v&&Hw(a,f,!0),a.child}function zy(s){var a=s.stateNode;a.pendingContext?Bw(s,a.pendingContext,a.pendingContext!==a.context):a.context&&Bw(s,a.context,!1),Rh(s,a.containerInfo)}function Fy(s,a,f,w,v){return _a(),_h(v),a.flags|=256,Br(s,a,f,w),a.child}var Yh={dehydrated:null,treeContext:null,retryLane:0};function Xh(s){return{baseLanes:s,cachePool:null,transitions:null}}function By(s,a,f){var w=a.pendingProps,v=Un.current,x=!1,C=(a.flags&128)!==0,U;if((U=C)||(U=s!==null&&s.memoizedState===null?!1:(v&2)!==0),U?(x=!0,a.flags&=-129):(s===null||s.memoizedState!==null)&&(v|=1),jn(Un,v&1),s===null)return Sh(a),s=a.memoizedState,s!==null&&(s=s.dehydrated,s!==null)?((a.mode&1)===0?a.lanes=1:s.data==="$!"?a.lanes=8:a.lanes=1073741824,null):(C=w.children,s=w.fallback,x?(w=a.mode,x=a.child,C={mode:"hidden",children:C},(w&1)===0&&x!==null?(x.childLanes=0,x.pendingProps=C):x=nd(C,w,0,null),s=zi(s,w,f,null),x.return=a,s.return=a,x.sibling=s,a.child=x,a.child.memoizedState=Xh(f),a.memoizedState=Yh,s):Qh(a,C));if(v=s.memoizedState,v!==null&&(U=v.dehydrated,U!==null))return wj(s,a,C,w,U,v,f);if(x){x=w.fallback,C=a.mode,v=s.child,U=v.sibling;var X={mode:"hidden",children:w.children};return(C&1)===0&&a.child!==v?(w=a.child,w.childLanes=0,w.pendingProps=X,a.deletions=null):(w=Qs(v,X),w.subtreeFlags=v.subtreeFlags&14680064),U!==null?x=Qs(U,x):(x=zi(x,C,f,null),x.flags|=2),x.return=a,w.return=a,w.sibling=x,a.child=w,w=x,x=a.child,C=s.child.memoizedState,C=C===null?Xh(f):{baseLanes:C.baseLanes|f,cachePool:null,transitions:C.transitions},x.memoizedState=C,x.childLanes=s.childLanes&~f,a.memoizedState=Yh,w}return x=s.child,s=x.sibling,w=Qs(x,{mode:"visible",children:w.children}),(a.mode&1)===0&&(w.lanes=f),w.return=a,w.sibling=null,s!==null&&(f=a.deletions,f===null?(a.deletions=[s],a.flags|=16):f.push(s)),a.child=w,a.memoizedState=null,w}function Qh(s,a){return a=nd({mode:"visible",children:a},s.mode,0,null),a.return=s,s.child=a}function Hu(s,a,f,w){return w!==null&&_h(w),Na(a,s.child,null,f),s=Qh(a,a.pendingProps.children),s.flags|=2,a.memoizedState=null,s}function wj(s,a,f,w,v,x,C){if(f)return a.flags&256?(a.flags&=-257,w=Zh(Error(n(422))),Hu(s,a,C,w)):a.memoizedState!==null?(a.child=s.child,a.flags|=128,null):(x=w.fallback,v=a.mode,w=nd({mode:"visible",children:w.children},v,0,null),x=zi(x,v,C,null),x.flags|=2,w.return=a,x.return=a,w.sibling=x,a.child=w,(a.mode&1)!==0&&Na(a,s.child,null,C),a.child.memoizedState=Xh(C),a.memoizedState=Yh,x);if((a.mode&1)===0)return Hu(s,a,C,null);if(v.data==="$!"){if(w=v.nextSibling&&v.nextSibling.dataset,w)var U=w.dgst;return w=U,x=Error(n(419)),w=Zh(x,w,void 0),Hu(s,a,C,w)}if(U=(C&s.childLanes)!==0,Yr||U){if(w=kr,w!==null){switch(C&-C){case 4:v=2;break;case 16:v=8;break;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:v=32;break;case 536870912:v=268435456;break;default:v=0}v=(v&(w.suspendedLanes|C))!==0?0:v,v!==0&&v!==x.retryLane&&(x.retryLane=v,xs(s,v),zo(w,s,v,-1))}return pp(),w=Zh(Error(n(421))),Hu(s,a,C,w)}return v.data==="$?"?(a.flags|=128,a.child=s.child,a=Ij.bind(null,s),v._reactRetry=a,null):(s=x.treeContext,fo=Bs(v.nextSibling),uo=a,Pn=!0,Mo=null,s!==null&&(wo[yo++]=vs,wo[yo++]=bs,wo[yo++]=Ai,vs=s.id,bs=s.overflow,Ai=a),a=Qh(a,w.children),a.flags|=4096,a)}function Uy(s,a,f){s.lanes|=a;var w=s.alternate;w!==null&&(w.lanes|=a),Ch(s.return,a,f)}function Jh(s,a,f,w,v){var x=s.memoizedState;x===null?s.memoizedState={isBackwards:a,rendering:null,renderingStartTime:0,last:w,tail:f,tailMode:v}:(x.isBackwards=a,x.rendering=null,x.renderingStartTime=0,x.last=w,x.tail=f,x.tailMode=v)}function Hy(s,a,f){var w=a.pendingProps,v=w.revealOrder,x=w.tail;if(Br(s,a,w.children,f),w=Un.current,(w&2)!==0)w=w&1|2,a.flags|=128;else{if(s!==null&&(s.flags&128)!==0)e:for(s=a.child;s!==null;){if(s.tag===13)s.memoizedState!==null&&Uy(s,f,a);else if(s.tag===19)Uy(s,f,a);else if(s.child!==null){s.child.return=s,s=s.child;continue}if(s===a)break e;for(;s.sibling===null;){if(s.return===null||s.return===a)break e;s=s.return}s.sibling.return=s.return,s=s.sibling}w&=1}if(jn(Un,w),(a.mode&1)===0)a.memoizedState=null;else switch(v){case"forwards":for(f=a.child,v=null;f!==null;)s=f.alternate,s!==null&&Pu(s)===null&&(v=f),f=f.sibling;f=v,f===null?(v=a.child,a.child=null):(v=f.sibling,f.sibling=null),Jh(a,!1,v,f,x);break;case"backwards":for(f=null,v=a.child,a.child=null;v!==null;){if(s=v.alternate,s!==null&&Pu(s)===null){a.child=v;break}s=v.sibling,v.sibling=f,f=v,v=s}Jh(a,!0,f,null,x);break;case"together":Jh(a,!1,null,null,void 0);break;default:a.memoizedState=null}return a.child}function Wu(s,a){(a.mode&1)===0&&s!==null&&(s.alternate=null,a.alternate=null,a.flags|=2)}function Ss(s,a,f){if(s!==null&&(a.dependencies=s.dependencies),Mi|=a.lanes,(f&a.childLanes)===0)return null;if(s!==null&&a.child!==s.child)throw Error(n(153));if(a.child!==null){for(s=a.child,f=Qs(s,s.pendingProps),a.child=f,f.return=a;s.sibling!==null;)s=s.sibling,f=f.sibling=Qs(s,s.pendingProps),f.return=a;f.sibling=null}return a.child}function yj(s,a,f){switch(a.tag){case 3:zy(a),_a();break;case 5:ry(a);break;case 1:Vr(a.type)&&Nu(a);break;case 4:Rh(a,a.stateNode.containerInfo);break;case 10:var w=a.type._context,v=a.memoizedProps.value;jn(Ru,w._currentValue),w._currentValue=v;break;case 13:if(w=a.memoizedState,w!==null)return w.dehydrated!==null?(jn(Un,Un.current&1),a.flags|=128,null):(f&a.child.childLanes)!==0?By(s,a,f):(jn(Un,Un.current&1),s=Ss(s,a,f),s!==null?s.sibling:null);jn(Un,Un.current&1);break;case 19:if(w=(f&a.childLanes)!==0,(s.flags&128)!==0){if(w)return Hy(s,a,f);a.flags|=128}if(v=a.memoizedState,v!==null&&(v.rendering=null,v.tail=null,v.lastEffect=null),jn(Un,Un.current),w)break;return null;case 22:case 23:return a.lanes=0,Py(s,a,f)}return Ss(s,a,f)}var Wy,ep,Ky,Zy;Wy=function(s,a){for(var f=a.child;f!==null;){if(f.tag===5||f.tag===6)s.appendChild(f.stateNode);else if(f.tag!==4&&f.child!==null){f.child.return=f,f=f.child;continue}if(f===a)break;for(;f.sibling===null;){if(f.return===null||f.return===a)return;f=f.return}f.sibling.return=f.return,f=f.sibling}},ep=function(){},Ky=function(s,a,f,w){var v=s.memoizedProps;if(v!==w){s=a.stateNode,$i(ns.current);var x=null;switch(f){case"input":v=_e(s,v),w=_e(s,w),x=[];break;case"select":v=J({},v,{value:void 0}),w=J({},w,{value:void 0}),x=[];break;case"textarea":v=sn(s,v),w=sn(s,w),x=[];break;default:typeof v.onClick!="function"&&typeof w.onClick=="function"&&(s.onclick=Eu)}nt(f,w);var C;f=null;for(he in v)if(!w.hasOwnProperty(he)&&v.hasOwnProperty(he)&&v[he]!=null)if(he==="style"){var U=v[he];for(C in U)U.hasOwnProperty(C)&&(f||(f={}),f[C]="")}else he!=="dangerouslySetInnerHTML"&&he!=="children"&&he!=="suppressContentEditableWarning"&&he!=="suppressHydrationWarning"&&he!=="autoFocus"&&(o.hasOwnProperty(he)?x||(x=[]):(x=x||[]).push(he,null));for(he in w){var X=w[he];if(U=v!=null?v[he]:void 0,w.hasOwnProperty(he)&&X!==U&&(X!=null||U!=null))if(he==="style")if(U){for(C in U)!U.hasOwnProperty(C)||X&&X.hasOwnProperty(C)||(f||(f={}),f[C]="");for(C in X)X.hasOwnProperty(C)&&U[C]!==X[C]&&(f||(f={}),f[C]=X[C])}else f||(x||(x=[]),x.push(he,f)),f=X;else he==="dangerouslySetInnerHTML"?(X=X?X.__html:void 0,U=U?U.__html:void 0,X!=null&&U!==X&&(x=x||[]).push(he,X)):he==="children"?typeof X!="string"&&typeof X!="number"||(x=x||[]).push(he,""+X):he!=="suppressContentEditableWarning"&&he!=="suppressHydrationWarning"&&(o.hasOwnProperty(he)?(X!=null&&he==="onScroll"&&Rn("scroll",s),x||U===X||(x=[])):(x=x||[]).push(he,X))}f&&(x=x||[]).push("style",f);var he=x;(a.updateQueue=he)&&(a.flags|=4)}},Zy=function(s,a,f,w){f!==w&&(a.flags|=4)};function Ql(s,a){if(!Pn)switch(s.tailMode){case"hidden":a=s.tail;for(var f=null;a!==null;)a.alternate!==null&&(f=a),a=a.sibling;f===null?s.tail=null:f.sibling=null;break;case"collapsed":f=s.tail;for(var w=null;f!==null;)f.alternate!==null&&(w=f),f=f.sibling;w===null?a||s.tail===null?s.tail=null:s.tail.sibling=null:w.sibling=null}}function Ir(s){var a=s.alternate!==null&&s.alternate.child===s.child,f=0,w=0;if(a)for(var v=s.child;v!==null;)f|=v.lanes|v.childLanes,w|=v.subtreeFlags&14680064,w|=v.flags&14680064,v.return=s,v=v.sibling;else for(v=s.child;v!==null;)f|=v.lanes|v.childLanes,w|=v.subtreeFlags,w|=v.flags,v.return=s,v=v.sibling;return s.subtreeFlags|=w,s.childLanes=f,a}function vj(s,a,f){var w=a.pendingProps;switch(xh(a),a.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Ir(a),null;case 1:return Vr(a.type)&&_u(),Ir(a),null;case 3:return w=a.stateNode,Ca(),$n(Gr),$n(Cr),Mh(),w.pendingContext&&(w.context=w.pendingContext,w.pendingContext=null),(s===null||s.child===null)&&(Au(a)?a.flags|=4:s===null||s.memoizedState.isDehydrated&&(a.flags&256)===0||(a.flags|=1024,Mo!==null&&(dp(Mo),Mo=null))),ep(s,a),Ir(a),null;case 5:$h(a);var v=$i(ql.current);if(f=a.type,s!==null&&a.stateNode!=null)Ky(s,a,f,w,v),s.ref!==a.ref&&(a.flags|=512,a.flags|=2097152);else{if(!w){if(a.stateNode===null)throw Error(n(166));return Ir(a),null}if(s=$i(ns.current),Au(a)){w=a.stateNode,f=a.type;var x=a.memoizedProps;switch(w[ts]=a,w[Ul]=x,s=(a.mode&1)!==0,f){case"dialog":Rn("cancel",w),Rn("close",w);break;case"iframe":case"object":case"embed":Rn("load",w);break;case"video":case"audio":for(v=0;v<zl.length;v++)Rn(zl[v],w);break;case"source":Rn("error",w);break;case"img":case"image":case"link":Rn("error",w),Rn("load",w);break;case"details":Rn("toggle",w);break;case"input":je(w,x),Rn("invalid",w);break;case"select":w._wrapperState={wasMultiple:!!x.multiple},Rn("invalid",w);break;case"textarea":Ct(w,x),Rn("invalid",w)}nt(f,x),v=null;for(var C in x)if(x.hasOwnProperty(C)){var U=x[C];C==="children"?typeof U=="string"?w.textContent!==U&&(x.suppressHydrationWarning!==!0&&xu(w.textContent,U,s),v=["children",U]):typeof U=="number"&&w.textContent!==""+U&&(x.suppressHydrationWarning!==!0&&xu(w.textContent,U,s),v=["children",""+U]):o.hasOwnProperty(C)&&U!=null&&C==="onScroll"&&Rn("scroll",w)}switch(f){case"input":re(w),Ft(w,x,!0);break;case"textarea":re(w),Ze(w);break;case"select":case"option":break;default:typeof x.onClick=="function"&&(w.onclick=Eu)}w=v,a.updateQueue=w,w!==null&&(a.flags|=4)}else{C=v.nodeType===9?v:v.ownerDocument,s==="http://www.w3.org/1999/xhtml"&&(s=At(f)),s==="http://www.w3.org/1999/xhtml"?f==="script"?(s=C.createElement("div"),s.innerHTML="<script><\/script>",s=s.removeChild(s.firstChild)):typeof w.is=="string"?s=C.createElement(f,{is:w.is}):(s=C.createElement(f),f==="select"&&(C=s,w.multiple?C.multiple=!0:w.size&&(C.size=w.size))):s=C.createElementNS(s,f),s[ts]=a,s[Ul]=w,Wy(s,a,!1,!1),a.stateNode=s;e:{switch(C=dt(f,w),f){case"dialog":Rn("cancel",s),Rn("close",s),v=w;break;case"iframe":case"object":case"embed":Rn("load",s),v=w;break;case"video":case"audio":for(v=0;v<zl.length;v++)Rn(zl[v],s);v=w;break;case"source":Rn("error",s),v=w;break;case"img":case"image":case"link":Rn("error",s),Rn("load",s),v=w;break;case"details":Rn("toggle",s),v=w;break;case"input":je(s,w),v=_e(s,w),Rn("invalid",s);break;case"option":v=w;break;case"select":s._wrapperState={wasMultiple:!!w.multiple},v=J({},w,{value:void 0}),Rn("invalid",s);break;case"textarea":Ct(s,w),v=sn(s,w),Rn("invalid",s);break;default:v=w}nt(f,v),U=v;for(x in U)if(U.hasOwnProperty(x)){var X=U[x];x==="style"?Y(s,X):x==="dangerouslySetInnerHTML"?(X=X?X.__html:void 0,X!=null&&Fn(s,X)):x==="children"?typeof X=="string"?(f!=="textarea"||X!=="")&&un(s,X):typeof X=="number"&&un(s,""+X):x!=="suppressContentEditableWarning"&&x!=="suppressHydrationWarning"&&x!=="autoFocus"&&(o.hasOwnProperty(x)?X!=null&&x==="onScroll"&&Rn("scroll",s):X!=null&&N(s,x,X,C))}switch(f){case"input":re(s),Ft(s,w,!1);break;case"textarea":re(s),Ze(s);break;case"option":w.value!=null&&s.setAttribute("value",""+G(w.value));break;case"select":s.multiple=!!w.multiple,x=w.value,x!=null?Ht(s,!!w.multiple,x,!1):w.defaultValue!=null&&Ht(s,!!w.multiple,w.defaultValue,!0);break;default:typeof v.onClick=="function"&&(s.onclick=Eu)}switch(f){case"button":case"input":case"select":case"textarea":w=!!w.autoFocus;break e;case"img":w=!0;break e;default:w=!1}}w&&(a.flags|=4)}a.ref!==null&&(a.flags|=512,a.flags|=2097152)}return Ir(a),null;case 6:if(s&&a.stateNode!=null)Zy(s,a,s.memoizedProps,w);else{if(typeof w!="string"&&a.stateNode===null)throw Error(n(166));if(f=$i(ql.current),$i(ns.current),Au(a)){if(w=a.stateNode,f=a.memoizedProps,w[ts]=a,(x=w.nodeValue!==f)&&(s=uo,s!==null))switch(s.tag){case 3:xu(w.nodeValue,f,(s.mode&1)!==0);break;case 5:s.memoizedProps.suppressHydrationWarning!==!0&&xu(w.nodeValue,f,(s.mode&1)!==0)}x&&(a.flags|=4)}else w=(f.nodeType===9?f:f.ownerDocument).createTextNode(w),w[ts]=a,a.stateNode=w}return Ir(a),null;case 13:if($n(Un),w=a.memoizedState,s===null||s.memoizedState!==null&&s.memoizedState.dehydrated!==null){if(Pn&&fo!==null&&(a.mode&1)!==0&&(a.flags&128)===0)Vw(),_a(),a.flags|=98560,x=!1;else if(x=Au(a),w!==null&&w.dehydrated!==null){if(s===null){if(!x)throw Error(n(318));if(x=a.memoizedState,x=x!==null?x.dehydrated:null,!x)throw Error(n(317));x[ts]=a}else _a(),(a.flags&128)===0&&(a.memoizedState=null),a.flags|=4;Ir(a),x=!1}else Mo!==null&&(dp(Mo),Mo=null),x=!0;if(!x)return a.flags&65536?a:null}return(a.flags&128)!==0?(a.lanes=f,a):(w=w!==null,w!==(s!==null&&s.memoizedState!==null)&&w&&(a.child.flags|=8192,(a.mode&1)!==0&&(s===null||(Un.current&1)!==0?fr===0&&(fr=3):pp())),a.updateQueue!==null&&(a.flags|=4),Ir(a),null);case 4:return Ca(),ep(s,a),s===null&&Fl(a.stateNode.containerInfo),Ir(a),null;case 10:return jh(a.type._context),Ir(a),null;case 17:return Vr(a.type)&&_u(),Ir(a),null;case 19:if($n(Un),x=a.memoizedState,x===null)return Ir(a),null;if(w=(a.flags&128)!==0,C=x.rendering,C===null)if(w)Ql(x,!1);else{if(fr!==0||s!==null&&(s.flags&128)!==0)for(s=a.child;s!==null;){if(C=Pu(s),C!==null){for(a.flags|=128,Ql(x,!1),w=C.updateQueue,w!==null&&(a.updateQueue=w,a.flags|=4),a.subtreeFlags=0,w=f,f=a.child;f!==null;)x=f,s=w,x.flags&=14680066,C=x.alternate,C===null?(x.childLanes=0,x.lanes=s,x.child=null,x.subtreeFlags=0,x.memoizedProps=null,x.memoizedState=null,x.updateQueue=null,x.dependencies=null,x.stateNode=null):(x.childLanes=C.childLanes,x.lanes=C.lanes,x.child=C.child,x.subtreeFlags=0,x.deletions=null,x.memoizedProps=C.memoizedProps,x.memoizedState=C.memoizedState,x.updateQueue=C.updateQueue,x.type=C.type,s=C.dependencies,x.dependencies=s===null?null:{lanes:s.lanes,firstContext:s.firstContext}),f=f.sibling;return jn(Un,Un.current&1|2),a.child}s=s.sibling}x.tail!==null&&Gt()>$a&&(a.flags|=128,w=!0,Ql(x,!1),a.lanes=4194304)}else{if(!w)if(s=Pu(C),s!==null){if(a.flags|=128,w=!0,f=s.updateQueue,f!==null&&(a.updateQueue=f,a.flags|=4),Ql(x,!0),x.tail===null&&x.tailMode==="hidden"&&!C.alternate&&!Pn)return Ir(a),null}else 2*Gt()-x.renderingStartTime>$a&&f!==1073741824&&(a.flags|=128,w=!0,Ql(x,!1),a.lanes=4194304);x.isBackwards?(C.sibling=a.child,a.child=C):(f=x.last,f!==null?f.sibling=C:a.child=C,x.last=C)}return x.tail!==null?(a=x.tail,x.rendering=a,x.tail=a.sibling,x.renderingStartTime=Gt(),a.sibling=null,f=Un.current,jn(Un,w?f&1|2:f&1),a):(Ir(a),null);case 22:case 23:return hp(),w=a.memoizedState!==null,s!==null&&s.memoizedState!==null!==w&&(a.flags|=8192),w&&(a.mode&1)!==0?(ho&1073741824)!==0&&(Ir(a),a.subtreeFlags&6&&(a.flags|=8192)):Ir(a),null;case 24:return null;case 25:return null}throw Error(n(156,a.tag))}function bj(s,a){switch(xh(a),a.tag){case 1:return Vr(a.type)&&_u(),s=a.flags,s&65536?(a.flags=s&-65537|128,a):null;case 3:return Ca(),$n(Gr),$n(Cr),Mh(),s=a.flags,(s&65536)!==0&&(s&128)===0?(a.flags=s&-65537|128,a):null;case 5:return $h(a),null;case 13:if($n(Un),s=a.memoizedState,s!==null&&s.dehydrated!==null){if(a.alternate===null)throw Error(n(340));_a()}return s=a.flags,s&65536?(a.flags=s&-65537|128,a):null;case 19:return $n(Un),null;case 4:return Ca(),null;case 10:return jh(a.type._context),null;case 22:case 23:return hp(),null;case 24:return null;default:return null}}var Ku=!1,Rr=!1,xj=typeof WeakSet=="function"?WeakSet:Set,rt=null;function Ia(s,a){var f=s.ref;if(f!==null)if(typeof f=="function")try{f(null)}catch(w){Qn(s,a,w)}else f.current=null}function tp(s,a,f){try{f()}catch(w){Qn(s,a,w)}}var qy=!1;function Ej(s,a){if(hh=Ps,s=_w(),sh(s)){if("selectionStart"in s)var f={start:s.selectionStart,end:s.selectionEnd};else e:{f=(f=s.ownerDocument)&&f.defaultView||window;var w=f.getSelection&&f.getSelection();if(w&&w.rangeCount!==0){f=w.anchorNode;var v=w.anchorOffset,x=w.focusNode;w=w.focusOffset;try{f.nodeType,x.nodeType}catch{f=null;break e}var C=0,U=-1,X=-1,he=0,Re=0,Pe=s,Ie=null;t:for(;;){for(var et;Pe!==f||v!==0&&Pe.nodeType!==3||(U=C+v),Pe!==x||w!==0&&Pe.nodeType!==3||(X=C+w),Pe.nodeType===3&&(C+=Pe.nodeValue.length),(et=Pe.firstChild)!==null;)Ie=Pe,Pe=et;for(;;){if(Pe===s)break t;if(Ie===f&&++he===v&&(U=C),Ie===x&&++Re===w&&(X=C),(et=Pe.nextSibling)!==null)break;Pe=Ie,Ie=Pe.parentNode}Pe=et}f=U===-1||X===-1?null:{start:U,end:X}}else f=null}f=f||{start:0,end:0}}else f=null;for(ph={focusedElem:s,selectionRange:f},Ps=!1,rt=a;rt!==null;)if(a=rt,s=a.child,(a.subtreeFlags&1028)!==0&&s!==null)s.return=a,rt=s;else for(;rt!==null;){a=rt;try{var ot=a.alternate;if((a.flags&1024)!==0)switch(a.tag){case 0:case 11:case 15:break;case 1:if(ot!==null){var it=ot.memoizedProps,er=ot.memoizedState,ue=a.stateNode,te=ue.getSnapshotBeforeUpdate(a.elementType===a.type?it:Po(a.type,it),er);ue.__reactInternalSnapshotBeforeUpdate=te}break;case 3:var fe=a.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){Qn(a,a.return,Fe)}if(s=a.sibling,s!==null){s.return=a.return,rt=s;break}rt=a.return}return ot=qy,qy=!1,ot}function Jl(s,a,f){var w=a.updateQueue;if(w=w!==null?w.lastEffect:null,w!==null){var v=w=w.next;do{if((v.tag&s)===s){var x=v.destroy;v.destroy=void 0,x!==void 0&&tp(a,f,x)}v=v.next}while(v!==w)}}function Zu(s,a){if(a=a.updateQueue,a=a!==null?a.lastEffect:null,a!==null){var f=a=a.next;do{if((f.tag&s)===s){var w=f.create;f.destroy=w()}f=f.next}while(f!==a)}}function np(s){var a=s.ref;if(a!==null){var f=s.stateNode;switch(s.tag){case 5:s=f;break;default:s=f}typeof a=="function"?a(s):a.current=s}}function Gy(s){var a=s.alternate;a!==null&&(s.alternate=null,Gy(a)),s.child=null,s.deletions=null,s.sibling=null,s.tag===5&&(a=s.stateNode,a!==null&&(delete a[ts],delete a[Ul],delete a[wh],delete a[sj],delete a[ij])),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 Vy(s){return s.tag===5||s.tag===3||s.tag===4}function Yy(s){e:for(;;){for(;s.sibling===null;){if(s.return===null||Vy(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 rp(s,a,f){var w=s.tag;if(w===5||w===6)s=s.stateNode,a?f.nodeType===8?f.parentNode.insertBefore(s,a):f.insertBefore(s,a):(f.nodeType===8?(a=f.parentNode,a.insertBefore(s,f)):(a=f,a.appendChild(s)),f=f._reactRootContainer,f!=null||a.onclick!==null||(a.onclick=Eu));else if(w!==4&&(s=s.child,s!==null))for(rp(s,a,f),s=s.sibling;s!==null;)rp(s,a,f),s=s.sibling}function op(s,a,f){var w=s.tag;if(w===5||w===6)s=s.stateNode,a?f.insertBefore(s,a):f.appendChild(s);else if(w!==4&&(s=s.child,s!==null))for(op(s,a,f),s=s.sibling;s!==null;)op(s,a,f),s=s.sibling}var Sr=null,Lo=!1;function qs(s,a,f){for(f=f.child;f!==null;)Xy(s,a,f),f=f.sibling}function Xy(s,a,f){if(mt&&typeof mt.onCommitFiberUnmount=="function")try{mt.onCommitFiberUnmount(We,f)}catch{}switch(f.tag){case 5:Rr||Ia(f,a);case 6:var w=Sr,v=Lo;Sr=null,qs(s,a,f),Sr=w,Lo=v,Sr!==null&&(Lo?(s=Sr,f=f.stateNode,s.nodeType===8?s.parentNode.removeChild(f):s.removeChild(f)):Sr.removeChild(f.stateNode));break;case 18:Sr!==null&&(Lo?(s=Sr,f=f.stateNode,s.nodeType===8?kh(s.parentNode,f):s.nodeType===1&&kh(s,f),bi(s)):kh(Sr,f.stateNode));break;case 4:w=Sr,v=Lo,Sr=f.stateNode.containerInfo,Lo=!0,qs(s,a,f),Sr=w,Lo=v;break;case 0:case 11:case 14:case 15:if(!Rr&&(w=f.updateQueue,w!==null&&(w=w.lastEffect,w!==null))){v=w=w.next;do{var x=v,C=x.destroy;x=x.tag,C!==void 0&&((x&2)!==0||(x&4)!==0)&&tp(f,a,C),v=v.next}while(v!==w)}qs(s,a,f);break;case 1:if(!Rr&&(Ia(f,a),w=f.stateNode,typeof w.componentWillUnmount=="function"))try{w.props=f.memoizedProps,w.state=f.memoizedState,w.componentWillUnmount()}catch(U){Qn(f,a,U)}qs(s,a,f);break;case 21:qs(s,a,f);break;case 22:f.mode&1?(Rr=(w=Rr)||f.memoizedState!==null,qs(s,a,f),Rr=w):qs(s,a,f);break;default:qs(s,a,f)}}function Qy(s){var a=s.updateQueue;if(a!==null){s.updateQueue=null;var f=s.stateNode;f===null&&(f=s.stateNode=new xj),a.forEach(function(w){var v=Rj.bind(null,s,w);f.has(w)||(f.add(w),w.then(v,v))})}}function Do(s,a){var f=a.deletions;if(f!==null)for(var w=0;w<f.length;w++){var v=f[w];try{var x=s,C=a,U=C;e:for(;U!==null;){switch(U.tag){case 5:Sr=U.stateNode,Lo=!1;break e;case 3:Sr=U.stateNode.containerInfo,Lo=!0;break e;case 4:Sr=U.stateNode.containerInfo,Lo=!0;break e}U=U.return}if(Sr===null)throw Error(n(160));Xy(x,C,v),Sr=null,Lo=!1;var X=v.alternate;X!==null&&(X.return=null),v.return=null}catch(he){Qn(v,a,he)}}if(a.subtreeFlags&12854)for(a=a.child;a!==null;)Jy(a,s),a=a.sibling}function Jy(s,a){var f=s.alternate,w=s.flags;switch(s.tag){case 0:case 11:case 14:case 15:if(Do(a,s),os(s),w&4){try{Jl(3,s,s.return),Zu(3,s)}catch(it){Qn(s,s.return,it)}try{Jl(5,s,s.return)}catch(it){Qn(s,s.return,it)}}break;case 1:Do(a,s),os(s),w&512&&f!==null&&Ia(f,f.return);break;case 5:if(Do(a,s),os(s),w&512&&f!==null&&Ia(f,f.return),s.flags&32){var v=s.stateNode;try{un(v,"")}catch(it){Qn(s,s.return,it)}}if(w&4&&(v=s.stateNode,v!=null)){var x=s.memoizedProps,C=f!==null?f.memoizedProps:x,U=s.type,X=s.updateQueue;if(s.updateQueue=null,X!==null)try{U==="input"&&x.type==="radio"&&x.name!=null&&Ne(v,x),dt(U,C);var he=dt(U,x);for(C=0;C<X.length;C+=2){var Re=X[C],Pe=X[C+1];Re==="style"?Y(v,Pe):Re==="dangerouslySetInnerHTML"?Fn(v,Pe):Re==="children"?un(v,Pe):N(v,Re,Pe,he)}switch(U){case"input":qe(v,x);break;case"textarea":He(v,x);break;case"select":var Ie=v._wrapperState.wasMultiple;v._wrapperState.wasMultiple=!!x.multiple;var et=x.value;et!=null?Ht(v,!!x.multiple,et,!1):Ie!==!!x.multiple&&(x.defaultValue!=null?Ht(v,!!x.multiple,x.defaultValue,!0):Ht(v,!!x.multiple,x.multiple?[]:"",!1))}v[Ul]=x}catch(it){Qn(s,s.return,it)}}break;case 6:if(Do(a,s),os(s),w&4){if(s.stateNode===null)throw Error(n(162));v=s.stateNode,x=s.memoizedProps;try{v.nodeValue=x}catch(it){Qn(s,s.return,it)}}break;case 3:if(Do(a,s),os(s),w&4&&f!==null&&f.memoizedState.isDehydrated)try{bi(a.containerInfo)}catch(it){Qn(s,s.return,it)}break;case 4:Do(a,s),os(s);break;case 13:Do(a,s),os(s),v=s.child,v.flags&8192&&(x=v.memoizedState!==null,v.stateNode.isHidden=x,!x||v.alternate!==null&&v.alternate.memoizedState!==null||(ap=Gt())),w&4&&Qy(s);break;case 22:if(Re=f!==null&&f.memoizedState!==null,s.mode&1?(Rr=(he=Rr)||Re,Do(a,s),Rr=he):Do(a,s),os(s),w&8192){if(he=s.memoizedState!==null,(s.stateNode.isHidden=he)&&!Re&&(s.mode&1)!==0)for(rt=s,Re=s.child;Re!==null;){for(Pe=rt=Re;rt!==null;){switch(Ie=rt,et=Ie.child,Ie.tag){case 0:case 11:case 14:case 15:Jl(4,Ie,Ie.return);break;case 1:Ia(Ie,Ie.return);var ot=Ie.stateNode;if(typeof ot.componentWillUnmount=="function"){w=Ie,f=Ie.return;try{a=w,ot.props=a.memoizedProps,ot.state=a.memoizedState,ot.componentWillUnmount()}catch(it){Qn(w,f,it)}}break;case 5:Ia(Ie,Ie.return);break;case 22:if(Ie.memoizedState!==null){nv(Pe);continue}}et!==null?(et.return=Ie,rt=et):nv(Pe)}Re=Re.sibling}e:for(Re=null,Pe=s;;){if(Pe.tag===5){if(Re===null){Re=Pe;try{v=Pe.stateNode,he?(x=v.style,typeof x.setProperty=="function"?x.setProperty("display","none","important"):x.display="none"):(U=Pe.stateNode,X=Pe.memoizedProps.style,C=X!=null&&X.hasOwnProperty("display")?X.display:null,U.style.display=Tn("display",C))}catch(it){Qn(s,s.return,it)}}}else if(Pe.tag===6){if(Re===null)try{Pe.stateNode.nodeValue=he?"":Pe.memoizedProps}catch(it){Qn(s,s.return,it)}}else if((Pe.tag!==22&&Pe.tag!==23||Pe.memoizedState===null||Pe===s)&&Pe.child!==null){Pe.child.return=Pe,Pe=Pe.child;continue}if(Pe===s)break e;for(;Pe.sibling===null;){if(Pe.return===null||Pe.return===s)break e;Re===Pe&&(Re=null),Pe=Pe.return}Re===Pe&&(Re=null),Pe.sibling.return=Pe.return,Pe=Pe.sibling}}break;case 19:Do(a,s),os(s),w&4&&Qy(s);break;case 21:break;default:Do(a,s),os(s)}}function os(s){var a=s.flags;if(a&2){try{e:{for(var f=s.return;f!==null;){if(Vy(f)){var w=f;break e}f=f.return}throw Error(n(160))}switch(w.tag){case 5:var v=w.stateNode;w.flags&32&&(un(v,""),w.flags&=-33);var x=Yy(s);op(s,x,v);break;case 3:case 4:var C=w.stateNode.containerInfo,U=Yy(s);rp(s,U,C);break;default:throw Error(n(161))}}catch(X){Qn(s,s.return,X)}s.flags&=-3}a&4096&&(s.flags&=-4097)}function Sj(s,a,f){rt=s,ev(s)}function ev(s,a,f){for(var w=(s.mode&1)!==0;rt!==null;){var v=rt,x=v.child;if(v.tag===22&&w){var C=v.memoizedState!==null||Ku;if(!C){var U=v.alternate,X=U!==null&&U.memoizedState!==null||Rr;U=Ku;var he=Rr;if(Ku=C,(Rr=X)&&!he)for(rt=v;rt!==null;)C=rt,X=C.child,C.tag===22&&C.memoizedState!==null?rv(v):X!==null?(X.return=C,rt=X):rv(v);for(;x!==null;)rt=x,ev(x),x=x.sibling;rt=v,Ku=U,Rr=he}tv(s)}else(v.subtreeFlags&8772)!==0&&x!==null?(x.return=v,rt=x):tv(s)}}function tv(s){for(;rt!==null;){var a=rt;if((a.flags&8772)!==0){var f=a.alternate;try{if((a.flags&8772)!==0)switch(a.tag){case 0:case 11:case 15:Rr||Zu(5,a);break;case 1:var w=a.stateNode;if(a.flags&4&&!Rr)if(f===null)w.componentDidMount();else{var v=a.elementType===a.type?f.memoizedProps:Po(a.type,f.memoizedProps);w.componentDidUpdate(v,f.memoizedState,w.__reactInternalSnapshotBeforeUpdate)}var x=a.updateQueue;x!==null&&ny(a,x,w);break;case 3:var C=a.updateQueue;if(C!==null){if(f=null,a.child!==null)switch(a.child.tag){case 5:f=a.child.stateNode;break;case 1:f=a.child.stateNode}ny(a,C,f)}break;case 5:var U=a.stateNode;if(f===null&&a.flags&4){f=U;var X=a.memoizedProps;switch(a.type){case"button":case"input":case"select":case"textarea":X.autoFocus&&f.focus();break;case"img":X.src&&(f.src=X.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(a.memoizedState===null){var he=a.alternate;if(he!==null){var Re=he.memoizedState;if(Re!==null){var Pe=Re.dehydrated;Pe!==null&&bi(Pe)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(n(163))}Rr||a.flags&512&&np(a)}catch(Ie){Qn(a,a.return,Ie)}}if(a===s){rt=null;break}if(f=a.sibling,f!==null){f.return=a.return,rt=f;break}rt=a.return}}function nv(s){for(;rt!==null;){var a=rt;if(a===s){rt=null;break}var f=a.sibling;if(f!==null){f.return=a.return,rt=f;break}rt=a.return}}function rv(s){for(;rt!==null;){var a=rt;try{switch(a.tag){case 0:case 11:case 15:var f=a.return;try{Zu(4,a)}catch(X){Qn(a,f,X)}break;case 1:var w=a.stateNode;if(typeof w.componentDidMount=="function"){var v=a.return;try{w.componentDidMount()}catch(X){Qn(a,v,X)}}var x=a.return;try{np(a)}catch(X){Qn(a,x,X)}break;case 5:var C=a.return;try{np(a)}catch(X){Qn(a,C,X)}}}catch(X){Qn(a,a.return,X)}if(a===s){rt=null;break}var U=a.sibling;if(U!==null){U.return=a.return,rt=U;break}rt=a.return}}var _j=Math.ceil,qu=A.ReactCurrentDispatcher,sp=A.ReactCurrentOwner,xo=A.ReactCurrentBatchConfig,fn=0,kr=null,sr=null,_r=0,ho=0,Ra=Us(0),fr=0,ec=null,Mi=0,Gu=0,ip=0,tc=null,Xr=null,ap=0,$a=1/0,_s=null,Vu=!1,lp=null,Gs=null,Yu=!1,Vs=null,Xu=0,nc=0,cp=null,Qu=-1,Ju=0;function Ur(){return(fn&6)!==0?Gt():Qu!==-1?Qu:Qu=Gt()}function Ys(s){return(s.mode&1)===0?1:(fn&2)!==0&&_r!==0?_r&-_r:lj.transition!==null?(Ju===0&&(Ju=Ro()),Ju):(s=Qt,s!==0||(s=window.event,s=s===void 0?16:la(s.type)),s)}function zo(s,a,f,w){if(50<nc)throw nc=0,cp=null,Error(n(185));Zr(s,f,w),((fn&2)===0||s!==kr)&&(s===kr&&((fn&2)===0&&(Gu|=f),fr===4&&Xs(s,_r)),Qr(s,w),f===1&&fn===0&&(a.mode&1)===0&&($a=Gt()+500,Tu&&Ws()))}function Qr(s,a){var f=s.callbackNode;Dr(s,a);var w=Bn(s,s===kr?_r:0);if(w===0)f!==null&&tt(f),s.callbackNode=null,s.callbackPriority=0;else if(a=w&-w,s.callbackPriority!==a){if(f!=null&&tt(f),a===1)s.tag===0?aj(sv.bind(null,s)):Ww(sv.bind(null,s)),rj(function(){(fn&6)===0&&Ws()}),f=null;else{switch(wt(w)){case 1:f=Vn;break;case 4:f=Cn;break;case 16:f=rn;break;case 536870912:f=Ve;break;default:f=rn}f=hv(f,ov.bind(null,s))}s.callbackPriority=a,s.callbackNode=f}}function ov(s,a){if(Qu=-1,Ju=0,(fn&6)!==0)throw Error(n(327));var f=s.callbackNode;if(Oa()&&s.callbackNode!==f)return null;var w=Bn(s,s===kr?_r:0);if(w===0)return null;if((w&30)!==0||(w&s.expiredLanes)!==0||a)a=ed(s,w);else{a=w;var v=fn;fn|=2;var x=av();(kr!==s||_r!==a)&&(_s=null,$a=Gt()+500,Li(s,a));do try{jj();break}catch(U){iv(s,U)}while(!0);Th(),qu.current=x,fn=v,sr!==null?a=0:(kr=null,_r=0,a=fr)}if(a!==0){if(a===2&&(v=zr(s),v!==0&&(w=v,a=up(s,v))),a===1)throw f=ec,Li(s,0),Xs(s,w),Qr(s,Gt()),f;if(a===6)Xs(s,w);else{if(v=s.current.alternate,(w&30)===0&&!Nj(v)&&(a=ed(s,w),a===2&&(x=zr(s),x!==0&&(w=x,a=up(s,x))),a===1))throw f=ec,Li(s,0),Xs(s,w),Qr(s,Gt()),f;switch(s.finishedWork=v,s.finishedLanes=w,a){case 0:case 1:throw Error(n(345));case 2:Di(s,Xr,_s);break;case 3:if(Xs(s,w),(w&130023424)===w&&(a=ap+500-Gt(),10<a)){if(Bn(s,0)!==0)break;if(v=s.suspendedLanes,(v&w)!==w){Ur(),s.pingedLanes|=s.suspendedLanes&v;break}s.timeoutHandle=gh(Di.bind(null,s,Xr,_s),a);break}Di(s,Xr,_s);break;case 4:if(Xs(s,w),(w&4194240)===w)break;for(a=s.eventTimes,v=-1;0<w;){var C=31-yn(w);x=1<<C,C=a[C],C>v&&(v=C),w&=~x}if(w=v,w=Gt()-w,w=(120>w?120:480>w?480:1080>w?1080:1920>w?1920:3e3>w?3e3:4320>w?4320:1960*_j(w/1960))-w,10<w){s.timeoutHandle=gh(Di.bind(null,s,Xr,_s),w);break}Di(s,Xr,_s);break;case 5:Di(s,Xr,_s);break;default:throw Error(n(329))}}}return Qr(s,Gt()),s.callbackNode===f?ov.bind(null,s):null}function up(s,a){var f=tc;return s.current.memoizedState.isDehydrated&&(Li(s,a).flags|=256),s=ed(s,a),s!==2&&(a=Xr,Xr=f,a!==null&&dp(a)),s}function dp(s){Xr===null?Xr=s:Xr.push.apply(Xr,s)}function Nj(s){for(var a=s;;){if(a.flags&16384){var f=a.updateQueue;if(f!==null&&(f=f.stores,f!==null))for(var w=0;w<f.length;w++){var v=f[w],x=v.getSnapshot;v=v.value;try{if(!Oo(x(),v))return!1}catch{return!1}}}if(f=a.child,a.subtreeFlags&16384&&f!==null)f.return=a,a=f;else{if(a===s)break;for(;a.sibling===null;){if(a.return===null||a.return===s)return!0;a=a.return}a.sibling.return=a.return,a=a.sibling}}return!0}function Xs(s,a){for(a&=~ip,a&=~Gu,s.suspendedLanes|=a,s.pingedLanes&=~a,s=s.expirationTimes;0<a;){var f=31-yn(a),w=1<<f;s[f]=-1,a&=~w}}function sv(s){if((fn&6)!==0)throw Error(n(327));Oa();var a=Bn(s,0);if((a&1)===0)return Qr(s,Gt()),null;var f=ed(s,a);if(s.tag!==0&&f===2){var w=zr(s);w!==0&&(a=w,f=up(s,w))}if(f===1)throw f=ec,Li(s,0),Xs(s,a),Qr(s,Gt()),f;if(f===6)throw Error(n(345));return s.finishedWork=s.current.alternate,s.finishedLanes=a,Di(s,Xr,_s),Qr(s,Gt()),null}function fp(s,a){var f=fn;fn|=1;try{return s(a)}finally{fn=f,fn===0&&($a=Gt()+500,Tu&&Ws())}}function Pi(s){Vs!==null&&Vs.tag===0&&(fn&6)===0&&Oa();var a=fn;fn|=1;var f=xo.transition,w=Qt;try{if(xo.transition=null,Qt=1,s)return s()}finally{Qt=w,xo.transition=f,fn=a,(fn&6)===0&&Ws()}}function hp(){ho=Ra.current,$n(Ra)}function Li(s,a){s.finishedWork=null,s.finishedLanes=0;var f=s.timeoutHandle;if(f!==-1&&(s.timeoutHandle=-1,nj(f)),sr!==null)for(f=sr.return;f!==null;){var w=f;switch(xh(w),w.tag){case 1:w=w.type.childContextTypes,w!=null&&_u();break;case 3:Ca(),$n(Gr),$n(Cr),Mh();break;case 5:$h(w);break;case 4:Ca();break;case 13:$n(Un);break;case 19:$n(Un);break;case 10:jh(w.type._context);break;case 22:case 23:hp()}f=f.return}if(kr=s,sr=s=Qs(s.current,null),_r=ho=a,fr=0,ec=null,ip=Gu=Mi=0,Xr=tc=null,Ri!==null){for(a=0;a<Ri.length;a++)if(f=Ri[a],w=f.interleaved,w!==null){f.interleaved=null;var v=w.next,x=f.pending;if(x!==null){var C=x.next;x.next=v,w.next=C}f.pending=w}Ri=null}return s}function iv(s,a){do{var f=sr;try{if(Th(),Lu.current=Bu,Du){for(var w=Hn.memoizedState;w!==null;){var v=w.queue;v!==null&&(v.pending=null),w=w.next}Du=!1}if(Oi=0,gr=dr=Hn=null,Gl=!1,Vl=0,sp.current=null,f===null||f.return===null){fr=1,ec=a,sr=null;break}e:{var x=s,C=f.return,U=f,X=a;if(a=_r,U.flags|=32768,X!==null&&typeof X=="object"&&typeof X.then=="function"){var he=X,Re=U,Pe=Re.tag;if((Re.mode&1)===0&&(Pe===0||Pe===11||Pe===15)){var Ie=Re.alternate;Ie?(Re.updateQueue=Ie.updateQueue,Re.memoizedState=Ie.memoizedState,Re.lanes=Ie.lanes):(Re.updateQueue=null,Re.memoizedState=null)}var et=Iy(C);if(et!==null){et.flags&=-257,Ry(et,C,U,x,a),et.mode&1&&Ay(x,he,a),a=et,X=he;var ot=a.updateQueue;if(ot===null){var it=new Set;it.add(X),a.updateQueue=it}else ot.add(X);break e}else{if((a&1)===0){Ay(x,he,a),pp();break e}X=Error(n(426))}}else if(Pn&&U.mode&1){var er=Iy(C);if(er!==null){(er.flags&65536)===0&&(er.flags|=256),Ry(er,C,U,x,a),_h(Aa(X,U));break e}}x=X=Aa(X,U),fr!==4&&(fr=2),tc===null?tc=[x]:tc.push(x),x=C;do{switch(x.tag){case 3:x.flags|=65536,a&=-a,x.lanes|=a;var ue=jy(x,X,a);ty(x,ue);break e;case 1:U=X;var te=x.type,fe=x.stateNode;if((x.flags&128)===0&&(typeof te.getDerivedStateFromError=="function"||fe!==null&&typeof fe.componentDidCatch=="function"&&(Gs===null||!Gs.has(fe)))){x.flags|=65536,a&=-a,x.lanes|=a;var Fe=Cy(x,U,a);ty(x,Fe);break e}}x=x.return}while(x!==null)}cv(f)}catch(ct){a=ct,sr===f&&f!==null&&(sr=f=f.return);continue}break}while(!0)}function av(){var s=qu.current;return qu.current=Bu,s===null?Bu:s}function pp(){(fr===0||fr===3||fr===2)&&(fr=4),kr===null||(Mi&268435455)===0&&(Gu&268435455)===0||Xs(kr,_r)}function ed(s,a){var f=fn;fn|=2;var w=av();(kr!==s||_r!==a)&&(_s=null,Li(s,a));do try{Tj();break}catch(v){iv(s,v)}while(!0);if(Th(),fn=f,qu.current=w,sr!==null)throw Error(n(261));return kr=null,_r=0,fr}function Tj(){for(;sr!==null;)lv(sr)}function jj(){for(;sr!==null&&!at();)lv(sr)}function lv(s){var a=fv(s.alternate,s,ho);s.memoizedProps=s.pendingProps,a===null?cv(s):sr=a,sp.current=null}function cv(s){var a=s;do{var f=a.alternate;if(s=a.return,(a.flags&32768)===0){if(f=vj(f,a,ho),f!==null){sr=f;return}}else{if(f=bj(f,a),f!==null){f.flags&=32767,sr=f;return}if(s!==null)s.flags|=32768,s.subtreeFlags=0,s.deletions=null;else{fr=6,sr=null;return}}if(a=a.sibling,a!==null){sr=a;return}sr=a=s}while(a!==null);fr===0&&(fr=5)}function Di(s,a,f){var w=Qt,v=xo.transition;try{xo.transition=null,Qt=1,Cj(s,a,f,w)}finally{xo.transition=v,Qt=w}return null}function Cj(s,a,f,w){do Oa();while(Vs!==null);if((fn&6)!==0)throw Error(n(327));f=s.finishedWork;var v=s.finishedLanes;if(f===null)return null;if(s.finishedWork=null,s.finishedLanes=0,f===s.current)throw Error(n(177));s.callbackNode=null,s.callbackPriority=0;var x=f.lanes|f.childLanes;if(Er(s,x),s===kr&&(sr=kr=null,_r=0),(f.subtreeFlags&2064)===0&&(f.flags&2064)===0||Yu||(Yu=!0,hv(rn,function(){return Oa(),null})),x=(f.flags&15990)!==0,(f.subtreeFlags&15990)!==0||x){x=xo.transition,xo.transition=null;var C=Qt;Qt=1;var U=fn;fn|=4,sp.current=null,Ej(s,f),Jy(f,s),VT(ph),Ps=!!hh,ph=hh=null,s.current=f,Sj(f),dn(),fn=U,Qt=C,xo.transition=x}else s.current=f;if(Yu&&(Yu=!1,Vs=s,Xu=v),x=s.pendingLanes,x===0&&(Gs=null),ln(f.stateNode),Qr(s,Gt()),a!==null)for(w=s.onRecoverableError,f=0;f<a.length;f++)v=a[f],w(v.value,{componentStack:v.stack,digest:v.digest});if(Vu)throw Vu=!1,s=lp,lp=null,s;return(Xu&1)!==0&&s.tag!==0&&Oa(),x=s.pendingLanes,(x&1)!==0?s===cp?nc++:(nc=0,cp=s):nc=0,Ws(),null}function Oa(){if(Vs!==null){var s=wt(Xu),a=xo.transition,f=Qt;try{if(xo.transition=null,Qt=16>s?16:s,Vs===null)var w=!1;else{if(s=Vs,Vs=null,Xu=0,(fn&6)!==0)throw Error(n(331));var v=fn;for(fn|=4,rt=s.current;rt!==null;){var x=rt,C=x.child;if((rt.flags&16)!==0){var U=x.deletions;if(U!==null){for(var X=0;X<U.length;X++){var he=U[X];for(rt=he;rt!==null;){var Re=rt;switch(Re.tag){case 0:case 11:case 15:Jl(8,Re,x)}var Pe=Re.child;if(Pe!==null)Pe.return=Re,rt=Pe;else for(;rt!==null;){Re=rt;var Ie=Re.sibling,et=Re.return;if(Gy(Re),Re===he){rt=null;break}if(Ie!==null){Ie.return=et,rt=Ie;break}rt=et}}}var ot=x.alternate;if(ot!==null){var it=ot.child;if(it!==null){ot.child=null;do{var er=it.sibling;it.sibling=null,it=er}while(it!==null)}}rt=x}}if((x.subtreeFlags&2064)!==0&&C!==null)C.return=x,rt=C;else e:for(;rt!==null;){if(x=rt,(x.flags&2048)!==0)switch(x.tag){case 0:case 11:case 15:Jl(9,x,x.return)}var ue=x.sibling;if(ue!==null){ue.return=x.return,rt=ue;break e}rt=x.return}}var te=s.current;for(rt=te;rt!==null;){C=rt;var fe=C.child;if((C.subtreeFlags&2064)!==0&&fe!==null)fe.return=C,rt=fe;else e:for(C=te;rt!==null;){if(U=rt,(U.flags&2048)!==0)try{switch(U.tag){case 0:case 11:case 15:Zu(9,U)}}catch(ct){Qn(U,U.return,ct)}if(U===C){rt=null;break e}var Fe=U.sibling;if(Fe!==null){Fe.return=U.return,rt=Fe;break e}rt=U.return}}if(fn=v,Ws(),mt&&typeof mt.onPostCommitFiberRoot=="function")try{mt.onPostCommitFiberRoot(We,s)}catch{}w=!0}return w}finally{Qt=f,xo.transition=a}}return!1}function uv(s,a,f){a=Aa(f,a),a=jy(s,a,1),s=Zs(s,a,1),a=Ur(),s!==null&&(Zr(s,1,a),Qr(s,a))}function Qn(s,a,f){if(s.tag===3)uv(s,s,f);else for(;a!==null;){if(a.tag===3){uv(a,s,f);break}else if(a.tag===1){var w=a.stateNode;if(typeof a.type.getDerivedStateFromError=="function"||typeof w.componentDidCatch=="function"&&(Gs===null||!Gs.has(w))){s=Aa(f,s),s=Cy(a,s,1),a=Zs(a,s,1),s=Ur(),a!==null&&(Zr(a,1,s),Qr(a,s));break}}a=a.return}}function Aj(s,a,f){var w=s.pingCache;w!==null&&w.delete(a),a=Ur(),s.pingedLanes|=s.suspendedLanes&f,kr===s&&(_r&f)===f&&(fr===4||fr===3&&(_r&130023424)===_r&&500>Gt()-ap?Li(s,0):ip|=f),Qr(s,a)}function dv(s,a){a===0&&((s.mode&1)===0?a=1:(a=Nt,Nt<<=1,(Nt&130023424)===0&&(Nt=4194304)));var f=Ur();s=xs(s,a),s!==null&&(Zr(s,a,f),Qr(s,f))}function Ij(s){var a=s.memoizedState,f=0;a!==null&&(f=a.retryLane),dv(s,f)}function Rj(s,a){var f=0;switch(s.tag){case 13:var w=s.stateNode,v=s.memoizedState;v!==null&&(f=v.retryLane);break;case 19:w=s.stateNode;break;default:throw Error(n(314))}w!==null&&w.delete(a),dv(s,f)}var fv;fv=function(s,a,f){if(s!==null)if(s.memoizedProps!==a.pendingProps||Gr.current)Yr=!0;else{if((s.lanes&f)===0&&(a.flags&128)===0)return Yr=!1,yj(s,a,f);Yr=(s.flags&131072)!==0}else Yr=!1,Pn&&(a.flags&1048576)!==0&&Kw(a,Cu,a.index);switch(a.lanes=0,a.tag){case 2:var w=a.type;Wu(s,a),s=a.pendingProps;var v=xa(a,Cr.current);ja(a,f),v=Dh(null,a,w,s,v,f);var x=zh();return a.flags|=1,typeof v=="object"&&v!==null&&typeof v.render=="function"&&v.$$typeof===void 0?(a.tag=1,a.memoizedState=null,a.updateQueue=null,Vr(w)?(x=!0,Nu(a)):x=!1,a.memoizedState=v.state!==null&&v.state!==void 0?v.state:null,Ih(a),v.updater=Uu,a.stateNode=v,v._reactInternals=a,Kh(a,w,s,f),a=Vh(null,a,w,!0,x,f)):(a.tag=0,Pn&&x&&bh(a),Br(null,a,v,f),a=a.child),a;case 16:w=a.elementType;e:{switch(Wu(s,a),s=a.pendingProps,v=w._init,w=v(w._payload),a.type=w,v=a.tag=Oj(w),s=Po(w,s),v){case 0:a=Gh(null,a,w,s,f);break e;case 1:a=Dy(null,a,w,s,f);break e;case 11:a=$y(null,a,w,s,f);break e;case 14:a=Oy(null,a,w,Po(w.type,s),f);break e}throw Error(n(306,w,""))}return a;case 0:return w=a.type,v=a.pendingProps,v=a.elementType===w?v:Po(w,v),Gh(s,a,w,v,f);case 1:return w=a.type,v=a.pendingProps,v=a.elementType===w?v:Po(w,v),Dy(s,a,w,v,f);case 3:e:{if(zy(a),s===null)throw Error(n(387));w=a.pendingProps,x=a.memoizedState,v=x.element,ey(s,a),Mu(a,w,null,f);var C=a.memoizedState;if(w=C.element,x.isDehydrated)if(x={element:w,isDehydrated:!1,cache:C.cache,pendingSuspenseBoundaries:C.pendingSuspenseBoundaries,transitions:C.transitions},a.updateQueue.baseState=x,a.memoizedState=x,a.flags&256){v=Aa(Error(n(423)),a),a=Fy(s,a,w,f,v);break e}else if(w!==v){v=Aa(Error(n(424)),a),a=Fy(s,a,w,f,v);break e}else for(fo=Bs(a.stateNode.containerInfo.firstChild),uo=a,Pn=!0,Mo=null,f=Qw(a,null,w,f),a.child=f;f;)f.flags=f.flags&-3|4096,f=f.sibling;else{if(_a(),w===v){a=Ss(s,a,f);break e}Br(s,a,w,f)}a=a.child}return a;case 5:return ry(a),s===null&&Sh(a),w=a.type,v=a.pendingProps,x=s!==null?s.memoizedProps:null,C=v.children,mh(w,v)?C=null:x!==null&&mh(w,x)&&(a.flags|=32),Ly(s,a),Br(s,a,C,f),a.child;case 6:return s===null&&Sh(a),null;case 13:return By(s,a,f);case 4:return Rh(a,a.stateNode.containerInfo),w=a.pendingProps,s===null?a.child=Na(a,null,w,f):Br(s,a,w,f),a.child;case 11:return w=a.type,v=a.pendingProps,v=a.elementType===w?v:Po(w,v),$y(s,a,w,v,f);case 7:return Br(s,a,a.pendingProps,f),a.child;case 8:return Br(s,a,a.pendingProps.children,f),a.child;case 12:return Br(s,a,a.pendingProps.children,f),a.child;case 10:e:{if(w=a.type._context,v=a.pendingProps,x=a.memoizedProps,C=v.value,jn(Ru,w._currentValue),w._currentValue=C,x!==null)if(Oo(x.value,C)){if(x.children===v.children&&!Gr.current){a=Ss(s,a,f);break e}}else for(x=a.child,x!==null&&(x.return=a);x!==null;){var U=x.dependencies;if(U!==null){C=x.child;for(var X=U.firstContext;X!==null;){if(X.context===w){if(x.tag===1){X=Es(-1,f&-f),X.tag=2;var he=x.updateQueue;if(he!==null){he=he.shared;var Re=he.pending;Re===null?X.next=X:(X.next=Re.next,Re.next=X),he.pending=X}}x.lanes|=f,X=x.alternate,X!==null&&(X.lanes|=f),Ch(x.return,f,a),U.lanes|=f;break}X=X.next}}else if(x.tag===10)C=x.type===a.type?null:x.child;else if(x.tag===18){if(C=x.return,C===null)throw Error(n(341));C.lanes|=f,U=C.alternate,U!==null&&(U.lanes|=f),Ch(C,f,a),C=x.sibling}else C=x.child;if(C!==null)C.return=x;else for(C=x;C!==null;){if(C===a){C=null;break}if(x=C.sibling,x!==null){x.return=C.return,C=x;break}C=C.return}x=C}Br(s,a,v.children,f),a=a.child}return a;case 9:return v=a.type,w=a.pendingProps.children,ja(a,f),v=vo(v),w=w(v),a.flags|=1,Br(s,a,w,f),a.child;case 14:return w=a.type,v=Po(w,a.pendingProps),v=Po(w.type,v),Oy(s,a,w,v,f);case 15:return My(s,a,a.type,a.pendingProps,f);case 17:return w=a.type,v=a.pendingProps,v=a.elementType===w?v:Po(w,v),Wu(s,a),a.tag=1,Vr(w)?(s=!0,Nu(a)):s=!1,ja(a,f),Ny(a,w,v),Kh(a,w,v,f),Vh(null,a,w,!0,s,f);case 19:return Hy(s,a,f);case 22:return Py(s,a,f)}throw Error(n(156,a.tag))};function hv(s,a){return ke(s,a)}function $j(s,a,f,w){this.tag=s,this.key=f,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=a,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=w,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Eo(s,a,f,w){return new $j(s,a,f,w)}function mp(s){return s=s.prototype,!(!s||!s.isReactComponent)}function Oj(s){if(typeof s=="function")return mp(s)?1:0;if(s!=null){if(s=s.$$typeof,s===V)return 11;if(s===ne)return 14}return 2}function Qs(s,a){var f=s.alternate;return f===null?(f=Eo(s.tag,a,s.key,s.mode),f.elementType=s.elementType,f.type=s.type,f.stateNode=s.stateNode,f.alternate=s,s.alternate=f):(f.pendingProps=a,f.type=s.type,f.flags=0,f.subtreeFlags=0,f.deletions=null),f.flags=s.flags&14680064,f.childLanes=s.childLanes,f.lanes=s.lanes,f.child=s.child,f.memoizedProps=s.memoizedProps,f.memoizedState=s.memoizedState,f.updateQueue=s.updateQueue,a=s.dependencies,f.dependencies=a===null?null:{lanes:a.lanes,firstContext:a.firstContext},f.sibling=s.sibling,f.index=s.index,f.ref=s.ref,f}function td(s,a,f,w,v,x){var C=2;if(w=s,typeof s=="function")mp(s)&&(C=1);else if(typeof s=="string")C=5;else e:switch(s){case R:return zi(f.children,v,x,a);case T:C=8,v|=8;break;case $:return s=Eo(12,f,a,v|2),s.elementType=$,s.lanes=x,s;case se:return s=Eo(13,f,a,v),s.elementType=se,s.lanes=x,s;case I:return s=Eo(19,f,a,v),s.elementType=I,s.lanes=x,s;case K:return nd(f,v,x,a);default:if(typeof s=="object"&&s!==null)switch(s.$$typeof){case D:C=10;break e;case z:C=9;break e;case V:C=11;break e;case ne:C=14;break e;case we:C=16,w=null;break e}throw Error(n(130,s==null?s:typeof s,""))}return a=Eo(C,f,a,v),a.elementType=s,a.type=w,a.lanes=x,a}function zi(s,a,f,w){return s=Eo(7,s,w,a),s.lanes=f,s}function nd(s,a,f,w){return s=Eo(22,s,w,a),s.elementType=K,s.lanes=f,s.stateNode={isHidden:!1},s}function gp(s,a,f){return s=Eo(6,s,null,a),s.lanes=f,s}function kp(s,a,f){return a=Eo(4,s.children!==null?s.children:[],s.key,a),a.lanes=f,a.stateNode={containerInfo:s.containerInfo,pendingChildren:null,implementation:s.implementation},a}function Mj(s,a,f,w,v){this.tag=a,this.containerInfo=s,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=xr(0),this.expirationTimes=xr(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=xr(0),this.identifierPrefix=w,this.onRecoverableError=v,this.mutableSourceEagerHydrationData=null}function wp(s,a,f,w,v,x,C,U,X){return s=new Mj(s,a,f,U,X),a===1?(a=1,x===!0&&(a|=8)):a=0,x=Eo(3,null,null,a),s.current=x,x.stateNode=s,x.memoizedState={element:w,isDehydrated:f,cache:null,transitions:null,pendingSuspenseBoundaries:null},Ih(x),s}function Pj(s,a,f){var w=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:P,key:w==null?null:""+w,children:s,containerInfo:a,implementation:f}}function pv(s){if(!s)return Hs;s=s._reactInternals;e:{if(mr(s)!==s||s.tag!==1)throw Error(n(170));var a=s;do{switch(a.tag){case 3:a=a.stateNode.context;break e;case 1:if(Vr(a.type)){a=a.stateNode.__reactInternalMemoizedMergedChildContext;break e}}a=a.return}while(a!==null);throw Error(n(171))}if(s.tag===1){var f=s.type;if(Vr(f))return Uw(s,f,a)}return a}function mv(s,a,f,w,v,x,C,U,X){return s=wp(f,w,!0,s,v,x,C,U,X),s.context=pv(null),f=s.current,w=Ur(),v=Ys(f),x=Es(w,v),x.callback=a??null,Zs(f,x,v),s.current.lanes=v,Zr(s,v,w),Qr(s,w),s}function rd(s,a,f,w){var v=a.current,x=Ur(),C=Ys(v);return f=pv(f),a.context===null?a.context=f:a.pendingContext=f,a=Es(x,C),a.payload={element:s},w=w===void 0?null:w,w!==null&&(a.callback=w),s=Zs(v,a,C),s!==null&&(zo(s,v,C,x),Ou(s,v,C)),C}function od(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 gv(s,a){if(s=s.memoizedState,s!==null&&s.dehydrated!==null){var f=s.retryLane;s.retryLane=f!==0&&f<a?f:a}}function yp(s,a){gv(s,a),(s=s.alternate)&&gv(s,a)}function Lj(){return null}var kv=typeof reportError=="function"?reportError:function(s){console.error(s)};function vp(s){this._internalRoot=s}sd.prototype.render=vp.prototype.render=function(s){var a=this._internalRoot;if(a===null)throw Error(n(409));rd(s,a,null,null)},sd.prototype.unmount=vp.prototype.unmount=function(){var s=this._internalRoot;if(s!==null){this._internalRoot=null;var a=s.containerInfo;Pi(function(){rd(null,s,null,null)}),a[ws]=null}};function sd(s){this._internalRoot=s}sd.prototype.unstable_scheduleHydration=function(s){if(s){var a=Dt();s={blockedOn:null,target:s,priority:a};for(var f=0;f<yt.length&&a!==0&&a<yt[f].priority;f++);yt.splice(f,0,s),f===0&&Jn(s)}};function bp(s){return!(!s||s.nodeType!==1&&s.nodeType!==9&&s.nodeType!==11)}function id(s){return!(!s||s.nodeType!==1&&s.nodeType!==9&&s.nodeType!==11&&(s.nodeType!==8||s.nodeValue!==" react-mount-point-unstable "))}function wv(){}function Dj(s,a,f,w,v){if(v){if(typeof w=="function"){var x=w;w=function(){var he=od(C);x.call(he)}}var C=mv(a,w,s,0,null,!1,!1,"",wv);return s._reactRootContainer=C,s[ws]=C.current,Fl(s.nodeType===8?s.parentNode:s),Pi(),C}for(;v=s.lastChild;)s.removeChild(v);if(typeof w=="function"){var U=w;w=function(){var he=od(X);U.call(he)}}var X=wp(s,0,!1,null,null,!1,!1,"",wv);return s._reactRootContainer=X,s[ws]=X.current,Fl(s.nodeType===8?s.parentNode:s),Pi(function(){rd(a,X,f,w)}),X}function ad(s,a,f,w,v){var x=f._reactRootContainer;if(x){var C=x;if(typeof v=="function"){var U=v;v=function(){var X=od(C);U.call(X)}}rd(a,C,s,v)}else C=Dj(f,a,s,v,w);return od(C)}$o=function(s){switch(s.tag){case 3:var a=s.stateNode;if(a.current.memoizedState.isDehydrated){var f=Xt(a.pendingLanes);f!==0&&(qr(a,f|1),Qr(a,Gt()),(fn&6)===0&&($a=Gt()+500,Ws()))}break;case 13:Pi(function(){var w=xs(s,1);if(w!==null){var v=Ur();zo(w,s,1,v)}}),yp(s,1)}},An=function(s){if(s.tag===13){var a=xs(s,134217728);if(a!==null){var f=Ur();zo(a,s,134217728,f)}yp(s,134217728)}},on=function(s){if(s.tag===13){var a=Ys(s),f=xs(s,a);if(f!==null){var w=Ur();zo(f,s,a,w)}yp(s,a)}},Dt=function(){return Qt},nr=function(s,a){var f=Qt;try{return Qt=s,a()}finally{Qt=f}},Ee=function(s,a,f){switch(a){case"input":if(qe(s,f),a=f.name,f.type==="radio"&&a!=null){for(f=s;f.parentNode;)f=f.parentNode;for(f=f.querySelectorAll("input[name="+JSON.stringify(""+a)+'][type="radio"]'),a=0;a<f.length;a++){var w=f[a];if(w!==s&&w.form===s.form){var v=Su(w);if(!v)throw Error(n(90));Le(w),qe(w,v)}}}break;case"textarea":He(s,f);break;case"select":a=f.value,a!=null&&Ht(s,!!f.multiple,a,!1)}},Oe=fp,st=Pi;var zj={usingClientEntryPoint:!1,Events:[Hl,va,Su,Z,ge,fp]},rc={findFiberByHostInstance:ji,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},Fj={bundleType:rc.bundleType,version:rc.version,rendererPackageName:rc.rendererPackageName,rendererConfig:rc.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:A.ReactCurrentDispatcher,findHostInstanceByFiber:function(s){return s=nn(s),s===null?null:s.stateNode},findFiberByHostInstance:rc.findFiberByHostInstance||Lj,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 ld=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!ld.isDisabled&&ld.supportsFiber)try{We=ld.inject(Fj),mt=ld}catch{}}return Jr.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=zj,Jr.createPortal=function(s,a){var f=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!bp(a))throw Error(n(200));return Pj(s,a,null,f)},Jr.createRoot=function(s,a){if(!bp(s))throw Error(n(299));var f=!1,w="",v=kv;return a!=null&&(a.unstable_strictMode===!0&&(f=!0),a.identifierPrefix!==void 0&&(w=a.identifierPrefix),a.onRecoverableError!==void 0&&(v=a.onRecoverableError)),a=wp(s,1,!1,null,null,f,!1,w,v),s[ws]=a.current,Fl(s.nodeType===8?s.parentNode:s),new vp(a)},Jr.findDOMNode=function(s){if(s==null)return null;if(s.nodeType===1)return s;var a=s._reactInternals;if(a===void 0)throw typeof s.render=="function"?Error(n(188)):(s=Object.keys(s).join(","),Error(n(268,s)));return s=nn(a),s=s===null?null:s.stateNode,s},Jr.flushSync=function(s){return Pi(s)},Jr.hydrate=function(s,a,f){if(!id(a))throw Error(n(200));return ad(null,s,a,!0,f)},Jr.hydrateRoot=function(s,a,f){if(!bp(s))throw Error(n(405));var w=f!=null&&f.hydratedSources||null,v=!1,x="",C=kv;if(f!=null&&(f.unstable_strictMode===!0&&(v=!0),f.identifierPrefix!==void 0&&(x=f.identifierPrefix),f.onRecoverableError!==void 0&&(C=f.onRecoverableError)),a=mv(a,null,s,1,f??null,v,!1,x,C),s[ws]=a.current,Fl(s),w)for(s=0;s<w.length;s++)f=w[s],v=f._getVersion,v=v(f._source),a.mutableSourceEagerHydrationData==null?a.mutableSourceEagerHydrationData=[f,v]:a.mutableSourceEagerHydrationData.push(f,v);return new sd(a)},Jr.render=function(s,a,f){if(!id(a))throw Error(n(200));return ad(null,s,a,!1,f)},Jr.unmountComponentAtNode=function(s){if(!id(s))throw Error(n(40));return s._reactRootContainer?(Pi(function(){ad(null,null,s,!1,function(){s._reactRootContainer=null,s[ws]=null})}),!0):!1},Jr.unstable_batchedUpdates=fp,Jr.unstable_renderSubtreeIntoContainer=function(s,a,f,w){if(!id(f))throw Error(n(200));if(s==null||s._reactInternals===void 0)throw Error(n(38));return ad(s,a,f,!1,w)},Jr.version="18.3.1-next-f1338f8080-20240426",Jr}var Nv;function Jx(){if(Nv)return Sp.exports;Nv=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(),Sp.exports=Yj(),Sp.exports}var Xj=Jx(),cd={},Tv;function Qj(){if(Tv)return cd;Tv=1;var e=Jx();return cd.createRoot=e.createRoot,cd.hydrateRoot=e.hydrateRoot,cd}var Jj=Qj();const ui="shell",e1="check",pm="ToolSearch",Eg="AskUserQuestion",t1="preview",eC=new Set(["edit","delete","move","execute"]),tC=new Set(["Edit","Write","MultiEdit","NotebookEdit","Bash"]);function Sg(e){return e.kind?eC.has(e.kind):tC.has(e.name)}const nC=["read","edit","delete","move","search","execute","fetch"];function _g(e){return nC.includes(e??"")}function n1(e,t){return(_g(e.kind)||e.name===Eg||e.name===pm)&&bf(t)}function bf(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 Zc=[{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"}],Hd="auto";function rC(e){return e.branch.startsWith("toyon/")}const _o="shell",Cs="login";function oC(e,t){return`${e}/${t}`}function sC(e,t,n,r=0){var i;let o=e;for(let l=r;l>0;l--){let c=o.length-1;for(;c>=0&&((i=o[c])==null?void 0:i.proc)!==t;)c--;if(c<0)break;o=o===e?[...o]:o,o.splice(c,1)}return n?[...o,{proc:t,line:n}]:o}const iC=["use","always","off"];function r1(e){return e.find(t=>t.id==="default")}function aC(e){const t=r1(e);if(t!=null&&t.description)return e.find(n=>n!==t&&n.name===t.description)}function vn(e){return e.worktree!==void 0}function na(e){return e.kind==="main"}function qc(e){return e.kind==="spare"}function yr(e){return qc(e)||na(e)}function Ng(e){return e.kind==="worktree"}function o1(e){return e.kind==="worktree"&&rC(e)}function qi(e){var t;return e.kind==="worktree"&&((t=e.from)==null?void 0:t.kind)!=="pr"}function Id(e){return e.kind==="worktree"}function xf(e){return!!e.branch&&!e.locked&&!(e.worktree&&yr(e.worktree))}const Ja=e=>{var t;return e.promptedAt??((t=e.lastTurn)==null?void 0:t.at)??e.createdAt},lC=e=>yr(e)?0:1,cC=e=>e.variant?`group:${e.variant.group}`:`row:${e.id}`;function uC(e){const t=[],n=new Map;for(const r of e){const o=r.worktree,i=cC(o),l=n.get(i);if(l){l.rows.push(r),l.at=Math.max(l.at,Ja(o));continue}const c={tier:lC(o),at:Ja(o),rows:[r]};t.push(c),n.set(i,c)}return t.sort((r,o)=>r.tier-o.tier||o.at-r.at),t.flatMap(r=>r.rows.length>1?r.rows.sort((o,i)=>{var l,c;return(((l=o.worktree.variant)==null?void 0:l.index)??0)-(((c=i.worktree.variant)==null?void 0:c.index)??0)}):r.rows)}function jv(e,t){const n=new Map;for(const r of e)n.set(r.id,r.promptedAt??0);for(const r of t){if(!vn(r)||r.worktree.kind==="spare")continue;const o=r.worktree.repoId;n.set(o,Math.max(n.get(o)??0,Ja(r.worktree)))}return[...e].sort((r,o)=>(n.get(o.id)??0)-(n.get(r.id)??0))}const Cv="not opened in ";function dC(e){const t=e.lastIndexOf(Cv);return t<0?{what:e}:{what:e.slice(0,t).replace(/,\s*$/,""),idle:e.slice(t+Cv.length)}}const s1={image:6,paste:4,file:8,pick:8},fC={image:"image",paste:"paste",file:"file",pick:"element"},hC={image:"Image",paste:"Pasted text"},i1=(e,t)=>`${hC[e]} ${t}`,Tg=e=>`at most ${s1[e]} ${fC[e]}s per message`,pC=(e,t)=>e.filter(n=>n.kind===t).length,mC=(e,t)=>Math.max(0,s1[t]-pC(e,t));function mm(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 jg(e,t){const n={...t};return e.map(r=>[r,n[r.kind]++])}function yc(e,t){const n={...e};for(const r of t)n[r.kind]++;return n}function Cg(e){return e>=1024*1024?`${(e/1024/1024).toFixed(1)} MB`:`${Math.max(1,Math.round(e/1024))} KB`}const Za=e=>`card:${e}`,Rd=[{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"}],gC=new Set(["zen","close","back","forward"]);function a1(e,{guest:t=!1}={}){var r,o;if(e.altKey){if(e.metaKey||e.ctrlKey)return null;const i=Rd.find(l=>l.alt&&!!l.shift===e.shiftKey&&(l.key===e.key||l.key.length===1&&e.code===`Key${l.key.toUpperCase()}`));return i&&i.id!=="worktree"?{id:i.id}:null}if(!e.metaKey&&!e.ctrlKey){if(e.shiftKey||t)return null;const i=Rd.find(l=>l.bareAlias===e.key);return i&&i.id!=="worktree"?{id:i.id}:null}if(!!e.ctrlKey===e.metaKey)return null;const n=e.key.length===1?e.key.toLowerCase():e.key;if(e.metaKey&&!e.shiftKey&&n>="1"&&n<="9")return{id:"worktree",digit:Number(n)};for(const i of Rd){if(i.id==="worktree")continue;const l=i.ctrlAlias;if(l&&e.ctrlKey&&l.key===n&&!!l.shift===e.shiftKey&&!(t&&l.hostOnly))return{id:i.id};if(e.metaKey&&e.shiftKey&&((r=i.cmdShiftAlias)!=null&&r.includes(n)))return{id:i.id};if(!i.alt&&!(e.ctrlKey&&!i.ctrl||!!i.shift!==e.shiftKey)&&(i.key===n||(o=i.aliases)!=null&&o.includes(n)))return{id:i.id}}return null}function kC(e){return e.altKey||e.key.toLowerCase()!=="s"?!1:!!e.ctrlKey!==e.metaKey}function l1(e){const t=Rd.find(n=>n.id===e);if(!t)throw new Error(`unknown chord ${e}`);return t}function wC(e,t){return e===t-1?"⌘9":e<8?`⌘${e+1}`:void 0}function yC(e,t){return t===0?null:e===9?t-1:e-1<t?e-1:null}function vC(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 bC(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 xC(e,t){const n=l1(e);return!!n.textKeeps&&vC(t)&&!(n.emptyGives&&bC(t))}const EC=["Find","Preview","Panels","Worktrees"],vc={"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"}},SC={ArrowUp:"↑",ArrowDown:"↓",ArrowLeft:"←",ArrowRight:"→",Backspace:"⌫",Tab:"Tab"};function _C(e,t={}){var c;const n=l1(e),r=vc[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":SC[o]??o.toUpperCase(),l=o!==n.key&&o===((c=n.ctrlAlias)==null?void 0:c.key)?n.ctrlAlias:void 0;return l?`⌃${l.shift?"⇧":""}${i}`:`${n.alt?"⌥":n.ctrl?"⌃":"⌘"}${n.shift?"⇧":""}${i}`}function NC(e){return Object.keys(vc).filter(t=>vc[t].section===e&&!vc[t].hidden)}const Av={m:6e4,h:60*6e4};function TC(e){const[t,n]=jC(e);return`${t}${n.charAt(0)}`}function jC(e){const t=e/Av.h;if(t>=1&&Number.isInteger(t))return[t,"hour"];const n=e/Av.m;return n>=1&&Number.isInteger(n)?[n,"minute"]:n>=60?[Math.round(n),"minute"]:[Math.max(1,Math.round(e/1e3)),"second"]}const Cc={folder:{shared:".toyon/settings.json",local:".toyon/settings.local.json"},root:{shared:"toyon.json",local:"toyon.local.json"}};function c1(e){return typeof e=="string"?e:e.cmd}function CC(e){return typeof e!="string"&&e.from==="trunk"}function AC(e){return[...e.setup??[],...e.teardown??[],...Object.values(e.run).map(c1),...Object.values(e.profiles??{}).flatMap(n=>Object.values(n.env??{}))].some(n=>n.includes("TOYON_WORKTREE"))}function IC(e){return e===Cc.folder.local||e===Cc.root.local}function RC(e){return IC(e)?"local":"shared"}function $C(e,t){return(Object.values(Cc).find(r=>r.shared===e||r.local===e)??Cc.folder)[t]}const OC=e=>`https://${e}/`;function MC(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 LC(n.origin)?n.origin:null}function PC(e){return e.toLowerCase().endsWith(".fly.dev")}function LC(e){let t;try{t=new URL(e)}catch{return!1}return t.origin!==e?!1:t.protocol==="https:"||t.protocol==="http:"&&Ag(t.hostname)}const DC="toyon_grant";function Ag(e){return e==="127.0.0.1"||e==="::1"||e==="[::1]"||e==="localhost"||e.endsWith(".localhost")}function zC(e,t,n){return e.replace("{id}",t).replace("{port}",String(n))}const FC=4401,BC=25e4;function UC(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(...HC(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 HC(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)>BC)return[...e.map(c=>({mark:"-",value:c})),...t.map(c=>({mark:"+",value:c}))];const n=t.length+1,r=new Uint32Array((e.length+1)*n);for(let c=e.length-1;c>=0;c--)for(let u=t.length-1;u>=0;u--)r[c*n+u]=e[c]===t[u]?(r[(c+1)*n+u+1]??0)+1:Math.max(r[(c+1)*n+u]??0,r[c*n+u+1]??0);const o=[];let i=0,l=0;for(;i<e.length&&l<t.length;)e[i]===t[l]?(o.push({mark:" ",value:e[i]}),i++,l++):(r[(i+1)*n+l]??0)>=(r[i*n+l+1]??0)?(o.push({mark:"-",value:e[i]}),i++):(o.push({mark:"+",value:t[l]}),l++);for(;i<e.length;)o.push({mark:"-",value:e[i++]});for(;l<t.length;)o.push({mark:"+",value:t[l++]});return o}const WC=/[\p{L}\p{N}_$]+|\s+|[^\s\p{L}\p{N}_$]/gu;function Iv(e){return e.match(WC)??[]}const KC=.4;function ZC(e,t){if(e===t)return null;const n=UC(Iv(e),Iv(t));let r=0;for(const o of n)o.mark===" "&&(r+=o.value.length);return r<KC*Math.max(e.length,t.length)?null:{before:Rv(n,"-"),after:Rv(n,"+")}}function Rv(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 u1(n)}function $v(e){const t=[[]];for(const n of e){const r=n.text.split(`
|
|
42
|
+
`);for(const[o,i]of r.entries())o>0&&t.push([]),i&&t[t.length-1].push({text:i,changed:n.changed})}return t.map(u1)}function u1(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 qC=[{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"}],GC=[{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"}],VC=[{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)"}],gm="merge",km="merge";function ai(e){var n,r,o;const t=((n=e.land)==null?void 0:n.route)??gm;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 Ef(e){return e.base??e.defaultBranch}function YC(e){return e.base!==void 0&&e.base!==e.defaultBranch}function XC(e){return{land:"a land",commit:"a commit","sync-main":"a sync","pull-main":"a pull"}[e]}function Ig(e,t){return e.land==="pr"&&(!t.pr||t.pr.state==="closed")?"open PR":"land"}function Wd(e,t="main"){const n={merge:"merge into",squash:"squash onto",rebase:"rebase onto"}[e.merge??km];switch(e.land){case"merge":return`Commit and ${n} ${t} here`;case"push":return`Commit, ${n} ${t} on origin and push it`;case"pr":return e.automerge?"Commit, push the branch and open a PR that GitHub merges when its rules allow":"Commit, push the branch and open a PR"}}function d1(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 Ov(e,t="|"){return e.map(n=>p1(n)).join(t)}function wm(e,t){return typeof t=="bigint"?t.toString():t}function Sf(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function QC(e){return e==null}function Rg(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function JC(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 io(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function gi(...e){const t={};for(const n of e){const r=Object.getOwnPropertyDescriptors(n);Object.assign(t,r)}return Object.defineProperties({},t)}function eA(e){return JSON.stringify(e)}function tA(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const f1="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Ac(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const nA=Sf(()=>{var e;if(Go.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 Ic(e){if(Ac(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!(Ac(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function h1(e){return Ic(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}const rA=new Set(["string","number","symbol"]);function el(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ki(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 ht(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 p1(e){return typeof e=="bigint"?e.toString()+"n":typeof e=="string"?`"${e}"`:`${e}`}function oA(e){return Object.keys(e).filter(t=>e[t]._zod.optin!==void 0&&e[t]._zod.optout==="optional")}const sA={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 iA(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=gi(e._zod.def,{get shape(){const l={};for(const c of Reflect.ownKeys(t)){if(!Object.prototype.hasOwnProperty.call(n.shape,c))throw new Error(`Unrecognized key: "${String(c)}"`);t[c]&&io(l,c,n.shape[c])}return io(this,"shape",l),l},checks:[]});return ki(e,i)}function aA(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=gi(e._zod.def,{get shape(){const l={...e._zod.def.shape};for(const c of Reflect.ownKeys(t)){if(!Object.prototype.hasOwnProperty.call(n.shape,c))throw new Error(`Unrecognized key: "${String(c)}"`);t[c]&&delete l[c]}return io(this,"shape",l),l},checks:[]});return ki(e,i)}function lA(e,t){if(!Ic(t))throw new Error("Invalid input to extend: expected a plain object");const n=e._zod.def.checks;if(n&&n.length>0){const i=e._zod.def.shape;for(const l of Reflect.ownKeys(t))if(Object.getOwnPropertyDescriptor(i,l)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}const o=gi(e._zod.def,{get shape(){const i={...e._zod.def.shape,...t};return io(this,"shape",i),i}});return ki(e,o)}function cA(e,t){if(!Ic(t))throw new Error("Invalid input to safeExtend: expected a plain object");const n=gi(e._zod.def,{get shape(){const r={...e._zod.def.shape,...t};return io(this,"shape",r),r}});return ki(e,n)}function uA(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=gi(e._zod.def,{get shape(){const i={...e._zod.def.shape,...t._zod.def.shape};return io(this,"shape",i),i},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return ki(e,n)}function Mv(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=gi(t._zod.def,{get shape(){const u=t._zod.def.shape,h={...u};if(n)for(const p of Reflect.ownKeys(n)){if(!Object.prototype.hasOwnProperty.call(u,p))throw new Error(`Unrecognized key: "${String(p)}"`);n[p]&&(h[p]=e?new e({type:"optional",innerType:u[p]}):u[p])}else for(const p of Reflect.ownKeys(u))h[p]=e?new e({type:"optional",innerType:u[p]}):u[p];return io(this,"shape",h),h},checks:[]});return ki(t,c)}function dA(e,t,n){const r=gi(t._zod.def,{get shape(){const o=t._zod.def.shape,i={...o};if(n)for(const l of Reflect.ownKeys(n)){if(!Object.prototype.hasOwnProperty.call(i,l))throw new Error(`Unrecognized key: "${String(l)}"`);n[l]&&(i[l]=new e({type:"nonoptional",innerType:o[l]}))}else for(const l of Reflect.ownKeys(o))i[l]=new e({type:"nonoptional",innerType:o[l]});return io(this,"shape",i),i}});return ki(t,r)}function Fa(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 fA(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 _f(e,t){return t.map(n=>{var r;return(r=n).path??(r.path=[]),n.path.unshift(e),n})}function sc(e){return typeof e=="string"?e:e==null?void 0:e.message}function Pv(e,t,n){var r;for(let o=t;o<e.length;o++)(r=e[o]).schema??(r.schema=n)}function cl(e,t,n){var k,g,y,b,S,j,E,N,A,O;var r;const o=(g=(k=e.inst)==null?void 0:k._zod)==null?void 0:g.traits;o!=null&&o.has("$ZodType")&&(o.has("$ZodCheck")?(r=e).schema??(r.schema=e.inst):e.schema=e.inst);const i=e.schema!==e.inst?(b=(y=e.schema)==null?void 0:y._zod.def)==null?void 0:b.error:void 0,l=e.message?e.message:sc((E=(j=(S=e.inst)==null?void 0:S._zod.def)==null?void 0:j.error)==null?void 0:E.call(j,e))??sc(i==null?void 0:i(e))??sc((N=t==null?void 0:t.error)==null?void 0:N.call(t,e))??sc((A=n.customError)==null?void 0:A.call(n,e))??sc((O=n.localeError)==null?void 0:O.call(n,e))??"Invalid input",{inst:c,schema:u,continue:h,input:p,...m}=e;return m.path??(m.path=[]),m.message=l,t!=null&&t.reportInput&&(m.input=p),m}const hA=/[\uD800-\uDBFF]/;function $g(e){const t=e.length;if(!hA.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 Og(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function pA(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 Rc(...e){const[t,n,r]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:r}:{...t}}function mA(e,t){for(const n in t){const r=Object.getOwnPropertyDescriptor(t,n);r.get?Object.defineProperty(e,n,{...r,enumerable:!1}):gA(e,n,r.value)}}function tl(e,t,n,r=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:r,value:n}),n}function m1(e,t,n){return tl(e,t,n,!1)}function gA(e,t,n){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?n:tl(this,t,n.bind(this))},set(r){tl(this,t,r)}})}function kA(e,t){const n=Object.getPrototypeOf(e);return t in n?void 0:n}let Tp,oi=!1;const wA={configurable:!0,get(){oi=!0}};function _n(e,t,n){const r=Object.getPrototypeOf(e._zod);if(t in r&&Tp!==e._zod){Tp=void 0;return}Tp=e._zod,Object.defineProperty(r,t,{configurable:!0,get(){Object.defineProperty(this,t,wA);const o=oi;oi=!1;try{const i=n(this);return oi?delete this[t]:Object.defineProperty(this,t,{configurable:!0,writable:!0,value:i}),oi=oi||o,i}catch(i){throw delete this[t],oi=oi||o,i}},set(o){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:o})}})}function yA(e,t,n,r){const o=kA(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 vA="~constantCatch";function bA(e){const t=()=>e;return t[vA]=!0,t}var Lv;const jp={value:void 0,enumerable:!1};let Dv="captureStackTrace"in Error?Error:null;function xA(e){const t=Dv;if(t){const n=t.stackTraceLimit;if(typeof n=="number"){try{t.stackTraceLimit=0}catch{return Dv=null,new e}try{return new e}finally{t.stackTraceLimit=n}}}return new e}function xe(e,t,n,r){const o={};function i(k){this.def=k,this.constr=m,this.traits=new Set}i.prototype=o;const l=n,c=l&&new WeakSet;function u(k,g){if(!k._zod){jp.value=new i(g);try{Object.defineProperty(k,"_zod",jp)}finally{jp.value=void 0}}if(k._zod.traits.has(e))return;if(k._zod.traits.add(e),t(k,g),c){const b=Object.getPrototypeOf(k),S=k._zod.constr.prototype;let j=b;for(;j&&j!==S;)j=Object.getPrototypeOf(j);const E=j??b;c.has(E)||(c.add(E),mA(E,l))}const y=m.prototype;for(const b in y)Object.prototype.hasOwnProperty.call(y,b)&&(b in k||(k[b]=y[b].bind(k)))}const h=(r==null?void 0:r.Parent)??Object;class p extends h{}Object.defineProperty(p,"name",{value:e});function m(k){var S;const g=r!=null&&r.Parent?xA(p):this;u(g,k);const y=g._zod.deferred;if(y){for(const j of y)j();g._zod.deferred=void 0}const b=(S=globalThis.__zod_globalConfig)==null?void 0:S.postProcessor;return b&&b(g),g}return Object.defineProperty(m,"init",{value:u}),Object.defineProperty(m,Symbol.hasInstance,{value:k=>{var g,y;return r!=null&&r.Parent&&k instanceof r.Parent?!0:(y=(g=k==null?void 0:k._zod)==null?void 0:g.traits)==null?void 0:y.has(e)}}),Object.defineProperty(m,"name",{value:e}),m}class qa extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class g1 extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}(Lv=globalThis).__zod_globalConfig??(Lv.__zod_globalConfig={});const Go=globalThis.__zod_globalConfig;function wi(e){return e&&Object.assign(Go,e),Go}function EA(){const e=this._zod;return e.message??(e.message=JSON.stringify(e.def,wm,2)),e.message}function SA(e){this._zod.message=e}const _A={get:EA,set:SA,enumerable:!0,configurable:!0},Cp={value:void 0,enumerable:!1},Ap={value:void 0,enumerable:!1},zv=new WeakSet([Object.prototype,Error.prototype]),k1=(e,t)=>{e.name="$ZodError",Cp.value=e._zod,Object.defineProperty(e,"_zod",Cp),Ap.value=t,Object.defineProperty(e,"issues",Ap),Cp.value=void 0,Ap.value=void 0,Object.defineProperty(e,"message",_A);const n=Object.getPrototypeOf(e);zv.has(n)||(zv.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})}}))},w1=xe("$ZodError",k1),y1=xe("$ZodError",k1,void 0,{Parent:Error});function NA(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 TA(e,t=n=>n.message){const n={},r=[];for(const o of e.issues)o.path.length>0?NA(n,o.path[0],()=>[]).push(t(o)):r.push(t(o));return{formErrors:r,fieldErrors:n}}function jA(e,t=n=>n.message){const n={_errors:[]},r=(o,i=[])=>{for(const l of o.issues)if(l.code==="invalid_union"&&l.errors.length)l.errors.map(c=>r({issues:c},[...i,...l.path]));else if(l.code==="invalid_key")r({issues:l.issues},[...i,...l.path]);else if(l.code==="invalid_element")r({issues:l.issues},[...i,...l.path]);else{const c=[...i,...l.path];if(c.length===0)n._errors.push(t(l));else{let u=n,h=0;for(;h<c.length;){const p=c[h],m=h===c.length-1;if(p==="_errors"){m&&u._errors.push(t(l)),h++;continue}Object.prototype.hasOwnProperty.call(u,p)||Object.defineProperty(u,p,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});const k=u[p];m&&k._errors.push(t(l)),u=k,h++}}}};return r(e),n}function Nf(e,t){return{callee:(t==null?void 0:t.callee)??e,Err:t==null?void 0:t.Err}}const Mg=e=>{const t=(n,r,o,i)=>{const l=o?{...o,async:!1}:{async:!1},c=n._zod.run({value:r,issues:[]},l);if(c instanceof Promise)throw new qa;if(c.issues.length){const u=new((i==null?void 0:i.Err)??e)(c.issues.map(h=>cl(h,l,wi())));throw f1(u,(i==null?void 0:i.callee)??t),u}return c.value};return t},Pg=e=>{const t=async(n,r,o,i)=>{const l=o?{...o,async:!0}:{async:!0};let c=n._zod.run({value:r,issues:[]},l);if(c instanceof Promise&&(c=await c),c.issues.length){const u=new((i==null?void 0:i.Err)??e)(c.issues.map(h=>cl(h,l,wi())));throw f1(u,(i==null?void 0:i.callee)??t),u}return c.value};return t},Tf=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 qa;return i.issues.length?{success:!1,error:new(e??w1)(i.issues.map(l=>cl(l,o,wi())))}:{success:!0,data:i.value}},CA=Tf(y1),jf=e=>async(t,n,r)=>{const o=r?{...r,async:!0}:{async:!0};let i=t._zod.run({value:n,issues:[]},o);return i instanceof Promise&&(i=await i),i.issues.length?{success:!1,error:new e(i.issues.map(l=>cl(l,o,wi())))}:{success:!0,data:i.value}},AA=jf(y1),IA=e=>{const t=Mg(e),n=(r,o,i,l)=>{const c=i?{...i,direction:"backward"}:{direction:"backward"};return t(r,o,c,Nf(n,l))};return n},RA=e=>{const t=Mg(e),n=(r,o,i,l)=>t(r,o,i,Nf(n,l));return n},$A=e=>{const t=Pg(e),n=async(r,o,i,l)=>{const c=i?{...i,direction:"backward"}:{direction:"backward"};return await t(r,o,c,Nf(n,l))};return n},OA=e=>{const t=Pg(e),n=async(r,o,i,l)=>await t(r,o,i,Nf(n,l));return n},MA=e=>(t,n,r)=>{const o=r?{...r,direction:"backward"}:{direction:"backward"};return Tf(e)(t,n,o)},PA=e=>(t,n,r)=>Tf(e)(t,n,r),LA=e=>async(t,n,r)=>{const o=r?{...r,direction:"backward"}:{direction:"backward"};return jf(e)(t,n,o)},DA=e=>async(t,n,r)=>jf(e)(t,n,r),zA=/^[cC][0-9a-z]{6,}$/,FA=/^[0-9a-z]+$/,BA=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,UA=/^[0-9a-vA-V]{20}$/,HA=/^[A-Za-z0-9]{27}$/,WA=/^[a-zA-Z0-9_-]{21}$/;function KA(e){return new RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}const ZA=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,qA=/^([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})$/,Fv=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)$/,GA=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,VA="^[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$";function YA(){return new RegExp(VA,"u")}const XA=/^(?:(?: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])$/,QA=/^(([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}|:))$/,JA=/^((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])$/,eI=/^(([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])$/,tI=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,v1=/^[A-Za-z0-9_-]*$/,nI=/^https?$/,rI=/^\+[1-9]\d{6,14}$/,b1="(?:(?:\\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 oI(e){return new RegExp(`^${e}$`)}const sI=oI(b1);function ym(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 iI(e){return new RegExp(`^${ym(e)}$`)}function aI(e){const t=["Z"];e.offset&&t.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const n=`${ym({precision:e.precision,seconds:!0})}(?:${t.join("|")})`,r=e.local?`${n}|${ym({precision:e.precision})}`:n;return new RegExp(`^${b1}T(?:${r})$`)}const lI=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}$`)},cI=/^-?\d+$/,uI=/^-?\d+(?:\.\d+)?$/,dI=/^(?:true|false)$/i,fI=/^[^A-Z]*$/,hI=/^[^a-z]*$/,ao=xe("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),Lg=e=>{const t=e.value;return!QC(t)&&t.length!==void 0},Kd={number:"number",bigint:"bigint",object:"date"},x1=xe("$ZodCheckLessThan",(e,t)=>{ao.init(e,t);const n=Kd[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:Kd[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})}}),E1=xe("$ZodCheckGreaterThan",(e,t)=>{ao.init(e,t);const n=Kd[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:Kd[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})}}),pI=xe("$ZodCheckMultipleOf",(e,t)=>{ao.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):JC(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:"not_multiple_of",divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),mI=xe("$ZodCheckNumberFormat",(e,t)=>{var l;ao.init(e,t),t.format=t.format||"float64";const n=(l=t.format)==null?void 0:l.includes("int"),r=n?"int":"number",[o,i]=sA[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=cI)}),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})}}),gI=xe("$ZodCheckMaxLength",(e,t)=>{var n;ao.init(e,t),(n=e._zod.def).when??(n.when=Lg),e._zod.onattach.push(r=>{const o=r._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<o&&(r._zod.bag.maximum=t.maximum)}),e._zod.check=r=>{const o=r.value,i=o.length;if((typeof o=="string"&&i>t.maximum?$g(o):i)<=t.maximum)return;const c=Og(o);r.issues.push({origin:c,code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),kI=xe("$ZodCheckMinLength",(e,t)=>{var n;ao.init(e,t),(n=e._zod.def).when??(n.when=Lg),e._zod.onattach.push(r=>{const o=r._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>o&&(r._zod.bag.minimum=t.minimum)}),e._zod.check=r=>{const o=r.value,i=o.length;if((typeof o=="string"&&i>=t.minimum&&i<t.minimum*2?$g(o):i)>=t.minimum)return;const c=Og(o);r.issues.push({origin:c,code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),wI=xe("$ZodCheckLengthEquals",(e,t)=>{var n;ao.init(e,t),(n=e._zod.def).when??(n.when=Lg),e._zod.onattach.push(r=>{const o=r._zod.bag;o.minimum=t.length,o.maximum=t.length,o.length=t.length}),e._zod.check=r=>{const o=r.value,i=o.length,l=typeof o=="string"&&i>=t.length&&i<=t.length*2?$g(o):i;if(l===t.length)return;const c=Og(o),u=l>t.length;r.issues.push({origin:c,...u?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!t.abort})}}),Cf=xe("$ZodCheckStringFormat",(e,t)=>{var n,r;ao.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=()=>{})}),yI=xe("$ZodCheckRegex",(e,t)=>{Cf.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})}}),vI=xe("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=fI),Cf.init(e,t)}),bI=xe("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=hI),Cf.init(e,t)}),xI=xe("$ZodCheckIncludes",(e,t)=>{ao.init(e,t);const n=el(t.includes),r=new RegExp(typeof t.position=="number"?`^.{${t.position},}${n}`:n);t.pattern=r,e._zod.onattach.push(o=>{const i=o._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(r)}),e._zod.check=o=>{o.value.includes(t.includes,t.position)||o.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:o.value,inst:e,continue:!t.abort})}}),EI=xe("$ZodCheckStartsWith",(e,t)=>{ao.init(e,t);const n=new RegExp(`^${el(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.onattach.push(r=>{const o=r._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(n)}),e._zod.check=r=>{r.value.startsWith(t.prefix)||r.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:r.value,inst:e,continue:!t.abort})}}),SI=xe("$ZodCheckEndsWith",(e,t)=>{ao.init(e,t);const n=new RegExp(`.*${el(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.onattach.push(r=>{const o=r._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(n)}),e._zod.check=r=>{r.value.endsWith(t.suffix)||r.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:r.value,inst:e,continue:!t.abort})}}),_I=xe("$ZodCheckOverwrite",(e,t)=>{ao.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});class NI{constructor(t=[],n={}){this.content=[],this.indent=0,this.args=t,this.closed=n}indented(t){this.indent+=1,t(this),this.indent-=1}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}const r=t.split(`
|
|
43
|
+
`).filter(l=>l),o=Math.min(...r.map(l=>l.length-l.trimStart().length)),i=r.map(l=>l.slice(o)).map(l=>" ".repeat(this.indent*2)+l);for(const l of i)this.content.push(l)}compile(){const t=Function,n=(this==null?void 0:this.content)??[""];return new t(...Object.keys(this.closed),`return function (${this.args.join(", ")}) {
|
|
44
|
+
${n.join(`
|
|
45
|
+
`)}
|
|
46
|
+
};`)(...Object.values(this.closed))}}const TI={major:4,minor:5,patch:4},Dn=xe("$ZodType",(e,t)=>{var i;var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=TI;const r=e._zod.def.checks,o=e._zod.traits.has("$ZodCheck")?[e,...r??[]]:r!=null&&r.length?[...r]:[];for(const l of o)for(const c of l._zod.onattach)c(e);if(o.length===0)(n=e._zod).deferred??(n.deferred=[]),(i=e._zod.deferred)==null||i.push(()=>{e._zod.run=e._zod.parse});else{const l=(u,h,p)=>{if(u.memo)return u;let m=Fa(u),k;for(const g of h){if(g._zod.def.when){if(fA(u)||!g._zod.def.when(u))continue}else if(m)continue;const y=u.issues.length,b=g._zod.check(u);if(b instanceof Promise&&(p==null?void 0:p.async)===!1)throw new qa;if(k||b instanceof Promise)k=(k??Promise.resolve()).then(async()=>{await b,u.issues.length!==y&&(Pv(u.issues,y,e),m||(m=Fa(u,y)))});else{if(u.issues.length===y)continue;Pv(u.issues,y,e),m||(m=Fa(u,y))}}return k?k.then(()=>u):u},c=(u,h,p)=>{if(Fa(u))return u.aborted=!0,u;const m=l(h,o,p);if(m instanceof Promise){if(p.async===!1)throw new qa;return m.then(k=>e._zod.parse(k,p))}return e._zod.parse(m,p)};e._zod.run=(u,h)=>{if(h.skipChecks)return e._zod.parse(u,h);if(h.direction==="backward"){const m=e._zod.parse({value:u.value,issues:[]},{...h,skipChecks:!0});return m instanceof Promise?m.then(k=>c(k,u,h)):c(m,u,h)}const p=e._zod.parse(u,h);if(p instanceof Promise){if(h.async===!1)throw new qa;return p.then(m=>l(m,o,h))}return l(p,o,h)}}},{get"~standard"(){return m1(this,"~standard",S1(this))},set"~standard"(e){tl(this,"~standard",e)}}),Bv=e=>{var t;return e.success?{value:e.data}:{issues:(t=e.error)==null?void 0:t.issues}};function S1(e){return{validate:t=>{try{return Bv(CA(e,t))}catch{return AA(e,t).then(Bv)}},vendor:"zod",version:1}}const Dg=xe("$ZodString",(e,t)=>{var n;Dn.init(e,t),e._zod.pattern=[...((n=e==null?void 0:e._zod.bag)==null?void 0:n.patterns)??[]].pop()??lI(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}}),zn=xe("$ZodStringFormat",(e,t)=>{Cf.init(e,t),Dg.init(e,t)}),jI=xe("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=qA),zn.init(e,t)}),CI=xe("$ZodUUID",(e,t)=>{if(t.version){const r={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(r===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=Fv(r))}else t.pattern??(t.pattern=Fv());zn.init(e,t)}),AI=xe("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=GA),zn.init(e,t)}),_1=1,N1=2;function II(e,t){var n;if(!t.normalize&&((n=t.protocol)==null?void 0:n.source)===nI.source&&!/^https?:\/\//i.test(e))return _1;try{return new URL(e)}catch{return N1}}const RI=/[\t\n\r]/g;function $I(e){return e.replace(RI,"")}function OI(e,t){return t.lastIndex=0,t.test(e.hostname)}function MI(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(":")?e.protocol.slice(0,-1):e.protocol)}const PI=xe("$ZodURL",(e,t)=>{zn.init(e,t),e._zod.check=n=>{try{const r=n.value.trim(),o=II(r,t);if(o===_1){n.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:n.value,inst:e,continue:!t.abort});return}if(o===N1){n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort});return}t.hostname&&!OI(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&&!MI(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:$I(r);return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),LI=xe("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=YA()),zn.init(e,t)}),DI=xe("$ZodNanoID",(e,t)=>{if(t.length!==void 0&&(!Number.isInteger(t.length)||t.length<1))throw new Error(`Invalid nanoid length: ${t.length}`);t.pattern??(t.pattern=t.length===void 0?WA:KA(t.length)),zn.init(e,t)}),zI=xe("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=zA),zn.init(e,t)}),FI=xe("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=FA),zn.init(e,t)}),BI=xe("$ZodULID",(e,t)=>{t.pattern??(t.pattern=BA),zn.init(e,t)}),UI=xe("$ZodXID",(e,t)=>{t.pattern??(t.pattern=UA),zn.init(e,t)}),HI=xe("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=HA),zn.init(e,t)}),WI=xe("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=aI(t)),zn.init(e,t),(t.local||t.precision===-1)&&(e._zod.bag.laxFormat=!0,e._zod.onattach.push(n=>{n._zod.bag.laxFormat=!0}))}),KI=xe("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=sI),zn.init(e,t)}),ZI=xe("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=iI(t)),zn.init(e,t)}),qI=xe("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=ZA),zn.init(e,t)}),GI=xe("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=XA),zn.init(e,t),e._zod.bag.format="ipv4"}),VI=/^[0-9a-fA-F:.]+$/;function T1(e){if(!VI.test(e))return!1;try{return new URL(`http://[${e}]`),!0}catch{return!1}}const YI=xe("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=QA),zn.init(e,t),e._zod.bag.format="ipv6",e._zod.check=n=>{T1(n.value)||n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}}),XI=xe("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=JA),zn.init(e,t)});function QI(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:T1(n)}const JI=xe("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=eI),zn.init(e,t),e._zod.check=n=>{QI(n.value)||n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}});function j1(e){if(e==="")return!0;if(/\s/.test(e)||e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const eR=xe("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=tI),zn.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{j1(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});function tR(e){if(!v1.test(e))return!1;const t=e.replace(/[-_]/g,r=>r==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return j1(n)}const nR=xe("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=v1),zn.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{tR(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),rR=xe("$ZodE164",(e,t)=>{t.pattern??(t.pattern=rI),zn.init(e,t)});function oR(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 sR=xe("$ZodJWT",(e,t)=>{zn.init(e,t),e._zod.check=n=>{oR(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),C1=xe("$ZodNumber",(e,t)=>{Dn.init(e,t),e._zod.pattern=e._zod.bag.pattern??uI,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}}),iR=xe("$ZodNumberFormat",(e,t)=>{mI.init(e,t),C1.init(e,t)}),aR=xe("$ZodBoolean",(e,t)=>{Dn.init(e,t),e._zod.pattern=dI,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}}),lR=xe("$ZodUnknown",(e,t)=>{Dn.init(e,t),e._zod.parse=n=>n}),cR=xe("$ZodNever",(e,t)=>{Dn.init(e,t),e._zod.parse=(n,r)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)});function Uv(e,t,n){e.issues.length&&t.issues.push(..._f(n,e.issues)),t.value[n]=e.value}const uR=xe("$ZodArray",(e,t)=>{Dn.init(e,t);const n=Go.memoizer;n==null||n.attach(e),e._zod.parse=(r,o)=>{const i=r.value;if(!Array.isArray(i))return r.issues.push({expected:"array",code:"invalid_type",input:i,inst:e}),r;r.value=n?n.alloc(e,r,Array(i.length),o):Array(i.length);const l=[];for(let c=0;c<i.length;c++){const u=i[c],h=t.element._zod.run({value:u,issues:[]},o);h instanceof Promise?l.push(h.then(p=>Uv(p,r,c))):Uv(h,r,c)}return l.length?Promise.all(l).then(()=>r):r}});function Zd(e,t,n,r,o,i){const l=n in r,c=i==="optional";if(!(!l&&c&&o==="optional")){if(e.issues.length){if(o!==void 0&&c&&!l)return;t.issues.push(..._f(n,e.issues))}if(!l&&o===void 0){e.issues.length||t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[n]});return}e.value===void 0?l&&(t.value[n]=void 0):t.value[n]=e.value}}const dR=[];function A1(e){var l,c,u,h;const t=Object.keys(e.shape),n=Object.getOwnPropertySymbols(e.shape),r=n.length?n:dR,o=r.length?[...t,...r]:t;for(const p of o)if(!((h=(u=(c=(l=e.shape)==null?void 0:l[p])==null?void 0:c._zod)==null?void 0:u.traits)!=null&&h.has("$ZodType")))throw new Error(`Invalid element at key "${String(p)}": expected a Zod schema`);const i=oA(e.shape);return{...e,allKeys:o,symbolKeys:r,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(i)}}function I1(e,t,n,r,o,i){const l=[],c=o.keySet,u=o.catchall._zod,h=u.def.type,p=u.optin,m=u.optout;for(const k in t){if(c.has(k))continue;if(k==="__proto__"){h==="never"&&l.push(k);continue}if(h==="never"){l.push(k);continue}const g=u.run({value:t[k],issues:[]},r);g instanceof Promise?e.push(g.then(y=>Zd(y,n,k,t,p,m))):Zd(g,n,k,t,p,m)}return l.length&&n.issues.push({code:"unrecognized_keys",keys:l,input:t,inst:i,continue:!0}),e.length?Promise.all(e).then(()=>n):n}const vm=new WeakMap,fR=xe("$ZodObject",(e,t)=>{Dn.init(e,t);const n=Object.getOwnPropertyDescriptor(t,"shape");if(!(n!=null&&n.get)){const u=t.shape;vm.set(t,u),Object.defineProperty(t,"shape",{get:()=>{const h={...u};return Object.defineProperty(t,"shape",{value:h}),vm.set(t,h),h}})}const r=Sf(()=>A1(t));_n(e,"propValues",u=>{const h=u.def.shape,p={};for(const m in h){const k=h[m]._zod;if(k.values){Object.prototype.hasOwnProperty.call(p,m)||io(p,m,new Set);for(const g of k.values)p[m].add(g);k.optin!==void 0&&p[m].add(void 0)}}return p});const o=Ac,i=t.catchall;let l;const c=Go.memoizer;c==null||c.attach(e),e._zod.parse=(u,h)=>{l??(l=r.value);const p=u.value;if(!o(p))return u.issues.push({expected:"object",code:"invalid_type",input:p,inst:e}),u;u.value=c?c.alloc(e,u,{},h):{};const m=[],k=l.shape;for(const g of l.allKeys){if(g==="__proto__")continue;const y=k[g],b=y._zod.optin,S=y._zod.optout,j=y._zod.run({value:p[g],issues:[]},h);j instanceof Promise?m.push(j.then(E=>Zd(E,u,g,p,b,S))):Zd(j,u,g,p,b,S)}return i?I1(m,p,u,h,r.value,e):m.length?Promise.all(m).then(()=>u):u}}),hR=xe("$ZodObjectJIT",(e,t)=>{fR.init(e,t);const n=e._zod.parse,r=Sf(()=>A1(t)),o=Go.memoizer,i=g=>{var O,P;const y=r.value,b=y.symbolKeys,S=new NI(["payload","ctx"],{shape:g,inst:e,memo:o,syms:b}),j=R=>`shape[${R}]._zod.run({ value: input[${R}], issues: [] }, ctx)`,E=(R,T)=>`
|
|
47
|
+
for (let i = 0; i < ${R}.issues.length; i++) {
|
|
48
|
+
const iss = ${R}.issues[i];
|
|
49
|
+
iss.path = iss.path ? [${T}, ...iss.path] : [${T}];
|
|
50
|
+
payload.issues.push(iss);
|
|
51
|
+
}`;S.write("const input = payload.value;");const N=Object.create(null);let A=0;for(const R of y.allKeys)N[R]=`key_${A++}`;S.write(o?"const newResult = memo.alloc(inst, payload, {}, ctx);":"const newResult = {};");for(const R of y.allKeys){if(R==="__proto__")continue;const T=N[R],$=typeof R=="symbol"?`syms[${b.indexOf(R)}]`:eA(R),D=`${$} in input`,z=g[R],V=(O=z==null?void 0:z._zod)==null?void 0:O.optin,se=V!==void 0,I=((P=z==null?void 0:z._zod)==null?void 0:P.optout)==="optional";if(S.write(`const ${T} = ${j($)};`),se&&I){const ne=V==="optional"?`${T}_present`:`${T}.value !== undefined || ${T}_present`;S.write(`
|
|
52
|
+
const ${T}_present = ${D};
|
|
53
|
+
if (!${T}.issues.length || ${T}_present) {
|
|
54
|
+
if (${T}.issues.length) {${E(T,$)}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (${ne}) {
|
|
58
|
+
newResult[${$}] = ${T}.value;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
`)}else se?S.write(`
|
|
63
|
+
if (${T}.issues.length) {${E(T,$)}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (${T}.value === undefined) {
|
|
67
|
+
if (${D}) {
|
|
68
|
+
newResult[${$}] = undefined;
|
|
69
|
+
}
|
|
70
|
+
} else {
|
|
71
|
+
newResult[${$}] = ${T}.value;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
`):S.write(`
|
|
75
|
+
const ${T}_present = ${D};
|
|
76
|
+
if (${T}.issues.length) {${E(T,$)}
|
|
77
|
+
}
|
|
78
|
+
if (!${T}_present && !${T}.issues.length) {
|
|
79
|
+
payload.issues.push({
|
|
80
|
+
code: "invalid_type",
|
|
81
|
+
expected: "nonoptional",
|
|
82
|
+
input: undefined,
|
|
83
|
+
path: [${$}]
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
if (${T}_present) {
|
|
88
|
+
newResult[${$}] = ${T}.value;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
`)}return S.write("payload.value = newResult;"),S.write("return payload;"),S.compile()};let l;const c=Ac,u=!Go.jitless,p=u&&nA.value,m=t.catchall;let k;e._zod.parse=(g,y)=>{k??(k=r.value);const b=g.value;return c(b)?u&&p&&(y==null?void 0:y.async)===!1&&y.jitless!==!0?(l||(l=i(t.shape)),g=l(g,y),m?I1([],b,g,y,k,e):g):n(g,y):(g.issues.push({expected:"object",code:"invalid_type",input:b,inst:e}),g)}});function Hv(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=>!Fa(i));return o.length===1?(t.value=o[0].value,o[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(i=>i.issues.map(l=>cl(l,r,wi())))}),t)}const R1=xe("$ZodUnion",(e,t)=>{Dn.init(e,t),_n(e,"optin",r=>r.def.options.some(o=>o._zod.optin==="defaulted")?"defaulted":r.def.options.some(o=>o._zod.optin!==void 0)?"optional":void 0),_n(e,"optout",r=>r.def.options.some(o=>o._zod.optout==="optional")?"optional":void 0),_n(e,"values",r=>{if(r.def.options.every(o=>o._zod.values))return new Set(r.def.options.flatMap(o=>Array.from(o._zod.values)))}),_n(e,"pattern",r=>{if(r.def.options.every(o=>o._zod.pattern)){const o=r.def.options.map(i=>i._zod.pattern);return new RegExp(`^(${o.map(i=>Rg(i.source)).join("|")})$`)}});const n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,o)=>{if(n)return n(r,o);let i=!1;const l=[];for(const c of t.options){const u=c._zod.run({value:r.value,issues:[]},o);if(u instanceof Promise)l.push(u),i=!0;else{if(u.issues.length===0)return u;l.push(u)}}return i?Promise.all(l).then(c=>Hv(c,r,e,o)):Hv(l,r,e,o)}}),pR=xe("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,R1.init(e,t);const n=e._zod.parse;_n(e,"propValues",o=>{const i={};for(const l of o.def.options){const c=l._zod.propValues;if(!c||Object.keys(c).length===0)throw new Error(`Invalid discriminated union option at index "${o.def.options.indexOf(l)}"`);for(const[u,h]of Object.entries(c)){Object.prototype.hasOwnProperty.call(i,u)||io(i,u,new Set);for(const p of h)i[u].add(p)}}return i}),t.options.forEach((o,i)=>{const l=vm.get(o._zod.def);if(l&&!Object.prototype.hasOwnProperty.call(l,t.discriminator))throw new Error(`Invalid discriminated union option at index "${i}"`)});const r=Sf(()=>{var l;const o=t.options,i=new Map;for(const c of o){const u=(l=c._zod.propValues)==null?void 0:l[t.discriminator];if(!u||u.size===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(c)}"`);for(const h of u){if(i.has(h))throw new Error(`Duplicate discriminator value "${String(h)}"`);i.set(h,c)}}return i});e._zod.parse=(o,i)=>{const l=o.value;if(!Ac(l))return o.issues.push({code:"invalid_type",expected:"object",input:l,inst:e}),o;const c=r.value.get(l==null?void 0:l[t.discriminator]);return c?c._zod.run(o,i):t.unionFallback||i.direction==="backward"?n(o,i):(o.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,options:Array.from(r.value.keys()),input:l,path:[t.discriminator],inst:e}),o)}}),mR=xe("$ZodIntersection",(e,t)=>{Dn.init(e,t),e._zod.parse=(n,r)=>{const o=n.value,i=t.left._zod.run({value:o,issues:[]},r),l=t.right._zod.run({value:o,issues:[]},r);return i instanceof Promise||l instanceof Promise?Promise.all([i,l]).then(([u,h])=>Wv(n,u,h)):Wv(n,i,l)}});function bm(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(Ic(e)&&Ic(t)){const n=Object.keys(t),r=Object.keys(e).filter(i=>n.indexOf(i)!==-1),o={...e,...t};Object.prototype.hasOwnProperty.call(o,"__proto__")&&delete o.__proto__;for(const i of r){if(i==="__proto__")continue;const l=bm(e[i],t[i]);if(!l.valid)return{valid:!1,mergeErrorPath:[i,...l.mergeErrorPath]};o[i]=l.data}return{valid:!0,data:o}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const n=[];for(let r=0;r<e.length;r++){const o=e[r],i=t[r],l=bm(o,i);if(!l.valid)return{valid:!1,mergeErrorPath:[r,...l.mergeErrorPath]};n.push(l.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function Wv(e,t,n){const r=new Map;let o;const i=new Map,l=(h,p)=>{var k,g;let m;if(h.code==="unrecognized_keys"&&!((k=h.path)!=null&&k.length))o??(o=h),m=h.keys;else if(h.code==="invalid_key"&&h.origin==="record"&&((g=h.path)==null?void 0:g.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)[p]=!0;return!0};for(const h of t.issues)l(h,"l")||e.issues.push(h);for(const h of n.issues)l(h,"r")||e.issues.push(h);const c=[...r].filter(([,h])=>h.l&&h.r).map(([h])=>h);if(c.length){const h=o?c.filter(p=>o.keys.includes(p)):[];h.length&&e.issues.push({...o,keys:h});for(const p of c)!h.includes(p)&&i.has(p)&&e.issues.push(i.get(p))}const u=bm(t.value,n.value);if(!u.valid){if(Fa(e))return e;throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(u.mergeErrorPath)}`)}return e.value=u.data,e}const gR=xe("$ZodTuple",(e,t)=>{Dn.init(e,t);const n=t.items,r=Go.memoizer;r==null||r.attach(e),e._zod.parse=(o,i)=>{const l=o.value;if(!Array.isArray(l))return o.issues.push({input:l,inst:e,expected:"tuple",code:"invalid_type"}),o;o.value=r?r.alloc(e,o,[],i):[];const c=[],u=Kv(n,"optin"),h=Kv(n,"optout");if(!t.rest){if(l.length<u)return o.issues.push({code:"too_small",minimum:u,inclusive:!0,input:l,inst:e,origin:"array"}),o;l.length>n.length&&o.issues.push({code:"too_big",maximum:n.length,inclusive:!0,input:l,inst:e,origin:"array"})}const p=new Array(n.length);for(let m=0;m<n.length;m++){const k=n[m]._zod.run({value:l[m],issues:[]},i);k instanceof Promise?c.push(k.then(g=>{p[m]=g})):p[m]=k}if(t.rest){let m=n.length-1;const k=l.slice(n.length);for(const g of k){m++;const y=t.rest._zod.run({value:g,issues:[]},i);y instanceof Promise?c.push(y.then(b=>Zv(b,o,m))):Zv(y,o,m)}}return c.length?Promise.all(c).then(()=>qv(p,o,n,l,h)):qv(p,o,n,l,h)}});function Kv(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 Zv(e,t,n){e.issues.length&&t.issues.push(..._f(n,e.issues)),t.value[n]=e.value}function qv(e,t,n,r,o){for(let i=0;i<n.length;i++){const l=e[i],c=i<r.length;if(!c&&i>=o&&n[i]._zod.optin==="optional"){t.value.length=i;break}if(l.issues.length){if(!c&&i>=o){t.value.length=i;break}t.issues.push(..._f(i,l.issues))}t.value[i]=l.value}for(let i=t.value.length-1;i>=r.length&&(n[i]._zod.optout==="optional"&&t.value[i]===void 0);i--)t.value.length=i;return t}const kR=xe("$ZodEnum",(e,t)=>{Dn.init(e,t);const n=d1(t.entries),r=new Set(n);e._zod.values=r;const o=n.filter(i=>rA.has(typeof i));e._zod.pattern=new RegExp(o.length?`^(${o.map(i=>el(i.toString())).join("|")})$`:"^[^\\s\\S]$"),e._zod.parse=(i,l)=>{const c=i.value;return r.has(c)||i.issues.push({code:"invalid_value",values:n,input:c,inst:e}),i}}),wR=xe("$ZodLiteral",(e,t)=>{Dn.init(e,t);const n=new Set(t.values);e._zod.values=n,e._zod.pattern=new RegExp(t.values.length?`^(${t.values.map(r=>typeof r=="string"?el(r):r?el(r.toString()):String(r)).join("|")})$`:"^[^\\s\\S]$"),e._zod.parse=(r,o)=>{const i=r.value;return n.has(i)||r.issues.push({code:"invalid_value",values:t.values,input:i,inst:e}),r}}),yR=xe("$ZodTransform",(e,t)=>{var n;Dn.init(e,t),e._zod.optin="optional",(n=Go.memoizer)==null||n.guard(e),e._zod.parse=(r,o)=>{if(o.direction==="backward")throw new g1(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 qa;return r.value=i,r}});function Gv(e,t){return e.value=t.issues.length?void 0:t.value,e}const $1=xe("$ZodOptional",(e,t)=>{Dn.init(e,t),_n(e,"optin",n=>n.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),e._zod.optout="optional",_n(e,"values",n=>{const r=n.def.innerType._zod.values;return r?new Set([...r,void 0]):void 0}),_n(e,"pattern",n=>{const r=n.def.innerType._zod.pattern;return r?new RegExp(`^(${Rg(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=>Gv(n,i)):Gv(n,o)}return t.innerType._zod.run(n,r)}}),vR=xe("$ZodExactOptional",(e,t)=>{$1.init(e,t),_n(e,"values",n=>n.def.innerType._zod.values),_n(e,"pattern",n=>n.def.innerType._zod.pattern),e._zod.parse=(n,r)=>t.innerType._zod.run(n,r)}),bR=xe("$ZodNullable",(e,t)=>{Dn.init(e,t),_n(e,"optin",n=>n.def.innerType._zod.optin),_n(e,"optout",n=>n.def.innerType._zod.optout),_n(e,"pattern",n=>{const r=n.def.innerType._zod.pattern;return r?new RegExp(`^(${Rg(r.source)}|null)$`):void 0}),_n(e,"values",n=>n.def.innerType._zod.values?new Set([...n.def.innerType._zod.values,null]):void 0),e._zod.parse=(n,r)=>n.value===null?n:t.innerType._zod.run(n,r)}),xR=xe("$ZodDefault",(e,t)=>{Dn.init(e,t),e._zod.optin="defaulted",_n(e,"values",n=>n.def.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);if(n.value===void 0)return n.value=t.defaultValue,n;const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(i=>Vv(i,t)):Vv(o,t)}});function Vv(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const ER=xe("$ZodPrefault",(e,t)=>{Dn.init(e,t),e._zod.optin="defaulted",_n(e,"values",n=>n.def.innerType._zod.values),e._zod.parse=(n,r)=>(r.direction==="backward"||n.value===void 0&&(n.value=t.defaultValue),t.innerType._zod.run(n,r))}),SR=xe("$ZodNonOptional",(e,t)=>{Dn.init(e,t),_n(e,"values",n=>{const r=n.def.innerType._zod.values;return r?new Set([...r].filter(o=>o!==void 0)):void 0}),e._zod.parse=(n,r)=>{const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(i=>Yv(i,e)):Yv(o,e)}});function Yv(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 Xv(e,t,n,r){return t.issues.length?(e.value=n.catchValue({...t,value:e.value,error:{issues:t.issues.map(o=>cl(o,r,wi()))},input:e.value}),e):(e.value=t.value,t.memo&&(e.memo=!0),e)}const _R=xe("$ZodCatch",(e,t)=>{Dn.init(e,t),_n(e,"optin",n=>n.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),_n(e,"optout",n=>n.def.innerType._zod.optout),_n(e,"values",n=>n.def.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);const o=t.innerType._zod.run({value:n.value,issues:[]},r);return o instanceof Promise?o.then(i=>Xv(n,i,t,r)):Xv(n,o,t,r)}}),NR=xe("$ZodPipe",(e,t)=>{Dn.init(e,t),_n(e,"values",n=>n.def.in._zod.values),_n(e,"optin",n=>n.def.in._zod.optin),_n(e,"optout",n=>n.def.out._zod.optout),_n(e,"propValues",n=>n.def.in._zod.propValues),e._zod.parse=(n,r)=>{if(r.direction==="backward"){const i=t.out._zod.run(n,r);return i instanceof Promise?i.then(l=>ud(l,t.in,r)):ud(i,t.in,r)}const o=t.in._zod.run(n,r);return o instanceof Promise?o.then(i=>ud(i,t.out,r)):ud(o,t.out,r)}});function ud(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 TR=xe("$ZodReadonly",(e,t)=>{Dn.init(e,t),_n(e,"propValues",n=>n.def.innerType._zod.propValues),_n(e,"values",n=>n.def.innerType._zod.values),_n(e,"optin",n=>{var r,o;return(o=(r=n.def.innerType)==null?void 0:r._zod)==null?void 0:o.optin}),_n(e,"optout",n=>{var r,o;return(o=(r=n.def.innerType)==null?void 0:r._zod)==null?void 0:o.optout}),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(Qv):Qv(o)}});function Qv(e){return e.memo||(e.value=Object.freeze(e.value)),e}const jR=xe("$ZodCustom",(e,t)=>{ao.init(e,t),Dn.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=>Jv(i,n,r,e));Jv(o,n,r,e)}});function Jv(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(Rc(o))}}class CR extends Error{constructor(){super("Cannot parse a reference cycle that closes through a transform"),this.name="ZodCyclicError"}}const xm="~memo",e0=[];function Ip(e){return e.map(t=>t.path?{...t,path:t.path.slice()}:{...t})}const t0=new WeakMap;function O1(e,t){const n=t0.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)&&O1(c,t)&&(r=!0)},i=e._zod.def;switch(i.type){case"object":{for(const c of Reflect.ownKeys(i.shape))o(i.shape[c]);o(i.catchall);break}case"array":o(i.element);break;case"tuple":for(const c of i.items)o(c);o(i.rest);break;case"record":case"map":o(i.keyType),o(i.valueType);break;case"set":o(i.valueType);break;case"union":for(const c of i.options)o(c);break;case"intersection":o(i.left),o(i.right);break;case"optional":case"nullable":case"default":case"prefault":case"catch":case"readonly":case"nonoptional":case"promise":case"success":o(i.innerType);break;case"pipe":o(i.in),o(i.out);break;case"function":o(i.input),o(i.output);break;case"lazy":o(e._zod.innerType);break;case"template_literal":case"string":case"number":case"int":case"boolean":case"bigint":case"symbol":case"undefined":case"null":case"void":case"never":case"any":case"unknown":case"date":case"nan":case"enum":case"literal":case"file":case"transform":case"custom":break;default:for(const c in i){const u=Object.getOwnPropertyDescriptor(i,c);if(!u||u.get)continue;const h=u.value;if(!(!h||typeof h!="object")){if(h._zod)o(h);else if(Array.isArray(h))for(const p of h)o(p)}}}return t.delete(e),t0.set(e,r),r}function AR(e,t){let n=e.buckets.get(t);return n||(n=new Map,e.buckets.set(t,n)),n}let dd;const fd=[],IR={alloc(e,t,n){const r=dd;if(!r)return n;dd=void 0;const o={value:n,issues:null};return r.set(t.value,o),fd.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"&&$R(i,o.value))throw new CR;return n(o,i)};e._zod.parse=r,e._zod.run===n&&(e._zod.run=r)})},attach(e){var t;let n,r,o;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{const i=e._zod.parse,l=(c,u)=>{if(n===void 0&&(n=O1(e,new Set),!n))return e._zod.parse=i,e._zod.run===l&&(e._zod.run=i),i(c,u);const h=c.value;if(h===null||typeof h!="object")return i(c,u);let p=u[xm];p||(p={buckets:new Map,backEdges:void 0},u[xm]=p);let m;r===u?m=o:(m=AR(p,e),r=u,o=m);const k=m.get(h);if(k)return c.value=k.value,k.issues?k.issues.length&&c.issues.push(...Ip(k.issues)):(c.memo=!0,p.backEdges??(p.backEdges=new Set),p.backEdges.add(k.value)),c;dd=m;const g=fd.length,y=i(c,u);dd=void 0;const b=fd.length>g?fd.pop():void 0;return y instanceof Promise?y.then(S=>(b&&(b.issues=S.issues.length?Ip(S.issues):e0),S)):(b&&(b.issues=y.issues.length?Ip(y.issues):e0),y)};e._zod.parse=l,e._zod.run===i&&(e._zod.run=l)})}};function RR(){return IR}function $R(e,t){var r;const n=(r=e[xm])==null?void 0:r.backEdges;return n!==void 0&&t!==null&&typeof t=="object"&&n.has(t)}const OR=()=>{const e={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"},map:{unit:"entries",verb:"to have"}};function t(i){return e[i]??null}const n={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",mac:"MAC address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",credit_card:"credit card number",jwt:"JWT",template_literal:"input"},r={nan:"NaN"};function o(i,l){return i==="number"&&typeof l=="number"&&!Number.isFinite(l)?String(l):r[i]??i}return i=>{switch(i.code){case"invalid_type":{const l=o(i.expected),c=pA(i.input),u=o(c,i.input);return`Invalid input: expected ${l}, received ${u}`}case"invalid_value":return i.values.length===1?`Invalid input: expected ${p1(i.values[0])}`:`Invalid option: expected one of ${Ov(i.values,"|")}`;case"too_big":{const l=i.exact?"exactly ":i.inclusive?"<=":"<",c=t(i.origin);return c?`Too big: expected ${i.origin??"value"} to have ${l}${i.maximum.toString()} ${c.unit??"elements"}`:`Too big: expected ${i.origin??"value"} to be ${l}${i.maximum.toString()}`}case"too_small":{const l=i.exact?"exactly ":i.inclusive?">=":">",c=t(i.origin);return c?`Too small: expected ${i.origin} to have ${l}${i.minimum.toString()} ${c.unit}`:`Too small: expected ${i.origin} to be ${l}${i.minimum.toString()}`}case"invalid_format":{const l=i;return l.format==="starts_with"?`Invalid string: must start with "${l.prefix}"`:l.format==="ends_with"?`Invalid string: must end with "${l.suffix}"`:l.format==="includes"?`Invalid string: must include "${l.includes}"`:l.format==="regex"?`Invalid string: must match pattern ${l.pattern}`:`Invalid ${n[l.format]??i.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${i.divisor}`;case"unrecognized_keys":return`Unrecognized key${i.keys.length>1?"s":""}: ${Ov(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 MR(){return{localeError:OR()}}var n0;class PR{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...n){const r=n[0];return this._map.set(t,r),r&&typeof r=="object"&&"id"in r&&this._idmap.set(r.id,t),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(t){const n=this._map.get(t);return n&&typeof n=="object"&&"id"in n&&this._idmap.delete(n.id),this._map.delete(t),this}get(t){const n=t._zod.parent;if(n){const r={...this.get(n)??{}};delete r.id;const o={...r,...this._map.get(t)};return Object.keys(o).length?o:void 0}return this._map.get(t)}has(t){return this._map.has(t)}}function LR(){return new PR}(n0=globalThis).__zod_globalRegistry??(n0.__zod_globalRegistry=LR());const fc=globalThis.__zod_globalRegistry;function DR(e,t){return new e({type:"string",...ht(t)})}function zR(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...ht(t)})}function FR(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...ht(t)})}function BR(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...ht(t)})}function UR(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...ht(t)})}function HR(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...ht(t)})}function WR(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...ht(t)})}function KR(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...ht(t)})}function ZR(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...ht(t)})}function qR(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...ht(t)})}function GR(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...ht(t)})}function VR(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...ht(t)})}function YR(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...ht(t)})}function XR(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...ht(t)})}function QR(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...ht(t)})}function JR(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...ht(t)})}function e$(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...ht(t)})}function t$(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...ht(t)})}function n$(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...ht(t)})}function r$(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...ht(t)})}function o$(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...ht(t)})}function s$(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...ht(t)})}function i$(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...ht(t)})}function a$(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...ht(t)})}function l$(e,t){return new e({type:"string",format:"date",check:"string_format",...ht(t)})}function c$(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...ht(t)})}function u$(e,t){return new e({type:"string",format:"duration",check:"string_format",...ht(t)})}function d$(e,t){return new e({type:"number",checks:[],...ht(t)})}function f$(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...ht(t)})}function h$(e,t){return new e({type:"boolean",...ht(t)})}function p$(e){return new e({type:"unknown"})}function m$(e,t){return new e({type:"never",...ht(t)})}function r0(e,t){return new x1({check:"less_than",...ht(t),value:e,inclusive:!1})}function Rp(e,t){return new x1({check:"less_than",...ht(t),value:e,inclusive:!0})}function o0(e,t){return new E1({check:"greater_than",...ht(t),value:e,inclusive:!1})}function $p(e,t){return new E1({check:"greater_than",...ht(t),value:e,inclusive:!0})}function s0(e,t){return new pI({check:"multiple_of",...ht(t),value:e})}function M1(e,t){return new gI({check:"max_length",...ht(t),maximum:e})}function qd(e,t){return new kI({check:"min_length",...ht(t),minimum:e})}function P1(e,t){return new wI({check:"length_equals",...ht(t),length:e})}function g$(e,t){return new yI({check:"string_format",format:"regex",...ht(t),pattern:e})}function k$(e){return new vI({check:"string_format",format:"lowercase",...ht(e)})}function w$(e){return new bI({check:"string_format",format:"uppercase",...ht(e)})}function y$(e,t){return new xI({check:"string_format",format:"includes",...ht(t),includes:e})}function v$(e,t){return new EI({check:"string_format",format:"starts_with",...ht(t),prefix:e})}function b$(e,t){return new SI({check:"string_format",format:"ends_with",...ht(t),suffix:e})}function ul(e){return new _I({check:"overwrite",tx:e})}function x$(e){return ul(t=>t.normalize(e))}function E$(){return ul(e=>e.trim())}function S$(){return ul(e=>e.toLowerCase())}function _$(){return ul(e=>e.toUpperCase())}function N$(){return ul(e=>tA(e))}function T$(e,t,n){return new e({type:"array",element:t,...ht(n)})}function j$(e,t,n){return new e({type:"custom",check:"custom",fn:t,...ht(n)})}function C$(e,t){const n=A$(r=>(r.addIssue=o=>{if(typeof o=="string")r.issues.push(Rc(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(Rc(i))}},e(r.value,r)),t);return n}function A$(e,t){const n=new ao({check:"custom",...ht(t)});return n._zod.check=e,n}function bc(e,...t){for(const n of t)for(const r of Reflect.ownKeys(n))Object.prototype.propertyIsEnumerable.call(n,r)&&io(e,r,n[r]);return e}function L1(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)??fc,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 di(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 pr(e,t,n={path:[],schemaPath:[]}){var p,m;var r;const o=e._zod.def,i=t.seen.get(e);if(i)return i.count++,n.schemaPath.includes(e)&&(i.cycle=n.path),i.schema;const l={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,l),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;const c=(m=(p=e._zod).toJSONSchema)==null?void 0:m.call(p);if(c)l.schema=c;else{const k={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,l.schema,k);else{const y=l.schema,b=t.processors[o.type];if(!b)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${o.type}`);b(e,t,y,k)}const g=e._zod.parent;g&&(l.ref||(l.ref=g),pr(g,t,k),t.seen.get(g).isParent=!0)}const u=t.metadataRegistry.get(e);return u&&bc(l.schema,u),t.io==="input"&&Hr(e)&&(delete l.schema.examples,delete l.schema.default),t.io==="input"&&"_prefault"in l.schema&&((r=l.schema).default??(r.default=l.schema._prefault)),delete l.schema._prefault,t.seen.get(e).schema}function i0(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function D1(e,t){var l,c,u,h;const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");if(e.external&&e.sharedDefsExtractedFor===e.external)return;const r=new Map;for(const p of e.seen.entries()){const m=(l=e.metadataRegistry.get(p[0]))==null?void 0:l.id;if(m){const k=r.get(m);if(k&&k!==p[0])throw new Error(`Duplicate schema id "${m}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(m,p[0])}}const o=p=>{var b;const m=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){const S=(b=e.external.registry.get(p[0]))==null?void 0:b.id,j=e.external.uri??(N=>N);if(S)return{ref:j(S)};const E=p[1].defId??p[1].schema.id??`schema${e.counter++}`;return p[1].defId=E,{defId:E,ref:`${j("__shared")}#/${m}/${i0(E)}`}}const k="#",g=`${k}/${m}/`;if(p[1]===n&&!p[1].schema.id)return{ref:k};const y=p[1].schema.id??`__schema${e.counter++}`;return{defId:y,ref:g+i0(y)}},i=p=>{if(p[1].schema.$ref)return;const m=p[1],{ref:k,defId:g}=o(p);m.def={...m.schema},g&&(m.defId=g);const y=m.schema;for(const b in y)delete y[b];y.$ref=k};if(e.cycles==="throw")for(const p of e.seen.entries()){const m=p[1];if(m.cycle)throw new Error(`Cycle detected: #/${(c=m.cycle)==null?void 0:c.join("/")}/<root>
|
|
92
|
+
|
|
93
|
+
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const p of e.seen.entries()){const m=p[1];if(t===p[0]){i(p);continue}if(e.external){const g=(u=e.external.registry.get(p[0]))==null?void 0:u.id;if(t!==p[0]&&g){i(p);continue}}if((h=e.metadataRegistry.get(p[0]))==null?void 0:h.id){i(p);continue}if(m.cycle){i(p);continue}if(m.count>1&&e.reused==="ref"){i(p);continue}}e.external&&(e.sharedDefsExtractedFor=e.external)}function z1(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;z1(r);const o=Object.keys(r);if(o.length!==1||o[0]!=="type")return;const i=r.type;for(const l of Array.isArray(i)?i:[i]){if(typeof l!="string")return;n.includes(l)||n.push(l)}}delete e.anyOf,e.type=n.length===1?n[0]:n}const F1=new Set(["type","properties","required","additionalProperties"]),a0=["oneOf","anyOf"];function l0(e){const t=e.additionalProperties;return t===void 0||t===!1||typeof t!="object"||t===null?null:Object.keys(t).length?t:null}function Em(e){var i;const t=[];for(const l of e){if(typeof l!="object"||l.type!=="object")return null;for(const c in l)if(!F1.has(c))return null;t.push(l)}const n={},r=new Set;for(const l of t){for(const c in l.properties){if(Object.prototype.hasOwnProperty.call(n,c))continue;const u=[];for(const p of t){const m=((i=p.properties)==null?void 0:i[c])??l0(p);m!=null&&(u.some(k=>JSON.stringify(k)===JSON.stringify(m))||u.push(m))}const h=u.length===1?u[0]:Em(u)??{allOf:u};io(n,c,h)}for(const c of l.required??[])r.add(c)}const o={type:"object",properties:n};if(r.size&&(o.required=[...r]),t.every(l=>l.additionalProperties===!1))o.additionalProperties=!1;else{const l=[];for(const c of t){const u=l0(c);u&&!l.some(h=>JSON.stringify(h)===JSON.stringify(u))&&l.push(u)}l.length===1?o.additionalProperties=l[0]:l.length>1&&(o.additionalProperties={allOf:l})}return o}function I$(e){const t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(const o of F1)if(o in e)return;const n=t.filter(o=>a0.some(i=>Array.isArray(o[i])));let r=null;if(!n.length)r=Em(t);else{const o=n[0],i=a0.find(u=>Array.isArray(o[u]));if(Object.keys(o).length!==1)return;const l=t.filter(u=>u!==o),c=o[i].map(u=>Em([...l,u]));if(c.some(u=>!u))return;r={[i]:c}}r&&(delete e.allOf,bc(e,r))}function B1(e,t){var c,u,h,p;const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=m=>{const k=e.seen.get(m);if(k.ref===null)return;const g=k.def??k.schema,y={...g},b=k.ref;if(k.ref=null,b){r(b);const j=e.seen.get(b),E=j.schema;if(E.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(g.allOf=g.allOf??[],g.allOf.push(E)):bc(g,E),bc(g,y),m._zod.parent===b)for(const A in g)A==="$ref"||A==="allOf"||A in y||delete g[A];if(E.$ref&&j.def)for(const A in g)A==="$ref"||A==="allOf"||A in j.def&&JSON.stringify(g[A])===JSON.stringify(j.def[A])&&delete g[A]}const S=m._zod.parent;if(S&&S!==b){r(S);const j=e.seen.get(S);if(j!=null&&j.schema.$ref&&(g.$ref=j.schema.$ref,j.def))for(const E in g)E==="$ref"||E==="allOf"||E in j.def&&JSON.stringify(g[E])===JSON.stringify(j.def[E])&&delete g[E]}e.override({zodSchema:m,jsonSchema:g,path:k.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())z1(m[1].def??m[1].schema);for(const m of e.deferred)m();if(e.intersections.length){const m=new Map;for(const k of e.seen.values())for(const g of[k.schema,k.def]){const y=g==null?void 0:g.allOf;if(!Array.isArray(y))continue;const b=m.get(y);b?b.push(g):m.set(y,[g])}for(const k of e.intersections)for(const g of m.get(k)??[])I$(g)}}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)}bc(o,n.defId?n.schema:n.def??n.schema);const i=(h=e.metadataRegistry.get(t))==null?void 0:h.id;i!==void 0&&o.id===i&&delete o.id;const l=((p=e.external)==null?void 0:p.defs)??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(const m of e.seen.entries()){const k=m[1];k.def&&k.defId&&(k.def.id===k.defId&&delete k.def.id,io(l,k.defId,k.def))}e.external&&(e.sharedEmitDoneFor=e.external),e.external||Object.keys(l).length>0&&(e.target==="draft-2020-12"?o.$defs=l:o.definitions=l);try{const m=JSON.parse(JSON.stringify(o));return Object.defineProperty(m,"~standard",{value:{...t["~standard"],jsonSchema:{input:Gd(t,"input",e.processors),output:Gd(t,"output",e.processors)}},enumerable:!1,writable:!1}),m}catch{throw new Error("Error converting schema to JSON.")}}function Hr(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 Hr(r.element,n);if(r.type==="set")return Hr(r.valueType,n);if(r.type==="lazy")return Hr(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 Hr(r.innerType,n);if(r.type==="intersection")return Hr(r.left,n)||Hr(r.right,n);if(r.type==="record"||r.type==="map")return Hr(r.keyType,n)||Hr(r.valueType,n);if(r.type==="pipe")return e._zod.traits.has("$ZodCodec")?!0:Hr(r.in,n)||Hr(r.out,n);if(r.type==="object"){for(const o in r.shape)if(Hr(r.shape[o],n))return!0;return!1}if(r.type==="union"){for(const o of r.options)if(Hr(o,n))return!0;return!1}if(r.type==="tuple"){for(const o of r.items)if(Hr(o,n))return!0;return!!(r.rest&&Hr(r.rest,n))}return!1}const R$=(e,t={})=>n=>{const r=L1({...n,processors:t});return pr(e,r),D1(r,e),B1(r,e)},Gd=(e,t,n={})=>r=>{const{libraryOptions:o,target:i}=r??{},l=L1({...o??{},target:i,io:t,processors:n});return pr(e,l),D1(l,e),B1(l,e)},$$={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},O$=(e,t,n,r)=>{const o=n;o.type="string";const{minimum:i,maximum:l,format:c,patterns:u,contentEncoding:h,laxFormat:p}=e._zod.bag;if(typeof i=="number"&&(o.minLength=i),typeof l=="number"&&(o.maxLength=l),c&&(o.format=$$[c]??c,o.format===""&&delete o.format,(c==="time"||p)&&delete o.format),h&&(o.contentEncoding=h),u&&u.size>0){const m=[...u];m.length===1?o.pattern=m[0].source:m.length>1&&(o.allOf=[...m.map(k=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:k.source}))])}},M$=(e,t,n,r)=>{const o=n,{minimum:i,maximum:l,format:c,multipleOf:u,exclusiveMaximum:h,exclusiveMinimum:p}=e._zod.bag;typeof c=="string"&&c.includes("int")?o.type="integer":o.type="number";const m=typeof p=="number"&&p>=(i??Number.NEGATIVE_INFINITY),k=typeof h=="number"&&h<=(l??Number.POSITIVE_INFINITY),g=t.target==="draft-04"||t.target==="openapi-3.0";m?g?(o.minimum=p,o.exclusiveMinimum=!0):o.exclusiveMinimum=p:typeof i=="number"&&(o.minimum=i),k?g?(o.maximum=h,o.exclusiveMaximum=!0):o.exclusiveMaximum=h:typeof l=="number"&&(o.maximum=l),typeof u=="number"&&(Number.isFinite(u)&&u!==0?o.multipleOf=Math.abs(u):di(e,t,o,r,`A multipleOf divisor of ${u} cannot be represented in JSON Schema`))},P$=(e,t,n,r)=>{n.type="boolean"},L$=(e,t,n,r)=>{n.not={}},D$=(e,t,n,r)=>{},z$=(e,t,n,r)=>{const o=e._zod.def,i=d1(o.entries);if(i.length===0){n.not={};return}i.every(l=>typeof l=="number")&&(n.type="number"),i.every(l=>typeof l=="string")&&(n.type="string"),n.enum=i},F$=(e,t,n,r)=>{const o=e._zod.def;if(o.values.length===0){n.not={};return}const i=[];for(const l of o.values)if(l===void 0){if(di(e,t,n,r,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof l=="bigint"){if(di(e,t,n,r,"BigInt literals cannot be represented in JSON Schema"))return;i.push(Number(l))}else i.push(l);if(i.length!==0)if(i.length===1){const l=i[0];n.type=l===null?"null":typeof l,t.target==="draft-04"||t.target==="openapi-3.0"?n.enum=[l]:n.const=l}else i.every(l=>typeof l=="number")&&(n.type="number"),i.every(l=>typeof l=="string")&&(n.type="string"),i.every(l=>typeof l=="boolean")&&(n.type="boolean"),i.every(l=>l===null)&&(n.type="null"),n.enum=i},B$=(e,t,n,r)=>{di(e,t,n,r,"Custom types cannot be represented in JSON Schema")},U$=(e,t,n,r)=>{di(e,t,n,r,"Transforms cannot be represented in JSON Schema")},H$=(e,t,n,r)=>{const o=n,i=e._zod.def,{minimum:l,maximum:c}=e._zod.bag;typeof l=="number"&&(o.minItems=l),typeof c=="number"&&(o.maxItems=c),o.type="array",o.items=pr(i.element,t,{...r,path:[...r.path,"items"]})};function Vd(e){const t=e._zod.def;return t.type==="pipe"&&t.in._zod.traits.has("$ZodTransform")?Vd(t.out):t.type==="catch"?Vd(t.innerType):e._zod.optin}const W$=(e,t,n,r)=>{var p;const o=n,i=e._zod.def,l=i.shape;if(Object.getOwnPropertySymbols(l).length&&di(e,t,o,r,"Symbol keys cannot be represented in JSON Schema"))return;o.type="object",o.properties={};for(const m in l)io(o.properties,m,pr(l[m],t,{...r,path:[...r.path,"properties",m]}));const u=new Set(Object.keys(l)),h=new Set([...u].filter(m=>{const k=i.shape[m];return t.io==="input"?Vd(k)===void 0:k._zod.optout===void 0}));h.size>0&&(o.required=Array.from(h)),((p=i.catchall)==null?void 0:p._zod.def.type)==="never"?o.additionalProperties=!1:i.catchall?i.catchall&&(o.additionalProperties=pr(i.catchall,t,{...r,path:[...r.path,"additionalProperties"]})):t.io==="output"&&(o.additionalProperties=!1)},K$=(e,t,n,r)=>{const o=e._zod.def,i=o.inclusive===!1,l=o.options.map((c,u)=>pr(c,t,{...r,path:[...r.path,i?"oneOf":"anyOf",u]}));i?n.oneOf=l:n.anyOf=l},Z$=(e,t,n,r)=>{const o=e._zod.def,i=pr(o.left,t,{...r,path:[...r.path,"allOf",0]}),l=pr(o.right,t,{...r,path:[...r.path,"allOf",1]}),c=h=>"allOf"in h&&Object.keys(h).length===1,u=[...c(i)?i.allOf:[i],...c(l)?l.allOf:[l]];n.allOf=u,t.intersections.push(u)},q$=(e,t,n,r)=>{const o=n,i=e._zod.def;o.type="array";const l=t.target==="draft-2020-12"?"prefixItems":"items",c=t.target==="draft-2020-12"||t.target==="openapi-3.0"?"items":"additionalItems",u=i.items.map((b,S)=>pr(b,t,{...r,path:[...r.path,l,S]})),h=i.rest?pr(i.rest,t,{...r,path:[...r.path,c,...t.target==="openapi-3.0"?[i.items.length]:[]]}):null;let p=i.items.length;for(;p>0;){const b=i.items[p-1];if(!(t.io==="input"?Vd(b)!==void 0:b._zod.optout==="optional"))break;p--}const m=i.items.length,k=!i.rest;t.target==="draft-2020-12"?(o.prefixItems=u,k?o.items=!1:h&&(o.items=h),p>0&&(o.minItems=p),k&&(o.maxItems=m)):t.target==="openapi-3.0"?(o.items={anyOf:u},h&&o.items.anyOf.push(h),p>0&&(o.minItems=p),k&&(o.maxItems=m)):(o.items=u,k?o.additionalItems=!1:h&&(o.additionalItems=h),p>0&&(o.minItems=p),k&&(o.maxItems=m));const{minimum:g,maximum:y}=e._zod.bag;typeof g=="number"&&(o.minItems=g),typeof y=="number"&&(o.maxItems=y)},G$=(e,t,n,r)=>{const o=e._zod.def,i=pr(o.innerType,t,r),l=t.seen.get(e);t.target==="openapi-3.0"?(l.ref=o.innerType,n.nullable=!0):n.anyOf=[i,{type:"null"}]},V$=(e,t,n,r)=>{const o=e._zod.def;pr(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType},zg=Symbol();function U1(e,t,n,r,o){let i=!1;const l=JSON.stringify(e,(c,u)=>typeof u!="bigint"?u:(i=!0,null));return i?(di(t,n,r,o,"BigInt defaults cannot be represented in JSON Schema"),zg):JSON.parse(l)}const Y$=(e,t,n,r)=>{const o=e._zod.def;pr(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType;const l=U1(o.defaultValue,e,t,n,r);l!==zg&&(n.default=l)},X$=(e,t,n,r)=>{const o=e._zod.def;pr(o.innerType,t,r);const i=t.seen.get(e);if(i.ref=o.innerType,t.io!=="input")return;const l=U1(o.defaultValue,e,t,n,r);l!==zg&&(n._prefault=l)},Q$=(e,t,n,r)=>{const o=e._zod.def;pr(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType;let l;try{l=o.catchValue(void 0)}catch{di(e,t,n,r,"Dynamic catch values are not supported in JSON Schema");return}n.default=l},J$=(e,t,n,r)=>{const o=e._zod.def,i=o.in._zod.traits.has("$ZodTransform"),l=t.io==="input"?i?o.out:o.in:o.out;pr(l,t,r);const c=t.seen.get(e);c.ref=l},eO=(e,t,n,r)=>{const o=e._zod.def;pr(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType,n.readOnly=!0},H1=(e,t,n,r)=>{const o=e._zod.def;pr(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType},c0=new WeakSet([Object.prototype,Error.prototype]);function hd(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 tO=(e,t)=>{w1.init(e,t),e.name="ZodError";const n=Object.getPrototypeOf(e);c0.has(n)||(c0.add(n),hd(n,"format",r=>o=>jA(r,o)),hd(n,"flatten",r=>o=>TA(r,o)),hd(n,"addIssue",r=>o=>{r.issues.push(o),r.message=JSON.stringify(r.issues,wm,2)}),hd(n,"addIssues",r=>o=>{r.issues.push(...o),r.message=JSON.stringify(r.issues,wm,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},Io=xe("ZodError",tO,void 0,{Parent:Error}),nO=Mg(Io),rO=Pg(Io),oO=Tf(Io),sO=jf(Io),iO=IA(Io),aO=RA(Io),lO=$A(Io),cO=OA(Io),uO=MA(Io),dO=PA(Io),fO=LA(Io),hO=DA(Io);function pO(){Go.localeError||wi(MR())}function Af(){Go.memoizer||wi({memoizer:RR()})}const Wn=xe("ZodType",(e,t)=>(pO(),Dn.init(e,t),e.def=t,e.type=t.type,e),{check(...e){const t=this.def;return this.clone(gi(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 ki(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(f2(e,t))},superRefine(e,t){return this.check(h2(e,t))},overwrite(e){return this.check(ul(e))},optional(){return f0(this)},exactOptional(){return e2(this)},nullable(){return h0(this)},nullish(){return f0(h0(this))},nonoptional(e){return i2(this,e)},array(){return Xi(this)},or(e){return KO([this,e])},and(e){return VO(this,e)},transform(e){return p0(this,JO(e))},default(e){return r2(this,e)},prefault(e){return s2(this,e)},catch(e){return l2(this,e)},pipe(e){return p0(this,e)},readonly(){return d2(this)},describe(e){const t=this.clone();return fc.add(t,{description:e}),t},meta(...e){if(e.length===0)return fc.get(this);const t=this.clone();return fc.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 m1(this,"~standard",{...S1(this),jsonSchema:{input:Gd(this,"input"),output:Gd(this,"output")}})},set"~standard"(e){tl(this,"~standard",e)},parse:function e(t,n){return nO(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await rO(this,t,n,{callee:e})},safeParse(e,t){return oO(this,e,t)},async safeParseAsync(e,t){return sO(this,e,t)},get spa(){return this==null?void 0:this.safeParseAsync},set spa(e){tl(this,"spa",e)},encode:function e(t,n){return iO(this,t,n,{callee:e})},decode:function e(t,n){return aO(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await lO(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await cO(this,t,n,{callee:e})},safeEncode(e,t){return uO(this,e,t)},safeDecode(e,t){return dO(this,e,t)},async safeEncodeAsync(e,t){return fO(this,e,t)},async safeDecodeAsync(e,t){return hO(this,e,t)},toJSONSchema(e){return R$(this,{})(e)},get description(){var e;return(e=fc.get(this))==null?void 0:e.description},get _def(){return this._zod.def}}),W1=xe("_ZodString",(e,t)=>{Dg.init(e,t),Wn.init(e,t),e._zod.processJSONSchema=(r,o,i)=>O$(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(g$(...e))},includes(...e){return this.check(y$(...e))},startsWith(...e){return this.check(v$(...e))},endsWith(...e){return this.check(b$(...e))},min(...e){return this.check(qd(...e))},max(...e){return this.check(M1(...e))},length(...e){return this.check(P1(...e))},nonempty(...e){return this.check(qd(1,...e))},lowercase(e){return this.check(k$(e))},uppercase(e){return this.check(w$(e))},trim(){return this.check(E$())},normalize(...e){return this.check(x$(...e))},toLowerCase(){return this.check(S$())},toUpperCase(){return this.check(_$())},slugify(){return this.check(N$())}}),mO=xe("ZodString",(e,t)=>{Dg.init(e,t),W1.init(e,t)},{email(e){return this.check(zR(vO,e))},url(e){return this.check(KR(xO,e))},jwt(e){return this.check(i$(LO,e))},emoji(e){return this.check(ZR(EO,e))},guid(e){return this.check(FR(bO,e))},uuid(e){return this.check(BR(pd,e))},uuidv4(e){return this.check(UR(pd,e))},uuidv6(e){return this.check(HR(pd,e))},uuidv7(e){return this.check(WR(pd,e))},nanoid(e){return this.check(qR(SO,e))},cuid(e){return this.check(GR(_O,e))},cuid2(e){return this.check(VR(NO,e))},ulid(e){return this.check(YR(TO,e))},base64(e){return this.check(r$(OO,e))},base64url(e){return this.check(o$(MO,e))},xid(e){return this.check(XR(jO,e))},ksuid(e){return this.check(QR(CO,e))},ipv4(e){return this.check(JR(AO,e))},ipv6(e){return this.check(e$(IO,e))},cidrv4(e){return this.check(t$(RO,e))},cidrv6(e){return this.check(n$($O,e))},e164(e){return this.check(s$(PO,e))},datetime(e){return this.check(a$(gO,e))},date(e){return this.check(l$(kO,e))},time(e){return this.check(c$(wO,e))},duration(e){return this.check(u$(yO,e))}});function Nn(e){return DR(mO,e)}const Kn=xe("ZodStringFormat",(e,t)=>{zn.init(e,t),W1.init(e,t)}),gO=xe("ZodISODateTime",(e,t)=>{WI.init(e,t),Kn.init(e,t)}),kO=xe("ZodISODate",(e,t)=>{KI.init(e,t),Kn.init(e,t)}),wO=xe("ZodISOTime",(e,t)=>{ZI.init(e,t),Kn.init(e,t)}),yO=xe("ZodISODuration",(e,t)=>{qI.init(e,t),Kn.init(e,t)}),vO=xe("ZodEmail",(e,t)=>{AI.init(e,t),Kn.init(e,t)}),bO=xe("ZodGUID",(e,t)=>{jI.init(e,t),Kn.init(e,t)}),pd=xe("ZodUUID",(e,t)=>{CI.init(e,t),Kn.init(e,t)}),xO=xe("ZodURL",(e,t)=>{PI.init(e,t),Kn.init(e,t)}),EO=xe("ZodEmoji",(e,t)=>{LI.init(e,t),Kn.init(e,t)}),SO=xe("ZodNanoID",(e,t)=>{DI.init(e,t),Kn.init(e,t)}),_O=xe("ZodCUID",(e,t)=>{zI.init(e,t),Kn.init(e,t)}),NO=xe("ZodCUID2",(e,t)=>{FI.init(e,t),Kn.init(e,t)}),TO=xe("ZodULID",(e,t)=>{BI.init(e,t),Kn.init(e,t)}),jO=xe("ZodXID",(e,t)=>{UI.init(e,t),Kn.init(e,t)}),CO=xe("ZodKSUID",(e,t)=>{HI.init(e,t),Kn.init(e,t)}),AO=xe("ZodIPv4",(e,t)=>{GI.init(e,t),Kn.init(e,t)}),IO=xe("ZodIPv6",(e,t)=>{YI.init(e,t),Kn.init(e,t)}),RO=xe("ZodCIDRv4",(e,t)=>{XI.init(e,t),Kn.init(e,t)}),$O=xe("ZodCIDRv6",(e,t)=>{JI.init(e,t),Kn.init(e,t)}),OO=xe("ZodBase64",(e,t)=>{eR.init(e,t),Kn.init(e,t)}),MO=xe("ZodBase64URL",(e,t)=>{nR.init(e,t),Kn.init(e,t)}),PO=xe("ZodE164",(e,t)=>{rR.init(e,t),Kn.init(e,t)}),LO=xe("ZodJWT",(e,t)=>{sR.init(e,t),Kn.init(e,t)}),K1=xe("ZodNumber",(e,t)=>{C1.init(e,t),Wn.init(e,t),e._zod.processJSONSchema=(r,o,i)=>M$(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(o0(e,t))},gte(e,t){return this.check($p(e,t))},min(e,t){return this.check($p(e,t))},lt(e,t){return this.check(r0(e,t))},lte(e,t){return this.check(Rp(e,t))},max(e,t){return this.check(Rp(e,t))},int(e){return this.check(u0(e))},safe(e){return this.check(u0(e))},positive(e){return this.check(o0(0,e))},nonnegative(e){return this.check($p(0,e))},negative(e){return this.check(r0(0,e))},nonpositive(e){return this.check(Rp(0,e))},multipleOf(e,t){return this.check(s0(e,t))},step(e,t){return this.check(s0(e,t))},finite(){return this}});function Yi(e){return d$(K1,e)}const DO=xe("ZodNumberFormat",(e,t)=>{iR.init(e,t),K1.init(e,t)});function u0(e){return f$(DO,e)}const zO=xe("ZodBoolean",(e,t)=>{aR.init(e,t),Wn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>P$(e,n,r)});function So(e){return h$(zO,e)}const FO=xe("ZodUnknown",(e,t)=>{lR.init(e,t),Wn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>D$()});function d0(){return p$(FO)}const BO=xe("ZodNever",(e,t)=>{cR.init(e,t),Wn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>L$(e,n,r)});function UO(e){return m$(BO,e)}const HO=xe("ZodArray",(e,t)=>{Af(),uR.init(e,t),Wn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>H$(e,n,r,o),e.element=t.element},{min(e,t){return this.check(qd(e,t))},nonempty(e){return this.check(qd(1,e))},max(e,t){return this.check(M1(e,t))},length(e,t){return this.check(P1(e,t))},unwrap(){return this.element}});function Xi(e,t){return T$(HO,e,t)}const WO=xe("ZodObject",(e,t)=>{Af(),hR.init(e,t),Wn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>W$(e,n,r,o),yA(e,"shape",n=>n._zod.def.shape,!1)},{keyof(){return xc(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:d0()})},loose(){return this.clone({...this._zod.def,catchall:d0()})},strict(){return this.clone({...this._zod.def,catchall:UO()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return lA(this,e)},safeExtend(e){return cA(this,e)},merge(e){return uA(this,e)},pick(e){return iA(this,e)},omit(e){return aA(this,e)},partial(...e){return Mv(Fg,this,e[0])},exactPartial(...e){return Mv(G1,this,e[0],"exactPartial")},required(...e){return dA(V1,this,e[0])}});function Nr(e,t){const n={type:"object",shape:e??{},...ht(t)};return new WO(n)}const Z1=xe("ZodUnion",(e,t)=>{R1.init(e,t),Wn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>K$(e,n,r,o),e.options=t.options});function KO(e,t){return new Z1({type:"union",options:e,...ht(t)})}const ZO=xe("ZodDiscriminatedUnion",(e,t)=>{Z1.init(e,t),pR.init(e,t)});function qO(e,t,n){return new ZO({type:"union",options:t,discriminator:e,...ht(n)})}const GO=xe("ZodIntersection",(e,t)=>{mR.init(e,t),Wn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Z$(e,n,r,o)});function VO(e,t){return new GO({type:"intersection",left:e,right:t})}const YO=xe("ZodTuple",(e,t)=>{Af(),gR.init(e,t),Wn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>q$(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 Fg({type:"optional",innerType:n}))})}});function q1(e,t,n){const r=t instanceof Dn,o=r?n:t,i=r?t:null;return new YO({type:"tuple",items:e,rest:i,...ht(o)})}const Sm=xe("ZodEnum",(e,t)=>{kR.init(e,t),Wn.init(e,t),e._zod.processJSONSchema=(r,o,i)=>z$(e,r,o),e.enum=t.entries,e.options=Object.values(t.entries);const n=new Set(Object.keys(t.entries));e.extract=(r,o)=>{const i={};for(const l of r)if(n.has(l))i[l]=t.entries[l];else throw new Error(`Key ${l} not found in enum`);return new Sm({...t,checks:[],...ht(o),entries:i})},e.exclude=(r,o)=>{const i={...t.entries};for(const l of r)if(n.has(l))delete i[l];else throw new Error(`Key ${l} not found in enum`);return new Sm({...t,checks:[],...ht(o),entries:i})}});function xc(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(r=>[r,r])):e;return new Sm({type:"enum",entries:n,...ht(t)})}const XO=xe("ZodLiteral",(e,t)=>{wR.init(e,t),Wn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>F$(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 eo(e,t){return new XO({type:"literal",values:Array.isArray(e)?e:[e],...ht(t)})}const QO=xe("ZodTransform",(e,t)=>{Af(),yR.init(e,t),Wn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>U$(e,n,r,o),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new g1(e.constructor.name);n.addIssue=i=>{if(typeof i=="string")n.issues.push(Rc(i,n.value,t));else{const l=i;l.fatal&&(l.continue=!1),l.code??(l.code="custom"),"input"in l||(l.input=n.value),l.inst??(l.inst=e),n.issues.push(Rc(l))}};const o=t.transform(n.value,n);return o instanceof Promise?o.then(i=>(n.value=i,n)):(n.value=o,n)}});function JO(e){return new QO({type:"transform",transform:e})}const Fg=xe("ZodOptional",(e,t)=>{$1.init(e,t),Wn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>H1(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function f0(e){return new Fg({type:"optional",innerType:e})}const G1=xe("ZodExactOptional",(e,t)=>{vR.init(e,t),Wn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>H1(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function e2(e){return new G1({type:"optional",innerType:e})}const t2=xe("ZodNullable",(e,t)=>{bR.init(e,t),Wn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>G$(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function h0(e){return new t2({type:"nullable",innerType:e})}const n2=xe("ZodDefault",(e,t)=>{xR.init(e,t),Wn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Y$(e,n,r,o),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function r2(e,t){return new n2({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():h1(t)}})}const o2=xe("ZodPrefault",(e,t)=>{ER.init(e,t),Wn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>X$(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function s2(e,t){return new o2({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():h1(t)}})}const V1=xe("ZodNonOptional",(e,t)=>{SR.init(e,t),Wn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>V$(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function i2(e,t){return new V1({type:"nonoptional",innerType:e,...ht(t)})}const a2=xe("ZodCatch",(e,t)=>{_R.init(e,t),Wn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Q$(e,n,r,o),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function l2(e,t){return new a2({type:"catch",innerType:e,catchValue:typeof t=="function"?t:bA(t)})}const c2=xe("ZodPipe",(e,t)=>{NR.init(e,t),Wn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>J$(e,n,r,o),e.in=t.in,e.out=t.out});function p0(e,t){return new c2({type:"pipe",in:e,out:t})}const u2=xe("ZodReadonly",(e,t)=>{TR.init(e,t),Wn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>eO(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function d2(e){return new u2({type:"readonly",innerType:e})}const Y1=xe("ZodCustom",(e,t)=>{jR.init(e,t),Wn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>B$(e,n,r,o)});function f2(e,t={}){return j$(Y1,e,t)}function h2(e,t){return C$(e,t)}function p2(e,t={}){const n=new Y1({type:"custom",check:"custom",fn:r=>r instanceof e,abort:!0,...ht(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 m2=["off","tailscale","any"],g2={updates:!0,deploy:!0,remote:"any",agents:null,customAgents:!0,brandedListener:!0,planSignIn:!0};Nr({updates:So().optional(),deploy:So().optional(),remote:xc(m2).optional(),agents:Xi(Nn()).optional(),customAgents:So().optional(),brandedListener:So().optional(),planSignIn:So().optional()});const k2={...g2,source:null,problem:null};function w2(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 Op=6e3,m0=1500;function y2(e){if(e.length<=Op)return e;const t=e.length-Op;return`${e.slice(0,m0)}
|
|
94
|
+
[${t} characters cut here]
|
|
95
|
+
${e.slice(e.length-(Op-m0))}`}const md=109,v2=2e3,b2=1e3,x2=10,E2=2048,Yd=5e6,S2=["image/png","image/jpeg","image/gif","image/webp"],g0=2576,Mp=5*1024*1024,_2=1200,N2=10,T2=1e5,k0=100*1024*1024,j2="pasted-text.txt";function C2(e){return e.t==="term-data"||e.t==="term-snapshot"||e.t==="term-exit"}function A2(e){return e.t==="file-read"||e.t==="file-written"||e.t==="file-blame"}const I2=80;function Bg(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,I2)}}function X1(e){return e.length>=_2||e.split(`
|
|
97
|
+
`).length>=N2}function R2({startLine:e,endLine:t}){return e===t?`${e}`:`${e}-${t}`}function $2(e){return`${e.path.slice(e.path.lastIndexOf("/")+1)} (${R2(e)})`}const O2=/\u001B(?:\[[0-?]*[ -/]*[@-~]|\][^\u0007]*(?:\u0007|\u001B\\))/g;function M2(e){return e.replace(O2,"")}const Q1="Projects";function P2(e){for(const t of e){const n=t.codePointAt(0)??0;if(n<32||n===127)return!0}return!1}function $c(e){const t=e.trim();return t?t.length>100?"that name is too long: keep it under 100 characters":t.includes("/")||t.includes("\\")?"a project name cannot contain a slash":/\s/.test(t)?"a project name cannot contain spaces":P2(t)?"a project name cannot contain control characters":t==="."||t===".."?`"${t}" is not a project name`:t.startsWith("-")||t.startsWith(".")?"a project name cannot start with a dot or a dash":null:"a project name is required"}const L2=/^(?:https?|ssh|git|file):\/\/\S+$/i,J1=/^[\w.-]+@[\w.-]+:\S+$/;function D2(e){const t=e.trim();if(!L2.test(t)&&!J1.test(t))return null;const n=z2(t);return n&&!$c(n)?{url:t,name:n}:null}function z2(e){var o;const t=((o=e.split(/[?#]/)[0])==null?void 0:o.replace(/\/+$/,""))??"";return((J1.test(t)?t.split(":")[1]??"":t).split("/").pop()??"").replace(/\.git$/i,"")}const F2=Nr({component:Nn().nullable(),file:Nn().nullable(),line:Yi().nullable(),callFile:Nn().nullable().default(null),callLine:Yi().nullable().default(null),tag:Nn(),selector:Nn()}),B2=Nr({tag:Nn().max(40),id:Nn().max(200),classes:Xi(Nn().max(120)).max(16),text:Nn().max(200),attrs:Xi(q1([Nn().max(40),Nn().max(200)])).max(12)}),U2=q1([Yi(),Yi()]),H2=F2.extend({classes:Nn(),text:Nn(),html:Nn(),route:Nn(),element:B2}),W2=qO("type",[Nr({type:eo("loaded"),url:Nn(),title:Nn()}),Nr({type:eo("navigated"),url:Nn(),title:Nn().optional()}),Nr({type:eo("traversed"),dir:xc(["back","forward"]).optional()}),Nr({type:eo("title"),title:Nn()}),Nr({type:eo("links"),links:Xi(Nr({path:Nn().max(2048),text:Nn().max(120)})).max(200)}),Nr({type:eo("hmr")}),Nr({type:eo("page-error"),message:Nn(),source:Nn().optional(),line:Yi().optional()}),H2.extend({type:eo("picked"),verb:xc(["chat","code"]).default("chat"),site:xc(["call","source"]).default("source")}),Nr({type:eo("pick-cancel")}),Nr({type:eo("highlight-miss"),path:Nn(),fileMatched:Yi(),withSource:Yi(),ranges:Xi(U2).nullable()}),Nr({type:eo("drag-files"),over:So().default(!0)}),Nr({type:eo("drop-files"),files:Xi(p2(File))}),Nr({type:eo("focus"),gesture:So()}),Nr({type:eo("key"),key:Nn(),code:Nn().optional(),meta:So(),ctrl:So().optional(),shift:So().optional(),alt:So().optional(),up:So().optional()})]);function eE(e){const t=W2.safeParse(e);return t.success?t.data:null}const K2=/["“”]([^"“”]*)["“”]?|(\S+)/g;function tE(e){const t=new Set;for(const n of e.matchAll(K2)){const r=(n[1]??n[2]??"").replace(/\s+/g," ").trim().toLowerCase();r&&t.add(r)}return[...t]}const Z2="now",q2="http://preview.invalid",G2=200;function w0(e){const t=e==null?void 0:e.replace(/\s+/g," ").trim().slice(0,G2).trim();return t||void 0}function If(e){let t;try{t=new URL(e,q2)}catch{return null}if(t.pathname.startsWith("/__toyon"))return null;const n=y0(t.pathname)||"/",r=t.hash.startsWith("#/")?y0(t.hash.split("?")[0]??""):"";return r.length>1?`${n}${r}`:n}const y0=e=>e.replace(/\/+$/,""),V2={static:4,mixed:3.5,param:3,optional:2,"optional-static":2,splat:1},Xd=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");function nE(e){const t=/^\[\[\.\.\.([^\]]*)\]\]$/.exec(e);if(t)return{kind:"splat",name:t[1]||"path",min:0};const n=/^\[\.\.\.([^\]]*)\]$/.exec(e);if(n)return{kind:"splat",name:n[1]||"path",min:1};const r=/^\[\[([^\]]+)\]\]$/.exec(e)??/^:([\w-]+)\?$/.exec(e)??/^\{-\$([\w-]+)\}$/.exec(e);if(r)return{kind:"optional",name:r[1]};const o=/^\[([^\]=]+)(?:=[^\]]*)?\]$/.exec(e)??/^:([\w-]+)$/.exec(e)??/^\$([\w-]+)$/.exec(e);if(o)return{kind:"param",name:o[1]};if(e==="*"||e==="$")return{kind:"splat",name:"path",min:0};if(/^[^[{:$*?]+\?$/.test(e))return{kind:"optional-static",text:e.slice(0,-1)};if(/[[{]/.test(e)){const i=[];let l="",c=0;for(const h of e.matchAll(/\[([^\]=]+)(?:=[^\]]*)?\]|\{\$([\w-]+)\}/g)){const p=e.slice(c,h.index);p&&(i.push({text:p}),l+=Xd(p)),i.push({name:h[1]??h[2]??"param"}),l+="[^/]+?",c=(h.index??0)+h[0].length}const u=e.slice(c);if(u&&(i.push({text:u}),l+=Xd(u)),i.some(h=>"name"in h))return{kind:"mixed",pattern:l,parts:i}}return{kind:"static",text:e}}function Y2(e){const t=e.split("/").filter(Boolean).map(nE);if(t.every(r=>r.kind==="static"))return null;let n="";for(const r of t)r.kind==="static"?n+=`/${Xd(r.text)}`:r.kind==="optional-static"?n+=`(?:/${Xd(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+V2[o.kind],0),statics:t.filter(r=>r.kind==="static").length}}function X2(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 Rf(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(nE))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 Gc={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"}},rE={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"}},Q2={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"}},J2={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"}},eM={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"}},tM={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"}},nM={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"}},rM={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"}},oM={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"}},sM={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"}},iM={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"}},aM={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"}},lM={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"}},cM={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"}},uM={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"}},dM={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"}},fM={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"}},hM={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"}},pM={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"}},mM=[oM,sM,iM,aM,lM,cM,uM,dM,fM,hM,pM],$d=[Gc,rE,Q2,J2,eM,tM,nM,rM,...mM],gM={mode:"dark",light:rE.id,dark:Gc.id},kM=["surface0","surface1","surface2","element0","element1","border0","border1","text0","text1","text2","red","orange","yellow","green","aqua","blue","purple","diffAdd","diffDel"];function wM(e){return`--${e.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`)}`}function v0(e){const t=iE(e);return t>.008856?116*t**(1/3)-16:903.3*t}function oE(e,t){const n=v0(e)+t,r=ra(e);if(!r)return e;let o=0,i=2;for(let l=0;l<24;l++){const c=(o+i)/2,u=nl(Math.min(255,r[0]*c),Math.min(255,r[1]*c),Math.min(255,r[2]*c));v0(u)<n?o=c:i=c}return nl(Math.min(255,r[0]*o),Math.min(255,r[1]*o),Math.min(255,r[2]*o))}function yM(e){return oE(e.colors.surface1,-4)}function vM(e){return oE(e.colors.surface0,-4)}function b0(e){return CM(e,.55)}function bM(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 xM(e){const t={};for(const n of kM)t[wM(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(bM(e)))t[`--syntax-${n}`]=r;return t["--accent"]=Ug(e),t["--fault"]=EM(e),t["--sunken"]=yM(e),t["--sunken-floor"]=vM(e),t["--scrim"]=jM(e.colors.surface0,.7),t["--shadow"]=e.kind==="dark"?"#00000066":"#0000002e",t["--diff-add-word"]=b0(e.colors.diffAdd),t["--diff-del-word"]=b0(e.colors.diffDel),t}function Ug(e){return sE(e.accent??"")??e.colors.orange}function EM(e){return Ug(e)===sE(e.colors.orange)?e.colors.red:e.colors.orange}function SM(e){return e==="system"||e==="daylight"}function Hg(e,t){return e.mode==="system"?t.system?"dark":"light":e.mode==="daylight"?t.daylight?"dark":"light":e.mode}function $f(e,t,n){const r=Hg(e,n);return t.find(o=>o.id===e[r])??$d.find(o=>o.kind===r)??Gc}function _M(e,t){if(e.pair){const l=t.find(c=>c.id===e.pair);if(l&&l.kind!==e.kind)return l}const n=e.kind==="dark"?"light":"dark",r=l=>l.toLowerCase().replace(/\b(dark|light)\b/g,"*").replace(/\s+/g," ").trim(),o=r(e.name);if(!o.includes("*"))return null;const i=e.id.startsWith("vscode:")?e.id.slice(0,e.id.lastIndexOf(":")+1):null;return t.find(l=>l.kind===n&&l.source===e.source&&(!i||l.id.startsWith(i))&&r(l.name)===o)??null}function NM(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=_M(o,e),l={name:r(o)};l[o.kind]=o,n.add(o.id),i&&(l[i.kind]=i,n.add(i.id)),t.push(l)}return t}function TM(e,t){const n={...e};return t.dark&&(n.dark=t.dark.id),t.light&&(n.light=t.light.id),!SM(n.mode)&&!t[n.mode]&&(n.mode=t.dark?"dark":"light"),n}function ra(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 sE(e){const t=ra(e);return t?nl(t[0],t[1],t[2],t[3]):null}function nl(e,t,n,r=1){const o=i=>Math.round(Math.max(0,Math.min(255,i))).toString(16).padStart(2,"0");return`#${o(e)}${o(t)}${o(n)}${r>=1?"":o(r*255)}`}function jM(e,t){const n=ra(e);return n?nl(n[0],n[1],n[2],t):e}function CM(e,t){const n=ra(e);return n?nl(n[0],n[1],n[2],Math.min(1,n[3]*t)):e}function mW(e,t){const n=ra(e),r=ra(t);if(!n||!r)return e;const o=n[3];return nl(n[0]*o+r[0]*(1-o),n[1]*o+r[1]*(1-o),n[2]*o+r[2]*(1-o))}function iE(e){const t=ra(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 AM(e){return iE(e)>.179?"#1d2021":"#fbf1c7"}function _m(e){if(e===null||e==="")return"the npm registry";try{return new URL(e).host}catch{return e}}function Wg(e,t){const n=x0(e),r=x0(t);if(!n||!r)return!1;for(let o=0;o<3;o++){const i=n.nums[o]??0,l=r.nums[o]??0;if(i!==l)return i>l}return n.pre===r.pre?!1:n.pre===null?!0:r.pre===null?!1:n.pre>r.pre}function x0(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 IM=[[/\.(png|jpe?g|gif|webp|avif|bmp|ico)$/i,"image"]];function RM(e){var t;return((t=IM.find(([n])=>n.test(e)))==null?void 0:t[1])??null}const $M=[[/\.(md|markdown)$/i,"markdown"],[/\.html?$/i,"html"]];function Of(e){var t;return((t=$M.find(([n])=>n.test(e)))==null?void 0:t[1])??null}const Xe={active:"toyon-active",phoneRow:"toyon-phone-row",repo:"toyon-repo",lastActive:"toyon-last",discoveredOpen:"toyon-disc",archivedOpen:"toyon-arch",committedShut:"toyon-committed-shut",turnOpen:"toyon-turn-open",treeOpen:"toyon-tree",token:"toyon-token",theme:"toyon-theme",daylight:"toyon-sun",changesWidth:"toyon-changes-w",chatWidth:"toyon-chat-w",editorHeight:"toyon-dh",editorFull:"toyon-dfull",designHeight:"toyon-dsh",designFull:"toyon-dsfull",termHeight:"toyon-th",rail:"toyon-rail",railWidth:"toyon-rail-w",chatSide:"toyon-chat-side",clipboardOffer:"toyon-clipboard-offer",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"},OM=[Xe.active,Xe.repo,Xe.lastActive,Xe.discoveredOpen,Xe.archivedOpen,Xe.committedShut,Xe.turnOpen,Xe.treeOpen,Xe.profilePrefix,Xe.modePrefix,Xe.modelPrefix,Xe.effortPrefix,Xe.phoneRow,Xe.version],MM=[Xe.profilePrefix,Xe.modePrefix,Xe.modelPrefix,Xe.effortPrefix],Od=(e,t)=>`${e}@${t}`;function PM(e,t=typeof localStorage>"u"?null:localStorage,n=typeof sessionStorage>"u"?null:sessionStorage){const r=l=>({get(c){try{return(l==null?void 0:l.getItem(Od(c,e)))??null}catch{return null}},set(c,u){try{l==null||l.setItem(Od(c,e),u)}catch{}},remove(c){try{l==null||l.removeItem(Od(c,e))}catch{}}}),o=r(t),i=r(n);return{...o,session:{get:i.get,set:i.set},clear(){for(const l of[t,n])for(const c of aE(l).filter(u=>u.endsWith(`@${e}`)))try{l==null||l.removeItem(c)}catch{}}}}function aE(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 LM="orch-";function DM(e,t=typeof localStorage>"u"?null:localStorage,n=typeof sessionStorage>"u"?null:sessionStorage){for(const[r,o]of[[t,["active","token","theme","editorHeight","editorFull"]],[n,["client"]]])for(const i of o){const l=Xe[i],c=LM+l.slice(6);E0(r,c,l)}for(const[r,o]of[[t,OM.filter(i=>i!==Xe.phoneRow)],[n,[Xe.phoneRow]]]){const i=aE(r).filter(l=>!l.includes("@"));for(const l of o){const c=MM.includes(l)?i.filter(u=>u.startsWith(l)):i.filter(u=>u===l);for(const u of c)E0(r,u,Od(u,e))}}}function E0(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 lE(){const e=location.hash.match(/token=([a-f0-9]+)/);if(e!=null&&e[1])return cE(e[1]),e[1];try{return localStorage.getItem(Xe.token)??sessionStorage.getItem(Xe.token)??""}catch{return""}}function cE(e){try{localStorage.setItem(Xe.token,e)}catch{}}function Kg(){return lE()!==""}function Zg(e,t){const n=new URL(e),r=`token=${t}`,o=i=>`&v=${encodeURIComponent(i??"")}`;return{origin:n.origin,host:n.hostname,token:t,ws:`${n.protocol==="https:"?"wss":"ws"}://${n.host}/ws?${r}`,attachment:(i,l)=>`${n.origin}/attachments/${i}/${l}?${r}`,upload:i=>`${n.origin}/uploads/${i}?${r}`,worktreeFile:(i,l,c)=>`${n.origin}/files/${i}/${l.split("/").map(encodeURIComponent).join("/")}?${r}${o(c)}`,loose:(i,l)=>`${n.origin}/loose/${encodeURIComponent(i)}?${r}${o(l)}`,health:`${n.origin}/health`,restart:i=>`${n.origin}/restart?${r}${i?`&${Z2}`:""}`,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 dl=e=>({authorization:`Bearer ${e.token}`});async function zM(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",dl(e).authorization),i.setRequestHeader("content-type",n.type||"application/octet-stream"),r&&(i.upload.onprogress=l=>l.lengthComputable&&r(l.loaded/l.total)),i.onload=()=>{if(i.status>=502&&i.status<=504)return o(null);if(i.status<200||i.status>=300)return o(i.responseText||"could not be attached");try{o(JSON.parse(i.responseText))}catch{o("could not be attached")}},i.onerror=()=>o(null),i.onabort=()=>o(null),i.send(n)})}async function FM(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 uE(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 BM(e){var t;try{const n=await fetch(e.changelog,{headers:dl(e)});return!n.ok||!((t=n.headers.get("content-type"))!=null&&t.startsWith("text/markdown"))?null:await n.text()}catch{return null}}async function UM(e,t){try{const n=await fetch(t,{headers:dl(e)});return n.ok?await n.json():null}catch{return null}}async function Mf(e,t,n,r){try{const o=await fetch(t,{method:"POST",headers:{...dl(e),"content-type":"application/json"},body:JSON.stringify(n)});return o.ok?null:await o.text()||`refused (${o.status})`}catch{return r}}const HM=e=>UM(e,e.tailnet),WM=e=>Mf(e,e.remote,{tailscale:!0},"Toyon is not answering; try again once it is back."),KM=e=>Mf(e,e.remote,{off:!0},"Toyon is not answering; try again once it is back.");async function dE(e,t,n){try{const r=await fetch(t,{method:"POST",headers:{...dl(e),"content-type":"application/json"},body:JSON.stringify(n)});return r.ok?await r.json():null}catch{return null}}const fE="Toyon is not answering; try again once it is back.",ZM=async e=>{const t=await dE(e,e.tailscale,{up:!0});return t===null?fE:t.refused},qM=async e=>await dE(e,e.tailscale,{login:!0})??{why:fE},GM=(e,t,n)=>Mf(e,e.machines,{origin:t,token:n},"Toyon here is not answering; the machine is not listed yet."),VM=(e,t,n)=>Mf(e,e.knockAnswer(t),{letIn:n},"Toyon is not answering");async function hE(e){try{const t=await fetch(e.previewGrant,{method:"POST",headers:dl(e)});return t.ok?await t.json():null}catch{return null}}const YM=2e3;async function pE(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,YM))}return"gone"}async function Nm(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 XM=1e3,QM=3e4,JM=1500,eP=5e3,S0=50,tP=e=>e.t==="chat"||e.t==="create-worktree"||e.t==="restore-worktree"||e.t==="batch-worktrees";class nP{constructor(t,n,r,o=eP){zt(this,"ws",null);zt(this,"queue",[]);zt(this,"closed",!1);zt(this,"attempt",0);zt(this,"timer",null);zt(this,"downAt",null);zt(this,"downCode",0);zt(this,"sayTimer",null);zt(this,"sentDown",new Set);zt(this,"urls");zt(this,"suspended",!1);zt(this,"wake",()=>{var n;if(this.closed||this.suspended||document.visibilityState!=="visible"||((n=this.ws)==null?void 0:n.readyState)===WebSocket.OPEN)return;this.timer&&clearTimeout(this.timer),this.timer=null,this.attempt=0,this.downAt!==null&&(this.downAt=Date.now(),this.onStatus(!1,null),this.armSay());const t=this.ws;this.connect(),t==null||t.close()});this.onMsg=n,this.onStatus=r,this.connectDeadline=o,this.urls=Zg(t.origin,t.token),this.connect(),document.addEventListener("visibilitychange",this.wake),window.addEventListener("online",this.wake)}suspend(){if(this.suspended||this.closed)return;this.suspended=!0,this.timer&&clearTimeout(this.timer),this.timer=null;const t=this.ws;this.ws=null,t==null||t.close(),this.onStatus(!1,null)}resume(){!this.suspended||this.closed||(this.suspended=!1,this.attempt=0,this.connect())}async diagnose(t){if(t===FC)return"unauthorized";try{return(await fetch(this.urls.health,{signal:AbortSignal.timeout(2e3)})).ok?"blocked":"down"}catch{return"down"}}say(t){this.downAt??(this.downAt=Date.now()),this.downCode=t,this.armSay()}armSay(){if(this.downAt===null)return;const t=this.downAt,n=()=>!this.closed&&this.downAt===t&&document.visibilityState==="visible";this.sayTimer&&clearTimeout(this.sayTimer),this.sayTimer=setTimeout(()=>{n()&&this.diagnose(this.downCode).then(r=>{n()&&this.onStatus(!1,r)})},Math.max(0,t+JM-Date.now()))}connect(){if(this.closed||this.suspended)return;const t=new WebSocket(this.urls.ws);this.ws=t;let n=!1;const r=setTimeout(()=>{t.readyState===WebSocket.CONNECTING&&t.close()},this.connectDeadline);t.onmessage=o=>{if(!n){n=!0,clearTimeout(r),this.attempt=0,this.downAt=null,this.sayTimer&&clearTimeout(this.sayTimer),this.sayTimer=null,this.onStatus(!0);for(const i of this.queue)t.send(i.raw);this.queue=[]}try{this.onMsg(JSON.parse(o.data))}catch{}},t.onclose=o=>{if(clearTimeout(r),this.ws!==t||(this.onStatus(!1),this.closed||this.suspended))return;this.say(o.code);const i=Math.min(QM,XM*2**this.attempt++);this.timer=setTimeout(()=>this.connect(),i/2+Math.random()*(i/2))},t.onerror=()=>t.close()}send(t){const n=JSON.stringify(t);if(this.ws&&this.ws.readyState===WebSocket.OPEN){this.ws.send(n);return}if(t.t.startsWith("term-"))return;const r=t.t==="subscribe"||t.t==="unsubscribe"?`sub:${t.worktreeId}`:t.t==="view"?"view":null;r&&(this.queue=this.queue.filter(o=>o.key!==r)),tP(t)&&t.boxId&&this.sentDown.add(t.boxId),this.queue.push({key:r,raw:n}),this.queue.length>S0&&this.queue.splice(0,this.queue.length-S0)}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 Tm(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 qg(e,t,n){const r=h=>e.map((p,m)=>h(p)&&p.id!==t?m:-1).filter(p=>p>=0),i=[()=>r(h=>h.agent==="waiting"),()=>r(h=>!!h.unseen),()=>r(h=>h.agent==="working")].reduce((h,p)=>h.length>0?h:p(),[]),l=e.findIndex(h=>h.id===t),c=n>0?i.find(h=>h>l)??i[0]:i.findLast(h=>h<l)??i[i.length-1],u=c===void 0?void 0:e[c];return u?{activate:u.id}:null}function Gg(e,t,n){const r=qg(e,t,n);if(r)return r;const o=e[0];return o&&o.id!==t?{activate:o.id}:null}function rP(e,t,n){const r=[Tm(e,t),...n.map(o=>Tm(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 oP(e,t,n){const r=[i=>i.agent==="waiting",i=>!!i.unseen];for(const i of r){if(e.some(l=>i(l)&&l.id!==t)){const l=qg(e,t,1);return l&&{origin:null,activate:l.activate}}for(const l of n){const c=l.rows.find(i);if(c)return{origin:l.origin,activate:c.id}}}const o=Gg(e,t,1);return o&&{origin:null,activate:o.activate}}function Vg(e){return e==="cancelled"||e==="expired"}function mE(e){const t=e.findLast(n=>n.kind==="ask"||n.kind==="user");return(t==null?void 0:t.kind)!=="ask"||t.ask.kind!=="question"?null:Vg(t.outcome)?t:null}function sP(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 iP(e){return e.map(()=>({selected:[]}))}function _0(e,t,n,r){return e.map((o,i)=>{if(i!==t)return o;const l=o.selected.includes(n);return r?{...o,selected:l?o.selected.filter(c=>c!==n):[...o.selected,n]}:{...o,selected:[n]}})}function Qd(e,t,n){return e.map((r,o)=>{if(o!==t)return r;const{note:i,...l}=r;return n===void 0?l:{...l,note:n}})}function N0(e,t,n,r){return e.map((o,i)=>i!==t?o:{selected:n&&!r?[]:o.selected,note:o.note??""})}function Md(e,t){const n=e[t];return n&&n.note!==void 0&&!n.note.trim()?Qd(e,t,void 0):e}function aP(e){return e?e.options.length+(e.note?1:0):0}function lP(e,t){return!!(e!=null&&e.note)&&t===e.options.length}function gE(e,t){return!!e&&e.note!==void 0&&(t||e.selected.length===0)}function Ga(e){var t;return!!e&&(e.selected.length>0||!!((t=e.note)!=null&&t.trim()))}function gd(e,t){return e.every((n,r)=>!n.required||Ga(t[r]))}function cP(e,t){var o;const n=((t==null?void 0:t.selected)??[]).map(i=>{var l;return Xg(((l=e.options.find(c=>c.value===i))==null?void 0:l.label)??i)}),r=(o=t==null?void 0:t.note)==null?void 0:o.trim();return n.length===0?r||"skipped":r?`${n.join(", ")}: ${r}`:n.join(", ")}function uP(e,t){var o;const n=((t==null?void 0:t.selected)??[]).map(i=>{var l;return Xg(((l=e.options.find(c=>c.value===i))==null?void 0:l.label)??i)}),r=((o=t==null?void 0:t.note)==null?void 0:o.trim())||void 0;return n.length>0?r?{pick:n.join(", "),note:r}:{pick:n.join(", ")}:r&&e.note?{pick:e.note.label,note:r}:{pick:r??"skipped"}}function Yg(e,t){return e.map((n,r)=>{const o=cP(n,t==null?void 0:t[r]);return e.length>1&&n.header?`${n.header} · ${o}`:o})}function dP(e){return e.outcome!=="answered"||e.ask.kind!=="question"?null:{message:e.ask.message,questions:e.ask.questions,answers:e.answers}}function fP(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 Ba(e,t){if(!e)return 0;if(gE(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 hP(e,t,n){return Math.max(0,Math.min(n-1,e+t))}function pP(e,t,n){const r=e.length;for(let o=1;o<=r;o++){const i=(n+o)%r;if(!Ga(t[i]))return i}return-1}function Ec(e){return e.length>1?e.length:-1}function mP(e){return e.length+(Ec(e)===-1?0:1)}function T0(e,t,n){const r=pP(e,t,n);if(r!==-1)return{current:r,cursor:Ba(e[r],t[r]),send:!1};const o=Ec(e);return o!==-1?{current:o,cursor:0,send:!1}:{current:n,cursor:Ba(e[n],t[n]),send:!0}}const kE=/\s*\(recommended\)\s*$/i;function gP(e){return kE.test(e)}function Xg(e){return e.replace(kE,"")}const kP={skipped:"you skipped this",cancelled:"the turn was stopped before you answered",expired:"Toyon restarted before you answered"};function Pd(e,t,n,r){return n!==null&&r===n.host?`${zC(n.previews,e,t)}/`:r.endsWith(".localhost")?`http://w${e}.${r}:${t}/`:Ag(r)?`http://${r==="localhost"?"127.0.0.1":r}:${t}/`:`https://${r}:${t}/`}function j0(e){return e.ranges.map(([t,n])=>[t+e.offset,n+e.offset])}function wE(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 C0(e){var r;const t=(r=e.source)==null?void 0:r.replace(/[?#].*$/,""),n=t?` (${wE(t)}:${e.line??"?"})`:"";return`${e.message}${n}`.slice(0,v2)}function kd(e,t){return!Number.isFinite(e)||e<=0?t:Math.min(Math.max(e,170),Math.floor(window.innerWidth*.5))}function Vc(e){return e.agent==="working"||e.agent==="waiting"}function fi(e){var t,n,r;return e.agent==="waiting"?"waiting":e.agent==="working"?"working":e.agent==="error"||((n=(t=e.worktree)==null?void 0:t.lastTurn)==null?void 0:n.end)==="failed"?"failed":(r=e.worktree)!=null&&r.landed?"landed":e.procs.some(o=>o.status==="crashed"||o.status==="unreachable")?"crashed":e.procs.some(o=>o.status==="running")?"running":e.procs.some(o=>o.status==="starting")?"starting":e.procs.some(o=>o.status==="asleep")?"asleep":"idle"}const wP={waiting:"Waiting for you",working:"Agent working",failed:"Agent failed",landed:"Landed",crashed:"Crashed",running:"Running",starting:"Starting",asleep:"Asleep",idle:"Idle"};function Qg(e,t=!1){const n=fi(e);return n==="idle"&&t?"Not set up":wP[n]}const yP={starting:"Starting",running:"Running",unreachable:"Not answering",crashed:"Crashed",stopped:"Stopped",asleep:"Asleep"};function vP(e){return yP[e]}function yE(e,t){return t&&fi(e)!=="waiting"?t:null}const bP={land:"Landing",commit:"Committing","sync-main":"Syncing with main","pull-main":"Pulling"};function Jg(e){return bP[e]}function vE(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 xP(e){const t=e.lastIndexOf("/");return t<0?{name:e,dir:""}:{name:e.slice(t+1),dir:e.slice(0,t)}}const bE=new Intl.Collator(void 0,{numeric:!0,sensitivity:"base"}).compare;function Jd(e){const t=[];for(let n=e.indexOf("/");n!==-1;n=e.indexOf("/",n+1))t.push(e.slice(0,n));return t}function xE(e){const t=new Set;for(const n of e)for(const r of Jd(n))t.add(r);return[...t].sort(bE)}function ek(e){return e.includes("A")||e==="??"?"added":e.includes("D")?"deleted":""}function tk(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 EP=/Firefox\//.test(navigator.userAgent);function nk(){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 SP=/Chrome\//.test(navigator.userAgent)&&nk(),Lt=e=>_C(e,{firefox:EP,pwa:SP});function rk(e){return e.component?`<${e.component} />`:`<${e.tag}>`}function jm(e,t){return e.worktree&&yr(e.worktree)&&t?t.defaultBranch:e.name}function ok(e){const t=Math.max(0,e/1e3),n=(l,c)=>`${l} ${c}${l===1?"":"s"}`;if(t<60)return"a moment";const r=t/60;if(r<60)return n(Math.floor(r),"minute");const o=r/60;if(o<24)return n(Math.floor(o),"hour");const i=o/24;return i<7?n(Math.floor(i),"day"):i<365?n(Math.floor(i/7),"week"):n(Math.floor(i/365),"year")}function oo(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 Gi(e){const t=Math.max(0,Math.floor(e));return t<100?`${t}s`:`${Math.floor(t/60)}m ${t%60}s`}function _P(e,t,n,r){var l;if(!t)return null;const o=e.filter(vn).filter(c=>c.repoId===t&&(c.worktree.agent??r)===n);return((l=o.find(c=>yr(c.worktree))??o[0])==null?void 0:l.id)??null}const NP=200;function TP(e,t){const n=new Map(e.map(r=>[r.path,r]));for(const r of t){if(n.size>=NP)break;const o=If(r.path);o&&!n.has(o)&&n.set(o,{path:o,text:r.text})}return n.size===e.length?e:[...n.values()]}function EE(e){return e!==void 0&&!e.routes.some(t=>!t.endpoint)}const hi=e=>"uploading"in e&&e.uploading===!0;function Va(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 sk=e=>e.filter(t=>!hi(t)).map(Va);let jP=0;function Cm(e,t){const n=new Map(t.filter(o=>!hi(o)).map(o=>[JSON.stringify(Va(o)),o]));return[...e.map(o=>{const i=JSON.stringify(o),l=n.get(i);if(l)return n.delete(i),l;const c=`d${++jP}`;return o.kind==="paste"?{...o,key:c,...Bg(o.text)}:{...o,key:c}}),...t.filter(hi)]}const Am="out:",CP=(e,t,n)=>`${Am}${e}:${t}:${n}`;function ls(e){if(!e.startsWith(Am))return null;const t=e.slice(Am.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 hc(e,t,n,r){const o=r.length?sk(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 AP(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(hi)){n.add(o.log);continue}r.push(o.id)}return r}const SE=e=>e.flatMap(t=>"upload"in t&&t.upload?[t.upload]:[]);function IP(e){const t=n=>SE(n.items).some(r=>!n.before.includes(r));return[...e.filter(t),...e.filter(n=>!t(n))]}const Ld=["files","changes","history"],RP=e=>Ld.includes(e),_E=e=>!!(e!=null&&e.carry)&&!e.batch&&e.variants===1,fl=e=>(e==null?void 0:e.worktree.id)??null,rl="new-project",sa=Object.freeze({chat:[],log:[],queue:[],page:{},turn:{edits:!1,hmr:!1},changedRanges:{},commitFiles:{},search:null,design:null,draft:"",attachments:[],commands:[],termStream:_o}),ik=e=>({...e,phase:"editing",repoId:null}),A0=()=>ik({mode:"create",name:"",parent:`~/${Q1}`}),$P=Object.freeze({changes:!1,changesTab:"files",chat:!0,term:!1,design:!1});function OP(e){if(!e||typeof e!="object")return!1;const t=e;return typeof t.changes=="boolean"&&RP(t.changesTab)&&typeof t.chat=="boolean"&&typeof t.term=="boolean"&&typeof t.design=="boolean"}function to(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 ak(e,t){return{...e,layout:t,changesAuto:!1}}const pi=e=>Of(e)?"preview":"file",MP=(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 NE(e,t,n,r){var i;if(!r.fiber)return r;const o=(i=Co(e,t).changedRanges[n])==null?void 0:i.offset;return o===void 0?r:{n:r.n-o}}function PP(e){const t=e.cached??Gc,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,local:{},editor:null,openUrl:null,reloadReq:null,renders:[],dragFiles:null,picking:!1,overlay:null,paletteReturn:null,incompatible:!1,layout:$P,focusChanges:0,editCommit:0,focusChat:0,walked:0,railOpen:e.storedRailOpen??!1,chatSide:e.storedChatSide??"left",focusRail:0,railPeek:!1,unreadHold:null,layouts:e.storedLayouts??{},screen:e.storedActive&&e.storedPhoneRow?"chat":"home",frame:e.frame??"desk",touch:e.touch??!1,reading:!1,changesAuto:!0,zen:!1,focusTerm:0,termRun:null,termTall:0,previewSize:null,themes:$d.some(o=>o.id===t.id)?$d:[...$d,t],themePrefs:{...gM,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:k2,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?ak(n,r):n}function TE(e){var t;return{system:e.systemDark,daylight:((t=e.daylight)==null?void 0:t.dark)??e.systemDark}}function LP(e){return e.previewTheme??$f(e.themePrefs,e.themes,TE(e))}function Co(e,t){return t&&e.local[t]||sa}function ko(e,t){return t&&e.rows.find(n=>n.id===t)||null}function pn(e,t){const n=ko(e,t);return n&&vn(n)?n:null}function jE(e){var o;const t=pn(e,e.activeId);if(!t||!na(t.worktree)||t.agent!=="idle"||!((o=ol(e,t.repoId))!=null&&o.empty))return!1;const n=yi(e,t.repoId),r=e.rows.some(i=>{var l;return i.repoId===t.repoId&&((l=i.worktree)==null?void 0:l.kind)==="worktree"});return!!(n!=null&&n.needsSetup)&&!r&&Co(e,t.id).chat.length===0}function Pf(e){return e.newProject!==null||jE(e)}function DP(e){return e.incompatible||Pf(e)}function zP(e){return(!e.needsSetup||!!e.assumed)&&Object.keys(e.config.run).length===0}function ef(e){return!!(e!=null&&e.needsSetup)&&!e.assumed}function lk(e){const t=e.archivedPage?null:ko(e,e.activeId);return(t==null?void 0:t.repoId)??e.activeRepoId}function To(e){const t=yi(e,lk(e));return!!t&&zP(t)}function CE(e){return e.layout.chat&&!To(e)&&!e.archivedPage&&!ME(e)?{a:"toggle-chat"}:{a:"focus-chat"}}function AE(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 Uo(e){return To(e)?e:to(e,{chat:!0})}function yi(e,t){return t&&e.repos.find(n=>n.id===t)||null}function IE(e,t){if(!t)return null;const n=e.rows.filter(vn).filter(r=>r.repoId===t);return n.find(r=>qc(r.worktree))??n.find(r=>na(r.worktree))??null}function ol(e,t){return t&&e.trunks[t]||null}function pc(e){return To(e)||e.archivedPage||e.notesPage?null:e.activeId}function ck(e){return e.procs.some(t=>t.status==="running"||t.status==="starting")}function tf(e){if(e.archivedPage||e.notesPage)return null;const t=pn(e,e.activeId);return t&&ck(t)?{worktreeId:t.worktree.id,repoId:t.repoId}:null}function uk(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&&vn(o)&&o.repoId===t?o:null}function RE(e,t){return e.repoId!==t&&(e.agent==="waiting"||!!e.unseen)}function Lf(e,t,n,r){return e.repoId===t||uk(e,t,n)!==null||RE(e,t)||e.id===r}function $E(e,t,n){return!e||!t||!vn(e)||e.repoId===t||uk(e,t,n)?null:RE(e,t)?e.id:null}function OE(e,t){return t.length?e.filter(n=>!t.includes(n.id)):e}function FP(e,t,n,r){const o=OE(e,n).filter(vn);return uC(t?o.filter(i=>Lf(i,t,o,r)):o)}function BP(e,t){const n=e.filter(r=>!vn(r));return t?n.filter(r=>r.repoId===t):n}function Ya(e,t,n=e.rows){var c;const r=n.filter(vn),o=e.archiving.length?r.filter(u=>!e.archiving.includes(u.id)):r,i=t?e.lastActive[t]:void 0;if(i&&o.some(u=>u.id===i))return i;const l=t?o.filter(u=>u.repoId===t):o;return((c=l.find(u=>qc(u.worktree))??l.find(u=>na(u.worktree))??l[0])==null?void 0:c.id)??null}function I0(e,t){const n=Object.entries(e),r=n.filter(([o])=>!t(o));return r.length===n.length?e:Object.fromEntries(r)}function R0(e,t,n){const r={};for(const l of t)l.shipping&&(r[l.id]=l.shipping);for(const l of Object.values(n))l.shipping&&(r[l.id]=l.shipping);for(const[l,c]of Object.entries(e))!c.sent||r[l]||(t.some(u=>u.id===l)||FE({trunks:n},l))&&(r[l]=c);const o=Object.keys(r);return o.length===Object.keys(e).length&&o.every(l=>UP(e[l],r[l]))?e:r}const UP=(e,t)=>!!e&&!!t&&e.op===t.op&&e.step===t.step&&e.sent===t.sent;function Ua(e,t){var m;const n=ko(e,t),r=!!n&&vn(n)&&!!e.activeRepoId&&Lf(n,e.activeRepoId,e.rows,e.lent),o=r&&e.lent!==t?$E(n,e.activeRepoId,e.rows):r?e.lent:null,i=r?e.activeRepoId:(n==null?void 0:n.repoId)??e.activeRepoId,l=n&&vn(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"?Ha(u,"reveal"):null,p=c&&h?{...e.local,[c]:h}:e.local;return{...e,activeId:t,activeRepoId:i,lent:o,lastActive:l,editor:null,archivedPage:null,notesPage:!1,local:p}}function sl(e){return Ao(e)?"history":e.layout.changesTab}function HP(e,t){const n=sl(e);if(Ao(e))return n;const r=Ld.length;return Ld[(Ld.indexOf(n)+t+r)%r]??"changes"}function ME(e){if(e.archivedPage)return null;const t=ko(e,e.activeId);return t&&!vn(t)?t:null}function WP(e){return e.notesSeen||e.ranBefore===null||!Wg(e.version,e.ranBefore)?null:e.version}function Ao(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 Ha(e,t){var o;if(((o=e.mark)==null?void 0:o.by)!==t)return e;const{mark:n,...r}=e;return r}const PE=e=>e.kind==="theme"||e.kind==="appearance"||e.kind==="keep-awake"||e.kind==="agent"||e.kind==="agent-page"||e.kind==="choose-folder"||e.kind==="handoff";let KP=0;function Oc(e){if(!e.sending)return e;const{sending:t,...n}=e;return n}function ZP(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]=Oc(r[o]);return{...e,local:r}}function qP(e,t,n,r){var l;let o=e;const i=n?(l=o[n])==null?void 0:l.sending:void 0;if(i&&n&&r&&r!==n){const c=o[r]??sa,u=c.chat.some(h=>h.kind==="user")?{at:i.at}:i;o={...o,[n]:Oc(o[n]),[r]:{...c,sending:u}}}for(const c of t){const u=o[c.id];u!=null&&u.sending&&!u.sending.message&&(c.agent==="working"||c.agent==="waiting")&&(o={...o,[c.id]:Oc(u)})}return o}function xt(e,t,n){return{...e,local:{...e.local,[t]:n(e.local[t]??sa)}}}function $0(e,t){const n=e.find(r=>r.kind==="tool"&&!r.done&&!r.parentToolId&&!r.background);if(n)return(t==null?void 0:t.id)===n.id?t:{id:n.id,at:Date.now()}}function GP(e,t){const n=t.type==="agent-question"||t.type==="agent-permission"||t.type==="handoff-proposed",r=t.type==="agent-ask-end"||t.type==="handoff-go"||t.type==="handoff-declined"?t.id:null;if(!n&&!r)return e;const o=t.type==="agent-ask-end"&&Vg(t.outcome),i=t.type==="agent-ask-end"&&t.outcome==="expired"?t.id:null,{card:l,cardParked:c,askRevived:u,...h}=e;return{...h,...l&&!n&&(l.id!==r||o)?{card:l}:{},...c&&!n&&c!==r?{cardParked:c}:{},...i?{askRevived:i}:u&&!n?{askRevived:u}:{}}}function VP(e,t,n){return xt(e,t,r=>({...r,chat:[...r.chat,n],chatAt:Date.now()}))}function LE(e,t,n){return VP(Uo(e),t,{kind:"error",text:n})}function Im(e,t){const n=fl(pn(e,e.activeId));return n?xt(Uo(e),n,r=>({...r,notice:t})):e}function O0(e,t,n){return pn(e,t)?LE(e,t,n):Im(e,n)}function YP(e,t){const n=e.paletteReturn;return!t||!n?{overlay:null,paletteReturn:null}:{overlay:{kind:n.mode},paletteReturn:n}}function XP(e){const t=e.activeRepoId;if(!t)return e;const n=e.layouts[t];return n?ak(e,n):e.frame==="desk"?{...e,layouts:{...e.layouts,[t]:e.layout}}:e}function QP(e){return e.a==="server"&&e.msg.t==="git-status"}function JP(e){return{variants:1,batch:!1,agent:e.defaultAgent}}function eL(e){const t=pn(e,e.activeId);return!!t&&yr(t.worktree)&&!e.archivedPage&&!Pf(e)?e.draft?e:{...e,draft:JP(e)}:e.draft?{...e,draft:null}:e}function DE(e){var r;const t=e.archivedPage,n=t!==null&&((r=e.editor)==null?void 0:r.worktreeId)===t&&pn(e,t)===null;return{...e,archivedPage:null,...n?{editor:null}:{}}}function tL(e){const t=e.activeRepoId;if(!t)return e;const n=pn(e,e.activeId);return!n||n.repoId===t||Lf(n,t,OE(e.rows,e.archiving),e.lent)?e:Ua(e,Ya(e,t))}function M0(e,t,n){const r=t.some(i=>!e.knocks.some(l=>l.id===i.id)),o={...e,knocks:t,letIn:n};return r&&o.overlay===null?li(o,{a:"open",overlay:{kind:"devices"}}):o}const nL=e=>{var t;return e.frame==="desk"&&(e.remote!==null||((t=e.tailscale)==null?void 0:t.state)==="ready")};function li(e,t){let n=eL(tL(rL(e,t)));return n.unreadHold!==null&&n.activeId!==n.unreadHold&&(n={...n,unreadHold:null}),n.archivedPage!==null&&(Ao(n)===null||pn(n,n.archivedPage)!==null)&&(n=DE(n)),n.activeRepoId!==e.activeRepoId?n=XP(n):n.frame==="desk"&&n.activeRepoId&&!QP(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:FP(n.rows,n.activeRepoId,n.archiving,n.lent),visibleDiscovered:BP(n.rows,n.activeRepoId)}}function rL(e,t){var n,r,o,i,l,c,u,h,p,m,k;switch(t.a){case"connected":return{...e,connected:t.v,connectFailure:t.v?null:t.failure===void 0?e.connectFailure:t.failure};case"activate":return{...Ua(e,t.id),carryTo:null,screen:t.id?"chat":"home"};case"open-draft":{if(Pf(e))return e;const g=((n=IE(e,e.activeRepoId))==null?void 0:n.id)??null;return g?Uo({...Ua(e,g),carryTo:g,overlay:null,paletteReturn:null,focusChat:e.focusChat+1,screen:"chat"}):e}case"draft-carry":return e.draft?{...e,draft:{...e.draft,carry:t.v}}:e;case"draft-variants":return e.draft?{...e,draft:{...e.draft,variants:t.n}}:e;case"draft-batch":return e.draft?{...e,draft:{...e.draft,batch:t.v}}:e;case"draft-agent":return e.draft?{...e,draft:{...e.draft,agent:t.id}}:e;case"draft-profile":return e.draft?{...e,draft:{...e.draft,profile:t.profile}}:e;case"open-archived":return AE(e,t.id);case"close-archived":return e.archivedPage?DE(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 xt(e,t.id,g=>({...g,sending:{message:t.message,at:Date.now()}}));case"sent-box":return xt(e,t.id,({notice:g,...y})=>({...Ha(y,"walk"),draft:"",attachments:[],sent:(y.sent??0)+1}));case"answered":return xt(e,t.id,g=>({...g,sent:(g.sent??0)+1}));case"hold-send":{const g=e.local[t.id];if(!g)return e;const y=CP(e.clientId,++KP,t.id),b={...sa,draft:t.text,attachments:g.attachments,outgoing:{frame:t.frame,log:t.log}},S=xt(e,t.id,({notice:j,...E})=>({...Ha(E,"walk"),draft:"",attachments:[]}));return{...S,local:{...S.local,[y]:b},outbox:[...e.outbox,{id:y,log:t.log,kinds:g.attachments.map(j=>j.kind)}]}}case"sent-out":{const g=e.local[t.id],y=g==null?void 0:g.outgoing;if(!g||!y)return e;const{[t.id]:b,...S}=e.local,j={...e,local:S,outbox:e.outbox.filter(R=>R.id!==t.id)},E=g.draft,N=g.attachments.length?sk(g.attachments):void 0,A=R=>({...R,sent:(R.sent??0)+1});if(y.frame.t==="restore-worktree"||y.frame.t==="adopt-worktree")return xt(j,y.log,R=>({...A(R),sending:{message:{text:E,attachments:N},at:Date.now()}}));if(y.frame.t==="agent-answer")return xt(j,y.log,A);const O=(r=ko(e,y.log))==null?void 0:r.agent,P=y.frame.t==="chat"&&(O==="working"||O==="waiting");return xt(j,y.log,R=>P?A(R):{...A(R),sending:{message:{text:E,attachments:N},at:Date.now()}})}case"unsend":{const g=e.local[t.id],y=(o=ls(t.id))==null?void 0:o.source;if(!(g!=null&&g.outgoing)||!y)return e;const{[t.id]:b,...S}=e.local,j={...e,local:S,outbox:e.outbox.filter(E=>E.id!==t.id)};return xt(Uo(j),y,E=>({...E,draft:E.draft||g.draft,attachments:[...g.attachments,...E.attachments],...t.notice?{notice:t.notice}:{}}))}case"drop-out":{if(!((i=e.local[t.id])!=null&&i.outgoing))return e;const{[t.id]:g,...y}=e.local;return{...e,local:y,outbox:e.outbox.filter(b=>b.id!==t.id)}}case"archive-worktrees":{const g=t.ids.filter(T=>!e.archiving.includes(T)&&pn(e,T));if(g.length===0)return e;const y={...e,archiving:[...e.archiving,...g]};if(!e.activeId||!g.includes(e.activeId))return y;const b=e.visible.filter(T=>T.id===e.activeId||!y.archiving.includes(T.id)),S=b.findIndex(T=>T.id===e.activeId),j=T=>T.id!==e.activeId&&Ng(T.worktree)&&!!T.worktree.landed&&T.agent==="idle",E=T=>{var $;return($=b.find((D,z)=>z>S&&T(D))??b.find(T))==null?void 0:$.id},N=E(T=>T.id!==e.activeId&&T.agent==="waiting"),A=E(j),O=(l=qg(b,e.activeId,1))==null?void 0:l.activate,P=(c=b.map((T,$)=>({id:T.id,i:$,far:Math.abs($-S),up:!yr(T.worktree)&&fi(T)==="running"})).filter(T=>T.up&&T.far>0).sort((T,$)=>T.far-$.far||$.i-T.i)[0])==null?void 0:c.id,R=Ua(y,N??A??O??P??Ya(y,e.activeRepoId));return e.frame==="phone"?{...R,screen:"home"}:R}case"shipping":return e.shipping[t.id]||!(ko(e,t.id)||FE(e,t.id))?e:{...e,shipping:{...e.shipping,[t.id]:{op:t.op,sent:!0}}};case"activate-repo":{if(!yi(e,t.id))return e;const g=e.newProject?{...e,newProject:null}:e;if(t.id===e.activeRepoId)return g;const y=Ya(g,t.id);return{...Ua(g,y),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 g="name"in t.v||"parent"in t.v||"url"in t.v||"mode"in t.v,{error:y,...b}=e.newProject;return{...e,newProject:{...g?b: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 g=t.v,y=e.editor,b=y&&ic(y,g)?y:null,S=g.line&&NE(e,g.worktreeId,g.path,g.line);return{...e,editor:{worktreeId:g.worktreeId,path:g.path,...g.ref?{ref:g.ref}:{},...g.since?{since:g.since}:{},view:g.view??(b==null?void 0:b.view)??null,seq:g.seq,disk:(b==null?void 0:b.disk)??null,...S?{line:S}:{},focus:g.focus,conflict:(b==null?void 0:b.conflict)??null,blame:(b==null?void 0:b.blame)??null}}}case"open-loose":{const g=t.v,y={before:g.text,after:g.text,version:null,writable:g.source.kind!=="bytes"&&!g.tooLarge&&!g.binary,binary:g.binary,tooLarge:g.tooLarge};return{...e,editor:{worktreeId:g.worktreeId,path:g.name,view:pi(g.name),seq:g.seq,disk:y,focus:!0,conflict:null,blame:null,loose:{source:g.source}}}}case"editor-read":{const g=e.editor;if(!g||g.loose||!ic(g,t.file))return e;const y=t.disk;if(!y){const j=LE(e,g.worktreeId,t.error??`could not read ${g.path}`);return g.disk?j:{...j,editor:null}}const b=pi(g.path),S=y.before===""?g.view&&g.view!=="diff"?g.view:b:g.view??(y.before===y.after?b:"diff");return{...e,editor:{...g,view:S,disk:y}}}case"editor-conflict":{const g=e.editor;return g&&!g.loose&&ic(g,t.file)?{...e,editor:{...g,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 g=e.editor;if(!g||!ic(g,t.file))return e;const y=g.loose&&g.disk?{...g.disk,writable:!1}:g.disk;return{...e,editor:{...g,refused:t.message,disk:y}}}case"editor-blame":{const g=e.editor;return g&&!g.loose&&ic(g,t.file)?{...e,editor:{...g,blame:t.blame}}:e}case"notice":return xt(Uo(e),((u=ls(t.id))==null?void 0:u.source)??t.id,g=>({...g,notice:t.text}));case"link-refused":return xt(e,t.id,({refusedLink:g,...y})=>t.v?{...y,refusedLink:t.v}:y);case"card-draft":return xt(e,t.id,g=>({...g,card:t.card}));case"card-park":return xt(e,t.id,g=>({...g,cardParked:t.cardId}));case"card-unpark":return xt(e,t.id,({cardParked:g,...y})=>y);case"ask-revive":return xt(e,t.id,({askRevived:g,...y})=>t.askId?{...y,askRevived:t.askId}:y);case"opened-url":return e.openUrl?{...e,openUrl:null}:e;case"set-draft":return xt(e,t.id,g=>{const{notice:y,...b}=Ha(g,"walk");return{...b,draft:t.text,...y!==void 0&&t.text===""?{notice:y}:{}}});case"move-box":return zE(e,t.from,t.to);case"walk":return xt(e,t.id,g=>({...Ha(g,"walk"),draft:t.text,...t.walk?{mark:{by:"walk",at:t.walk.at,from:t.walk.from}}:{}}));case"reveal":return xt(Uo(e),t.id,g=>{var y;return{...g,mark:{by:"reveal",seq:t.seq,n:((y=g.mark)==null?void 0:y.by)==="reveal"?g.mark.n+1:1}}});case"attach":return xt(Uo(e),t.id,({notice:g,...y})=>({...y,attachments:[...y.attachments,...t.items]}));case"upload-progress":return(h=e.local[t.id])!=null&&h.attachments.some(g=>g.key===t.key&&hi(g))?xt(e,t.id,g=>({...g,attachments:g.attachments.map(y=>y.key===t.key?{...y,progress:t.progress}:y)})):e;case"attached":return(p=e.local[t.id])!=null&&p.attachments.some(g=>g.key===t.key)?xt(e,t.id,g=>({...g,attachments:g.attachments.map(y=>y.key===t.key?t.item:y)})):e;case"detach":{const g=xt(e,t.id,({notice:y,...b})=>({...b,attachments:b.attachments.filter(S=>S.key!==t.key)}));return(m=e.local[t.id])!=null&&m.outgoing?li(g,{a:"unsend",id:t.id}):g}case"clear-attachments":return xt(e,t.id,({notice:g,...y})=>y.attachments.length?{...y,attachments:[]}:y);case"hmr":return xt(e,t.id,g=>({...g,turn:{...g.turn,hmr:!0}}));case"page":return xt(e,t.id,g=>({...g,page:{url:t.url??g.page.url,title:t.title??g.page.title}}));case"render-done":return e.renders.some(g=>g.id===t.id)?{...e,renders:e.renders.filter(g=>g.id!==t.id)}:e;case"links":return xt(e,t.id,g=>{const y=TP(g.links??[],t.links);return y===g.links?g:{...g,links:y}});case"drag-files":return MP(e.dragFiles,t.v)?e:{...e,dragFiles:t.v};case"set-picking":return{...e,picking:t.v};case"preview-size":return e.previewSize===t.text?e:{...e,previewSize:t.text};case"open":return{...e,overlay:t.overlay,previewTheme:null,paletteReturn:PE(t.overlay)?e.paletteReturn:null};case"choosing-folder":return{...e,choosingFolder:t.v};case"close":return{...e,previewTheme:null,...YP(e,t.back)};case"toggle":return((k=e.overlay)==null?void 0:k.kind)===t.overlay.kind?li(e,{a:"close"}):li(e,{a:"open",overlay:t.overlay});case"palette-return":return{...e,paletteReturn:t.v};case"toggle-changes":return{...to(e,{changes:!e.layout.changes}),changesAuto:!1};case"focus-changes":return{...to(e,{changes:!0,changesTab:t.tab&&!Ao(e)?t.tab:e.layout.changesTab}),changesAuto:!1,focusChanges:e.focusChanges+1};case"changes-tab":return to(e,{changesTab:t.v});case"edit-commit":return{...to(e,{changes:!0}),changesAuto:!1,editCommit:e.editCommit+1};case"toggle-chat":return To(e)?e:to(e,{chat:!e.layout.chat});case"focus-chat":return{...Uo(e),focusChat:e.focusChat+1};case"walked":return{...e,walked:e.walked+1};case"show-chat":return Uo(e);case"hold-unread":return{...e,unreadHold:t.id};case"toggle-rail":return{...e,railOpen:!e.railOpen};case"toggle-chat-side":return{...e,chatSide:e.chatSide==="left"?"right":"left"};case"update-check":return{...e,updateCheck:"asking"};case"update-check-settle":return e.updateCheck===t.check?{...e,updateCheck:null}:e;case"focus-rail":return{...e,railOpen:!0,focusRail:e.focusRail+1,screen:"home"};case"screen":return e.screen===t.to&&!e.editor?e:{...t.to==="changes"&&e.screen!=="changes"?to(e,{changesTab:"changes"}):e,screen:t.to,editor:null};case"frame":{if(e.frame===t.v)return e;const g={...e,frame:t.v};if(t.v!=="desk"||!g.activeRepoId)return g;const y=g.layouts[g.activeRepoId];return y?ak(g,y):g}case"touch":return e.touch===t.v?e:{...e,touch:t.v};case"reading":return e.reading===t.on?e:{...e,reading:t.on};case"rail-peek":return e.railPeek===t.on?e:{...e,railPeek:t.on};case"toggle-discovered":{const g=e.activeRepoId;return g?{...e,discoveredOpen:{...e.discoveredOpen,[g]:!e.discoveredOpen[g]}}:e}case"toggle-archived":{const g=e.activeRepoId;return g?{...e,archivedOpen:{...e.archivedOpen,[g]:!e.archivedOpen[g]}}:e}case"toggle-committed":{const g=e.activeRepoId;return g?{...e,committedShut:{...e.committedShut,[g]:!e.committedShut[g]}}:e}case"toggle-turn":{const g=e.activeRepoId;return g?{...e,turnOpen:{...e.turnOpen,[g]:!e.turnOpen[g]}}:e}case"tree-folder":{const g=e.treeOpen[t.worktreeId]??[];if(g.includes(t.path)===t.open)return e;const y=t.open?[...g,t.path]:g.filter(S=>S!==t.path),b={...e.treeOpen};return y.length>0?b[t.worktreeId]=y:delete b[t.worktreeId],{...e,treeOpen:b}}case"tree-reveal":{const g=e.treeOpen[t.worktreeId]??[],y=[];for(let j=t.path.indexOf("/");j!==-1;j=t.path.indexOf("/",j+1))y.push(t.path.slice(0,j));y.push(t.path);const b=y.filter(j=>!g.includes(j)),S=b.length?{...e.treeOpen,[t.worktreeId]:[...g,...b]}:e.treeOpen;return{...to(e,{changes:!0,changesTab:"files"}),changesAuto:!1,focusChanges:e.focusChanges+1,treeOpen:S,treeReveal:{worktreeId:t.worktreeId,path:t.path}}}case"files-asked":return xt(e,t.worktreeId,g=>({...g,filesFor:t.key}));case"toggle-zen":return To(e)?e:{...e,zen:!e.zen};case"toggle-terminal":return to(e,{term:!e.layout.term});case"focus-terminal":return{...to(e,{term:!0}),focusTerm:e.focusTerm+1};case"toggle-design":return To(e)?e:to(e,{design:!e.layout.design});case"term-stream":return xt({...to(e,{term:!0}),termTall:t.tall?e.termTall+1:e.termTall},t.id,g=>({...g,termStream:t.stream}));case"term-run":return xt({...to(e,{term:!0}),focusTerm:e.focusTerm+1,termRun:{id:t.id,command:t.command}},t.id,g=>({...g,termStream:_o}));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 lL(e,t.msg)}}function P0(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 L0(e,t,n){const r=new Set(t.map(l=>l.id));n&&r.add(n);const o=([l,c])=>r.has(l)||!!c.draft||c.attachments.length>0,i=Object.entries(e);return i.every(o)?e:Object.fromEntries(i.filter(o))}function oL(e,t,n){var o;let r=e;for(const i of n){if(!((o=i.worktree)!=null&&o.landed)||t.some(c=>{var u;return c.id===i.id&&((u=c.worktree)==null?void 0:u.landed)}))continue;const l=r[i.id];!(l!=null&&l.git)||l.git.files.length===0||(r===e&&(r={...e}),r[i.id]={...l,git:{...l.git,files:[]}})}return r}function sL(e,t){let n=e;for(const[r,o]of Object.entries(t)){const i=n[r];i!=null&&i.draft||ls(r)||(n===e&&(n={...e}),n[r]={...i??sa,draft:o})}return n}function iL(e,t){let n=e;for(const[r,o]of Object.entries(t)){const i=n[r];i!=null&&i.attachments.length||ls(r)||(n===e&&(n={...e}),n[r]={...i??sa,attachments:Cm(o,[])})}return n}function aL(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 Fi(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 D0(e){const t=e.newProject;if((t==null?void 0:t.phase)!=="creating"||!t.repoId)return e;const n=IE(e,t.repoId);if(!n)return e;const r=Co(e,rl);return!r.draft.trim()&&r.attachments.length===0?{...e,newProject:null}:{...zE(e,rl,n.id),newProject:null,autoSend:n.id}}function zE(e,t,n){const r=e.local[t];if(!r)return e;const o=xt(e,n,i=>({...i,draft:r.draft,attachments:r.attachments}));return xt(o,t,i=>({...i,draft:"",attachments:[]}))}function FE(e,t){return Object.values(e.trunks).some(n=>n.id===t)}function lL(e,t){var n,r,o,i,l,c,u,h,p,m,k,g,y,b,S,j;switch(t.t){case"hello":{const E=$=>!!$&&t.rows.some(D=>D.id===$),N=$=>!!$&&t.repos.some(D=>D.id===$),A=N(e.activeRepoId)?e.activeRepoId:N(e.storedRepo)?e.storedRepo:null,O=E(e.activeId)?e.activeId:E(e.storedActive)?e.storedActive:Ya(e,A,t.rows),P=t.rows.find($=>$.id===O),R=!!A&&!!P&&vn(P)&&Lf(P,A,t.rows,e.lent),T={...e,heard:!0,repos:t.repos,rows:t.rows,activeId:O,lent:R?e.lent===O?e.lent:$E(P??null,A,t.rows):null,activeRepoId:R?A:(P==null?void 0:P.repoId)??A??((n=t.repos[0])==null?void 0:n.id)??null,trunks:t.trunks,archiving:e.archiving.length?[]:e.archiving,shipping:R0({},t.rows,t.trunks),local:L0(iL(sL(e.local,t.drafts),t.attachments),t.rows,e.archivedPage),lastActive:aL(e.lastActive,t.rows),treeOpen:P0(e.treeOpen,t.rows),discoveredOpen:Fi(e.discoveredOpen,t.repos),archivedOpen:Fi(e.archivedOpen,t.repos),committedShut:Fi(e.committedShut,t.repos),turnOpen:Fi(e.turnOpen,t.repos),refs:Fi(e.refs,t.repos),chats:Fi(e.chats,t.repos),archived:Fi(e.archived,t.repos),themes:t.themes??e.themes,themePrefs:t.themePrefs??e.themePrefs,agents:t.agents,defaultAgent:t.defaultAgent,agentChosen:t.agentChosen,home:t.home,folderDialog:t.folderDialog,keepAwake:t.keepAwake,remote:t.remote,machine:t.machine,managed:t.managed,tailscale:t.tailscale,handed:t.machines,gitIdentity:t.gitIdentity,newProject:e.newProject??(t.repos.length===0&&t.rows.length===0&&t.pending.length===0?A0():null),pending:t.pending,visits:t.visits,self:t.self,update:t.update,updateCheck:e.updateCheck==="asking"?null:e.updateCheck,version:t.version,install:t.install,registry:t.registry,activeImportId:t.pending.some($=>$.id===e.activeImportId)?e.activeImportId:null};return M0(T,t.knocks,t.letIn)}case"self":{const E=((r=e.self)==null?void 0:r.building)===!0&&e.self.rebuild&&!((o=t.self)!=null&&o.building);return{...e,self:t.self,rebuilt:e.rebuilt||E&&((i=t.self)==null?void 0:i.buildFailed)===void 0}}case"remote":return{...e,remote:t.remote,machine:t.machine};case"machines":return{...e,handed:t.machines};case"tailscale":return{...e,tailscale:t.tailscale};case"knocks":return M0(e,t.knocks,t.letIn);case"update":return{...e,update:t.update};case"update-checked":return{...e,updateCheck:t.check};case"visits":return{...e,visits:{...e.visits,[t.repoId]:t.pages}};case"render":return{...e,renders:[...e.renders,{worktreeId:t.worktreeId,id:t.id,path:t.path}]};case"themes":return{...e,themes:t.themes,themePrefs:t.prefs};case"daylight":return{...e,daylight:{dark:t.dark,until:t.until}};case"keep-awake":return{...e,keepAwake:t.mode};case"agents":return{...e,agents:t.agents,defaultAgent:t.defaultAgent,agentChosen:t.agentChosen};case"agent-config":{const{t:E,...N}=t;return{...e,agentConfigs:{...e.agentConfigs,[N.agent]:N}}}case"pending-repos":{const E=new Set(e.pending.map(R=>R.id)),N=t.pending.find(R=>!E.has(R.id)),A=N&&e.pendingOpen?N.id:e.activeImportId,O=t.pending.some(R=>R.id===A),P=t.pending.some(R=>R.id===A&&R.error);return{...e,pending:t.pending,activeImportId:O?A:null,pendingOpen:P?!1:e.pendingOpen,newProject:N&&e.pendingOpen&&((l=e.newProject)==null?void 0:l.phase)==="creating"?null:e.newProject}}case"path-entries":return{...e,paths:{query:t.query,entries:t.entries,target:t.target}};case"folder-chosen":return{...e,chosenFolder:{seq:(((c=e.chosenFolder)==null?void 0:c.seq)??0)+1,folder:t.folder}};case"refs":return{...e,refs:{...e.refs,[t.repoId]:{query:t.query,refs:t.refs}}};case"chat-hits":return{...e,chats:{...e.chats,[t.repoId]:{query:t.query,hits:t.hits,truncated:t.truncated,asks:t.asks}}};case"archived":return{...e,archived:{...e.archived,[t.repoId]:t.items}};case"draft":return t.clientId===e.clientId||ls(t.boxId)?e:xt(e,t.boxId,E=>{var N;return E.draft===t.text||((N=E.mark)==null?void 0:N.by)==="walk"?E:{...E,draft:t.text}});case"attachments":return t.clientId===e.clientId||ls(t.boxId)?e:xt(e,t.boxId,E=>({...E,attachments:Cm(t.items,E.attachments)}));case"repos":{const E=new Set(e.repos.map(T=>T.id)),N=t.repos.find(T=>!E.has(T.id));let A=e.activeRepoId,O=e.pendingOpen,P=e.newProject;N&&(O||!A)?(A=N.id,O=!1,P&&P.phase!=="unmaking"&&(P={...P,phase:"creating",repoId:N.id})):t.repos.some(T=>T.id===A)||(A=((u=t.repos[0])==null?void 0:u.id)??null),(P==null?void 0:P.phase)==="unmaking"&&!t.repos.some(T=>T.id===(P==null?void 0:P.repoId))&&(P={...P,phase:"editing",repoId:null}),t.repos.length===0&&!P&&(P=A0());const R=e.gitIdentity||t.repos.some(T=>T.made&&!E.has(T.id));return A===e.activeRepoId?{...e,repos:t.repos,pendingOpen:O,newProject:P,gitIdentity:R}:D0({...e,repos:t.repos,pendingOpen:O,newProject:P,gitIdentity:R,activeRepoId:A,activeId:Ya(e,A),editor:null})}case"worktrees":{let E=e.activeId;(!E||!t.rows.some(T=>T.id===E))&&(E=Ya(e,e.activeRepoId,t.rows));const N=new Set(e.rows.map(T=>T.id)),A=T=>{var $;return(($=T.worktree)==null?void 0:$.kind)==="worktree"&&T.worktree.createdBy===e.clientId},O=t.rows.find(T=>!N.has(T.id)&&A(T)),P=!!E&&e.rows.some(T=>{var $;return T.id===E&&(($=T.worktree)==null?void 0:$.kind)==="spare"})&&t.rows.some(T=>T.id===E&&A(T));O&&e.rows.length>0&&!P&&(E=O.id);const R=e.archiving.filter(T=>t.rows.some($=>$.id===T));return D0({...Ua({...e,rows:t.rows,trunks:t.trunks,archiving:R.length===e.archiving.length?e.archiving:R,shipping:R0(e.shipping,t.rows,t.trunks),local:L0(qP(oL(e.local,e.rows,t.rows),t.rows,e.activeId,E===(O==null?void 0:O.id)?O.id:void 0),t.rows,e.archivedPage),treeOpen:P0(e.treeOpen,t.rows)},E),editor:E===e.activeId?e.editor:null,...O&&E===O.id?{carryTo:O.id}:{},...E===e.activeId?{activeRepoId:e.activeRepoId}:{},archivedPage:O?null:e.archivedPage,notesPage:O?!1:e.notesPage})}case"proc":{const E=e.rows.map(N=>N.id===t.worktreeId?{...N,procs:cL(N.procs,t.proc)}:N);return{...e,rows:E}}case"log":return xt(e,t.worktreeId,E=>({...E,log:sC(E.log.slice(-400),t.proc,t.line,t.retract)}));case"agent":{const E=t.event,N=t.worktreeId;let A=xt(e,N,O=>{const P=F0(O.chat,E,t.seq),T=E.type==="tool-start"||E.type==="tool-end"||E.type==="turn-end"||E.type==="agent-error"||E.type==="tool-update"&&E.background?$0(P,O.running):O.running;let $=O.turn;E.type==="turn-start"?$={edits:!1,hmr:!1}:E.type==="tool-start"&&Sg(E)&&($={...$,edits:!0});const D=E.type==="session-info"&&E.model?E.model:O.model,z=E.type==="session-info"&&E.effort?E.effort:O.effort,V=E.type==="usage"?{...z0(E),heard:Date.now()}:O.usage,se=e.rows.find(B=>B.id===N),I=(se==null?void 0:se.agent)==="working"||(se==null?void 0:se.agent)==="waiting",ne=O.sending?I?Oc(O):{...O,sending:{at:O.sending.at}}:O,we=E.type==="turn-end"||E.type==="agent-error",K=GP(E.type==="user-message"?ne:we?Oc(O):O,E);return{...E.type==="user-message"?Ha(K,"reveal"):K,chat:P,...P!==O.chat?{chatAt:Date.now()}:{},...T!==O.running?{running:T}:{},turn:$,...D!==O.model?{model:D}:{},...z!==O.effort?{effort:z}:{},...V!==O.usage?{usage:V}:{}}});if(E.type==="agent-ask-end"&&!Vg(E.outcome)&&((h=A.local[Za(E.id)])!=null&&h.attachments.length)&&(A=xt(A,Za(E.id),O=>({...O,attachments:[]}))),E.type==="user-message"){const O=mE(((p=e.local[N])==null?void 0:p.chat)??[]),P=O?Za(O.id):null,R=P?((m=A.local[P])==null?void 0:m.attachments)??[]:[];P&&R.length&&(A=xt(A,P,T=>({...T,attachments:[]})),A=xt(A,N,T=>({...T,attachments:[...T.attachments,...R]})))}if(E.type==="turn-end"){const O=A.local[N].turn;O.edits&&!O.hmr&&(A={...A,reloadReq:{id:N,n:(((k=A.reloadReq)==null?void 0:k.n)??0)+1}})}return(E.type==="agent-question"||E.type==="agent-permission"||E.type==="handoff-proposed")&&N===e.activeId&&(A=Uo(A)),A}case"backfill":{let E=[],N;for(const{seq:O,event:P}of t.events)E=F0(E,P,O),P.type==="usage"&&(N=z0(P));const A=O=>t.events.some(({event:P})=>P.type==="user-message"&&P.text===O);return xt(e,t.worktreeId,({sending:O,...P})=>({...P,...O&&!(O.message&&A(O.message.text))?{sending:O}:{},chat:E,chatAt:Date.now(),running:$0(E,P.running),log:t.log??P.log,...N?{usage:N}:{}}))}case"git-status":{let E=e.layout.changes,N=e.changesAuto;e.changesAuto&&t.worktreeId===e.activeId&&!E&&(t.files.length>0||(((g=t.committed)==null?void 0:g.length)??0)>0)&&(E=!0,N=!1);const A=t.worktreeId===e.archivedPage?Ao(e):null;A&&(t.files.length>0||(((y=t.committed)==null?void 0:y.length)??0)>0||A.landed)&&(E=!0);const O=xt(e,t.worktreeId,P=>({...P,git:{files:t.files,committed:t.committed,turn:t.turn,ahead:t.ahead,behind:t.behind,unpushed:t.unpushed,head:t.head},changedRanges:{}}));return{...to(O,{changes:E}),changesAuto:N}}case"changed-ranges":{const E=xt(e,t.worktreeId,A=>({...A,changedRanges:{...A.changedRanges,[t.path]:{ranges:t.ranges,offset:t.lineOffset}}})),N=E.editor;return!((b=N==null?void 0:N.line)!=null&&b.fiber)||N.worktreeId!==t.worktreeId||N.path!==t.path?E:{...E,editor:{...N,line:NE(E,N.worktreeId,N.path,N.line)}}}case"shipped":{const E=t.worktreeId,N={...e,shipping:I0(e.shipping,A=>{var O;return A===E&&((O=e.shipping[A])==null?void 0:O.sent)===!0}),openUrl:t.ok&&t.url?t.url:e.openUrl};return!t.ok&&!t.asked?E?O0(N,E,t.message):Im(N,t.message):N}case"files":return xt(e,t.worktreeId,E=>({...E,files:t.paths,submodules:t.submodules,ignored:t.ignored}));case"search-results":return xt(e,t.worktreeId,E=>({...E,search:{query:t.query,hits:t.hits,truncated:t.truncated}}));case"element-sources":{if(e.editor&&e.editor.seq>t.seq)return e;const[E]=t.hits;if(!E)return xt(e,t.worktreeId,A=>({...A,notice:"nothing in the source matches this element"}));if(!t.sure)return li(e,{a:"open",overlay:{kind:"element-sources",worktreeId:t.worktreeId,hits:t.hits}});const N=li(e,{a:"open-file",v:{worktreeId:t.worktreeId,path:E.path,view:"file",line:{n:E.line},focus:!0,seq:t.seq}});return N.layout.changes?N:li(N,{a:"toggle-changes"})}case"design-index":return xt(e,t.worktreeId,E=>({...E,design:t.index}));case"routes":return xt(e,t.worktreeId,E=>({...E,pages:{routes:t.routes,unseen:t.unseen}}));case"queue":return xt(e,t.worktreeId,E=>({...E,queue:t.items}));case"agent-commands":return xt(e,t.worktreeId,E=>({...E,commands:t.commands}));case"git-log":return xt(e,t.worktreeId,E=>({...E,commits:t.commits}));case"git-commit":return xt(e,t.worktreeId,E=>({...E,commitFiles:{...E.commitFiles,[t.sha]:t.files}}));case"error":{const E=t.worktreeId,N=e.newProject,A=(N==null?void 0:N.phase)==="creating"&&!N.repoId,O={...ZP(e,E),archiving:E?e.archiving.includes(E)?e.archiving.filter(P=>P!==E):e.archiving:e.archiving.length?[]:e.archiving,shipping:I0(e.shipping,P=>!E||P===E),newProject:A?{...N,phase:"editing",error:t.message}:(N==null?void 0:N.phase)==="unmaking"?null:N,pendingOpen:A?!1:e.pendingOpen,updateCheck:!E&&e.updateCheck==="asking"?null:e.updateCheck};return A?O:E?O0(O,E,t.message):Im(O,t.message)}case"unsent":{const E=((S=ls(t.boxId))==null?void 0:S.source)??t.boxId,N=!ko(e,E)&&!!e.activeRepoId&&((j=e.archived[e.activeRepoId])==null?void 0:j.some(A=>A.id===E));return xt(Uo(N?AE(e,E):e),E,({sending:A,...O})=>({...O,draft:O.draft||t.text,attachments:[...Cm(t.items,[]),...O.attachments],notice:t.message}))}default:return e}}function cL(e,t){const n=e.findIndex(o=>o.name===t.name);if(n===-1)return[...e,t];const r=e.slice();return r[n]=t,r}function z0(e){return{used:e.used,size:e.size,...e.cost!==void 0?{cost:e.cost}:{}}}function uL(e,t){const n=t.trim();return n!==""&&(e.trim()===n||e.trim().endsWith(`: ${n}`))}function F0(e,t,n){var i,l;const r=e[e.length-1],o=n===void 0?{}:{seq:n};switch(t.type){case"fix-asked":return[...e,{kind:"asked",about:t.kind,why:t.why,...t.toolId?{toolId:t.toolId}:{}}];case"user-message":return[...e,{kind:"user",text:t.text,...(i=t.attachments)!=null&&i.length?{attachments:t.attachments}:{},...o}];case"text-delta":{const c=t.messageId?{messageId:t.messageId}:{};if((r==null?void 0:r.kind)==="assistant")return[...e.slice(0,-1),{...r,text:r.text+t.text,...c}];const u=t.messageId===void 0?-1:dL(e,t.messageId);if(u!==-1){const h=e.slice(),p=h[u];return h[u]={...p,text:p.text+t.text},h}return[...e,{kind:"assistant",text:t.text,...o,...c}]}case"thinking-delta":return(r==null?void 0:r.kind)==="thinking"?[...e.slice(0,-1),{...r,text:r.text+t.text}]:[...e,{kind:"thinking",text:t.text}];case"tool-start":return[...e,{kind:"tool",id:t.toolId,name:t.name,input:t.input,done:!1,...t.kind?{toolKind:t.kind}:{},...t.title?{title:t.title}:{},...t.parentToolId?{parentToolId:t.parentToolId}:{},...t.subagent?{subagent:!0}:{}}];case"tool-update":{const c=e.findLastIndex(p=>p.kind==="tool"&&p.id===t.toolId);if(c===-1)return e;const u=e.slice(),h=u[c];return u[c]={...h,...t.name?{name:t.name}:{},...t.title?{title:t.title}:{},...t.input!==void 0?{input:t.input}:{},...t.kind?{toolKind:t.kind}:{},...t.background?{background:!0}:{}},u}case"tool-delta":{const c=e.findLastIndex(p=>p.kind==="tool"&&p.id===t.toolId);if(c===-1)return e;const u=e.slice(),h=u[c];return u[c]={...h,output:(h.output??"")+t.text},u}case"tool-end":{const c=e.findLastIndex(p=>p.kind==="tool"&&p.id===t.toolId);if(c===-1)return e;const u=e.slice(),h=u[c];return u[c]={...h,output:t.output,isError:t.isError,...(l=t.images)!=null&&l.length?{images:t.images}:{},...t.detached?{detached:!0}:{},...t.fixable?{fixable:t.fixable}:{},done:!0},u}case"agent-error":{const c=B0(e);return(r==null?void 0:r.kind)==="assistant"&&uL(t.message,r.text)?[...c.slice(0,-1),{kind:"error",text:t.message,...o}]:[...c,{kind:"error",text:t.message,...o}]}case"page-error":return[...e,{kind:"page-error",errors:t.errors,...o}];case"agent-blocked":return[...e,{kind:"blocked",tool:t.tool,path:t.path,reason:t.reason}];case"grafted":return[...e,{kind:"grafted",title:t.title,branch:t.branch}];case"landed":return[...e,{kind:"landed",text:t.message,archiveIds:t.archiveIds,...t.mark?{mark:t.mark}:{},ts:t.ts}];case"handoff-proposed":return[...e,{kind:"handoff",id:t.id,repo:t.repo,message:t.message,...t.title?{title:t.title}:{},by:t.by,mode:t.mode,state:"proposed",ts:t.ts}];case"handoff-go":{const c=Pp(e,t.id);if(c===-1)return e;const u=e.slice(),h=u[c];return u[c]={...h,state:"starting"},u}case"handoff":{const c=Pp(e,t.id);if(c===-1)return[...e,{kind:"handoff",id:t.id,repo:{id:t.repoId,name:t.repoName,path:""},message:"",title:t.title,by:"agent",mode:Hd,state:"continued",worktreeId:t.worktreeId,ts:t.ts}];const u=e.slice(),h=u[c];return u[c]={...h,state:"continued",worktreeId:t.worktreeId,title:t.title},u}case"handoff-declined":{const c=Pp(e,t.id);if(c===-1)return e;const u=e.slice(),h=u[c];return u[c]={...h,state:"declined",...t.reason?{reason:t.reason}:{}},u}case"handoff-landed":return[...e,{kind:"handoff-landed",worktreeId:t.worktreeId,repoName:t.repoName,title:t.title,...t.url?{url:t.url}:{},ts:t.ts}];case"restored":return[...e,{kind:"restored",archivedAt:t.archivedAt,branch:t.branch,uncommitted:t.uncommitted,ts:t.ts}];case"adopted":return[...e,{kind:"adopted",branch:t.branch,ts:t.ts}];case"agent-auth-required":return[...e,{kind:"auth",agent:t.agent,agentName:t.agentName,methods:t.methods,...t.rejected?{rejected:!0}:{},...t.withheld?{withheld:!0}:{},done:!1}];case"agent-auth-ok":return e.some(c=>c.kind==="auth"&&!c.done)?e.map(c=>c.kind==="auth"&&!c.done?{...c,done:!0}:c):e;case"agent-question":return U0(e,t.toolId,{kind:"ask",id:t.id,ask:{kind:"question",message:t.message,questions:t.questions}});case"agent-permission":{const c={kind:"ask",id:t.id,ask:{kind:"permission",title:t.title,...t.command?{command:t.command}:{},...t.detail?{detail:t.detail}:{},...t.plan?{plan:t.plan}:{},choices:t.choices}},u=e.findLast(h=>h.kind==="tool"&&h.id===t.toolId);return(u==null?void 0:u.kind)!=="tool"||t.plan||u.toolKind==="switch_mode"?U0(e,t.toolId,c):[...e,{...c,toolId:u.id}]}case"agent-ask-end":{const c=e.findLastIndex(p=>p.kind==="ask"&&p.id===t.id&&!p.outcome);if(c===-1)return e;const u=e[c];if(u.toolId&&fL(u,t.choiceId))return[...e.slice(0,c),...e.slice(c+1)];const h=e.slice();return h[c]={...h[c],outcome:t.outcome,...t.answers?{answers:t.answers}:{},...t.choiceId?{choiceId:t.choiceId}:{}},h}case"turn-end":{const c=B0(e);return t.stopReason==="interrupted"?[...c,{kind:"stopped",...o}]:c}default:return e}}function B0(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 dL(e,t){var o;let n=e.length-1;for(;n>=0&&((o=e[n])==null?void 0:o.kind)==="user";)n--;const r=e[n];return(r==null?void 0:r.kind)==="assistant"&&r.messageId===t?n:-1}function Pp(e,t){return e.findLastIndex(n=>n.kind==="handoff"&&n.id===t&&(n.state==="proposed"||n.state==="starting"))}function fL(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 U0(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 hL(e){let t=e;const n=new Set;return{getState:()=>t,dispatch(r){const o=li(t,r);if(o!==t){t=o;for(const i of n)i()}},subscribe(r){return n.add(r),()=>n.delete(r)}}}const BE=_.createContext(null),dk=_.createContext(null),UE=_.createContext(null);function pL({store:e,sock:t,files:n,children:r}){return d.jsx(BE.Provider,{value:e,children:d.jsx(dk.Provider,{value:t,children:d.jsx(UE.Provider,{value:n,children:r})})})}const HE=_.createContext(null),WE=_.createContext(null);function mL({machines:e,children:t}){const n=_.useSyncExternalStore(e.subscribe,e.active);return d.jsx(HE.Provider,{value:e,children:d.jsx(WE.Provider,{value:n,children:d.jsx(pL,{store:n.store,sock:n.sock,files:n.files,children:d.jsx(_.Fragment,{children:t},n.origin)})})})}function Vo(){const e=_.useContext(HE);if(!e)throw new Error("useMachines outside <MachinesProvider>");return e}function lo(){const e=_.useContext(WE);if(!e)throw new Error("useMachine outside <MachinesProvider>");return e}function fk(){const e=Vo();return _.useSyncExternalStore(e.subscribe,e.list)}function Da(e,t){return _.useSyncExternalStore(e.store.subscribe,()=>t(e.store.getState()))}const Rm=(e,t)=>e.length===t.length&&e.every((n,r)=>n===t[r]);function KE(){const e=Vo(),t=lo(),n=fk(),r=_.useMemo(()=>n.filter(c=>c!==t),[n,t]),o=_.useRef(null),i=_.useCallback(c=>{const u=r.map(h=>h.store.subscribe(c));return()=>{for(const h of u)h()}},[r]),l=_.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&&Rm(h.names,c)&&Rm(h.repos,u))return h.value;const p=r.map((m,k)=>({origin:m.origin,name:c[k]??m.origin,repos:u[k]??[]}));return o.current={others:r,names:c,repos:u,value:p},p},[r,e]);return _.useSyncExternalStore(i,l)}function ZE(){const e=lo(),t=fk(),n=_.useMemo(()=>t.filter(l=>l!==e),[t,e]),r=_.useRef(null),o=_.useCallback(l=>{const c=n.map(u=>u.store.subscribe(l));return()=>{for(const u of c)u()}},[n]),i=_.useCallback(()=>{const l=n.map(h=>{const p=h.store.getState();return p.connected&&!p.incompatible?p.rows:H0}),c=r.current;if(c&&c.others===n&&Rm(c.rows,l))return c.value;const u=n.map((h,p)=>({origin:h.origin,rows:(l[p]??H0).filter(vn)}));return r.current={others:n,rows:l,value:u},u},[n]);return _.useSyncExternalStore(o,i)}const H0=[];function gW(){return lo().terminals}function Zn(){const e=_.useContext(BE);if(!e)throw new Error("useStore outside <StoreProvider>");return e}function L(e){const t=Zn();return _.useSyncExternalStore(t.subscribe,()=>e(t.getState()))}function hk(){const e=L(n=>n.systemDark),t=L(n=>{var r;return(r=n.daylight)==null?void 0:r.dark});return{system:e,daylight:t??e}}function ut(){return Zn().dispatch}function pt(){return _.useContext(dk)}function Lr(){const e=_.useContext(dk);return(e==null?void 0:e.urls)??Zg(location.origin,"")}function qE(){return _.useContext(UE)}function gL(e=!1,t=!0){const n=_.useRef(null);return _.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 No(e,t,n,r=kL){const o=()=>{try{return n(r.get(e))??t}catch{return t}},[i,l]=_.useState(()=>({key:e,value:o()}));return i.key!==e&&l({key:e,value:o()}),[i.key===e?i.value:o(),h=>{l({key:e,value:h});try{r.set(e,typeof h=="boolean"?h?"1":"0":String(h))}catch{}}]}const kL={get:e=>localStorage.getItem(e),set:(e,t)=>localStorage.setItem(e,t)};function Xa(e,t){return n=>{n.preventDefault(),document.body.classList.add("resizing");const r=n.currentTarget;r.classList.add("active");const o=l=>{const c=e(l,r);c!==null&&t(c)},i=()=>{document.body.classList.remove("resizing"),r.classList.remove("active"),window.removeEventListener("pointermove",o),window.removeEventListener("pointerup",i)};window.addEventListener("pointermove",o),window.addEventListener("pointerup",i)}}function GE(e,t){const[n,r]=_.useState(!1);return _.useEffect(()=>{if(!e){r(!1);return}const o=setTimeout(()=>r(!0),t);return()=>clearTimeout(o)},[e,t]),n}function pk(e,t){const[n,r]=_.useState(void 0);return _.useEffect(()=>{if(e===void 0){r(void 0);return}const o=setTimeout(()=>r(e),t);return()=>clearTimeout(o)},[e,t]),n}const mk=1500;function Qi(e){const[t,n]=_.useState(()=>Date.now()),r=e!==void 0;return _.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 wL(){const[e,t]=_.useState(window.innerWidth);return _.useEffect(()=>{const n=()=>t(window.innerWidth);return window.addEventListener("resize",n),()=>window.removeEventListener("resize",n)},[]),e}function yL(e){const t=_.useRef(null);return _.useLayoutEffect(()=>{const n=t.current;if(!n)return;t.current=null;const r=n.closest(e);if(!r)return;const o=r.getBoundingClientRect(),i=n.getBoundingClientRect(),l=i.bottom-o.bottom;if(l<=0)return;const c=parseFloat(getComputedStyle(r).paddingTop)||0;r.scrollTop+=Math.min(l,Math.max(0,i.top-o.top-c))}),n=>{t.current=n}}const Dd=40,vL=1200,bL=150,xL=new Set(["ArrowUp","ArrowDown","PageUp","PageDown","Home","End"," "]);function VE(e,t){const n=_.useRef(!0),r=_.useRef(Number.NEGATIVE_INFINITY),o=_.useRef(!1),[i,l]=_.useState(!1),[c,u]=_.useState(!1),[h,p]=_.useState(!1),[m,k]=_.useState(null),g=_.useCallback(A=>{n.current=A,e.current&&(e.current.style.overflowAnchor=A?"none":"")},[e]),y=_.useRef(null),b=_.useRef(null);gt([t],()=>{n.current||p(!0)});const S=_.useCallback(()=>{const A=e.current;A&&(g(A.scrollHeight-A.scrollTop-A.clientHeight<Dd),l(!n.current),u(A.scrollTop>=Dd),n.current&&p(!1))},[e,g]),j=_.useCallback(A=>{A!==0&&(k(A<0?"up":"down"),b.current&&clearTimeout(b.current),b.current=setTimeout(()=>k(null),vL))},[]),E=_.useCallback(()=>{const A=e.current;A&&(A.scrollTop=A.scrollHeight,g(!0),l(!1),p(!1))},[e,g]),N=_.useCallback(()=>{const A=e.current;A&&(r.current=performance.now(),A.scrollTop=0)},[e]);return _.useEffect(()=>{const A=e.current;if(!A)return;g(n.current);const O=()=>o.current||performance.now()-r.current<bL,P=()=>{n.current&&!O()?u(A.scrollTop>=Dd):S()};A.addEventListener("scroll",P,{passive:!0});const R=()=>{r.current=performance.now()},T=K=>{R(),j(K.deltaY)},$=K=>{var B;R(),y.current=((B=K.touches[0])==null?void 0:B.clientY)??null},D=K=>{var ee;R();const B=(ee=K.touches[0])==null?void 0:ee.clientY;B===void 0||y.current===null||(j(y.current-B),y.current=B)},z=()=>{o.current=!0},V=()=>{o.current=!1},se=K=>{if(!xL.has(K.key))return;const B=K.target;(B===document.body||B instanceof Node&&A.contains(B))&&R()};A.addEventListener("wheel",T,{passive:!0}),A.addEventListener("touchstart",$,{passive:!0}),A.addEventListener("touchmove",D,{passive:!0}),A.addEventListener("pointerdown",z,{passive:!0}),window.addEventListener("pointerup",V,{passive:!0}),window.addEventListener("pointercancel",V,{passive:!0}),document.addEventListener("keydown",se);const I=()=>{A.scrollTop=A.scrollHeight},ne=new ResizeObserver(()=>{n.current&&I()});ne.observe(A);for(const K of A.children)ne.observe(K);const we=new MutationObserver(K=>{for(const B of K){for(const ee of B.addedNodes)ee instanceof Element&&ne.observe(ee);for(const ee of B.removedNodes)ee instanceof Element&&ne.unobserve(ee)}n.current&&I()});return we.observe(A,{childList:!0}),()=>{A.removeEventListener("scroll",P),A.removeEventListener("wheel",T),A.removeEventListener("touchstart",$),A.removeEventListener("touchmove",D),A.removeEventListener("pointerdown",z),window.removeEventListener("pointerup",V),window.removeEventListener("pointercancel",V),document.removeEventListener("keydown",se),we.disconnect(),ne.disconnect(),b.current&&clearTimeout(b.current)}},[e,S,j,g]),{offEnd:i,offStart:c,away:h,moving:m,pinned:()=>n.current,jump:E,start:N,read:S}}function W0(e,t,n){const r=document.createRange();return r.selectNodeContents(e),r.setEnd(t,n),r.toString().length}function K0(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 YE(e,t){_.useLayoutEffect(()=>{const n=e.current;if(!n)return;const r=window.getSelection(),o=k=>!!k&&n.contains(k),i=r&&r.rangeCount>0&&o(r.anchorNode)?W0(n,r.anchorNode,r.anchorOffset):null,l=r&&r.rangeCount>0&&o(r.focusNode)?W0(n,r.focusNode,r.focusOffset):null,c=r&&(i!==null||l!==null)?[r.anchorNode,r.anchorOffset,r.focusNode,r.focusOffset]:null;if(n.innerHTML=t,!r||!c)return;const[u,h]=i===null?[c[0],c[1]]:K0(n,i),[p,m]=l===null?[c[2],c[3]]:K0(n,l);u&&p&&r.setBaseAndExtent(u,h,p,m)},[e,t])}function gt(e,t){const n=_.useRef(t);n.current=t,_.useEffect(()=>n.current(),e)}function XE(e){const[t,n]=_.useState({left:0,right:0});return _.useLayoutEffect(()=>{if(!e)return;const r=()=>{const i=e.getBoundingClientRect();let{left:l,right:c}=i;const u=e.closest("[data-pinned]");if(u){const p=u.getBoundingClientRect(),m=u.offsetWidth/p.width;l=u.offsetLeft+(l-p.left)*m,c=u.offsetLeft+(c-p.left)*m}const h={left:Math.round(l),right:Math.round(c)};n(p=>p.left===h.left&&p.right===h.right?p:h)};r();const o=new ResizeObserver(r);return o.observe(e),window.addEventListener("resize",r),()=>{o.disconnect(),window.removeEventListener("resize",r)}},[e]),t}function Z0(){const[e,t]=_.useState(null);return[t,XE(e)]}function kW(e){e.ctrlKey&&e.stopPropagation()}function EL(e){_.useEffect(()=>{const t=window.visualViewport;if(!t)return;const n=()=>{const r=e.current;r&&(t.scale<1.01?delete r.dataset.zoomed:r.dataset.zoomed="")};return n(),t.addEventListener("resize",n),()=>t.removeEventListener("resize",n)},[e])}function SL(e){_.useEffect(()=>{const t=window.visualViewport;if(!t)return;const n=()=>{var r;(r=e.current)==null||r.style.setProperty("--visible-height",`${Math.round(t.height)}px`)};return n(),t.addEventListener("resize",n),()=>t.removeEventListener("resize",n)},[e])}function _L(e){_.useEffect(()=>{const t=window.visualViewport;if(!t)return;const n=()=>{const r=e.current;if(r){if(t.scale<1.01){delete r.dataset.pinned;return}r.dataset.pinned="",r.style.setProperty("--pin-x",`${t.offsetLeft}px`),r.style.setProperty("--pin-y",`${t.offsetTop}px`),r.style.setProperty("--pin-scale",String(1/t.scale))}};return n(),t.addEventListener("resize",n),t.addEventListener("scroll",n),()=>{t.removeEventListener("resize",n),t.removeEventListener("scroll",n)}},[e])}function NL(e,t,n){const[r,o]=_.useState(),i=_.useRef(e);return i.current=e,_.useEffect(()=>{if(!n)return;let l=!0,c;const u=()=>void i.current().then(h=>{l&&(o(h),c=setTimeout(u,t))});return u(),()=>{l=!1,clearTimeout(c)}},[t,n]),r}const hl=()=>L(e=>e.activeId),QE=()=>GE(!L(e=>e.connected),900),Rs=()=>L(e=>pn(e,e.activeId)),gk=()=>L(e=>ko(e,e.activeId)),JE=()=>L(e=>e.rows),kk=()=>L(e=>e.visible),TL=()=>L(e=>e.visibleDiscovered),jL=()=>L(e=>e.activeRepoId?e.discoveredOpen[e.activeRepoId]??!1:!1),q0=[],CL=()=>L(e=>e.activeRepoId?e.archived[e.activeRepoId]??q0:q0),AL=()=>L(e=>e.activeRepoId?e.archivedOpen[e.activeRepoId]??!1:!1),IL=()=>L(e=>!(e.activeRepoId&&e.committedShut[e.activeRepoId])),RL=()=>L(e=>!!(e.activeRepoId&&e.turnOpen[e.activeRepoId])),ia=()=>L(Ao),wk=()=>L(ME),$L=()=>L(e=>yi(e,e.activeRepoId)),pl=()=>L(e=>yi(e,lk(e))),eS=e=>L(t=>Co(t,e)),It=(e,t)=>L(n=>Co(n,e)[t]),OL=()=>L(e=>e.overlay),Df=()=>L(LP),tS=()=>L(jE),Yc=()=>L(DP),Xc=()=>L(To),ML=()=>L(e=>e.newProject),vi=()=>L(e=>e.touch),PL=()=>L(e=>e.draft),yk=()=>L(pc),LL=()=>L(e=>{const t=ko(e,e.activeId),n=t?e.repos.find(r=>r.id===t.repoId):null;return ef(n)?n:null});function DL(e){return e.image?{kind:"image",blob:e.image,sig:`image:${e.image.type}:${e.image.size}`}:e.text&&X1(e.text)?{kind:"text",text:e.text,sig:`text:${e.text}`}:null}function zL(){try{return localStorage.getItem(Xe.clipboardOffer)==="1"}catch{return!1}}let As={access:"none",on:typeof localStorage<"u"&&zL(),offer:null},$m="";const Om=new Set;function zf(e){As={...As,...e};for(const t of Om)t()}async function FL(){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 DL({image:e,text:t})}async function Ff({taken:e=!1,asking:t=!1}={}){if(!As.on||!(As.access==="granted"||t&&As.access==="prompt"))return;let n;try{n=await FL()}catch{return}e&&($m=(n==null?void 0:n.sig)??""),zf({offer:n&&n.sig!==$m?n:null})}const BL=()=>void Ff();let G0=!1;function UL(){var e,t;G0||(G0=!0,!(!((e=navigator.clipboard)!=null&&e.read)||!((t=navigator.permissions)!=null&&t.query))&&navigator.permissions.query({name:"clipboard-read"}).then(n=>{const r=()=>{zf({access:n.state,...n.state==="denied"?{offer:null}:{}})};n.onchange=r,r(),window.addEventListener("focus",BL),document.hasFocus()&&Ff()},()=>{}))}function HL(e){return Om.add(e),UL(),()=>{Om.delete(e)}}const WL=()=>As;function KL(e){try{localStorage.setItem(Xe.clipboardOffer,e?"1":"0")}catch{}zf({on:e,offer:null}),e&&Ff({asking:!0})}function nS(){As.offer&&($m=As.offer.sig),zf({offer:null})}const ZL=()=>void Ff({taken:!0});function qL(){return _.useSyncExternalStore(HL,()=>As.offer)}const rS="application/x-toyon-source";function wW(e){const t=e.endColumn===1&&e.endLineNumber>e.startLineNumber?e.endLineNumber-1:e.endLineNumber;return{startLine:e.startLineNumber,endLine:t}}function GL(e,t){e.setData(rS,JSON.stringify(t))}const V0=e=>typeof e=="number"&&Number.isInteger(e)&&e>=1;function VL(e,t){const n=e.getData(rS);if(!n||!t)return null;let r;try{r=JSON.parse(n)}catch{return null}if(!r||r.worktreeId!==t||typeof r.path!="string"||!r.path)return null;const{startLine:o,endLine:i,ref:l}=r;return!V0(o)||!V0(i)||i<o?null:{path:r.path,startLine:o,endLine:i,...typeof l=="string"?{ref:l}:{}}}const oS=e=>({left:e.x,top:e.y,right:e.x,bottom:e.y});function YL(e,t){return t.matchWidth===void 0?void 0:Math.max(0,e.right-e.left+t.matchWidth)}const XL=new Set(["top","bottom"]),Lp={top:"bottom",bottom:"top",left:"right",right:"left"};function Dp(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 Y0(e,t,n,r,o){return n==="top"||n==="left"?e>=o:e+t<=r-o}function zp(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 X0(e,t,n,r,o){return n==="start"?e+t<=r-o:e>=o}const Q0=(e,t,n,r)=>n||!r?e:t,J0=(e,t,n,r)=>Math.max(r,Math.min(e,n-r-t));function QL(e,t,n,r){const{offset:o=0,alignOffset:i=0,cover:l=!1,flip:c="none",margin:u=8}=r,h=XL.has(r.side),p=h?{a:{start:e.top,end:e.bottom},size:t.h,limit:n.h}:{a:{start:e.left,end:e.right},size:t.w,limit:n.w},m=h?{a:{start:e.left,end:e.right},size:t.w,limit:n.w}:{a:{start:e.top,end:e.bottom},size:t.h,limit:n.h};let k=r.side;if(c==="side"||c==="both"){const S=Dp(p.a,p.size,k,o,l),j=Dp(p.a,p.size,Lp[k],o,l);k=Q0(k,Lp[k],Y0(S,p.size,k,p.limit,u),Y0(j,p.size,Lp[k],p.limit,u))}let g=r.align??"center";if((c==="align"||c==="both")&&g!=="center"){const S=g==="start"?"end":"start",j=zp(m.a,m.size,g,i),E=zp(m.a,m.size,S,i);g=Q0(g,S,X0(j,m.size,g,m.limit,u),X0(E,m.size,S,m.limit,u))}const y=J0(Dp(p.a,p.size,k,o,l),p.size,p.limit,u),b=J0(zp(m.a,m.size,g,i),m.size,m.limit,u);return h?{x:b,y,side:k,align:g}:{x:y,y:b,side:k,align:g}}function JL(e,t,n){var i,l;const r=e.length;if(r===0)return-1;let o=t<0?n===1?0:r-1:(t+n+r)%r;for(let c=0;c<r&&((i=e[o])!=null&&i.disabled);c++)o=(o+n+r)%r;return(l=e[o])!=null&&l.disabled?-1:o}const sS={sep:!0},cs=e=>!("sep"in e);function Bf(e){const t=[];for(const n of e)(cs(n)||t.length>0&&cs(t[t.length-1]))&&t.push(n);for(;t.length>0&&!cs(t[t.length-1]);)t.pop();return t}const Ln=e=>Bf(e.flatMap((t,n)=>n?[sS,...t]:t));let Ma=null,e4=0;const Mm=new Set,eb=()=>{for(const e of Mm)e()},so={get:()=>Ma,subscribe(e){return Mm.add(e),()=>{Mm.delete(e)}},open(e){const t=Bf(e.items);if(t.length===0)return so.close();Ma={...e,items:t,id:++e4},eb()},close(){Ma&&(Ma=null,eb())},toggle(e){Ma&&Ma.target===e.target?so.close():so.open(e)}};function vk(){return _.useSyncExternalStore(so.subscribe,so.get)}function iS(e){const t=e.nativeEvent;return t&&"pointerType"in t?t.pointerType==="":e.clientX===0&&e.clientY===0}function t4(e,t){return iS(e)?{anchor:(t.querySelector('[data-state~="cursor"]')??t).getBoundingClientRect()}:{at:{x:e.clientX,y:e.clientY}}}function n4(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:oS(e.at??{x:0,y:0}),placement:{side:"bottom",align:"start",margin:4}}}function bn(e){return _.useMemo(()=>({contextMenu(t,n){return{onContextMenu:r=>{const o=Bf(t(iS(r)?"keyboard":"pointer",r.target));if(o.length===0)return;r.preventDefault(),r.stopPropagation();const i=r.currentTarget;so.open({items:o,owner:e,key:n,target:i,...t4(r,i)})}}},dropdown(t,n="left",r){return{"aria-haspopup":"menu",onClick:o=>{o.stopPropagation();const i=o.currentTarget;so.toggle({items:t(),owner:e,key:r,target:i,toggles:!0,anchor:i.getBoundingClientRect(),align:n})}}},openUnder(t,n,r){so.open({items:n(),owner:e,key:r,target:t,toggles:!0,anchor:t.getBoundingClientRect(),align:"left"})}}),[e])}const aS=e=>({id:"open-out",label:nk()?"open in the browser":"open in a new tab",onClick:()=>window.open(e,"_blank")}),Jt=e=>{var t;return void((t=navigator.clipboard)==null?void 0:t.writeText(e).catch(()=>{}))};function lS(e,t){const n=navigator.clipboard;if(n){if(typeof ClipboardItem>"u"||!n.write){e==="text/plain"&&t.then(r=>r.text()).then(Jt,()=>{});return}n.write([new ClipboardItem({[e]:t})]).catch(()=>{})}}const r4=e=>lS("text/plain",fetch(e).then(t=>t.blob())),o4=e=>lS("image/png",s4(e));async function s4(e){const t=await(await fetch(e)).blob();if(t.type==="image/png")return t;const n=await createImageBitmap(t);try{const r=document.createElement("canvas");return r.width=n.width,r.height=n.height,r.getContext("2d").drawImage(n,0,0),await new Promise((o,i)=>r.toBlob(l=>l?o(l):i(new Error("could not encode image")),"image/png"))}finally{n.close()}}function cS(e){return Ag(e)}function Is(e){return(e==null?void 0:e.urls.host)??(typeof location=="object"?location.hostname:"127.0.0.1")}function ds(e,t){return!e||!cS(t)?[]:[{id:"reveal",label:"reveal in Finder",onClick:e}]}function i4(e,t){const n=[];for(const r of t)r.xy.includes("D")?n.push(`-${r.path}`):/[?ARC]/.test(r.xy)&&n.push(`+${r.path}`);return`${e??""}
|
|
98
|
+
${n.sort().join(`
|
|
99
|
+
`)}`}function Uf(e,t,{sock:n,dispatch:r}){var l,c;if(!n)return;const o=t.local[e]??sa,i=i4((l=o.git)==null?void 0:l.head,((c=o.git)==null?void 0:c.files)??[]);o.filesFor!==i&&(r({a:"files-asked",worktreeId:e,key:i}),n.send({t:"list-files",worktreeId:e}))}const a4=["diff","file","preview"],uS=(e,t)=>a4.filter(n=>!(n==="preview"&&!Of(e))&&!(n==="diff"&&t));let l4=0;const Zo=()=>++l4;function tr({dispatch:e},{focus:t=!0,...n}){e({a:"open-file",v:{...n,focus:t,seq:Zo()}})}const Pm=new Map;function dS(e,t,n=""){const{sock:r}=e;if(!r)return Promise.resolve("not connected to the daemon");const o=Zo();return new Promise(i=>{Pm.set(o,l=>{l.ok?(tr(e,{...t,view:pi(t.path)}),i(null)):i(l.reason==="changed"?"a file is already there":l.message??"the file was not made")}),r.send({t:"write-file",...t,content:n,base:null,seq:o})})}function c4(e){const t=Pm.get(e.seq);return t?(Pm.delete(e.seq),t(e),!0):!1}function u4({dispatch:e},t){e({a:"tree-reveal",...t})}function js(e,t,{discard:n=!1,ref:r,since:o,showing:i,noDiff:l=!1,kept:c=!1,select:u},h){const{sock:p,dispatch:m}=h,k=uS(t,l).filter(E=>E!==i).map(E=>({id:`view:${E}`,label:`view ${E}`,onClick:()=>i?m({a:"editor-view",v:E}):tr(h,{worktreeId:e.id,path:t,view:E,ref:r,since:o})})),g=`${e.dir}/${t}`,y=c?[]:ds(()=>p==null?void 0:p.send({t:"reveal",worktreeId:e.id,path:t}),Is(p));return Ln([k,[{id:"copy-path",label:"copy path",onClick:()=>Jt(g)}],y,u?[{id:"select",label:"select…",onClick:()=>u(t)}]:[],n?[{id:"discard",label:"discard changes…",danger:!0,onClick:()=>{window.confirm(fS([t]))&&(p==null||p.send({t:"discard-files",worktreeId:e.id,paths:[t]}))}}]:[]])}function fS(e){if(e.length===1)return`Discard uncommitted changes to ${e[0]}?`;const t=e.slice(0,12),n=e.length-t.length,r=[...t,...n>0?[`and ${n} more`]:[]].join(`
|
|
100
|
+
`);return`Discard uncommitted changes to ${e.length} files?
|
|
101
|
+
|
|
102
|
+
${r}`}const go=(e,t,n)=>e.dispatch({a:"notice",id:t,text:n});function Hf(e,t,n){var o;const r=mC(((o=e.getState().local[t])==null?void 0:o.attachments)??[],n);return r===0&&go(e,t,Tg(n)),r}const d4=1e3,f4=1e4,hS=new WeakMap;function h4(e,t){hS.set(e,t)}async function pS(e,t,n,r){var y,b;const{local:o,...i}=n;e.dispatch({a:"attach",id:t,items:[{...n,upload:"",uploading:!0}]});const l=()=>{var S;return(S=Object.entries(e.getState().local).find(([,j])=>j.attachments.some(E=>E.key===n.key)))==null?void 0:S[0]},c=hS.get(e);let u=-1;const h=S=>{const j=Math.min(99,Math.floor(S*100)),E=l();j===u||E===void 0||(u=j,e.dispatch({a:"upload-progress",id:E,key:n.key,progress:j}))},p=()=>(u=-1,c?zM(c,n.kind,r,h):Promise.resolve(null));let m=await p();const k=m===null;k&&go(e,l()??t,`${n.name}: Toyon is not answering; it attaches once it is back`);for(let S=d4;m===null&&l()!==void 0;S=Math.min(S*2,f4))await new Promise(j=>setTimeout(j,S)),l()!==void 0&&(m=await p());const g=l();if(!(m===null||g===void 0))if(typeof m=="string")e.dispatch({a:"detach",id:g,key:n.key}),go(e,g,`${n.name}: ${m}`);else{const S=i.kind==="file"?{...i,...m}:{...i,upload:m.upload,bytes:m.bytes};e.dispatch({a:"attached",id:g,key:n.key,item:S});const j=(b=e.getState().local[((y=ls(g))==null?void 0:y.source)??g])==null?void 0:b.notice;k&&(j!=null&&j.startsWith(`${n.name}: Toyon is not answering`))&&go(e,g,"")}o&&URL.revokeObjectURL(o)}function bk(e,t,n){if(!t||n.length===0)return;const r=Hf(e,t,"file");if(r!==0){for(const o of n.slice(0,r)){const i=o.name||"file";if(o.size>k0){go(e,t,`${i}: larger than ${Cg(k0)}`);continue}const l={kind:"file",key:crypto.randomUUID(),upload:"",name:i,bytes:o.size,text:!1};pS(e,t,l,o)}n.length>r&&go(e,t,`kept ${r} of ${n.length}: ${Tg("file")}`)}}function xk(e,t,n,r={}){if(!t)return;const o=M2(r.source?n.replace(/\r?\n$/,""):n);if(o.length>T2)return r.source?go(e,t,"that paste is too large; save it in the worktree and reference it with @path"):bk(e,t,[new File([o],j2,{type:"text/plain"})]);Hf(e,t,"paste")!==0&&e.dispatch({a:"attach",id:t,items:[{kind:"paste",key:crypto.randomUUID(),text:o,...r,...Bg(o)}]})}function mS(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 tb(e,t){var i;const n=e.getState(),r=pn(n,n.activeId),o=fl(r);if(t&&o&&t.worktreeId===(r==null?void 0:r.worktree.id)&&t.text.trim()){const l="source"in t?{source:t.source}:{name:t.name};(((i=n.local[o])==null?void 0:i.attachments)??[]).some(u=>{var g;if(u.kind!=="paste")return!1;if(!("source"in t))return u.name===t.name&&u.text===t.text;const{path:h,startLine:p,endLine:m,ref:k}=t.source;return((g=u.source)==null?void 0:g.path)===h&&u.source.startLine===p&&u.source.endLine===m&&u.source.ref===k})||xk(e,o,t.text,l)}e.dispatch(t?{a:"focus-chat"}:CE(n))}function Wf(e,t){return t!==e.activeId?null:fl(pn(e,t))}const Ek=(e,t)=>`@${e}${t?"/":""}`;function Sk(e,t,n){var c;const r=e.getState(),o=Wf(r,t);if(!o)return;const i=((c=r.local[o])==null?void 0:c.draft)??"",l=i===""||/\s$/.test(i)?"":" ";e.dispatch({a:"set-draft",id:o,text:`${i}${l}${n}`}),e.dispatch({a:"focus-chat"})}function gS(e,t,n,r){Sk(e,t,`${Ek(n,r)} `)}function p4(e,t,n){n.length!==0&&Sk(e,t,`${n.map(r=>Ek(r,!1)).join(" ")} `)}function nb(e,t,n){Sk(e,t,n)}function m4(e,t){return pn(e,t)?t:null}function g4(e,t){var r;const n=(r=pn(e,t))==null?void 0:r.worktree;return n?[n.path]:[]}function rb(e,t){if(!e)return e;const n=t.find(r=>e.startsWith(`${r}/`));return n?e.slice(n.length+1):e}function k4(e,t,n){var k;e.dispatch({a:"set-picking",v:!1});const r=e.getState(),o=m4(r,t);if(!o)return;const{classes:i,route:l,element:c,...u}=n,h=g4(r,t),p={...u,file:rb(u.file,h),callFile:rb(u.callFile,h)};!(((k=r.local[o])==null?void 0:k.attachments)??[]).some(g=>g.kind==="pick"&&g.selector===p.selector)&&Hf(e,o,"pick")>0&&e.dispatch({a:"attach",id:o,items:[{kind:"pick",key:crypto.randomUUID(),...p}]}),e.dispatch({a:"focus-chat"})}function w4(e,t=[],n=[]){const r={path:"",name:"",kind:"folder",children:[],ignored:!1},o=new Map([["",r]]),i=u=>{const h=o.get(u);if(h)return h;const p=u.lastIndexOf("/"),m={path:u,name:u.slice(p+1),kind:"folder",children:[],ignored:!1};return i(p===-1?"":u.slice(0,p)).children.push(m),o.set(u,m),m},l=(u,h,p=!1)=>{const m=u.lastIndexOf("/");i(m===-1?"":u.slice(0,m)).children.push({path:u,name:u.slice(m+1),kind:h,children:[],ignored:p})};for(const u of e)l(u,"file");for(const u of t)l(u,"submodule");for(const u of n)u.endsWith("/")?l(u.slice(0,-1),"ignored",!0):l(u,"file",!0);const c=u=>{const h=p=>p.kind==="file"?1:0;u.children.sort((p,m)=>h(p)-h(m)||bE(p.name,m.name));for(const p of u.children)p.kind==="folder"&&c(p)};return c(r),r.children}function y4(e,t){const n=[],r=(o,i)=>{for(const l of o){const c=l.kind==="folder"&&t(l.path);n.push({path:l.path,name:l.name,depth:i,kind:l.kind,open:c,ignored:l.ignored}),c&&r(l.children,i+1)}};return r(e,0),n}const kS=e=>{const t=e.lastIndexOf("/");return t===-1?"":e.slice(0,t)};function v4(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 b4(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 Jd(o))n.add(i)}return{files:t,folders:n}}function _k(e){const t=e.findLast(n=>n.kind==="ask"&&!n.outcome||n.kind==="handoff"&&n.state==="proposed");return(t==null?void 0:t.kind)==="ask"||(t==null?void 0:t.kind)==="handoff"?t:null}function x4(e){const t=e?_k(e.chat):null;return(t==null?void 0:t.kind)!=="ask"||t.ask.kind!=="question"||(e==null?void 0:e.cardParked)===t.id?null:Za(t.id)}function ob(e){return e.kind==="ask"?sP(e):`Continue in ${e.repo.name}?`}function E4(e,t,n,r){const o=n?r==null?void 0:r.trim():void 0;return{t:"handoff-answer",worktreeId:t,id:e.id,go:n,...o?{note:o}:{}}}function S4(e,t,n){const r=e.trim();if(!r)return{pick:!0};if(t.length<2)return{error:"open another project first"};const o=r.search(/\s/),i=o===-1?r:r.slice(0,o),l=o===-1?void 0:r.slice(o).trim()||void 0,c=i.toLowerCase(),u=t.filter(m=>m.name.toLowerCase()===c),h=u.length>0?u:t.filter(m=>m.name.toLowerCase().startsWith(c));if(h.length===0)return{error:`no open project named "${i}"`};if(h.length>1)return{error:`"${i}" names more than one project`};const p=h[0];return p.id===n?{error:`this worktree is already in ${p.name}`}:{repo:p,...l?{text:l}:{}}}const wS=new Set(S2),_4=/^image\.[a-z0-9]+$/i,N4=e=>_4.test(e.name),T4=(e,t)=>e===t||e.name===t.name&&e.size===t.size&&e.type===t.type&&e.lastModified===t.lastModified;function j4(e){if(!e)return[];const t=[];for(const i of Array.from(e.items??[])){if(i.kind!=="file"||!i.type.startsWith("image/"))continue;const l=i.getAsFile();l&&t.push(l)}if(t.length===0)for(const i of Array.from(e.files??[]))i.type.startsWith("image/")&&t.push(i);const n=[];for(const i of t)n.some(l=>T4(l,i))||n.push(i);const r=n.filter(i=>!N4(i));if(r.length>0)return r;const o=n.find(i=>wS.has(i.type))??n[0];return o?[o]:[]}function C4(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 A4(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 I4(e){try{return await createImageBitmap(e)}catch{throw new Error(`${e.name||"image"}: not a readable image`)}}function sb(e,t,n){const r=document.createElement("canvas");return r.width=Math.max(1,Math.round(e.width*t)),r.height=Math.max(1,Math.round(e.height*t)),r.getContext("2d").drawImage(e,0,0,r.width,r.height),new Promise((o,i)=>r.toBlob(l=>l?o(l):i(new Error("could not encode image")),n,.9))}async function R4(e){const t=await I4(e);try{const n=Math.max(t.width,t.height);let r=e,o=e.type,i=t.width,l=t.height;if(!wS.has(o)||n>g0||e.size>Mp){const c=o==="image/jpeg"?"image/jpeg":"image/png";let u=Math.min(1,g0/n);for(r=await sb(t,u,c);r.size>Mp&&u>.1;)u*=.7,r=await sb(t,u,c);if(r.size>Mp)throw new Error(`${e.name||"image"}: too large even after downscaling`);o=c,i=Math.max(1,Math.round(t.width*u)),l=Math.max(1,Math.round(t.height*u))}return{blob:r,name:e.name||`pasted.${o==="image/jpeg"?"jpg":"png"}`,mimeType:o,width:i,height:l}}finally{t.close()}}const Sc={el:null},$4=80,O4=2e3;let us=null,Lm;const yS=(e,t)=>{clearTimeout(Lm),Lm=setTimeout(()=>Tk(e),t)};function Nk(e,t){us??(us={refused:!1}),e.dispatch({a:"drag-files",v:us.refused?null:t}),yS(e,O4)}function vS(e){us&&yS(e,$4)}function Tk(e){clearTimeout(Lm),us=null,e.dispatch({a:"drag-files",v:null})}function M4(e){us&&(us.refused=!0,e.dispatch({a:"drag-files",v:null}))}const bS="application/x-toyon-path";let Vi=null;function P4(e){Vi=e}function xS(e){Vi=null,us&&Tk(e)}const ib=e=>Vi!==null&&Array.from(e.dataTransfer.types).includes(bS);function L4(e){return{onDragOver:t=>{if(!ib(t)||!Vi)return;t.preventDefault();const n=Wf(e.getState(),Vi.worktreeId)!==null;t.dataTransfer.dropEffect=n?"copy":"none",n&&Nk(e,{at:"chat"})},onDrop:t=>{if(!ib(t)||!Vi)return;t.preventDefault();const{worktreeId:n,path:r,folder:o}=Vi;xS(e),gS(e,n,r,o)}}}let D4=0;function z4(e){const{blob:t,...n}=e;return{kind:"image",key:`img${++D4}`,...n,upload:"",bytes:t.size,local:URL.createObjectURL(t)}}async function Kf(e,t,n){var l;if(!t||n.length===0)return;const r=Hf(e,t,"image");if(r===0)return;const o=await Promise.allSettled(n.slice(0,r).map(R4));for(const c of o)c.status==="fulfilled"&&pS(e,t,z4(c.value),c.value.blob);const i=o.find(c=>c.status==="rejected");i?go(e,t,String(((l=i.reason)==null?void 0:l.message)??i.reason)):n.length>r&&go(e,t,`kept ${r} of ${n.length}: ${Tg("image")}`)}function F4(e,t,n){n.kind==="image"?Kf(e,t,[new File([n.blob],"image.png",{type:n.blob.type})]):xk(e,t,n.text),nS()}function ES(e,t,n){const r=o=>o.type.startsWith("image/");Kf(e,t,n.filter(r)),bk(e,t,n.filter(o=>!r(o)))}function SS(e,t,{images:n=!1}={}){const r=document.createElement("input");r.type="file",r.multiple=!0,n&&(r.accept="image/*"),r.onchange=()=>ES(e,t,Array.from(r.files??[])),r.click()}function Qc(e){const t=e.getState();if(t.newProject)return rl;const n=pn(t,t.activeId);return x4(n?t.local[n.worktree.id]:void 0)??fl(n)}function _S(e,t,n=Qc(e)){ES(e,n,t.filter(o=>!o.folder).map(o=>o.file));const r=t.find(o=>o.folder);n&&r&&go(e,n,`${r.file.name}: a folder cannot be attached; drop its files`)}const Dm=Promise.resolve(null);function B4(e){var n,r,o;if(!e)return[];const t=[];for(const i of Array.from(e.items)){if(i.kind!=="file")continue;const l=i.getAsFile();if(!l)continue;const c=((n=i.getAsFileSystemHandle)==null?void 0:n.call(i).then(u=>(u==null?void 0:u.kind)==="file"?u:null,()=>null))??Dm;t.push({file:l,handle:c,folder:((o=(r=i.webkitGetAsEntry)==null?void 0:r.call(i))==null?void 0:o.isDirectory)===!0})}if(t.length===0)for(const i of Array.from(e.files))t.push({file:i,handle:Dm});return t}const U4=e=>e.map(t=>({file:t,handle:Dm}));async function NS(e){const t=Yd*4;if(e.size>t)return{text:"",tooLarge:!0};const n=await A4(e,t);return n===null?null:n.length>Yd?{text:"",tooLarge:!0}:{text:n,tooLarge:!1}}async function H4(e,t){const n=Qc(e),r=e.getState().activeId,o=p=>n&&go(e,n,p),i=t.filter(p=>p.file.type.startsWith("image/")).map(p=>p.file);i.length&&Kf(e,n,i);const l=t.filter(p=>!p.file.type.startsWith("image/")),c=l[0];if(!c||!r)return;const u=await NS(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:Zo()}}),l.length>1&&o(`opened ${c.file.name}; one file opens at a time`)}async function W4(e,t,n,r){const o=Wf(e.getState(),n.worktreeId)??Qc(e),i=c=>o&&go(e,o,c),l={sock:t,dispatch:c=>e.dispatch(c)};for(const{file:c}of r){const u=await NS(c);if(!u){i(`${c.name}: not a text file`);continue}if(u.tooLarge){i(`${c.name}: too large to add here`);continue}const h=n.dir?`${n.dir}/${c.name}`:c.name,p=await dS(l,{worktreeId:n.worktreeId,path:h},u.text);p&&i(`${c.name}: ${p}`)}}function K4(e){const t=Qc(e);t&&go(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 TS(e,t,n,r){const o=(us==null?void 0:us.refused)??!1;Tk(e),!(o||r.length===0)&&(n?n.at==="chat"||n.at==="centre"&&e.getState().newProject?_S(e,r):n.at==="centre"?H4(e,r):n.at==="rail"?Z4(e,n,r):W4(e,t,n,r):K4(e))}function Z4(e,t,n){const r=pn(e.getState(),t.worktreeId);r&&(e.dispatch(yr(r.worktree)?{a:"open-draft"}:{a:"activate",id:r.worktree.id}),_S(e,n,fl(r)))}const zm=e=>!!e&&Array.from(e.types).includes("Files");function ab(e,t){var c,u;const n=t instanceof Element?t:t instanceof Node?t.parentElement:null;if(!n)return null;if((c=Sc.el)!=null&&c.contains(n))return Qc(e)?{at:"chat"}:null;const r=(u=n.closest(".rail [data-wt]"))==null?void 0:u.dataset.wt;if(r)return pn(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]"),p=h==null?void 0:h.dataset.kind;if(p==="submodule")return null;const m=(h==null?void 0:h.dataset.path)??"";return{at:"tree",worktreeId:i,dir:p==="file"?kS(m):m}}if(!n.closest(".center-root")||n.closest('[data-pane="terminal"], [data-pane="design"]'))return null;const l=e.getState();return l.activeId||l.newProject?{at:"centre"}:null}function q4(){const e=Zn(),t=pt();_.useEffect(()=>{const n=l=>{l.defaultPrevented||!zm(l.dataTransfer)||(l.preventDefault(),Nk(e,ab(e,l.target)),l.dataTransfer&&(l.dataTransfer.dropEffect=e.getState().dragFiles?"copy":"none"))},r=l=>{l.defaultPrevented||!zm(l.dataTransfer)||(l.preventDefault(),TS(e,t,ab(e,l.target),B4(l.dataTransfer)))},o=()=>vS(e),i=l=>{l.key==="Escape"&&M4(e)};return window.addEventListener("dragover",n),window.addEventListener("drop",r),window.addEventListener("dragleave",o),window.addEventListener("keydown",i,!0),()=>{window.removeEventListener("dragover",n),window.removeEventListener("drop",r),window.removeEventListener("dragleave",o),window.removeEventListener("keydown",i,!0)}},[e,t])}function jS(e,t){const n=Zn(),r=_.useRef(!1);return{onPaste:c=>{ZL();const u=j4(c.clipboardData);if(u.length>0)return c.preventDefault(),void Kf(n,e,u);const h=C4(c.clipboardData);if(h.length>0)return c.preventDefault(),bk(n,e,h);if(r.current)return;const p=c.clipboardData.getData("text/plain"),m=p.trim()?VL(c.clipboardData,t):null;!(m&&p.includes(`
|
|
103
|
+
`))&&!X1(p)||(c.preventDefault(),xk(n,e,p,m?{source:m}:{}))},onPasteKey:c=>{r.current=(c.metaKey||c.ctrlKey)&&c.shiftKey&&c.key.toLowerCase()==="v"},onPasteKeyUp:()=>{r.current=!1}}}const CS=(e,t)=>`${e}${e.includes("?")?"&":"?"}${DC}=${encodeURIComponent(t)}`,Fm=(e,t)=>!e.serving&&t!==null,G4=3e3;function AS(e,t,n){const[r,o]=_.useState(()=>new Map),i=_.useRef(new Set),l=_.useRef(t);l.current=t;const c=_.useRef(new Map),u=_.useCallback((h,p)=>{i.current.has(h)||(i.current.add(h),hE(e.sock.urls).then(m=>{if(i.current.delete(h),!!l.current.some(g=>g.id===h&&g.url===p)){if(!m){c.current.set(h,setTimeout(()=>{c.current.delete(h),l.current.some(g=>g.id===h&&g.url===p)&&u(h,p)},G4));return}o(g=>new Map(g).set(h,{url:p,src:CS(p,m.code)}))}}))},[e]);return _.useEffect(()=>{const h=c.current;return()=>{for(const p of h.values())clearTimeout(p);h.clear()}},[]),_.useEffect(()=>{var p;if(!n)return;for(const m of t)((p=r.get(m.id))==null?void 0:p.url)!==m.url&&u(m.id,m.url);const h=new Set(t.map(m=>m.id));[...r.keys()].some(m=>!h.has(m))&&o(m=>new Map([...m].filter(([k])=>h.has(k))))},[n,t,r,u]),{urlOf:h=>{var p,m;return n?((p=r.get(h))==null?void 0:p.src)??null:((m=t.find(k=>k.id===h))==null?void 0:m.url)??null},renew:h=>{const p=t.find(m=>m.id===h);!p||!n||(o(m=>{const k=new Map(m);return k.delete(h),k}),u(h,p.url))}}}function V4(e,t,n){var o;const r=_.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}]),AS(e,r.current,n).urlOf("one")}function Y4(e,t,n){if(!n){window.open(t,"_blank");return}const r=window.open("","_blank");hE(e.sock.urls).then(o=>{const i=o?CS(t,o.code):t;r?r.location.href=i:window.open(i,"_blank")})}function Ke(...e){return e.filter(Boolean).join(" ")}const X4={branch:"M4.5 5.1v5.8 M11.5 6.6c0 2.6-7 1.6-7 4.3 M4.5 1.9a1.6 1.6 0 1 0 0 3.2 1.6 1.6 0 1 0 0-3.2z M4.5 10.9a1.6 1.6 0 1 0 0 3.2 1.6 1.6 0 1 0 0-3.2z M11.5 3.4a1.6 1.6 0 1 0 0 3.2 1.6 1.6 0 1 0 0-3.2z",chat:"M2.5 3.5a1.5 1.5 0 0 1 1.5-1.5h8a1.5 1.5 0 0 1 1.5 1.5v6a1.5 1.5 0 0 1-1.5 1.5H7l-3.2 2.6V11H4a1.5 1.5 0 0 1-1.5-1.5z",settings:"M12.38 6.99 14.05 7.26 14.05 8.74 12.38 9.01 11.82 10.38 12.81 11.76 11.76 12.81 10.38 11.82 9.01 12.38 8.74 14.05 7.26 14.05 6.99 12.38 5.62 11.82 4.24 12.81 3.19 11.76 4.18 10.38 3.62 9.01 1.95 8.74 1.95 7.26 3.62 6.99 4.18 5.62 3.19 4.24 4.24 3.19 5.62 4.18 6.99 3.62 7.26 1.95 8.74 1.95 9.01 3.62 10.38 4.18 11.76 3.19 12.81 4.24 11.82 5.62z M8 6.4a1.6 1.6 0 1 0 0 3.2 1.6 1.6 0 1 0 0-3.2z",zen:"M2 6V3a1 1 0 0 1 1-1h3 M10 2h3a1 1 0 0 1 1 1v3 M14 10v3a1 1 0 0 1-1 1h-3 M6 14H3a1 1 0 0 1-1-1v-3",back:"M9.5 3.5 5 8l4.5 4.5",forward:"M6.5 3.5 11 8l-4.5 4.5",reload:"M13.5 2.5v3.5H10 M12.4 9.2a4.8 4.8 0 1 1-1-4.9l2.1 1.7",pick:"M8 4.2a3.8 3.8 0 1 0 0 7.6 3.8 3.8 0 1 0 0-7.6z M8 1.5v2.7 M8 11.8v2.7 M1.5 8h2.7 M11.8 8h2.7",inspect:"M6.5 13.5h-3a1 1 0 0 1-1-1v-9a1 1 0 0 1 1-1h9a1 1 0 0 1 1 1v3 M8.2 8.2l5.3 2-2.3.9-.9 2.3z",terminal:"M2 3a1 1 0 0 1 1-1h10a1 1 0 0 1 1 1v10a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1z M4.8 5.6 7.4 8l-2.6 2.4 M8.6 10.6h2.8",close:"M4.2 4.2 11.8 11.8 M11.8 4.2 4.2 11.8",edit:"M10.6 2.6 13.4 5.4 5.8 13H3v-2.8z M9.2 4l2.8 2.8 M3 10.2l2.8 2.8",check:"M3.4 8.4 6.4 11.4 12.6 4.6",split:"M2.5 2.5h11v11h-11z M2.5 8h11",full:"M2.5 2.5h11v11h-11z",more:"M3.55 8a.45 .45 0 1 0 .9 0a.45 .45 0 1 0-.9 0z M7.55 8a.45 .45 0 1 0 .9 0a.45 .45 0 1 0-.9 0z M11.55 8a.45 .45 0 1 0 .9 0a.45 .45 0 1 0-.9 0z",caret:"M4.5 6.5 8 10l3.5-3.5","caret-up":"M4.5 9.5 8 6l3.5 3.5",stop:"M4.5 4.5h7v7h-7z",send:"M8 13V3.2 M4 7.2 8 3.2l4 4",external:"M9 3h4v4 M13 3 8 8 M11.5 9.5V13H3V4.5h3.5",plus:"M8 3.5v9 M3.5 8h9",download:"M8 2.5v7.4 M4.9 6.8 8 9.9l3.1-3.1 M3 13h10",copy:"M5.5 5.5h8v8h-8z M10.5 5.5v-3h-8v8h3",pull:"M8 3.2v7.4 M4.9 7.4 8 10.6l3.1-3.2",layers:"M6 2.5h7.5V10 M2.5 6h8v7.5h-8z",text:"M3.5 3.5h9 M3.5 6.5h9 M3.5 9.5h9 M3.5 12.5h5",file:"M4.5 2.5h4.5l2.5 2.5v8.5h-7z M9 2.5V5h2.5",diff:"M8 2.8v5 M5.5 5.3h5 M5.5 11.2h5",folder:"M2.2 3.9a1 1 0 0 1 1-1h2.9l1.5 1.7h5.2a1 1 0 0 1 1 1v5.9a1 1 0 0 1-1 1H3.2a1 1 0 0 1-1-1z",book:"M8 4.6c-1.2-1-2.7-1.4-4.4-1.3v7.6c1.7-.1 3.2.3 4.4 1.3 1.2-1 2.7-1.4 4.4-1.3V3.3c-1.7-.1-3.2.3-4.4 1.3z M8 4.6v8.6",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",land:"M8 2.1a1.3 1.3 0 1 0 0 2.6 1.3 1.3 0 1 0 0-2.6z M8 4.7v5.4 M5.4 7.6 8 10.2l2.6-2.6 M3 13h10",attach:"M13.7 7.4 8.2 12.9a3.6 3.6 0 0 1-5.1-5.1l5.5-5.5a2.4 2.4 0 0 1 3.4 3.4l-5.5 5.5a1.2 1.2 0 0 1-1.7-1.7l5.1-5.1",dot:"M8 4.6a3.4 3.4 0 1 0 0 6.8 3.4 3.4 0 1 0 0-6.8z"};function 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:X4[e]})})}function il({size:e="inline",variant:t="ring",className:n}){return d.jsx("span",{className:Ke("spinner",e==="dot"&&"spinner-dot",t==="squares"&&"spinner-squares",n),"aria-hidden":"true",children:t==="squares"&&d.jsxs(d.Fragment,{children:[d.jsx("span",{}),d.jsx("span",{}),d.jsx("span",{}),d.jsx("span",{})]})})}const Q4='button, a[href], input, textarea, select, summary, label, [role="button"], [role="menuitem"]';function lb(e){var n;const t=e;return((n=t==null?void 0:t.closest)==null?void 0:n.call(t,Q4))??t??null}function J4(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 eD(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 tD(e,t){const n=new Set;for(const r of e)if(J4(r,t))for(let o=r;o;o=o.parent)n.add(o);return e.filter(r=>!n.has(r)&&r.dismiss).reverse()}const nD=e=>{setTimeout(e,0)};function rD({schedule:e=nD}={}){let t=[],n=null,r=!1;const o=new Set,i=()=>{for(const c of[...o])c()},l=c=>{var u;for(const h of[...t].reverse())(u=h.dismiss)==null||u.call(h,c)};return{register(c){const u=c.trigger??(c.from===void 0?n:null),h={box:c.box,trigger:u,parent:eD(t,c.from??u),dismiss:c.dismiss,onKey:c.onKey,back:c.back};return t=[...t,h],i(),h},unregister(c){t=t.filter(u=>u!==c),i()},top:()=>t[t.length-1]??null,open:()=>t,watch(c){return o.add(c),()=>o.delete(c)},shut(c){var u;c.back?c.back():(u=c.dismiss)==null||u.call(c,"outside")},install(c){const u=c.document,h=b=>{var E;const S=b.target,j=S?tD(t,S):[];for(const N of j)(E=N.dismiss)==null||E.call(N,"outside");r=j.length>0&&b.pointerType==="touch",r&&b.preventDefault(),n=lb(b.target)},p=()=>e(()=>n=null),m=()=>{r=!1,p()},k=b=>{if(r){r=!1,b.preventDefault(),b.stopPropagation();return}n||(n=lb(b.target),p())},g=b=>{var j;const S=t[t.length-1];(j=S==null?void 0:S.onKey)==null||j.call(S,b)},y=()=>e(()=>{var b;((b=u.activeElement)==null?void 0:b.tagName)==="IFRAME"&&l("frame")});return u.addEventListener("pointerdown",h,!0),u.addEventListener("pointerup",p,!0),u.addEventListener("pointercancel",m,!0),u.addEventListener("click",k,!0),c.addEventListener("keydown",g,!0),c.addEventListener("blur",y),()=>{u.removeEventListener("pointerdown",h,!0),u.removeEventListener("pointerup",p,!0),u.removeEventListener("pointercancel",m,!0),u.removeEventListener("click",k,!0),c.removeEventListener("keydown",g,!0),c.removeEventListener("blur",y)}}}}const nf=rD(),Fp=typeof HTMLElement<"u"&&"showPopover"in HTMLElement.prototype,cb=e=>(e==null?void 0:e.getBoundingClientRect())??null;function oD(e,t,n,r){const o=e.querySelector(t);if(!o)return null;const i=e.getBoundingClientRect(),l=o.getBoundingClientRect();return{offset:n==="top"?i.bottom-l.bottom:l.top-i.top,alignOffset:r==="end"?i.right-l.right:l.left-i.left}}function $s({className:e,anchor:t,placement:n,coverBy:r,track:o=t==="parent",raiseKey:i,onDismiss:l,onKey:c,onBack:u,trigger:h,from:p,boxRef:m,handle:k,children:g,...y}){const b=_.useRef(null),S=_.useRef({anchor:t,placement:n,coverBy:r,onDismiss:l,onKey:c,onBack:u,trigger:h,from:p});S.current={anchor:t,placement:n,coverBy:r,onDismiss:l,onKey:c,onBack:u,trigger:h,from:p};const j=_.useCallback(()=>{const N=b.current,{anchor:A,placement:O,coverBy:P}=S.current;if(!N||!A||!O)return;const R=A==="parent"?cb(N.parentElement):A();if(!R)return;const T=YL(R,O);T!==void 0&&(N.style.width=`${T}px`);for(let $=0;$<2;$++){const D=P?oD(N,P,N.dataset.side??"",N.dataset.align??""):null,z=QL(R,{w:N.offsetWidth,h:N.offsetHeight},{w:window.innerWidth,h:window.innerHeight},D?{...O,...D}:O);N.style.left=`${z.x}px`,N.style.top=`${z.y}px`;const V=N.dataset.side!==z.side||N.dataset.align!==z.align;if(N.dataset.side=z.side,N.dataset.align=z.align,!V)break}},[]);_.useImperativeHandle(k,()=>({update:j}),[j]),_.useLayoutEffect(()=>{const N=b.current;if(!N)return;m&&(m.current=N),Fp&&(N.popover="manual",N.matches(":popover-open")||N.showPopover());const{onDismiss:A,onKey:O,onBack:P,trigger:R,from:T}=S.current,$=A||O?nf.register({box:N,trigger:R,from:T,dismiss:A?D=>{var z,V;return(V=(z=S.current).onDismiss)==null?void 0:V.call(z,D)}:void 0,onKey:O?D=>{var z,V;return(V=(z=S.current).onKey)==null?void 0:V.call(z,D)}:void 0,back:P?()=>{var D,z;return(z=(D=S.current).onBack)==null?void 0:z.call(D)}:void 0}):null;return()=>{$&&nf.unregister($),m&&(m.current=null),Fp&&N.isConnected&&N.matches(":popover-open")&&N.hidePopover()}},[m]),_.useLayoutEffect(j),_.useLayoutEffect(()=>{if(!o)return;let N=0,A="";const O=()=>{const P=b.current,{anchor:R}=S.current,T=P&&R?R==="parent"?cb(P.parentElement):R():null;if(P&&T){const $=`${T.left},${T.top},${T.right},${T.bottom},${P.offsetWidth},${P.offsetHeight},${window.innerWidth},${window.innerHeight}`;$!==A&&(A=$,j())}N=requestAnimationFrame(O)};return N=requestAnimationFrame(O),()=>cancelAnimationFrame(N)},[o,j]);const E=_.useRef(!0);return gt([i],()=>{if(E.current){E.current=!1;return}const N=b.current;!Fp||!(N!=null&&N.matches(":popover-open"))||(N.hidePopover(),N.showPopover(),j())}),d.jsx("div",{ref:b,className:Ke("float",e),...y,children:g})}const sD=/^[⌘⇧⌥⌃]+/;function qo({k:e,chip:t=!1,className:n}){var l;const r=(l=e.match(sD))==null?void 0:l[0],o=r?e.slice(r.length):e,i=["kbd",t?"kbd-chip":"",n??""].filter(Boolean).join(" ");return d.jsxs("kbd",{className:i,children:[r&&d.jsx("span",{className:"kbd-mod",children:r}),o]})}function Ut(e,t,{placement:n,detail:r,card:o,dot:i,name:l,aside:c,also:u}={}){const h=l?`${e}: ${l}`:e,p=(Array.isArray(r)?r:[r]).filter(k=>!!k),m=[h,...p,...c??[]].join(", ");return{"data-tip":e,"data-tip-key":t,"data-tip-placement":n,"data-tip-detail":p.length?p.join(`
|
|
104
|
+
`):void 0,"data-tip-card":o||l||c!=null&&c.length?"":void 0,"data-tip-dot":i,"data-tip-name":l,"data-tip-aside":c!=null&&c.length?c.join(`
|
|
105
|
+
`):void 0,"data-tip-also":u==null?void 0:u.text,"data-tip-also-key":u==null?void 0:u.key,"aria-label":t?`${m} (${t})`:m}}const iD=120,aD=600,lD=150,ub=6,cD=18,Bp=8;function db(e){const t=e.dataset.tipPlacement;return t==="follow"||t==="top"||t==="bottom"||t==="left"||t==="right"?t:"bottom"}function IS(e){return e==="follow"?{side:"bottom",align:"start",offset:cD,alignOffset:-12,flip:"both",margin:Bp}:e==="left"||e==="right"?{side:e,align:"start",offset:ub,flip:"both",margin:Bp}:{side:e,align:"center",offset:ub,flip:"side",margin:Bp}}function uD(e,t){return e.placement==="follow"?oS(t):e.el.getBoundingClientRect()}function RS(){var u;const[e,t]=_.useState(null),n=_.useRef(null),r=_.useRef(null),o=_.useRef({x:0,y:0}),i=vi();if(_.useEffect(()=>{if(i)return;let h=0,p=0,m=null,k=!1,g=0;const y=()=>{window.clearTimeout(h),window.clearTimeout(p)},b=()=>{y(),k&&(g=Date.now()),k=!1,m=null,t(null)},S=(T,$)=>{var z,V;const D=T.dataset.tip;if(!D)return b();y(),k=!0,t({el:T,text:D,key:T.dataset.tipKey,detail:(z=T.dataset.tipDetail)==null?void 0:z.split(`
|
|
106
|
+
`),card:T.dataset.tipCard!==void 0,dot:T.dataset.tipDot,name:T.dataset.tipName,aside:(V=T.dataset.tipAside)==null?void 0:V.split(`
|
|
107
|
+
`),also:T.dataset.tipAlso&&T.dataset.tipAlsoKey?{text:T.dataset.tipAlso,key:T.dataset.tipAlsoKey}:void 0,placement:$})},j=T=>{const $=T.target;if(!($ instanceof Element))return null;const D=$.closest("[data-tip], .float");return(D==null?void 0:D.dataset.tip)!==void 0?D:null},E=T=>{o.current={x:T.clientX,y:T.clientY};const $=j(T);if($===m)return;if(y(),m=$,!$){k&&(p=window.setTimeout(b,lD));return}const D=db($);if(k||Date.now()-g<aD)return S($,D);h=window.setTimeout(()=>S($,D),iD)},N=T=>{T.relatedTarget||b()},A=T=>{const $=j(T);if($!=null&&$.matches(":focus-visible")){y(),m=$;const D=db($);S($,D==="follow"?"bottom":D)}},O=()=>b(),P=T=>{T.key!=="Shift"&&T.key!=="Control"&&T.key!=="Alt"&&T.key!=="Meta"&&b()},R=T=>{m&&T.target instanceof Node&&T.target.contains(m)&&b()};return document.addEventListener("mouseover",E),document.addEventListener("mouseout",N),document.addEventListener("mousedown",b),document.addEventListener("keydown",P),document.addEventListener("scroll",R,!0),document.addEventListener("focusin",A),document.addEventListener("focusout",O),window.addEventListener("blur",b),()=>{y(),document.removeEventListener("mouseover",E),document.removeEventListener("mouseout",N),document.removeEventListener("mousedown",b),document.removeEventListener("keydown",P),document.removeEventListener("scroll",R,!0),document.removeEventListener("focusin",A),document.removeEventListener("focusout",O),window.removeEventListener("blur",b)}},[i]),_.useLayoutEffect(()=>{e&&!e.el.isConnected&&t(null)},[e]),_.useEffect(()=>{if((e==null?void 0:e.placement)!=="follow")return;const h=p=>{var m;o.current={x:p.clientX,y:p.clientY},(m=r.current)==null||m.update()};return document.addEventListener("mousemove",h),()=>document.removeEventListener("mousemove",h)},[e]),!e)return null;const l=d.jsxs(d.Fragment,{children:[e.dot==="spinner"?d.jsx(il,{size:"dot",className:"tooltip-dot"}):e.dot&&d.jsx("span",{className:`dot ${e.dot} tooltip-dot`}),e.text]}),c=d.jsxs(d.Fragment,{children:[l,e.key&&d.jsx(qo,{k:e.key,className:"tooltip-key"})]});return d.jsxs($s,{className:Ke("tooltip",e.card&&"tooltip-card"),role:"tooltip",boxRef:n,handle:r,anchor:()=>uD(e,o.current),placement:IS(e.placement),track:!1,raiseKey:e,children:[e.also?d.jsxs("div",{className:"tooltip-pair",children:[d.jsx("span",{children:l}),e.key?d.jsx(qo,{k:e.key,className:"tooltip-key"}):d.jsx("span",{}),d.jsx("span",{className:"tooltip-also",children:e.also.text}),d.jsx(qo,{k:e.also.key,className:"tooltip-key"})]}):e.name?d.jsxs("div",{className:"tooltip-head",children:[d.jsx("span",{children:c}),d.jsx("span",{className:"tooltip-name",children:e.name})]}):c,(u=e.detail)==null?void 0:u.map((h,p)=>d.jsx("div",{className:"tooltip-detail",children:h},p)),e.aside&&d.jsx("div",{className:"tooltip-foot",children:e.aside.map(h=>d.jsx("span",{children:h},h))})]})}const dD={sm:"",md:"btn-md",lg:"btn-lg"},fD={ghost:"",outline:"btn-outline",field:"btn-outline btn-field",inline:"btn-inline"},$S={primary:"tone-primary",quiet:"tone-quiet",danger:"tone-danger",strong:"tone-strong",chrome:"tone-chrome"};function De({variant:e="ghost",size:t="sm",tone:n,on:r,mono:o,busy:i,className:l,type:c="button",disabled:u,children:h,...p}){const m=Ke("btn",fD[e],dD[t],n&&$S[n],r&&"on",o&&"btn-mono",i&&"btn-busy",l);return d.jsxs("button",{className:m,type:c,disabled:i||u,"aria-busy":i||void 0,...p,children:[i&&d.jsx(il,{}),h]})}function Rt({icon:e,label:t,hint:n,detail:r,also:o,silent:i,badge:l,tone:c,on:u,className:h,type:p="button",...m}){const k=Ke("btn-icon",c&&$S[c],u&&"on",h),g=Ut(t,n,{detail:r,also:o});return d.jsxs("button",{className:k,type:p,...i?{"aria-label":g["aria-label"]}:g,...m,children:[typeof e=="string"?d.jsx(St,{name:e}):e,l]})}function Jc(e,t,n){return n===0?0:(e+t+n)%n}function fb(e,t,n){return e>=0?Jc(e,t,n):n===0?-1:t>0?0:n-1}function OS(e,t,n){var i;const r=e.length,o=n.toLowerCase();for(let l=1;l<=r;l++){const c=(Math.max(t,-1)+l)%r;if((i=e[c])!=null&&i.trim().toLowerCase().startsWith(o))return c}return-1}function Up(e,t){return e&&e.length>t.length&&e.toLowerCase().startsWith(t.toLowerCase())?e.slice(t.length):null}function hD(e,t){if(e==null)return null;if(typeof e=="string"){const o=Up(e,t);return o?{text:o,accept:o,params:[]}:null}const n=Up(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:Up(e.accept,t),params:r}}function MS(e){const{results:t,keyOf:n,q:r,onPick:o,listRef:i,onActive:l,onSide:c,completionOf:u,narrowTo:h,setQ:p,tabPicks:m,onIdlePick:k}=e,[g,y]=_.useState(()=>{var P;return e.idle?-1:Math.max(0,((P=e.initialIndex)==null?void 0:P.call(e,t))??0)}),b=g>=0&&t[g]?n(t[g]):null,S=_.useRef(l);S.current=l,gt([b],()=>{var P,R,T;(R=(P=i.current)==null?void 0:P.querySelector('.picker-item[data-state~="cursor"]'))==null||R.scrollIntoView({block:"nearest"}),(T=S.current)==null||T.call(S,g>=0?t[g]??null:null)});const j=g<0?-1:Math.min(g,Math.max(0,t.length-1)),E=j>=0?t[j]??null:null,N=E?hD(u==null?void 0:u(E,r),r):null,A=P=>{const R=h==null?void 0:h(P,r);if(R==null)return o(P,r);p==null||p(R),y(0)};return{index:j,active:E,ghost:N,setIndex:y,pick:A,onKeyDown:P=>{if(P.key==="ArrowDown")P.preventDefault(),y(fb(j,1,t.length));else if(P.key==="ArrowUp")P.preventDefault(),y(fb(j,-1,t.length));else if((P.key==="ArrowLeft"||P.key==="ArrowRight")&&c&&E)P.preventDefault(),c(E,P.key==="ArrowLeft"?-1:1);else if(P.key==="Tab"&&(N!=null&&N.accept))P.preventDefault(),p==null||p(r+N.accept),y(0);else if(P.key==="Tab"&&m&&E)P.preventDefault(),A(E);else if(P.key==="Enter"&&E)P.preventDefault(),A(E);else if(P.key==="Enter"&&j<0&&k)P.preventDefault(),k(r);else return!1;return!0}}}function vr(e){const t=Object.keys(e).filter(n=>e[n]);return t.length>0?t.join(" "):void 0}const pD=new Set(["Shift","Meta","Control","Alt","CapsLock","Fn"]);function PS(){const e=vk(),t=Zn();return _.useEffect(()=>{if(!e)return;const n=()=>{e.target.isConnected||so.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(mD,{spec:e},e.id):null}function mD({spec:e}){const t=e.items,n=t.filter(cs),[r,o]=_.useState(-1),i=_.useRef({idx:r,items:n});i.current={idx:r,items:n};const l=_.useRef(null),c=m=>{var k,g;{const y=()=>so.close(),{idx:b,items:S}=i.current;if(pD.has(m.key))return;if(m.key==="ArrowDown"||m.key==="ArrowUp"){m.preventDefault(),m.stopPropagation();const j=m.key==="ArrowDown"?1:-1;o(JL(S,b,j));return}if((m.key==="Enter"||m.key===" ")&&b>=0&&S[b]&&!S[b].disabled){m.preventDefault(),m.stopPropagation(),S[b].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 j=Array.from(((k=l.current)==null?void 0:k.querySelectorAll(".menu-label"))??[],N=>N.textContent??""),E=OS(j,b,m.key);E>=0&&!((g=S[E])!=null&&g.disabled)&&o(E);return}y()}};_.useEffect(()=>{const m=()=>so.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}=n4(e),p=n.some(m=>m.checked);return d.jsx($s,{className:"menu",role:"menu",boxRef:l,anchor:()=>u,placement:h,track:!1,from:e.target,trigger:e.toggles?e.target:null,onDismiss:()=>so.close(),onKey:c,onContextMenu:m=>m.preventDefault(),children:t.map((m,k)=>{if(!cs(m))return d.jsx("hr",{className:"menu-sep"},`sep-${k}`);const g=n.indexOf(m);return d.jsx(gD,{item:m,gutter:p,cursor:g===r,onEnter:()=>o(g)},m.id)})})}function gD({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:Ke("row row-keyed",e.danger&&"danger",i!==void 0&&"row-tall",o&&"disabled"),"data-state":vr({cursor:n,checked:e.checked}),onMouseMove:o||n?void 0:r,onClick:()=>{o||(e.onClick(),so.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(qo,{k:e.key,className:"menu-key row-dim"})]})}function Zf({items:e,current:t,onPick:n,fill:r,font:o,segmented:i,quiet:l,end:c,label:u,owner:h}){const p=bn(h),m=_.useRef(null),k=Math.max(0,e.findIndex(y=>y.id===t)),g=y=>{var j,E;if(y.key!=="ArrowLeft"&&y.key!=="ArrowRight")return;y.preventDefault();const b=e.findIndex(N=>N.id===t),S=e[Jc(b,y.key==="ArrowRight"?1:-1,e.length)];S&&(n(S.id),(E=(j=m.current)==null?void 0:j.querySelectorAll('[role="tab"]')[e.indexOf(S)])==null||E.focus())};return d.jsxs("div",{className:Ke("tabs",r&&"tabs-fill",o==="mono"&&"tabs-mono",i&&"tabs-segmented",l&&"tabs-quiet"),children:[d.jsx("div",{className:"tabs-list",role:"tablist","aria-label":u,ref:m,onKeyDown:g,style:i?{"--tabs-at":k,"--tabs-count":e.length}:void 0,children:e.map(y=>{const b=y.id===t;return d.jsxs("div",{className:Ke("tab",b&&!!y.trail&&"tab-trailed",y.fit&&"tab-fit",y.far&&"tab-far"),"data-state":vr({current:b}),...y.menu?p.contextMenu(y.menu):{},children:[d.jsxs("button",{type:"button",className:"tab-btn",role:"tab","aria-selected":b,tabIndex:b?0:-1,onClick:()=>n(y.id),...y.tip,...y.ariaLabel?{"aria-label":y.ariaLabel}:{},children:[y.lead,y.label]}),b&&y.trail&&d.jsx("span",{className:"tab-trail",children:y.trail})]},y.id)})}),c&&d.jsx("span",{className:"tabs-end",children:c})]})}function fs({anchor:e="top",wide:t,foot:n,children:r}){const o=d.jsx("div",{className:Ke("view",e==="line"&&"view-anchored",t&&"view-wide"),children:r});return n?d.jsxs("div",{className:"view-stack",children:[o,n]}):o}const LS=e=>`Toyon restarts once ${e.join(", ")} ${e.length===1?"finishes":"finish"}`,kD=(e,t)=>[...e,...t.filter(n=>!e.includes(n))];function wD(e,t,n){const r=[...t];return[...e.map(i=>{const l=r.indexOf(i);return l===-1?{name:i,dot:"idle",note:"finished"}:(r.splice(l,1),{name:i,dot:"working",note:null})}),...n.map(i=>({name:i,dot:"waiting",note:"asking you"}))]}function yD(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 vD(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:LS(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 Bm=!1;function bD(){Bm=!0}function Mc({title:e,body:t,action:n,pane:r,children:o}){return d.jsxs("div",{className:Ke("crash",r&&"in-pane"),children:[d.jsx("div",{className:"crash-title",children:e}),t&&d.jsx("div",{className:"crash-body",children:t}),o,n]})}const hb={title:"Toyon was updated",body:"This page is still running the old build. Reload to pick up the new one."};class jk extends _.Component{constructor(){super(...arguments);zt(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(Mc,{pane:this.props.pane,title:Bm?hb.title:"Toyon hit an error",body:Bm?hb.body:n.message||String(n),action:d.jsx(De,{variant:"outline",onClick:()=>window.location.reload(),children:"reload"})}):this.props.children}}const Um={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.`},xD=1e3,pb={held:[],asking:[],seen:[]};async function mb(e,t,n){for(;;){await new Promise(i=>setTimeout(i,xD));const[r,o]=await Promise.all([Nm(e),uE(e)]);if(r!==null&&r!==t)break;n(o??{waiting:[],asking:[]})}window.location.reload()}function DS({foreign:e}={}){return e?d.jsx(ED,{name:e}):d.jsx(SD,{})}function ED({name:e}){const t=Vo(),n=t.list()[0];return d.jsx(Mc,{title:`Toyon on ${e} was updated`,body:Um.foreign(e),action:n&&d.jsxs(De,{variant:"outline",onClick:()=>t.activate(n.origin),children:["back to ",t.displayName(n.origin)]})})}function SD(){const e=Lr(),[t,n]=_.useState(!0),[r,o]=_.useState(null),[i,l]=_.useState(pb),c=_.useRef(null),u=_.useCallback(k=>l(g=>({held:k.waiting,asking:k.asking,seen:kD(g.seen,k.waiting)})),[]),h=_.useCallback(async k=>{n(!0),o(null);const g=c.current??{pid:await Nm(e)},y=await FM(e,k);if(y){n(c.current!==null),o(y);return}k&&l(pb),!c.current&&(c.current=g,mb(e,g.pid,u))},[u,e]);_.useEffect(()=>{let k=!0;return(async()=>{const[g,y]=await Promise.all([Nm(e),uE(e)]);if(!(!k||c.current)){if(y===null){h(!1);return}c.current={pid:g},u(y),mb(e,g,u)}})(),()=>{k=!1}},[u,h,e]);const p=t&&i.held.length>0,m=p?wD(i.seen,i.held,i.asking):[];return d.jsx(Mc,{title:Um.title,body:r??(p?yD(i.held.length,i.seen.length):Um.waiting),action:p?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((k,g)=>d.jsxs("li",{className:Ke("crash-row",k.dot!=="working"&&"row-dim"),children:[d.jsx("span",{className:Ke("dot",k.dot)}),d.jsx("span",{className:"crash-row-name",children:k.name}),k.note&&d.jsx("span",{className:"crash-row-note",children:k.note})]},g))})})}const gb={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"},_D={probing:e=>`connecting to ${e}…`,down:e=>`Toyon on ${e} is not answering.
|
|
108
|
+
is Tailscale on here, and is Toyon running there?`,blocked:e=>`Toyon on ${e} is up, but this page's websocket to it never connected.
|
|
109
|
+
a proxy, VPN or browser extension is the usual cause`,unauthorized:e=>`this page's token for ${e} is not the one running there.
|
|
110
|
+
forget ${e} here and pair it again`},ND="no access token for this address.\nrun `toyon` in your repo, or open the full URL\n(with #token=…) printed in ~/.toyon/daemon.log";function zS(e){return!e.connected&&(!e.heard||e.connectFailure)?e.machine?_D[e.connectFailure??"probing"](e.machine):e.hasToken?gb[e.connectFailure??"probing"]??gb.probing:ND:e.title===null?e.heard?`nothing open yet.
|
|
111
|
+
press ${e.projectChord} to open a project, or type a name there to start a new one`:"":null}function TD(e){const t=zS(e);return t!==null?t:e.needsSetup&&e.busy?`building in ${e.title}; the preview appears once it starts`:e.needsSetup&&e.treeEmpty?`${e.title} is empty so far; say what to build`:e.treeEmpty&&e.landsFrom?`nothing runs on main until ${e.landsFrom} lands`:null}const cn={post:(e,t)=>{},broadcast:e=>{}};function Pc(e,t,n,r){const o=t===r;cn.post(e,o?{type:"pick-cancel"}:{type:"pick-start",verb:r}),n({a:"set-picking",v:o?!1:r})}function FS(e){return[{id:"copy-sha",label:`copy ${e.short}`,onClick:()=>Jt(e.sha)},{id:"copy-subject",label:"copy subject",onClick:()=>Jt(e.subject)}]}function qf(e,t,n){var o,i;const r=e[t];if(!r)return null;if(n==="ArrowRight")return r.open===void 0?null:r.open?(((o=e[t+1])==null?void 0:o.depth)??-1)>r.depth?{do:"to",at:t+1}:null:{do:"open",at:t};if(r.open)return{do:"close",at:t};for(let l=t-1;l>=0;l--)if((((i=e[l])==null?void 0:i.depth)??0)<r.depth)return{do:"to",at:l};return null}function Gf(e){return e!=null&&e.config.profiles?Object.keys(e.config.profiles):[]}function BS(e,t){const n=Gf(t);if(n.length!==0)return e.profile&&n.includes(e.profile)?e.profile:t==null?void 0:t.config.defaultProfile}const jD=e=>Wd(ai((e==null?void 0:e.config)??{}),e==null?void 0:e.defaultBranch).toLowerCase();function ci(e,t,n){t({a:"shipping",id:n.worktreeId,op:n.t}),e==null||e.send(n)}const US=e=>e.dirty===void 0||e.ahead===void 0||e.dirty>0||e.ahead>0;function Ji(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 HS(e,t,n){t({a:"hold-unread",id:n}),e==null||e.send({t:"mark-unread",worktreeId:n})}function Ck(e,t){return{rename(n){if(!o1(n.worktree))return;const r=window.prompt("Rename worktree (its branch follows as a slug):",n.worktree.title);r!=null&&r.trim()&&(e==null||e.send({t:"rename-worktree",worktreeId:n.worktree.id,title:r.trim()}))},pickVariant(n){const r=n.worktree.variant;if(!r)return;const o=r.of-1;window.confirm(`Keep "${n.worktree.title}" and archive ${o} sibling variant(s)? Their directories and branches go; their chats and changes are kept.`)&&(e==null||e.send({t:"pick-variant",worktreeId:n.worktree.id}))},setProfile(n,r){e==null||e.send({t:"set-worktree-profile",worktreeId:n.worktree.id,profile:r})},ownProcs(n){e==null||e.send({t:"own-procs",worktreeId:n.worktree.id})},shareProcs(n){const r=(n.worktree.owns??[]).join(", ");window.confirm(`Stop this worktree's own ${r} and use main's?
|
|
112
|
+
|
|
113
|
+
What they hold that main's do not (a database of their own) is not carried over.`)&&(e==null||e.send({t:"share-procs",worktreeId:n.worktree.id}))},archive(n){if(!Ng(n.worktree))return;if(!US(n))return Ji(e,t,[n.worktree.id]);window.confirm(`Archive worktree "${n.worktree.title}"?
|
|
114
|
+
|
|
115
|
+
Its directory and branch (${n.worktree.branch}) go. The chat, the commits and any uncommitted changes are kept, and the project menu can restore it.`)&&Ji(e,t,[n.worktree.id])}}}function WS(e,t,n,{sock:r,dispatch:o},i){var P,R;const l=e.worktree.id,c=Ck(r,o),u=[],h=[],p=[],m=[],k=[],g=[],y=[],b=[];Vc(e)&&u.push({id:"stop",label:"stop agent",onClick:()=>r==null?void 0:r.send({t:"stop-agent",worktreeId:l})});const S=!n.shipping[l],j=n.frame==="phone";((e.dirty??0)>0||(e.ahead??0)>0||!j&&!n.layout.changes)&&h.push({id:"changes",label:`view changes${(e.dirty??0)>0?` (${e.dirty})`:""}`,onClick:()=>{o({a:"activate",id:l}),j?o({a:"screen",to:"changes"}):n.layout.changes||o({a:"toggle-changes"})}}),j||h.push({id:"terminal",label:"open terminal",onClick:()=>{o({a:"activate",id:l}),o({a:"focus-terminal"})}}),h.push(...ds(()=>r==null?void 0:r.send({t:"reveal",worktreeId:l}),i.hostname)),j||p.push({id:"copy-path",label:"copy path",onClick:()=>Jt(e.path)}),p.push({id:"copy-branch",label:"copy branch name",onClick:()=>Jt(e.worktree.branch)});const{transcript:E,sessionId:N}=e;!j&&E&&!yr(e.worktree)&&p.push({id:"copy-transcript",label:"copy transcript path",onClick:()=>Jt(E)}),!j&&N&&p.push({id:"copy-session",label:"copy session id",onClick:()=>Jt(N)});const A=BS(e.worktree,t);for(const T of qc(e.worktree)?[]:Gf(t))m.push({id:`profile:${T}`,label:`run with ${T}`,checked:T===A,onClick:()=>c.setProfile(e,T)});if(!na(e.worktree)&&((P=e.borrowed)!=null&&P.length)&&m.push({id:"own-procs",label:`run ${e.borrowed.join(", ")} here`,detail:"on main now",onClick:()=>c.ownProcs(e)}),!na(e.worktree)&&((R=e.worktree.owns)!=null&&R.length)&&m.push({id:"share-procs",label:`use main's ${e.worktree.owns.join(", ")}…`,detail:"runs here now",danger:!0,onClick:()=>c.shareProcs(e)}),o1(e.worktree)&&k.push({id:"rename",label:"rename…",onClick:()=>c.rename(e)}),e.worktree.variant&&k.push({id:"keep",label:"keep this variant…",onClick:()=>c.pickVariant(e)}),i.graft&&Id(e.worktree)){const T=i.graft;k.push({id:"graft",label:"graft with…",onClick:()=>T(l)})}k.push({id:"unread",label:"mark as unread",key:Lt("mark-unread"),disabled:e.unseen?"already unread":void 0,onClick:()=>HS(r,o,l)});const O=S?void 0:"waiting on the one in progress";if(e.syncQueued)g.push({id:"sync",label:"call off the sync from main",onClick:()=>r==null?void 0:r.send({t:"unqueue-sync",worktreeId:l})});else if(xf(e)&&(e.behind??0)>0){const T=(e.agent==="working"||e.agent==="waiting")&&(e.dirty??0)>0;g.push({id:"sync",label:`sync from main${T?" after the turn":""} (${e.behind} behind)`,disabled:O,onClick:()=>ci(r,o,{t:"sync-main",worktreeId:l})})}return qi(e.worktree)&&g.push({id:"land",label:Ig(ai((t==null?void 0:t.config)??{}),e.worktree),detail:jD(t),disabled:O,onClick:()=>ci(r,o,{t:"land",worktreeId:l})}),e.worktree.kind==="worktree"&&y.push({id:"handoff",label:"continue in another project…",sub:!0,disabled:n.repos.length<2?"open another project first":void 0,onClick:()=>o({a:"open",overlay:{kind:"handoff",worktreeId:l}})}),Ng(e.worktree)&&b.push({id:"archive",label:US(e)?"archive…":"archive",key:Lt("wt-archive"),danger:!0,onClick:()=>c.archive(e)}),Ln([u,h,p,m,k,g,y,b])}function CD(e,t,{sock:n,dispatch:r},o){const i=[],l=t.frame==="phone",c=[{id:"adopt",label:"take over",disabled:e.locked?`held by ${e.lockReason??"another tool"}`:void 0,onClick:()=>n==null?void 0:n.send({t:"adopt-worktree",worktreeId:e.id,clientId:t.clientId})}];return xf(e)&&(e.behind??0)>0&&i.push({id:"sync",label:`sync from main (${e.behind} behind)`,onClick:()=>n==null?void 0:n.send({t:"sync-main",worktreeId:e.id})}),l||i.push({id:"shell",label:"open a shell here",onClick:()=>{r({a:"activate",id:e.id}),r({a:"focus-terminal"})}}),i.push(...ds(()=>n==null?void 0:n.send({t:"reveal",worktreeId:e.id}),o)),Ln([c,i,l?[]:[{id:"copy-path",label:"copy path",onClick:()=>Jt(e.path)}]])}const AD={sm:"",md:"field-md",lg:"field-lg"};function KS({size:e="sm",font:t,bare:n,rule:r,className:o}){const i=t??(e==="lg"?"ui":"mono");return Ke("field",AD[e],i==="ui"&&"field-ui",i==="lead"&&"field-lead",n&&"field-bare",r&&"field-rule",o)}const jo=_.forwardRef(function({size:t,font:n,bare:r,rule:o,className:i,...l},c){return d.jsx("input",{ref:c,className:KS({size:t,font:n,bare:r,rule:o,className:i}),...l})}),Lc=_.forwardRef(function({size:t,font:n,bare:r,rule:o,className:i,...l},c){return d.jsx("textarea",{ref:c,className:KS({size:t,font:n,bare:r,rule:o,className:i}),...l})});function ID(e,t){const n=t??0;return n===0?null:`${n} behind ${e}`}function ZS(e){const t=new Date(e);return`${String(t.getHours()).padStart(2,"0")}:${String(t.getMinutes()).padStart(2,"0")}`}function qS(e,t){if(t.fetchFailed)return`could not reach origin${t.fetchedAt?` since ${ZS(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 RD(e){return e.stale!=="diverged"}const Kr=e=>/[.!?…]$/.test(e)?e:`${e}.`,kb=160;function Vf(e){const t=e.replace(/\s+/g," ").trim();if(t.length<=kb)return t;const n=t.slice(0,kb);return`${n.slice(0,Math.max(n.lastIndexOf(" "),1)).trimEnd()}…`}function GS(e){return e.subjects.length?Vf(e.subjects.join("; ")):void 0}function Ak(e){const t=GS(e);if(t)return e.pr===void 0?t:Vf(`PR #${e.pr}: ${t}`)}function Ik(e,t=3){const n=[];for(const l of e??[]){const c=Ak(l);c&&n.push({at:l.at,line:c})}if(n.length===0)return[];const r=n.slice(-t),o=n.length-r.length,i=r.map(({at:l,line:c})=>n.length===1?Kr(c):`${Rk(Ho(oo(l)))}: ${Kr(c)}`);return o>0?[`${o} earlier landing${o===1?"":"s"}.`,...i]:i}function Ns(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?"; preview up.":".";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 VS(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 Rk=e=>`${e.charAt(0).toUpperCase()}${e.slice(1)}`;function $k(e,t,n){return t===0||e!=null&&e.subject?null:!e||e.stale?"unwritten":e.check==="pending"?"pending":e.check==="fail"?null:e.unanswered||n?"unanswered":"unasked"}function YS(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 $D(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 wd(e,t=0,n=!0,r){var o,i;if(e.check==="pending")return"Checking the work…";if(e.check==="fail"){const l=(i=(o=e.checkTail)==null?void 0:o.split(`
|
|
116
|
+
`).find(c=>c.trim()))==null?void 0:i.trim();return`Check failed${l?`: ${Kr(l)}`:"."}`}return $k(e,t,n)==="unasked"?$D(r):null}function wb(e,t){const n=OD(e,t);return n?Kr(Rk(n)):""}function OD(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 XS=e=>/^[A-Z][a-z]+(\s|$)/.test(e)?`${e.charAt(0).toLowerCase()}${e.slice(1)}`:e;function MD(e,t){const n=t??0;return n>0?`${n} behind ${e}; land takes it in first.`:""}function PD(e){return e>0?Kr(Rk(`${e} ${e===1?"file":"files"} changed`)):""}function LD(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: ${Kr(XS(e.why))}`:null}function yd(e){return Kr(e)}const Ho=e=>e==="now"?"just now":`${e} ago`;function DD(e,t,n){switch(e){case"asking":return`Waiting on you${n==="now"?"":` for ${n}`}${t.ask?`: ${Kr(t.ask)}`:"."}`;case"failed":return t.auth?`Stopped ${Ho(n)}: not logged in.`:t.error?`Failed ${Ho(n)}: ${Kr(t.error)}`:`Failed ${Ho(n)}.`;case"stopped":return t.planBack?`Sent the plan back ${Ho(n)}. Say what to change.`:`Stopped ${Ho(n)}.`;case"done":return t.cut?`Ended early ${Ho(n)} (${t.cut}).`:`Finished ${Ho(n)}.`}}function Ok(e){var n;const t=(n=e.recap)==null?void 0:n.text;return t?Kr(t):DD(e.end,e.facts,oo(e.at))}function zD(e){var n;const t=(n=e.recap)==null?void 0:n.text;return t?`Last stop, ${Ho(oo(e.at))}: ${Kr(XS(t))}`:void 0}function Dc(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 Mk(e){return(e==null?void 0:e.status)==="running"||(e==null?void 0:e.status)==="detached"}function QS(e){const t=e&&e.status!=="terminated"?e.since:void 0,n=pk(t,mk);return t!==void 0&&n===t?e:void 0}function JS(e,t){const n=e.stage?[e.stage]:[];switch(e.status){case"queued":return[...n,"queued"];case"running":return[...n,`${Gi(t)} of ${TC(e.timeoutMs)}`];case"detached":return[...n,Gi(t),"detached"];case"terminated":return[e.why??"stopped"]}}function Hm(e,t,n){return[e,...JS(t,n)].join(" · ")}const e_={queued:"Asked for, not started yet.",running:"Running under the daemon's watch. It is killed at the ceiling.",detached:"The daemon restarted under it. It runs on, unwatched, until it ends or is stopped.",terminated:"Killed: at its ceiling, or by a stop."};function t_(e){switch(e){case"setup":return"Stop this setup command; the next one runs";case"check":return"Stop the check; it reads as failed until it runs again";case"commit":return"Stop the commit and the hooks it is running; nothing is committed"}}function FD({active:e,ahead:t,behind:n,unpushed:r,dirty:o}){var sn,Ct,He;const i=pt(),l=ut(),c=bn("changes"),u=vn(e)?e.worktree:null,h=e.id,p=L(Ze=>{var At;return(At=Ze.shipping[h])==null?void 0:At.op}),m=L(Ze=>{var At;return(At=Ze.shipping[h])==null?void 0:At.step}),k=pk(m,mk),g=Dc(e,"commit"),y=Dc(e,"check"),b=p?g:y,S=QS(b),j=Qi(Mk(S)?S==null?void 0:S.since:void 0),[E,N]=_.useState("");gt([h],()=>N(""));const A=_.useRef(null),O=(sn=u==null?void 0:u.landing)!=null&&sn.subject?u.landing.body?`${u.landing.subject}
|
|
117
|
+
|
|
118
|
+
${u.landing.body}`:u.landing.subject:null,P=()=>{E===""&&O&&N(O);const Ze=A.current;Ze&&(Ze.focus(),requestAnimationFrame(()=>Ze.setSelectionRange(Ze.value.length,Ze.value.length)))},R=L(Ze=>Ze.editCommit);gt([R],()=>{R&&P()});const T=E.trim()||void 0,$=L(Ze=>{var At;return!!((At=Ze.agents.find(_t=>_t.id===((u==null?void 0:u.agent)??Ze.defaultAgent)))!=null&&At.quick)}),D=u==null?void 0:u.landing,z=T?null:$k(D,o?1:0,$),V=(D==null?void 0:D.check)==="pending",se=!!(D!=null&&D.stale),I=()=>{p||i==null||i.send({t:"judge",worktreeId:h})},ne=()=>{p||!T&&!O||(ci(i,l,{t:"commit",worktreeId:h,message:T??O??""}),N(""))},we=()=>{p||ci(i,l,{t:"land",worktreeId:h,...T?{message:T}:{}})},K=((Ct=u==null?void 0:u.landing)==null?void 0:Ct.check)==="fail",B=u==null?void 0:u.pr,ee=(B==null?void 0:B.state)==="open",J=ee&&(o||r>0),W=V||se||!!z,ie=!!u&&qi(u)&&(o||t>0)&&!K&&!ee&&!W,Te=!!u&&J&&!K&&!W,Ce=!!u&&qi(u)&&!V&&(se||z==="unwritten"||z==="unanswered")&&e.agent!=="working"&&e.agent!=="waiting",de=L(Ze=>Ze.repos.find(At=>At.id===e.repoId)??null),be=ai((de==null?void 0:de.config)??{}),le=Wd(be,de==null?void 0:de.defaultBranch),G=Ig(be,u??{}),ce=de?Ef(de):"main",oe=xf(e)?ID(ce,n):null,re=e.agent==="working"||e.agent==="waiting",Le=o&&!u?"commit or discard the changes here first":void 0,Ue=!!e.syncQueued,_e=o&&re?`Merge ${ce} into this worktree once the turn ends, uncommitted changes kept`:`Merge ${ce} into this worktree${o?", uncommitted changes kept":""}`,je=ee&&!J&&VS(B),Ne=ie?G:Te?"update":je?"land":(B==null?void 0:B.state)==="merged"?"pull":"land",Ft=p==="commit"?k??"commit":p==="land"?k?`${Ne}: ${k}`:Ne:null,qt=b?S?JS(S,j).join(" · "):null:V&&!p?"writing the message":null,jt=S&&(S.status==="running"||S.status==="detached")?S:null,Ht=jt&&d.jsx(Rt,{icon:"stop",tone:"danger",label:t_(jt.kind),onClick:()=>i==null?void 0:i.send({t:"run-stop",worktreeId:h,kind:jt.kind})});return d.jsxs("div",{className:"composer commit-box",children:[u&&o&&d.jsx("div",{className:"composer-field",children:d.jsx(Lc,{size:"lg",bare:!0,ref:A,value:E,onChange:Ze=>N(Ze.target.value),onKeyDown:Ze=>{Ze.key==="Enter"&&(Ze.metaKey||Ze.ctrlKey)?(Ze.preventDefault(),ne()):Ze.key==="Tab"&&!Ze.shiftKey&&E===""&&O&&(Ze.preventDefault(),P())},placeholder:O??(z==="unanswered"?"no message yet: the model did not answer. Check again, or write one here":z==="unasked"?"no message yet: write one here to commit or land":"commit message…")})}),d.jsxs("div",{className:"hint composer-knobs",children:[d.jsxs("span",{className:"commit-where",children:[d.jsx(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 ${ce}`,children:[t," ahead"]}),(u==null?void 0:u.landed)&&d.jsxs("span",{className:"badge-landed","data-tip":`Merged into ${ce}`,children:[d.jsx(St,{name:"check",className:"icon-inline"})," landed"]})]}),d.jsxs("span",{className:"commit-acts",children:[Ft?d.jsx("span",{className:"live-text",children:Ft}):d.jsxs(d.Fragment,{children:[u&&o&&d.jsx(De,{disabled:!T&&!O||!!p,onClick:ne,...Ut(O&&!T?"Commit with the suggested message":"git add -A && git commit","⌘⏎"),children:"commit"}),u&&ie&&d.jsx(De,{tone:"primary",disabled:!!p,"data-tip":le,onClick:we,children:G}),Ce&&d.jsx(De,{tone:"primary",disabled:!!p,"data-tip":YS(D,!!((He=de==null?void 0:de.config.check)!=null&&He.trim()),z),onClick:I,children:"check"}),V&&d.jsx("span",{className:"live-text",children:"check"}),Te&&B&&d.jsx(De,{tone:"primary",disabled:!!p,"data-tip":`Commit, take ${ce} in and push the branch; PR #${B.number} takes the new commits`,onClick:we,children:"update"}),je&&d.jsx(De,{tone:"primary",disabled:!!p,"data-tip":"Merge the PR now, by the method the repo allows",onClick:we,children:"land"})]}),B&&d.jsxs(De,{"data-tip":`Open PR #${B.number} on GitHub`,onClick:()=>window.open(B.url,"_blank"),...c.contextMenu(()=>[{id:"open-pr",label:"open on GitHub",onClick:()=>window.open(B.url,"_blank")},{id:"copy-link",label:"copy link",onClick:()=>Jt(B.url)}]),children:["view ",d.jsx(St,{name:"external",className:"icon-inline"})]}),(B==null?void 0:B.preview)&&d.jsxs(De,{"data-tip":`Open the branch on ${new URL(B.preview).hostname}`,onClick:()=>window.open(B.preview,"_blank"),...c.contextMenu(()=>[{id:"open-preview",label:"open the preview",onClick:()=>window.open(B.preview,"_blank")},{id:"copy-preview",label:"copy link",onClick:()=>Jt(B.preview??"")}]),children:["preview ",d.jsx(St,{name:"external",className:"icon-inline"})]})]})]}),(oe||qt)&&d.jsxs("div",{className:"composer-notes",children:[qt&&d.jsxs("div",{className:"hint composer-note","data-tip":S?e_[S.status]:void 0,children:[d.jsx("span",{children:qt}),Ht]}),oe&&d.jsxs("div",{className:"hint composer-note",children:[d.jsx("span",{children:oe}),p==="sync-main"?d.jsx("span",{className:"live-text",children:k?`sync: ${k}`:"sync"}):Ue?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:!!p||!!Le,"data-tip":Le??_e,onClick:()=>ci(i,l,{t:"sync-main",worktreeId:h}),children:"sync"})]})]})]})}const BD=_.memo(function({c:t,id:n,selected:r,onToggle:o}){const i=bn("changes");return d.jsxs("button",{className:"row row-sm log-row row-edge",id:n,"data-state":vr({current:r,cursor:r}),role:"option","aria-selected":r,tabIndex:-1,onClick:()=>o(t.sha),...i.contextMenu(()=>FS(t)),"data-tip":`${t.subject}
|
|
119
|
+
${t.short} · ${t.author}`,"data-tip-placement":"follow",children:[d.jsx("span",{className:"subject",children:t.subject}),d.jsx("span",{className:"at row-dim",children:oo(t.at)})]})});function UD(e,t){const n=ko(e,t);if(!n||!vn(n))return"take this worktree over to change files here";if(na(n.worktree))return"start a worktree to change files"}function n_(e,t,n,r){return{id:"new-file",label:"new file…",disabled:UD(e.getState(),t),onClick:()=>r(n)}}function HD(e,t,n,r){const{worktreeId:o,dir:i,path:l,folder:c,newIn:u}=e,h=Wf(t.getState(),o)?void 0:"take this worktree over to talk to an agent here",p=Ek(l,c),m=[...c?[]:[{id:"open",label:"open",onClick:()=>tr(n,{worktreeId:o,path:l,view:pi(l)})}],{id:"add-to-chat",label:"add to chat",disabled:h,onClick:()=>gS(t,o,l,c)}],k=[n_(t,o,u,r),{id:"ask-rename",label:"ask the agent to rename…",disabled:h,onClick:()=>nb(t,o,`Rename ${p} to `)},{id:"ask-delete",label:"ask the agent to delete…",disabled:h,onClick:()=>nb(t,o,`Delete ${p} and update whatever still uses it`)}],g=[...ds(()=>{var y;return(y=n.sock)==null?void 0:y.send({t:"reveal",worktreeId:o,path:l})},Is(n.sock)),{id:"copy-path",label:"copy path",onClick:()=>Jt(`${i}/${l}`)},{id:"copy-relative-path",label:"copy relative path",onClick:()=>Jt(l)}];return Ln([m,g,k])}function WD(e,t,n,r){return Ln([[n_(t,e.worktreeId,"",r)],ds(()=>{var o;return(o=n.sock)==null?void 0:o.send({t:"reveal",worktreeId:e.worktreeId})},Is(n.sock))])}const vd=[],KD=[],yb=new Set,vb=e=>`tree-row-${e}`;function ZD({worktreeId:e,dir:t,openPath:n,openRef:r,rootRef:o}){const i=Zn(),l=pt(),c=ut(),u=It(e,"files"),h=It(e,"submodules"),p=It(e,"ignored"),m=It(e,"git"),k=(m==null?void 0:m.files)??KD;gt([e,m,l],()=>Uf(e,i.getState(),{sock:l,dispatch:c}));const g=L(oe=>{var re;return((re=oe.dragFiles)==null?void 0:re.at)==="tree"&&oe.dragFiles.worktreeId===e?oe.dragFiles.dir:null}),y=L(oe=>oe.treeOpen[e]??vd),b=_.useMemo(()=>new Set(y),[y]),[S,j]=_.useState(yb);gt([e,n,r],()=>j(n&&!r?new Set(Jd(n).filter(oe=>!b.has(oe))):yb));const E=_.useCallback(oe=>b.has(oe)||S.has(oe),[b,S]),N=_.useCallback(oe=>{const re=b.has(oe)||S.has(oe);if(re&&S.has(oe)){const Le=new Set(S);Le.delete(oe),j(Le)}c({a:"tree-folder",worktreeId:e,path:oe,open:!re})},[b,S,e,c]),A=_.useMemo(()=>w4(u??vd,h??vd,p??vd),[u,h,p]),O=_.useMemo(()=>y4(A,E),[A,E]),P=_.useMemo(()=>b4(k),[k]),R=L(oe=>oe.treeReveal),T=R&&R.worktreeId===e?R:null,[$,D]=_.useState(()=>(T==null?void 0:T.path)??null),[z,V]=_.useState({worktreeId:e,linked:T});(z.worktreeId!==e||z.linked!==T)&&(V({worktreeId:e,linked:T}),D((T==null?void 0:T.path)??null));const[se,I]=_.useState(!1),ne=_.useMemo(()=>{if($===null)return-1;const oe=O.findIndex(re=>re.path===$);if(oe>=0)return oe;for(const re of Jd($).reverse()){const Le=O.findIndex(Ue=>Ue.path===re);if(Le>=0)return Le}return-1},[O,$]);gt([ne,se],()=>{var oe,re;se&&((re=(oe=o.current)==null?void 0:oe.querySelector('[data-state~="cursor"]'))==null||re.scrollIntoView({block:"nearest"}))});const we=_.useCallback((oe,re)=>tr({dispatch:c},{worktreeId:e,path:oe,view:pi(oe),focus:re}),[e,l,c]),K=_.useCallback(oe=>{D(oe.path),oe.kind==="folder"?N(oe.path):oe.kind==="file"&&we(oe.path,!1)},[N,we]),B=oe=>{var Ue;if(oe.metaKey||oe.ctrlKey||oe.altKey)return;const re=O[ne],Le=_e=>{const je=O[_e];je&&(D(je.path),je.kind==="file"&&we(je.path,!1))};switch(oe.key){case"ArrowDown":case"ArrowUp":oe.preventDefault(),Le(ne<0?0:Jc(ne,oe.key==="ArrowDown"?1:-1,O.length));return;case" ":oe.preventDefault(),(re==null?void 0:re.kind)==="file"?we(re.path,!1):(re==null?void 0:re.kind)==="folder"&&N(re.path);return;case"Enter":oe.preventDefault(),(re==null?void 0:re.kind)==="file"?we(re.path,!0):(re==null?void 0:re.kind)==="folder"&&N(re.path);return;case"ArrowRight":case"ArrowLeft":{oe.preventDefault();const _e=O.map(Ne=>Ne.kind==="folder"?{depth:Ne.depth,open:Ne.open}:{depth:Ne.depth}),je=qf(_e,ne,oe.key);(je==null?void 0:je.do)==="to"?Le(je.at):je&&re&&N(re.path);return}case"Escape":oe.stopPropagation(),n!==null?c({a:"close-editor"}):(Ue=document.activeElement)==null||Ue.blur();return}if(oe.key.length===1){const _e=OS(O.map(je=>je.name),ne,oe.key);_e>=0&&(oe.preventDefault(),Le(_e))}},[ee,J]=_.useState(null),W=_.useRef(0),ie=_.useCallback(oe=>{oe&&!E(oe)&&N(oe),W.current++,J({dir:oe,error:null,busy:!1})},[E,N]),Te=_.useCallback(()=>{W.current++,J(null)},[]),Ce=_.useCallback(oe=>{if(!ee||ee.busy)return;const re=v4(ee.dir,oe);if("error"in re){J({...ee,error:re.error});return}const Le=++W.current;J({...ee,error:null,busy:!0}),dS({sock:l,dispatch:c},{worktreeId:e,path:re.path}).then(Ue=>{Ue===null&&D(re.path),Le===W.current&&J(Ue===null?null:{...ee,error:Ue,busy:!1})})},[ee,e,l,c]),de=bn("tree"),be=_.useCallback(oe=>HD({worktreeId:e,dir:t,path:oe.path,folder:oe.kind!=="file",newIn:oe.kind==="folder"||oe.kind==="ignored"?oe.path:kS(oe.path)},i,{sock:l,dispatch:c},ie),[e,t,i,l,c,ie]),le=_.useCallback((oe,re)=>{oe.kind==="file"&&cn.post(e,re?{type:"highlight-file",path:oe.path,ranges:null}:{type:"highlight-clear"})},[e]),G=_.useCallback((oe,re)=>{re.dataTransfer.setData(bS,oe.path),re.dataTransfer.setData("text/plain",oe.path),re.dataTransfer.effectAllowed="copy",P4({worktreeId:e,path:oe.path,folder:oe.kind!=="file"})},[e]),ce=_.useCallback(()=>xS(i),[i]);return d.jsx("div",{className:Ke("tree",g===""&&"drop-over"),role:"tree","aria-label":"files","data-worktree":e,"aria-activedescendant":se&&ne>=0?vb(ne):void 0,tabIndex:0,ref:o,onKeyDown:B,onFocus:()=>{var oe;I(!0),$===null&&D(n&&O.some(re=>re.path===n)?n:((oe=O[0])==null?void 0:oe.path)??null)},onBlur:oe=>!oe.currentTarget.contains(oe.relatedTarget)&&I(!1),onMouseDown:oe=>{if(oe.button!==0)return;const re=oe.target.closest("[data-path]");(re==null?void 0:re.dataset.path)!==void 0&&D(re.dataset.path)},...de.contextMenu(oe=>{const re=O[ne];return oe==="keyboard"&&re?be(re):WD({worktreeId:e},i,{sock:l},ie)}),children:u===void 0?d.jsx("div",{className:"empty",children:"listing files…"}):O.length===0&&!ee?d.jsx("div",{className:"empty",children:"no files"}):qD(O.map((oe,re)=>d.jsx(VD,{row:oe,id:vb(re),status:P.files.get(oe.path),changedInside:oe.kind!=="file"&&P.folders.has(oe.path),current:se?re===ne:!r&&oe.path===n,cursor:se&&re===ne,dropOver:g===oe.path,onPress:K,menu:be,onHover:le,onDragStart:G,onDragEnd:ce},oe.path)),ee&&(()=>{var re;const oe=ee.dir===""?-1:O.findIndex(Le=>Le.path===ee.dir);return{at:oe,node:d.jsx(GD,{depth:oe>=0?(((re=O[oe])==null?void 0:re.depth)??0)+1:0,error:ee.error,onSubmit:Ce,onCancel:Te},"new-file")}})())})}function qD(e,t){return t?[...e.slice(0,t.at+1),t.node,...e.slice(t.at+1)]:e}function GD({depth:e,error:t,onSubmit:n,onCancel:r}){const[o,i]=_.useState(""),l={"--tree-depth":e},c=e===0||void 0;return d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"row row-sm tree-row row-rails","data-kind":"file","data-root":c,style:l,children:[d.jsx("span",{className:"tree-caret row-dim"}),d.jsx(jo,{bare:!0,font:"mono",autoFocus:!0,className:"tree-new-name","aria-label":"new file name","aria-invalid":t!==null||void 0,placeholder:"name",value:o,onChange:u=>i(u.target.value),onKeyDown:u=>{u.stopPropagation(),u.key==="Enter"?(u.preventDefault(),n(o)):u.key==="Escape"&&(u.preventDefault(),r())},onBlur:r})]}),t&&d.jsxs("div",{className:"tree-row tree-new-error row-rails","data-root":c,style:l,children:[d.jsx("span",{className:"tree-caret"}),d.jsx("span",{className:"hint",children:t})]})]})}const VD=_.memo(function({row:t,id:n,status:r,changedInside:o,current:i,cursor:l,dropOver:c,onPress:u,menu:h,onHover:p,onDragStart:m,onDragEnd:k}){const g=bn("tree"),y=t.kind==="submodule",b=y?"A submodule: its files belong to its own repository":t.kind==="ignored"?"Ignored by git, so what is inside is not listed":null;return d.jsxs("div",{role:"treeitem",id:n,"aria-level":t.depth+1,"aria-expanded":t.kind==="folder"?t.open:void 0,"aria-selected":l,className:Ke("row row-sm tree-row row-rails row-edge",c&&"drop-over"),"data-state":vr({current:i,cursor:l}),"data-kind":t.kind,"data-path":t.path,style:{"--tree-depth":t.depth},draggable:!y,onDragStart:S=>m(t,S),onDragEnd:k,onClick:()=>u(t),onMouseEnter:()=>p(t,!0),onMouseLeave:()=>p(t,!1),...g.contextMenu(()=>h(t)),...b?Ut(b):{},children:[d.jsx("span",{className:"tree-caret row-dim",children:t.kind==="folder"&&d.jsx(St,{name:"caret",className:Ke("icon-inline disc-caret",!t.open&&"shut")})}),d.jsx("span",{className:Ke("tree-name",(y||t.ignored)&&"row-dim"),children:t.name}),r?d.jsx("span",{className:`xy ${ek(r.xy)}`,children:tk(r.xy)}):o&&d.jsx("span",{className:"dot tree-changed"})]})});function r_({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 bd=_.memo(function({f:t,id:n,active:r,selected:o,checking:i=!1,checked:l=!1,onOpen:c,onCheck:u,menu:h,onHover:p}){const m=bn("changes"),{name:k,dir:g}=xP(t.path);return d.jsxs("button",{className:"row row-sm git-file row-edge",id:n,"data-state":vr({current:r,cursor:o,checked:l}),role:"option","aria-selected":o,tabIndex:-1,onClick:y=>u&&(i||y.shiftKey)?u(t.path):c(t.path),...m.contextMenu(()=>h(t.path)),onMouseEnter:()=>p(t.path,!0),onMouseLeave:()=>p(t.path,!1),children:[i&&d.jsx("input",{type:"checkbox",className:"changes-check",checked:l,readOnly:!0,tabIndex:-1}),d.jsx("span",{className:`xy ${ek(t.xy)}`,children:tk(t.xy)}),d.jsxs("span",{className:"path","data-tip":g?t.path:void 0,children:[d.jsx("span",{className:"name",children:k}),g&&d.jsx("span",{className:"dir row-dim",children:g})]}),d.jsx(r_,{f:t})]})}),YD={added:"A",changed:"M",removed:"D"},XD={added:"added",changed:"",removed:"deleted"},QD=_.memo(function({tests:t,id:n,cursor:r,onPick:o}){return t.map((i,l)=>d.jsxs("button",{className:"row row-sm changes-test row-rails row-edge",id:`${n}-t${l}`,"data-state":vr({current:r===l,cursor:r===l}),"data-sub":!0,role:"option","aria-selected":r===l,tabIndex:-1,onClick:()=>o(l),"data-tip":[...i.group,i.name].join(" · "),"data-tip-placement":"follow",children:[d.jsx("span",{className:`xy ${XD[i.change]}`,children:YD[i.change]}),d.jsx("span",{className:"name",children:i.name})]},l))}),bb=new Set(["test","tests","__tests__","spec","e2e","__snapshots__","__mocks__","fixtures","testdata"]),JD=/([._-]tests?\.[^.]+$)|([._]specs?\.[^.]+$)|(^tests?[._-])|(^conftest\.py$)|(\.snap$)|([a-z0-9](Tests?|Spec)\.[^.]+$)/;function rf(e){const t=(e.endsWith("/")?e.slice(0,-1):e).split("/"),n=t.pop()??"";return e.endsWith("/")&&bb.has(n.toLowerCase())?!0:t.some(r=>bb.has(r.toLowerCase()))||JD.test(n)}function xd(e){const t=e.filter(n=>!rf(n.path));return t.length===0||t.length===e.length?{files:e,source:t.length}:{files:[...t,...e.filter(n=>rf(n.path))],source:t.length}}const Wm="(?<q>[\"'`])(?<name>(?:\\\\.|(?!\\k<q>).)*)\\k<q>",xb={tests:[new RegExp(`^\\s*(?:test|it)(?:\\.(?!each\\b)\\w+)*(?:\\.each\\(.*\\))?\\(\\s*${Wm}`)],groups:[new RegExp(`^\\s*describe(?:\\.(?!each\\b)\\w+)*(?:\\.each\\(.*\\))?\\(\\s*${Wm}`)]},ez={js:xb,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*${Wm}`),/^\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*\(/,...xb.tests]}},tz={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"},nz=3,rz=/^\s*(?:[)}\]]|end\b)/,Hp=e=>e.length-e.trimStart().length;function Eb(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 Sb(e,t){const n=t.split(`
|
|
120
|
+
`),r=[],o=[];let i=Number.NEGATIVE_INFINITY;return n.forEach((l,c)=>{var k,g,y;if(l.trim()==="")return;const u=Hp(l);for(;o.length>0&&(((k=o.at(-1))==null?void 0:k.indent)??0)>=u;)o.pop();(g=e.mark)!=null&&g.test(l)&&(i=c);const p=!e.mark||c-i<=nz?Eb(l,e.tests):null,m=p??Eb(l,e.groups);if(m!==null){if(p!==null){i=Number.NEGATIVE_INFINITY;let b=c+1;for(;b<n.length&&(((y=n[b])==null?void 0:y.trim())===""||Hp(n[b]??"")>u);)b++;b<n.length&&Hp(n[b]??"")===u&&rz.test(n[b]??"")&&b++;const S=n.slice(c,b).map(j=>j.trim()).join(`
|
|
121
|
+
`).trim();r.push({group:o.map(j=>j.name),name:m,line:c,end:b,body:S})}o.push({indent:u,name:m})}}),r}function _b(e){const t=new Map;for(const n of e){const r=[...n.group,n.name].join(`
|
|
122
|
+
`);let o=0;for(;t.has(`${r}
|
|
123
|
+
${o}`);)o++;t.set(`${r}
|
|
124
|
+
${o}`,n)}return t}function oz(e,t,n){const r=ez[tz[e.slice(e.lastIndexOf(".")+1).toLowerCase()]??""];if(!r)return[];const o=_b(Sb(r,t)),i=_b(Sb(r,n)),l=[];for(const[p,m]of i){const k=o.get(p);(k==null?void 0:k.body)!==m.body&&l.push({name:m.name,group:m.group,change:k?"changed":"added",line:m.line+1})}const c=n.split(`
|
|
125
|
+
`).length;let u=1;for(const[p,m]of o){const k=i.get(p);k?u=Math.min(k.end+1,c):l.push({name:m.name,group:m.group,change:"removed",line:u})}const h=p=>p.change==="removed"?0:1;return l.sort((p,m)=>p.line-m.line||h(p)-h(m))}const Ed=[];function sz(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=oo(r.at);return`${o}, last commit ${i==="now"?"just now":`${i} ago`}`}const Nb='[role="option"]:not([data-sub])',Tb=[];function o_({width:e,placement:t="dock"}){const n=t==="screen",r=pt(),o=ut(),i=Zn(),l=hl(),c=ia(),u=(c==null?void 0:c.id)??l,h=Rs(),p=L(H=>H.layout.changes),m=Yc(),k=L(H=>H.focusChanges),g=It(u,"git"),y=L(H=>H.editor&&H.editor.worktreeId===u?H.editor.path:null),b=L(H=>H.editor&&H.editor.worktreeId===u?H.editor.ref??null:null),S=L(H=>H.editor&&H.editor.worktreeId===u?H.editor.since??null:null),j=(g==null?void 0:g.files)??Ed,E=(g==null?void 0:g.committed)??Ed,{files:N,source:A}=_.useMemo(()=>xd(j),[j]),O=E.length>0,P=IL(),{files:R,source:T}=_.useMemo(()=>xd(P?E:Ed),[E,P]),$=g==null?void 0:g.turn,D=$==null?void 0:$.base,z=RL(),{files:V,source:se}=_.useMemo(()=>xd($&&z?$.files:Ed),[$,z]),I=N.length,ne=N.length+V.length,we=L(H=>H.editor&&H.editor.worktreeId===u?H.editor.disk:null),K=_.useMemo(()=>y!==null&&we&&rf(y)?oz(y,we.before,we.after):Tb,[y,we]),[B,ee]=_.useState(!1);gt([y,b,S],()=>ee(!1));const J=A>0?N.length-A:0,W=T>0?R.length-T:0,ie=se>0?V.length-se:0,Te=N.length===0,Ce=_.useMemo(()=>{if(N.length===0)return;const H=N.reduce((Nt,Xt)=>Nt+(Xt.add??0),0),me=N.reduce((Nt,Xt)=>Nt+(Xt.del??0),0),Be=[H>0&&`+${H}`,me>0&&`−${me}`].filter(Boolean).join(" "),lt=`${N.length} uncommitted ${N.length===1?"file":"files"}`;return Be?`${lt}, ${Be}`:lt},[N]),de=!!g&&Te&&!O,be=L(sl),le=c!==null||be==="changes",G=c!==null||be==="history",ce=_.useCallback(H=>o({a:"changes-tab",v:H}),[o]),oe=_.useRef(be);oe.current=be;const re=_.useRef(null),Le=gk(),Ue=L(H=>{const me=yi(H,Le==null?void 0:Le.repoId);return me?Ef(me):"main"}),_e=It(u,"commits"),je=It(u,"commitFiles"),[Ne,qe]=_.useState(null),Ft=_.useRef(null);Ft.current=Ne;const qt=_.useRef(null),jt=It(u,"changedRanges"),Ht=_.useCallback((H,me)=>{if(!u||c)return;if(!me){qt.current=null,cn.post(u,{type:"highlight-clear"});return}qt.current=H;const Be=jt[H];Be?cn.post(u,{type:"highlight-file",path:H,ranges:j0(Be)}):r==null||r.send({t:"changed-ranges",worktreeId:u,path:H})},[u,c,jt,r]);_.useEffect(()=>{const H=qt.current;if(!H||!u)return;const me=jt[H];me&&cn.post(u,{type:"highlight-file",path:H,ranges:j0(me)})},[jt,u]);const sn=c&&N.length>0?(g==null?void 0:g.head)??null:null,Ct=_.useCallback((H,me=!1,Be)=>u&&tr({dispatch:o},{worktreeId:u,path:H,focus:me,ref:sn??void 0,since:Be}),[u,sn,r,o]),He=_.useMemo(()=>c?N:[...N,...V,...R],[c,N,V,R]),Ze=_.useMemo(()=>{const H=[];for(const me of _e??[])if(H.push({commit:me}),me.sha===Ne)for(const Be of xd(je[me.sha]??[]).files)H.push({commit:me,file:Be});return H},[_e,Ne,je]),At=_.useMemo(()=>Ze.filter(H=>!H.file&&H.commit.ahead).length,[Ze]),_t=_.useMemo(()=>Ze.findIndex(H=>!H.file&&!H.commit.ahead),[Ze]),kt=c?He.length:0,Fn=(le?He.length:0)+(G?Ze.length:0),un=_.useMemo(()=>{const H=new Map;if(!c||N.length===0&&Ze.every(Be=>Be.commit.landedAt))return H;let me;return Ze.forEach((Be,lt)=>{const Nt=!!Be.commit.landedAt;Nt!==me&&(me=Nt,H.set(lt,Nt?"landed":"not landed"))}),H},[c,N,Ze]),xn=_.useRef(null),[{row:$t,at:Tn},Y]=_.useReducer((H,me)=>typeof me=="number"?{row:me,at:-1}:me,{row:0,at:-1}),[pe,nt]=_.useState(!1),dt=(H,me)=>pe?wn(H):me,Bt=H=>`changes-row-${H}`,[Ot,Ee]=_.useState(!1),[$e,Wt]=_.useState([]),ft=_.useCallback(()=>{Ee(!1),Wt([])},[]),Z=_.useCallback(H=>{Ee(!0),Wt(me=>me.includes(H)?me.filter(Be=>Be!==H):[...me,H])},[]),ge=_.useMemo(()=>N.filter(H=>$e.includes(H.path)).map(H=>H.path),[N,$e]);gt([N],()=>Wt(H=>{const me=H.filter(Be=>N.some(lt=>lt.path===Be));return me.length===H.length?H:me})),gt([Ot],()=>{if(!Ot)return;const H=me=>me.key==="Escape"&&ft();return window.addEventListener("keydown",H),()=>window.removeEventListener("keydown",H)}),gt([u,be],()=>{Y(0),ft()});const Oe=g==null?void 0:g.head,st=_.useRef("");_.useEffect(()=>{if(!(G||de)||!u)return;const H=`${u}:${Oe??""}`;st.current!==H&&(st.current=H,r==null||r.send({t:"git-log",worktreeId:u}))},[G,de,u,Oe,r]);const Et=_.useCallback(H=>{qe(me=>me===H?null:H),u&&!je[H]&&(r==null||r.send({t:"git-commit",worktreeId:u,sha:H}))},[u,je,r]);gt([$t,Tn,pe],()=>{var H,me;pe&&((me=(H=xn.current)==null?void 0:H.querySelector('[data-state~="cursor"]'))==null||me.scrollIntoView({block:"nearest"}))});const Mt=_.useRef(-1),ze=H=>H>=I&&H<ne?D:void 0,Se=H=>{var me;return((me=He[H])==null?void 0:me.path)===y&&(S??void 0)===ze(H)&&(H<I?b===sn:!b)};Mt.current=le?He.findIndex((H,me)=>Se(me)):-1,_.useEffect(()=>{if(!k)return;const H=oe.current==="files";Mt.current>=0&&Y(Mt.current);const me=requestAnimationFrame(()=>{var Be;return(Be=(H?re:xn).current)==null?void 0:Be.focus()});return()=>cancelAnimationFrame(me)},[k]);const Ge=_.useCallback((H,me=!1)=>{const Be=He[H];Be&&(Y(H),Ct(Be.path,me,H>=I&&H<ne?D:void 0),Ht(Be.path,!0))},[He,Ct,Ht,I,ne,D]),Kt=_.useCallback((H,me=!1)=>{const Be=Ft.current;u&&Be&&tr({dispatch:o},{worktreeId:u,path:H,ref:Be,focus:me})},[u,r,o]),Qe=_.useCallback(H=>{const me=Ze[H-kt];me&&(Y(H),me.file&&Kt(me.file.path))},[Ze,kt,Kt]),mn=_.useCallback(H=>{const me=Ze[H-kt];me&&(Y(H),me.file?Kt(me.file.path,!0):Et(me.commit.sha))},[Ze,kt,Kt,Et]),Yt=H=>G&&H>=kt,En=H=>{if(y===null)return!1;if(le&&H<He.length)return Se(H);const me=Yt(H)?Ze[H-kt]:void 0;return!!(me!=null&&me.file)&&b===me.commit.sha&&me.file.path===y},qn=H=>En(H)&&!B?K:Tb,an=Tn<qn($t).length?Tn:-1,wn=H=>pe&&$t===H&&an<0,mr=()=>{var me,Be;const H=[];for(let lt=0;lt<Fn;lt++){const Nt=Yt(lt)?Ze[lt-kt]:void 0,Xt=Nt?(me=Nt.file)==null?void 0:me.path:(Be=He[lt])==null?void 0:Be.path,Bn=Nt!=null&&Nt.file?1:0,Yn=qn(lt);Nt&&!Nt.file?H.push({row:lt,at:-1,depth:Bn,open:Nt.commit.sha===Ne}):Xt!==void 0&&rf(Xt)?H.push({row:lt,at:-1,depth:Bn,open:Yn.length>0}):H.push({row:lt,at:-1,depth:Bn});for(let Dr=0;Dr<Yn.length;Dr++)H.push({row:lt,at:Dr,depth:Bn+1})}return H},Mn=(H,me=!1)=>{const Be=K[H];!Be||!u||y===null||tr({dispatch:o},{worktreeId:u,path:y,ref:b??void 0,since:S??void 0,line:{n:Be.line},focus:me})},tn=H=>qn(H).length>0&&d.jsx(QD,{tests:K,id:Bt(H),cursor:pe&&$t===H?an:-1,onPick:me=>{Y({row:H,at:me}),Mn(me)}}),Gn=H=>{var me;if(Ot&&H.key==="Escape")H.preventDefault(),H.stopPropagation(),ft();else if(Ot&&H.key===" "){H.preventDefault();const Be=le&&$t<N.length?N[$t]:void 0;Be&&Z(Be.path)}else if(H.key==="ArrowDown"&&an+1<qn($t).length)H.preventDefault(),Y({row:$t,at:an+1}),Mn(an+1);else if(H.key==="ArrowUp"&&an>=0)H.preventDefault(),an===0?Y($t):(Y({row:$t,at:an-1}),Mn(an-1));else if(H.key==="Enter"&&an>=0)H.preventDefault(),Mn(an,!0);else if(H.key==="ArrowDown"||H.key==="ArrowUp"){H.preventDefault();const Be=Jc($t,H.key==="ArrowDown"?1:-1,Fn);Yt(Be)?Qe(Be):Ge(Be)}else if(H.key==="Enter")H.preventDefault(),Yt($t)?mn($t):Ge($t,!0);else if(H.key==="ArrowRight"||H.key==="ArrowLeft"){H.preventDefault();const Be=mr(),lt=qf(Be,Be.findIndex(Bn=>Bn.row===$t&&Bn.at===an),H.key),Nt=lt&&Be[lt.at];if(!lt||!Nt)return;const Xt=Yt(Nt.row)?Ze[Nt.row-kt]:void 0;lt.do==="to"?Nt.at>=0?(Y({row:Nt.row,at:Nt.at}),Mn(Nt.at)):Xt!=null&&Xt.file&&Nt.row>$t?Qe(Nt.row):Y(Nt.row):Xt&&!Xt.file?Et(Xt.commit.sha):lt.do==="close"?ee(!0):En(Nt.row)?ee(!1):Xt!=null&&Xt.file?Qe(Nt.row):Ge(Nt.row)}else H.key==="Escape"&&(H.stopPropagation(),y!==null?o({a:"close-editor"}):(me=document.activeElement)==null||me.blur())},nn=c?c.id:h==null?void 0:h.worktree.id,Q=c?c.path:h?h.worktree.path:"",ke=c!==null,tt=_.useCallback(H=>nn?js({id:nn,dir:Q},H,{discard:!ke,kept:ke,ref:sn??void 0,select:ke?void 0:Z},{sock:r,dispatch:o}):[],[nn,Q,ke,sn,Z,r,o]),at=_.useCallback(H=>nn?js({id:nn,dir:Q},H,{kept:ke},{sock:r,dispatch:o}):[],[nn,Q,ke,r,o]),dn=_.useCallback(H=>nn?js({id:nn,dir:Q},H,{kept:ke,since:D},{sock:r,dispatch:o}):[],[nn,Q,ke,D,r,o]),Gt=_.useCallback(H=>nn?js({id:nn,dir:Q},H,{ref:Ft.current??void 0,kept:ke},{sock:r,dispatch:o}):[],[nn,Q,ke,r,o]),Tr=bn("changes"),Vn=()=>{if(le&&$t<He.length){const me=He[$t];return me?($t<I?tt:$t<ne?dn:at)(me.path):[]}const H=Yt($t)?Ze[$t-kt]:void 0;return H?H.file?Gt(H.file.path):FS(H.commit):[]},Cn=(H,me)=>{const Be=He.findIndex((lt,Nt)=>Nt>=H&<.path===me);Y(Be),Se(Be)&&K.length>0?ee(lt=>!lt):Ct(me,!1,ze(Be))},rn=_.useRef(Cn);rn.current=Cn;const ve=_.useCallback(H=>rn.current(0,H),[]),Ve=_.useCallback(H=>rn.current(I,H),[I]),We=_.useCallback(H=>rn.current(ne,H),[ne]),mt=_.useCallback(H=>{Y(kt+Ze.findIndex(me=>!me.file&&me.commit.sha===H)),Et(H)},[Ze,kt,Et]),ln=_.useCallback(H=>{Y(kt+Ze.findIndex(me=>{var Be;return((Be=me.file)==null?void 0:Be.path)===H})),H===y&&b===Ft.current&&K.length>0?ee(me=>!me):Kt(H)},[Ze,kt,Kt,y,b,K]),yn=_.useCallback(()=>{},[]);return d.jsxs("div",{className:Ke("changes-dock",n&&"changes-screen",!n&&(!p||m)&&"collapsed"),style:n?void 0:{width:e},children:[!c&&d.jsx(Zf,{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:Ut("files",Lt("files"))},{id:"changes",label:"changes",tip:Ut("changes",Lt("changes"),{detail:Ce})},{id:"history",label:"history"}],current:be,onPick:ce}),be==="files"&&u?d.jsx(ZD,{worktreeId:u,dir:h?h.worktree.path:(Le==null?void 0:Le.path)??"",openPath:y,openRef:b,rootRef:re}):d.jsxs("div",{className:Ke("changes-list",G&&"history"),role:"listbox","aria-label":c?"kept work":G?"commits":"changed files","aria-activedescendant":pe&&$t>=0&&$t<Fn?an<0?Bt($t):`${Bt($t)}-t${an}`:void 0,tabIndex:0,ref:xn,onKeyDown:Gn,onFocus:()=>nt(!0),onMouseDown:H=>{var lt;if(H.button!==0)return;H.preventDefault();const me=H.target.closest(Nb),Be=me?Array.from(H.currentTarget.querySelectorAll(Nb)).indexOf(me):-1;Be>=0&&Y(Be),(lt=xn.current)==null||lt.focus()},onBlur:H=>!H.currentTarget.contains(H.relatedTarget)&&nt(!1),...Tr.contextMenu(H=>H==="keyboard"?Vn():[]),children:[le&&N.length>0&&d.jsxs(d.Fragment,{children:[(O||c)&&d.jsx("div",{className:"section-title section-row",children:"uncommitted"}),N.map((H,me)=>d.jsxs(_.Fragment,{children:[J>0&&me===A&&d.jsx("div",{className:"section-title changes-sub",children:"tests"}),d.jsx(bd,{f:H,id:Bt(me),active:dt(me,En(me)),selected:wn(me),checking:Ot,checked:$e.includes(H.path),onOpen:ve,onCheck:ke?void 0:Z,menu:tt,onHover:Ht}),tn(me)]},`${H.xy}:${H.path}`))]}),le&&!c&&$&&d.jsxs(d.Fragment,{children:[d.jsxs("button",{type:"button",className:"section-title section-row section-fold","aria-expanded":z,"data-tip":"What changed since your last message","data-tip-placement":"follow",onClick:()=>o({a:"toggle-turn"}),onKeyDown:H=>(H.key==="Enter"||H.key===" ")&&H.stopPropagation(),children:["last turn",d.jsx(St,{name:"caret",className:Ke("icon-inline disc-caret",!z&&"shut")})]}),V.map((H,me)=>d.jsxs(_.Fragment,{children:[ie>0&&me===se&&d.jsx("div",{className:"section-title changes-sub",children:"tests"}),d.jsx(bd,{f:H,id:Bt(I+me),active:dt(I+me,En(I+me)),selected:wn(I+me),onOpen:Ve,menu:dn,onHover:Ht}),tn(I+me)]},`t-${H.path}`))]}),le&&!c&&O&&d.jsxs(d.Fragment,{children:[d.jsxs("button",{type:"button",className:"section-title section-row section-fold","aria-expanded":P,"data-tip":`Committed on this branch, not yet on ${Ue}`,"data-tip-placement":"follow",onClick:()=>o({a:"toggle-committed"}),onKeyDown:H=>(H.key==="Enter"||H.key===" ")&&H.stopPropagation(),children:["committed",d.jsx(St,{name:"caret",className:Ke("icon-inline disc-caret",!P&&"shut")})]}),R.map((H,me)=>d.jsxs(_.Fragment,{children:[W>0&&me===T&&d.jsx("div",{className:"section-title changes-sub",children:"tests"}),d.jsx(bd,{f:H,id:Bt(ne+me),active:dt(ne+me,En(ne+me)),selected:wn(ne+me),onOpen:We,menu:at,onHover:Ht}),tn(ne+me)]},`c-${H.path}`))]}),le&&!c&&de&&d.jsx("div",{className:"empty",children:sz(Ue,!!Le&&xf(Le),(g==null?void 0:g.behind)??0,_e==null?void 0:_e[0])}),G&&Ze.map((H,me)=>d.jsxs(_.Fragment,{children:[c&&un.has(me)&&d.jsx("div",{className:"section-title section-row",children:un.get(me)}),!c&&At>0&&me===0&&d.jsx("div",{className:"section-title section-row",children:"on this branch"}),!c&&At>0&&me===_t&&d.jsx("div",{className:"section-title section-row",children:Ue}),H.file?d.jsxs(d.Fragment,{children:[d.jsx(bd,{f:H.file,id:Bt(kt+me),active:dt(kt+me,En(kt+me)),selected:wn(kt+me),onOpen:ln,menu:Gt,onHover:yn}),tn(kt+me)]}):d.jsx(BD,{c:H.commit,id:Bt(kt+me),selected:wn(kt+me),onToggle:mt})]},H.file?`${H.commit.sha}:${H.file.path}`:H.commit.sha)),G&&_e===void 0&&d.jsx("div",{className:"empty",children:"reading history…"}),G&&(_e==null?void 0:_e.length)===0&&N.length===0&&d.jsx("div",{className:"empty",children:"no commits yet"})]}),Ot&&d.jsxs("div",{className:"changes-pick",children:[d.jsxs(De,{size:"md",tone:"danger",disabled:ge.length===0,"data-tip":"Throw away the uncommitted changes to every checked file",onClick:()=>{!nn||ge.length===0||window.confirm(fS(ge))&&(r==null||r.send({t:"discard-files",worktreeId:nn,paths:ge}),ft())},children:["discard ",ge.length,"…"]}),d.jsx(De,{size:"md",disabled:ge.length===0,"data-tip":"Name every checked file in the chat",onClick:()=>{nn&&p4(i,nn,ge),ft()},children:"add to chat"}),d.jsx(Rt,{icon:"close",label:"Cancel",hint:"esc",onClick:ft})]}),Le&&!c&&d.jsx(FD,{active:Le,ahead:(g==null?void 0:g.ahead)??0,behind:(g==null?void 0:g.behind)??0,unpushed:(g==null?void 0:g.unpushed)??Le.unpushed??0,dirty:!Te})]})}function iz(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 jb(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 eu(e){return e>0&&e<.005?"<$0.01":`$${e.toFixed(2)}`}function az(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 lz(e){if(!(e<.5))return e<.8?"worth compacting between tasks":"compact before the next task"}const s_=["five_hour","seven_day"],cz={five_hour:"the 5-hour window",seven_day:"the week"},uz={five_hour:"5-hour",seven_day:"this week"};function i_(e,t){return s_.flatMap(n=>{const r=e.windows[n];return r&&r.resetsAt>t?[{key:n,used:r.used,resetsAt:r.resetsAt}]:[]})}function dz(e,t){return Math.min(1,Math.max(0,...i_(e,t).map(n=>n.used)))}const fz=e=>`${Math.round(100*e)}%`;function Cb(e,t){const n=i_(e,t).map(r=>`${fz(r.used)} of ${cz[r.key]}`);return n.length?n.join(", "):"plan windows reset"}function hz(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 pz(e,t,n=r=>hz(r,t)){return s_.flatMap(r=>{const o=e.windows[r];if(!o)return[];const i=uz[r];if(o.resetsAt<=t)return[{key:r,name:i,used:0,sub:`reset ${n(o.resetsAt)}, read again on the next reply`}];const l=e.binding===r&&e.status==="rejected"?", out until then":e.binding===r&&e.status==="allowed_warning"?", nearly out":"";return[{key:r,name:i,used:o.used,sub:`resets ${n(o.resetsAt)}${l}`}]})}function mz(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 a_(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(eu(e.cost)),t.push(oo(e.archivedAt)),t.filter(Boolean).join(" · ")}function l_({sock:e},t,n){e==null||e.send({t:"restore-worktree",archiveId:t,clientId:n})}function zd(e,t,{sock:n,dispatch:r}){const o=[{id:"restore",label:"restore",disabled:e.restorable?void 0:"its commits were not kept",onClick:()=>{l_({sock:n},e.id,t.clientId),r({a:"close"})}}],i=[{id:"copy-branch",label:"copy branch name",onClick:()=>Jt(e.branch)}],{sessionId:l}=e;return t.frame!=="phone"&&(i.push({id:"copy-transcript",label:"copy transcript path",onClick:()=>Jt(e.transcript)}),l&&i.push({id:"copy-session",label:"copy session id",onClick:()=>Jt(l)})),Ln([o,i,[{id:"delete",label:"delete for good…",danger:!0,onClick:()=>{window.confirm(`Delete "${e.title}" for good?
|
|
126
|
+
|
|
127
|
+
Its chat, attachments and kept commits are deleted, and it can no longer be restored.`)&&(n==null||n.send({t:"delete-archived",archiveId:e.id}))}}]])}const gz=new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"});function c_(e){const[t,n]=_.useState(()=>Date.now());return _.useEffect(()=>{const r=setInterval(()=>n(Date.now()),6e4);return()=>clearInterval(r)},[]),`${ok(t-e)} ago`}function Wr({icon:e,word:t,tone:n,at:r,below:o,children:i,...l}){const c=r!==void 0?{"data-tip":`${t} ${gz.format(r)}`,"data-tip-placement":"follow"}:null;return d.jsxs("div",{...c,...l,className:"daemon-row row-edge","data-tone":n,children:[d.jsxs("div",{className:"daemon-head",children:[d.jsxs("span",{className:"daemon-tag",children:[d.jsx(St,{name:e,className:"icon-inline"}),t]}),i]}),o]})}function kz({item:e}){const t=pt(),n=L(u=>u.clientId),r=e.uncommitted?"its chat, commits and uncommitted changes":"its chat and commits",o=e.cost!==void 0?`; the session cost ${eu(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 for good.`,l=c_(e.archivedAt),c=Ik(e.lands);return d.jsxs(Wr,{icon:"archive",word:"archived",tone:"quiet",at:e.archivedAt,below:d.jsxs(d.Fragment,{children:[c.map((u,h)=>d.jsx("div",{className:"daemon-below row-dim",children:u},h)),d.jsx("div",{className:"daemon-below row-dim",children:i})]}),children:[d.jsxs("span",{className:"daemon-text",children:[l,e.landed?", after it was merged into main":""]}),e.restorable&&d.jsx(De,{variant:"inline",tone:"strong",onClick:()=>l_({sock:t},e.id,n),children:"restore"})]})}function ea(e,t,n,r,o){const{layout:i}=e.getState();tr({dispatch:e.dispatch},{worktreeId:n,path:r,view:"file",line:{n:o,fiber:!0}}),i.changes||e.dispatch({a:"toggle-changes"})}function wz(e){let t=0;return e.map(n=>{const r={start:t,len:n};return t+=n,r})}function yz(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 Ab(e,t,n){let r=0,o=e.length-1;for(;r<o;){const l=r+o>>1,c=e[l];(n?t>c.start+c.len:t>=c.start+c.len)?r=l+1:o=l}const i=e[r];return{i:r,at:t-i.start}}function vz(e,t){return{from:Ab(e,t.start,!1),to:Ab(e,t.end,!0)}}function Ib(e,t){if(e.length===0)return-1;const n=e.findIndex(r=>r.start>=t);return n===-1?0:n}function bz(e,t,n){return t===0?-1:(e+n+t)%t}function Pk(e){return e.key==="f"&&(e.metaKey||e.ctrlKey)&&!e.altKey&&!e.shiftKey}function xz({label:e,query:t,onQuery:n,seed:r,seq:o,status:i,none:l,onStep:c,onClose:u}){const h=_.useRef(null);return gt([o],()=>{var p,m;r&&n(r),(p=h.current)==null||p.focus(),(m=h.current)==null||m.select()}),d.jsxs("div",{className:"find",children:[d.jsx(jo,{ref:h,autoFocus:!0,value:t,onChange:p=>n(p.target.value),placeholder:"find…","aria-label":e,className:"find-field",spellCheck:!1,onKeyDown:p=>{if(p.key==="Escape"){p.preventDefault(),p.stopPropagation(),u();return}if(p.key==="Enter"){p.preventDefault(),c(p.shiftKey?-1:1);return}if(Pk(p)){p.preventDefault(),p.stopPropagation(),p.currentTarget.select();return}p.key.toLowerCase()==="g"&&(p.metaKey||p.ctrlKey)&&!p.altKey&&(p.preventDefault(),p.stopPropagation(),c(p.shiftKey?-1:1))}}),d.jsx("span",{className:"find-count","aria-live":"polite",children:i}),d.jsx(Rt,{icon:"caret",label:"Previous match",hint:"⇧↩",className:"find-prev",disabled:l,onClick:()=>c(-1)}),d.jsx(Rt,{icon:"caret",label:"Next match",hint:"↩",disabled:l,onClick:()=>c(1)}),d.jsx(Rt,{icon:"close",label:"Close",hint:"esc",onClick:u})]})}const u_="find",d_="find-current",f_=typeof CSS<"u"&&"highlights"in CSS;function Ez(e){const t=e.parentElement;return t?typeof t.checkVisibility=="function"?t.checkVisibility():!0:!1}function Sz(e){const t=document.createTreeWalker(e,NodeFilter.SHOW_TEXT),n=[];for(let r=t.nextNode();r;r=t.nextNode()){const o=r;o.data.length>0&&Ez(o)&&n.push(o)}return n}const Km={matches:[],ranges:[]};function _z(e,t){if(!t)return Km;const n=Sz(e),r=yz(n.map(l=>l.data).join(""),t),o=wz(n.map(l=>l.data.length)),i=r.map(l=>{const{from:c,to:u}=vz(o,l),h=document.createRange();return h.setStart(n[c.i],c.at),h.setEnd(n[u.i],u.at),h});return{matches:r,ranges:i}}function Nz(e,t){f_&&(CSS.highlights.set(u_,new Highlight(...e.filter((n,r)=>r!==t))),CSS.highlights.set(d_,new Highlight(...e[t]?[e[t]]:[])))}function Tz(){f_&&(CSS.highlights.delete(u_),CSS.highlights.delete(d_))}function jz(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 Rb=48;function Cz(e,t){const n=t.getBoundingClientRect(),r=e.getBoundingClientRect();n.top>=r.top+Rb&&n.bottom<=r.bottom-Rb||(e.scrollTop+=n.top-r.top-r.height/3)}function h_({root:e,body:t,seed:n,seq:r,onClose:o,onReveal:i}){const[l,c]=_.useState(n),[u,h]=_.useState(Km),[p,m]=_.useState(-1),k=_.useRef({found:Km,at:-1}),g=_.useRef(""),y=_.useRef(!1),[b,S]=_.useState(0);_.useLayoutEffect(()=>{const A=t.current;if(!A)return;let O=0;const P=new MutationObserver(()=>{O||(O=requestAnimationFrame(()=>{O=0,S(R=>R+1)}))});return P.observe(A,{childList:!0,characterData:!0,subtree:!0,attributes:!0}),()=>{P.disconnect(),O&&cancelAnimationFrame(O)}},[t]),_.useLayoutEffect(()=>{const A=t.current;if(!A)return;const O=_z(A,l),P=l!==g.current;g.current=l,P&&(y.current=!0);const{found:R,at:T}=k.current;let $;P?R.matches[T]?$=Ib(O.matches,R.matches[T].start):$=e.current?jz(O.ranges,e.current):Ib(O.matches,0):$=Math.min(T,O.matches.length-1),k.current={found:O,at:$},h(O),m($)},[l,b]),_.useLayoutEffect(()=>{Nz(u.ranges,p);const A=u.ranges[p];A&&(y.current&&e.current&&(Cz(e.current,A),i==null||i()),y.current=!1)},[u,p,e,i]),_.useLayoutEffect(()=>Tz,[]);const j=u.matches.length,E=A=>{if(j===0)return;y.current=!0;const O=bz(k.current.at,j,A);k.current={...k.current,at:O},m(O)},N=()=>o(u.ranges[p]??null);return d.jsx(xz,{label:"find in this document",query:l,onQuery:c,seed:n,seq:r,status:l?j===0?"no matches":`${p+1}/${j}`:"",none:j===0,onStep:E,onClose:N})}function p_(e){return e.key==="a"&&(e.metaKey||e.ctrlKey)&&!e.altKey&&!e.shiftKey}function m_(e,t,n,r){_.useEffect(()=>{let o=!1;const i=c=>{o=!!e.current&&c.target instanceof Node&&e.current.contains(c.target)},l=c=>{const u=e.current;if(!u||c.defaultPrevented||!t(c))return;const h=document.activeElement;!(h&&h!==document.body?u.contains(h):o)&&!(r!=null&&r(h))||(c.preventDefault(),n(u,c))};return window.addEventListener("pointerdown",i,!0),window.addEventListener("keydown",l),()=>{window.removeEventListener("pointerdown",i,!0),window.removeEventListener("keydown",l)}},[e,t,n,r])}function Az(e){m_(e,p_,g_)}function Zm(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 g_(e){const t=document.createRange();t.selectNodeContents(e);const n=window.getSelection();n&&(n.removeAllRanges(),n.addRange(t))}const Iz=e=>e.t==="open-path"||e.t==="open-loose",Wa=new Map,Rz=16;function qm({sock:e,dispatch:t},n,r){const o=Zo();Wa.set(o,{worktreeId:n,href:r.href});for(const i of Wa.keys()){if(Wa.size<=Rz)break;Wa.delete(i)}t({a:"link-refused",id:n,v:null}),e==null||e.send({t:"open-by-path",path:r.path,seq:o})}function $z(e,t){const n=Wa.get(t.seq);n&&(Wa.delete(t.seq),e.dispatch({a:"link-refused",id:n.worktreeId,v:{href:n.href,message:t.message}}))}function Oz(e,t,n){var i;const r=e.getState();if(n.t==="open-path"){const l={dispatch:u=>e.dispatch(u)};if(ko(r,n.worktreeId)){r.activeId!==n.worktreeId&&e.dispatch({a:"activate",id:n.worktreeId}),tr(l,{worktreeId:n.worktreeId,path:n.path});return}const c=Object.keys(r.trunks).find(u=>{var h;return((h=r.trunks[u])==null?void 0:h.id)===n.worktreeId});if(!c)return;if(((i=ko(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})}tr(l,{worktreeId:n.worktreeId,path:n.path});return}const o=r.activeId;if(!o){e.dispatch({a:"server",msg:{t:"error",message:`open a project first; ${n.name} needs a window to open in`}});return}e.dispatch({a:"open-loose",v:{worktreeId:o,name:n.name,text:n.text,binary:n.binary,tooLarge:n.tooLarge,source:{kind:"grant",id:n.id,path:n.path,version:n.version},seq:Zo()}})}const k_=({open:e,remove:t})=>[e?[{id:"open",label:"open full size",onClick:e}]:[],t?[{id:"remove",label:"remove",onClick:t}]:[]];function zc(e,t={}){return Ln([[{id:"copy-image",label:"copy image",onClick:()=>o4(e)}],...k_(t)])}function w_(e,t={}){const{text:n,href:r}=e;return Ln([n!==void 0?[{id:"copy-text",label:"copy text",onClick:()=>Jt(n)}]:r?[{id:"copy-text",label:"copy text",onClick:()=>r4(r)}]:[],...k_(t)])}function Mz(e){return[aS(e),{id:"copy-link",label:"copy link",onClick:()=>Jt(e)}]}function y_(e,t,n){if(!t)return null;if(e.kind==="outside")return()=>qm(n,t,e);if(e.kind==="path")return()=>qm(n,t,{href:e.path,path:e.path});if(e.kind!=="file")return null;const r=e.file;return r.folder?()=>u4(n,{worktreeId:t,path:r.path}):()=>tr(n,{worktreeId:t,path:r.path,...r.line?{line:{n:r.line}}:{}})}function Pz(e,t,n){const r=y_(e,t,n),{sock:o}=n,i=e.kind==="file"?t?()=>o==null?void 0:o.send({t:"reveal",worktreeId:t,path:e.file.path}):void 0:()=>o==null?void 0:o.send({t:"reveal-path",path:e.path}),l=e.kind==="file"?e.file.path:e.path;return[[...r?[{id:"open",label:"open",onClick:r}]:[],...ds(i,Is(o))],[{id:"copy-path",label:"copy path",onClick:()=>Jt(l)}]]}function Gm(e){return e?[{id:"copy-code",label:"copy code",onClick:()=>Jt(e)}]:[]}function Bi(e,t,n,r={}){const{dispatch:o,sock:i}=n,l=r.link,c=l?l.kind==="out"?[Mz(l.href)]:Pz(l,t,n):[],u=[{id:"copy",label:"copy message",onClick:()=>Jt(e.text)}],h=[];return e.kind==="user"&&t&&h.push({id:"draft",label:"edit in composer",onClick:()=>{const p=e.seq;if(p===void 0||!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:p})}}),Ln([Gm(r.code),...c,u,h])}function v_(e,t,n){return[ds(t,n),[{id:"copy-path",label:"copy path",onClick:()=>Jt(e)}]]}function b_(e,t,n){return Ln(v_(e,t,n))}function Lz(e,t){const n=e.callFile??e.file,r=n?v_(n,void 0,t.host):[],o=t.remove?[{id:"remove",label:"remove",onClick:t.remove}]:[];return Ln([...r,o])}const $b=8,Dz=.7,zz=100,Fz=400,Bz=260,Uz=80,Hz=220;function Ob({dx:e,dy:t}){return Math.abs(e)<$b&&Math.abs(t)<$b?null:Math.abs(t)>Math.abs(e)?"away":"other"}function Wz(e,t){const n=e.filter(i=>t-i.t<=zz),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 Kz=e=>Math.abs(e)>=Dz;function Zz(e,t){return Math.min(Hz,Math.max(Uz,e/Math.abs(t)))}function qz(e,t,n){const r=_.useRef(n);r.current=n,_.useEffect(()=>{const o=e.current;if(!o)return;let i=null,l=!1,c=[],u=0;const h=(b,S,j)=>{j!==void 0&&o.style.setProperty("--swipe-ms",`${j}ms`),o.dataset.swipe!==S&&(o.dataset.swipe=S,o.offsetWidth),o.style.setProperty("--swipe-y",`${b}px`),o.style.setProperty("--swipe-fade",`${Math.min(1,Math.abs(b)/(window.innerHeight/2))}`)},p=()=>{o.style.removeProperty("--swipe-y"),o.style.removeProperty("--swipe-fade"),o.style.removeProperty("--swipe-ms"),delete o.dataset.swipe},m=()=>{const b=l;i=null,l=!1,c=[],b&&(h(0,"settle"),u=window.setTimeout(p,Bz))},k=b=>{var E;const S=b.touches[0],j=b.target;if(b.touches.length!==1||!S||(((E=window.visualViewport)==null?void 0:E.scale)??1)>1.01)return m();o.dataset.swipe==="leave"||!(j===o||j!=null&&j.closest(t))||(window.clearTimeout(u),i={x:S.clientX,y:S.clientY,at:b.timeStamp},c=[{y:S.clientY,t:b.timeStamp}])},g=b=>{const S=b.touches[0];if(!i||!S)return;const j=S.clientX-i.x,E=S.clientY-i.y;if(!l){const N=Ob({dx:j,dy:E});if(N==="other"&&(i=null),N!=="away")return;l=!0}b.preventDefault(),c.push({y:S.clientY,t:b.timeStamp}),c.length>16&&c.shift(),h(E,"drag")},y=b=>{const S=b.changedTouches[0];if(!i||!S)return;const j=S.clientY-i.y,E=b.timeStamp-i.at;if(!l&&E<Fz&&b.target!==o&&Ob({dx:S.clientX-i.x,dy:j})===null){b.preventDefault(),i=null,r.current();return}const A=Wz(c,b.timeStamp);if(!l||!Kz(A))return m();i=null,l=!1,c=[];const O=Math.sign(A)*window.innerHeight,P=Zz(Math.abs(O-j),A);h(O,"leave",P),u=window.setTimeout(()=>r.current(),P)};return o.addEventListener("touchstart",k,{passive:!0}),o.addEventListener("touchmove",g,{passive:!1}),o.addEventListener("touchend",y),o.addEventListener("touchcancel",m),()=>{window.clearTimeout(u),o.removeEventListener("touchstart",k),o.removeEventListener("touchmove",g),o.removeEventListener("touchend",y),o.removeEventListener("touchcancel",m)}},[e,t])}function Lk({owner:e,onClose:t,menu:n,children:r}){const o=bn(e),i=_.useRef(null);return qz(i,"img",t),d.jsxs($s,{className:"attach-full scrim",boxRef:i,onDismiss:t,onKey:l=>{l.key==="Escape"&&(l.stopPropagation(),t())},onClick:l=>{l.target===l.currentTarget&&t()},...n&&o.contextMenu(n),children:[r,d.jsx(Rt,{icon:"close",label:"Close",tone:"quiet",onClick:t})]})}function Gz({item:e}){if(!e.outcome)return null;const t=kP[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 Dk(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 x_=e=>e.slice(0,Math.max(0,e.lastIndexOf("/")));function E_(e,t){let n;try{n=decodeURIComponent(t)}catch{return null}const r=n.match(/#L(\d+)(?:-L?\d+)?$/i);r?n=n.slice(0,r.index):n=n.split(/[?#]/)[0]??"";const o=n.match(/:(\d+)(?::\d+)?$/);o&&(n=n.slice(0,o.index));const i=e.replace(/\/+$/,"");if(!i||!n.startsWith(`${i}/`))return null;const l=n.endsWith("/"),c=n.slice(i.length+1).replace(/\/+$/,"");if(!c||c.split("/").some(p=>p===".."))return null;if(l)return{path:c,folder:!0};const u=(r==null?void 0:r[1])??(o==null?void 0:o[1]),h=u?Number.parseInt(u,10):void 0;return h&&h>0?{path:c,line:h}:{path:c}}function S_(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 Vz(e){return e.length<2||!e.startsWith("/")||e.startsWith("//")||/\s/.test(e)?null:e}function zk(e,t){const n=e.closest("a, code[data-path]");if(!n)return null;const r=n.getAttribute("data-path");if(r)return{kind:"path",path:r};const o=n.getAttribute("href");if(!o)return null;const i=t?E_(t,o):null;if(i)return{kind:"file",file:i};const l=S_(o);return l?{kind:"outside",href:o,...l}:{kind:"out",href:o}}function Fk(e,t,n,r){const o=zk(e.target,t),i=o&&o.kind!=="path"?y_(o,n,r):null;i&&(e.preventDefault(),i())}const Yz=150,Xz=e=>({side:e,align:"center",offset:12,flip:"side",margin:8});function __({chip:e,className:t,children:n}){const[r,o]=_.useState(!1),i=L(c=>c.chatSide);_.useEffect(()=>{const c=e.current;if(!c)return;let u=0;const h=()=>{window.clearTimeout(u),o(!1)},p=()=>{window.clearTimeout(u),u=window.setTimeout(()=>o(!0),Yz)};return c.addEventListener("mouseenter",p),c.addEventListener("mouseleave",h),c.addEventListener("mousedown",h),()=>{window.clearTimeout(u),c.removeEventListener("mouseenter",p),c.removeEventListener("mouseleave",h),c.removeEventListener("mousedown",h)}},[e]);const l=()=>{var p;const c=e.current;if(!c)return null;const u=c.getBoundingClientRect(),h=((p=c.closest(".chat-log"))==null?void 0:p.getBoundingClientRect())??u;return{left:h.left,right:h.right,top:u.top,bottom:u.bottom}};return r?d.jsx($s,{className:Ke("chip-peek",t),anchor:l,placement:Xz(i==="left"?"right":"left"),track:!0,children:n}):null}function Bk({className:e,label:t,tip:n,peek:r,full:o,menu:i,removeLabel:l,onRemove:c}){const u=_.useRef(null),[h,p]=_.useState(!1),m=bn("chat"),k=o!==void 0;return d.jsxs("div",{ref:u,className:Ke("pick-chip row row-sm",e),"data-tip":k?"Open full size":n,"data-tip-placement":"follow",...m.contextMenu(()=>i({open:k?()=>p(!0):void 0,remove:c})),children:[k?d.jsx("button",{type:"button",className:"chip-link",onClick:()=>p(!0),children:t}):t,c&&d.jsx(Rt,{icon:"close",label:l,tone:"quiet",onClick:c}),k&&r!==void 0&&d.jsx(__,{chip:u,children:r}),h&&k&&d.jsx(Lk,{owner:"chat",onClose:()=>p(!1),menu:()=>i(),children:o})]})}/*! @license DOMPurify 3.4.14 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.4.14/LICENSE */function Mb(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 Qz(e){if(Array.isArray(e))return e}function Jz(e,t){var n=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var r,o,i,l,c=[],u=!0,h=!1;try{if(i=(n=n.call(e)).next,t!==0)for(;!(u=(r=i.call(n)).done)&&(c.push(r.value),c.length!==t);u=!0);}catch(p){h=!0,o=p}finally{try{if(!u&&n.return!=null&&(l=n.return(),Object(l)!==l))return}finally{if(h)throw o}}return c}}function e3(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
128
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function t3(e,t){return Qz(e)||Jz(e,t)||n3(e,t)||e3()}function n3(e,t){if(e){if(typeof e=="string")return Mb(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)?Mb(e,t):void 0}}const N_=Object.entries,Pb=Object.setPrototypeOf,r3=Object.isFrozen,o3=Object.getPrototypeOf,s3=Object.getOwnPropertyDescriptor;let hr=Object.freeze,br=Object.seal,za=Object.create,T_=typeof Reflect<"u"&&Reflect,Vm=T_.apply,Ym=T_.construct;hr||(hr=function(t){return t});br||(br=function(t){return t});Vm||(Vm=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)});Ym||(Ym=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 Wi=ar(Array.prototype.forEach),i3=ar(Array.prototype.lastIndexOf),Lb=ar(Array.prototype.pop),ac=ar(Array.prototype.push),a3=ar(Array.prototype.splice),Qa=Array.isArray,mc=ar(String.prototype.toLowerCase),Wp=ar(String.prototype.toString),Db=ar(String.prototype.match),lc=ar(String.prototype.replace),zb=ar(String.prototype.indexOf),l3=ar(String.prototype.trim),c3=ar(Number.prototype.toString),u3=ar(Boolean.prototype.toString),Fb=typeof BigInt>"u"?null:ar(BigInt.prototype.toString),Bb=typeof Symbol>"u"?null:ar(Symbol.prototype.toString),no=ar(Object.prototype.hasOwnProperty),cc=ar(Object.prototype.toString),$r=ar(RegExp.prototype.test),Ui=d3(TypeError);function ar(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 Vm(e,t,r)}}function d3(e){return function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return Ym(e,n)}}function hn(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:mc;if(Pb&&Pb(e,null),!Qa(t))return e;let r=t.length;for(;r--;){let o=t[r];if(typeof o=="string"){const i=n(o);i!==o&&(r3(t)||(t[r]=i),o=i)}e[o]=!0}return e}function f3(e){for(let t=0;t<e.length;t++)no(e,t)||(e[t]=null);return e}function mo(e){const t=za(null);for(const r of N_(e)){var n=t3(r,2);const o=n[0],i=n[1];no(e,o)&&(Qa(i)?t[o]=f3(i):i&&typeof i=="object"&&i.constructor===Object?t[o]=mo(i):t[o]=i)}return t}function h3(e){switch(typeof e){case"string":return e;case"number":return c3(e);case"boolean":return u3(e);case"bigint":return Fb?Fb(e):"0";case"symbol":return Bb?Bb(e):"Symbol()";case"undefined":return cc(e);case"function":case"object":{if(e===null)return cc(e);const t=e,n=Bo(t,"toString");if(typeof n=="function"){const r=n(t);return typeof r=="string"?r:cc(r)}return cc(e)}default:return cc(e)}}function Bo(e,t){for(;e!==null;){const r=s3(e,t);if(r){if(r.get)return ar(r.get);if(typeof r.value=="function")return ar(r.value)}e=o3(e)}function n(){return null}return n}function p3(e){try{return $r(e,""),!0}catch{return!1}}const Ub=hr(["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"]),Kp=hr(["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"]),Zp=hr(["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"]),m3=hr(["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"]),qp=hr(["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"]),g3=hr(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),Hb=hr(["#text"]),Wb=hr(["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"]),Gp=hr(["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"]),Kb=hr(["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"]),Sd=hr(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),k3=br(/{{[\w\W]*|^[\w\W]*}}/g),w3=br(/<%[\w\W]*|^[\w\W]*%>/g),y3=br(/\${[\w\W]*/g),v3=br(/^data-[\-\w.\u00B7-\uFFFF]+$/),b3=br(/^aria-[\-\w]+$/),Zb=br(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),x3=br(/^(?:\w+script|data):/i),E3=br(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),S3=br(/^html$/i),_3=br(/^[a-z][.\w]*(-[.\w]+)+$/i),qb=br(/<[/\w!]/g),Gb=br(/<[/\w]/g),N3=br(/<\/no(script|embed|frames)/i),T3=br(/\/>/i),po={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},j_=["style","script","xmp","iframe","noembed","noframes","plaintext","noscript"],j3=hr(hn({},j_)),C3=(function(){const e={};return Wi(j_,t=>{e[t]=br(new RegExp("</"+t+"(?=[\\t\\n\\f\\r />])","i"))}),hr(e)})(),A3=function(){return typeof window>"u"?null:window},I3=function(t,n){if(typeof t!="object"||typeof t.createPolicy!="function")return null;let r=null;const o="data-tt-policy-suffix";n&&n.hasAttribute(o)&&(r=n.getAttribute(o));const i="dompurify"+(r?"#"+r:"");try{return t.createPolicy(i,{createHTML(l){return l},createScriptURL(l){return l}})}catch{return console.warn("TrustedTypes policy "+i+" could not be created."),null}},Vb=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},ei=function(t,n,r,o){return no(t,n)&&Qa(t[n])?hn(o.base?mo(o.base):{},t[n],o.transform):r},Vp=function(t,n,r){const o=no(t,n)?t[n]:void 0;return o&&typeof o=="object"?mo(o):r()};function C_(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:A3();const t=Ae=>C_(Ae);if(t.version="3.4.14",t.removed=[],!e||!e.document||e.document.nodeType!==po.document||!e.Element)return t.isSupported=!1,t;let n=e.document;const r=n,o=r.currentScript;e.DocumentFragment;const i=e.HTMLTemplateElement,l=e.Node,c=e.Element,u=e.NodeFilter,h=e.NamedNodeMap;h===void 0&&(e.NamedNodeMap||e.MozNamedAttrMap),e.HTMLFormElement;const p=e.DOMParser,m=e.trustedTypes,k=c.prototype,g=Bo(k,"cloneNode"),y=Bo(k,"remove"),b=Bo(k,"nextSibling"),S=Bo(k,"childNodes"),j=Bo(k,"parentNode"),E=Bo(k,"shadowRoot"),N=Bo(k,"attributes"),A=l&&l.prototype?Bo(l.prototype,"nodeType"):null,O=l&&l.prototype?Bo(l.prototype,"nodeName"):null,P=l&&l.prototype?Bo(l.prototype,"ownerDocument"):null,R=function(M){return A?A(M):M.nodeType},T=function(M){return O?O(M):M.nodeName};if(typeof i=="function"){const Ae=n.createElement("template");Ae.content&&Ae.content.ownerDocument&&(n=Ae.content.ownerDocument)}let $,D="",z,V=!1,se=0;const I=function(){if(se>0)throw Ui('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.')},ne=function(M){I(),se++;try{return $.createHTML(M)}finally{se--}},we=function(M){I(),se++;try{return $.createScriptURL(M)}finally{se--}},K=function(){return V||(z=I3(m,o),V=!0),z},B=n,ee=B.implementation,J=B.createNodeIterator,W=B.createDocumentFragment,ie=B.getElementsByTagName,Te=r.importNode;let Ce=Vb();t.isSupported=typeof N_=="function"&&typeof j=="function"&&ee&&ee.createHTMLDocument!==void 0;const de=k3,be=w3,le=y3,G=v3,ce=b3,oe=x3,re=E3,Le=_3;let Ue=Zb,_e=null;const je=hn({},[...Ub,...Kp,...Zp,...qp,...Hb]);let Ne=null;const qe=hn({},[...Wb,...Gp,...Kb,...Sd]);let Ft=Object.seal(za(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}})),qt=null,jt=null;const Ht=Object.seal(za(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let sn=!0,Ct=!0,He=!1,Ze=!0,At=!1,_t=!0,kt=!1,Fn=!1,un=null,xn=null,$t=!1,Tn=!1,Y=!1,pe=!1,nt=!0,dt=!1;const Bt="user-content-";let Ot=!0,Ee=!1,$e={},Wt=null;const ft=hn({},["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 Z=null;const ge=hn({},["audio","video","img","source","image","track"]);let Oe=null;const st=hn({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Et="http://www.w3.org/1998/Math/MathML",Mt="http://www.w3.org/2000/svg",ze="http://www.w3.org/1999/xhtml";let Se=ze,Ge=!1,Kt=null;const Qe=hn({},[Et,Mt,ze],Wp),mn=hr(["mi","mo","mn","ms","mtext"]);let Yt=hn({},mn);const En=hr(["annotation-xml"]);let qn=hn({},En);const an=hn({},["title","style","font","a","script"]);let wn=null;const mr=["application/xhtml+xml","text/html"],Mn="text/html";let tn=null,Gn=null;const nn=n.createElement("form"),Q=function(M){return M instanceof RegExp||M instanceof Function},ke=function(){let M=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(Gn&&Gn===M)return;(!M||typeof M!="object")&&(M={}),M=mo(M),wn=mr.indexOf(M.PARSER_MEDIA_TYPE)===-1?Mn:M.PARSER_MEDIA_TYPE,tn=wn==="application/xhtml+xml"?Wp:mc,_e=ei(M,"ALLOWED_TAGS",je,{transform:tn}),Ne=ei(M,"ALLOWED_ATTR",qe,{transform:tn}),Kt=ei(M,"ALLOWED_NAMESPACES",Qe,{transform:Wp}),Oe=ei(M,"ADD_URI_SAFE_ATTR",st,{transform:tn,base:st}),Z=ei(M,"ADD_DATA_URI_TAGS",ge,{transform:tn,base:ge}),Wt=ei(M,"FORBID_CONTENTS",ft,{transform:tn}),qt=ei(M,"FORBID_TAGS",mo({}),{transform:tn}),jt=ei(M,"FORBID_ATTR",mo({}),{transform:tn}),$e=no(M,"USE_PROFILES")?M.USE_PROFILES&&typeof M.USE_PROFILES=="object"?mo(M.USE_PROFILES):M.USE_PROFILES:!1,sn=M.ALLOW_ARIA_ATTR!==!1,Ct=M.ALLOW_DATA_ATTR!==!1,He=M.ALLOW_UNKNOWN_PROTOCOLS||!1,Ze=M.ALLOW_SELF_CLOSE_IN_ATTR!==!1,At=M.SAFE_FOR_TEMPLATES||!1,_t=M.SAFE_FOR_XML!==!1,kt=M.WHOLE_DOCUMENT||!1,Tn=M.RETURN_DOM||!1,Y=M.RETURN_DOM_FRAGMENT||!1,pe=M.RETURN_TRUSTED_TYPE||!1,$t=M.FORCE_BODY||!1,nt=M.SANITIZE_DOM!==!1,dt=M.SANITIZE_NAMED_PROPS||!1,Ot=M.KEEP_CONTENT!==!1,Ee=M.IN_PLACE||!1,Ue=p3(M.ALLOWED_URI_REGEXP)?M.ALLOWED_URI_REGEXP:Zb,Se=typeof M.NAMESPACE=="string"?M.NAMESPACE:ze,Yt=Vp(M,"MATHML_TEXT_INTEGRATION_POINTS",()=>hn({},mn)),qn=Vp(M,"HTML_INTEGRATION_POINTS",()=>hn({},En));const F=Vp(M,"CUSTOM_ELEMENT_HANDLING",()=>za(null));if(Ft=za(null),no(F,"tagNameCheck")&&Q(F.tagNameCheck)&&(Ft.tagNameCheck=F.tagNameCheck),no(F,"attributeNameCheck")&&Q(F.attributeNameCheck)&&(Ft.attributeNameCheck=F.attributeNameCheck),no(F,"allowCustomizedBuiltInElements")&&typeof F.allowCustomizedBuiltInElements=="boolean"&&(Ft.allowCustomizedBuiltInElements=F.allowCustomizedBuiltInElements),br(Ft),At&&(Ct=!1),Y&&(Tn=!0),$e&&(_e=hn({},Hb),Ne=za(null),$e.html===!0&&(hn(_e,Ub),hn(Ne,Wb)),$e.svg===!0&&(hn(_e,Kp),hn(Ne,Gp),hn(Ne,Sd)),$e.svgFilters===!0&&(hn(_e,Zp),hn(Ne,Gp),hn(Ne,Sd)),$e.mathMl===!0&&(hn(_e,qp),hn(Ne,Kb),hn(Ne,Sd))),Ht.tagCheck=null,Ht.attributeCheck=null,no(M,"ADD_TAGS")&&(typeof M.ADD_TAGS=="function"?Ht.tagCheck=M.ADD_TAGS:Qa(M.ADD_TAGS)&&(_e===je&&(_e=mo(_e)),hn(_e,M.ADD_TAGS,tn))),no(M,"ADD_ATTR")&&(typeof M.ADD_ATTR=="function"?Ht.attributeCheck=M.ADD_ATTR:Qa(M.ADD_ATTR)&&(Ne===qe&&(Ne=mo(Ne)),hn(Ne,M.ADD_ATTR,tn))),no(M,"ADD_FORBID_CONTENTS")&&Qa(M.ADD_FORBID_CONTENTS)&&(Wt===ft&&(Wt=mo(Wt)),hn(Wt,M.ADD_FORBID_CONTENTS,tn)),Ot&&(_e["#text"]=!0),kt&&hn(_e,["html","head","body"]),_e.table&&(hn(_e,["tbody"]),delete qt.tbody),M.TRUSTED_TYPES_POLICY){if(typeof M.TRUSTED_TYPES_POLICY.createHTML!="function")throw Ui('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof M.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw Ui('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');const ae=$;$=M.TRUSTED_TYPES_POLICY;try{D=ne("")}catch(ye){throw $=ae,ye}}else M.TRUSTED_TYPES_POLICY===null?($=void 0,D=""):($===void 0&&($=K()),$&&typeof D=="string"&&(D=ne("")));hr&&hr(M),Gn=M},tt=hn({},[...Kp,...Zp,...m3]),at=hn({},[...qp,...g3]),dn=function(M,F,ae){return F.namespaceURI===ze?M==="svg":F.namespaceURI===Et?M==="svg"&&(ae==="annotation-xml"||Yt[ae]):!!tt[M]},Gt=function(M,F,ae){return F.namespaceURI===ze?M==="math":F.namespaceURI===Mt?M==="math"&&qn[ae]:!!at[M]},Tr=function(M,F,ae){return F.namespaceURI===Mt&&!qn[ae]||F.namespaceURI===Et&&!Yt[ae]?!1:!at[M]&&(an[M]||!tt[M])},Vn=function(M){let F=j(M);(!F||!F.tagName)&&(F={namespaceURI:Se,tagName:"template"});const ae=mc(M.tagName),ye=mc(F.tagName);return Kt[M.namespaceURI]?M.namespaceURI===Mt?dn(ae,F,ye):M.namespaceURI===Et?Gt(ae,F,ye):M.namespaceURI===ze?Tr(ae,F,ye):!!(wn==="application/xhtml+xml"&&Kt[M.namespaceURI]):!1},Cn=function(M){ac(t.removed,{element:M});try{j(M).removeChild(M)}catch{if(y(M),!j(M))throw Ui("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},rn=function(M,F,ae){try{M.removeAttributeNode(F)}catch{try{M.removeAttribute(ae)}catch{}}},ve=function(M){mt(M);const F=S(M);if(F){const ye=[];Wi(F,Me=>{ac(ye,Me)}),Wi(ye,Me=>{try{y(Me)}catch{}})}const ae=N(M);if(ae)for(let ye=ae.length-1;ye>=0;--ye){const Me=ae[ye],Ye=Me&&Me.name;typeof Ye=="string"&&rn(M,Me,Ye)}},Ve=function(M,F,ae){if(!ae)try{ae=F.getAttributeNode(M)}catch{ae=null}ac(t.removed,{attribute:ae||null,from:F});try{ae?F.removeAttributeNode(ae):F.removeAttribute(M)}catch{try{F.removeAttribute(M)}catch{}}if(M==="is")if(Tn||Y)try{Cn(F)}catch{}else try{F.setAttribute(M,"")}catch{}},We=function(M){const F=N(M);if(F)for(let ae=F.length-1;ae>=0;--ae){const ye=F[ae],Me=ye&&ye.name;typeof Me!="string"||Ne[tn(Me)]||rn(M,ye,Me)}},mt=function(M){const F=[M];for(;F.length>0;){const ae=F.pop();R(ae)===po.element&&We(ae);const Me=S(ae);if(Me)for(let Ye=Me.length-1;Ye>=0;--Ye)F.push(Me[Ye])}},ln=function(M,F){return _t?M==="patchsrc"?!0:M==="for"&&F!=="label"&&F!=="output":!1},yn=function(M){if(!_t)return;const F=[M];for(;F.length>0;){const ae=F.pop(),ye=R(ae);if(ye===po.processingInstruction||ye===po.comment&&$r(Gb,ae.data)){try{y(ae)}catch{}continue}if(ye===po.element){const Ye=ae,yt=tn(T(ae));try{Ye.hasAttribute&&Ye.hasAttribute("patchsrc")&&Ye.removeAttribute("patchsrc"),Ye.hasAttribute&&Ye.hasAttribute("for")&&ln("for",yt)&&Ye.removeAttribute("for")}catch{}}const Me=S(ae);if(Me)for(let Ye=Me.length-1;Ye>=0;--Ye)F.push(Me[Ye])}},H=function(M){let F=null,ae=null;if($t)M="<remove></remove>"+M;else{const Ye=Db(M,/^[\r\n\t ]+/);ae=Ye&&Ye[0]}wn==="application/xhtml+xml"&&Se===ze&&(M='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+M+"</body></html>");const ye=$?ne(M):M;if(Se===ze)try{F=new p().parseFromString(ye,wn)}catch{}if(!F||!F.documentElement){F=ee.createDocument(Se,"template",null);try{F.documentElement.innerHTML=Ge?D:ye}catch{}}const Me=F.body||F.documentElement;return M&&ae&&Me.insertBefore(n.createTextNode(ae),Me.childNodes[0]||null),Se===ze?ie.call(F,kt?"html":"body")[0]:kt?F.documentElement:Me},me=function(M){const F=P?P(M):M.ownerDocument;return J.call(F||M,M,u.SHOW_ELEMENT|u.SHOW_COMMENT|u.SHOW_TEXT|u.SHOW_PROCESSING_INSTRUCTION|u.SHOW_CDATA_SECTION,null)},Be=function(M){return M=lc(M,de," "),M=lc(M,be," "),M=lc(M,le," "),M},lt=function(M){var F;M.normalize();const ae=P?P(M):M.ownerDocument,ye=J.call(ae||M,M,u.SHOW_TEXT|u.SHOW_COMMENT|u.SHOW_CDATA_SECTION|u.SHOW_PROCESSING_INSTRUCTION,null);let Me=ye.nextNode();for(;Me;)Me.data=Be(Me.data),Me=ye.nextNode();const Ye=(F=M.querySelectorAll)===null||F===void 0?void 0:F.call(M,"template");Ye&&Wi(Ye,yt=>{Xt(yt.content)&<(yt.content)})},Nt=function(M){const F=O?O(M):null;return typeof F!="string"||tn(F)!=="form"?!1:typeof M.nodeName!="string"||typeof M.textContent!="string"||typeof M.removeChild!="function"||M.attributes!==N(M)||typeof M.removeAttribute!="function"||typeof M.setAttribute!="function"||typeof M.namespaceURI!="string"||typeof M.insertBefore!="function"||typeof M.hasChildNodes!="function"||M.nodeType!==A(M)||M.childNodes!==S(M)},Xt=function(M){if(!A||typeof M!="object"||M===null)return!1;try{return A(M)===po.documentFragment}catch{return!1}},Bn=function(M){if(!A||typeof M!="object"||M===null)return!1;try{return typeof A(M)=="number"}catch{return!1}};function Yn(Ae,M,F){Ae.length!==0&&Wi(Ae,ae=>{ae.call(t,M,F,Gn)})}const Dr=function(M,F){return!!(_t&&M.hasChildNodes()&&!Bn(M.firstElementChild)&&$r(qb,M.textContent)&&$r(qb,M.innerHTML)||_t&&M.namespaceURI===ze&&j3[F]&&(Bn(M.firstElementChild)||typeof M.textContent=="string"&&$r(C3[F],M.textContent))||M.nodeType===po.processingInstruction||_t&&M.nodeType===po.comment&&$r(Gb,M.data))},zr=function(M,F){if(M instanceof RegExp)return $r(M,F);if(M instanceof Function){for(var ae=arguments.length,ye=new Array(ae>2?ae-2:0),Me=2;Me<ae;Me++)ye[Me-2]=arguments[Me];return!!M(F,...ye)}return!1},Ro=function(M,F,ae){if(!qt[F]&&wt(F)&&zr(Ft.tagNameCheck,F))return!1;if(Ot&&!Wt[F]){const ye=j(M),Me=S(M);if(Me&&ye){const Ye=Me.length;for(let yt=Ye-1;yt>=0;--yt){const gn=M===ae?g(Me[yt],!0):Me[yt];ye.insertBefore(gn,b(M))}}}return Cn(M),!0},xr=function(M,F,ae,ye){return M.length===0?F:F===ae||F===ye?mo(F):F},Zr=function(M,F){return M===F||j(M)!==null?!1:(Ee&&mt(M),!0)},Er=function(M,F){if(Yn(Ce.beforeSanitizeElements,M,null),Zr(M,F))return!0;if(Nt(M))return Cn(M),!0;const ae=tn(T(M));if(_e=xr(Ce.uponSanitizeElement,_e,je,un),Yn(Ce.uponSanitizeElement,M,{tagName:ae,allowedTags:_e}),Zr(M,F))return!0;if(Dr(M,ae))return Cn(M),!0;if(qt[ae]||!(Ht.tagCheck instanceof Function&&Ht.tagCheck(ae))&&!_e[ae]){const Me=Ro(M,ae,F);return Me===!1&&Yn(Ce.afterSanitizeElements,M,null),Me}if(R(M)===po.element&&!Vn(M)||(ae==="noscript"||ae==="noembed"||ae==="noframes")&&$r(N3,M.innerHTML))return Cn(M),!0;if(At&&M.nodeType===po.text){const Me=Be(M.textContent);M.textContent!==Me&&(ac(t.removed,{element:M.cloneNode()}),M.textContent=Me)}return Yn(Ce.afterSanitizeElements,M,null),!1},qr=function(M,F,ae){if(jt[F]||ln(F,M)||nt&&(F==="id"||F==="name")&&(ae in n||ae in nn))return!1;const ye=Ne[F]||Ht.attributeCheck instanceof Function&&Ht.attributeCheck(F,M);return Ct&&$r(G,F)||sn&&$r(ce,F)?!0:ye?Oe[F]||$r(Ue,lc(ae,re,""))||(F==="src"||F==="xlink:href"||F==="href")&&M!=="script"&&zb(ae,"data:")===0&&Z[M]||He&&!$r(oe,lc(ae,re,""))?!0:!ae:wt(M)&&zr(Ft.tagNameCheck,M)&&zr(Ft.attributeNameCheck,F,M)||F==="is"&&Ft.allowCustomizedBuiltInElements&&zr(Ft.tagNameCheck,ae)},Qt=hn({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),wt=function(M){return!Qt[mc(M)]&&$r(Le,M)},$o=function(M,F,ae,ye){if($&&typeof m=="object"&&typeof m.getAttributeType=="function"&&!ae)switch(m.getAttributeType(M,F)){case"TrustedHTML":return ne(ye);case"TrustedScriptURL":return we(ye)}return ye},An=function(M,F,ae,ye){try{ae?M.setAttributeNS(ae,F,ye):M.setAttribute(F,ye),Nt(M)?Cn(M):Lb(t.removed)}catch{Ve(F,M)}},on=function(M){Yn(Ce.beforeSanitizeAttributes,M,null);const F=M.attributes;if(!F||Nt(M))return;Ne=xr(Ce.uponSanitizeAttribute,Ne,qe,xn);const ae={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:Ne,forceKeepAttr:void 0};let ye=F.length;const Me=tn(M.nodeName);for(;ye--;){const Ye=F[ye],yt=Ye.name,gn=Ye.namespaceURI,Xn=Ye.value,In=tn(yt),Yo=Xn;let Jn=yt==="value"?Yo:l3(Yo);if(ae.attrName=In,ae.attrValue=Jn,ae.keepAttr=!0,ae.forceKeepAttr=void 0,Yn(Ce.uponSanitizeAttribute,M,ae),Jn=ae.attrValue,dt&&(In==="id"||In==="name")&&zb(Jn,Bt)!==0&&(Ve(yt,M,Ye),Jn=Bt+Jn),_t&&$r(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,Jn)){Ve(yt,M,Ye);continue}if(In==="attributename"&&Db(Jn,"href")){Ve(yt,M,Ye);continue}if(!ae.forceKeepAttr){if(!ae.keepAttr){Ve(yt,M,Ye);continue}if(!Ze&&$r(T3,Jn)){Ve(yt,M,Ye);continue}if(At&&(Jn=Be(Jn)),!qr(Me,In,Jn)){Ve(yt,M,Ye);continue}Jn=$o(Me,In,gn,Jn),Jn!==Yo&&An(M,yt,gn,Jn)}}Yn(Ce.afterSanitizeAttributes,M,null)},Dt=function(M){let F=null;const ae=me(M);for(Yn(Ce.beforeSanitizeShadowDOM,M,null);F=ae.nextNode();)if(Yn(Ce.uponSanitizeShadowNode,F,null),Er(F,M),on(F),Xt(F.content)&&Dt(F.content),R(F)===po.element){const ye=E(F);Xt(ye)&&(nr(ye),Dt(ye))}Yn(Ce.afterSanitizeShadowDOM,M,null)},nr=function(M){const F=[{node:M,shadow:null}];for(;F.length>0;){const ae=F.pop();if(ae.shadow){Dt(ae.shadow);continue}const ye=ae.node,Ye=R(ye)===po.element,yt=S(ye);if(yt)for(let gn=yt.length-1;gn>=0;--gn)F.push({node:yt[gn],shadow:null});if(Ye){const gn=O?O(ye):null;if(typeof gn=="string"&&tn(gn)==="template"){const Xn=ye.content;Xt(Xn)&&F.push({node:Xn,shadow:null})}}if(Ye){const gn=E(ye);Xt(gn)&&F.push({node:null,shadow:gn},{node:gn,shadow:null})}}};return t.sanitize=function(Ae){let M=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},F=null,ae=null,ye=null,Me=null;if(Ge=!Ae,Ge&&(Ae="<!-->"),typeof Ae!="string"&&!Bn(Ae)&&(Ae=h3(Ae),typeof Ae!="string"))throw Ui("dirty is not a string, aborting");if(!t.isSupported)return Ae;Fn?(_e=un,Ne=xn):ke(M),(Ce.uponSanitizeElement.length>0||Ce.uponSanitizeAttribute.length>0)&&(_e=mo(_e)),Ce.uponSanitizeAttribute.length>0&&(Ne=mo(Ne)),t.removed=[];const Ye=Ee&&typeof Ae!="string"&&Bn(Ae);if(Ye){yn(Ae);const Xn=T(Ae);if(typeof Xn=="string"){const In=tn(Xn);if(!_e[In]||qt[In])throw ve(Ae),Ui("root node is forbidden and cannot be sanitized in-place")}if(Nt(Ae))throw ve(Ae),Ui("root node is clobbered and cannot be sanitized in-place");try{nr(Ae)}catch(In){throw ve(Ae),In}}else if(Bn(Ae))F=H("<!---->"),ae=F.ownerDocument.importNode(Ae,!0),ae.nodeType===po.element&&ae.nodeName==="BODY"||ae.nodeName==="HTML"?F=ae:F.appendChild(ae),nr(ae);else{if(!Tn&&!At&&!kt&&Ae.indexOf("<")===-1)return $&&pe?ne(Ae):Ae;if(F=H(Ae),!F)return Tn?null:pe?D:""}F&&$t&&Cn(F.firstChild);const yt=Ye?Ae:F;try{const Xn=me(yt);for(;ye=Xn.nextNode();)Er(ye,yt),on(ye),Xt(ye.content)&&Dt(ye.content)}catch(Xn){throw Ye&&(ve(Ae),Wi(t.removed,In=>{In.element&&mt(In.element)})),Xn}if(Ye)return Wi(t.removed,Xn=>{Xn.element&&mt(Xn.element)}),At&<(Ae),Ae;if(Tn){if(At&<(F),Y)for(Me=W.call(F.ownerDocument);F.firstChild;)Me.appendChild(F.firstChild);else Me=F;return(Ne.shadowroot||Ne.shadowrootmode)&&(Me=Te.call(r,Me,!0)),Me}let gn=kt?F.outerHTML:F.innerHTML;return kt&&_e["!doctype"]&&F.ownerDocument&&F.ownerDocument.doctype&&F.ownerDocument.doctype.name&&$r(S3,F.ownerDocument.doctype.name)&&(gn="<!DOCTYPE "+F.ownerDocument.doctype.name+`>
|
|
129
|
+
`+gn),At&&(gn=Be(gn)),$&&pe?ne(gn):gn},t.setConfig=function(){let Ae=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};ke(Ae),Fn=!0,un=_e,xn=Ne},t.clearConfig=function(){Gn=null,Fn=!1,un=null,xn=null,$=z,D=""},t.isValidAttribute=function(Ae,M,F){Gn||ke({});const ae=tn(Ae),ye=tn(M);return qr(ae,ye,F)},t.addHook=function(Ae,M){typeof M=="function"&&no(Ce,Ae)&&ac(Ce[Ae],M)},t.removeHook=function(Ae,M){if(no(Ce,Ae)){if(M!==void 0){const F=i3(Ce[Ae],M);return F===-1?void 0:a3(Ce[Ae],F,1)[0]}return Lb(Ce[Ae])}},t.removeHooks=function(Ae){no(Ce,Ae)&&(Ce[Ae]=[])},t.removeAllHooks=function(){Ce=Vb()},t}var R3=C_();function Uk(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var aa=Uk();function A_(e){aa=e}var Zi={exec:()=>null};function Pa(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 en(e,t=""){let n=typeof e=="string"?e:e.source,r={replace:(o,i)=>{let l=typeof i=="string"?i:i.source;return l=l.replace(Mr.caret,"$1"),n=n.replace(o,l),r},getRegex:()=>new RegExp(n,t)};return r}var $3=((e="")=>{try{return!!new RegExp("(?<=1)(?<!1)"+e)}catch{return!1}})(),Mr={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:Pa(e=>new RegExp(`^ {0,${e}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`)),hrRegex:Pa(e=>new RegExp(`^ {0,${e}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`)),fencesBeginRegex:Pa(e=>new RegExp(`^ {0,${e}}(?:\`\`\`|~~~)`)),headingBeginRegex:Pa(e=>new RegExp(`^ {0,${e}}#`)),htmlBeginRegex:Pa(e=>new RegExp(`^ {0,${e}}<(?:[a-z].*>|!--)`,"i")),blockquoteBeginRegex:Pa(e=>new RegExp(`^ {0,${e}}>`))},O3=/^(?:[ \t]*(?:\n|$))+/,M3=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,P3=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,tu=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,L3=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,Hk=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,I_=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,R_=en(I_).replace(/bull/g,Hk).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(),D3=en(I_).replace(/bull/g,Hk).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(),Wk=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table|[ \t]+\n)[^\n]+)*)/,z3=/^[^\n]+/,Kk=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,F3=en(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Kk).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),B3=en(/^(bull)([ \t][^\n]*?)?(?:\n|$)/).replace(/bull/g,Hk).getRegex(),Yf="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",Zk=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,U3=en("^ {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",Zk).replace("tag",Yf).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),$_=e=>en(Wk).replace("hr",tu).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",Yf).getRegex(),H3=$_(/ {0,3}(?:[*+-]|1[.)])[ \t]+[^ \t\n]/),W3=$_(/ {0,3}(?:[*+-]|\d{1,9}[.)])(?:[ \t]|\n|$)/),K3=en(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",W3).getRegex(),qk={blockquote:K3,code:M3,def:F3,fences:P3,heading:L3,hr:tu,html:U3,lheading:R_,list:B3,newline:O3,paragraph:H3,table:Zi,text:z3},Yb=en("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",tu).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",Yf).getRegex(),Z3={...qk,lheading:D3,table:Yb,paragraph:en(Wk).replace("hr",tu).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",Yb).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",Yf).getRegex()},q3={...qk,html:en(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Zk).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:Zi,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:en(Wk).replace("hr",tu).replace("heading",` *#{1,6} *[^
|
|
130
|
+
]`).replace("lheading",R_).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},G3=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,V3=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,O_=/^( {2,}|\\)\n(?!\s*$)/,Y3=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,Os=/[\p{P}\p{S}]/u,ml=/[\s\p{P}\p{S}]/u,nu=/[^\s\p{P}\p{S}]/u,X3=en(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,ml).getRegex(),Q3=/[\p{Pi}\p{Ps}"']/u,M_=/(?!~)[\p{P}\p{S}]/u,J3=/(?!~)[\s\p{P}\p{S}]/u,e5=/(?:[^\s\p{P}\p{S}]|~)/u,t5=en(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",$3?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),P_=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,n5=en(P_,"u").replace(/punct/g,Os).getRegex(),r5=en(P_,"u").replace(/punct/g,M_).getRegex(),o5=/^(?:\*+(?:((?!\*)(?!openQuote)punct)|([^\s*]))?)|^_+(?:((?!_)(?!openQuote)punct)|([^\s_]))?/,s5=en(o5,"u").replace(/openQuote/g,Q3).replace(/punct/g,Os).getRegex(),L_="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",i5=en(L_,"gu").replace(/notPunctSpace/g,nu).replace(/punctSpace/g,ml).replace(/punct/g,Os).getRegex(),a5=en(L_,"gu").replace(/notPunctSpace/g,e5).replace(/punctSpace/g,J3).replace(/punct/g,M_).getRegex(),l5="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)[\\s](\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|(?:(?!\\*)punct|notPunctSpace)(\\*+)(?!\\*)(?=notPunctSpace)",c5=en(l5,"gu").replace(/notPunctSpace/g,nu).replace(/punctSpace/g,ml).replace(/punct/g,Os).getRegex(),u5=en("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,nu).replace(/punctSpace/g,ml).replace(/punct/g,Os).getRegex(),d5="^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)[\\s](_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)|(?:(?!_)punct|notPunctSpace)(_+)(?!_)(?=notPunctSpace)",f5=en(d5,"gu").replace(/notPunctSpace/g,nu).replace(/punctSpace/g,ml).replace(/punct/g,Os).getRegex(),h5=en(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,Os).getRegex(),p5="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",m5=en(p5,"gu").replace(/notPunctSpace/g,nu).replace(/punctSpace/g,ml).replace(/punct/g,Os).getRegex(),g5=en(/\\(punct)/,"gu").replace(/punct/g,Os).getRegex(),k5=en(/^<(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(),w5=en(Zk).replace("(?:-->|$)","-->").getRegex(),y5=en("^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",w5).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),of=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,v5=en(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",of).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]+|(?=\))/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),D_=en(/^!?\[(label)\]\[(ref)\]/).replace("label",of).replace("ref",Kk).getRegex(),z_=en(/^!?\[(ref)\](?:\[\])?/).replace("ref",Kk).getRegex(),b5=en("reflink|nolink(?!\\()","g").replace("reflink",D_).replace("nolink",z_).getRegex(),Xb=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,Gk={_backpedal:Zi,anyPunctuation:g5,autolink:k5,blockSkip:t5,br:O_,code:V3,del:Zi,delLDelim:Zi,delRDelim:Zi,emStrongLDelim:n5,emStrongRDelimAst:i5,emStrongRDelimUnd:u5,escape:G3,link:v5,nolink:z_,punctuation:X3,reflink:D_,reflinkSearch:b5,tag:y5,text:Y3,url:Zi},x5={...Gk,emStrongLDelim:s5,emStrongRDelimAst:c5,emStrongRDelimUnd:f5,link:en(/^!?\[(label)\]\((.*?)\)/).replace("label",of).getRegex(),reflink:en(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",of).getRegex()},Xm={...Gk,emStrongRDelimAst:a5,emStrongLDelim:r5,delLDelim:h5,delRDelim:m5,url:en(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",Xb).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:en(/^(`+|~+|[^`~])(?:(?=[`~])|(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",Xb).getRegex()},E5={...Xm,br:en(O_).replace("{2,}","*").getRegex(),text:en(Xm.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},_d={normal:qk,gfm:Z3,pedantic:q3},uc={normal:Gk,gfm:Xm,breaks:E5,pedantic:x5},S5={"&":"&","<":"<",">":">",'"':""","'":"'"},Qb=e=>S5[e];function ss(e,t){if(t){if(Mr.escapeTest.test(e))return e.replace(Mr.escapeReplace,Qb)}else if(Mr.escapeTestNoEncode.test(e))return e.replace(Mr.escapeReplaceNoEncode,Qb);return e}function Jb(e){try{e=encodeURI(e).replace(Mr.percentDecode,"%")}catch{return null}return e}function ex(e,t){var i;let n=e.replace(Mr.findPipe,(l,c,u)=>{let h=!1,p=c;for(;--p>=0&&u[p]==="\\";)h=!h;return h?"|":" |"}),r=n.split(Mr.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(Mr.slashPipe,"|");return r}function ti(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 tx(e){let t=e.split(`
|
|
131
|
+
`),n=t.length-1;for(;n>=0&&Mr.blankLine.test(t[n]);)n--;return t.length-n<=2?e:t.slice(0,n+1).join(`
|
|
132
|
+
`)}function _5(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 N5(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 nx(e,t,n,r,o){let i=t.href,l=t.title||null,c=e[1].replace(o.other.outputLinkReplace,"$1"),u=e[0].charAt(0)==="!";r.state.inLink=!0;let h=r.state.linkEmitted,p=r.state.inRawBlock;r.state.linkEmitted=!1;let m=r.inlineTokens(c),k=r.state.linkEmitted;if(r.state.linkEmitted=h,r.state.inLink=!1,!u){if(k){r.state.inRawBlock=p;return}r.state.linkEmitted=!0}return{type:u?"image":"link",raw:n,href:i,title:l,text:c,tokens:m}}function T5(e,t,n){let r=e.match(n.other.indentCodeCompensation);if(r===null)return t;let o=r[1];return t.split(`
|
|
133
|
+
`).map(i=>{let l=i.match(n.other.beginningSpace);if(l===null)return i;let[c]=l;return c.length>=o.length?i.slice(o.length):i}).join(`
|
|
134
|
+
`)}var sf=class{constructor(e){zt(this,"options");zt(this,"rules");zt(this,"lexer");this.options=e||aa}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]:tx(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=T5(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=ti(n,"#");(this.options.pedantic||!r||this.rules.other.endingSpaceChar.test(r))&&(n=r.trim())}return{type:"heading",raw:ti(t[0],`
|
|
135
|
+
`),depth:t[1].length,text:n,tokens:this.lexer.inline(n)}}}hr(e){let t=this.rules.block.hr.exec(e);if(t)return{type:"hr",raw:ti(t[0],`
|
|
136
|
+
`)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let n=ti(t[0],`
|
|
137
|
+
`).split(`
|
|
138
|
+
`),r="",o="",i=[];for(;n.length>0;){let l=!1,c=[],u;for(u=0;u<n.length;u++)if(this.rules.other.blockquoteStart.test(n[u]))c.push(n[u]),l=!0;else if(!l)c.push(n[u]);else break;n=n.slice(u);let h=c.join(`
|
|
139
|
+
`),p=h.replace(this.rules.other.blockquoteSetextReplace,`
|
|
140
|
+
$1`).replace(this.rules.other.blockquoteSetextReplace2,"");r=r?`${r}
|
|
141
|
+
${h}`:h,o=o?`${o}
|
|
142
|
+
${p}`:p;let m=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(p,i,!0),this.lexer.state.top=m,n.length===0)break;let k=i.at(-1);if((k==null?void 0:k.type)==="code")break;if((k==null?void 0:k.type)==="blockquote"){let g=k,y=n.join(`
|
|
143
|
+
`),b=g.raw+`
|
|
144
|
+
`+y.replace(this.rules.other.blockquoteSetextReplace2,""),S=this.blockquote(b);i[i.length-1]=S,r=`${r}
|
|
145
|
+
${y}`,o=o.substring(0,o.length-g.text.length)+S.text;break}else if((k==null?void 0:k.type)==="list"){let g=k,y=g.raw+`
|
|
146
|
+
`+n.join(`
|
|
147
|
+
`),b=this.list(y);i[i.length-1]=b,r=r.substring(0,r.length-k.raw.length)+b.raw,o=o.substring(0,o.length-g.raw.length)+b.raw,n=y.substring(i.at(-1).raw.length).split(`
|
|
148
|
+
`);continue}}return{type:"blockquote",raw:r,tokens:i,text:o}}}list(e){let t=this.rules.block.list.exec(e);if(t){let n=t[1].trim(),r=n.length>1,o={type:"list",raw:"",ordered:r,start:r?+n.slice(0,-1):"",loose:!1,items:[]};n=r?`\\d{1,9}\\${n.slice(-1)}`:`\\${n}`,this.options.pedantic&&(n=r?n:"[*+-]");let i=this.rules.other.listItemRegex(n),l=!1;for(;e;){let u=!1,h="",p="";if(!(t=i.exec(e))||this.rules.block.hr.test(e))break;h=t[0],e=e.substring(h.length);let m=N5(t[2].split(`
|
|
149
|
+
`,1)[0],t[1].length),k=e.split(`
|
|
150
|
+
`,1)[0],g=!m.trim(),y=0;if(this.options.pedantic?(y=2,p=m.trimStart()):g?y=t[1].length+1:(y=m.search(this.rules.other.nonSpaceChar),y=y>4?1:y,p=m.slice(y),y+=t[1].length),g&&this.rules.other.blankLine.test(k)&&(h+=k+`
|
|
151
|
+
`,e=e.substring(k.length+1),u=!0),!u){let b=this.rules.other.nextBulletRegex(y),S=this.rules.other.hrRegex(y),j=this.rules.other.fencesBeginRegex(y),E=this.rules.other.headingBeginRegex(y),N=this.rules.other.htmlBeginRegex(y),A=this.rules.other.blockquoteBeginRegex(y);for(;e;){let O=e.split(`
|
|
152
|
+
`,1)[0],P;if(k=O,this.options.pedantic?(k=k.replace(this.rules.other.listReplaceNesting," "),P=k):P=k.replace(this.rules.other.tabCharGlobal," "),j.test(k)||E.test(k)||N.test(k)||A.test(k)||b.test(k)||S.test(k))break;if(P.search(this.rules.other.nonSpaceChar)>=y||!k.trim())p+=`
|
|
153
|
+
`+P.slice(y);else{if(g||m.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||j.test(m)||E.test(m)||S.test(m))break;p+=`
|
|
154
|
+
`+k}g=!k.trim(),h+=O+`
|
|
155
|
+
`,e=e.substring(O.length+1),m=P.slice(y)}}o.loose||(l?o.loose=!0:this.rules.other.doubleBlankLine.test(h)&&(l=!0)),o.items.push({type:"list_item",raw:h,task:!!this.options.gfm&&this.rules.other.listIsTask.test(p),loose:!1,text:p,tokens:[]}),o.raw+=h}let c=o.items.at(-1);if(c)c.raw=c.raw.trimEnd(),c.text=c.text.trimEnd();else return;o.raw=o.raw.trimEnd();for(let u of o.items)if(this.lexer.state.top=!1,u.tokens=this.lexer.blockTokens(u.text,[]),!o.loose){let h=u.tokens.filter(m=>m.type==="space"),p=h.length>0&&h.some(m=>this.rules.other.anyLine.test(m.raw));o.loose=p}for(let u of o.items){let h=u.tokens[0];if(u.task&&((h==null?void 0:h.type)==="text"||(h==null?void 0:h.type)==="paragraph")){u.text=u.text.replace(this.rules.other.listReplaceTask,""),h.raw=h.raw.replace(this.rules.other.listReplaceTask,""),h.text=h.text.replace(this.rules.other.listReplaceTask,"");for(let m=this.lexer.inlineQueue.length-1;m>=0;m--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[m].src)){this.lexer.inlineQueue[m].src=this.lexer.inlineQueue[m].src.replace(this.rules.other.listReplaceTask,"");break}let p=this.rules.other.listTaskCheckbox.exec(u.raw);if(p){let m={type:"checkbox",raw:p[0]+" ",checked:p[0]!=="[ ]"};u.checked=m.checked,o.loose?u.tokens[0]&&["paragraph","text"].includes(u.tokens[0].type)&&"tokens"in u.tokens[0]&&u.tokens[0].tokens?(u.tokens[0].raw=m.raw+u.tokens[0].raw,u.tokens[0].text=m.raw+u.tokens[0].text,u.tokens[0].tokens.unshift(m)):u.tokens.unshift({type:"paragraph",raw:m.raw,text:m.raw,tokens:[m]}):u.tokens.unshift(m)}}else u.task&&(u.task=!1)}if(o.loose)for(let u of o.items){u.loose=!0;for(let h of u.tokens)h.type==="text"&&(h.type="paragraph")}return o}}html(e){let t=this.rules.block.html.exec(e);if(t){let n=tx(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:ti(t[0],`
|
|
156
|
+
`),href:r,title:o}}}table(e){var l;let t=this.rules.block.table.exec(e);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let n=ex(t[1]),r=t[2].replace(this.rules.other.tableAlignChars,"").split("|"),o=(l=t[3])!=null&&l.trim()?t[3].replace(this.rules.other.tableRowBlankLine,"").split(`
|
|
157
|
+
`):[],i={type:"table",raw:ti(t[0],`
|
|
158
|
+
`),header:[],align:[],rows:[]};if(n.length===r.length){for(let c of r)this.rules.other.tableAlignRight.test(c)?i.align.push("right"):this.rules.other.tableAlignCenter.test(c)?i.align.push("center"):this.rules.other.tableAlignLeft.test(c)?i.align.push("left"):i.align.push(null);for(let c=0;c<n.length;c++)i.header.push({text:n[c],tokens:this.lexer.inline(n[c]),header:!0,align:i.align[c]});for(let c of o)i.rows.push(ex(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:ti(t[0],`
|
|
159
|
+
`),depth:t[2].charAt(0)==="="?1:2,text:n,tokens:this.lexer.inline(n)}}}paragraph(e){let t=this.rules.block.paragraph.exec(e);if(t){let n=t[1].charAt(t[1].length-1)===`
|
|
160
|
+
`?t[1].slice(0,-1):t[1];return{type:"paragraph",raw:t[0],text:n,tokens:this.lexer.inline(n)}}}text(e){let t=this.rules.block.text.exec(e);if(t)return{type:"text",raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(e){let t=this.rules.inline.escape.exec(e);if(t)return{type:"escape",raw:t[0],text:t[1]}}tag(e){let t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&this.rules.other.startATag.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(e){let t=this.rules.inline.link.exec(e);if(t){let n=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(n)){if(!this.rules.other.endAngleBracket.test(n))return;let i=ti(n.slice(0,-1),"\\");if((n.length-i.length)%2===0)return}else{let i=_5(t[2],"()");if(i===-2)return;if(i>-1){let l=(t[0].indexOf("!")===0?5:4)+t[1].length+i;t[2]=t[2].substring(0,i),t[0]=t[0].substring(0,l).trim(),t[3]=""}}let r=t[2],o="";if(this.options.pedantic){let i=this.rules.other.pedanticHrefTitle.exec(r);i&&(r=i[1],o=i[3])}else o=t[3]?t[3].slice(1,-1):"";return r=r.trim(),this.rules.other.startAngleBracket.test(r)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(n)?r=r.slice(1):r=r.slice(1,-1)),nx(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 nx(n,o,n[0],this.lexer,this.rules)}}emStrong(e,t,n=""){let r=this.rules.inline.emStrongLDelim.exec(e);if(!(!r||!r[1]&&!r[2]&&!r[3]&&!r[4]||r[4]&&n.match(this.rules.other.unicodeAlphaNumeric))&&(!(r[1]||r[3])||!n||this.rules.inline.punctuation.exec(n))){let o=[...r[0]].length-1,i,l,c=o,u=0,h=r[0][0],p=n===h,m=h==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(m.lastIndex=0,t=t.slice(-1*e.length+o);(r=m.exec(t))!==null;){if(i=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!i)continue;if(l=[...i].length,r[3]||r[4]){c+=l;continue}else if(r[5]||r[6]){if(o%3&&!((o+l)%3)){u+=l;continue}if(p)break}if(c-=l,c>0)continue;l=Math.min(l,l+c+u);let k=[...r[0]][0].length,g=e.slice(0,o+r.index+k+l);if(Math.min(o,l)%2){let b=g.slice(1,-1);return{type:"em",raw:g,text:b,tokens:this.lexer.inlineTokens(b)}}let y=g.slice(2,-2);return{type:"strong",raw:g,text:y,tokens:this.lexer.inlineTokens(y)}}}}codespan(e){let t=this.rules.inline.code.exec(e);if(t){let n=t[2].replace(this.rules.other.newLineCharGlobal," "),r=this.rules.other.nonSpaceChar.test(n),o=this.rules.other.startingSpaceChar.test(n)&&this.rules.other.endingSpaceChar.test(n);return r&&o&&(n=n.substring(1,n.length-1)),{type:"codespan",raw:t[0],text:n}}}br(e){let t=this.rules.inline.br.exec(e);if(t)return{type:"br",raw:t[0]}}del(e,t,n=""){let r=this.rules.inline.delLDelim.exec(e);if(r&&(!r[1]||!n||this.rules.inline.punctuation.exec(n))){let o=[...r[0]].length-1,i,l,c=o,u=this.rules.inline.delRDelim;for(u.lastIndex=0,t=t.slice(-1*e.length+o);(r=u.exec(t))!==null;){if(i=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!i||(l=[...i].length,l!==o))continue;if(r[3]||r[4]){c+=l;continue}if(c-=l,c>0)continue;l=Math.min(l,l+c);let h=[...r[0]][0].length,p=e.slice(0,o+r.index+h+l),m=p.slice(o,-o);return{type:"del",raw:p,text:m,tokens:this.lexer.inlineTokens(m)}}}}autolink(e){let t=this.rules.inline.autolink.exec(e);if(t){let n,r;return t[2]==="@"?(n=t[1],r="mailto:"+n):(n=t[1],r=n),{type:"link",raw:t[0],text:n,href:r,tokens:[{type:"text",raw:n,text:n}]}}}url(e){var n;let t;if(t=this.rules.inline.url.exec(e)){let r,o;if(t[2]==="@")r=t[0],o="mailto:"+r;else{let i;do i=t[0],t[0]=((n=this.rules.inline._backpedal.exec(t[0]))==null?void 0:n[0])??"";while(i!==t[0]);r=t[0],t[1]==="www."?o="http://"+t[0]:o=t[0]}return{type:"link",raw:t[0],text:r,href:o,tokens:[{type:"text",raw:r,text:r}]}}}inlineText(e){let t=this.rules.inline.text.exec(e);if(t){let n=this.lexer.state.inRawBlock;return{type:"text",raw:t[0],text:t[0],escaped:n}}}},Wo=class Qm{constructor(t){zt(this,"tokens");zt(this,"options");zt(this,"state");zt(this,"inlineQueue");zt(this,"tokenizer");this.tokens=[],this.tokens.links=Object.create(null),this.options=t||aa,this.options.tokenizer=this.options.tokenizer||new sf,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:Mr,block:_d.normal,inline:uc.normal};this.options.pedantic?(n.block=_d.pedantic,n.inline=uc.pedantic):this.options.gfm&&(n.block=_d.gfm,this.options.breaks?n.inline=uc.breaks:n.inline=uc.gfm),this.tokenizer.rules=n}static get rules(){return{block:_d,inline:uc}}static lex(t,n){return new Qm(n).lex(t)}static lexInline(t,n){return new Qm(n).inlineTokens(t)}lex(t){t=t.replace(Mr.carriageReturn,`
|
|
161
|
+
`),this.blockTokens(t,this.tokens);for(let n=0;n<this.inlineQueue.length;n++){let r=this.inlineQueue[n];this.inlineTokens(r.src,r.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(t,n=[],r=!1){var i,l,c;this.tokenizer.lexer=this,this.options.pedantic&&(t=t.replace(Mr.tabCharGlobal," ").replace(Mr.spaceLine,""));let o=1/0;for(;t;){if(t.length<o)o=t.length;else{this.infiniteLoopError(t.charCodeAt(0));break}let u;if((l=(i=this.options.extensions)==null?void 0:i.block)!=null&&l.some(p=>(u=p.call({lexer:this},t,n))?(t=t.substring(u.raw.length),n.push(u),!0):!1))continue;if(u=this.tokenizer.space(t)){t=t.substring(u.raw.length);let p=n.at(-1);u.raw.length===1&&p!==void 0?p.raw+=`
|
|
162
|
+
`:n.push(u);continue}if(u=this.tokenizer.code(t)){t=t.substring(u.raw.length);let p=n.at(-1);(p==null?void 0:p.type)==="paragraph"||(p==null?void 0:p.type)==="text"?(p.raw+=(p.raw.endsWith(`
|
|
163
|
+
`)?"":`
|
|
164
|
+
`)+u.raw,p.text+=`
|
|
165
|
+
`+u.text,this.inlineQueue.at(-1).src=p.text):n.push(u);continue}if(u=this.tokenizer.fences(t)){t=t.substring(u.raw.length),n.push(u);continue}if(u=this.tokenizer.heading(t)){t=t.substring(u.raw.length),n.push(u);continue}if(u=this.tokenizer.hr(t)){t=t.substring(u.raw.length),n.push(u);continue}if(u=this.tokenizer.blockquote(t)){t=t.substring(u.raw.length),n.push(u);continue}if(u=this.tokenizer.list(t)){t=t.substring(u.raw.length),n.push(u);continue}if(u=this.tokenizer.html(t)){t=t.substring(u.raw.length),n.push(u);continue}if(u=this.tokenizer.def(t)){t=t.substring(u.raw.length);let p=n.at(-1);(p==null?void 0:p.type)==="paragraph"||(p==null?void 0:p.type)==="text"?(p.raw+=(p.raw.endsWith(`
|
|
166
|
+
`)?"":`
|
|
167
|
+
`)+u.raw,p.text+=`
|
|
168
|
+
`+u.raw,this.inlineQueue.at(-1).src=p.text):this.tokens.links[u.tag]||(this.tokens.links[u.tag]={href:u.href,title:u.title},n.push(u));continue}if(u=this.tokenizer.table(t)){t=t.substring(u.raw.length),n.push(u);continue}if(u=this.tokenizer.lheading(t)){t=t.substring(u.raw.length),n.push(u);continue}let h=t;if((c=this.options.extensions)!=null&&c.startBlock){let p=1/0,m=t.slice(1),k;this.options.extensions.startBlock.forEach(g=>{k=g.call({lexer:this},m),typeof k=="number"&&k>=0&&(p=Math.min(p,k))}),p<1/0&&p>=0&&(h=t.substring(0,p+1))}if(this.state.top&&(u=this.tokenizer.paragraph(h))){let p=n.at(-1);r&&(p==null?void 0:p.type)==="paragraph"?(p.raw+=(p.raw.endsWith(`
|
|
169
|
+
`)?"":`
|
|
170
|
+
`)+u.raw,p.text+=`
|
|
171
|
+
`+u.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=p.text):n.push(u),r=h.length!==t.length,t=t.substring(u.raw.length);continue}if(u=this.tokenizer.text(t)){t=t.substring(u.raw.length);let p=n.at(-1);(p==null?void 0:p.type)==="text"?(p.raw+=(p.raw.endsWith(`
|
|
172
|
+
`)?"":`
|
|
173
|
+
`)+u.raw,p.text+=`
|
|
174
|
+
`+u.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=p.text):n.push(u);continue}if(t){this.infiniteLoopError(t.charCodeAt(0));break}}return this.state.top=!0,n}inline(t,n=[]){return this.inlineQueue.push({src:t,tokens:n}),n}linkInText(t){if(!t.includes("["))return!1;let n=this.tokenizer.rules.inline.link;for(let r of t.matchAll(this.tokenizer.rules.inline.blockSkip))if(n.test(r[0])&&t.charAt(r.index-1)!=="!")return!0;for(let r of t.matchAll(this.tokenizer.rules.inline.reflinkSearch)){let o=r[0],i=o.lastIndexOf("[");if(!(o.charAt(0)==="!"||!Object.hasOwn(this.tokens.links,o.slice(i+1,-1)))&&!(i>1&&this.linkInText(o.slice(1,i-1))))return!0}return!1}inlineTokens(t,n=[]){var c,u,h,p,m;this.tokenizer.lexer=this;let r=t;if(this.tokens.links&&t.includes("[")){let k=this.tokenizer.rules.inline.reflinkSearch,g=y=>{let b=y.lastIndexOf("[");if(!Object.hasOwn(this.tokens.links,y.slice(b+1,-1)))return y;if(b>1&&y.charAt(0)!=="!"){let S=y.slice(1,b-1);if(this.linkInText(S))return"["+S.replace(k,g)+"]["+"a".repeat(y.length-b-2)+"]"}return"["+"a".repeat(y.length-2)+"]"};r=r.replace(k,g)}r=r.replace(this.tokenizer.rules.inline.anyPunctuation,k=>"+".repeat(k.length)),r=r.replace(this.tokenizer.rules.inline.blockSkip,(k,g,y)=>{let b=y?y.length:0;return k.slice(0,b)+"["+"a".repeat(k.length-b-2)+"]"}),r=((u=(c=this.options.hooks)==null?void 0:c.emStrongMask)==null?void 0:u.call({lexer:this},r))??r;let o=!1,i="",l=1/0;for(;t;){if(t.length<l)l=t.length;else{this.infiniteLoopError(t.charCodeAt(0));break}o||(i=""),o=!1;let k;if((p=(h=this.options.extensions)==null?void 0:h.inline)!=null&&p.some(y=>(k=y.call({lexer:this},t,n))?(t=t.substring(k.raw.length),n.push(k),!0):!1))continue;if(k=this.tokenizer.escape(t)){t=t.substring(k.raw.length),n.push(k);continue}if(k=this.tokenizer.tag(t)){t=t.substring(k.raw.length),n.push(k);continue}if(k=this.tokenizer.link(t)){t=t.substring(k.raw.length),n.push(k);continue}if(k=this.tokenizer.reflink(t,this.tokens.links)){t=t.substring(k.raw.length);let y=n.at(-1);k.type==="text"&&(y==null?void 0:y.type)==="text"?(y.raw+=k.raw,y.text+=k.text):n.push(k);continue}if(k=this.tokenizer.emStrong(t,r,i)){t=t.substring(k.raw.length),n.push(k);continue}if(k=this.tokenizer.codespan(t)){t=t.substring(k.raw.length),n.push(k);continue}if(k=this.tokenizer.br(t)){t=t.substring(k.raw.length),n.push(k);continue}if(k=this.tokenizer.del(t,r,i)){t=t.substring(k.raw.length),n.push(k);continue}if(k=this.tokenizer.autolink(t)){t=t.substring(k.raw.length),n.push(k);continue}if(!this.state.inLink&&(k=this.tokenizer.url(t))){t=t.substring(k.raw.length),n.push(k);continue}let g=t;if((m=this.options.extensions)!=null&&m.startInline){let y=1/0,b=t.slice(1),S;this.options.extensions.startInline.forEach(j=>{S=j.call({lexer:this},b),typeof S=="number"&&S>=0&&(y=Math.min(y,S))}),y<1/0&&y>=0&&(g=t.substring(0,y+1))}if(k=this.tokenizer.inlineText(g)){t=t.substring(k.raw.length),k.raw.slice(-1)!=="_"&&(i=k.raw.slice(-1)),o=!0;let y=n.at(-1);(y==null?void 0:y.type)==="text"?(y.raw+=k.raw,y.text+=k.text):n.push(k);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)}},af=class{constructor(e){zt(this,"options");zt(this,"parser");this.options=e||aa}space(e){return""}code({text:e,lang:t,escaped:n}){var i;let r=(i=(t||"").match(Mr.notSpaceStart))==null?void 0:i[0],o=e.replace(Mr.endingNewline,"")+`
|
|
175
|
+
`;return r?'<pre><code class="language-'+ss(r)+'">'+(n?o:ss(o,!0))+`</code></pre>
|
|
176
|
+
`:"<pre><code>"+(n?o:ss(o,!0))+`</code></pre>
|
|
177
|
+
`}blockquote({tokens:e}){return`<blockquote>
|
|
178
|
+
${this.parser.parse(e)}</blockquote>
|
|
179
|
+
`}html({text:e}){return e}def(e){return""}heading({tokens:e,depth:t}){return`<h${t}>${this.parser.parseInline(e)}</h${t}>
|
|
180
|
+
`}hr(e){return`<hr>
|
|
181
|
+
`}list(e){let t=e.ordered,n=e.start,r="";for(let l=0;l<e.items.length;l++){let c=e.items[l];r+=this.listitem(c)}let o=t?"ol":"ul",i=t&&n!==1?' start="'+n+'"':"";return"<"+o+i+`>
|
|
182
|
+
`+r+"</"+o+`>
|
|
183
|
+
`}listitem(e){return`<li>${this.parser.parse(e.tokens)}</li>
|
|
184
|
+
`}checkbox({checked:e}){return"<input "+(e?'checked="" ':"")+'disabled="" type="checkbox"> '}paragraph({tokens:e}){return`<p>${this.parser.parseInline(e)}</p>
|
|
185
|
+
`}table(e){let t="",n="";for(let o=0;o<e.header.length;o++)n+=this.tablecell(e.header[o]);t+=this.tablerow({text:n});let r="";for(let o=0;o<e.rows.length;o++){let i=e.rows[o];n="";for(let l=0;l<i.length;l++)n+=this.tablecell(i[l]);r+=this.tablerow({text:n})}return r&&(r=`<tbody>${r}</tbody>`),`<table>
|
|
186
|
+
<thead>
|
|
187
|
+
`+t+`</thead>
|
|
188
|
+
`+r+`</table>
|
|
189
|
+
`}tablerow({text:e}){return`<tr>
|
|
190
|
+
${e}</tr>
|
|
191
|
+
`}tablecell(e){let t=this.parser.parseInline(e.tokens),n=e.header?"th":"td";return(e.align?`<${n} align="${e.align}">`:`<${n}>`)+t+`</${n}>
|
|
192
|
+
`}strong({tokens:e}){return`<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return`<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return`<code>${ss(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=Jb(e);if(o===null)return r;e=o;let i='<a href="'+e+'"';return t&&(i+=' title="'+ss(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=Jb(e);if(o===null)return ss(n);e=o;let i=`<img src="${e}" alt="${ss(n)}"`;return t&&(i+=` title="${ss(t)}"`),i+=">",i}text(e){return"tokens"in e&&e.tokens?this.parser.parseInline(e.tokens):"escaped"in e&&e.escaped?e.text:ss(e.text)}},Vk=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}},Ko=class Jm{constructor(t){zt(this,"options");zt(this,"renderer");zt(this,"textRenderer");this.options=t||aa,this.options.renderer=this.options.renderer||new af,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Vk}static parse(t,n){return new Jm(n).parse(t)}static parseInline(t,n){return new Jm(n).parseInline(t)}parse(t){var r,o;this.renderer.parser=this;let n="";for(let i=0;i<t.length;i++){let l=t[i];if((o=(r=this.options.extensions)==null?void 0:r.renderers)!=null&&o[l.type]){let u=l,h=this.options.extensions.renderers[u.type].call({parser:this},u);if(h!==!1||!["space","hr","heading","code","table","blockquote","list","checkbox","html","def","paragraph","text"].includes(u.type)){n+=h||"";continue}}let c=l;switch(c.type){case"space":{n+=this.renderer.space(c);break}case"hr":{n+=this.renderer.hr(c);break}case"heading":{n+=this.renderer.heading(c);break}case"code":{n+=this.renderer.code(c);break}case"table":{n+=this.renderer.table(c);break}case"blockquote":{n+=this.renderer.blockquote(c);break}case"list":{n+=this.renderer.list(c);break}case"checkbox":{n+=this.renderer.checkbox(c);break}case"html":{n+=this.renderer.html(c);break}case"def":{n+=this.renderer.def(c);break}case"paragraph":{n+=this.renderer.paragraph(c);break}case"text":{n+=this.renderer.text(c);break}default:{let u='Token with "'+c.type+'" type was not found.';if(this.options.silent)return console.error(u),"";throw new Error(u)}}}return n}parseInline(t,n=this.renderer){var o,i;this.renderer.parser=this;let r="";for(let l=0;l<t.length;l++){let c=t[l];if((i=(o=this.options.extensions)==null?void 0:o.renderers)!=null&&i[c.type]){let h=this.options.extensions.renderers[c.type].call({parser:this},c);if(h!==!1||!["escape","html","link","image","checkbox","strong","em","codespan","br","del","text"].includes(c.type)){r+=h||"";continue}}let u=c;switch(u.type){case"escape":{r+=n.text(u);break}case"html":{r+=n.html(u);break}case"link":{r+=n.link(u);break}case"image":{r+=n.image(u);break}case"checkbox":{r+=n.checkbox(u);break}case"strong":{r+=n.strong(u);break}case"em":{r+=n.em(u);break}case"codespan":{r+=n.codespan(u);break}case"br":{r+=n.br(u);break}case"del":{r+=n.del(u);break}case"text":{r+=n.text(u);break}default:{let h='Token with "'+u.type+'" type was not found.';if(this.options.silent)return console.error(h),"";throw new Error(h)}}}return r}},Ad,gc=(Ad=class{constructor(e){zt(this,"options");zt(this,"block");this.options=e||aa}preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(e=this.block){return e?Wo.lex:Wo.lexInline}provideParser(e=this.block){return e?Ko.parse:Ko.parseInline}},zt(Ad,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens","emStrongMask"])),zt(Ad,"passThroughHooksRespectAsync",new Set(["preprocess","postprocess","processAllTokens"])),Ad),j5=class{constructor(...e){zt(this,"defaults",Uk());zt(this,"options",this.setOptions);zt(this,"parse",this.parseMarkdown(!0));zt(this,"parseInline",this.parseMarkdown(!1));zt(this,"Parser",Ko);zt(this,"Renderer",af);zt(this,"TextRenderer",Vk);zt(this,"Lexer",Wo);zt(this,"Tokenizer",sf);zt(this,"Hooks",gc);this.use(...e)}walkTokens(e,t){var r,o;let n=[];for(let i of e)switch(n=n.concat(t.call(this,i)),i.type){case"table":{let l=i;for(let c of l.header)n=n.concat(this.walkTokens(c.tokens,t));for(let c of l.rows)for(let u of c)n=n.concat(this.walkTokens(u.tokens,t));break}case"list":{let l=i;n=n.concat(this.walkTokens(l.items,t));break}default:{let l=i;(o=(r=this.defaults.extensions)==null?void 0:r.childTokens)!=null&&o[l.type]?this.defaults.extensions.childTokens[l.type].forEach(c=>{let u=l[c].flat(1/0);n=n.concat(this.walkTokens(u,t))}):l.tokens&&(n=n.concat(this.walkTokens(l.tokens,t)))}}return n}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(n=>{let r={...n};if(r.async=this.defaults.async||r.async||!1,n.extensions&&(n.extensions.forEach(o=>{if(!o.name)throw new Error("extension name required");if("renderer"in o){let i=t.renderers[o.name];i?t.renderers[o.name]=function(...l){let c=o.renderer.apply(this,l);return c===!1&&(c=i.apply(this,l)),c}:t.renderers[o.name]=o.renderer}if("tokenizer"in o){if(!o.level||o.level!=="block"&&o.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let i=t[o.level];i?i.unshift(o.tokenizer):t[o.level]=[o.tokenizer],o.start&&(o.level==="block"?t.startBlock?t.startBlock.push(o.start):t.startBlock=[o.start]:o.level==="inline"&&(t.startInline?t.startInline.push(o.start):t.startInline=[o.start]))}"childTokens"in o&&o.childTokens&&(t.childTokens[o.name]=o.childTokens)}),r.extensions=t),n.renderer){let o=this.defaults.renderer||new af(this.defaults);for(let i in n.renderer){if(!(i in o))throw new Error(`renderer '${i}' does not exist`);if(["options","parser"].includes(i))continue;let l=i,c=n.renderer[l],u=o[l];o[l]=(...h)=>{let p=c.apply(o,h);return p===!1&&(p=u.apply(o,h)),p||""}}r.renderer=o}if(n.tokenizer){let o=this.defaults.tokenizer||new sf(this.defaults);for(let i in n.tokenizer){if(!(i in o))throw new Error(`tokenizer '${i}' does not exist`);if(["options","rules","lexer"].includes(i))continue;let l=i,c=n.tokenizer[l],u=o[l];o[l]=(...h)=>{let p=c.apply(o,h);return p===!1&&(p=u.apply(o,h)),p}}r.tokenizer=o}if(n.hooks){let o=this.defaults.hooks||new gc;for(let i in n.hooks){if(!(i in o))throw new Error(`hook '${i}' does not exist`);if(["options","block"].includes(i))continue;let l=i,c=n.hooks[l],u=o[l];gc.passThroughHooks.has(i)?o[l]=h=>{if(this.defaults.async&&gc.passThroughHooksRespectAsync.has(i))return(async()=>{let m=await c.call(o,h);return u.call(o,m)})();let p=c.call(o,h);return u.call(o,p)}:o[l]=(...h)=>{if(this.defaults.async)return(async()=>{let m=await c.apply(o,h);return m===!1&&(m=await u.apply(o,h)),m})();let p=c.apply(o,h);return p===!1&&(p=u.apply(o,h)),p}}r.hooks=o}if(n.walkTokens){let o=this.defaults.walkTokens,i=n.walkTokens;r.walkTokens=function(l){let c=[];return c.push(i.call(this,l)),o&&(c=c.concat(o.call(this,l))),c}}this.defaults={...this.defaults,...r}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return Wo.lex(e,t??this.defaults)}parser(e,t){return Ko.parse(e,t??this.defaults)}parseMarkdown(e){return(t,n)=>{let r={...n},o={...this.defaults,...r},i=this.onError(!!o.silent,!!o.async);if(this.defaults.async===!0&&r.async===!1)return i(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof t>"u"||t===null)return i(new Error("marked(): input parameter is undefined or null"));if(typeof t!="string")return i(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(t)+", string expected"));if(o.hooks&&(o.hooks.options=o,o.hooks.block=e),o.async)return(async()=>{let l=o.hooks?await o.hooks.preprocess(t):t,c=await(o.hooks?await o.hooks.provideLexer(e):e?Wo.lex:Wo.lexInline)(l,o),u=o.hooks?await o.hooks.processAllTokens(c):c;o.walkTokens&&await Promise.all(this.walkTokens(u,o.walkTokens));let h=await(o.hooks?await o.hooks.provideParser(e):e?Ko.parse:Ko.parseInline)(u,o);return o.hooks?await o.hooks.postprocess(h):h})().catch(i);try{o.hooks&&(t=o.hooks.preprocess(t));let l=(o.hooks?o.hooks.provideLexer(e):e?Wo.lex:Wo.lexInline)(t,o);o.hooks&&(l=o.hooks.processAllTokens(l)),o.walkTokens&&this.walkTokens(l,o.walkTokens);let c=(o.hooks?o.hooks.provideParser(e):e?Ko.parse:Ko.parseInline)(l,o);return o.hooks&&(c=o.hooks.postprocess(c)),c}catch(l){return i(l)}}}onError(e,t){return n=>{if(n.message+=`
|
|
193
|
+
Please report this to https://github.com/markedjs/marked.`,e){let r="<p>An error occurred:</p><pre>"+ss(n.message+"",!0)+"</pre>";return t?Promise.resolve(r):r}if(t)return Promise.reject(n);throw n}}},oa=new j5;function Sn(e,t){return oa.parse(e,t)}Sn.options=Sn.setOptions=function(e){return oa.setOptions(e),Sn.defaults=oa.defaults,A_(Sn.defaults),Sn};Sn.getDefaults=Uk;Sn.defaults=aa;function C5(...e){return oa.use(...e),Sn.defaults=oa.defaults,A_(Sn.defaults),Sn}Sn.use=C5;Sn.walkTokens=function(e,t){return oa.walkTokens(e,t)};Sn.parseInline=oa.parseInline;Sn.Parser=Ko;Sn.parser=Ko.parse;Sn.Renderer=af;Sn.TextRenderer=Vk;Sn.Lexer=Wo;Sn.lexer=Wo.lex;Sn.Tokenizer=sf;Sn.Hooks=gc;Sn.parse=Sn;Sn.options;Sn.setOptions;Sn.walkTokens;Sn.parseInline;Ko.parse;Wo.lex;const lf=100,A5=e=>e.type==="text-delta"||e.type==="thinking-delta"||e.type==="tool-delta";function I5(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 R5={now:()=>performance.now(),after:(e,t)=>void setTimeout(t,e)};function $5(e,t=R5){let n=[],r=!1,o=Number.NEGATIVE_INFINITY;const i=()=>{if(r=!1,n.length===0)return;const l=n;n=[],o=t.now();for(const c of l)e(c)};return l=>{if(l.t==="agent"&&A5(l.event)){const c={...l,event:{...l.event}},u=t.now();if(n.length===0&&u-o>=lf){o=u,e(c);return}const h=n[n.length-1];h&&I5(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+lf-u),i));return}i(),e(l)}}const F_="#toyon-link-pending",O5=/!?\[([^[\]\n]*)(?:\]\(([^()\s]*))?$/;function M5(e){const t=e.lastIndexOf(`
|
|
194
|
+
`)+1,n=e.slice(t),r=O5.exec(n);return!r||P5(e.slice(0,t))||L5(n.slice(0,r.index))?e:`${e.slice(0,t)}${n.slice(0,r.index)}[${r[1]}](${F_})`}function P5(e){let t=!1;for(const n of e.split(`
|
|
195
|
+
`))/^\s*(```|~~~)/.test(n)&&(t=!t);return t}function L5(e){let t=0;for(const n of e)n==="`"&&t++;return t%2===1}const Yp="__[a-z][a-z0-9_]*[a-z0-9]__",D5=new RegExp(`^(?:${Yp}\\.)+${Yp}|^${Yp}(?=\\.\\w|\\(|["'])`),z5={name:"dunder",level:"inline",start:e=>e.indexOf("__"),tokenizer(e){const t=D5.exec(e);if(t)return{type:"dunder",raw:t[0],text:t[0]}},renderer:e=>e.text};function F5(e){if(e.header.some(n=>n.text.trim()))return!1;let t="";for(const n of e.rows){let r="";for(const o of n)r+=this.tablecell(o);t+=this.tablerow({text:r})}return`<table>
|
|
196
|
+
<tbody>${t}</tbody></table>
|
|
197
|
+
`}function B5(e){const t=e.regex,n={},r={begin:/\$\{/,end:/\}/,contains:["self",{begin:/:-/,contains:[n]}]};Object.assign(n,{className:"variable",variants:[{begin:t.concat(/\$[\w\d#@][\w\d_]*/,"(?![\\w\\d])(?![$])")},r]});const o={className:"subst",begin:/\$\(/,end:/\)/,contains:[e.BACKSLASH_ESCAPE]},i=e.inherit(e.COMMENT(),{match:[/(^|\s)/,/#.*$/],scope:{2:"comment"}}),l={begin:/<<-?\s*(?=\w+)/,starts:{contains:[e.END_SAME_AS_BEGIN({begin:/(\w+)/,end:/(\w+)/,className:"string"})]}},c={className:"string",begin:/"/,end:/"/,contains:[e.BACKSLASH_ESCAPE,n,o]};o.contains.push(c);const u={match:/\\"/},h={className:"string",begin:/'/,end:/'/},p={match:/\\'/},m={begin:/\$?\(\(/,end:/\)\)/,contains:[{begin:/\d+#[0-9a-f]+/,className:"number"},e.NUMBER_MODE,n]},k=["fish","bash","zsh","sh","csh","ksh","tcsh","dash","scsh"],g=e.SHEBANG({binary:`(${k.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},b=["if","then","else","elif","fi","time","for","while","until","in","do","done","case","esac","coproc","function","select"],S=["true","false"],j={match:/(\/[a-z._-]+)+/},E=["break","cd","continue","eval","exec","exit","export","getopts","hash","pwd","readonly","return","shift","test","times","trap","umask","unset"],N=["alias","bind","builtin","caller","command","declare","echo","enable","help","let","local","logout","mapfile","printf","read","readarray","source","sudo","type","typeset","ulimit","unalias"],A=["autoload","bg","bindkey","bye","cap","chdir","clone","comparguments","compcall","compctl","compdescribe","compfiles","compgroups","compquote","comptags","comptry","compvalues","dirs","disable","disown","echotc","echoti","emulate","fc","fg","float","functions","getcap","getln","history","integer","jobs","kill","limit","log","noglob","popd","print","pushd","pushln","rehash","sched","setcap","setopt","stat","suspend","ttyctl","unfunction","unhash","unlimit","unsetopt","vared","wait","whence","where","which","zcompile","zformat","zftp","zle","zmodload","zparseopts","zprof","zpty","zregexparse","zsocket","zstyle","ztcp"],O=["chcon","chgrp","chown","chmod","cp","dd","df","dir","dircolors","ln","ls","mkdir","mkfifo","mknod","mktemp","mv","realpath","rm","rmdir","shred","sync","touch","truncate","vdir","b2sum","base32","base64","cat","cksum","comm","csplit","cut","expand","fmt","fold","head","join","md5sum","nl","numfmt","od","paste","ptx","pr","sha1sum","sha224sum","sha256sum","sha384sum","sha512sum","shuf","sort","split","sum","tac","tail","tr","tsort","unexpand","uniq","wc","arch","basename","chroot","date","dirname","du","echo","env","expr","factor","groups","hostid","id","link","logname","nice","nohup","nproc","pathchk","pinky","printenv","printf","pwd","readlink","runcon","seq","sleep","stat","stdbuf","stty","tee","test","timeout","tty","uname","unlink","uptime","users","who","whoami","yes"];return{name:"Bash",aliases:["sh","zsh"],keywords:{$pattern:/\b[a-z][a-z0-9._-]+\b/,keyword:b,literal:S,built_in:[...E,...N,"set","shopt",...A,...O]},contains:[g,e.SHEBANG(),y,m,i,l,j,c,u,h,p,n]}}const U5=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_-]*/}}),H5=["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"],W5=["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"],K5=[...H5,...W5],Z5=["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(),q5=["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(),G5=["after","backdrop","before","cue","cue-region","first-letter","first-line","grammar-error","marker","part","placeholder","selection","slotted","spelling-error"].sort().reverse(),V5=["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 Y5(e){const t=e.regex,n=U5(e),r={begin:/-(webkit|moz|ms|o)-(?=[a-z])/},o="and or not only",i=/@-?\w[\w]*(-\w+)*/,l="[a-zA-Z-][a-zA-Z0-9_-]*",c=[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE];return{name:"CSS",case_insensitive:!0,illegal:/[=|'\$]/,keywords:{keyframePosition:"from to"},classNameAliases:{keyframePosition:"selector-tag"},contains:[n.BLOCK_COMMENT,r,n.CSS_NUMBER_MODE,{className:"selector-id",begin:/#[A-Za-z0-9_-]+/,relevance:0},{className:"selector-class",begin:"\\."+l,relevance:0},n.ATTRIBUTE_SELECTOR_MODE,{className:"selector-pseudo",variants:[{begin:":("+q5.join("|")+")"},{begin:":(:)?("+G5.join("|")+")"}]},n.CSS_VARIABLE,{className:"attribute",begin:"\\b("+V5.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:Z5.join(" ")},contains:[{begin:/[a-z-]+(?=:)/,className:"attribute"},...c,n.CSS_NUMBER_MODE]}]},{className:"selector-tag",begin:"\\b("+K5.join("|")+")\\b"}]}}function X5(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 Q5(e){const t=e.regex,n={className:"number",relevance:0,variants:[{begin:/([+-]+)?[\d]+_[\d_]+/},{begin:e.NUMBER_RE}]},r=e.COMMENT();r.variants=[{begin:/;/,end:/$/},{begin:/#/,end:/$/}];const o={className:"variable",variants:[{begin:/\$[\w\d"][\w\d_]*/},{begin:/\$\{(.*?)\}/}]},i={className:"literal",begin:/\bon|off|true|false|yes|no\b/},l={className:"string",contains:[e.BACKSLASH_ESCAPE],variants:[{begin:"'''",end:"'''",relevance:10},{begin:'"""',end:'"""',relevance:10},{begin:'"',end:'"'},{begin:"'",end:"'"}]},c={begin:/\[/,end:/\]/,contains:[r,i,o,l,n,"self"],relevance:0},u=/[A-Za-z0-9_-]+/,h=/"(\\"|[^"])*"/,p=/'[^']*'/,m=t.either(u,h,p),k=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:k,className:"attr",starts:{end:/$/,contains:[r,c,i,o,l,n]}}]}}const rx="[A-Za-z$_][0-9A-Za-z$_]*",J5=["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"],e6=["true","false","null","undefined","NaN","Infinity"],B_=["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"],U_=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],H_=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],t6=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","self","global"],n6=[].concat(H_,B_,U_);function r6(e){const t=e.regex,n=(B,{after:ee})=>{const J="</"+B[0].slice(1);return B.input.indexOf(J,ee)!==-1},r=rx,o={begin:"<>",end:"</>"},i=/<[A-Za-z0-9\\._:-]+\s*\/>/,l={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(B,ee)=>{const J=B[0].length+B.index,W=B.input[J];if(W==="<"||W===","){ee.ignoreMatch();return}W===">"&&(n(B,{after:J})||ee.ignoreMatch());let ie;const Te=B.input.substring(J);if(ie=Te.match(/^\s*=/)){ee.ignoreMatch();return}if((ie=Te.match(/^\s+extends\s+/))&&ie.index===0){ee.ignoreMatch();return}}},c={$pattern:rx,keyword:J5,literal:e6,built_in:n6,"variable.language":t6},u="[0-9](_?[0-9])*",h=`\\.(${u})`,p="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",m={className:"number",variants:[{begin:`(\\b(${p})((${h})|\\.)?|(${h}))[eE][+-]?(${u})\\b`},{begin:`\\b(${p})\\b((${h})\\b|\\.)?|(${h})\\b`},{begin:"\\b(0|[1-9](_?[0-9])*)n\\b"},{begin:"\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*n?\\b"},{begin:"\\b0[bB][0-1](_?[0-1])*n?\\b"},{begin:"\\b0[oO][0-7](_?[0-7])*n?\\b"},{begin:"\\b0[0-7]+n?\\b"}],relevance:0},k={className:"subst",begin:"\\$\\{",end:"\\}",keywords:c,contains:[]},g={begin:".?html`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,k],subLanguage:"xml"}},y={begin:".?css`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,k],subLanguage:"css"}},b={begin:".?gql`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,k],subLanguage:"graphql"}},S={className:"string",begin:"`",end:"`",contains:[e.BACKSLASH_ESCAPE,k]},E={className:"comment",variants:[e.COMMENT(/\/\*\*(?!\/)/,"\\*/",{relevance:0,contains:[{begin:"(?=@[A-Za-z]+)",relevance:0,contains:[{className:"doctag",begin:"@[A-Za-z]+"},{className:"type",begin:"\\{",end:"\\}",excludeEnd:!0,excludeBegin:!0,relevance:0},{className:"variable",begin:r+"(?=\\s*(-)|$)",endsParent:!0,relevance:0},{begin:/(?=[^\n])\s/,relevance:0}]}]}),e.C_BLOCK_COMMENT_MODE,e.C_LINE_COMMENT_MODE]},N=[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,g,y,b,S,{match:/\$\d+/},m];k.contains=N.concat({begin:/\{/,end:/\}/,keywords:c,contains:["self"].concat(N)});const A=[].concat(E,k.contains),O=A.concat([{begin:/(\s*)\(/,end:/\)/,keywords:c,contains:["self"].concat(A)}]),P={className:"params",begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:c,contains:O},R={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"}}]},T={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:{_:[...B_,...U_]}},$={label:"use_strict",className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},D={variants:[{match:[/function/,/\s+/,r,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:"keyword",3:"title.function"},label:"func.def",contains:[P],illegal:/%/},z={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"};function V(B){return t.concat("(?!",B.join("|"),")")}const se={match:t.concat(/\b/,V([...H_,"super","import","await"].map(B=>`${B}\\s*\\(`)),r,t.lookahead(/\s*\(/)),className:"title.function",relevance:0},I={begin:t.concat(/\./,t.lookahead(t.concat(r,/(?![0-9A-Za-z$_(])/))),end:r,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},ne={match:[/get|set/,/\s+/,r,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},P]},we="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+e.UNDERSCORE_IDENT_RE+")\\s*=>",K={match:[/const|var|let/,/\s+/,r,/\s*/,/=\s*/,/(async\s*)?/,t.lookahead(we)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[P]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:c,exports:{PARAMS_CONTAINS:O,CLASS_REFERENCE:T},illegal:/#(?![$_A-Za-z])/,contains:[e.SHEBANG({label:"shebang",binary:"node",relevance:5}),$,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,g,y,b,S,E,{match:/\$\d+/},m,T,{scope:"attr",match:r+t.lookahead(":"),relevance:0},K,{begin:"("+e.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",relevance:0,contains:[E,e.REGEXP_MODE,{className:"function",begin:we,returnBegin:!0,end:"\\s*=>",contains:[{className:"params",variants:[{begin:e.UNDERSCORE_IDENT_RE,relevance:0},{className:null,begin:/\(\s*\)/,skip:!0},{begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:c,contains:O}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:o.begin,end:o.end},{match:i},{begin:l.begin,"on:begin":l.isTrulyOpeningTag,end:l.end}],subLanguage:"xml",contains:[{begin:l.begin,end:l.end,skip:!0,contains:["self"]}]}]},D,{beginKeywords:"while if switch catch for"},{begin:"\\b(?!function)"+e.UNDERSCORE_IDENT_RE+"\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",returnBegin:!0,label:"func.def",contains:[P,e.inherit(e.TITLE_MODE,{begin:r,className:"title.function"})]},{match:/\.\.\./,relevance:0},I,{match:"\\$"+r,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[P]},se,z,R,ne,{match:/\$[(.]/}]}}const o6="([-+]?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)|NaN|[-+]?Infinity",s6={scope:"number",match:o6,relevance:0};function i6(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,s6,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE],illegal:"\\S"}}function a6(e){const t=e.regex,n={begin:/<\/?[A-Za-z_]/,end:">",subLanguage:"xml",relevance:0},r={match:/^ {0,3}([-*_])[ \t]*(?:\1[ \t]*){2,}$/},o={className:"code",variants:[{begin:"(`{3,})[^`](.|\\n)*?\\1`*[ ]*"},{begin:"(~{3,})[^~](.|\\n)*?\\1~*[ ]*"},{begin:"```",end:"```+[ ]*$"},{begin:"~~~",end:"~~~+[ ]*$"},{begin:"`.+?`"},{begin:"(?=^( {4}|\\t))",contains:[{begin:"^( {4}|\\t)",end:"(\\n)$"}],relevance:0}]},i={className:"bullet",begin:"^[ ]*([*+-]|(\\d+\\.))(?=\\s+)",end:"\\s+",excludeEnd:!0},l={begin:/^\[[^\n]+\]:/,returnBegin:!0,contains:[{className:"symbol",begin:/\[/,end:/\]/,excludeBegin:!0,excludeEnd:!0},{className:"link",begin:/:\s*/,end:/$/,excludeBegin:!0}]},c=/[A-Za-z][A-Za-z0-9+.-]*/,u={variants:[{begin:/\[.+?\]\[.*?\]/,relevance:0},{begin:/\[.+?\]\(((data|javascript|mailto):|(?:http|ftp)s?:\/\/).*?\)/,relevance:2},{begin:t.concat(/\[.+?\]\(/,c,/:\/\/.*?\)/),relevance:2},{begin:/\[.+?\]\([./?&#].*?\)/,relevance:1},{begin:/\[.*?\]\(.*?\)/,relevance:0}],returnBegin:!0,contains:[{match:/\[(?=\])/},{className:"string",relevance:0,begin:"\\[",end:"\\]",excludeBegin:!0,returnEnd:!0},{className:"link",relevance:0,begin:"\\]\\(",end:"\\)",excludeBegin:!0,excludeEnd:!0},{className:"symbol",relevance:0,begin:"\\]\\[",end:"\\]",excludeBegin:!0,excludeEnd:!0}]},h={className:"strong",contains:[],variants:[{begin:/_{2}(?!\s)/,end:/_{2}/},{begin:/\*{2}(?!\s)/,end:/\*{2}/}]},p={className:"emphasis",contains:[],variants:[{begin:/\*(?![*\s])/,end:/\*/},{begin:/_(?![_\s])/,end:/_/,relevance:0}]},m=e.inherit(h,{contains:[]}),k=e.inherit(p,{contains:[]});h.contains.push(k),p.contains.push(m);let g=[n,u];return[h,p,m,k].forEach(j=>{j.contains=j.contains.concat(g)}),g=g.concat(h,p),{name:"Markdown",aliases:["md","mkdown","mkd"],contains:[{className:"section",variants:[{begin:"^#{1,6}",end:"$",contains:g},{begin:"(?=^.+?\\n[=-]{2,}$)",contains:[{begin:"^[=-]*$"},{begin:"^",end:"\\n",contains:g}]}]},n,i,r,h,p,{className:"quote",begin:"^>\\s+",contains:g,end:"$"},o,u,l,{scope:"literal",match:/&([a-zA-Z0-9]+|#[0-9]{1,7}|#[Xx][0-9a-fA-F]{1,6});/}]}}function l6(e){const t=e.regex,n=new RegExp("[\\p{XID_Start}_]\\p{XID_Continue}*","u"),r=["and","as","assert","async","await","break","case","class","continue","def","del","elif","else","except","finally","for","from","global","if","import","in","is","lambda","lazy","match","nonlocal|10","not","or","pass","raise","return","try","while","with","yield"],c={$pattern:/[A-Za-z]\w+|__\w+__/,keyword:r,built_in:["__import__","abs","aiter","all","anext","any","ascii","bin","bool","breakpoint","bytearray","bytes","callable","chr","classmethod","compile","complex","delattr","dict","dir","divmod","enumerate","eval","exec","filter","float","format","frozendict","frozenset","getattr","globals","hasattr","hash","help","hex","id","input","int","isinstance","issubclass","iter","len","list","locals","map","max","memoryview","min","next","object","oct","open","ord","pow","print","property","range","repr","reversed","round","sentinel","set","setattr","slice","sorted","staticmethod","str","sum","super","tuple","type","vars","zip"],literal:["__debug__","Ellipsis","False","None","NotImplemented","True"],type:["Any","Callable","Coroutine","Dict","List","Literal","Generic","Optional","Sequence","Set","Tuple","Type","Union"]},u={className:"meta",begin:/^(>>>|\.\.\.) /},h={className:"subst",begin:/\{/,end:/\}/,keywords:c,illegal:/#/},p={begin:/\{\{/,relevance:0},m={className:"string",contains:[e.BACKSLASH_ESCAPE],variants:[{begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?'''/,end:/'''/,contains:[e.BACKSLASH_ESCAPE,u],relevance:10},{begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?"""/,end:/"""/,contains:[e.BACKSLASH_ESCAPE,u],relevance:10},{begin:/([fFtT][rR]|[rR][fFtT]|[fFtT])'''/,end:/'''/,contains:[e.BACKSLASH_ESCAPE,u,p,h]},{begin:/([fFtT][rR]|[rR][fFtT]|[fFtT])"""/,end:/"""/,contains:[e.BACKSLASH_ESCAPE,u,p,h]},{begin:/([uU]|[rR])'/,end:/'/,relevance:10},{begin:/([uU]|[rR])"/,end:/"/,relevance:10},{begin:/([bB]|[bB][rR]|[rR][bB])'/,end:/'/},{begin:/([bB]|[bB][rR]|[rR][bB])"/,end:/"/},{begin:/([fFtT][rR]|[rR][fFtT]|[fFtT])'/,end:/'/,contains:[e.BACKSLASH_ESCAPE,p,h]},{begin:/([fFtT][rR]|[rR][fFtT]|[fFtT])"/,end:/"/,contains:[e.BACKSLASH_ESCAPE,p,h]},e.APOS_STRING_MODE,e.QUOTE_STRING_MODE]},k="[0-9](_?[0-9])*",g=`(\\b(${k}))?\\.(${k})|\\b(${k})\\.`,y=`\\b|${r.join("|")}`,b={className:"number",relevance:0,variants:[{begin:`(\\b(${k})|(${g}))[eE][+-]?(${k})[jJ]?(?=${y})`},{begin:`(${g})[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(${k})[jJ](?=${y})`}]},S={className:"comment",begin:t.lookahead(/# type:/),end:/$/,keywords:c,contains:[{begin:/# type:/},{begin:/#/,end:/\b\B/,endsWithParent:!0}]},j={className:"params",variants:[{className:"",begin:/\(\s*\)/,skip:!0},{begin:/\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:c,contains:["self",u,b,m,e.HASH_COMMENT_MODE]}]};return h.contains=[m,b,u],{name:"Python",aliases:["py","gyp","ipython"],unicodeRegex:!0,keywords:c,illegal:/(<\/|\?)|=>/,contains:[u,b,{scope:"variable.language",match:/\bself\b/},{beginKeywords:"if",relevance:0},{match:/\bor\b/,scope:"keyword"},m,S,e.HASH_COMMENT_MODE,{match:[/\bdef/,/\s+/,n],scope:{1:"keyword",3:"title.function"},contains:[j]},{variants:[{match:[/\bclass/,/\s+/,n,/\s*/,/\(\s*/,n,/\s*\)/]},{match:[/\bclass/,/\s+/,n]}],scope:{1:"keyword",3:"title.class",6:"title.class.inherited"}},{className:"meta",begin:/^[\t ]*@/,end:/(?=#)|$/,contains:[b,j,m]}]}}function c6(e){const t=e.regex,n=/(r#)?/,r=t.concat(n,e.UNDERSCORE_IDENT_RE),o=t.concat(n,e.IDENT_RE),i={scope:"title.function.invoke",relevance:0,begin:t.concat(/\b/,/(?!(?:let|for|while|if|else|match)\b)/,o,t.lookahead(/\s*\(/))},l="([ui](8|16|32|64|128|size)|f(16|32|64|128))?",c=["abstract","as","async","await","become","box","break","const","continue","crate","do","dyn","else","enum","extern","false","final","fn","for","if","impl","in","let","loop","macro","match","mod","move","mut","override","priv","pub","raw","ref","return","self","Self","static","struct","super","trait","true","try","type","typeof","union","unsafe","unsized","use","virtual","where","while","yield"],u=["true","false","Some","None","Ok","Err"],h=["drop ","Copy","Send","Sized","Sync","Drop","Fn","FnMut","FnOnce","ToOwned","Clone","Debug","PartialEq","PartialOrd","Eq","Ord","AsRef","AsMut","Into","From","Default","Iterator","Extend","IntoIterator","DoubleEndedIterator","ExactSizeIterator","SliceConcatExt","ToString","assert!","assert_eq!","bitflags!","bytes!","cfg!","col!","concat!","concat_idents!","debug_assert!","debug_assert_eq!","env!","eprintln!","panic!","file!","format!","format_args!","include_bytes!","include_str!","line!","local_data_key!","module_path!","option_env!","print!","println!","select!","stringify!","try!","unimplemented!","unreachable!","vec!","write!","writeln!","macro_rules!","assert_ne!","debug_assert_ne!"],p=["i8","i16","i32","i64","i128","isize","u8","u16","u32","u64","u128","usize","f16","f32","f64","f128","str","char","bool","Box","Option","Result","String","Vec"];return{name:"Rust",aliases:["rs"],keywords:{$pattern:e.IDENT_RE+"!?",type:p,keyword:c,literal:u,built_in:h},illegal:"</",contains:[e.C_LINE_COMMENT_MODE,e.COMMENT("/\\*","\\*/",{contains:["self"]}),e.inherit(e.QUOTE_STRING_MODE,{begin:/b?"/,illegal:null}),{scope:"symbol",begin:/'[a-zA-Z_][a-zA-Z0-9_]*(?!')/},{scope:"string",variants:[{begin:/b?r(#*)"(.|\n)*?"\1(?!#)/},{begin:/b?'/,end:/'/,contains:[{scope:"char.escape",match:/\\('|"|\\|\w|x\w{2}|u\w{4}|U\w{8})/}]}]},{scope:"number",variants:[{begin:"\\b0b([01_]+)"+l},{begin:"\\b0o([0-7_]+)"+l},{begin:"\\b0x([A-Fa-f0-9_]+)"+l},{begin:"\\b(\\d[\\d_]*(\\.[0-9_]+)?([eE][+-]?[0-9_]+)?)"+l}],relevance:0},{begin:[/\bsafe/,/\s+/,/extern/],scope:{1:"keyword",3:"keyword"}},{begin:[/fn/,/\s+/,r],scope:{1:"keyword",3:"title.function"}},{scope:"meta",begin:"#!?\\[",end:"\\]",contains:[{scope:"string",begin:/"/,end:/"/,contains:[e.BACKSLASH_ESCAPE]}]},{begin:[/let/,/\s+/,/(?:mut\s+)?/,r],scope:{1:"keyword",3:"keyword",4:"variable"}},{begin:[/for/,/\s+/,r,/\s+/,/in/],scope:{1:"keyword",3:"variable",5:"keyword"}},{begin:[/type/,/\s+/,r],scope:{1:"keyword",3:"title.class"}},{begin:[/(?:trait|enum|struct|union|impl|for)/,/\s+/,r],scope:{1:"keyword",3:"title.class"}},{begin:e.IDENT_RE+"::",keywords:{keyword:"Self",built_in:h,type:p}},{scope:"punctuation",begin:"->"},i]}}const cf="[A-Za-z$_][0-9A-Za-z$_]*",W_=["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"],K_=["true","false","null","undefined","NaN","Infinity"],Z_=["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"],q_=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],G_=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],V_=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","self","global"],Y_=[].concat(G_,Z_,q_);function u6(e){const t=e.regex,n=(B,{after:ee})=>{const J="</"+B[0].slice(1);return B.input.indexOf(J,ee)!==-1},r=cf,o={begin:"<>",end:"</>"},i=/<[A-Za-z0-9\\._:-]+\s*\/>/,l={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(B,ee)=>{const J=B[0].length+B.index,W=B.input[J];if(W==="<"||W===","){ee.ignoreMatch();return}W===">"&&(n(B,{after:J})||ee.ignoreMatch());let ie;const Te=B.input.substring(J);if(ie=Te.match(/^\s*=/)){ee.ignoreMatch();return}if((ie=Te.match(/^\s+extends\s+/))&&ie.index===0){ee.ignoreMatch();return}}},c={$pattern:cf,keyword:W_,literal:K_,built_in:Y_,"variable.language":V_},u="[0-9](_?[0-9])*",h=`\\.(${u})`,p="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",m={className:"number",variants:[{begin:`(\\b(${p})((${h})|\\.)?|(${h}))[eE][+-]?(${u})\\b`},{begin:`\\b(${p})\\b((${h})\\b|\\.)?|(${h})\\b`},{begin:"\\b(0|[1-9](_?[0-9])*)n\\b"},{begin:"\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*n?\\b"},{begin:"\\b0[bB][0-1](_?[0-1])*n?\\b"},{begin:"\\b0[oO][0-7](_?[0-7])*n?\\b"},{begin:"\\b0[0-7]+n?\\b"}],relevance:0},k={className:"subst",begin:"\\$\\{",end:"\\}",keywords:c,contains:[]},g={begin:".?html`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,k],subLanguage:"xml"}},y={begin:".?css`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,k],subLanguage:"css"}},b={begin:".?gql`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,k],subLanguage:"graphql"}},S={className:"string",begin:"`",end:"`",contains:[e.BACKSLASH_ESCAPE,k]},E={className:"comment",variants:[e.COMMENT(/\/\*\*(?!\/)/,"\\*/",{relevance:0,contains:[{begin:"(?=@[A-Za-z]+)",relevance:0,contains:[{className:"doctag",begin:"@[A-Za-z]+"},{className:"type",begin:"\\{",end:"\\}",excludeEnd:!0,excludeBegin:!0,relevance:0},{className:"variable",begin:r+"(?=\\s*(-)|$)",endsParent:!0,relevance:0},{begin:/(?=[^\n])\s/,relevance:0}]}]}),e.C_BLOCK_COMMENT_MODE,e.C_LINE_COMMENT_MODE]},N=[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,g,y,b,S,{match:/\$\d+/},m];k.contains=N.concat({begin:/\{/,end:/\}/,keywords:c,contains:["self"].concat(N)});const A=[].concat(E,k.contains),O=A.concat([{begin:/(\s*)\(/,end:/\)/,keywords:c,contains:["self"].concat(A)}]),P={className:"params",begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:c,contains:O},R={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"}}]},T={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:{_:[...Z_,...q_]}},$={label:"use_strict",className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},D={variants:[{match:[/function/,/\s+/,r,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:"keyword",3:"title.function"},label:"func.def",contains:[P],illegal:/%/},z={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"};function V(B){return t.concat("(?!",B.join("|"),")")}const se={match:t.concat(/\b/,V([...G_,"super","import","await"].map(B=>`${B}\\s*\\(`)),r,t.lookahead(/\s*\(/)),className:"title.function",relevance:0},I={begin:t.concat(/\./,t.lookahead(t.concat(r,/(?![0-9A-Za-z$_(])/))),end:r,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},ne={match:[/get|set/,/\s+/,r,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},P]},we="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+e.UNDERSCORE_IDENT_RE+")\\s*=>",K={match:[/const|var|let/,/\s+/,r,/\s*/,/=\s*/,/(async\s*)?/,t.lookahead(we)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[P]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:c,exports:{PARAMS_CONTAINS:O,CLASS_REFERENCE:T},illegal:/#(?![$_A-Za-z])/,contains:[e.SHEBANG({label:"shebang",binary:"node",relevance:5}),$,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,g,y,b,S,E,{match:/\$\d+/},m,T,{scope:"attr",match:r+t.lookahead(":"),relevance:0},K,{begin:"("+e.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",relevance:0,contains:[E,e.REGEXP_MODE,{className:"function",begin:we,returnBegin:!0,end:"\\s*=>",contains:[{className:"params",variants:[{begin:e.UNDERSCORE_IDENT_RE,relevance:0},{className:null,begin:/\(\s*\)/,skip:!0},{begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:c,contains:O}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:o.begin,end:o.end},{match:i},{begin:l.begin,"on:begin":l.isTrulyOpeningTag,end:l.end}],subLanguage:"xml",contains:[{begin:l.begin,end:l.end,skip:!0,contains:["self"]}]}]},D,{beginKeywords:"while if switch catch for"},{begin:"\\b(?!function)"+e.UNDERSCORE_IDENT_RE+"\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",returnBegin:!0,label:"func.def",contains:[P,e.inherit(e.TITLE_MODE,{begin:r,className:"title.function"})]},{match:/\.\.\./,relevance:0},I,{match:"\\$"+r,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[P]},se,z,R,ne,{match:/\$[(.]/}]}}function d6(e){const t=e.regex,n=u6(e),r=cf,o=["any","void","number","boolean","string","object","never","symbol","bigint","unknown"],i={begin:[/namespace/,/\s+/,e.IDENT_RE],beginScope:{1:"keyword",3:"title.class"}},l={beginKeywords:"interface",end:/\{/,excludeEnd:!0,keywords:{keyword:"interface extends",built_in:o},contains:[n.exports.CLASS_REFERENCE]},c={className:"meta",relevance:10,begin:/^\s*['"]use strict['"]/},u=["type","interface","public","private","protected","implements","declare","abstract","readonly","enum","override","satisfies"],h={$pattern:cf,keyword:W_.concat(u),literal:K_,built_in:Y_.concat(o),"variable.language":V_},p={className:"meta",begin:"@"+r},m=(b,S,j)=>{const E=b.contains.findIndex(N=>N.label===S);if(E===-1)throw new Error("can not find mode to replace");b.contains.splice(E,1,j)};Object.assign(n.keywords,h),n.exports.PARAMS_CONTAINS.push(p);const k=n.contains.find(b=>b.scope==="attr"),g=Object.assign({},k,{match:t.concat(r,t.lookahead(/\s*\?:/))});n.exports.PARAMS_CONTAINS.push([n.exports.CLASS_REFERENCE,k,g]),n.contains=n.contains.concat([p,i,l,g]),m(n,"shebang",e.SHEBANG()),m(n,"use_strict",c);const y=n.contains.find(b=>b.label==="func.def");return y.relevance=0,Object.assign(n,{name:"TypeScript",aliases:["ts","tsx","mts","cts"]}),n}function f6(e){const t=e.regex,n=t.concat(/[\p{L}_]/u,t.optional(/[\p{L}0-9_.-]*:/u),/[\p{L}0-9_.-]*/u),r=/[\p{L}0-9._:-]+/u,o={className:"symbol",begin:/&[a-z]+;|&#[0-9]+;|&#x[a-f0-9]+;/},i={begin:/\s/,contains:[{className:"keyword",begin:/#?[a-z_][a-z1-9_-]+/,illegal:/\n/}]},l=e.inherit(i,{begin:/\(/,end:/\)/}),c=e.inherit(e.APOS_STRING_MODE,{className:"string"}),u=e.inherit(e.QUOTE_STRING_MODE,{className:"string"}),h={endsWithParent:!0,illegal:/</,relevance:0,contains:[{className:"attr",begin:r,relevance:0},{begin:/=\s*/,relevance:0,contains:[{className:"string",endsParent:!0,variants:[{begin:/"/,end:/"/,contains:[o]},{begin:/'/,end:/'/,contains:[o]},{begin:/[^\s"'=<>`]+/}]}]}]};return{name:"HTML, XML",aliases:["html","xhtml","rss","atom","xjb","xsd","xsl","plist","wsf","svg"],case_insensitive:!0,unicodeRegex:!0,contains:[{className:"meta",begin:/<![a-z]/,end:/>/,relevance:10,contains:[i,u,c,l,{begin:/\[/,end:/\]/,contains:[{className:"meta",begin:/<![a-z]/,end:/>/,contains:[i,l,u,c]}]}]},e.COMMENT(/<!--/,/-->/,{relevance:10}),{begin:/<!\[CDATA\[/,end:/\]\]>/,relevance:10},o,{className:"meta",end:/\?>/,variants:[{begin:/<\?xml/,relevance:10,contains:[u]},{begin:/<\?[a-z][a-z0-9]+/}]},{className:"tag",begin:/<style(?=\s|>)/,end:/>/,keywords:{name:"style"},contains:[h],starts:{end:/<\/style>/,returnEnd:!0,subLanguage:"css"}},{className:"tag",begin:/<script(?=\s|>)/,end:/>/,keywords:{name:"script"},contains:[h],starts:{end:/<\/script>/,returnEnd:!0,subLanguage:"javascript"}},{className:"tag",begin:/<>|<\/>/},{className:"tag",begin:t.concat(/</,t.lookahead(t.concat(n,t.either(/\/>/,/>/,/\s/)))),end:/\/?>/,contains:[{className:"name",begin:n,relevance:0,starts:h}]},{className:"tag",begin:t.concat(/<\//,t.lookahead(t.concat(n,/>/))),contains:[{className:"name",begin:n,relevance:0},{begin:/>/,relevance:0,endsParent:!0}]}]}}function h6(e){const t="true false yes no null",n="[\\w#;/?:@&=+$,.~*'()[\\]]+",r={className:"attr",variants:[{begin:/[\w*@][\w*@ :()\./-]*:(?=[ \t]|$)/},{begin:/"[\w*@][\w*@ :()\./-]*":(?=[ \t]|$)/},{begin:/'[\w*@][\w*@ :()\./-]*':(?=[ \t]|$)/}]},o={className:"template-variable",variants:[{begin:/\{\{/,end:/\}\}/},{begin:/%\{/,end:/\}/}]},i={className:"string",relevance:0,begin:/'/,end:/'/,contains:[{match:/''/,scope:"char.escape",relevance:0}]},l={className:"string",relevance:0,variants:[{begin:/"/,end:/"/},{begin:/\S+/}],contains:[e.BACKSLASH_ESCAPE,o]},c=e.inherit(l,{variants:[{begin:/'/,end:/'/,contains:[{begin:/''/,relevance:0}]},{begin:/"/,end:/"/},{begin:/[^\s,{}[\]]+/}]}),k={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"},g={end:",",endsWithParent:!0,excludeEnd:!0,keywords:t,relevance:0},y={begin:/\{/,end:/\}/,contains:[g],illegal:"\\n",relevance:0},b={begin:"\\[",end:"\\]",contains:[g],illegal:"\\n",relevance:0},S=[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}},k,{className:"number",begin:e.C_NUMBER_RE+"\\b",relevance:0},y,b,i,l],j=[...S];return j.pop(),j.push(c),g.contains=j,{name:"YAML",case_insensitive:!0,aliases:["yml"],contains:S}}var Xp,ox;function p6(){if(ox)return Xp;ox=1;function e(Z){return Z instanceof Map?Z.clear=Z.delete=Z.set=function(){throw new Error("map is read-only")}:Z instanceof Set&&(Z.add=Z.clear=Z.delete=function(){throw new Error("set is read-only")}),Object.freeze(Z),Object.getOwnPropertyNames(Z).forEach(ge=>{const Oe=Z[ge],st=typeof Oe;(st==="object"||st==="function")&&!Object.isFrozen(Oe)&&e(Oe)}),Z}class t{constructor(ge){ge.data===void 0&&(ge.data={}),this.data=ge.data,this.isMatchIgnored=!1}ignoreMatch(){this.isMatchIgnored=!0}}function n(Z){return Z.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function r(Z,...ge){const Oe=Object.create(null);for(const st in Z)Oe[st]=Z[st];return ge.forEach(function(st){for(const Et in st)Oe[Et]=st[Et]}),Oe}const o="</span>",i=Z=>!!Z.scope,l=(Z,{prefix:ge})=>{if(Z.startsWith("language:"))return Z.replace("language:","language-");if(Z.includes(".")){const Oe=Z.split(".");return[`${ge}${Oe.shift()}`,...Oe.map((st,Et)=>`${st}${"_".repeat(Et+1)}`)].join(" ")}return`${ge}${Z}`};class c{constructor(ge,Oe){this.buffer="",this.classPrefix=Oe.classPrefix,ge.walk(this)}addText(ge){this.buffer+=n(ge)}openNode(ge){if(!i(ge))return;const Oe=l(ge.scope,{prefix:this.classPrefix});this.span(Oe)}closeNode(ge){i(ge)&&(this.buffer+=o)}value(){return this.buffer}span(ge){this.buffer+=`<span class="${ge}">`}}const u=(Z={})=>{const ge={children:[]};return Object.assign(ge,Z),ge};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(ge){this.top.children.push(ge)}openNode(ge){const Oe=u({scope:ge});this.add(Oe),this.stack.push(Oe)}closeNode(){if(this.stack.length>1)return this.stack.pop()}closeAllNodes(){for(;this.closeNode(););}toJSON(){return JSON.stringify(this.rootNode,null,4)}walk(ge){return this.constructor._walk(ge,this.rootNode)}static _walk(ge,Oe){return typeof Oe=="string"?ge.addText(Oe):Oe.children&&(ge.openNode(Oe),Oe.children.forEach(st=>this._walk(ge,st)),ge.closeNode(Oe)),ge}static _collapse(ge){typeof ge!="string"&&ge.children&&(ge.children.every(Oe=>typeof Oe=="string")?ge.children=[ge.children.join("")]:ge.children.forEach(Oe=>{h._collapse(Oe)}))}}class p extends h{constructor(ge){super(),this.options=ge}addText(ge){ge!==""&&this.add(ge)}startScope(ge){this.openNode(ge)}endScope(){this.closeNode()}__addSublanguage(ge,Oe){const st=ge.root;Oe&&(st.scope=`language:${Oe}`),this.add(st)}toHTML(){return new c(this,this.options).value()}finalize(){return this.closeAllNodes(),!0}}function m(Z){return Z?typeof Z=="string"?Z:Z.source:null}function k(Z){return b("(?=",Z,")")}function g(Z){return b("(?:",Z,")*")}function y(Z){return b("(?:",Z,")?")}function b(...Z){return Z.map(Oe=>m(Oe)).join("")}function S(Z){const ge=Z[Z.length-1];return typeof ge=="object"&&ge.constructor===Object?(Z.splice(Z.length-1,1),ge):{}}function j(...Z){return"("+(S(Z).capture?"":"?:")+Z.map(st=>m(st)).join("|")+")"}function E(Z){return new RegExp(Z.toString()+"|").exec("").length-1}function N(Z,ge){const Oe=Z&&Z.exec(ge);return Oe&&Oe.index===0}const A=/\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)|\\./;function O(Z,{joinWith:ge}){let Oe=0;return Z.map(st=>{Oe+=1;const Et=Oe;let Mt=m(st),ze="";for(;Mt.length>0;){const Se=A.exec(Mt);if(!Se){ze+=Mt;break}ze+=Mt.substring(0,Se.index),Mt=Mt.substring(Se.index+Se[0].length),Se[0][0]==="\\"&&Se[1]?ze+="\\"+String(Number(Se[1])+Et):(ze+=Se[0],Se[0]==="("&&Oe++)}return ze}).map(st=>`(${st})`).join(ge)}const P=/\b\B/,R="[a-zA-Z]\\w*",T="[a-zA-Z_]\\w*",$="\\b\\d+(\\.\\d+)?",D="(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)",z="\\b(0b[01]+)",V="!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~",se=(Z={})=>{const ge=/^#![ ]*\//;return Z.binary&&(Z.begin=b(ge,/.*\b/,Z.binary,/\b.*/)),r({scope:"meta",begin:ge,end:/$/,relevance:0,"on:begin":(Oe,st)=>{Oe.index!==0&&st.ignoreMatch()}},Z)},I={begin:"\\\\[\\s\\S]",relevance:0},ne={scope:"string",begin:"'",end:"'",illegal:"\\n",contains:[I]},we={scope:"string",begin:'"',end:'"',illegal:"\\n",contains:[I]},K={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/},B=function(Z,ge,Oe={}){const st=r({scope:"comment",begin:Z,end:ge,contains:[]},Oe);st.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 Et=j("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 st.contains.push({begin:b(/[ ]+/,"(",Et,/[.]?[:]?([.][ ]|[ ])/,"){3}")}),st},ee=B("//","$"),J=B("/\\*","\\*/"),W=B("#","$"),ie={scope:"number",begin:$,relevance:0},Te={scope:"number",begin:D,relevance:0},Ce={scope:"number",begin:z,relevance:0},de={scope:"regexp",begin:/\/(?=[^/\n]*\/)/,end:/\/[gimuy]*/,contains:[I,{begin:/\[/,end:/\]/,relevance:0,contains:[I]}]},be={scope:"title",begin:R,relevance:0},le={scope:"title",begin:T,relevance:0},G={begin:"\\.\\s*"+T,relevance:0};var oe=Object.freeze({__proto__:null,APOS_STRING_MODE:ne,BACKSLASH_ESCAPE:I,BINARY_NUMBER_MODE:Ce,BINARY_NUMBER_RE:z,COMMENT:B,C_BLOCK_COMMENT_MODE:J,C_LINE_COMMENT_MODE:ee,C_NUMBER_MODE:Te,C_NUMBER_RE:D,END_SAME_AS_BEGIN:function(Z){return Object.assign(Z,{"on:begin":(ge,Oe)=>{Oe.data._beginMatch=ge[1]},"on:end":(ge,Oe)=>{Oe.data._beginMatch!==ge[1]&&Oe.ignoreMatch()}})},HASH_COMMENT_MODE:W,IDENT_RE:R,MATCH_NOTHING_RE:P,METHOD_GUARD:G,NUMBER_MODE:ie,NUMBER_RE:$,PHRASAL_WORDS_MODE:K,QUOTE_STRING_MODE:we,REGEXP_MODE:de,RE_STARTERS_RE:V,SHEBANG:se,TITLE_MODE:be,UNDERSCORE_IDENT_RE:T,UNDERSCORE_TITLE_MODE:le});function re(Z,ge){Z.input[Z.index-1]==="."&&ge.ignoreMatch()}function Le(Z,ge){Z.className!==void 0&&(Z.scope=Z.className,delete Z.className)}function Ue(Z,ge){ge&&Z.beginKeywords&&(Z.begin="\\b("+Z.beginKeywords.split(" ").join("|")+")(?!\\.)(?=\\b|\\s)",Z.__beforeBegin=re,Z.keywords=Z.keywords||Z.beginKeywords,delete Z.beginKeywords,Z.relevance===void 0&&(Z.relevance=0))}function _e(Z,ge){Array.isArray(Z.illegal)&&(Z.illegal=j(...Z.illegal))}function je(Z,ge){if(Z.match){if(Z.begin||Z.end)throw new Error("begin & end are not supported with match");Z.begin=Z.match,delete Z.match}}function Ne(Z,ge){Z.relevance===void 0&&(Z.relevance=1)}const qe=(Z,ge)=>{if(!Z.beforeMatch)return;if(Z.starts)throw new Error("beforeMatch cannot be used with starts");const Oe=Object.assign({},Z);Object.keys(Z).forEach(st=>{delete Z[st]}),Z.keywords=Oe.keywords,Z.begin=b(Oe.beforeMatch,k(Oe.begin)),Z.starts={relevance:0,contains:[Object.assign(Oe,{endsParent:!0})]},Z.relevance=0,delete Oe.beforeMatch},Ft=["of","and","for","in","not","or","if","then","parent","list","value"],qt="keyword";function jt(Z,ge,Oe=qt){const st=Object.create(null);return typeof Z=="string"?Et(Oe,Z.split(" ")):Array.isArray(Z)?Et(Oe,Z):Object.keys(Z).forEach(function(Mt){Object.assign(st,jt(Z[Mt],ge,Mt))}),st;function Et(Mt,ze){ge&&(ze=ze.map(Se=>Se.toLowerCase())),ze.forEach(function(Se){const Ge=Se.split("|");st[Ge[0]]=[Mt,Ht(Ge[0],Ge[1])]})}}function Ht(Z,ge){return ge?Number(ge):sn(Z)?0:1}function sn(Z){return Ft.includes(Z.toLowerCase())}const Ct={},He=Z=>{console.error(Z)},Ze=(Z,...ge)=>{console.log(`WARN: ${Z}`,...ge)},At=(Z,ge)=>{Ct[`${Z}/${ge}`]||(console.log(`Deprecated as of ${Z}. ${ge}`),Ct[`${Z}/${ge}`]=!0)},_t=new Error;function kt(Z,ge,{key:Oe}){let st=0;const Et=Z[Oe],Mt={},ze={};for(let Se=1;Se<=ge.length;Se++)ze[Se+st]=Et[Se],Mt[Se+st]=!0,st+=E(ge[Se-1]);Z[Oe]=ze,Z[Oe]._emit=Mt,Z[Oe]._multi=!0}function Fn(Z){if(Array.isArray(Z.begin)){if(Z.skip||Z.excludeBegin||Z.returnBegin)throw He("skip, excludeBegin, returnBegin not compatible with beginScope: {}"),_t;if(typeof Z.beginScope!="object"||Z.beginScope===null)throw He("beginScope must be object"),_t;kt(Z,Z.begin,{key:"beginScope"}),Z.begin=O(Z.begin,{joinWith:""})}}function un(Z){if(Array.isArray(Z.end)){if(Z.skip||Z.excludeEnd||Z.returnEnd)throw He("skip, excludeEnd, returnEnd not compatible with endScope: {}"),_t;if(typeof Z.endScope!="object"||Z.endScope===null)throw He("endScope must be object"),_t;kt(Z,Z.end,{key:"endScope"}),Z.end=O(Z.end,{joinWith:""})}}function xn(Z){Z.scope&&typeof Z.scope=="object"&&Z.scope!==null&&(Z.beginScope=Z.scope,delete Z.scope)}function $t(Z){xn(Z),typeof Z.beginScope=="string"&&(Z.beginScope={_wrap:Z.beginScope}),typeof Z.endScope=="string"&&(Z.endScope={_wrap:Z.endScope}),Fn(Z),un(Z)}function Tn(Z){function ge(ze,Se){return new RegExp(m(ze),"m"+(Z.case_insensitive?"i":"")+(Z.unicodeRegex?"u":"")+(Se?"g":""))}class Oe{constructor(){this.matchIndexes={},this.regexes=[],this.matchAt=1,this.position=0}addRule(Se,Ge){Ge.position=this.position++,this.matchIndexes[this.matchAt]=Ge,this.regexes.push([Ge,Se]),this.matchAt+=E(Se)+1}compile(){this.regexes.length===0&&(this.exec=()=>null);const Se=this.regexes.map(Ge=>Ge[1]);this.matcherRe=ge(O(Se,{joinWith:"|"}),!0),this.lastIndex=0}exec(Se){this.matcherRe.lastIndex=this.lastIndex;const Ge=this.matcherRe.exec(Se);if(!Ge)return null;const Kt=Ge.findIndex((mn,Yt)=>Yt>0&&mn!==void 0),Qe=this.matchIndexes[Kt];return Ge.splice(0,Kt),Object.assign(Ge,Qe)}}class st{constructor(){this.rules=[],this.multiRegexes=[],this.count=0,this.lastIndex=0,this.regexIndex=0}getMatcher(Se){if(this.multiRegexes[Se])return this.multiRegexes[Se];const Ge=new Oe;return this.rules.slice(Se).forEach(([Kt,Qe])=>Ge.addRule(Kt,Qe)),Ge.compile(),this.multiRegexes[Se]=Ge,Ge}resumingScanAtSamePosition(){return this.regexIndex!==0}considerAll(){this.regexIndex=0}addRule(Se,Ge){this.rules.push([Se,Ge]),Ge.type==="begin"&&this.count++}exec(Se){const Ge=this.getMatcher(this.regexIndex);Ge.lastIndex=this.lastIndex;let Kt=Ge.exec(Se);if(this.resumingScanAtSamePosition()&&!(Kt&&Kt.index===this.lastIndex)){const Qe=this.getMatcher(0);Qe.lastIndex=this.lastIndex+1,Kt=Qe.exec(Se)}return Kt&&(this.regexIndex+=Kt.position+1,this.regexIndex===this.count&&this.considerAll()),Kt}}function Et(ze){const Se=new st;return ze.contains.forEach(Ge=>Se.addRule(Ge.begin,{rule:Ge,type:"begin"})),ze.terminatorEnd&&Se.addRule(ze.terminatorEnd,{type:"end"}),ze.illegal&&Se.addRule(ze.illegal,{type:"illegal"}),Se}function Mt(ze,Se){const Ge=ze;if(ze.isCompiled)return Ge;[Le,je,$t,qe].forEach(Qe=>Qe(ze,Se)),Z.compilerExtensions.forEach(Qe=>Qe(ze,Se)),ze.__beforeBegin=null,[Ue,_e,Ne].forEach(Qe=>Qe(ze,Se)),ze.isCompiled=!0;let Kt=null;return typeof ze.keywords=="object"&&ze.keywords.$pattern&&(ze.keywords=Object.assign({},ze.keywords),Kt=ze.keywords.$pattern,delete ze.keywords.$pattern),Kt=Kt||/\w+/,ze.keywords&&(ze.keywords=jt(ze.keywords,Z.case_insensitive)),Ge.keywordPatternRe=ge(Kt,!0),Se&&(ze.begin||(ze.begin=/\B|\b/),Ge.beginRe=ge(Ge.begin),!ze.end&&!ze.endsWithParent&&(ze.end=/\B|\b/),ze.end&&(Ge.endRe=ge(Ge.end)),Ge.terminatorEnd=m(Ge.end)||"",ze.endsWithParent&&Se.terminatorEnd&&(Ge.terminatorEnd+=(ze.end?"|":"")+Se.terminatorEnd)),ze.illegal&&(Ge.illegalRe=ge(ze.illegal)),ze.contains||(ze.contains=[]),ze.contains=[].concat(...ze.contains.map(function(Qe){return pe(Qe==="self"?ze:Qe)})),ze.contains.forEach(function(Qe){Mt(Qe,Ge)}),ze.starts&&Mt(ze.starts,Se),Ge.matcher=Et(Ge),Ge}if(Z.compilerExtensions||(Z.compilerExtensions=[]),Z.contains&&Z.contains.includes("self"))throw new Error("ERR: contains `self` is not supported at the top-level of a language. See documentation.");return Z.classNameAliases=r(Z.classNameAliases||{}),Mt(Z)}function Y(Z){return Z?Z.endsWithParent||Y(Z.starts):!1}function pe(Z){return Z.variants&&!Z.cachedVariants&&(Z.cachedVariants=Z.variants.map(function(ge){return r(Z,{variants:null},ge)})),Z.cachedVariants?Z.cachedVariants:Y(Z)?r(Z,{starts:Z.starts?r(Z.starts):null}):Object.isFrozen(Z)?r(Z):Z}var nt="11.11.2";class dt extends Error{constructor(ge,Oe){super(ge),this.name="HTMLInjectionError",this.html=Oe}}const Bt=n,Ot=r,Ee=Symbol("nomatch"),$e=7,Wt=function(Z){const ge=Object.create(null),Oe=Object.create(null),st=[];let Et=!0;const Mt="Could not find the language '{}', did you forget to load/include a language module?",ze={disableAutodetect:!0,name:"Plain text",contains:[]};let Se={ignoreUnescapedHTML:!1,throwUnescapedHTML:!1,noHighlightRe:/^(no-?highlight)$/i,languageDetectRe:/\blang(?:uage)?-([\w-]+)\b/i,classPrefix:"hljs-",cssSelector:"pre code",languages:null,__emitter:p};function Ge(ve){return Se.noHighlightRe.test(ve)}function Kt(ve){let Ve=ve.className+" ";Ve+=ve.parentNode?ve.parentNode.className:"";const We=Se.languageDetectRe.exec(Ve);if(We){const mt=tt(We[1]);return mt||(Ze(Mt.replace("{}",We[1])),Ze("Falling back to no-highlight mode for this block.",ve)),mt?We[1]:"no-highlight"}return Ve.split(/\s+/).find(mt=>Ge(mt)||tt(mt))}function Qe(ve,Ve,We){let mt="",ln="";typeof Ve=="object"?(mt=ve,We=Ve.ignoreIllegals,ln=Ve.language):(At("10.7.0","highlight(lang, code, ...args) has been deprecated."),At("10.7.0",`Please use highlight(code, options) instead.
|
|
198
|
+
https://github.com/highlightjs/highlight.js/issues/2277`),ln=ve,mt=Ve),We===void 0&&(We=!0);const yn={code:mt,language:ln};Cn("before:highlight",yn);const H=yn.result?yn.result:mn(yn.language,yn.code,We);return H.code=yn.code,Cn("after:highlight",H),H}function mn(ve,Ve,We,mt){const ln=Object.create(null);function yn(F,ae){return F.keywords[ae]}function H(){if(!wt.keywords){An.addText(on);return}let F=0;wt.keywordPatternRe.lastIndex=0;let ae=wt.keywordPatternRe.exec(on),ye="";for(;ae;){ye+=on.substring(F,ae.index);const Me=Er.case_insensitive?ae[0].toLowerCase():ae[0],Ye=yn(wt,Me);if(Ye){const[yt,gn]=Ye;if(An.addText(ye),ye="",ln[Me]=(ln[Me]||0)+1,ln[Me]<=$e&&(Dt+=gn),yt.startsWith("_"))ye+=ae[0];else{const Xn=Er.classNameAliases[yt]||yt;lt(ae[0],Xn)}}else ye+=ae[0];F=wt.keywordPatternRe.lastIndex,ae=wt.keywordPatternRe.exec(on)}ye+=on.substring(F),An.addText(ye)}function me(){if(on==="")return;let F=null;if(typeof wt.subLanguage=="string"){if(!ge[wt.subLanguage]){An.addText(on);return}F=mn(wt.subLanguage,on,!0,$o[wt.subLanguage]),$o[wt.subLanguage]=F._top}else F=En(on,wt.subLanguage.length?wt.subLanguage:null);wt.relevance>0&&(Dt+=F.relevance),An.__addSublanguage(F._emitter,F.language)}function Be(){wt.subLanguage!=null?me():H(),on=""}function lt(F,ae){F!==""&&(An.startScope(ae),An.addText(F),An.endScope())}function Nt(F,ae){let ye=1;const Me=ae.length-1;for(;ye<=Me;){if(!F._emit[ye]){ye++;continue}const Ye=Er.classNameAliases[F[ye]]||F[ye],yt=ae[ye];Ye?lt(yt,Ye):(on=yt,H(),on=""),ye++}}function Xt(F,ae){return F.scope&&typeof F.scope=="string"&&An.openNode(Er.classNameAliases[F.scope]||F.scope),F.beginScope&&(F.beginScope._wrap?(lt(on,Er.classNameAliases[F.beginScope._wrap]||F.beginScope._wrap),on=""):F.beginScope._multi&&(Nt(F.beginScope,ae),on="")),wt=Object.create(F,{parent:{value:wt}}),wt}function Bn(F,ae,ye){let Me=N(F.endRe,ye);if(Me){if(F["on:end"]){const Ye=new t(F);F["on:end"](ae,Ye),Ye.isMatchIgnored&&(Me=!1)}if(Me){for(;F.endsParent&&F.parent;)F=F.parent;return F}}if(F.endsWithParent)return Bn(F.parent,ae,ye)}function Yn(F){return wt.matcher.regexIndex===0?(on+=F[0],1):(M=!0,0)}function Dr(F){const ae=F[0],ye=F.rule,Me=new t(ye),Ye=[ye.__beforeBegin,ye["on:begin"]];for(const yt of Ye)if(yt&&(yt(F,Me),Me.isMatchIgnored))return Yn(ae);return ye.skip?on+=ae:(ye.excludeBegin&&(on+=ae),Be(),!ye.returnBegin&&!ye.excludeBegin&&(on=ae)),Xt(ye,F),ye.returnBegin?0:ae.length}function zr(F){const ae=F[0],ye=Ve.substring(F.index),Me=Bn(wt,F,ye);if(!Me)return Ee;const Ye=wt;wt.endScope&&wt.endScope._wrap?(Be(),lt(ae,wt.endScope._wrap)):wt.endScope&&wt.endScope._multi?(Be(),Nt(wt.endScope,F)):Ye.skip?on+=ae:(Ye.returnEnd||Ye.excludeEnd||(on+=ae),Be(),Ye.excludeEnd&&(on=ae));do wt.scope&&An.closeNode(),!wt.skip&&!wt.subLanguage&&(Dt+=wt.relevance),wt=wt.parent;while(wt!==Me.parent);return Me.starts&&Xt(Me.starts,F),Ye.returnEnd?0:ae.length}function Ro(){const F=[];for(let ae=wt;ae!==Er;ae=ae.parent)ae.scope&&F.unshift(ae.scope);F.forEach(ae=>An.openNode(ae))}let xr={};function Zr(F,ae){const ye=ae&&ae[0];if(on+=F,ye==null)return Be(),0;if(xr.type==="begin"&&ae.type==="end"&&xr.index===ae.index&&ye===""){if(on+=Ve.slice(ae.index,ae.index+1),!Et){const Me=new Error(`0 width match regex (${ve})`);throw Me.languageName=ve,Me.badRule=xr.rule,Me}return 1}if(xr=ae,ae.type==="begin")return Dr(ae);if(ae.type==="illegal"&&!We){const Me=new Error('Illegal lexeme "'+ye+'" for mode "'+(wt.scope||"<unnamed>")+'"');throw Me.mode=wt,Me}else if(ae.type==="end"){const Me=zr(ae);if(Me!==Ee)return Me}if(ae.type==="illegal"&&ye==="")return ae.index===Ve.length||(on+=`
|
|
199
|
+
`),1;if(Ae>1e5&&Ae>ae.index*3)throw new Error("potential infinite loop, way more iterations than matches");return on+=ye,ye.length}const Er=tt(ve);if(!Er)throw He(Mt.replace("{}",ve)),new Error('Unknown language: "'+ve+'"');const qr=Tn(Er);let Qt="",wt=mt||qr;const $o={},An=new Se.__emitter(Se);Ro();let on="",Dt=0,nr=0,Ae=0,M=!1;try{if(Er.__emitTokens)Er.__emitTokens(Ve,An);else{for(wt.matcher.considerAll();;){Ae++,M?M=!1:wt.matcher.considerAll(),wt.matcher.lastIndex=nr;const F=wt.matcher.exec(Ve);if(!F)break;const ae=Ve.substring(nr,F.index),ye=Zr(ae,F);nr=F.index+ye}Zr(Ve.substring(nr))}return An.finalize(),Qt=An.toHTML(),{language:ve,value:Qt,relevance:Dt,illegal:!1,_emitter:An,_top:wt}}catch(F){if(F.message&&F.message.includes("Illegal"))return{language:ve,value:Bt(Ve),illegal:!0,relevance:0,_illegalBy:{message:F.message,index:nr,context:Ve.slice(nr-100,nr+100),mode:F.mode,resultSoFar:Qt},_emitter:An};if(Et)return{language:ve,value:Bt(Ve),illegal:!1,relevance:0,errorRaised:F,_emitter:An,_top:wt};throw F}}function Yt(ve){const Ve={value:Bt(ve),illegal:!1,relevance:0,_top:ze,_emitter:new Se.__emitter(Se)};return Ve._emitter.addText(ve),Ve}function En(ve,Ve){Ve=Ve||Se.languages||Object.keys(ge);const We=Yt(ve),mt=Ve.filter(tt).filter(dn).map(Be=>mn(Be,ve,!1));mt.unshift(We);const ln=mt.sort((Be,lt)=>{if(Be.relevance!==lt.relevance)return lt.relevance-Be.relevance;if(Be.language&<.language){if(tt(Be.language).supersetOf===lt.language)return 1;if(tt(lt.language).supersetOf===Be.language)return-1}return 0}),[yn,H]=ln,me=yn;return me.secondBest=H,me}function qn(ve,Ve,We){const mt=Ve&&Oe[Ve]||We;ve.classList.add("hljs"),ve.classList.add(`language-${mt}`)}function an(ve){let Ve=null;const We=Kt(ve);if(Ge(We))return;if(Cn("before:highlightElement",{el:ve,language:We}),ve.dataset.highlighted){console.log("Element previously highlighted. To highlight again, first unset `dataset.highlighted`.",ve);return}if(ve.children.length>0&&(Se.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(ve)),Se.throwUnescapedHTML))throw new dt("One of your code blocks includes unescaped HTML.",ve.innerHTML);Ve=ve;const mt=Ve.textContent,ln=We?Qe(mt,{language:We,ignoreIllegals:!0}):En(mt);ve.innerHTML=ln.value,ve.dataset.highlighted="yes",qn(ve,We,ln.language),ve.result={language:ln.language,re:ln.relevance,relevance:ln.relevance},ln.secondBest&&(ve.secondBest={language:ln.secondBest.language,relevance:ln.secondBest.relevance}),Cn("after:highlightElement",{el:ve,result:ln,text:mt})}function wn(ve){Se=Ot(Se,ve)}const mr=()=>{Gn(),At("10.6.0","initHighlighting() deprecated. Use highlightAll() now.")};function Mn(){Gn(),At("10.6.0","initHighlightingOnLoad() deprecated. Use highlightAll() now.")}let tn=!1;function Gn(){function ve(){Gn()}if(document.readyState==="loading"){tn||window.addEventListener("DOMContentLoaded",ve,!1),tn=!0;return}document.querySelectorAll(Se.cssSelector).forEach(an)}function nn(ve,Ve){let We=null;try{We=Ve(Z)}catch(mt){if(He("Language definition for '{}' could not be registered.".replace("{}",ve)),Et)He(mt);else throw mt;We=ze}We.name||(We.name=ve),ge[ve]=We,We.rawDefinition=Ve.bind(null,Z),We.aliases&&at(We.aliases,{languageName:ve})}function Q(ve){delete ge[ve];for(const Ve of Object.keys(Oe))Oe[Ve]===ve&&delete Oe[Ve]}function ke(){return Object.keys(ge)}function tt(ve){return ve=(ve||"").toLowerCase(),ge[ve]||ge[Oe[ve]]}function at(ve,{languageName:Ve}){typeof ve=="string"&&(ve=[ve]),ve.forEach(We=>{Oe[We.toLowerCase()]=Ve})}function dn(ve){const Ve=tt(ve);return Ve&&!Ve.disableAutodetect}function Gt(ve){ve["before:highlightBlock"]&&!ve["before:highlightElement"]&&(ve["before:highlightElement"]=Ve=>{ve["before:highlightBlock"](Object.assign({block:Ve.el},Ve))}),ve["after:highlightBlock"]&&!ve["after:highlightElement"]&&(ve["after:highlightElement"]=Ve=>{ve["after:highlightBlock"](Object.assign({block:Ve.el},Ve))})}function Tr(ve){Gt(ve),st.push(ve)}function Vn(ve){const Ve=st.indexOf(ve);Ve!==-1&&st.splice(Ve,1)}function Cn(ve,Ve){const We=ve;st.forEach(function(mt){mt[We]&&mt[We](Ve)})}function rn(ve){return At("10.7.0","highlightBlock will be removed entirely in v12.0"),At("10.7.0","Please use highlightElement now."),an(ve)}Object.assign(Z,{highlight:Qe,highlightAuto:En,highlightAll:Gn,highlightElement:an,highlightBlock:rn,configure:wn,initHighlighting:mr,initHighlightingOnLoad:Mn,registerLanguage:nn,unregisterLanguage:Q,listLanguages:ke,getLanguage:tt,registerAliases:at,autoDetection:dn,inherit:Ot,addPlugin:Tr,removePlugin:Vn}),Z.debugMode=function(){Et=!1},Z.safeMode=function(){Et=!0},Z.versionString=nt,Z.regex={concat:b,lookahead:k,either:j,optional:y,anyNumberOfTimes:g};for(const ve in oe)typeof oe[ve]=="object"&&e(oe[ve]);return Object.assign(Z,oe),Z},ft=Wt({});return ft.newInstance=()=>Wt({}),Xp=ft,ft.HighlightJS=ft,ft.default=ft,Xp}var m6=p6();const g6=Qx(m6),sx={},k6="hljs-";function w6(e){const t=g6.newInstance();return e&&i(e),{highlight:n,highlightAuto:r,listLanguages:o,register:i,registerAlias:l,registered:c};function n(u,h,p){const m=p||sx,k=typeof m.prefix=="string"?m.prefix:k6;if(!t.getLanguage(u))throw new Error("Unknown language: `"+u+"` is not registered");t.configure({__emitter:y6,classPrefix:k});const g=t.highlight(h,{ignoreIllegals:!0,language:u});if(g.errorRaised)throw new Error("Could not highlight with `Highlight.js`",{cause:g.errorRaised});const y=g._emitter.root,b=y.data;return b.language=g.language,b.relevance=g.relevance,y}function r(u,h){const m=(h||sx).subset||o();let k=-1,g=0,y;for(;++k<m.length;){const b=m[k];if(!t.getLanguage(b))continue;const S=n(b,u,h);S.data&&S.data.relevance!==void 0&&S.data.relevance>g&&(g=S.data.relevance,y=S)}return y||{type:"root",children:[],data:{language:void 0,relevance:g}}}function o(){return t.listLanguages()}function i(u,h){if(typeof u=="string")t.registerLanguage(u,h);else{let p;for(p in u)Object.hasOwn(u,p)&&t.registerLanguage(p,u[p])}}function l(u,h){if(typeof u=="string")t.registerAliases(typeof h=="string"?h:[...h],{languageName:u});else{let p;for(p in u)if(Object.hasOwn(u,p)){const m=u[p];t.registerAliases(typeof m=="string"?m:[...m],{languageName:p})}}}function c(u){return!!t.getLanguage(u)}}class y6{constructor(t){this.options=t,this.root={type:"root",children:[],data:{language:void 0,relevance:0}},this.stack=[this.root]}addText(t){if(t==="")return;const n=this.stack[this.stack.length-1],r=n.children[n.children.length-1];r&&r.type==="text"?r.value+=t:n.children.push({type:"text",value:t})}startScope(t){this.openNode(String(t))}endScope(){this.closeNode()}__addSublanguage(t,n){const r=this.stack[this.stack.length-1],o=t.root.children;n?r.children.push({type:"element",tagName:"span",properties:{className:[n]},children:o}):r.children.push(...o)}openNode(t){const n=this,r=t.split(".").map(function(l,c){return c?l+"_".repeat(c):n.options.classPrefix+l}),o=this.stack[this.stack.length-1],i={type:"element",tagName:"span",properties:{className:r},children:[]};o.children.push(i),this.stack.push(i)}closeNode(){this.stack.pop()}finalize(){}toHTML(){return""}}const X_=w6({bash:B5,css:Y5,go:X5,ini:Q5,javascript:r6,json:i6,markdown:a6,python:l6,rust:c6,typescript:d6,xml:f6,yaml:h6}),ix={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 Yk(e,t){const n=e&&(ix[e]??(X_.registered(e)?e:null));if(n)return n;const r=t.lastIndexOf("."),o=r<0?"":t.slice(r+1).toLowerCase();return(o?ix[o]:null)??null}const v6=/^(?:diff --git a\/\S+ b\/(\S+)|\+\+\+ (?:b\/)?(\S+))$/gm;function b6(e){const t=new Set;for(const n of e.matchAll(v6)){const r=n[1]??n[2]??"";r&&r!=="/dev/null"&&t.add(r)}return t.size===1?[...t][0]:""}const x6={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 Q_(e,t){const n=[[]],r=(i,l)=>{const c=i.split(`
|
|
200
|
+
`);for(const[u,h]of c.entries()){if(u>0&&n.push([]),!h)continue;const p=n[n.length-1],m=p[p.length-1];m&&m.scope===l?m.text+=h:p.push({text:h,scope:l})}},o=(i,l)=>{for(const c of i)c.type==="text"?r(c.value,l):c.type==="element"&&o(c.children,E6(c)??l)};try{o(X_.highlight(t,e).children,"")}catch{return e.split(`
|
|
201
|
+
`).map(i=>i?[{text:i,scope:""}]:[])}return n}function E6(e){var r;const t=((r=e.properties)==null?void 0:r.className)??[];let n=null;for(const o of t){const i=x6[o.startsWith("hljs-")?o.slice(5):o];i&&(n=i)}return n}const ax=/^\d+\t/;function Xk(e,t){if(!t)return[];const n=e.split(`
|
|
202
|
+
`),r=ax.test(n[0]??""),o=r?n.map(l=>{var c;return((c=ax.exec(l))==null?void 0:c[0])??""}):[],i=r?n.map((l,c)=>l.slice(o[c].length)).join(`
|
|
203
|
+
`):e;return Q_(i,t).map((l,c)=>{const u=l.map(p=>({text:p.text,changed:!1,scope:p.scope})),h=o[c];return h?[{text:h,changed:!1,scope:""},...u]:u})}function S6(e,t){var r;const n=new Array(e.length);if(t){let o=0;for(let i=0;i<=e.length;i++){const l=(r=e[i])==null?void 0:r.kind;i<e.length&&l!=="hunk"&&l!=="meta"||(_6(e,o,i,t,n),o=i+1)}}return e.map((o,i)=>N6(o.spans,n[i],o.text))}function _6(e,t,n,r,o){var i,l;for(const c of["del","add"]){const u=[];for(let m=t;m<n;m++){const k=(i=e[m])==null?void 0:i.kind;(k===""||k===c)&&u.push(m)}if(u.length===0)continue;const h=u.map(m=>{var k;return((k=e[m])==null?void 0:k.text)??""}).join(`
|
|
204
|
+
`),p=Q_(h,r);for(const[m,k]of u.entries())(c==="add"||((l=e[k])==null?void 0:l.kind)==="del")&&(o[k]=p[m])}}function N6(e,t,n){if(!(e!=null&&e.length)&&!(t!=null&&t.length))return n?[{text:n,changed:!1,scope:""}]:[];const r=[],o=e!=null&&e.length?e:[{text:n,changed:!1}],i=t!=null&&t.length?t:[{text:n,scope:""}];let l=0,c=0,u=0,h=0;for(;l<o.length&&c<i.length;){const p=o[l],m=i[c],k=Math.min(p.text.length-u,m.text.length-h);if(k>0){const g={text:p.text.slice(u,u+k),changed:p.changed,scope:m.scope},y=r[r.length-1];y&&y.changed===g.changed&&y.scope===g.scope?y.text+=g.text:r.push(g)}u+=k,h+=k,u>=p.text.length&&(l++,u=0),h>=m.text.length&&(c++,h=0)}return r}Sn.use({extensions:[z5],renderer:{code({text:e,lang:t}){const n=Yk((t??"").trim().toLowerCase().split(/\s+/)[0]??"","");return n?`<pre><code>${Xk(e,n).map(o=>o.map(i=>i.scope?`<span class="sy-${i.scope}">${lx(i.text)}</span>`:lx(i.text)).join("")).join(`
|
|
205
|
+
`)}</code></pre>
|
|
206
|
+
`:!1},table:F5}});const lx=e=>e.replace(/[&<>]/g,t=>t==="&"?"&":t==="<"?"<":">"),J_=R3(window);let Ts=null;J_.addHook("afterSanitizeAttributes",e=>{const t=e.tagName==="A"?e.getAttribute("href")??"":"";if(t===F_){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=Ts!=null&&Ts.fileRoot?E_(Ts.fileRoot,t):null,r=n?null:S_(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=Vz(e.textContent??"");i&&e.setAttribute("data-path",i)}const o=Ts==null?void 0:Ts.base;if(e.tagName==="IMG"&&o){const i=Dk(o.dir,e.getAttribute("src")??"");i&&e.setAttribute("src",o.urls.worktreeFile(o.worktreeId,i,o.version))}});function ta(e,t){Ts=t??null;const n=t!=null&&t.streaming?M5(e):e;try{return J_.sanitize(Sn.parse(n,{async:!1}))}finally{Ts=null}}function Qk(e,t){var m,k,g,y;const[n,r]=_.useState(()=>ta(e,t)),o=_.useRef(0),i=(m=t==null?void 0:t.base)==null?void 0:m.worktreeId,l=(k=t==null?void 0:t.base)==null?void 0:k.dir,c=(g=t==null?void 0:t.base)==null?void 0:g.version,u=(y=t==null?void 0:t.base)==null?void 0:y.urls,h=t==null?void 0:t.fileRoot,p=t==null?void 0:t.streaming;return _.useEffect(()=>{const b=i!==void 0&&l!==void 0&&u!==void 0?{worktreeId:i,dir:l,version:c??null,urls:u}:void 0,S=b||h||p?{base:b,fileRoot:h,streaming:p}:void 0,j=performance.now()-o.current;if(j>=lf){o.current=performance.now(),r(ta(e,S));return}const E=setTimeout(()=>{o.current=performance.now(),r(ta(e,S))},lf-j);return()=>clearTimeout(E)},[e,i,l,c,u,h,p]),n}const T6=/^ {0,3}(`{3,}|~{3,})/,j6=/^#{1,6} \S/,C6=/^\s*(?:[-*+]|\d+[.)]) \S/,A6=/^> ?\S/,I6=/^\s*\|?\s*:?-{3,}:?\s*(?:\|\s*:?-{3,}:?\s*)+\|?\s*$/,R6=/\[[^\]\n]+\]\((?:https?:|\.{0,2}\/|#)[^)\s]*\)/,$6=/\*\*[^\s*][^*\n]*\*\*/;function O6(e){var i,l;const t=e.split(`
|
|
207
|
+
`),n=new Set;let r=null,o=0;for(let c=0;c<t.length;c++){const u=t[c],h=(i=T6.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}j6.test(u)&&!((l=t[c+1])!=null&&l.trim())&&n.add("heading"),C6.test(u)&&++o===2&&n.add("list"),A6.test(u)&&n.add("quote"),I6.test(u)&&n.add("table"),R6.test(u)&&n.add("link"),$6.test(u)&&n.add("bold")}return n.size}function M6(e,t){if(t)return Of(t)==="markdown"?"rendered":"plain";const n=O6(e);return n>=2?"rendered":n===1?"source":"plain"}function Jk({n:e,name:t,source:n,lines:r,chars:o,preview:i,text:l,href:c,onRemove:u,className:h=""}){const p=(n==null?void 0:n.path)??t??"",m=p.includes("/")?p.slice(0,p.lastIndexOf("/")):"",k=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(" · "),g=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?$2(n):i1("paste",e)}),k&&d.jsxs("span",{className:"pick-file row-dim",children:[" · ",k]})]})]}),y=l!==void 0||c!==void 0;return d.jsx(Bk,{className:Ke("paste-chip",h),label:g,tip:i||void 0,peek:y?d.jsx(nN,{text:l,href:c}):void 0,full:y?d.jsx(tN,{text:l,href:c,path:p||void 0}):void 0,menu:b=>w_({text:l,href:c},b),removeLabel:"Remove attachment",onRemove:u})}function eN(e,t){const[n,r]=_.useState(e??null),[o,i]=_.useState(!1);return _.useEffect(()=>{if(e!==void 0||!t)return;let l=!0;return fetch(t).then(c=>c.ok?c.text():Promise.reject(new Error(String(c.status)))).then(c=>{l&&r(c)}).catch(()=>{l&&i(!0)}),()=>{l=!1}},[e,t]),{text:e??n,failed:o}}function tN({text:e,href:t,path:n}){const{text:r,failed:o}=eN(e,t),i=_.useMemo(()=>r?M6(r,n):"plain",[r,n]),[l,c]=_.useState(null);if(o)return d.jsx("p",{className:"paste-full hint",children:"Toyon could not read that back."});if(!r||i==="plain")return d.jsx("pre",{className:"paste-full paste-text",children:r});const u=l??i==="rendered";return d.jsxs("div",{className:"paste-full paste-doc",children:[d.jsx("div",{className:"paste-doc-head",children:d.jsxs(De,{variant:"outline",tone:"quiet",mono:!0,className:"deep-link",onClick:()=>c(!u),"data-tip":u?"Text: read it as it was sent":"Preview: read it rendered",children:[d.jsx(St,{name:u?"text":"book",className:"icon-inline"})," ",u?"text":"preview"]})}),u?d.jsx(P6,{text:r}):d.jsx("pre",{className:"paste-doc-body paste-text",children:r})]})}function P6({text:e}){const t=_.useMemo(()=>ta(e),[e]);return d.jsx("div",{className:"paste-doc-body md md-preview",onClick:n=>{const r=n.target.closest("a");r&&r.target!=="_blank"&&n.preventDefault()},dangerouslySetInnerHTML:{__html:t}})}const L6=2e4;function nN({text:e,href:t}){const{text:n}=eN(e,t);return n?d.jsx("pre",{className:"paste-peek paste-text",children:n.slice(0,L6)}):null}function ew({name:e,bytes:t,href:n,uploading:r,progress:o,onRemove:i,className:l=""}){return d.jsx(Bk,{className:Ke("file-chip",l),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:[" ","· ",Cg(t),o!==void 0?d.jsxs(d.Fragment,{children:[" ","· ",d.jsxs("span",{className:"pick-progress",children:[o,"%"]})]}):r&&" · uploading"]})]})]}),tip:e,peek:n?d.jsx(nN,{href:n}):void 0,full:n?d.jsx(tN,{href:n,path:e}):void 0,menu:c=>w_({href:n},c),removeLabel:"Remove attachment",onRemove:i})}function rN(e){return e.replace(/^([\t ]*)\*\*(\S(?:[^\n]*\S)?)\*\*([\t ]*)$/gm,"$1$2$3")}const oN=120,D6=/^\*\*(\S(?:[^\n]*\S)?)\*\*$/;function sN(e){var n,r;const t=[];for(const o of e.split(/\n[\t ]*\n/)){const i=o.trim();if(!i)continue;const l=((r=(n=D6.exec(i))==null?void 0:n[1])==null?void 0:r.replace(/`/g,""))??"";if(!l||l.length>oN)return[];t.push(l)}return t}function iN(e){const t=sN(e);if(t.length)return t.at(-1);const n=rN(e).trim().replace(/`/g,"");return n&&!n.includes(`
|
|
208
|
+
`)&&n.length<=oN?n:""}const z6={read:"read",edit:"edit",delete:"delete",move:"move",search:"search",execute:"run",think:"think",fetch:"fetch",switch_mode:"mode",other:"tool"},cx={read:"book",edit:"edit",delete:"trash",move:"move",search:"search",execute:"run",think:"bulb",fetch:"globe",switch_mode:"swap",other:"dot"},aN="Skill",Qp=new Map([[Eg,"chat"],["Monitor","clock"],["TaskOutput","terminal"],[aN,"layers"],[t1,"globe"]]);function F6(e){if(e.name!==aN)return"";const t=ro(e,"skill").trim();if(!t)return"";const n=ro(e,"args").trim();return n?`/${t} ${n}`:`/${t}`}const eg={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"},B6=/(^|\s)(-[A-Za-z]*[iI]|--in-place)/,ux=String.raw`(?:"[^"]*"|'[^']*'|[^\s;&|]+)`,dx=new RegExp(String.raw`^\s*(?:(?:cd|echo)\s+${ux}\s*(?:&&|;)|mkdir(?:\s+${ux})+\s*(?:&&|;)|(?:export\s+)?[A-Za-z_]\w*=(?:"[^"]*"|'[^']*'|[^\s;&|()\`]*)\s*(?:&&|;|(?=\s)))\s*`),U6=/^python[\d.]*$/,H6=new RegExp(`open\\([^)]*,\\s*["'][wax]|(?<!std(?:out|err))\\.write\\(|\\.write_text\\(`);function lN(e){let t=e;for(let n=t.replace(dx,"");n!==t;n=t.replace(dx,""))t=n;return t}const W6=new RegExp("(?<![0-9&])>{1,2}\\s*(?!\\/dev\\/null|&)[^\\s&>]"),cN=/&&|;|\n|\|/;function K6(e){return e.split(cN).some(t=>/^\s*(?:\S*\/)?sed\s/.test(t)&&B6.test(t))}function Z6(e){return e.split(/&&|;|\n/).map(t=>lN(t).trim().split(/\s+/)[0]??"").filter(Boolean).every(t=>eg[t.slice(t.lastIndexOf("/")+1)]==="trash")}function q6(e){const t=lN(e).trim(),n=t.split(/\s+/)[0]??"",r=n.slice(n.lastIndexOf("/")+1),o=r==="sed"?K6(e)?void 0:"book":eg[r];if(o==="book"||o==="search"){const i=t.split(cN)[0]??"";if(W6.test(i))return r==="cat"&&i.includes("<<")?"edit":void 0}if(!(o==="trash"&&!Z6(t)))return o||(U6.test(r)?t.includes("<<")&&H6.test(t)?"edit":void 0:eg[r])}function ro(e,t){const n=e.input,r=n?n[t]:void 0;return typeof r=="string"?r:""}const G6=/^(?:\/(?:usr\/)?bin\/)?(?:ba|z|da)?sh\s+(?:-[a-zA-Z]+\s+)*(?:'([^']*)'|"((?:[^"\\]|\\.)*)")\s*$/;function uN(e){const t=G6.exec(e.trim());return t?t[1]!==void 0?t[1]:(t[2]??"").replace(/\\(["\\$`])/g,"$1"):e}const V6="Guardian Review";function dN(e){return e.toolKind==="think"&&e.title===V6}function Y6(e){const t=o=>{var l,c;return((c=(l=[...e.matchAll(new RegExp(`^${o}:[ \\t]*(.+)$`,"gm"))].at(-1))==null?void 0:l[1])==null?void 0:c.trim().toLowerCase())??""},n=t("Status"),r=t("Risk");return!n||n==="in progress"?"reviewing":r?`${n}, ${r} risk`:n}function Fc(e,t=[]){const n=uN(ro(e,"command")),r=e.name===pm?"":ro(e,"query"),i=fN(e)||n||ro(e,"path")||ro(e,"pattern")||r||F6(e)||(e.title&&e.title!==e.name?e.title:""),l=Xf(ro(e,"description")||i,t),c=e.toolKind&&e.toolKind in cx?e.toolKind:"other",u=z6[c],h=e.name===Eg,p=c!=="other"||Qp.has(e.name),m=e.name===e.title||e.name===ui||e.name===e1,k=l&&(p||m||e.name===pm)&&e.name!==t1?"":e.name,g=k&&k.toLowerCase()!==u?k:l?"":u,y=(c==="execute"||c==="other")&&n?q6(n):void 0;return{label:h?"ask":u,name:g,icon:Qp.get(e.name)??Qp.get(e.title??"")??y??cx[c],hint:l===g?"":l,command:n&&n!==l?n:""}}const X6=/^Async agent launched/m;function Q6(e){if(!e.subagent)return!1;const t=e.input;return!!e.detached||(t==null?void 0:t.run_in_background)===!0||!!e.output&&X6.test(e.output)}const J6={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 eF(e){const t=e.toolKind;return e.subagent?ro(e,"prompt")?"":"writing the brief":!bf(e.input)||!n1({name:e.name,kind:t},e.input)?"":_g(t)?J6[t]:"writing the question"}function tg(e,t){const n=hN(t),r=n[0],o=ro(e,"description");return o&&r&&!r.code&&r.text===o?n.slice(1):n}function al(e){return fN(e)||ro(e,"path")}function tF(e){return ro(e,"description")}function fN(e){return ro(e,"file_path")||ro(e,"filepath")||ro(e,"filePath")||nF(e)}function nF(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 Xf(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 rF=/^(`{3,})([\w+#.-]*)\s*$/;function hN(e){var c;const t=[];let n=[],r="",o=!1,i=0;const l=()=>{const u=n.join(`
|
|
209
|
+
`).replace(/^\n+|\n+$/g,"");u.trim()&&t.push({code:o,diff:oF(u,r),lang:o?r:"",text:u}),n=[]};for(const u of e.split(`
|
|
210
|
+
`)){const h=rF.exec(u),p=((c=h==null?void 0:h[1])==null?void 0:c.length)??0;if(!h||o&&(p<i||h[2])){n.push(u);continue}l(),o=!o,i=o?p:0,r=o?(h[2]??"").toLowerCase():""}return l(),t}function oF(e,t){return t==="diff"||t==="patch"||/^diff --git /m.test(e)||/^@@ .*@@/m.test(e)?!0:/^--- /m.test(e)&&/^[+-]/m.test(e)}const sF=/^(diff --git |index [0-9a-f]+\.\.|new file mode |deleted file mode |similarity index |rename (from|to) |Binary files )/;function iF(e){const t=[];for(const n of e.split(`
|
|
211
|
+
`)){const r=lF(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 aF(t),t}function aF(e){var t,n,r,o;for(let i=0;i<e.length;){if(((t=e[i])==null?void 0:t.kind)!=="del"&&((n=e[i])==null?void 0:n.kind)!=="add"){i++;continue}let l=i;for(;((r=e[l])==null?void 0:r.kind)==="del";)l++;let c=l;for(;((o=e[c])==null?void 0:o.kind)==="add";)c++;const u=e.slice(i,l),h=e.slice(l,c),p=u.length>0&&h.length>0?ZC(u.map(m=>m.text).join(`
|
|
212
|
+
`),h.map(m=>m.text).join(`
|
|
213
|
+
`)):null;p&&(fx(u,$v(p.before)),fx(h,$v(p.after)));for(const m of[...u,...h])m.spans??(m.spans=[]);i=c}}function fx(e,t){if(t.length===e.length)for(const[n,r]of e.entries())r.spans=t[n]}function lF(e){return e.startsWith("@@")?"hunk":e.startsWith("+++")||e.startsWith("---")||sF.test(e)?"meta":e.startsWith("+")?"add":e.startsWith("-")?"del":""}function cF(e){const t=e.tools.at(-1);return t.done||t.parentToolId?!1:t.name===ui?!t.background:!!t.background}const pN=new Set(["read","edit","fetch"]);function tw(e,t){if(e.isError||!e.toolKind||!pN.has(e.toolKind)||_g(e.toolKind)&&bf(e.input))return"";const{hint:n}=Fc(e,t);return n?`${e.parentToolId??""}
|
|
214
|
+
${e.toolKind}
|
|
215
|
+
${e.name}
|
|
216
|
+
${n}`:""}function hx(e,t,n){if(!t||!("tools"in t)||e.done||e.isError||!e.toolKind||!pN.has(e.toolKind))return!1;const r=t.tools[0];return r.toolKind===e.toolKind&&r.name===e.name&&r.parentToolId===e.parentToolId&&tw(r,n)!==""}function uF(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:tw(o,t)?n:-1}function mN(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 dF(e){return e.done&&!e.output&&!e.isError&&n1({name:e.name,kind:e.toolKind},e.input)}function fF(e,t){const n=mN(e),r=[],o=new Map;let i="";for(const[l,c]of e.entries()){if(c.kind!=="tool"){i="",r.push({at:l,item:c});continue}if(dF(c))continue;if(n.has(c.id)){i="";const m={at:l,spawn:c,run:[],end:l};o.set(c.id,{entry:m,key:""}),r.push(m);continue}const u=tw(c,t),h=c.parentToolId?o.get(c.parentToolId):void 0;if(h){const m=h.entry.run,k=m.at(-1);u&&u===h.key&&k?k.tools.push(c):!u&&hx(c,k,t)?k.next=c:m.push({at:l,tools:[c]}),h.key=u,h.entry.end=l;continue}const p=r.at(-1);if(u&&u===i&&p&&"tools"in p){p.tools.push(c);continue}if(!u&&hx(c,p,t)){p.next=c;continue}i=u,r.push({at:l,tools:[c]})}return r}function hF(e){return e.reduce((t,n)=>t+n.tools.length,0)}function pF(e){const t=new Set,n=new Set;let r=!0;for(let i=e.length-1;i>=0;i--){const l=e[i];if(l.kind!=="tool"||!l.parentToolId){r=!1;continue}n.add(l.parentToolId),(r||!l.done)&&t.add(l.parentToolId)}let o=!0;for(let i=e.length-1;i>=0;i--){const l=e[i];l.kind==="user"&&(o=!1),!(l.kind!=="tool"||!l.subagent)&&(l.isError?t.delete(l.id):l.done?Q6(l)?o&&!n.has(l.id)&&t.add(l.id):t.delete(l.id):t.add(l.id))}return t}function mF(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&&cF(i)?n.push(i):r.push({key:i.at,entry:i});return r.sort((i,l)=>i.key-l.key),{flow:r.map(i=>i.entry),floating:n}}function gF(e){const t=mN(e);return e.some(n=>n.kind==="tool"&&!n.done&&!n.parentToolId&&!n.background&&(!t.has(n.id)||bf(n.input)))}function gN(e,t=!1){const n=new Set;let r=!1,o=!1;return e.forEach((i,l)=>{if(!("tools"in i)||!t&&i.tools[0].parentToolId)return;const c=i.tools.at(-1);if(c.done||c.background||c.name===ui)return;const u=Sg({name:c.name,kind:c.toolKind});(o||r&&u)&&n.add(l),r=!0,o||(o=u)}),n}function kF(e){return e.findIndex(t=>!t.tools.at(-1).done)}function nw(e,t){return e.length===t.length&&e.every((n,r)=>n===t[r])}function kN(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)&&nw(n.tools,t[r].tools)})}function wF(e,t){if(e.length===0)return t;const n=new Map;for(const i of e)n.set(i.at,i);let r=e.length===t.length;const o=t.map((i,l)=>{const c=n.get(i.at),u=c!==void 0&&yF(c,i)?c:i;return u!==e[l]&&(r=!1),u});return r?e:o}function yF(e,t){return"spawn"in e?"spawn"in t&&e.spawn===t.spawn&&e.end===t.end&&kN(e.run,t.run):"tools"in e?"tools"in t&&e.next===t.next&&nw(e.tools,t.tools):"item"in t&&e.item===t.item}function vF(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"&&!dN(r))return t;continue}if(n.item.kind==="thinking"){if(!n.item.text.trim())continue;return iN(n.item.text)?-1:t}if(bF(n.item))return-1}}return-1}function bF(e){return e.kind==="assistant"?!!e.text.trim():e.kind==="ask"?e.ask.kind==="question"||!!e.outcome:!0}function xF(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 EF({item:e}){const t=ut(),n=L(r=>pn(r,e.worktreeId)!==null);return e.state==="proposed"?null:e.state==="starting"?d.jsx(Wr,{icon:"spawn",word:"continuing",tone:"accent",at:e.ts,children:d.jsxs("span",{className:"daemon-text live-text",children:["in ",e.repo.name,", starting the worktree"]})}):e.state==="declined"?d.jsx(Wr,{icon:"close",word:"not continued",tone:"quiet",at:e.ts,below:e.reason?d.jsx("div",{className:"daemon-below row-dim",children:e.reason}):void 0,children:d.jsxs("span",{className:"daemon-text",children:["in ",e.repo.name]})}):d.jsx(Wr,{icon:"spawn",word:"continued",tone:"accent",at:e.ts,children:d.jsxs("span",{className:"daemon-text",children:["in ",e.repo.name,":"," ",d.jsx(De,{variant:"inline",tone:"strong",disabled:!n,onClick:()=>e.worktreeId&&t({a:"activate",id:e.worktreeId}),children:e.title??e.repo.name})]})})}function SF({item:e}){return d.jsxs(Wr,{icon:"check",word:"landed",tone:"aqua",at:e.ts,children:[d.jsxs("span",{className:"daemon-text",children:[e.title," in ",e.repoName]}),e.url&&d.jsx(De,{variant:"inline",tone:"strong",onClick:()=>window.open(e.url,"_blank"),children:"view PR"})]})}function rw({src:e,n:t,name:n,width:r,height:o,bytes:i,uploading:l,progress:c,onRemove:u,className:h=""}){return d.jsx(Bk,{className:Ke("image-chip",h),label:d.jsxs(d.Fragment,{children:[d.jsx("img",{className:"image-thumb",src:e,alt:n,width:40,height:40}),d.jsxs("span",{className:"pick-target",children:[d.jsx("b",{children:i1("image",t)}),d.jsxs("span",{className:"pick-file row-dim",children:[" ","· ",n," · ",r,"×",o," · ",Cg(i),c!==void 0?d.jsxs(d.Fragment,{children:[" ","· ",d.jsxs("span",{className:"pick-progress",children:[c,"%"]})]}):l&&" · uploading"]})]})]}),peek:d.jsx("img",{src:e,alt:n,style:{aspectRatio:`${r} / ${o}`}}),full:d.jsx("img",{src:e,alt:n}),menu:p=>zc(e,p),removeLabel:"Remove image",onRemove:u})}function _F({img:e,src:t}){return d.jsx(rw,{className:"in-chat",src:t,...e})}function wN(e,{sock:t,dispatch:n}){var m,k;const r=g=>g?"hide":"show",o=e.repos.some(g=>g.id===e.activeRepoId),i=(m=pn(e,e.activeId))==null?void 0:m.worktree.id,l=[];o&&(l.push({id:"new",label:"new worktree…",key:Lt("new"),onClick:()=>n({a:"open-draft"})}),l.push({id:"refs",label:"open a branch or PR…",key:Lt("refs"),onClick:()=>n({a:"open",overlay:{kind:"refs"}})})),i&&(l.push({id:"jump",label:"jump to file…",key:Lt("quick-open"),onClick:()=>n({a:"open",overlay:{kind:"quick-open"}})}),l.push({id:"search",label:"search in files…",key:Lt("search"),onClick:()=>n({a:"open",overlay:{kind:"search"}})})),tf(e)&&l.push({id:"routes",label:"go to page…",key:Lt("routes"),onClick:()=>n({a:"open",overlay:{kind:"routes"}})}),o&&l.push({id:"chats",label:"search chats…",key:Lt("chats"),onClick:()=>n({a:"open",overlay:{kind:"chats"}})});const c=Gg(e.visible,e.activeId,1);c&&l.push({id:"wt-unseen-next",label:"next that needs you",key:Lt("wt-unseen-next"),onClick:()=>n({a:"activate",id:c.activate})}),l.push({id:"project",label:e.repos.length>1?"switch project…":"open project…",key:Lt("project"),onClick:()=>n({a:"open",overlay:{kind:"projects",form:"center"}})});const u=[{id:"changes",label:`${r(e.layout.changes)} changes panel`,key:Lt("changes"),onClick:()=>n({a:"toggle-changes"})},{id:"files",label:`${r(e.layout.changes&&sl(e)==="files")} files`,key:Lt("files"),onClick:()=>n(e.layout.changes&&sl(e)==="files"?{a:"toggle-changes"}:{a:"focus-changes",tab:"files"})},{id:"chat",label:`${r(e.layout.chat)} chat panel`,key:Lt("composer"),onClick:()=>n({a:"toggle-chat"})},{id:"terminal",label:`${r(e.layout.term)} terminal`,key:Lt("terminal"),onClick:()=>n({a:"toggle-terminal"})},{id:"rail",label:`${r(e.railOpen)} worktree panel`,key:Lt("rail"),onClick:()=>n({a:"toggle-rail"})},{id:"design",label:`${r(e.layout.design)} design system`,key:Lt("design"),onClick:()=>n({a:"toggle-design"})},{id:"zen",label:"full-bleed preview",key:Lt("zen"),onClick:()=>n({a:"toggle-zen"})}],h=[{id:"commands",label:"command palette",key:Lt("commands"),onClick:()=>n({a:"open",overlay:{kind:"commands"}})},{id:"keys",label:"settings & shortcuts",key:Lt("keys"),onClick:()=>n({a:"open",overlay:{kind:"keys"}})}];(k=e.self)!=null&&k.restart&&h.push({id:"restart-daemon",label:"restart Toyon",onClick:()=>t==null?void 0:t.send({t:"restart-daemon"})}),h.push({id:"devices",label:e.knocks.length>0?`let a device in (${e.knocks.length})`:"your devices",onClick:()=>n({a:"open",overlay:{kind:"devices"}})});const p=To(e)?new Set(["chat","design","zen"]):null;return Ln([l,p?u.filter(g=>!p.has(g.id)):u,h])}function ng(e,t){const n=e.get(t);if(!n||n.serving)return[];const r=e.displayName(t),o=[];e.active().origin!==t&&o.push({id:`machine:${t}`,label:`switch to ${r}`,onClick:()=>e.activate(t)});const i=[{id:`forget-machine:${t}`,label:`forget ${r}…`,danger:!0,onClick:()=>{window.confirm(`Forget ${r}?
|
|
217
|
+
|
|
218
|
+
It leaves your list, here and in every browser Toyon on this machine serves, and this browser forgets what it had selected there. Toyon on that machine is not touched; pair again to list it.`)&&e.serving().sock.send({t:"forget-machine",origin:t})}}];return Ln([o,i])}function ow(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 yN(e,{sock:t}){return[{id:"restart:shell",label:"restart shell",onClick:()=>t==null?void 0:t.send({t:"term-restart",worktreeId:e,stream:_o})}]}function NF(e,t,n,r){return Ln([[...e.flatMap(o=>ow(o,t,r)),...yN(t,r)],[{id:"terminal",label:`${n?"hide":"show"} terminal`,onClick:()=>r.dispatch({a:"toggle-terminal"})}]])}const Qf=e=>/^(~|\/|\.\.?\/)/.test(e.trim());function sw(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 TF(e,t,n){const r=e.map(h=>h.path.slice(0,h.path.lastIndexOf("/"))).filter(Boolean),o=e.find(h=>h.id===t),i=o==null?void 0:o.path.slice(0,o.path.lastIndexOf("/")),l=new Map;for(const h of r)l.set(h,(l.get(h)??0)+1);let c="",u=0;for(const[h,p]of[...l].sort(([m],[k])=>m.localeCompare(k)))(p>u||p===u&&h===i)&&(c=h,u=p);return c?vN(c,n):`~/${Q1}`}function vN(e,t){return t&&(e===t||e.startsWith(`${t}/`))?`~${e.slice(t.length)}`:e}function bN(e,t){return`${e.replace(/\/+$/,"")}/${t.trim()}`}function jF(e){const t=e.query.trim(),n=()=>e.entries.map(l=>({kind:"dir",entry:l}));if(!Qf(t)){const l=e.repos.filter(k=>is(t,k.name,k.path)).map(k=>({kind:"repo",repo:k})),c=e.pending.filter(k=>is(t,k.name,k.url)).map(k=>({kind:"pending",pending:k})),u=[...l,...c],h=(e.others??[]).flatMap(k=>k.repos.length===0?is(t,k.name)?[{kind:"machine",machine:k}]:[]:k.repos.filter(g=>is(t,g.name,g.path,k.name)).map(g=>({kind:"repo",repo:g,machine:k})));if(!t){const k=l.find(y=>y.kind==="repo"&&y.repo.id===e.current);return[...k?[k,...l.filter(y=>y!==k)]:l,...c,{kind:"new"},{kind:"disk"},{kind:"add-machine"},...h]}const p=D2(t);if(p)return u.length>0?u:[{kind:"clone",url:p.url,name:p.name}];const m=k=>k.toLowerCase()===t.toLowerCase();return e.repos.some(k=>m(k.name))||e.pending.some(k=>m(k.name))?[...u,...h]:$c(t)?[...u,...h]:[...u,{kind:"create",name:t,parent:null},...h]}if(e.answered.trim()!==t||!e.target)return n();const{target:r}=e;if(r.exists){const l=t.replace(/\/+$/,"")||"/";if(r.isRepo)return[...n(),{kind:"open",path:l}];if(!r.isDir)return n();const c=ll(l,e.home);return c==="/"||c===e.home||e.repos.some(h=>h.path.startsWith(`${c}/`))?n():[...n(),{kind:"init",path:l}]}if(t.endsWith("/"))return n();if(!r.parentExists)return[];const{parent:o,name:i}=sw(t);return $c(i)?n():[...n(),{kind:"create",name:i,parent:o}]}function ll(e,t){return t&&(e==="~"||e.startsWith("~/"))?`${t}${e.slice(1)}`:e}function xN(e,t){const n=ll(e,t).replace(/\/+$/,"");return n.startsWith("/")?vN(n.slice(0,n.lastIndexOf("/"))||"/",t):null}function rg(e,t){const n=ll(e,t).replace(/\/+$/,"");return n.slice(n.lastIndexOf("/")+1)||"/"}function CF(e){const t=e.query.trim(),n=t.lastIndexOf("/"),r=n<0?"":t.slice(0,n)||"/",o=ll(r,e.home);if(!Qf(t)||!o.startsWith("/"))return[];const i=t.slice(n+1).toLowerCase(),l=e.answered.trim()===t?e.target:null,c=!l||(i?l.parentExists:l.exists&&l.isDir&&!l.isRepo),u=e.entries.filter(p=>{if(p.isRepo)return!1;const m=ll(p.path,e.home);return(m.slice(0,m.lastIndexOf("/"))||"/")===o&&p.name.toLowerCase().startsWith(i)}),h=xN(r,e.home);return[...c?[{kind:"here",path:r}]:[],...h?[{kind:"up",path:h}]:[],...u.map(p=>({kind:"dir",entry:p}))]}function Bc({sock:e,dispatch:t},n){t({a:"open-repo"}),e==null||e.send(n)}function EN(e,t){const{parent:n,name:r}=sw(t);Bc(e,{t:"create-repo",mode:"init",parent:n,name:r})}function AF(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 Jf(e,t,{sock:n,dispatch:r}){const o=[];e.id!==t&&o.push({id:`repo:${e.id}`,label:`switch to ${e.name}`,onClick:()=>r({a:"activate-repo",id:e.id})});const i=[{id:`setup:${e.id}`,label:"project settings…",detail:e.configFile,onClick:()=>r({a:"open",overlay:{kind:"setup",repoId:e.id}})},{id:`archived:${e.id}`,label:"archived worktrees…",onClick:()=>{r({a:"activate-repo",id:e.id}),r({a:"open",overlay:{kind:"chats",names:!0}})}},{id:`forget:${e.id}`,label:"forget project…",danger:!0,onClick:()=>{window.confirm(`Forget ${e.name}?
|
|
219
|
+
|
|
220
|
+
Its procs stop, it leaves the project list, and the chat on main is deleted. The checkout is not touched, and archived worktrees come back when you open it again.`)&&(n==null||n.send({t:"forget-repo",repoId:e.id}))}}];return Ln([o,i])}const uf={dark:"dark",light:"light",system:"follow system",daylight:"follow daylight"},df={use:"while in use",always:"always",off:"off"};function IF(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 SN(e,{sock:t,dispatch:n}){var l;const r=e.themePrefs,o=c=>{var u;return((u=e.themes.find(h=>h.id===c))==null?void 0:u.name)??c},i=WL();return Ln([[{id:"theme",label:"theme…",detail:$f(r,e.themes,TE(e)).name,sub:!0,onClick:()=>n({a:"open",overlay:{kind:"theme",slot:"theme"}})},{id:"appearance",topic:"theme",label:"light or dark…",detail:uf[r.mode],sub:!0,onClick:()=>n({a:"open",overlay:{kind:"appearance"}})}],[{id:"agent",label:"default agent…",detail:((l=e.agents.find(c=>c.id===e.defaultAgent))==null?void 0:l.name)??e.defaultAgent,sub:!0,onClick:()=>n({a:"open",overlay:{kind:"agent"}})}],[{id:"chat-side",label:"chat side",detail:e.chatSide,onClick:()=>n({a:"toggle-chat-side"})},...i.access==="none"?[]:[{id:"clipboard-offer",label:"offer what is copied",detail:i.access==="denied"?"blocked in site settings":i.on?"on":"off",onClick:()=>KL(!i.on)}]],...e.keepAwake===null?[]:[[{id:"keep-awake",label:"keep awake…",detail:df[e.keepAwake],sub:!0,onClick:()=>n({a:"open",overlay:{kind:"keep-awake"}})}]],[{id:"theme-import",topic:"theme",label:"import a VS Code theme…",onClick:()=>IF((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 RF(e,t,n,r,o,i={machines:[],switchTo:()=>{},forget:()=>{}}){const l=[],c=(k,g,y,b,S)=>l.push({id:k,label:g,hint:b,run:y,sub:S}),u=(k,g)=>{for(const y of k){if(!cs(y)||y.disabled!==void 0||y.checked)continue;const b=y.key??(typeof y.detail=="string"?y.detail:void 0),S=g?`${g.scope}:${y.id}`:y.id,j=y.topic?`${y.topic}: ${y.label}`:y.label;c(S,g?`${j} · ${g.name}`:j,y.onClick,b,y.sub)}},h={sock:n,dispatch:t},p=r,m=p==null?void 0:p.worktree.id;if(u(wN(e,h).filter(k=>!cs(k)||k.id!=="commands")),o&&u(Jf(o,o.id,h),{scope:"project",name:o.name}),m&&!To(e)&&(c("pick",e.picking==="chat"?"cancel element picker":"pick an element for the chat",()=>Pc(m,e.picking,t,"chat"),Lt("pick")),c("inspect",e.picking==="code"?"cancel element picker":"pick an element to open its code",()=>Pc(m,e.picking,t,"code"),Lt("inspect")),c("reload","reload preview",()=>cn.post(m,{type:"reload"}))),u(SN(e,h)),p&&m){const k=e.repos.find(g=>g.id===p.worktree.repoId)??null;u(WS(p,k,e,h,{hostname:e.hostname}),{scope:"wt",name:jm(p,k)});for(const g of p.procs)u(ow(g,m,h))}e.visible.forEach((k,g)=>{var j;if(k.worktree.id===m)return;const y=k.worktree.variant,S=!!e.activeRepoId&&k.repoId!==e.activeRepoId?` in ${((j=e.repos.find(E=>E.id===k.repoId))==null?void 0:j.name)??k.repoId}`:"";c(`go:${k.worktree.id}`,`switch to ${jm(k,o)}${y?` (v${y.index}/${y.of})`:""}${S}`,()=>t({a:"activate",id:k.worktree.id}),wC(g,e.visible.length))});for(const k of e.repos)k.id!==(o==null?void 0:o.id)&&c(`repo:${k.id}`,`switch to project ${k.name}`,()=>t({a:"activate-repo",id:k.id}));for(const k of i.machines){for(const g of k.repos)c(`machine:${k.origin}:${g.id}`,`switch to project ${g.name} on ${k.name}`,()=>i.switchTo(k.origin,g.id));c(`forget-machine:${k.origin}`,`forget ${k.name}`,()=>i.forget(k.origin))}return l}function _N(){const e=ut(),t=pt(),{host:n}=Lr(),r=Vo(),o=KE(),i=L(I=>I.picking),l=L(I=>I.layout),c=L(I=>I.chatSide),u=L(I=>I.keepAwake),h=L(I=>I.railOpen),p=L(I=>I.themePrefs),m=L(I=>I.themes),k=L(I=>I.systemDark),g=L(I=>I.daylight),y=L(I=>I.rows),b=L(I=>I.visible),S=L(I=>I.activeId),j=L(I=>I.activeRepoId),E=L(I=>I.repos),N=L(I=>I.agents),A=L(I=>I.defaultAgent),O=L(I=>I.shipping),P=L(I=>I.remote),R=L(I=>I.managed),T=L(I=>I.frame),$=L(I=>I.self),D=L(I=>I.archivedPage),z=L(I=>I.archived),V=L(I=>I.knocks),se=L(I=>I.tailscale);return _.useMemo(()=>{const I={picking:i,layout:l,chatSide:c,keepAwake:u,railOpen:h,themePrefs:p,themes:m,systemDark:k,daylight:g,rows:y,visible:b,activeId:S,activeRepoId:j,repos:E,agents:N,defaultAgent:A,shipping:O,frame:T,self:$,archivedPage:D,archived:z,knocks:V,hostname:n},ne={machines:o,switchTo:(we,K)=>{var B;(B=r.get(we))==null||B.store.dispatch({a:"activate-repo",id:K}),r.activate(we)},forget:we=>{const K=ng(r,we).find(B=>cs(B)&&B.id.startsWith("forget-machine:"));K&&cs(K)&&K.onClick()}};return RF(I,e,t,pn(I,S),yi(I,j),ne)},[i,l,c,u,h,p,m,k,g,y,b,S,j,E,N,A,O,P,R,T,$,D,z,V,se,e,t,n,r,o])}function NN(e,t){const n=t.trim().toLowerCase();if(!n)return e;const r=[];for(const o of e){const i=og(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 og(e,t){const n=iw(e,t);if(!n)return 0;let r=0,o=0,i=-1;for(const l of n)o=l===i+1?o+1:1,r+=o+(TN(e,l)?3:0),i=l;return r+Math.max(0,40-e.length/4)}const TN=(e,t)=>t===0||/[\s:\-–—·/.(]/.test(e[t-1]);function iw(e,t){const n=e.toLowerCase(),r=[];let o=0;for(const i of t.toLowerCase()){let l=-1;if(n[o]===i)l=o;else if(i===" ")l=n.indexOf(" ",o);else for(let c=n.indexOf(i,o);c!==-1;c=n.indexOf(i,c+1))if(TN(n,c)){l=c;break}if(l===-1)return null;r.push(l),o=l+1}return r}const is=(e,...t)=>{const n=e.trim().toLowerCase();return!n||t.some(r=>r==null?void 0:r.toLowerCase().includes(n))},$F=/^[^\s]*$/;function px(e,t){if(e.startsWith("!"))return null;if(e.startsWith("/")){const i=e.indexOf(" "),l=i===-1?e.length:i;if(!(e.indexOf("/",1)!==-1&&e.indexOf("/",1)<l)&&t<=l)return{kind:"command",query:e.slice(1,t),from:0,to:l}}const n=e.lastIndexOf("@",Math.max(0,t-1));if(n===-1||n>=t||n>0&&!/\s/.test(e[n-1]??""))return null;const r=e.slice(n+1,t);if(!$F.test(r))return null;let o=t;for(;o<e.length&&!/\s/.test(e[o]??"");)o++;return{kind:"file",query:r,from:n,to:o}}const OF={files:new Set,folders:new Set},mx=new WeakMap;function MF(e){if(!e)return OF;let t=mx.get(e);return t||(t={files:new Set(e),folders:new Set(xE(e))},mx.set(e,t)),t}const PF=/(^|\s)(@\S+)/g,LF=/[.,;:!?)\]}'"]$/;function gx(e,t){if(e==="changes")return{kind:"changes",text:"@changes"};if(t.files.has(e))return{kind:"file",text:`@${e}`,path:e};const n=e.replace(/\/+$/,"");return n&&t.folders.has(n)?{kind:"folder",text:`@${e}`,path:n}:null}function DF(e,t){const n=[];let r=0;const o=i=>{if(!i)return;const l=n.at(-1);(l==null?void 0:l.kind)==="text"?l.text+=i:n.push({kind:"text",text:i})};for(const i of e.matchAll(PF)){const l=i.index+(i[1]??"").length;let c=(i[2]??"").slice(1),u=gx(c,t);for(;!u&&LF.test(c);)c=c.slice(0,-1),u=c?gx(c,t):null;u&&(o(e.slice(r,l)),n.push(u),r=l+u.text.length)}return o(e.slice(r)),n}function zF(e,t,n){return{text:e.slice(0,t.from)+n+e.slice(t.to),caret:t.from+n.length}}function FF(e,t){const n=t.trim().toLowerCase();if(!n)return e;const r=i=>e.map((l,c)=>({c:l,i:c,score:i(l)})).filter(l=>l.score>0).sort((l,c)=>c.score-l.score||l.i-c.i).map(l=>l.c),o=r(i=>og(i.name,n));return o.length>0?o:r(i=>og(i.description,n))}const BF=/(^|\s)@\S/;function jN({text:e,worktreeId:t,root:n,inField:r}){const o=Zn(),i=pt(),l=L(p=>{var m;return t?(m=p.local[t])==null?void 0:m.files:void 0}),c=MF(l),u=_.useMemo(()=>DF(e,c),[e,c]),h=l===void 0&&t&&BF.test(e)?t:null;return _.useEffect(()=>{h&&Uf(h,o.getState(),{sock:i,dispatch:o.dispatch})},[h,o,i]),d.jsx(d.Fragment,{children:u.map((p,m)=>{if(p.kind==="text")return p.text;if(p.kind==="changes"){const b=Ut("this worktree's uncommitted files",void 0,{placement:"follow"});return d.jsx("span",{className:"chat-mention","data-changes":"",...b,children:p.text},m)}if(!n||!t)return p.text;const k=p.kind==="folder",g=`${n}/${p.path}${k?"/":""}`,y=Ut(k?`${p.path}/`:p.path,void 0,{placement:"follow"});return d.jsx("a",{className:"chat-mention",href:g,tabIndex:r?-1:void 0,...y,children:p.text},m)})})}function CN(e,t,n,r){if(e.target.closest("[data-changes]")){n&&r.dispatch({a:"focus-changes",tab:"changes"});return}Fk(e,t,n,r)}function UF(e){return e.length<2||!e.every(t=>{var n;return t.length===1&&((n=t[0])==null?void 0:n.diff)})?null:WF(e.map(t=>t[0].text))}const HF=/^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@/;function WF(e,t=3){let n=[];for(const r of e){const o=KF(r);if(!o)return null;const i=ZF(n,o);if(!i)return null;n=i}return n.some(r=>r.kind!=="same")?qF(n,t):null}function KF(e){const t=[];let n=null;for(const r of e.split(`
|
|
221
|
+
`)){const o=HF.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 ZF(e,t){const n=[];let r=0,o=0,i=0,l=0;const c=p=>{p.kind==="same"?o=p.a-p.c:p.kind==="add"?o-=1:o+=1},u=()=>{for(;r<e.length&&e[r].kind==="del";)n.push(e[r]),c(e[r]),r++},h=p=>{for(let m=p;m<e.length;m++){const k=e[m];if(k.kind!=="del")return k.c}return Number.POSITIVE_INFINITY};for(const p of t){if(p.oldStart<=l)return null;for(;r<e.length;){const g=e[r];if((g.kind==="del"?h(r):g.c)>=p.oldStart)break;n.push(g.kind==="del"?g:{...g,c:g.c+i}),c(g),r++}let m=p.oldStart,k=p.newStart;for(const g of p.ops){if(u(),g.mark==="+"){n.push({kind:"add",c:k,text:g.text}),k++;continue}const y=e[r],b=y&&y.kind!=="del"&&y.c===m?y:void 0;if(b){if(b.text!==g.text)return null;r++,c(b),g.mark===" "?n.push({...b,c:k}):b.kind==="same"&&n.push({kind:"del",a:b.a,text:b.text})}else g.mark===" "?n.push({kind:"same",a:m+o,c:k,text:g.text}):n.push({kind:"del",a:m+o,text:g.text});g.mark===" "&&k++,m++}i=k-m,l=m-1}for(;r<e.length;r++){const p=e[r];n.push(p.kind==="del"?p:{...p,c:p.c+i})}return n}function qF(e,t){const n=[];for(const r of VF(e))for(const[o,i]of YF(r.rows,t)){const l=GF(r.rows.slice(o,i)),c=l.filter(m=>m.kind!=="add").length,u=l.filter(m=>m.kind!=="del").length,h=l.find(m=>m.kind!=="add"),p=l.find(m=>m.kind!=="del");n.push(`@@ -${h?h.a:r.oldAt[o]},${c} +${p?p.c:r.newAt[o]},${u} @@`,...l.map(m=>`${m.kind==="add"?"+":m.kind==="del"?"-":" "}${m.text}`))}return n.join(`
|
|
222
|
+
`)}function GF(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 VF(e){const t=[];let n=null,r=1,o=1;for(const i of e){const l=i.kind==="add"?r:i.a,c=i.kind==="del"?o:i.c;(!n||l!==r||c!==o)&&(n={rows:[],oldAt:[],newAt:[]},t.push(n)),n.rows.push(i),n.oldAt.push(l),n.newAt.push(c),r=l+(i.kind==="add"?0:1),o=c+(i.kind==="del"?0:1)}return t}function YF(e,t){const n=[];let r=0;for(;r<e.length;){if(e[r].kind==="same"){r++;continue}let o=r,i=r;for(;i<e.length;){if(e[i].kind!=="same"){o=i,i++;continue}let l=0;for(;i+l<e.length&&e[i+l].kind==="same";)l++;if(l>t*2||i+l>=e.length)break;i+=l}n.push([Math.max(0,r-t),Math.min(e.length,o+t+1)]),r=o+t+1}return n}function sg({pieces:e}){return d.jsx(d.Fragment,{children:e.map((t,n)=>{const r=`${t.changed?"ch ":""}${t.scope?`sy-${t.scope}`:""}`.trim();return r?d.jsx("span",{className:r,children:t.text},n):d.jsx(_.Fragment,{children:t.text},n)})})}function aw({pick:e,worktreeId:t,tipText:n,onHover:r,onOpen:o,onRemove:i,className:l=""}){const c=e.callFile,u=e.file,h=c?{path:c,line:e.callLine}:u?{path:u,line:e.line}:null,p=c&&u?{path:u,line:e.line}:null,m=(E,N)=>`${E}${N?`:${N}`:""}`,k=E=>E.split("/").pop()??E,g=(E,N,A,O)=>o?d.jsx("button",{className:"pick-open","data-tip":O,onClick:()=>o(E,N??1),children:A}):A,y=bn("chat"),{host:b}=Lr(),S=_.useRef(null),j=i?()=>{r==null||r(!1),i()}:void 0;return d.jsxs("div",{ref:S,className:Ke("pick-chip row row-sm",l),"data-tip":n,onMouseEnter:()=>r==null?void 0:r(!0),onMouseLeave:()=>r==null?void 0:r(!1),...y.contextMenu(()=>Lz(e,{remove:j,host:b})),children:[d.jsxs("span",{className:"pick-target",children:[d.jsx(St,{name:"pick",className:"icon-inline"})," ",rk(e),h&&d.jsxs("span",{className:"pick-file row-dim",children:[" ","· ",g(h.path,h.line,m(k(h.path),h.line),`Open ${m(h.path,h.line)}`)]}),p&&d.jsxs("span",{className:"pick-file row-dim",children:[" ","·"," ",g(p.path,p.line,m(p.path.split("/").pop()??p.path,p.line),`Open the component: ${m(p.path,p.line)}`)]})]}),j&&d.jsx(Rt,{icon:"close",label:"Remove attachment",tone:"quiet",onClick:j}),t&&(h==null?void 0:h.line)&&d.jsx(__,{chip:S,children:d.jsx(JF,{worktreeId:t,path:h.path,line:h.line})})]})}const XF=6,QF=16;function JF({worktreeId:e,path:t,line:n}){const r=qE(),o=pt(),i=L(m=>{var k;return((k=Ao(m))==null?void 0:k.id)===e}),l=L(m=>{var k;return i?0:(k=Co(m,e).changedRanges[t])==null?void 0:k.offset}),[c,u]=_.useState(null);_.useEffect(()=>{let m=!0;return i||o==null||o.send({t:"changed-ranges",worktreeId:e,path:t}),r==null||r.look(e,t).then(k=>{m&&u(k)}),()=>{m=!1}},[r,o,e,t,i]);const h=_.useMemo(()=>{if(c===null||l===void 0)return null;const m=c.split(`
|
|
223
|
+
`),k=n-l,g=Math.max(1,k-XF),y=Math.min(m.length,k+QF);if(g>y)return null;const b=m.slice(g-1,y);return{from:g,at:k,slice:b,painted:Xk(b.join(`
|
|
224
|
+
`),Yk("",t))}},[c,l,n,t]);if(!h)return null;const p=String(h.from+h.slice.length-1).length;return d.jsx("pre",{className:"pick-peek",children:h.slice.map((m,k)=>{const g=h.from+k,y=h.painted[k];return d.jsxs("span",{className:"pick-peek-line","data-state":g===h.at?"current":void 0,children:[d.jsx("span",{className:"pick-peek-n",children:String(g).padStart(p)}),y!=null&&y.length?d.jsx(sg,{pieces:y}):m||" "]},g)})})}function e8(e){return e.startsWith("!")?e.slice(1).trim():null}function lw(e){if(e.kind!=="tool"||e.name!==ui&&e.name!==e1)return null;const t=e.input;return typeof(t==null?void 0:t.command)=="string"?t.command:null}function AN(e){var t;return e.kind!=="tool"||e.name!==ui||(t=e.input)!=null&&t.landing?null:lw(e)}function t8(e){return e.length>0&&e.every(t=>t.kind==="tool"&&AN(t)!==null&&t.done&&!t.isError)}function n8(e){const t=[],n=new Set(e.flatMap(r=>r.kind==="asked"&&r.toolId?[r.toolId]:[]));for(let r=e.length-1;r>=0;r--){const o=e[r];if(o.kind==="user")break;if(o.kind!=="tool"||!o.done||n.has(o.id))continue;const i=lw(o);if(i===null)continue;const l=hN(o.output??"").map(u=>u.text).join(`
|
|
225
|
+
`),c=y2(l);t.unshift(`$ ${i}${c?`
|
|
226
|
+
${c}`:""}`)}if(t.length!==0)return`Shell commands the user ran since their last message, and what each printed:
|
|
227
|
+
${t.join(`
|
|
228
|
+
`)}`}const kx={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 IN(e,t,n,r){const o=e[0];if(!o||!n)return[];const i=Xf(al(o),t);return i?i.startsWith("/")?[{label:"open",tip:kx.file,open:()=>qm(r,n.id,{href:i,path:i})}]:[...pi(i)==="preview"?["preview"]:[],...o.toolKind==="edit"?["diff"]:[],"file"].map(c=>({label:`open ${c}`,tip:kx[c],open:()=>tr(r,{worktreeId:n.id,path:i,view:c})})):[]}const r8=(...e)=>IN(...e)[0]??null;function o8(e,t,n,r,o){const{sock:i}=r,l=e[0];if(!l)return[];const c=[],u=Xf(al(l),t),h=IN(e,t,n,r).map(S=>({id:S.label.replace(" ","-"),label:S.label,onClick:S.open}));u&&!u.startsWith("/")&&n?c.push(...h,...ds(()=>i==null?void 0:i.send({t:"reveal",worktreeId:n.id,path:u}),Is(i))):u.startsWith("/")&&c.push(...h,...ds(()=>i==null?void 0:i.send({t:"reveal-path",path:u}),Is(i)));const p=[],m=al(l);u&&m&&p.push({id:"copy-path",label:"copy path",onClick:()=>Jt(m)});const k=Fc(l,t).command,g=tF(l);g&&g!==k&&p.push({id:"copy-description",label:"copy description",onClick:()=>Jt(g)}),k&&p.push({id:"copy-command",label:"copy command",onClick:()=>Jt(k)});const y=e.map(S=>S.output??"").filter(Boolean).join(`
|
|
229
|
+
`);y&&p.push({id:"copy-output",label:"copy output",onClick:()=>Jt(y)});const b=o.leaf?[]:[{id:"fold",label:o.open?"collapse":"expand",onClick:o.toggle}];return Ln([c,p,b])}const RN=e=>e.replace(/\n$/,""),s8=1500,wx=4;function $N(e){return e.closest(".md pre, .card-code pre")}function ig(e){const t=$N(e);return t?RN(t.textContent??""):null}function i8(e,t){const n=e.getBoundingClientRect(),r=t.getBoundingClientRect();return{pre:t,top:r.top-n.top+e.scrollTop+wx,right:n.left+e.clientLeft+e.clientWidth-r.right+wx}}function cw(e){const[t,n]=_.useState(null),[r,o]=_.useState(null);if(_.useEffect(()=>{const h=e.current;if(!h)return;const p=k=>{if(!(k.target instanceof Element)||k.target.closest(".code-copy"))return;const g=$N(k.target);n(g&&h.contains(g)?i8(h,g):null)},m=()=>n(null);return h.addEventListener("pointerover",p),h.addEventListener("pointerleave",m),()=>{h.removeEventListener("pointerover",p),h.removeEventListener("pointerleave",m)}},[e]),_.useEffect(()=>{if(!r)return;const h=setTimeout(()=>o(null),s8);return()=>clearTimeout(h)},[r]),!(t!=null&&t.pre.isConnected))return null;const{pre:i,top:l,right:c}=t,u=r===i;return d.jsx(Rt,{className:"code-copy",style:{top:l,right:c},icon:u?"check":"copy",label:u?"Copied":"Copy code",onClick:()=>{Jt(RN(i.textContent??"")),o(i)}})}function Jp({text:e,menu:t,marked:n,worktreeId:r,fileRoot:o,streaming:i}){const l=Qk(e,{fileRoot:o,streaming:i}),c=pt(),u=ut(),h=bn("chat"),p=_.useRef(null);YE(p,l);const m=L(y=>{var b;return r?(b=y.local[r])==null?void 0:b.refusedLink:void 0});gt([l,m],()=>{var b;const y=p.current;if(y)for(const S of y.querySelectorAll("a.file-link, code[data-path]")){const j=S.getAttribute("href")??S.dataset.path,E=m!==void 0&&j===m.href;S.classList.toggle("file-link-refused",E),E?((b=S.dataset).tipWas??(b.tipWas=S.dataset.tip??""),S.dataset.tip=m.message,S.dataset.tipPlacement="bottom",S.dispatchEvent(new MouseEvent("mouseover",{bubbles:!0}))):S.dataset.tipWas!==void 0&&(S.dataset.tipWas?(S.dataset.tip=S.dataset.tipWas,S.dataset.tipPlacement="follow"):(delete S.dataset.tip,delete S.dataset.tipPlacement),delete S.dataset.tipWas)}});const k=_.useRef(null),g=cw(k);return d.jsxs("div",{ref:k,className:"msg-assistant md row-edge","data-state":vr({cursor:n}),...h.contextMenu((y,b)=>t(zk(b,o),ig(b))),onClick:y=>Fk(y,o,r,{sock:c,dispatch:u}),children:[d.jsx("div",{ref:p}),g]})}const em=40;function ON(e,t){return e.map(n=>{const r=Yk(n.lang,t||(n.diff?b6(n.text):""));if(n.diff){const o=iF(n.text);return{...n,lines:o,painted:S6(o,r)}}return{...n,lines:[],painted:n.code?Xk(n.text,r):[]}})}function MN({blocks:e,path:t,worktreeId:n}){pt();const r=ut();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,em).map((l,c)=>{var u;return l.kind==="hunk"?d.jsx("span",{className:"dl hunk",title:l.text},c):d.jsx("span",{className:`dl ${l.kind}`,children:(u=o.painted[c])!=null&&u.length?d.jsx(sg,{pieces:o.painted[c]}):l.text||" "},c)}),o.lines.length>em&&d.jsxs("button",{type:"button",className:"dl more",disabled:!t||!n,"data-tip":t&&n?"Open this file's diff":void 0,onClick:()=>n&&tr({dispatch:r},{worktreeId:n,path:t,view:"diff"}),children:[o.lines.length-em," more lines"]})]},i):o.code?d.jsx("pre",{className:"tool-block",children:o.painted.length?o.painted.map((l,c)=>d.jsxs(_.Fragment,{children:[c>0?`
|
|
230
|
+
`:null,d.jsx(sg,{pieces:l})]},c)):o.text},i):d.jsx("p",{className:"tool-note",children:o.text},i))})}function a8({image:e,worktreeId:t}){const n=Lr().attachment(t,e.file),[r,o]=_.useState(!1),i=bn("chat");return d.jsxs(d.Fragment,{children:[d.jsx("button",{type:"button",className:"tool-image","data-tip":"Open full size","data-tip-placement":"follow",onClick:()=>o(!0),...i.contextMenu(()=>zc(n,{open:()=>o(!0)})),children:d.jsx("img",{src:n,alt:e.file})}),r&&d.jsx(Lk,{owner:"chat",onClose:()=>o(!1),menu:()=>zc(n),children:d.jsx("img",{src:n,alt:e.file})})]})}const l8=_.memo(function({item:t,roots:n,worktreeId:r}){const o=_.useMemo(()=>ON(tg(t,t.output??""),al(t)),[t]),i=Fc(t,n).command,l=r?t.images??[]:[];return!i&&o.length===0&&l.length===0?null:d.jsxs("div",{className:"tool-part",children:[i&&d.jsx("pre",{className:"tool-block cmd",children:i}),o.length>0&&d.jsx(MN,{blocks:o,path:PN(t,n),worktreeId:r}),l.length>0&&r&&d.jsx("div",{className:"tool-out",children:l.map(c=>d.jsx(a8,{image:c,worktreeId:r},c.file))})]})});function PN(e,t){const n=Xf(al(e),t??[]);return n.startsWith("/")?"":n}const c8=_.memo(function({text:t,item:n,roots:r,worktreeId:o}){const i=al(n),l=_.useMemo(()=>ON([{code:!0,diff:!0,lang:"diff",text:t}],i),[t,i]);return d.jsx("div",{className:"tool-part",children:d.jsx(MN,{blocks:l,path:PN(n,r),worktreeId:o})})});function ag({className:e,state:t,auto:n,leaf:r,growing:o,label:i,summary:l,menu:c,children:u}){const[h,p]=_.useState(null),m=_.useRef(null),k=_.useRef(null),g=VE(k),y=yL(".chat-log"),b=!r&&(h??n),S=()=>{r||(b||y(m.current),p(!b))},j=bn("chat");return d.jsxs("details",{ref:m,className:Ke(e,r&&"leaf"),"data-state":t,open:b,onToggle:E=>{if(!E.currentTarget.open||o)return;const N=k.current;N&&(N.scrollTop=0,g.read())},...j.contextMenu((E,N)=>c({open:b,leaf:!!r,toggle:S},N)),tabIndex:-1,onPointerDown:()=>{var E;return(E=m.current)==null?void 0:E.focus({preventScroll:!0})},onKeyDown:E=>{if((E.key==="ArrowLeft"||E.key==="ArrowRight")&&!r){if(E.shiftKey||E.altKey||E.metaKey||E.ctrlKey)return;qf([{depth:0,open:b}],0,E.key)&&S();return}E.key!=="Escape"||!b||(E.stopPropagation(),p(!1))},children:[d.jsx("summary",{"aria-label":i,tabIndex:r?-1:void 0,onClick:E=>{E.preventDefault(),S()},children:l}),d.jsx("div",{className:"tool-body",ref:k,children:u})]})}const u8=_.memo(function({item:t,open:n,streaming:r,worktreeId:o,fileRoot:i}){const l=sN(t.text),c=l.slice(0,-1),u=Qk(l.length?c.join(`
|
|
231
|
+
|
|
232
|
+
`):rN(t.text),i?{fileRoot:i}:void 0),h=pt(),p=ut(),m=r?"Thinking":"Thought",k=_.useRef(null);YE(k,u);const g=_.useRef(null),y=cw(g),b=d.jsx("div",{className:"tool-part",children:d.jsxs("div",{ref:g,className:"tool-out thought-out md",onClick:j=>Fk(j,i,o,{sock:h,dispatch:p}),children:[d.jsx("div",{ref:k}),y]})}),S=l.at(-1)??(r?"":iN(t.text));if(S){const j=c.length===0;return d.jsx(ag,{className:"tool-row",auto:!1,leaf:j,growing:r,label:S,menu:(E,N)=>Ln([Gm(ig(N)),[{id:"copy",label:"copy thought",onClick:()=>Jt(t.text)}],...j?[]:[[{id:"fold",label:E.open?"collapse":"expand",onClick:E.toggle}]]]),summary:d.jsxs(d.Fragment,{children:[d.jsx(St,{name:"bulb",className:"tool-icon"}),d.jsx("span",{className:Ke("tool-hint thought-line",r&&"live-text"),children:S})]}),children:j?null:b})}return d.jsx(ag,{className:"tool-row",auto:!!n,growing:r,label:m,menu:(j,E)=>Ln([Gm(ig(E)),[{id:"copy",label:"copy thought",onClick:()=>Jt(t.text)}],[{id:"fold",label:j.open?"collapse":"expand",onClick:j.toggle}]]),summary:d.jsxs(d.Fragment,{children:[d.jsx(St,{name:"bulb",className:"tool-icon"}),d.jsx("span",{className:Ke("tool-name",r&&"live-text"),children:m})]}),children:b})}),Ki=6,d8={land:"the land",commit:"the commit","sync-main":"the sync","pull-main":"the pull"},Nd=_.memo(function e({tools:t,run:n,next:r,live:o,working:i,held:l,since:c,queued:u,roots:h,worktreeId:p,marked:m}){const k=t[0],g=_.useMemo(()=>UF(t.map(be=>tg(be,be.output??""))),[t]),y=t.at(-1)??k,b=!y.done,S=b&&!!y.background,E=(b||!!r||!!l)&&!u||!!i,N=b&&!!u,A=Qi(b||i?c:void 0),O=n?kF(n):-1,P=_.useMemo(()=>n?gN(n,!0):void 0,[n]),R=!!o,T=Fc(k,h),$=b?eF(k):"",{label:D,icon:z}=T,V=dN(k),se=$?"":V?"Guardian":T.name,I=$&&k.subagent?T.hint:"",ne=I||$||(V?Y6(k.output??""):T.hint),we=!(n&&n.length>0)&&!g&&t.every(be=>{var le;return!Fc(be,h).command&&tg(be,be.output??"").length===0&&!((le=be.images)!=null&&le.length)}),K=n?hF(n):0,B=t8(t),ee=[D,ne].filter(Boolean).join(" ")+(S?", in the background":"")+(N?", queued":"")+(B?", done":""),J=$?"":n?`${K} ${K===1?"call":"calls"}`:t.length>1?`×${t.length}`:"",W=Zn(),ie=pt(),Te=L(be=>{var le;return p?(le=be.shipping[p])==null?void 0:le.op:void 0}),Ce=b&&k.name===ui&&p?{worktreeId:p,toolId:y.id}:null,de=b?null:(()=>{const be=pn(W.getState(),p);return r8(t,h??[],be?{id:be.worktree.id}:null,{sock:ie,dispatch:W.dispatch})})();return d.jsxs(ag,{className:Ke("tool-row",t.some(be=>be.isError)&&"error",k.parentToolId&&"nested",n&&"spawn",N&&"queued"),state:vr({cursor:m}),auto:R,leaf:we,growing:E,label:n&&J?`${ee}, ${J}`:t.length>1?`${ee}, ${t.length} calls`:ee,menu:be=>{const le=pn(W.getState(),p),G=le?{id:le.worktree.id}:null;return o8(t,h??[],G,{sock:ie,dispatch:W.dispatch},be)},summary:d.jsxs(d.Fragment,{children:[d.jsx(St,{name:n?"spawn":z,className:"tool-icon"}),se&&d.jsx("span",{className:Ke("tool-name",E&&!ne&&"live-text"),children:se}),$&&!I?d.jsx("span",{className:"tool-writing","data-tip":ne,children:d.jsx(il,{variant:"squares"})}):ne&&d.jsx("span",{className:Ke("tool-hint",E&&"live-text"),children:ne}),S&&d.jsx("span",{className:"tool-status",children:"in the background"}),N&&d.jsx("span",{className:"tool-status",children:"queued"}),B&&d.jsx(St,{name:"check",className:"tool-done"}),A>=Ki&&d.jsx("span",{className:Ke("tool-age",O>=0&&"tool-age-folded"),children:Gi(A)}),J&&d.jsx("span",{className:"tool-count",children:J}),I&&d.jsx("span",{className:"tool-writing","data-tip":$,children:d.jsx(il,{variant:"squares"})}),Ce&&d.jsx(Rt,{icon:"stop",className:"tool-stop",label:Te?`Stop ${d8[Te]}: this step is killed, and what it printed so far stays`:S?"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:be=>{be.preventDefault(),be.stopPropagation(),ie==null||ie.send({t:"exec-stop",...Ce})}}),de&&d.jsx(Rt,{icon:"eye",className:"tool-open",label:de.tip,onClick:be=>{be.preventDefault(),be.stopPropagation(),de.open()}})]}),children:[n&&n.length>0&&d.jsx("div",{className:"spawn-run",children:n.map((be,le)=>d.jsx(e,{tools:be.tools,next:be.next,since:le===O?c:void 0,queued:P==null?void 0:P.has(le),roots:h,worktreeId:p},be.at))}),g?d.jsx(c8,{text:g,item:k,roots:h,worktreeId:p}):t.map(be=>d.jsx(l8,{item:be,roots:h,worktreeId:p},be.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&&nw(e.tools,t.tools)&&kN(e.run,t.run));function f8({item:e}){const t=pt(),n=ut(),r=L(y=>y.activeId),o=L(y=>y.layout.term),i=L(y=>{var b;return((b=y.rows.find(S=>S.id===y.activeId))==null?void 0:b.login)??!1}),l=L(y=>y.managed.problem),[c,u]=_.useState(""),[h,p]=_.useState(null),m=_.useRef(!1);if(gt([i],()=>{i&&m.current&&r&&n({a:"term-stream",id:r,stream:Cs,tall:!0})}),gt([e.done],()=>{e.done&&m.current&&o&&n({a:"toggle-terminal"}),m.current=!1}),!r)return null;const k=(y,b)=>{t==null||t.send({t:"agent-auth",worktreeId:r,methodId:y,...b?{apiKey:b}:{}})},g=e.methods.find(y=>y.id===h);return d.jsxs("div",{className:`auth-card ${e.done?"done":""}`,children:[d.jsx("div",{className:"auth-title",children:e.done?`${e.agentName} is logged in`:e.rejected?`${e.agentName}'s credentials were refused`:`${e.agentName} is not logged in`}),!e.done&&d.jsxs("div",{className:"auth-methods",children:[e.methods.map(y=>y.needsKey?d.jsx(De,{variant:"outline",on:h===y.id,"data-tip":y.description,onClick:()=>p(h===y.id?null:y.id),children:y.name},y.id):d.jsx(De,{variant:"outline","data-tip":y.kind==="terminal"?"opens in the terminal pane":y.description,onClick:()=>{k(y.id),y.kind==="terminal"&&(m.current=!0)},children:y.name},y.id)),d.jsx(De,{variant:"outline","data-tip":"after logging in elsewhere (the terminal, another window)",onClick:()=>t==null?void 0:t.send({t:"agent-retry",worktreeId:r}),children:"send again"})]}),!e.done&&i&&d.jsx("div",{className:"hint auth-hint",children:"paste the code into the login tab below and press Enter; it stays hidden as you paste. Your message sends once you are in."}),!e.done&&e.withheld&&d.jsx("div",{className:"hint auth-hint",children:l?"the policy file on this machine is invalid, so signing in with a Claude plan is off until it is fixed; toyon doctor says why":"signing in with a Claude plan is managed by your organization"}),!e.done&&g&&d.jsxs("form",{className:"auth-key",onSubmit:y=>{y.preventDefault(),c.trim()&&(k(g.id,c.trim()),u(""),p(null))},children:[d.jsx(jo,{type:"password",autoFocus:!0,placeholder:`${g.name} for ${e.agentName}`,value:c,onChange:y=>u(y.target.value)}),d.jsx(De,{type:"submit",children:"use key"})]})]})}const h8=_.memo(function({item:t,worktreeId:n,onPickHover:r,marked:o,streaming:i}){const l=Zn(),c=pt(),u=Lr(),h=bn("chat"),p={sock:c,dispatch:l.dispatch},m=()=>{var k;return(k=pn(l.getState(),n))==null?void 0:k.worktree.path};switch(t.kind){case"user":{const k=m();return d.jsxs("div",{className:"msg-user row-edge","data-state":vr({cursor:o}),...h.contextMenu((g,y)=>Bi(t,n??null,p,{link:zk(y,k)})),onClick:g=>CN(g,k,n,p),children:[t.attachments&&n&&d.jsx("div",{className:"msg-attachments",children:t.attachments.map(g=>g.kind==="image"?d.jsx(_F,{img:g,src:u.attachment(n,g.file)},`${g.kind}-${g.n}`):g.kind==="file"?d.jsx(ew,{className:"in-chat",name:g.name,bytes:g.bytes,href:g.text?u.attachment(n,g.file):void 0},`${g.kind}-${g.n}`):g.kind==="paste"?d.jsx(Jk,{className:"in-chat",n:g.n,name:g.name,source:g.source,lines:g.lines,chars:g.chars,preview:g.preview,href:u.attachment(n,g.file)},`${g.kind}-${g.n}`):d.jsx(aw,{pick:g,className:"in-chat",tipText:"Hover to highlight on the page",onHover:y=>r==null?void 0:r(g,y),worktreeId:n,onOpen:(y,b)=>ea(l,c,n,y,b)},`${g.kind}-${g.n}`))}),d.jsx(jN,{text:t.text,worktreeId:n,root:k})]})}case"assistant":return d.jsx(Jp,{text:t.text,menu:(k,g)=>Bi(t,n??null,p,{link:k,code:g}),marked:o,worktreeId:n,fileRoot:m(),streaming:i});case"error":return d.jsx("div",{className:"msg-assistant msg-error",...h.contextMenu(()=>Bi(t,n??null,p)),children:t.text});case"auth":return d.jsx(f8,{item:t});case"ask":{const k=dP(t);if(k){const S=Yg(k.questions,k.answers).join(`
|
|
233
|
+
`),j={kind:"assistant",text:S};return d.jsxs(d.Fragment,{children:[d.jsx(Jp,{text:k.message,menu:(E,N)=>Bi({kind:"assistant",text:k.message},n??null,p,{link:E,code:N}),worktreeId:n,fileRoot:m()}),d.jsx("div",{className:"msg-user",...h.contextMenu(()=>Bi(j,n??null,p)),children:S})]})}const g=fP(t);if(!g)return d.jsx(Gz,{item:t});const y=g.file,b={kind:"assistant",text:g.choice};return d.jsxs(d.Fragment,{children:[y?d.jsx(Wr,{icon:"file",word:"plan",tone:"quiet",children:d.jsx("span",{className:"daemon-text",children:d.jsx(De,{variant:"inline",tone:"strong",mono:!0,onClick:()=>n&&tr(p,{worktreeId:n,path:y,view:"preview"}),children:y})})}):g.text&&d.jsx(Jp,{text:g.text,menu:(S,j)=>Bi({kind:"assistant",text:g.text},n??null,p,{link:S,code:j}),worktreeId:n,fileRoot:m()}),d.jsx("div",{className:"msg-user",...h.contextMenu(()=>Bi(b,n??null,p)),children:g.choice})]})}case"blocked":return d.jsxs(Wr,{icon:"lock",word:"blocked",tone:"red",below:d.jsx("div",{className:"daemon-below row-dim",children:t.reason}),...h.contextMenu(()=>b_(t.path,void 0,Is(p.sock))),children:[d.jsx("span",{className:"tool-name",children:t.tool}),t.path&&d.jsx("span",{className:"tool-hint",children:t.path})]});case"grafted":return d.jsxs(Wr,{icon:"layers",word:"grafted",tone:"accent","data-tip":`what follows was said in ${t.title} before it was merged in here`,"data-tip-placement":"follow",children:[d.jsx("span",{className:"tool-name",children:t.title}),d.jsx("span",{className:"tool-hint",children:t.branch})]});case"asked":return d.jsx(Wr,{icon:"send",word:"asked",tone:"quiet",children:d.jsx("span",{className:"daemon-text",children:t.why})});case"stopped":return d.jsx(Wr,{icon:"stop",word:"stopped",tone:"quiet"});case"page-error":return d.jsx(Wr,{icon:"globe",word:"preview threw",tone:"quiet",below:t.errors.map(k=>d.jsx("code",{className:"daemon-text",children:k},k))});case"landed":return d.jsx(m8,{item:t});case"handoff":return d.jsx(EF,{item:t});case"handoff-landed":return d.jsx(SF,{item:t});case"restored":return d.jsx(p8,{item:t});case"adopted":return d.jsx(Wr,{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 p8({item:e}){return d.jsx(Wr,{icon:"reload",word:"restored",tone:"quiet",at:e.ts,children:d.jsxs("span",{className:"daemon-text",children:["after ",ok(e.ts-e.archivedAt)," in the archive, back on ",e.branch,e.uncommitted?" with its uncommitted changes":""]})})}function m8({item:e}){const t=pt(),n=ut(),r=L(l=>e.archiveIds.filter(c=>pn(l,c)!==null).length),o=c_(e.ts),i=e.mark&&Ak(e.mark);return d.jsxs(Wr,{icon:"check",word:"landed",tone:"aqua",at:e.ts,below:i?d.jsx("div",{className:"daemon-below row-dim",children:Kr(i)}):void 0,children:[d.jsxs("span",{className:"daemon-text",children:[e.text,", ",o]}),r>0&&d.jsx(De,{variant:"inline",tone:"strong",onClick:()=>Ji(t,n,e.archiveIds),children:r>1?`archive ${r} worktrees`:"archive the other worktree"})]})}const LN=e=>e===""||e==="!";function yx(e,t){const n=new Set,r=[];for(let o=e.length-1;o>=0;o--){const i=e[o],l=AN(i),c=l!==null?`!${l}`:i.kind==="user"&&!t?i.text:null;c===null||!c.trim()||n.has(c)||(n.add(c),r.push({text:c,at:o}))}return r}function g8(e,t,n,r){if(!t){if(r!=="up"&&r!=="first"||!LN(n))return null;const c=yx(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=yx(e,t.from==="!"),i=r==="first"?o.length-1:o.findIndex(c=>c.at===t.at)+(r==="up"?1:-1);if(i<0)return{walk:null,text:t.from};const l=o[i];return l?{walk:{at:l.at,from:t.from},text:l.text}:{walk:t,text:n}}function k8(e,t,n,r){const o=new Map;return{rows:t.map((l,c)=>{const u=n(l,c),h=e.get(l.at),p=h&&h.row.kind===u.kind&&w8(h.row.props,u.props)?h.el:r(l,u);return o.set(l.at,{row:u,el:p}),p}),cache:o}}function w8(e,t){const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(const o of n){if(!(o in t))return!1;const i=e[o],l=t[o];if(!Object.is(i,l)&&(!Array.isArray(i)||!Array.isArray(l)||i.length!==l.length||!i.every((c,u)=>Object.is(c,l[u]))))return!1}return!0}const vx={get current(){return Sc.el}};function lg({items:e,next:t,worktreeId:n,onOpen:r}){const o=Lr();return d.jsx("div",{className:"msg-attachments",children:jg(e,t).map(([i,l])=>i.kind==="image"?d.jsx(rw,{className:"in-chat",src:"local"in i&&i.local||o.upload(i.upload),n:l,name:i.name,width:i.width,height:i.height,bytes:i.bytes,progress:"progress"in i?i.progress:void 0},`image-${l}`):i.kind==="file"?d.jsx(ew,{className:"in-chat",name:i.name,bytes:i.bytes,href:i.text&&i.upload?o.upload(i.upload):void 0,progress:"progress"in i?i.progress:void 0},`file-${l}`):i.kind==="paste"?d.jsx(Jk,{className:"in-chat",n:l,name:i.name,source:i.source,...Bg(i.text),text:i.text},`paste-${l}`):d.jsx(aw,{className:"in-chat",pick:i,worktreeId:n,onOpen:r},`pick-${l}`))})}function y8({entry:e,next:t,worktreeId:n,onOpen:r}){const o=ut(),i=It(e.id,"draft"),l=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:"queued-word",children:"uploading"})]}),d.jsxs("div",{className:"queued-text",children:[l.length>0&&d.jsx(lg,{items:l,next:t,worktreeId:n,onOpen:r}),i]}),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})})]})]})}const v8=new Set,b8=90;function tm({active:e,archived:t,found:n,lead:r,tail:o}){var Ot;const i=pt(),l=Zn(),c=ut(),u=L(Ee=>Ee.frame==="phone"),h=(e==null?void 0:e.worktree.id)??(t==null?void 0:t.id)??(n==null?void 0:n.id)??null,p=It(h,"chat"),m=It(h,"queue"),k=It(h,"sending"),g=_.useMemo(()=>mm(p.map(Ee=>Ee.kind==="user"?Ee.attachments:void 0)),[p]),y=_.useMemo(()=>{let Ee=g;return m.map($e=>{const Wt=Ee;return Ee=yc(Ee,$e.attachments??[]),Wt})},[m,g]),b=L(Ee=>Ee.outbox),S=_.useMemo(()=>{let Ee=m.reduce(($e,Wt)=>yc($e,Wt.attachments??[]),g);return b.filter($e=>$e.log===h).map($e=>{const Wt=Ee;return Ee=yc(Ee,$e.kinds.map(ft=>({kind:ft}))),{entry:$e,next:Wt}})},[b,h,m,g]),j=k!=null&&k.message?m.findIndex(Ee=>{var $e;return Ee.text===(($e=k.message)==null?void 0:$e.text)}):-1,E=_.useRef(null);Az(E);const[N,A]=_.useState(null),O=_.useCallback(()=>{const Ee=(E.current&&Zm(E.current))??"";A($e=>({seed:Ee||($e==null?void 0:$e.seed)||"",seq:(($e==null?void 0:$e.seq)??0)+1}))},[]),P=_.useCallback(Ee=>!(Ee!=null&&Ee.closest("[data-pane]"))&&!l.getState().overlay,[l]);m_(vx,Pk,O,P);const R=Ee=>{if(A(null),Ee){const $e=window.getSelection();$e==null||$e.removeAllRanges(),$e==null||$e.addRange(Ee)}},T=VE(E,p);gt([h],()=>T.jump());const $=T.offStart&&T.moving==="up",D=T.offEnd&&(T.moving==="down"||T.away),z=Ee=>Ee.preventDefault(),V=($||D)&&d.jsxs("div",{className:Ke("jump",T.away&&"jump-news"),children:[$&&d.jsx("button",{className:"jump-up",onMouseDown:z,onClick:T.start,"data-tip":"Jump to start",children:d.jsx(St,{name:"caret-up",className:"icon-inline"})}),D&&d.jsxs("button",{className:"jump-down",onMouseDown:z,onClick:T.jump,"data-tip":"Jump to latest",children:[d.jsx(St,{name:"caret",className:"icon-inline"}),T.away&&" new messages"]})]});_.useEffect(()=>{const Ee=E.current;if(!u||!T.offEnd||!Ee){c({a:"reading",on:!1});return}const $e=()=>{var ft,Z;const Wt=((Z=(ft=vx.current)==null?void 0:ft.querySelector(":scope > .chat-input"))==null?void 0:Z.offsetHeight)??0;Ee.scrollHeight-Ee.scrollTop-Ee.clientHeight<=Wt+Dd+b8||(c({a:"reading",on:!0}),Ee.removeEventListener("scroll",$e))};return $e(),Ee.addEventListener("scroll",$e,{passive:!0}),()=>Ee.removeEventListener("scroll",$e)},[u,T.offEnd,c]),_.useEffect(()=>()=>c({a:"reading",on:!1}),[c]);const se=It(h,"mark"),I=(se==null?void 0:se.by)==="walk"?se.at:void 0,ne=_.useRef(null),we=()=>{const Ee=E.current,$e=Ee==null?void 0:Ee.querySelector(':scope > [data-state~="cursor"]');if(!Ee||!$e)return;const Wt=parseFloat(getComputedStyle(Ee).paddingTop)||0;Ee.scrollTop+=$e.getBoundingClientRect().top-Ee.getBoundingClientRect().top-Wt,T.read()};gt([I],()=>{const Ee=E.current;if(Ee){if(I===void 0){const $e=ne.current;if(ne.current=null,!$e||!LN(Co(l.getState(),h).draft))return;$e.bottom?T.jump():(Ee.scrollTop=$e.top,T.read());return}ne.current??(ne.current={bottom:T.pinned(),top:Ee.scrollTop}),we()}});const K=It(h,"sent");gt([K],()=>{K&&T.jump()});const B=S.length,ee=_.useRef(B);gt([B],()=>{B>ee.current&&T.jump(),ee.current=B});const J=(se==null?void 0:se.by)==="reveal"?se:void 0,W=_.useMemo(()=>J?xF(p,J.seq):-1,[p,J]),ie=I??(W>=0?W:void 0);gt([J==null?void 0:J.n,W],()=>{W>=0&&we()});const Te=_.useCallback((Ee,$e)=>{h&&($e?cn.post(h,{type:"highlight-selector",selector:Ee.selector,label:rk(Ee)}):cn.post(h,{type:"highlight-clear"}))},[h]),Ce=!!e&&Vc(e),de=It(h,"cardParked"),be=_.useMemo(()=>{const Ee=_k(p);return!!Ee&&de!==Ee.id},[p,de]),le=e==null?void 0:e.worktree,G=(le==null?void 0:le.path)??(t==null?void 0:t.path)??(n==null?void 0:n.path),ce=_.useMemo(()=>G?[G]:[],[G]),oe=_.useMemo(()=>fF(p,ce),[p,ce]),re=_.useMemo(()=>Ce?pF(p):v8,[Ce,p]),Le=_.useMemo(()=>mF(oe,re),[oe,re]),Ue=Le.floating,_e=_.useRef([]),je=_.useMemo(()=>(_e.current=wF(_e.current,Le.flow),_e.current),[Le]),Ne=(e==null?void 0:e.agent)==="working",qe=Ne||(e==null?void 0:e.agent)==="waiting",Ft=_.useMemo(()=>qe?vF(je):-1,[qe,je]),qt=je.at(-1),jt=Ne&&qt&&"item"in qt&&(qt.item.kind==="thinking"||qt.item.kind==="assistant")?je.length-1:-1,Ht=(Ot=oe.findLast(Ee=>{var $e;return"tools"in Ee&&(($e=Ee.tools[0])==null?void 0:$e.name)===ui}))==null?void 0:Ot.at,sn=It(h,"chatAt"),Ct=Qi(Ce?sn:void 0),He=It(h,"usage"),Ze=(He==null?void 0:He.heard)!==void 0&&sn!==void 0&&He.heard>sn?He.heard:void 0,At=Qi(Ce?Ze:void 0),_t=Qi(k&&!Ce?k.at:void 0),kt=gF(p),Fn=Ue.length>0,un=jt>=0||kt||Fn,xn=Ne&&!un&&Ct<Ki?uF(je,ce):-1,$t=_.useMemo(()=>gN(je),[je]),Tn=It(h,"running"),Y=Ee=>Tn&&Ee.tools.some($e=>$e.id===Tn.id)?Tn.at:void 0,pe=e==null?void 0:e.worktree.path,nt=(Ee,$e)=>"spawn"in Ee?{kind:"tool",props:{tools:[Ee.spawn],run:Ee.run,roots:ce,worktreeId:h}}:"tools"in Ee?{kind:"tool",props:{tools:Ee.tools,next:Ee.next,live:$e===Ft||Ee.at===Ht,held:$e===xn,since:Y(Ee),queued:$t.has($e),roots:ce,worktreeId:h,marked:Ee.at===ie}}:Ee.item.kind==="thinking"?{kind:"thought",props:{item:Ee.item,open:$e===Ft,streaming:$e===jt,worktreeId:h,fileRoot:pe}}:{kind:"item",props:{item:Ee.item,worktreeId:h,onPickHover:Te,marked:Ee.at===ie,streaming:Ne&&$e===je.length-1}},dt=_.useRef(new Map),Bt=k8(dt.current,je,nt,(Ee,$e)=>$e.kind==="tool"?d.jsx(Nd,{...$e.props},Ee.at):$e.kind==="thought"?d.jsx(u8,{...$e.props},Ee.at):d.jsx(h8,{...$e.props},Ee.at));return dt.current=Bt.cache,d.jsxs("div",{className:"chat-wrap",children:[d.jsxs("div",{className:"chat-log",ref:E,children:[r,Bt.rows,Ue.map(Ee=>{var $e;return"spawn"in Ee?d.jsx(Nd,{tools:[Ee.spawn],run:Ee.run,working:!0,since:sn,roots:ce,worktreeId:h},Ee.at):(($e=Ee.tools[0])==null?void 0:$e.name)===ui?d.jsx(Nd,{tools:Ee.tools,live:Ee.at===Ht,since:Y(Ee),roots:ce,worktreeId:h,marked:Ee.at===ie},Ee.at):d.jsx(Nd,{tools:Ee.tools,since:sn,roots:ce,worktreeId:h},Ee.at)}),h&&(k==null?void 0:k.message)&&d.jsxs("div",{className:"msg-user",children:[k.message.attachments&&d.jsx(lg,{items:k.message.attachments,next:g,worktreeId:h,onOpen:(Ee,$e)=>ea(l,i,h,Ee,$e)}),k.message.text]}),e&&(k||Ce&&!(e.agent==="waiting"&&be)&&!kt&&!Fn&&xn<0&&!(un&&Ct<Ki))&&d.jsx("div",{className:"working-row",children:e.agent==="waiting"?"waiting for your answer…":un?Ct>=Ki&&d.jsxs("span",{children:["quiet for",d.jsx("span",{className:"working-num",children:Gi(Ct)})]}):d.jsxs("span",{className:"working-mark",children:[d.jsx(il,{variant:"squares"}),!Ce&&k?_t>=Ki&&d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"working-word",children:"waiting for the agent"}),d.jsx("span",{className:"working-num",children:Gi(_t)})]}):Ze!==void 0?At>=Ki&&d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"working-word",children:"thinking"}),d.jsx("span",{className:"working-num",children:Gi(At)})]}):Ct>=Ki&&d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"working-word",children:"waiting for the model"}),d.jsx("span",{className:"working-num",children:Gi(Ct)})]})]})}),h&&m.map((Ee,$e)=>$e===j?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"}),d.jsx("span",{className:"queued-word",children:"queued"})]}),d.jsxs("div",{className:"queued-text",children:[Ee.attachments&&d.jsx(lg,{items:Ee.attachments,next:y[$e]??g,worktreeId:h,onOpen:(Wt,ft)=>ea(l,i,h,Wt,ft)}),Ee.text]}),d.jsxs("span",{className:"queued-actions",children:[d.jsx(Rt,{icon:"edit",label:"Edit: removes from queue, puts it back in the input",onClick:()=>mS(l,i,h,$e)}),d.jsx(Rt,{icon:"close",label:"Remove from queue",onClick:()=>i==null?void 0:i.send({t:"unqueue",worktreeId:h,index:$e})})]})]},`q-${$e}`)),h&&S.map(({entry:Ee,next:$e})=>d.jsx(y8,{entry:Ee,next:$e,worktreeId:h,onOpen:(Wt,ft)=>ea(l,i,h,Wt,ft)},Ee.id)),o]}),N&&d.jsx(h_,{root:E,body:E,seed:N.seed,seq:N.seq,onClose:R,onReveal:T.read}),V]})}function x8(){try{return localStorage.getItem(Xe.installOffered)==="1"}catch{return!1}}let ff={prompt:null,offered:typeof localStorage<"u"&&x8()};const cg=new Set;function ug(e){ff={...ff,...e};for(const t of cg)t()}typeof window<"u"&&(window.addEventListener("beforeinstallprompt",e=>{e.preventDefault(),ug({prompt:e})}),window.addEventListener("appinstalled",()=>ug({prompt:null})));function DN(e){return cg.add(e),()=>{cg.delete(e)}}function zN(){return _.useSyncExternalStore(DN,()=>ff.prompt)}function E8(){return _.useSyncExternalStore(DN,()=>ff.offered)}function bx(){try{localStorage.setItem(Xe.installOffered,"1")}catch{}ug({offered:!0})}function S8(e){return!e.prompt||e.offered||e.agent!=="idle"?!1:e.chat.some(t=>t.kind==="assistant")}function FN({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(qo,{k:r}),o]},r)),t&&d.jsx("span",{className:"key-note",children:t})]})}const _8={side:"top",align:"start",offset:4,alignOffset:-10,matchWidth:-20,flip:"side",margin:8};function N8({results:e,keyOf:t,row:n,rowClass:r,nav:o,listRef:i,empty:l,note:c}){return d.jsxs($s,{className:"inline-picker",anchor:"parent",placement:_8,children:[d.jsxs("div",{className:"picker-list",ref:i,children:[e.map((u,h)=>d.jsx("button",{className:Ke("picker-item",r==null?void 0:r(u)),"data-state":vr({cursor:h===o.index}),onMouseMove:()=>h!==o.index&&o.setIndex(h),onMouseDown:p=>p.preventDefault(),onClick:()=>o.pick(u),children:n(u,h===o.index)},t(u))),e.length===0&&d.jsx("div",{className:"empty",children:l})]}),d.jsx(FN,{hints:[["↑↓","moves"],["tab","inserts"],["esc","dismisses"]],note:c})]})}const xx=e=>Math.max(0,Math.min(1,Number.isFinite(e)?e:0));function T8({fraction:e,level:t,className:n}){const o=2*Math.PI*5.5,i=xx(e),l=_.useId(),c=3.5,u=2*c*xx(t);return d.jsxs("svg",{className:Ke("ring",n),viewBox:"0 0 14 14",width:"14",height:"14","aria-hidden":"true",children:[t!==void 0&&d.jsxs(d.Fragment,{children:[d.jsx("clipPath",{id:l,children:d.jsx("circle",{cx:"7",cy:"7",r:c})}),d.jsx("rect",{className:"ring-level",clipPath:`url(#${l})`,x:"0",y:7+c-u,width:"14",height:u})]}),d.jsx("circle",{className:"ring-track",cx:"7",cy:"7",r:5.5}),d.jsx("circle",{className:"ring-fill",cx:"7",cy:"7",r:5.5,strokeDasharray:`${o*i} ${o}`})]})}function j8(e,t=Cc.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 uw(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=BN(e);return r&&n.push({id:"install",label:r,onClick:()=>t==null?void 0:t.send({t:"install-agent",agent:e.id})}),n}function BN(e){return e.install?e.install==="missing"?"install":"install again":null}const eh=e=>e.reason??"not installed",as="";function C8(e){var h;const t=I8(e.name);if(t){const p=[t.qualifier,e.description||e.name].filter(Boolean).join(" · ");return{label:t.label,version:t.version,description:p}}const n=e.name.match(/^([A-Za-z]+)-(\d+(?:\.\d+)*)(?:-([A-Z][a-z]+))?$/);if(n!=null&&n[1]&&n[2])return{label:n[3]??n[1],version:n[2],...e.description?{description:e.description}:{}};const[r="",...o]=(e.description??"").split(" · "),i=e.name.replace(/\s*\([^)]*\)$/,""),l=r.match(/^(.+?) (\d+(?:\.\d+)*)(?: with (.+))?$/);if(!(l!=null&&l[2])||l[1]!==i)return{label:e.name,...e.description?{description:e.description}:{}};const u=[l[3]??((h=e.name.match(/\(([^)]*)\)$/))==null?void 0:h[1]),...o].filter(Boolean).join(" · ");return{label:i,version:l[2],...u?{description:u}:{}}}const A8=/(?:^|[./])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 I8(e){const t=e.match(A8),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 UN(e,t,n,r){const o=r1(e),i=aC(e),l=y=>i&&y===(o==null?void 0:o.id)?i.id:y,c=l(t||n||(o==null?void 0:o.id)||as),u=l(t||(o==null?void 0:o.id)||as),h=i?e.filter(y=>y!==o):e,p=h.some(y=>y.id===c),m=h.map(y=>({c:y,words:C8(y)})),k=y=>[y.label,y.version].filter(Boolean).join(" "),g=[...o?[]:[{id:as,label:r.label,description:r.description}],...m.map(({c:y,words:b})=>{const S=m.filter(E=>k(E.words)===k(b)).length===1?b:void 0,j=S?S.description:y.description;return{id:y.id,label:S?S.label:y.name,...S!=null&&S.version?{suffix:S.version}:{},...S!=null&&S.version&&m.some(E=>E.c!==y&&E.words.label===S.label)?{chip:k(S)}:{},description:y===i?["recommended",j].filter(Boolean).join(" · "):j}}),...c&&!p?[{id:c,label:c}]:[]];if(c!==u){const y=g.find(j=>j.id===c),b=g.findIndex(j=>j.id===u),S=g[b];if(S){const j=(y==null?void 0:y.chip)??(y==null?void 0:y.label)??c;g[b]={...S,description:[`${j} now`,S.description].filter(Boolean).join(" · ")}}}return{rows:g,shown:c,picked:u}}const dc=(e,t)=>`${e} ${t}`;function R8(e){const t=e.indexOf(" ");return t<0?{agent:e,model:as}:{agent:e.slice(0,t),model:e.slice(t+1)}}function $8(e,t,n){const r=e.length>1;let o=dc(t,n);return{rows:e.flatMap(l=>{var p;const c=l.short??l.name,u=l.id===t;if(!l.available||!((p=l.models)!=null&&p.length))return u&&(o=dc(l.id,as)),[{id:dc(l.id,as),label:c,description:l.available?"its own default model; the rest are listed once it has run":eh(l),disabled:!l.available}];const h=UN(l.models,u?n:as,void 0,{label:`${c} default`,description:`whatever ${l.name} runs when nothing is asked for`});return u&&(o=dc(l.id,h.shown)),h.rows.map(m=>({...m,id:dc(l.id,m.id),...r&&m.id!==as?{prefix:c}:{}}))}),shown:o}}function Uc({anchored:e=!1,...t}){return e?d.jsx(O8,{...t,anchored:e===!0?{}:e}):d.jsx(M8,{...t})}function O8({onClose:e,onEscape:t,boxClass:n="",bare:r=!1,anchored:o,coverBy:i,id:l,children:c}){const{onKey:u,back:h}=HN(t);return d.jsx($s,{className:Ke(r?"":"overlay-box","anchored",n),id:l,anchor:"parent",placement:{side:"bottom",align:"start",cover:!0,margin:0,...o},coverBy:i,onDismiss:e?()=>e():void 0,onKey:u,onBack:()=>h()||(e==null?void 0:e()),children:c})}function M8({onClose:e,onEscape:t,boxClass:n="",bare:r=!1,id:o,children:i}){const{onKey:l,back:c}=HN(t);return d.jsx($s,{className:"overlay scrim",id:o,onDismiss:e?()=>e():void 0,onKey:l,onBack:()=>c()||(e==null?void 0:e()),onClick:u=>{e&&u.target===u.currentTarget&&e()},children:d.jsx("div",{className:Ke(r?"":"overlay-box",n),children:i})})}function HN(e){const t=Zn(),n=()=>{if(e)return e(),!0;const o=t.getState();return!o.overlay||o.choosingFolder?!1:(t.dispatch({a:"close",back:PE(o.overlay)}),!0)};return{onKey:o=>{o.key==="Escape"&&n()&&o.stopPropagation()},back:n}}function P8(e){const t=e.value.length;e.setSelectionRange(t,t)}function L8({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 Pr({items:e,filter:t,keyOf:n,row:r,rowClass:o,rowTitle:i,onPick:l,onBack:c,onActive:u,onSide:h,onTab:p,onQuery:m,completionOf:k,narrowTo:g,placeholder:y,initialQuery:b="",initialIndex:S,selectOnMount:j=!1,idleWhen:E,onIdlePick:N,anchored:A=!1,onEscape:O,lead:P,trailing:R,empty:T="no matches",footer:$,keys:D,rowMenu:z,groupOf:V,groupHead:se,headAlone:I=!1,field:ne}){const we=bn("picker"),[K,B]=_.useState(b),ee=_.useMemo(()=>t(e,K),[e,K,t]),J=_.useRef(null),W=vi(),ie=gL(j,!W&&!ne);_.useEffect(()=>{if(!m)return;const _e=setTimeout(()=>m(K),150);return()=>clearTimeout(_e)},[K,m]);const Te=MS({results:ee,keyOf:n,q:K,onPick:l,listRef:J,onActive:u,onSide:h,completionOf:k,narrowTo:g,setQ:B,initialIndex:S,idle:(E==null?void 0:E(b))??!1,onIdlePick:N}),{index:Ce,ghost:de}=Te,be=ne?ne.open:!0;gt([be,b],()=>{!ne||be||(B(b),Te.setIndex(E!=null&&E(b)?-1:0))}),gt([be],()=>{if(!ne||!be||W)return;const _e=()=>{const Ne=ie.current;!Ne||document.activeElement===Ne||(Ne.focus(),j&&Ne.select())};_e();const je=requestAnimationFrame(_e);return()=>cancelAnimationFrame(je)});const le=_.useRef(!1),G=typeof D=="function"?D(Te.active,K):D,ce=[];G!=null&&G.nav&&ce.push(["↑↓",G.nav]),G!=null&&G.side&&h&&ce.push(["←→",G.side]),G!=null&&G.complete&&(de!=null&&de.accept)&&ce.push(["tab",G.complete]),G!=null&&G.tab&&p&&ce.push(["tab",G.tab]),G!=null&&G.pick&&ce.push(["enter",G.pick]),G!=null&&G.back&&ce.push(["esc",G.back]);const oe=_e=>d.jsxs("div",{...ne==null?void 0:ne.attrs,className:Ke("picker-input",ne&&"picker-field",ne==null?void 0:ne.className),"data-open":(ne==null?void 0:ne.open)||void 0,onMouseDown:je=>{var Ne;je.target.closest("input, .float")||(je.preventDefault(),(Ne=ie.current)==null||Ne.focus())},children:[P,d.jsxs("div",{className:"picker-caret",children:[d.jsx(jo,{font:"mono",bare:!0,ref:ie,value:K,spellCheck:!1,"aria-controls":ne==null?void 0:ne.id,"aria-expanded":ne?ne.open:void 0,onFocus:()=>{ne&&!ne.open&&ne.onOpen()},onBlur:je=>{const Ne=je.relatedTarget;ne!=null&&ne.open&&Ne instanceof Element&&!Ne.closest(".float")&&c()},onMouseDown:je=>{const Ne=document.activeElement!==je.currentTarget;if(le.current=Ne,ne&&Ne){const qe=document.getSelection();qe&&(!qe.isCollapsed||qe.toString()!=="")&&qe.removeAllRanges()}},onClick:je=>{if(!ne||!le.current)return;le.current=!1;const Ne=je.currentTarget;setTimeout(()=>{document.activeElement===Ne&&Ne.selectionStart===Ne.selectionEnd&&Ne.select()},0)},onChange:je=>{B(je.target.value),Te.setIndex(E!=null&&E(je.target.value)?-1:0),ne&&!ne.open&&ne.onOpen()},onKeyDown:je=>{var Ne;if(ne&&!ne.open){if(je.key==="ArrowDown"||je.key==="ArrowUp")ne.onOpen();else if(je.key==="Escape"){P8(je.currentTarget),je.currentTarget.blur();return}}if(z&&Te.active&&(je.key==="ContextMenu"||je.key==="F10"&&je.shiftKey)){const qe=(Ne=J.current)==null?void 0:Ne.querySelector('[data-state~="cursor"]');if(qe){je.preventDefault(),je.stopPropagation(),so.open({items:z(Te.active),owner:"picker",target:qe,anchor:qe.getBoundingClientRect()});return}}Te.onKeyDown(je)||!p||je.key!=="Tab"||je.shiftKey||(je.preventDefault(),p())},placeholder:y}),de&&d.jsxs("div",{className:"picker-ghost","aria-hidden":"true",children:[d.jsx("span",{className:"picker-typed",children:K}),L8(de)]})]}),R,_e]}),re=new Map;if(V)for(const _e of ee)re.set(V(_e),(re.get(V(_e))??0)+1);const Le=d.jsxs("div",{className:"picker-list",ref:J,onMouseDown:_e=>{ne&&_e.target!==_e.currentTarget&&_e.preventDefault()},children:[ee.map((_e,je)=>{const Ne=V==null?void 0:V(_e),qe=Ne!==void 0&&(I||re.size>1)&&(je===0||(V==null?void 0:V(ee[je-1]))!==Ne)?d.jsx("div",{className:"picker-group",children:(se==null?void 0:se(Ne,re.get(Ne)??0))??Ne}):null;return d.jsxs(_.Fragment,{children:[qe,d.jsx("button",{className:Ke("picker-item",o==null?void 0:o(_e)),"data-state":vr({cursor:je===Ce}),title:i==null?void 0:i(_e),onMouseMove:()=>je!==Ce&&Te.setIndex(je),onClick:()=>{var Ft;Te.pick(_e),(Ft=ie.current)==null||Ft.focus()},...we.contextMenu(()=>(z==null?void 0:z(_e))??[]),children:r(_e,je===Ce,K)})]},n(_e))}),ee.length===0&&d.jsx("div",{className:"empty",children:typeof T=="function"?T(K):T}),$==null?void 0:$(K,ee)]}),Ue=ce.length>0&&d.jsx(FN,{hints:ce});return ne?oe(ne.open&&d.jsxs(Uc,{onClose:c,onEscape:O,boxClass:"picker",anchored:A,id:ne.id,children:[Le,Ue]})):d.jsxs(Uc,{onClose:c,onEscape:O,boxClass:"picker",anchored:A,coverBy:P?".picker-input > *:first-child":R?".picker-input > *:last-child":void 0,children:[oe(),Le,Ue]})}function ii({value:e,reads:t,options:n,onChange:r,placeholder:o,hint:i,className:l,onClose:c}){const[u,h]=_.useState(!1),p=()=>{h(!1),c==null||c()},m=t??e,k=n.find(y=>y.id===m),g=(k==null?void 0:k.chip)??(k==null?void 0:k.label)??m;return d.jsxs("span",{className:"chip-picker",children:[d.jsx(De,{variant:"ghost",tone:"chrome",mono:!0,on:u,className:Ke("chip-picker-btn",l),...Ut(i),onClick:()=>u?p():h(!0),children:g}),u&&d.jsx(Pr,{anchored:{flip:"both",margin:0},onEscape:p,items:n,filter:(y,b)=>{const S=b.trim().toLowerCase().split(/\s+/).filter(Boolean);return y.filter(j=>{const E=`${j.prefix??""} ${j.label??j.id} ${j.suffix??""} ${j.id}`.toLowerCase();return S.every(N=>E.includes(N))})},keyOf:y=>y.id,initialIndex:y=>Math.max(0,y.findIndex(b=>b.id===e)),lead:d.jsx(De,{tone:"chrome",mono:!0,on:!0,className:"chip-picker-lead",onClick:p,children:g}),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:Ke("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),p())},onBack:p})]})}function WN({choices:e,value:t,current:n,what:r,defaultLabel:o,defaultDescription:i,placeholder:l,className:c,onChange:u,onClose:h}){const{rows:p,shown:m,picked:k}=_.useMemo(()=>UN(e,t,n,{label:o,description:i}),[e,t,n,o,i]);if(e.length===0)return null;const g=p.find(b=>b.id===m),y=(g==null?void 0:g.chip)??(g==null?void 0:g.label)??m;return d.jsx(ii,{value:k,reads:m,options:p,onChange:u,onClose:h,className:c,hint:t?`asked for ${y}; click to change`:`${y}, the agent's choice; click to pick ${r}`,placeholder:l})}function D8(e){const[t,n]=No(Xe.effortPrefix+(e??""),as,r=>r??"",lo().storage);return[t,n]}function Ex({efforts:e,value:t,current:n,onChange:r,onClose:o}){return d.jsx(WN,{choices:e,value:t,current:n,what:"an effort level",defaultLabel:"default effort",defaultDescription:"the level the agent runs at when nothing is asked for",placeholder:"how hard the agent thinks here",className:"effort-chip",onChange:r,onClose:o})}function z8(e){const[t,n]=No(Xe.modePrefix+((e==null?void 0:e.id)??""),Hd,r=>Zc.some(o=>o.id===r)?r:Hd,lo().storage);return[t,n]}const F8=e=>{var t;return((t=Zc.find(n=>n.id===e))==null?void 0:t.description)??""};function Sx({value:e,onChange:t,onClose:n}){return d.jsx(ii,{value:e,options:Zc.map(r=>({id:r.id,label:r.name,description:r.description})),onChange:t,onClose:n,className:Ke("mode-chip",e!=="auto"&&"mode-held"),hint:`${e}: ${F8(e)}. Click to change`,placeholder:"what the agent may do without asking"})}function B8(e){const[t,n]=No(Xe.modelPrefix+(e??""),as,r=>r??"",lo().storage);return[t,n]}function U8(e,t,n){e.set(Xe.modelPrefix+t,n)}function _x({models:e,value:t,current:n,onChange:r,onClose:o}){return d.jsx(WN,{choices:e,value:t,current:n,what:"a model",defaultLabel:"default model",defaultDescription:"whatever the agent runs when nothing is asked for",placeholder:"which model answers here",className:"model-chip",onChange:r,onClose:o})}function H8({agents:e,agent:t,model:n,onChange:r,onClose:o}){const{rows:i,shown:l}=_.useMemo(()=>$8(e,t,n),[e,t,n]);if(i.length===0)return null;const c=i.find(h=>h.id===l),u=c?[c.prefix,c.label,c.suffix].filter(Boolean).join(" "):n;return d.jsx(ii,{value:l,options:i,onChange:h=>{const p=R8(h);r(p.agent,p.model)},onClose:o,className:"model-chip",hint:`${u} works on the new worktree; click to change`,placeholder:"which agent and model work on it"})}function KN(e){const t=Gf(e),[n,r]=No(Xe.profilePrefix+((e==null?void 0:e.id)??""),(e==null?void 0:e.config.defaultProfile)??"",i=>i??void 0,lo().storage);return[t.length===0?void 0:t.includes(n)?n:e==null?void 0:e.config.defaultProfile,r]}function W8({repo:e,value:t,onChange:n,onClose:r}){const o=Gf(e);if(o.length===0||!t)return null;const i=(e==null?void 0:e.config.profiles)??{},l=(e==null?void 0:e.configFile)??"the settings",c=u=>{var m;const h=((m=i[u])==null?void 0:m.run)??[],p=h.length>0?`runs ${h.join(", ")}`:"runs nothing";return u===(e==null?void 0:e.config.defaultProfile)?`${p}; the default in ${l}`:p};return d.jsx(ii,{value:t,options:o.map(u=>({id:u,description:c(u)})),onChange:n,onClose:r,hint:o.length>1?`${t}: ${c(t)}. Click to change`:`the only profile in ${l}`,placeholder:"the profile the worktree runs"})}function Hc(e,t,n){if(!t)return e;const r=new Set(t.map(l=>l-n)),o=[];let i="";for(let l=0;l<e.length;l++)r.has(l)?(i&&o.push(i),i="",o.push(d.jsx("b",{className:"hit",children:e[l]},l))):i+=e[l];return i&&o.push(i),o}function K8({c:e,query:t}){const n=t.trim();return d.jsxs(d.Fragment,{children:[d.jsxs("span",{className:"picker-name",children:["/",Hc(e.name,n?iw(e.name,n):null,0)]}),d.jsx("span",{className:"picker-desc row-dim",children:e.description})]})}function On({label:e,hint:t,current:n=!1}){return d.jsxs(d.Fragment,{children:[n&&d.jsx("span",{className:"row-current","aria-hidden":"true"}),d.jsx("span",{className:"picker-label",children:e}),t?d.jsx("span",{className:"picker-hint row-dim",children:t}):null]})}function Z8(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 q8=/ \| | - | \u2013 | \u2014 | \u00b7 |: /,G8=/^(\d+|[0-9a-f]{8}-[0-9a-f-]{27}|[0-9a-f]{12,})$/i,V8=/^[[:$*{]|\[/;function Y8(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(q8).map(l=>l.trim()).filter(Boolean)})),o=new Map;for(const{path:i,parts:l}of r)for(const c of l)o.set(c,(o.get(c)??new Set).add(i));for(const{path:i,parts:l}of r){const c=l.filter(u=>{var h;return(((h=o.get(u))==null?void 0:h.size)??0)<2});c.length>0&&t.set(i,c.join(" "))}return t}function dw(e){const t=e.split(/[/#]/).filter(Boolean);for(let n=t.length-1;n>=0;n--){let r=t[n];try{r=decodeURIComponent(r)}catch{}if(G8.test(r)||V8.test(r))continue;const o=r.replace(/[-_.]+/g," ").trim();if(o)return o[0].toUpperCase()+o.slice(1)}return"Home"}const nm=8,X8=3,Q8=50,J8=3;function e9(e,t,n=[]){const r=new Map,o=[],i=new Map;for(const l of(t==null?void 0:t.routes)??[]){if(l.endpoint)continue;const c=l.dynamic?Y2(l.path):null;c?(o.push(c),i.set(l.path,l)):r.set(l.path,l)}return{history:e,statics:r,templates:o,templateRoutes:i,unseen:(t==null?void 0:t.unseen)??{},titles:Y8(e),links:new Map(n.map(l=>[l.path,l.text]))}}function t9(e){if(!e)return"/";try{const t=new URL(e);return t.pathname+t.search+t.hash}catch{return"/"}}function n9(e){const t=e.trim();return/^[/?#]/.test(t)?t:`/${t}`}function r9(e,t){const n=/^[/?#]/.test(t)?e:e.replace(/^\//,"");return t&&n.toLowerCase().startsWith(t.toLowerCase())?n:null}const ZN=e=>/^\[\[?\.\.\.|^\*$|^\$$/.test(e),kc=e=>ZN(e)||/[[:$*{]/.test(e)&&!/^[^[{:$*]+\?$/.test(e),o9=e=>Rf(`/${e}`).text.slice(1),fw=e=>e.split("/").filter(Boolean);function hw(e,t){const n=t.startsWith("/"),r=t.replace(/^\//,"").split("/"),o=fw(e);let i="";const l=[],c=m=>{const k=o9(m);l.push([i.length,i.length+k.length]),i+=k};for(let m=0;m<r.length;m++){const k=r[m],g=o[m];if(g===void 0)return null;if(m<r.length-1){if(ZN(g))return{show:t,accept:t};if(kc(g)){if(!k)return null}else if(k.toLowerCase()!==g.toLowerCase())return null;i+=`${kc(g)?k:g}/`;continue}if(kc(g))k?i+=k:c(g);else{if(!g.toLowerCase().startsWith(k.toLowerCase()))return null;i+=g}}for(const m of o.slice(r.length))i+="/",kc(m)?c(m):i+=m;const u=n?1:0,h=(n?"/":"")+i,p=l[0];return{show:h,accept:p?h.slice(0,p[0]+u):h,params:l.map(([m,k])=>[m+u,k+u])}}function s9(e,t){const n=hw(e,t);return n?n.accept.length>t.length?n.accept:t:Rf(e).literal}function qN(e,t){if(e.kind==="go")return null;if(e.template){const n=hw(e.path,t);return n&&n.show.length>t.length?n:null}return r9(e.path,t)}const i9=e=>e.trim().replace(/^\//,"").toLowerCase();function GN(e,t){for(let n=0;n<e.length;n++)if("/-_.#".includes(e[n])&&e.startsWith(t,n+1))return!0;return!1}function a9(e,t,n){const r=e.replace(/^\//,"").toLowerCase(),o=t.toLowerCase();return r===n?100:r.startsWith(n)?80:GN(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 l9(e,t){const{text:n,literal:r}=Rf(e);return r.replace(/^\//,"").toLowerCase().startsWith(t)?80:hw(e,t)?70:GN(n.replace(/^\//,"").toLowerCase(),t)?60:0}function c9(e,t){const n=fw(e).findIndex(kc);return n>=0&&t.split("/").length>n}function _c(e,t,n){var c;const r=e.statics.get(t),o=r?null:X2(e.templates,t),i=(r==null?void 0:r.file)??(o?(c=e.templateRoutes.get(o.path))==null?void 0:c.file:void 0),l=i?e.unseen[i]:void 0;return{kind:"page",path:t,title:e.titles.get(t)||e.links.get(t)||dw(t),template:!1,visited:n<Number.POSITIVE_INFINITY,...i?{file:i}:{},...l?{badge:l}:{},rank:n,group:(o==null?void 0:o.path)??t,score:0}}function VN(e,t){const n=e.unseen[t.file];return{kind:"page",path:t.path,title:dw(t.path),template:!0,visited:!1,file:t.file,...n?{badge:n}:{},rank:Number.POSITIVE_INFINITY,group:t.path,score:0}}function Fd({rank:e,group:t,score:n,...r}){return r}const hf=e=>fw(e).length,pf=e=>e.badge==="new"?0:e.badge==="changed"?1:2;function u9(e,t){const n=new Set,r=[];e.history.forEach((p,m)=>{if(p.path===t)return;const k=_c(e,p.path,m);n.has(k.group)||(n.add(k.group),r.push(k))});const o=new Set(r.map(p=>p.path)),i=r.filter(p=>p.badge);for(const[p,m]of e.statics)e.unseen[m.file]&&p!==t&&!o.has(p)&&i.push(_c(e,p,Number.POSITIVE_INFINITY));for(const p of e.templateRoutes.values())e.unseen[p.file]&&!n.has(p.path)&&i.push(VN(e,p));i.sort((p,m)=>pf(p)-pf(m)||p.rank-m.rank);const l=r.filter(p=>!p.badge),c=i.slice(0,nm-Math.min(X8,l.length));for(const p of l)c.length<nm&&c.push(p);const u=new Set(c.map(p=>p.path)),h=[...e.statics.keys(),...[...e.links.keys()].filter(p=>!e.statics.has(p))].filter(p=>p!==t&&!u.has(p)&&!o.has(p)).sort((p,m)=>hf(p)-hf(m)||(p<m?-1:p>m?1:0));for(const p of h){if(c.length>=nm)break;c.push(_c(e,p,Number.POSITIVE_INFINITY))}return c.map(Fd)}function d9(e,t,n){const r=i9(t),o=n9(t),i=new Map;e.history.forEach((g,y)=>{g.path!==n&&i.set(g.path,_c(e,g.path,y))});for(const g of[...e.statics.keys(),...e.links.keys()])g!==n&&!i.has(g)&&i.set(g,_c(e,g,Number.POSITIVE_INFINITY));const l=[];for(const g of i.values()){const y=a9(g.path,g.title,r);y>0&&l.push({...g,score:y})}let c=null;for(const g of e.templates){const y=e.templateRoutes.get(g.path);if(!c&&!e.statics.has(o)&&g.re.test(o)){c=y;continue}const b=l9(g.path,r);b>=60&&l.push({...VN(e,y),score:b})}l.sort((g,y)=>y.score-g.score||g.rank-y.rank||pf(g)-pf(y)||hf(g.path)-hf(y.path)||(g.path<y.path?-1:g.path>y.path?1:0));const u=new Map,h=[];for(const g of l){if(!g.template&&g.group!==g.path){const y=u.get(g.group)??0;if(y>=J8&&!c9(g.group,r))continue;u.set(g.group,y+1)}if(h.push(g),h.length>=Q8)break}if(h.some(g=>g.score===100))return h.map(Fd);const p={kind:"go",path:o,title:dw((c==null?void 0:c.path)??o)},m=h[0];return!c&&m!==void 0&&m.score>=80&&f9(m.path,r)?[...h.map(Fd),p]:[p,...h.map(Fd)]}function f9(e,t){const n=e.replace(/^\//,"").toLowerCase().slice(t.length);return!t.endsWith("/")&&n.length>0&&!/^[/?#]/.test(n)}function YN(e,{query:t,current:n,here:r}){return t===n||t.trim()===""?u9(e,r):d9(e,t,r)}const h9=[],p9=[];function XN(e,t){const n=L(i=>(t?i.visits[t]:void 0)??h9),r=It(e,"pages"),o=It(e,"links");return gt([e],()=>{EE(r)&&cn.post(e,{type:"links"})}),_.useMemo(()=>e9(n,r,o),[n,r,o])}function m9({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}=Rf(e.path),r=[];let o=0;for(const[i,l]of n)i>o&&r.push(t.slice(o,i)),r.push(d.jsx("span",{className:"bar-route-param",children:t.slice(i,l)},i)),o=l;return o<t.length&&r.push(t.slice(o)),d.jsx("span",{className:"bar-route-path row-dim",children:r})}function QN({row:e}){return d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"picker-label",children:e.title}),d.jsx(m9,{row:e}),e.kind==="go"?d.jsx("span",{className:"picker-hint row-dim",children:"as typed"}):e.badge?d.jsx("span",{className:e.badge==="new"?"badge-new":"badge-changed",children:e.badge}):null]})}const JN=e=>e.kind==="page"&&e.file?e.file:e.path,eT=(e,t)=>e.kind==="page"&&e.template?s9(e.path,t):null,tT=e=>e.kind==="page"&&e.template?"fills in the parameter":"goes there";function nT(e,t,n){return e.kind!=="page"?[]:Bf([...e.file&&t.dir?js({id:t.worktreeId,dir:t.dir},e.file,{},n):[],sS,...e.visited?Z8(t.repoId,e.path,n):[]])}function g9({worktreeId:e,repoId:t,url:n,open:r}){const o=ut(),i=pt(),l=L(y=>{const b=pn(y,e);return b?b.worktree.path:null}),c=XN(e,t),u=t9(n),h=n?If(n):null,p=_.useCallback((y,b)=>YN(c,{query:b,current:u,here:h}),[c,u,h]),m=_.useCallback(y=>y===u||y.trim()==="",[u]),k=()=>o({a:"close"}),g=_.useMemo(()=>({open:r,onOpen:()=>o({a:"open",overlay:{kind:"routes"}}),id:"routes",className:"bar-path",attrs:Ut("Go to a page",Lt("routes"))}),[r,o]);return d.jsx(Pr,{anchored:{matchWidth:0,cover:!1,offset:-1},field:g,items:p9,filter:p,initialQuery:u,selectOnMount:!0,idleWhen:m,onIdlePick:()=>{cn.post(e,{type:"reload"}),k()},keyOf:y=>`${y.kind}:${y.path}`,rowClass:()=>"picker-row",rowTitle:JN,completionOf:(y,b)=>m(b)?null:qN(y,b),narrowTo:eT,onPick:y=>{cn.post(e,{type:"navigate",path:y.path}),k()},onBack:k,rowMenu:y=>nT(y,{worktreeId:e,repoId:t,dir:l},{sock:i,dispatch:o}),placeholder:"type a path",keys:y=>({complete:"completes the path",pick:y?tT(y):"reloads",back:"closes"}),empty:"no pages yet; type a path",row:y=>d.jsx(QN,{row:y})})}function rT(e,t){const n=t.trim();return d.jsx(On,{label:Hc(e.label,n?iw(e.label,n):null,0),hint:e.hint&&d.jsx(qo,{k:e.hint})})}function oT({anchored:e,trailing:t}){const n=ut(),r=_N(),o=L(i=>{var l;return((l=i.paletteReturn)==null?void 0:l.mode)==="commands"?i.paletteReturn.q:""});return d.jsx(Pr,{anchored:e,trailing:t,items:r,filter:NN,rowClass:()=>"picker-row",keyOf:i=>i.id,onPick:(i,l)=>{i.sub?n({a:"palette-return",v:{mode:"commands",q:l}}):n({a:"close"}),i.run()},onBack:()=>n({a:"close"}),placeholder:"run a command…",keys:{pick:"runs",back:"closes"},initialQuery:o,empty:"no matching command",row:(i,l,c)=>rT(i,c)})}function sT(e,t){const n=new Map(t.map(l=>[l.path,l])),r=t.filter(l=>l.xy==="??"&&l.path.endsWith("/")).map(l=>l.path),o=e.map(l=>{const c=n.get(l)??(r.some(u=>l.startsWith(u))?{path:l,xy:"??"}:void 0);return c?{path:l,status:c}:{path:l}}),i=new Set(e);for(const l of t)!i.has(l.path)&&!l.path.endsWith("/")&&o.push({path:l.path,status:l});return o}function Nx(e,t){const n=e.split("/"),r=t.split("/");for(let o=0;;o++){const i=n[o],l=r[o];if(i===void 0||l===void 0)return n.length-r.length;const c=o===n.length-1,u=o===r.length-1;if(c!==u)return c?-1:1;if(i!==l)return i<l?-1:1}}function iT(e,t,n,r=50){const o=sT(e,t),i=n.trim().toLowerCase();if(!i){const c=new Map(t.map((m,k)=>[m.path,k])),u=m=>{var k;return c.get(((k=m.status)==null?void 0:k.path)??"")??c.get(m.path)??Number.MAX_SAFE_INTEGER},h=o.filter(m=>m.status).sort((m,k)=>u(m)-u(k)||Nx(m.path,k.path)),p=o.filter(m=>!m.status).sort((m,k)=>Nx(m.path,k.path));return{rows:[...h,...p].slice(0,r),changed:Math.min(h.length,r)}}const l=lT(o,i);return l.sort((c,u)=>u.score-c.score||c.row.path.localeCompare(u.row.path)),{rows:l.slice(0,r).map(c=>c.row),changed:0}}function aT(e,t){const n=e.toLowerCase(),r=Tx(n,t);return r<=0?0:Tx(n.slice(n.lastIndexOf("/")+1),t)>0?r+10:r}function lT(e,t){const n=[];for(const r of e){const o=aT(r.path,t);o>0&&n.push({row:r,score:r.status?o+4:o})}return n}function k9(e,t,n,r,o){const i=r.trim().toLowerCase();if(!i)return iT(e,n,r,o).rows.map(u=>({kind:"file",path:u.path,status:u.status}));const l=lT(sT(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=aT(u,i);h>0&&l.push({row:{kind:"folder",path:u},score:h})}const c=u=>u.kind==="folder"?1:0;return l.sort((u,h)=>h.score-u.score||c(u.row)-c(h.row)||u.row.path.localeCompare(h.row.path)),l.slice(0,o).map(u=>u.row)}function w9(e,t){const n=e.toLowerCase(),r=[];let o=0;for(const i of t.toLowerCase()){const l=n.indexOf(i,o);if(l===-1)return null;r.push(l),o=l+1}return r}function Tx(e,t){let n=0,r=0,o=0;for(const i of t){const l=e.indexOf(i,r);if(l===-1)return 0;o=l===r?o+1:1,n+=o+(l===0||e[l-1]==="/"||e[l-1]==="."?3:0),r=l+1}return n+Math.max(0,40-e.length/4)}function y9(e){const t=e.lastIndexOf("/");return t===-1?[e,""]:[e.slice(t+1),e.slice(0,t+1)]}const jx=[],v9=[],b9=[];function x9({worktreeId:e}){var b;const t=ut(),n=pt(),r=Zn();gt([e,n],()=>Uf(e,r.getState(),{sock:n,dispatch:t}));const o=eS(e),i=o.files??v9,l=((b=o.git)==null?void 0:b.files)??b9,c=_N(),u=L(S=>{var j;return((j=S.paletteReturn)==null?void 0:j.mode)==="quick-open"?S.paletteReturn.q:""}),h=L(S=>{var E;const j=(E=pn(S,e))==null?void 0:E.worktree;return j?j.path:null}),p=L(S=>{var j;return((j=pn(S,e))==null?void 0:j.repoId)??null}),m=L(S=>{var j;return((j=tf(S))==null?void 0:j.worktreeId)===e}),k=XN(e,p),g=o.page.url?If(o.page.url):null,y=_.useCallback((S,j)=>j.startsWith(">")?NN(c,j.slice(1)).map(E=>({kind:"cmd",c:E})):j.startsWith("/")?m?YN(k,{query:j,current:"/",here:g}).map(E=>({kind:"page",page:E})):jx:iT(i,l,j).rows.map(E=>({kind:"file",path:E.path,status:E.status})),[c,i,l,m,k,g]);return d.jsx(Pr,{items:jx,filter:y,keyOf:S=>S.kind==="cmd"?`c:${S.c.id}`:S.kind==="page"?`p:${S.page.kind}:${S.page.path}`:`f:${S.path}`,rowClass:S=>S.kind==="file"?"qo-file":"picker-row",rowTitle:S=>S.kind==="page"?JN(S.page):void 0,completionOf:(S,j)=>S.kind==="page"?qN(S.page,j):null,narrowTo:(S,j)=>S.kind==="page"?eT(S.page,j):null,onPick:(S,j)=>{S.kind==="cmd"?(S.c.sub?t({a:"palette-return",v:{mode:"quick-open",q:j}}):t({a:"close"}),S.c.run()):S.kind==="page"?(cn.post(e,{type:"navigate",path:S.page.path}),t({a:"close"})):(tr({dispatch:t},{worktreeId:e,path:S.path,view:pi(S.path)}),t({a:"close"}))},onBack:()=>t({a:"close"}),rowMenu:S=>S.kind==="file"&&h?js({id:e,dir:h},S.path,{},{sock:n,dispatch:t}):S.kind==="page"&&p?nT(S.page,{worktreeId:e,repoId:p,dir:h},{sock:n,dispatch:t}):[],placeholder:"jump to file · type > for commands, / for pages",keys:(S,j)=>j.startsWith("/")?{complete:"completes the path",pick:(S==null?void 0:S.kind)==="page"?tT(S.page):void 0,back:"closes"}:{pick:"opens",back:"closes"},initialQuery:u,empty:S=>S.startsWith(">")?"no matching command":S.startsWith("/")?m?"no pages yet; type a path":"no preview running":"no matches",row:(S,j,E)=>S.kind==="cmd"?rT(S.c,E.slice(1)):S.kind==="page"?d.jsx(QN,{row:S.page}):dg(S.path,S.status,E,{gutter:l.length>0})})}function dg(e,t,n,{folder:r=!1,gutter:o=!0}={}){const[i,l]=y9(e),c=n.trim()?w9(e,n.trim()):null;return d.jsxs(d.Fragment,{children:[o&&d.jsx("span",{className:`xy ${t?ek(t.xy):""}`,children:t?tk(t.xy):""}),d.jsxs("span",{className:"name",children:[Hc(i,c,l.length),r&&"/"]}),d.jsx("span",{className:"dir row-dim",children:l&&d.jsxs(d.Fragment,{children:["",Hc(l,c,0),""]})}),t&&d.jsx(r_,{f:t})]})}function E9(e,t,n){if(!e||e.available)return null;const r=n?t.find(l=>l.available&&l.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: ${eh(e)}`,retry:BN(e),...o}}function Hi({icon:e,verb:t,tip:n,onPress:r,onDismiss:o,children:i}){return d.jsxs("div",{className:"composer-offer",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})," ",i]}),o&&d.jsx(Rt,{icon:"close",tone:"quiet",className:"composer-offer-close",label:"Not this one",onClick:o})]})}function cT({item:e,n:t,onRemove:n}){const r=Lr();return e.kind==="image"?d.jsx(rw,{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(ew,{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(Jk,{n:t,name:e.name,source:e.source,lines:e.lines,chars:e.chars,preview:e.preview,text:e.text,onRemove:n})}const Cx=8,S9=104,_9=.25,uT=220;function N9({dx:e,dy:t}){return Math.abs(e)<Cx&&Math.abs(t)<Cx?null:Math.abs(e)>Math.abs(t)&&e<0?"slide":"other"}function T9(e,t,n=S9){const r=Math.max(0,-e),o=t*n,i=Math.min(t,Math.floor(r/n)),l=r<=o?r:o+(r-o)*_9;return{step:i,x:-l}}function dT(e,t){const n=_.useRef(t);n.current=t,_.useEffect(()=>{const r=e.current;if(!r)return;let o=null,i=null,l=!1,c=0,u=0,h=0;const p=(E,N,A)=>{E.el.dataset.slide!==A&&(E.el.dataset.slide=A,E.el.offsetWidth),E.el.style.setProperty("--slide-x",`${N}px`)},m=E=>{E.el.style.removeProperty("--slide-x"),delete E.el.dataset.slide},k=()=>{const E=o,N=l,A=c;o=null,i=null,l=!1,c=0,!(!E||!N)&&(p(E,0,"settle"),A>0&&n.current.onPick(E.key,A),u=window.setTimeout(()=>{m(E),n.current.onSlide(null)},uT))};let g=null;const y=E=>{if(!E.isPrimary||E.pointerType==="mouse"&&E.button!==0)return k();const N=E.target instanceof Element?n.current.rowOf(E.target):null;!N||N.el.dataset.slide||(window.clearTimeout(u),o=N,g=E.pointerId,i={x:E.clientX,y:E.clientY})},b=E=>{var R;const N=o;if(!N||!i||E.pointerId!==g)return;const A=E.clientX-i.x,O=E.clientY-i.y;if(!l){const T=N9({dx:A,dy:O});if(T==="other"&&(o=null,i=null,g=null),T!=="slide")return;l=!0;try{N.el.setPointerCapture(E.pointerId)}catch{}n.current.onSlide({key:N.key,step:0})}const P=T9(A,N.rungs,N.rung);p(N,P.x,"drag"),P.step!==c&&(c=P.step,n.current.onSlide({key:N.key,step:c}),c>0&&((R=navigator.vibrate)==null||R.call(navigator,8)))},S=E=>{E.pointerId===g&&(l&&(h=E.timeStamp+400),g=null,k())},j=E=>{E.timeStamp>=h||(E.preventDefault(),E.stopPropagation())};return r.addEventListener("pointerdown",y),r.addEventListener("pointermove",b),r.addEventListener("pointerup",S),r.addEventListener("pointercancel",S),r.addEventListener("click",j,!0),()=>{window.clearTimeout(u),r.removeEventListener("pointerdown",y),r.removeEventListener("pointermove",b),r.removeEventListener("pointerup",S),r.removeEventListener("pointercancel",S),r.removeEventListener("click",j,!0)}},[e])}function mf({rows:e,cursor:t,onCursor:n,onPick:r,onHint:o,hover:i=!1}){const l=vi(),c=_.useRef(null),[u,h]=_.useState(null),p=l&&!!o;dT(c,{rowOf:k=>{if(!p||k.closest("textarea"))return null;const g=k.closest(".slide"),y=g==null?void 0:g.dataset.row,b=y===void 0?void 0:e[Number(y)];return g&&y!==void 0&&(b!=null&&b.hint)&&!b.field?{el:g,key:y,rungs:1,rung:120}:null},onSlide:h,onPick:k=>o==null?void 0:o(Number(k))});const m=k=>{var g;k.target instanceof HTMLTextAreaElement||(k.preventDefault(),(g=k.currentTarget.querySelector("textarea"))==null||g.focus())};return d.jsx("div",{className:Ke("choices",i&&"choices-hover",l&&"choices-touch"),ref:c,children:e.map((k,g)=>{const y=!l&&t===g,b=vr({cursor:y,checked:k.checked}),S=k.tone==="deny"&&"choice-deny",j=()=>n&&t!==g&&n(g),E=A=>{var R;if(!p)return A;const O=(u==null?void 0:u.key)===String(g)?u.step:null,P=O!==null&&O>0&&((R=k.hint)==null?void 0:R.on)!==!1;return d.jsxs("div",{className:"slide","data-row":g,children:[A,O!==null&&k.hint&&d.jsxs("span",{className:"slide-verb","data-rung":P?"hint":void 0,"aria-hidden":"true",children:[d.jsx("span",{className:"slide-word",children:k.hint.label}),d.jsx(St,{name:k.hint.icon})]})]},g)},N=d.jsxs(d.Fragment,{children:[!l&&d.jsx(qo,{k:String(g+1),className:"choice-num row-dim"}),d.jsx("span",{className:"choice-label",children:k.label}),!l&&k.hint&&d.jsxs("span",{className:Ke("choice-hint row-dim",y&&k.hint.on!==!1&&"on"),children:[d.jsx(qo,{k:k.hint.k})," ",k.hint.label]}),k.description&&d.jsx("span",{className:"choice-desc",children:k.description})]});return k.field?E(d.jsxs("div",{className:Ke("picker-item choice row-edge",S),"data-state":b,onMouseMove:j,onMouseDown:m,children:[N,d.jsx(Lc,{ref:k.field.ref,bare:!0,font:"ui",rows:1,className:"choice-field",enterKeyHint:k.field.enterKeyHint,placeholder:k.field.placeholder,value:k.field.value,onChange:A=>{var O;return(O=k.field)==null?void 0:O.onChange(A.target.value)}})]},g)):E(d.jsx("button",{type:"button",className:Ke("picker-item choice row-edge",S),"data-state":b,disabled:k.disabled,onMouseMove:j,onClick:()=>r(g),children:N},g))})})}function j9(e){return Bd(e.key)&&(e.metaKey||e.ctrlKey)&&!e.altKey?!1:e.metaKey||e.ctrlKey||e.altKey}const C9=e=>e.length===1&&e>="1"&&e<="9",Bd=e=>e==="Enter"||e==="NumpadEnter";function A9(e,t,n){const r=Bd(e.key)&&(e.metaKey||e.ctrlKey);return t?e.key==="Escape"||e.key==="Tab"&&!e.shiftKey?{kind:"field-leave"}:r?{kind:"submit"}:Bd(e.key)&&!e.shiftKey?{kind:"field-enter"}:{kind:"typing"}:j9(e)?{kind:"chord"}:e.key==="Escape"?{kind:"escape"}:r?{kind:"submit"}:Bd(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:Jc(n.cursor,e.key==="ArrowUp"?-1:1,n.count)}:C9(e.key)&&Number(e.key)<=n.count?{kind:"pick",at:Number(e.key)-1,by:"digit"}:null}function pw(e,t){var o,i,l,c;const n=e.target instanceof HTMLTextAreaElement,r=A9(e,n,t);if(!r)return!1;switch(r.kind){case"chord":case"typing":return!0;case"escape":case"field-leave":return e.preventDefault(),e.stopPropagation(),(o=r.kind==="escape"?t.onEscape:t.onFieldLeave)==null||o(),!0;case"submit":return e.preventDefault(),t.onSubmit?t.onSubmit():n?(i=t.onFieldEnter)==null||i.call(t):t.cursor!==void 0&&t.onPick(t.cursor,"enter"),!0;case"pick":return e.preventDefault(),t.onPick(r.at,r.by),!0;case"cursor":return e.preventDefault(),(l=t.onCursor)==null||l.call(t,r.to),!0;case"field-enter":return e.preventDefault(),(c=t.onFieldEnter)==null||c.call(t),!0}}function I9(e){return!e||e===document.body?!1:e.closest(".monaco-editor, .xterm")?!0:(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement)&&!e.closest(".chat-input")}function R9(e,t){gt([t],()=>{const o=requestAnimationFrame(()=>{var i;I9(document.activeElement)||(i=e.current)==null||i.focus()});return()=>cancelAnimationFrame(o)});const n=_.useRef(!1),r=_.useCallback(()=>{requestAnimationFrame(()=>{var o;document.activeElement===document.body&&((o=e.current)==null||o.focus())})},[e]);return _.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 mw({root:e,id:t,onKeyDown:n,onKeyUp:r,onPaste:o,children:i}){const l=R9(e,t);return d.jsx("div",{ref:e,className:"card",tabIndex:-1,onKeyDown:n,onKeyUp:r,onPaste:o,onBlur:l,children:i})}function gf({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 kf(e){const t=_.useRef(null),n=cw(t);return"html"in e?d.jsxs("div",{ref:t,className:"card-band md",children:[d.jsx("div",{dangerouslySetInnerHTML:{__html:e.html}}),n]}):d.jsxs("div",{ref:e.still?void 0:t,className:Ke("card-band card-code",e.still&&"card-still"),children:[d.jsx("pre",{children:e.code}),!e.still&&n]})}function $9({children:e}){return d.jsx("div",{className:"card-foot",children:e})}const O9=[{selected:[]}],rm=0,M9=2;function P9({item:e,worktreeId:t,rootRef:n}){var R;const r=pt(),o=ut(),i=It(t,"card"),l=(i==null?void 0:i.id)===e.id?i.draft:O9,c=(R=l[0])==null?void 0:R.note,u=c!==void 0,h=T=>o({a:"card-draft",id:t,card:{id:e.id,draft:T,current:0}}),p=_.useRef(null),[m,k]=_.useState(rm),[g,y]=_.useState(!1),b=_.useMemo(()=>ta(e.message),[e.message]),S=T=>{g||!r||(r.send(E4(e,t,T,c)),T&&y(!0),o({a:"answered",id:t}))},j=()=>{u||h(Qd(l,0,"")),k(rm),requestAnimationFrame(()=>{var T;return(T=p.current)==null?void 0:T.focus()})},E=T=>S(T===rm),N=()=>o({a:"card-park",id:t,cardId:e.id}),A=()=>{var $;const T=Md(l,0);T!==l&&h(T),($=n.current)==null||$.focus()},O=T=>{pw(T,{count:M9,cursor:m,onCursor:k,onPick:E,onEscape:N,onFieldEnter:()=>S(!0),onFieldLeave:A})||T.key==="n"&&(T.preventDefault(),j())},P=[{label:"go",hint:{k:"n",label:"add context",icon:"edit",on:!u},checked:u,field:u?{ref:p,value:c??"",placeholder:"a note for the agent there, sent with go",enterKeyHint:"send",onChange:T=>h(Qd(l,0,T))}:void 0,description:g?"starting":void 0,disabled:g},{label:"not now",tone:"deny",disabled:g}];return d.jsxs(mw,{root:n,id:e.id,onKeyDown:O,children:[d.jsxs(gf,{sub:d.jsxs(d.Fragment,{children:["Starts a worktree in ",e.repo.path,", in ",e.mode," mode",e.mode==="auto"?", which runs without asking":"",". Nothing has started yet."," ",e.by==="agent"?"Proposed by this worktree's agent.":"You asked for this."]}),children:["Continue in ",e.repo.name,"?"]}),d.jsx(kf,{html:b}),d.jsx(mf,{rows:P,cursor:m,onCursor:k,onPick:E})]})}function L9(e,t){if(t.queued>0||t.sending||t.card)return null;const n=e.at(-1);if(!n)return null;const r=e.filter(c=>c.kind!=="page-error"),o=r.at(-1);if(o&&(o.kind==="stopped"||o.kind==="error")){if(o.seq===void 0)return null;const c=`${o.kind}:${o.seq}`;return t.dismissed.has(c)?null:o.kind==="stopped"?{verb:"continue",key:c,after:"stop"}:{verb:"continue",key:c,after:"error",...z9(r)?{again:!0}:{}}}const i=D9(e,t.dismissed);if(i!==void 0)return i;if(n.kind!=="tool"||!n.done||!n.fixable||t.dismissed.has(n.id)||e.some(c=>c.kind==="asked"&&c.toolId===n.id))return null;const l=lw(n);return l===null?null:{verb:"fix",key:n.id,toolId:n.id,command:l}}function D9(e,t){let n=0,r;for(let i=e.length-1;i>=0;i--){const l=e[i];if(l.kind==="page-error")r??(r=l.seq),n+=l.errors.length;else{if(l.kind==="user"||l.kind==="asked")break;if(l.kind==="tool"&&Sg({name:l.name,kind:l.toolKind}))break}}if(n===0)return;if(r===void 0)return null;const o=`page:${r}`;return t.has(o)?null:{verb:"fix",key:o,page:{errors:n}}}function z9(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 fg=new Set;const hg=new Set;function F9(e){return hg.add(e),()=>{hg.delete(e)}}function om(e){fg=new Set(fg).add(e);for(const t of hg)t()}function B9(){return _.useSyncExternalStore(F9,()=>fg)}const U9=e=>Zc.some(t=>t.id===e);function H9(e){return[...Zc.map(t=>({name:t.id,description:t.description,hint:"[<description>]"})),{name:"check",description:"run the repo's check here and write the recap and the commit message",hint:"[<note for the commit message>]"},{name:"land",description:e},{name:"archive",description:"archive this worktree once its work has landed"},{name:"handoff",description:"continue this work in another project; Toyon starts a worktree there with your message",hint:"<project> [<message>]"}]}function fT(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 W9(e,t){const n=fT(e,t);return[...n.yours,...n.own,...n.rest]}function Ax(e,t){const n=fT(e,t);return{rows:[...n.yours,...n.own],more:n.rest.length}}function K9(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 Z9({item:e,ask:t,worktreeId:n,rootRef:r}){const o=pt(),i=ut(),l=L(y=>y.activeId),[c,u]=_.useState(0),h=t.plan,p=_.useMemo(()=>t.detail&&!h?ta(t.detail):"",[t.detail,h]),m=()=>{h&&l===n&&tr({dispatch:i},{worktreeId:n,path:h,view:"preview",focus:!1})};gt([e.id,h],m);const k=y=>{const b=t.choices[y];b&&(o==null||o.send({t:"agent-decide",worktreeId:n,askId:e.id,choiceId:b.id}),i({a:"answered",id:n}))},g=y=>{pw(y,{count:t.choices.length,cursor:c,onCursor:u,onPick:k,onEscape:()=>i({a:"card-park",id:n,cardId:e.id})})};return d.jsxs(mw,{root:r,id:e.id,onKeyDown:g,children:[d.jsx(gf,{children:t.title}),t.command&&d.jsx(kf,{code:uN(t.command)}),p&&d.jsx(kf,{html:p}),d.jsx(mf,{rows:t.choices.map(y=>({label:y.name,tone:y.kind.startsWith("reject")?"deny":void 0})),cursor:c,onCursor:u,onPick:k})]})}function q9({item:e,ask:t,worktreeId:n,rootRef:r,numbers:o,onScreen:i,onAnswer:l}){const c=pt(),u=ut(),h=Zn(),p=L(G=>G.clientId),m=vi(),{message:k,questions:g}=t,y=Za(e.id),b=It(y,"attachments"),S=jS(y,n),j=It(n,"card"),E=_.useMemo(()=>(j==null?void 0:j.id)===e.id?j:{id:e.id,draft:iP(g),current:0},[j,e.id,g]),{draft:N,current:A}=E,O=A===Ec(g),P=g[A],R=N[A],T=!!(P!=null&&P.multi),[$,D]=_.useState(()=>Ba(P,R)),z=_.useRef(null);_.useEffect(()=>{const G=window.visualViewport;if(!G)return;const ce=()=>{z.current&&z.current===document.activeElement&&z.current.scrollIntoView({block:"nearest"})};return G.addEventListener("resize",ce),()=>G.removeEventListener("resize",ce)},[]);const V=(G,ce)=>u({a:"card-draft",id:n,card:{id:e.id,draft:G,current:ce}}),se=G=>{if(l){G&&l(G);return}const ce=G?b:[],oe={t:"agent-answer",worktreeId:n,askId:e.id,...G?{answers:G}:{}};ce.some(hi)?u({a:"hold-send",id:y,log:n,text:Yg(g,G).join(`
|
|
234
|
+
`),frame:oe}):(c==null||c.send({...oe,...ce.length?{attachments:ce.map(Va),boxId:y,clientId:p}:{}}),ce.length&&u({a:"clear-attachments",id:y})),u({a:"answered",id:n})},I=()=>u(l?{a:"ask-revive",id:n}:{a:"card-park",id:n,cardId:e.id}),ne=()=>{gd(g,N)&&se(N)},we=G=>{D(Ba(g[G],N[G])),V(N,G)},K=G=>{P!=null&&P.note&&(V(N0(N,A,G,T),A),requestAnimationFrame(()=>{var ce;return(ce=z.current)==null?void 0:ce.focus()}))},B=G=>{if(!(P!=null&&P.note))return;const ce=P.options[G];if(D(G),!ce||T)return K(!ce);V(N0(_0(N,A,ce.value,!1),A,!1,!1),A),requestAnimationFrame(()=>{var oe;return(oe=z.current)==null?void 0:oe.focus()})},ee=()=>B($),J=G=>{if(lP(P,G))return D(G),K(!0);const ce=P==null?void 0:P.options[G];if(!P||!ce)return;const oe=_0(Md(N,A),A,ce.value,T);if(T){D(G),V(oe,A);return}const re=T0(g,oe,A);D(re.cursor),V(oe,re.current),re.send&&gd(g,oe)&&se(oe)},W=()=>{var ce;const G=Md(N,A);G!==N&&(V(G,A),D(Ba(P,G[A]))),(ce=r.current)==null||ce.focus()},ie=()=>{var oe;const G=Md(N,A);if((oe=r.current)==null||oe.focus(),!Ga(G[A])){G!==N&&(V(G,A),D(Ba(P,G[A])));return}const ce=T0(g,G,A);D(ce.cursor),V(G,ce.current),ce.send&&gd(g,G)&&se(G)},Te=G=>{if(S.onPasteKey(G),!pw(G,{count:O?g.length:aP(P),cursor:O?void 0:$,spacePicks:T,onCursor:D,onPick:ce=>O?we(ce):J(ce),onSubmit:ne,onEscape:I,onFieldEnter:ie,onFieldLeave:W})){if(G.key==="ArrowLeft"||G.key==="ArrowRight"||G.key==="Tab"){G.preventDefault();const ce=G.key==="ArrowLeft"||G.key==="Tab"&&G.shiftKey;return we(hP(A,ce?-1:1,mP(g)))}if(G.key==="n"&&(P!=null&&P.note))return G.preventDefault(),ee();if(G.key==="s"&&!l)return G.preventDefault(),se()}},Ce=G=>g.length===1&&!G.multi,de=(G,ce)=>d.jsxs($9,{children:[(!G||!Ce(G)||m&&(ce==null?void 0:ce.note)!==void 0)&&d.jsx(De,{variant:"outline",size:"md",disabled:!gd(g,N),onClick:ne,children:"send"}),(G==null?void 0:G.note)&&ce&&ce.selected.length>0&&ce.note===void 0&&d.jsxs(De,{tone:"quiet",size:"md",onClick:()=>K(!1),children:[d.jsx(qo,{k:"n",chip:!0}),"add a note"]}),!l&&d.jsxs(De,{tone:"quiet",size:"md",onClick:()=>se(),children:[d.jsx(qo,{k:"s",chip:!0}),"skip"]}),d.jsx(Rt,{className:"card-attach",icon:"attach",tone:"chrome",label:i?"Attach a picture":"Attach a picture or a file",onClick:()=>SS(h,y,{images:i})})]}),be=b.length>0&&d.jsx("div",{className:"card-chips",children:jg(b,o).map(([G,ce])=>{const oe=()=>u({a:"detach",id:y,key:G.key});return G.kind==="pick"?null:d.jsx(cT,{item:G,n:ce,onRemove:oe},G.key)})}),le=(G,ce)=>{const oe=ce===A,re=N[ce],Le=gE(re,!!G.multi),Ue=oe?G.options[$]:void 0,_e=Ne=>({ref:oe?z:void 0,value:(re==null?void 0:re.note)??"",placeholder:Ne,enterKeyHint:Ec(g)===-1?"send":"next",onChange:qe=>V(Qd(N,ce,qe),ce)}),je=G.options.map(Ne=>{const qe=!!(re!=null&&re.selected.includes(Ne.value));return{label:d.jsxs(d.Fragment,{children:[Xg(Ne.label),gP(Ne.label)&&d.jsx("span",{className:"badge-recommended",children:"recommended"})]}),description:Ne.description,hint:G.note&&!G.multi?{k:"n",label:"add a note",icon:"edit",on:(re==null?void 0:re.note)===void 0}:void 0,checked:qe,field:qe&&!Le&&(re==null?void 0:re.note)!==void 0?_e("a note for the agent, sent with your pick"):void 0}});return G.note&&je.push({label:G.note.label,description:Le?void 0:"your own answer",checked:Le,field:Le?_e("your own answer"):void 0}),d.jsxs("div",{className:Ke("card-page",!oe&&"card-page-off"),children:[d.jsx(gf,{children:G.text||k}),oe&&be,d.jsx(mf,{rows:je,cursor:oe?$:void 0,onCursor:D,onPick:Ne=>{var qe;J(Ne),(qe=r.current)==null||qe.focus()},onHint:B}),(Ue==null?void 0:Ue.preview)&&d.jsx(kf,{code:Ue.preview,still:!0}),de(G,re)]},G.id)};return d.jsxs(mw,{root:r,id:e.id,onKeyDown:Te,onKeyUp:S.onPasteKeyUp,onPaste:S.onPaste,children:[g.length>1&&d.jsx("div",{className:"card-tabs",children:d.jsx(Zf,{label:"questions",owner:"ask",items:[...g.map((G,ce)=>({id:String(ce),label:G.header||`question ${ce+1}`,lead:d.jsx("span",{className:Ke("dot card-step",Ga(N[ce])&&"answered")})})),{id:String(g.length),label:"send",far:!0}],current:String(A),onPick:G=>{var ce;we(Number(G)),(ce=r.current)==null||ce.focus()}})}),d.jsxs("div",{className:"card-pages",children:[g.map(le),Ec(g)!==-1&&d.jsxs("div",{className:Ke("card-page",!O&&"card-page-off"),children:[d.jsx(gf,{children:"Send these answers?"}),O&&be,d.jsx(mf,{hover:!0,rows:g.map((G,ce)=>{const oe=Ga(N[ce])?uP(G,N[ce]):void 0;return{label:d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"row-dim",children:G.header||`question ${ce+1}`})," ",d.jsx("span",{className:Ke(!oe&&"row-dim"),children:oe?oe.pick:"no answer yet"})]}),description:oe==null?void 0:oe.note}}),onPick:G=>{var ce;we(G),(ce=r.current)==null||ce.focus()}}),de()]})]})]})}const G9=IS("top"),V9=5*6e4;function Y9({usage:e,limits:t,auth:n,now:r,onClose:o}){const i=t?pz(t,r):[],l=i.length?iz(n):void 0,c=t&&r-t.at>V9?ok(r-t.at):null,u=(e==null?void 0:e.cost)!==void 0?` · ${eu(e.cost)}`:"";return d.jsxs($s,{className:"usage-panel",anchor:"parent",placement:G9,onDismiss:o,onKey:h=>{h.key==="Escape"&&(h.stopPropagation(),o())},children:[e&&d.jsx(Ix,{name:"context",used:e.used/e.size,sub:`${jb(e.used)} of ${jb(e.size)}${u}`}),l&&d.jsx("div",{className:"usage-who section-title",children:l}),i.map(h=>d.jsx(Ix,{name:h.name,used:h.used,sub:h.sub},h.key)),c&&d.jsxs("div",{className:"usage-stale hint",children:["read ",c," ago"]})]})}function Ix({name:e,used:t,sub:n}){const r=Math.max(0,Math.min(1,t));return d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"usage-row",children:[d.jsx("span",{className:"usage-name",children:e}),d.jsx("span",{className:"meter",children:d.jsx("span",{className:"meter-fill",style:{"--meter":r}})}),d.jsxs("span",{className:"usage-fig",children:[Math.round(100*t),"%"]})]}),d.jsx("div",{className:"usage-sub hint",children:n})]})}const Rx=[],X9=[],Q9=new Set(["ArrowLeft","ArrowRight","Home","End","PageUp","PageDown"]),J9=150,$x=e=>({kind:"cmd",c:e});function eB(e,t,n,r){return e==="command"?r?n===0?"starting the agent to see what it offers…":"no matching command":"no session has run this agent yet, so it has offered no commands":t?"no matches":"listing files…"}function tB(e){return e.kind==="cmd"?`/${e.c.name} `:e.kind==="folder"?`@${e.path}/ `:e.kind==="changes"?"@changes ":`@${e.path} `}function Nc({active:e,draft:t,archived:n,found:r,project:o,greenfield:i,placement:l="dock"}){var Cl,Al,Il,Rl,$l,ks,pu,mu,gu;const c=l==="screen",u=ut(),h=pt(),{storage:p}=lo(),m=Zn(),k=!!t,g=(e==null?void 0:e.worktree.id)??null,y=e==null?void 0:e.worktree.repoId,b=o?rl:n?n.id:r?r.id:fl(e),S=!!n||!!r,j=n?n.restorable:!!r&&!r.locked,E=It(b,"draft"),N=It(b,"attachments"),A=It(b,"notice"),O=((Cl=e==null?void 0:e.worktree.owns)==null?void 0:Cl.join(", "))??"",P=_.useRef({id:g,owns:O});gt([g,O],()=>{const q=P.current;P.current={id:g,owns:O},!(q.id!==g||q.owns===O||!O||!b||n)&&u({a:"notice",id:b,text:`Running its own ${O} here now: this branch changed it.`})});const R=It(b,"mark"),T=(R==null?void 0:R.by)==="walk"?R:void 0,$=It(g,"chat"),D=It(g,"queue"),z=_.useMemo(()=>g&&!k?_k($):null,[g,k,$]),V=It(g,"cardParked"),se=It(g,"sending"),I=_.useMemo(()=>g&&!k&&!se?mE($):null,[g,k,se,$]),ne=It(g,"askRevived"),we=!z&&I&&ne===I.id?I:null,K=z&&V!==z.id?z:we,B=we?Za(we.id):null,ee=It(B,"attachments"),J=z?V===z.id?z:null:I&&!we?I:null,W=_.useRef(null),ie=vi(),Te=yk(),Ce=It(Te,"page"),de=Xc(),{onPaste:be,onPasteKey:le,onPasteKeyUp:G}=jS(b,g),ce=qL(),oe=zN(),re=E8(),Le=B9(),Ue=_.useMemo(()=>g&&!k?L9($,{queued:D.length,sending:!!se,card:!!(K||J),dismissed:Le}):null,[g,k,$,D.length,se,K,J,Le]),_e=q=>b&&u({a:"set-draft",id:b,text:q}),je=L(q=>q.clientId),Ne=L(q=>q.repos),qe=L(q=>q.repos.find(Je=>Je.id===(e==null?void 0:e.worktree.repoId))??null),Ft=L(q=>q.defaultAgent),qt=L(q=>q.agentChosen),jt=k||!!i||!!o,Ht=!jt&&!!e&&!e.worktree.agent,sn=jt||Ht,Ct=(t==null?void 0:t.agent)??Ft,He=L(q=>q.agents.find(Je=>Je.id===(sn?Ct:e==null?void 0:e.worktree.agent))),Ze=!!(He!=null&&He.quick),At=(He==null?void 0:He.models)??Rx,_t=(He==null?void 0:He.efforts)??Rx,[kt,Fn]=B8(Ct),[un,xn]=D8(Ct),$t=L(q=>q.agents),Tn=(q,Je)=>{if(q===Ct){Fn(Je);return}U8(p,q,Je),Y(q)},Y=q=>{k?u({a:"draft-agent",id:q}):h==null||h.send({t:"set-default-agent",agent:q})},pe=E9(He,$t,sn),nt=pe==null?void 0:pe.other,dt=It(g,"model"),Bt=It(g,"effort"),Ot=It(g,"usage")??(e==null?void 0:e.usage),[Ee]=KN(qe),$e=(t==null?void 0:t.profile)??Ee,[Wt,ft]=z8(qe),Z=(e==null?void 0:e.worktree.mode)??Hd,ge=L(q=>q.picking),Oe=L(q=>q.layout.term),st=vE((e==null?void 0:e.procs)??[]),Et=bn("composer"),Mt=It(g,"files"),ze=_.useMemo(()=>xE(Mt??X9),[Mt]),Se=It(g,"git"),Ge=(Se==null?void 0:Se.files.length)??(e==null?void 0:e.dirty)??0,Kt=(Se==null?void 0:Se.unpushed)??(e==null?void 0:e.unpushed)??0,Qe=L(q=>{var Je;return g?(Je=q.shipping[g])==null?void 0:Je.op:void 0}),mn=L(q=>{var Je;return g?(Je=q.shipping[g])==null?void 0:Je.step:void 0}),Yt=L(q=>ol(q,y)),En=L(q=>{var Je;return Yt?(Je=q.shipping[Yt.id])==null?void 0:Je.op:void 0}),qn=Yt&&qe&&jt?qS(qe.defaultBranch,Yt):null,an=L(q=>k?_P(q.rows,y,Ct,Ft):g),wn=It(an,"commands"),mr=wn.some(q=>q.name==="compact"),Mn=(e==null?void 0:e.agent)==="working"||(e==null?void 0:e.agent)==="waiting",tn=Mn&&!!g&&!k,Gn=e==null?void 0:e.worktree.lastTurn,nn=!E.trim()&&N.length===0,Q=!k&&!i&&nn&&!Mn?Gn:void 0,ke=!k&&!i&&e&&qi(e.worktree)?e.worktree.landing:void 0,tt=!!(ke!=null&&ke.ready)&&!ke.stale&&!wd(ke,Ge,Ze,He==null?void 0:He.name),at=nn&&(!Mn||tt)?ke:void 0,dn=Ge>0&&!!(at!=null&&at.subject),Gt=Ge||(((Al=Se==null?void 0:Se.committed)==null?void 0:Al.length)??0),Tr=!k&&!i&&nn&&!Mn&&!!e,Vn=!!(e!=null&&e.worktree.landed)&&Ge===0,Cn=Tr&&Vn,rn=Tr&&!Cn?e.worktree.pr:void 0,ve=!Vn&&((Il=e==null?void 0:e.worktree.pr)==null?void 0:Il.state)==="open"?e.worktree.pr:void 0,Ve=!!ve&&(Ge>0||Kt>0),We=((Rl=e==null?void 0:e.worktree.pr)==null?void 0:Rl.state)==="closed",mt=ai((qe==null?void 0:qe.config)??{}),ln=_.useMemo(()=>H9(Wd(ai((qe==null?void 0:qe.config)??{}),qe==null?void 0:qe.defaultBranch)),[qe]),yn=()=>g&&(h==null?void 0:h.send({t:"chat",worktreeId:g,text:"/compact"})),H=jt?"nothing to compact until the first reply":mr?Mn?"wait for the turn to end":void 0:"this agent offers no compact command",me=mr&&Ot?lz(Ot.used/Ot.size):void 0,Be=He==null?void 0:He.limits,lt=jt?void 0:Ot,Nt=(!!g||jt)&&!!(lt||Be),Xt=Date.now(),[Bn,Yn]=_.useState(!1),Dr=_.useRef(0),zr=()=>{window.clearTimeout(Dr.current),Yn(!1)};gt([g],zr);const Ro=vk(),xr=(Ro==null?void 0:Ro.owner)==="composer"&&Ro.key==="usage";gt([xr],()=>{xr&&zr()});const Zr=()=>[{id:"compact",label:"compact the context",detail:H||!Ot?void 0:az(Ot.used/Ot.size),disabled:H,onClick:yn}],[Er,qr]=_.useState(0),[Qt,wt]=_.useState(null),[$o,An]=_.useState(null),on=_.useRef(null),Dt=b&&!S&&!o?px(E,Er):null,nr=Dt!==null&&Dt.from!==Qt&&!T,Ae=Dt==null?void 0:Dt.kind,M=Dt==null?void 0:Dt.query,F=_.useMemo(()=>{if(M===void 0)return[];if(Ae==="command")return M.trim()?FF(W9(ln,wn),M).slice(0,8).map($x):Ax(ln,wn).rows.map($x);const q=[],Je=(Se==null?void 0:Se.files.length)??0;return Je>0&&"changes".startsWith(M.toLowerCase())&&q.push({kind:"changes",n:Je}),q.push(...k9(Mt??[],ze,(Se==null?void 0:Se.files)??[],M,8)),q},[Ae,M,Mt,ze,Se,wn,ln]),ae=Ae==="command"&&M!==void 0&&!M.trim()?Ax(ln,wn).more:0,ye=_.useRef(null),Me=_.useRef(null),Ye=()=>{var q;return(q=W.current??ye.current)==null?void 0:q.focus()},yt=Ye;gt([i?e==null?void 0:e.worktree.id:null],()=>{if(!i)return;const q=requestAnimationFrame(()=>{var Pt;const Je=document.activeElement;(!Je||Je===document.body)&&((Pt=ye.current)==null||Pt.focus())});return()=>cancelAnimationFrame(q)});const gn=L(q=>q.focusChat),Xn=_.useRef(gn),In=!!tS();gt([gn],()=>{if(gn===Xn.current||(Xn.current=gn,In!==!!i))return;const q=requestAnimationFrame(Ye);return()=>cancelAnimationFrame(q)});const Yo=K==null?void 0:K.id,Jn=_.useRef({id:g,cardUpId:Yo});gt([g,Yo],()=>{const q=Jn.current;if(Jn.current={id:g,cardUpId:Yo},Yo||!q.cardUpId||q.id!==g||In!==!!i||ie&&!J)return;const Je=requestAnimationFrame(()=>{var Zt;const Pt=document.activeElement;(!Pt||Pt===document.body)&&((Zt=ye.current)==null||Zt.focus())});return()=>cancelAnimationFrame(Je)});const hs=L(q=>q.walked),kl=_.useRef(hs);gt([hs],()=>{if(hs===kl.current||(kl.current=hs,In!==!!i))return;const q=requestAnimationFrame(()=>{const Je=document.activeElement;(!Je||Je===document.body||Je.closest(".rail"))&&Ye()});return()=>cancelAnimationFrame(q)});const wl=MS({results:F,keyOf:q=>q.kind==="cmd"?`c:${q.c.name}`:q.kind==="changes"?"changes":`f:${q.path}`,q:(Dt==null?void 0:Dt.query)??"",listRef:on,tabPicks:!0,onPick:q=>{if(!Dt)return;const{text:Je,caret:Pt}=zF(E,Dt,tB(q));_e(Je),wt(Dt.from),An(q.kind==="cmd"&&q.c.hint?{name:q.c.name,hint:q.c.hint}:null),requestAnimationFrame(()=>{const Zt=ye.current;Zt&&(Zt.focus(),Zt.setSelectionRange(Pt,Pt),qr(Pt))})}}),rr=g||S?e8(E):null,bi=$o&&E===`/${$o.name} `?$o.hint:null,Ms=rr===""&&e?k?" 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,Ps=bi??Ms,yl=(e==null?void 0:e.worktree.title)??"untitled",xi=($l=Gn==null?void 0:Gn.recap)==null?void 0:$l.text,Ei=()=>{g&&ci(h,u,{t:"land",worktreeId:g})},Si=q=>{g&&(h==null||h.send({t:"judge",worktreeId:g,...q?{note:q}:{}}))},vl=!!((ks=qe==null?void 0:qe.config.check)!=null&&ks.trim()),la=$k(ke,Ge,Ze),Xo=Tr&&!Qe&&!jt&&qi(e.worktree)&&!Vn&&!We&&Gt>0&&(!ke||!!ke.stale||la==="unanswered"),ca="Archive this worktree when you are done here; the rail's archived section brings it back with its chat.",ua=Ve?"update":Ig(mt,(e==null?void 0:e.worktree)??{}),bl=qe?Ef(qe):"main",da=Ve&&ve?`Commit, take ${bl} in and push the branch; PR #${ve.number} takes the new commits.`:`${Wd(mt,qe==null?void 0:qe.defaultBranch)}.`,lr=g?Cn?{word:"archive",kind:"archive",line:((pu=e==null?void 0:e.worktree.pr)==null?void 0:pu.state)==="merged"?Ns(e.worktree.pr):`landed on ${(qe==null?void 0:qe.defaultBranch)??"main"}.`,tip:ca,run:()=>Ji(h,u,[g])}:(rn==null?void 0:rn.state)==="open"&&!Ve?VS(rn)?{word:"land",kind:"merge",line:yd(xi??Ns(rn)),tip:`${Ns(rn)} Merge the PR now, by the method the repo allows.`,run:Ei,ships:!0}:{word:"view",kind:"view",line:yd(xi??Ns(rn)),tip:`${Ns(rn)} Open the PR on GitHub.`,run:()=>window.open(rn.url,"_blank")}:(rn==null?void 0:rn.state)==="closed"?{word:"archive",kind:"archive",line:Ns(rn),tip:`${Ns(rn)} ${ca}`,run:()=>Ji(h,u,[g])}:Xo?{word:"check",kind:"check",line:(ke==null?void 0:ke.subject)??yd(xi??PD(Gt)),tip:YS(ke,vl,la),run:Si}:at!=null&&at.ready&&!wd(at,Ge,Ze,He==null?void 0:He.name)?{word:ua,kind:"ship",line:at.subject??yd(xi??(wb(at,Gt)||"ready")),tip:[wb(at,Gt),MD(bl,e==null?void 0:e.behind),da,at.subject&&Ge>0?"Tab from the word edits the message first.":""].filter(Boolean).join(" "),run:Ei,ships:!0}:null:null,xl=(mu=e==null?void 0:e.worktree.lands)==null?void 0:mu.at(-1),jr=xl&&GS(xl),Qo=((lr==null?void 0:lr.kind)==="ship"||(lr==null?void 0:lr.kind)==="check")&&at?LD(at,la):(lr==null?void 0:lr.word)==="archive"&&jr?Kr(jr):null,_i=_.useRef(null);Qe!=="land"&&(_i.current=g&&(lr!=null&&lr.ships)?{id:g,verb:lr,under:Qo}:null);const Jo=Qe==="land"&&nn&&((gu=_i.current)==null?void 0:gu.id)===g?_i.current:null,or=Jo?Jo.verb:lr,Ls=!!(or!=null&&or.ships)&&Qe==="land",Ni=pk(mn,mk),es=Dc(e,"commit"),ps=Dc(e,"check"),ms=QS(Ls?es:ps),ou=Qi(Mk(ms)?ms==null?void 0:ms.since:void 0),El=at?at.check==="pending"&&ps&&ms===ps?Hm("Checking the work",ps,ou):wd(at,Ge,Ze,He==null?void 0:He.name):null,Sl=or&&Ls?Ni?`${or.word}: ${Ni}`:`${or.word} ${or.line}`:null,fa=Sl&&es&&ms===es?Hm(Sl,es,ou):Sl,su=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?or?"":El||(rn?Ns(rn):Q?Ok(Q):i?`describe ${yl}…`:jt?"describe a change":c?`message agent on ${yl}`:`message agent on ${yl}; / for a command, ! for a shell command`):"no worktree selected",ha=E!==""||Ps||!e?null:Ls?Ni?null:Jo?Jo.under:Qo:or?Qo:rn||El?xi??(at==null?void 0:at.subject)??null:null,iu=_.useRef(!1);_.useEffect(()=>{const q=nr&&!iu.current;iu.current=nr,q&&((Dt==null?void 0:Dt.kind)==="file"&&g?Uf(g,m.getState(),{sock:h,dispatch:u}):(Dt==null?void 0:Dt.kind)==="command"&&an&&wn.length===0&&(h==null||h.send({t:"list-commands",worktreeId:an})))},[nr,Dt==null?void 0:Dt.kind,wn.length,g,an,h,m,u]);const au=()=>{if(!e)return;const q=[],Je=Ce;if(Je.url)try{const ur=new URL(Je.url);q.push(`current route: ${ur.pathname}${ur.search}`)}catch{}Je.title&&q.push(`page title: ${Je.title}`);const Pt=[];i&&Pt.push(j8(e.worktree.title,qe==null?void 0:qe.configFile)),q.length>0&&Pt.push(`What the user is looking at right now:
|
|
235
|
+
${q.join(`
|
|
236
|
+
`)}`);const Zt=n8($);return Zt&&Pt.push(Zt),Pt.length>0?Pt:void 0},_l=q=>{jt?ft(q):g&&q!==Z&&(h==null||h.send({t:"set-worktree-mode",worktreeId:g,mode:q}))},cr=q=>b&&u({a:"notice",id:b,text:q}),nh=(q,Je="")=>{if(!e||!g)return;if(q==="handoff"){if(jt)return cr("a new worktree has nothing to continue yet");const Zt=S4(Je,Ne,e.worktree.repoId);"pick"in Zt?u({a:"open",overlay:{kind:"handoff",worktreeId:g}}):"error"in Zt?cr(Zt.error):h==null||h.send({t:"handoff-ask",worktreeId:g,repoId:Zt.repo.id,...Zt.text?{text:Zt.text}:{}});return}if(q==="archive"){Vn||We?Ji(h,u,[g]):cr("archive is for a landed worktree; this one has not landed");return}if(q==="check"){jt||!qi(e.worktree)?cr("nothing to check from here"):Mn?cr("wait for the turn to end"):Gt===0?cr("nothing to check: no changes here"):Si(Je||void 0);return}const Pt=ke?wd(ke,Ge,Ze,He==null?void 0:He.name):null;jt||!qi(e.worktree)?cr("nothing to land from here"):Vn?cr(`already landed on ${(qe==null?void 0:qe.defaultBranch)??"main"}`):Pt?cr(Pt):Mn&&(!ke||ke.stale)?cr("wait for the turn to end"):ke!=null&&ke.stale?cr("the work changed since this was checked; check again first"):Ei()},pa=N.some(hi),Ds=()=>{b&&(h==null||h.send({t:"set-draft",boxId:b,text:E,clientId:je}))},gs=(q,Je,Pt,Zt)=>u({a:"hold-send",id:q,log:Je,text:Pt,frame:Zt}),Nl=()=>{if(!b)return;const q=K9(E,ln),Je=q&&U9(q.name)?q.name:void 0;if(o){if(o.busy)return;if(o.why)return cr(o.why);(Ct!==Ft||!qt)&&(h==null||h.send({t:"set-default-agent",agent:Ct})),Ds(),o.create();return}if(nn)return;const Pt=rr===null&&(!q||!!Je&&!!q.args);if(pe&&He&&Pt){cr(pe.kind==="installing"?`${He.name} is still installing`:pe.retry?`nothing runs here until ${He.name} is installed`:pe.text);return}const Zt=()=>({text:E.trim(),attachments:N.length?N.map(Va):void 0});if(n){if(!n.restorable)return;if(rr!==null){cr("nothing runs here until it is restored");return}const co={t:"restore-worktree",archiveId:n.id,clientId:je};if(pa)return gs(b,b,E.trim(),co);Ds(),h==null||h.send(hc(co,b,E.trim(),N)),u({a:"sending",id:b,message:Zt()}),u({a:"sent-box",id:b});return}if(r){if(r.locked)return;if(rr!==null){cr("nothing runs here until Toyon takes it over; its menu on the rail opens a shell");return}const co={t:"adopt-worktree",worktreeId:r.id,clientId:je};if(pa)return gs(b,b,E.trim(),co);Ds(),h==null||h.send(hc(co,b,E.trim(),N)),u({a:"sending",id:b,message:Zt()}),u({a:"sent-box",id:b});return}if(!e||!g)return;if(rr!==null){if(rr&&Qe&&!k){cr(`${XC(Qe)} is running here; run the command once it is done`);return}rr&&k?u({a:"term-run",id:g,command:rr}):rr&&(h==null||h.send({t:"exec",worktreeId:g,command:rr})),_e("");return}if(q&&!Je){nh(q.name,q.args),_e("");return}if(Je&&!(q!=null&&q.args)){_l(Je),_e("");return}if(t!=null&&t.batch&&N.length){cr("a batch takes no attachments; remove them or turn batch off");return}const ur=q?q.args:E.trim(),Fr=au(),ku=N.length?N.map(Va):void 0;if(Je&&_l(Je),jt){const co=qc(e.worktree)?{worktreeId:g}:{},Ol={clientId:je,repoId:e.worktree.repoId,context:Fr,agent:Ct,profile:$e,mode:Je??Wt,...kt?{model:kt}:{},...un?{effort:un}:{},..._E(t)?{carry:!0}:{}};if((Ct!==Ft||!qt)&&(h==null||h.send({t:"set-default-agent",agent:Ct})),t!=null&&t.batch)Ds(),h==null||h.send({t:"batch-worktrees",repoId:e.worktree.repoId,prompt:ur,agent:Ct,...kt?{model:kt}:{},...un?{effort:un}:{},boxId:b}),u({a:"sent-box",id:b});else{const Ml=t&&t.variants>1?{variants:t.variants}:{},Pl={t:"create-worktree",...Ol,...co,...Ml};pa?gs(b,b,ur,Pl):(Ds(),h==null||h.send(hc(Pl,b,ur,N)),u({a:"sending",id:b,message:{text:ur,attachments:ku}}),u({a:"sent-box",id:b}))}}else{Ht&&(h==null||h.send({t:"set-worktree-model",worktreeId:g,model:kt}),h==null||h.send({t:"set-worktree-effort",worktreeId:g,effort:un}));const co={t:"chat",worktreeId:g,clientId:je,context:Fr};pa?gs(b,g,ur,co):(Ds(),h==null||h.send(hc(co,b,ur,N)),Mn||u({a:"sending",id:g,message:{text:ur,attachments:ku}}),u({a:"sent-box",id:b}))}i&&u({a:"show-chat"})},rh=q=>{if(!g||(we==null?void 0:we.ask.kind)!=="question")return;if(!q.some(Ga))return u({a:"ask-revive",id:g});const Je=Yg(we.ask.questions,q).join(`
|
|
237
|
+
`),Pt={t:"chat",worktreeId:g,clientId:je,context:au()};if(B&&ee.some(hi))gs(B,g,Je,Pt);else{const Zt=ee.length?ee.map(Va):void 0,ur=Zt&&B?{attachments:Zt,boxId:B}:{};h==null||h.send({...Pt,text:Je,...ur}),Zt&&B&&u({a:"clear-attachments",id:B}),u({a:"sending",id:g,message:{text:Je,attachments:Zt}})}u({a:"answered",id:g}),u({a:"ask-revive",id:g})},Tl=L(q=>q.autoSend);gt([Tl,g],()=>{!Tl||Tl!==g||nn||In!==!!i||(u({a:"auto-sent"}),Nl())});const lu=()=>{const q=N[N.length-1];return!b||!q?!1:(u({a:"detach",id:b,key:q.key}),!0)},cu=q=>{b&&(u({a:"walk",id:b,walk:q.walk,text:q.text}),requestAnimationFrame(()=>{var Je;(Je=ye.current)==null||Je.setSelectionRange(q.text.length,q.text.length),qr(q.text.length)}))},uu=()=>{b&&T&&u({a:"walk",id:b,walk:null,text:E})},du=jt?[]:$.map(q=>q.kind==="user"?q.attachments:void 0),fu=jt?[]:D.flatMap(q=>q.attachments??[]),Ti=e==null?void 0:e.worktree.plan,hu=tn&&!K,oh=L(q=>q.reading),[jl,zs]=_.useState(!1),ma=c&&oh&&!J&&(K?!jl:nn&&!ce);return gt([ma],()=>{if(ma||!K)return;const q=requestAnimationFrame(()=>{var Je;document.activeElement===document.body&&((Je=W.current)==null||Je.focus())});return()=>cancelAnimationFrame(q)}),d.jsxs("div",{className:Ke("composer chat-input",hu&&"stopping",ma&&"lean"),onFocus:q=>zs(q.target instanceof HTMLTextAreaElement),onBlur:()=>zs(!1),children:[Ti&&e&&d.jsxs("div",{className:"composer-plan",...Et.contextMenu(()=>b_(Ti,()=>h==null?void 0:h.send({t:"reveal",worktreeId:e.worktree.id,path:Ti}),Is(h))),children:[d.jsx(St,{name:"text",className:"icon-inline"}),d.jsx(De,{variant:"inline",className:"composer-plan-path","data-tip":"Read the plan in the editor pane",onClick:()=>tr({dispatch:u},{worktreeId:e.worktree.id,path:Ti,view:"preview"}),children:Ti})]}),J&&g&&d.jsx(Hi,{icon:"chat",verb:"answer",tip:"Bring the question back into the box",onPress:()=>{u(J.kind==="ask"&&J.outcome?{a:"ask-revive",id:g,askId:J.id}:{a:"card-unpark",id:g}),u({a:"focus-chat"})},children:ob(J)}),(Ue==null?void 0:Ue.verb)==="fix"&&"toolId"in Ue&&g&&d.jsxs(Hi,{icon:"run",verb:Ue.verb,tip:"Send the agent what it printed and ask for a fix",onPress:()=>h==null?void 0:h.send({t:"fix",worktreeId:g,toolId:Ue.toolId}),onDismiss:()=>om(Ue.key),children:["what failed in ",d.jsx("code",{children:Ue.command})]}),(Ue==null?void 0:Ue.verb)==="fix"&&"page"in Ue&&g&&d.jsx(Hi,{icon:"run",verb:Ue.verb,tip:"Send the agent what the preview threw and ask for a fix",onPress:()=>h==null?void 0:h.send({t:"fix-page",worktreeId:g}),onDismiss:()=>om(Ue.key),children:"what the preview threw"}),(Ue==null?void 0:Ue.verb)==="continue"&&g&&d.jsx(Hi,{icon:"send",verb:Ue.verb,tip:Ue.after==="stop"?"Send the agent on from where its turn stopped":Ue.again?"The last press ended in this same error. Send the agent on once more, or wait it out.":"Send the agent on from where its turn failed",onPress:()=>h==null?void 0:h.send({t:"continue",worktreeId:g}),onDismiss:()=>om(Ue.key),children:Ue.after==="stop"?"where it stopped":Ue.again?"after the same error again":"after the error"}),ce&&b&&!K&&(e||j||o)&&d.jsx(Hi,{icon:"copy",verb:"attach",tip:"Attach it, as a paste would",onPress:()=>{F4(m,b,ce),Ye()},onDismiss:nS,children:ce.kind==="image"?"the image you copied":`the text you copied, ${ce.text.split(`
|
|
238
|
+
`).length} lines`}),oe&&g&&!k&&!K&&S8({prompt:oe,offered:re,agent:e==null?void 0:e.agent,chat:$})&&d.jsx(Hi,{icon:"download",verb:"install",tip:"Install Toyon as an app: a window of its own, with a Dock icon and no browser bar",onPress:()=>{bx(),oe.prompt()},onDismiss:bx,children:"Toyon as a window of its own, with a Dock icon and no browser bar"}),b&&!K&&rr===null&&jg(N,yc(mm(du),fu)).map(([q,Je])=>{const Pt=()=>u({a:"detach",id:b,key:q.key});return q.kind!=="pick"?d.jsx(cT,{item:q,n:Je,onRemove:Pt},q.key):d.jsx(aw,{pick:q,tipText:q.html,onHover:Zt=>Te&&cn.post(Te,Zt?{type:"highlight-selector",selector:q.selector,label:rk(q)}:{type:"highlight-clear"}),worktreeId:g,onOpen:(Zt,ur)=>g&&ea(m,h,g,Zt,ur),onRemove:Pt},q.key)}),nr&&Dt&&d.jsx(N8,{results:F,keyOf:q=>q.kind==="cmd"?`c:${q.c.name}`:q.kind==="changes"?"changes":q.kind==="folder"?`d:${q.path}`:`f:${q.path}`,rowClass:q=>q.kind==="file"||q.kind==="folder"?"qo-file":q.kind==="changes"?"picker-row":"picker-row picker-cmd",nav:wl,listRef:on,empty:eB(Dt.kind,Mt,wn.length,an!==null),note:ae>0?`type to find ${ae} more`:void 0,row:q=>{const Je=((Se==null?void 0:Se.files.length)??0)>0;return q.kind==="file"?dg(q.path,q.status,Dt.query,{gutter:Je}):q.kind==="folder"?dg(q.path,void 0,Dt.query,{folder:!0,gutter:Je}):q.kind==="changes"?d.jsx(On,{label:"@changes",hint:`${q.n} uncommitted ${q.n===1?"file":"files"}`}):d.jsx(K8,{c:q.c,query:Dt.query})}}),K&&ma&&g&&d.jsx(Hi,{icon:"chat",verb:"answer",tip:"Back to the question",onPress:()=>u({a:"answered",id:g}),children:ob(K)}),K&&g?K.kind==="handoff"?d.jsx(P9,{item:K,worktreeId:g,rootRef:W},K.id):K.ask.kind==="question"?d.jsx(q9,{item:K,ask:K.ask,worktreeId:g,rootRef:W,numbers:yc(mm(du),fu),onScreen:c,onAnswer:we?rh:void 0},K.id):d.jsx(Z9,{item:K,ask:K.ask,worktreeId:g,rootRef:W},K.id):d.jsxs("div",{className:Ke("composer-field",rr!==null&&"shell",T&&"recalled"),children:[d.jsx(Lc,{size:"lg",bare:!0,font:rr!==null?"mono":"ui",ref:ye,value:E,onChange:q=>{var Fr;const Je=q.target.value,Pt=q.target.selectionStart??Je.length;_e(Je),qr(Pt),wl.setIndex(0);const{inputType:Zt}=q.nativeEvent;wt(Zt==="insertFromPaste"||Zt==="insertFromDrop"?((Fr=px(Je,Pt))==null?void 0:Fr.from)??null:null)},onKeyUp:q=>{G(),qr(q.currentTarget.selectionStart??0)},onClick:q=>{qr(q.currentTarget.selectionStart??0),uu()},onPaste:be,onScroll:q=>{Me.current&&(Me.current.scrollTop=q.currentTarget.scrollTop)},onKeyDown:q=>{var Je;if(le(q),!q.nativeEvent.isComposing){if(nr){if(q.key==="Escape"){q.preventDefault(),q.stopPropagation(),wt((Dt==null?void 0:Dt.from)??null);return}if(wl.onKeyDown(q))return}if((q.key==="ArrowUp"||q.key==="ArrowDown")&&!q.altKey&&!q.ctrlKey){const Pt=q.key==="ArrowUp",Zt=D.at(-1);if(Pt&&!q.metaKey&&!T&&E===""&&g&&!k&&Zt!==void 0){q.preventDefault(),mS(m,h,g,D.length-1);return}const ur=q.metaKey?Pt?"first":"box":Pt?"up":"down",Fr=g?g8($,T??null,E,ur):null;if(Fr){q.preventDefault(),(Fr.walk!==T||Fr.text!==E)&&cu(Fr);return}}if(T&&q.key==="Escape"){q.preventDefault(),q.stopPropagation(),cu({walk:null,text:T.from});return}if(q.key==="Escape"&&Mn&&g&&!k){q.preventDefault(),q.stopPropagation(),h==null||h.send({t:"stop-agent",worktreeId:g});return}if(T&&Q9.has(q.key)&&uu(),q.key==="Tab"&&!q.shiftKey&&E===""){const Pt=(Je=q.currentTarget.closest(".composer"))==null?void 0:Je.querySelector(".composer-verb");if(Pt&&!Pt.disabled){q.preventDefault(),Pt.focus();return}if(dn){q.preventDefault(),u({a:"edit-commit"});return}}q.key==="Enter"&&(ie?q.metaKey||q.ctrlKey:!q.shiftKey)?(q.preventDefault(),Nl()):q.key==="Backspace"&&E===""&&lu()&&q.preventDefault()}},placeholder:ha||or?"":su,disabled:o?o.busy:!e&&!j}),Ps&&d.jsxs("div",{className:"composer-ghost","aria-hidden":"true",children:[d.jsx("span",{className:"picker-typed",children:E}),Ps]}),g&&rr===null&&E.includes("@")&&d.jsx("div",{ref:Me,className:"composer-ghost composer-marks","aria-hidden":"true",onClick:q=>CN(q,e==null?void 0:e.worktree.path,g,{sock:h,dispatch:u}),children:d.jsx(jN,{text:E,worktreeId:g,root:e==null?void 0:e.worktree.path,inField:!0})}),(ha||or)&&d.jsxs("div",{className:"composer-ghost","aria-hidden":or?void 0:"true",children:[d.jsx("span",{className:Ke("composer-placeholder",Ls&&"live-text"),children:fa||(or?d.jsxs(d.Fragment,{children:[d.jsx(De,{variant:"inline",tone:"strong",className:"composer-verb",disabled:!!or.ships&&!!Qe,...Ut(or.tip,void 0,{placement:"top"}),onClick:()=>{var q;or.run(),ie||(q=ye.current)==null||q.focus()},onKeyDown:q=>{q.key==="Tab"&&!q.shiftKey&&dn&&(q.preventDefault(),u({a:"edit-commit"}))},children:or.word})," ",d.jsx("span",{className:"composer-verb-line",children:or.line})]}):su)}),ha&&d.jsxs(d.Fragment,{children:[`
|
|
239
|
+
`,d.jsx("span",{className:"composer-subline",children:ha})]})]}),hu&&d.jsx(Rt,{icon:"stop",tone:"danger",className:"composer-stop",label:`Stop the agent (context up to here is kept${D.length?"; queued messages go next":""})`,hint:"esc",onClick:()=>g&&(h==null?void 0:h.send({t:"stop-agent",worktreeId:g}))})]}),A&&d.jsx("div",{className:"hint composer-notice",role:"status",children:A}),!K&&d.jsxs("div",{className:"hint composer-knobs",children:[d.jsxs("span",{className:"spawn-left",children:[sn?$t.length>1?d.jsx(H8,{agents:$t,agent:Ct,model:kt,onChange:Tn,onClose:yt}):d.jsx(_x,{models:At,value:kt,onChange:Fn,onClose:yt}):e&&d.jsx(_x,{models:At,value:e.worktree.model??"",current:dt,onChange:q=>h==null?void 0:h.send({t:"set-worktree-model",worktreeId:e.worktree.id,model:q}),onClose:yt}),sn?d.jsx(Ex,{efforts:_t,value:un,onChange:xn,onClose:yt}):e&&d.jsx(Ex,{efforts:_t,value:e.worktree.effort??"",current:Bt,onChange:q=>h==null?void 0:h.send({t:"set-worktree-effort",worktreeId:e.worktree.id,effort:q}),onClose:yt}),jt?!o&&d.jsx(Sx,{value:Wt,onChange:ft,onClose:yt}):e&&d.jsx(Sx,{value:Z,onChange:q=>h==null?void 0:h.send({t:"set-worktree-mode",worktreeId:e.worktree.id,mode:q}),onClose:yt}),Nt&&d.jsxs("span",{className:"usage-knob",onMouseEnter:()=>{xr||(window.clearTimeout(Dr.current),Dr.current=window.setTimeout(()=>Yn(!0),J9))},onMouseLeave:()=>{window.clearTimeout(Dr.current),Yn(!1)},onFocus:q=>{xr||!q.target.matches(":focus-visible")||(window.clearTimeout(Dr.current),Yn(!0))},onBlur:zr,children:[d.jsx(Rt,{icon:d.jsx(T8,{fraction:lt?lt.used/lt.size:0,level:Be?dz(Be,Xt):void 0}),tone:"chrome",on:xr,silent:!0,label:lt?`${Math.round(100*lt.used/lt.size)}% of context`:Be?Cb(Be,Xt):"",detail:[...lt&&Be?[Cb(Be,Xt)]:[],...me?[me]:[]],...Et.dropdown(Zr,"left","usage"),...Et.contextMenu(Zr,"usage")}),Bn&&d.jsx(Y9,{usage:lt,limits:Be,auth:He==null?void 0:He.auth,now:Xt,onClose:zr})]})]}),d.jsxs("span",{className:"spawn-tools",children:[b&&(e||j||o)&&d.jsx(Rt,{icon:"attach",tone:"chrome",label:c?"Attach a picture":"Attach a picture or a file, or drop one here",onClick:()=>SS(m,b,{images:c})}),!i&&!S&&!c&&!o&&d.jsx(Rt,{icon:"terminal",tone:"chrome",on:Oe,className:"composer-term",disabled:!e,label:st?st.tip:"Terminal",hint:Lt("terminal"),badge:st&&d.jsx("span",{className:"composer-term-dot"}),onClick:()=>{u(st&&!Oe&&g?{a:"term-stream",id:g,stream:st.stream}:{a:"toggle-terminal"})},...Et.contextMenu(()=>e&&g?NF(e.procs,g,Oe,{sock:h,dispatch:m.dispatch}):[])}),!i&&!de&&!S&&!c&&!o&&d.jsx(Rt,{icon:"pick",label:"Pick an element on the page to attach",hint:Lt("pick"),on:ge==="chat",disabled:!Te,onClick:()=>Te&&Pc(Te,ge,u,"chat")}),ie&&b&&(e||j||o)&&d.jsx(Rt,{icon:"send",tone:"primary",label:o?"Create the project":"Send",disabled:o?o.busy:nn,onMouseDown:q=>q.preventDefault(),onClick:Nl})]})]}),(pe||qn&&Yt)&&d.jsxs("div",{className:"composer-notes",children:[pe&&He&&d.jsxs("div",{className:"hint composer-note",role:"status",children:[d.jsx("span",{children:pe.text}),(pe.retry||nt)&&d.jsxs("span",{className:"composer-note-actions",children:[pe.retry&&d.jsx(De,{variant:"outline",onClick:()=>h==null?void 0:h.send({t:"install-agent",agent:He.id}),children:pe.retry}),nt&&d.jsxs(De,{variant:"outline","data-tip":`${nt.name} is installed and takes this message instead`,onClick:()=>Y(nt.id),children:["use ",nt.name]})]})]}),qn&&Yt&&d.jsxs("div",{className:"hint composer-note",children:[d.jsx("span",{children:qn}),RD(Yt)&&d.jsx(De,{variant:"outline",busy:En==="pull-main",disabled:!!En,"data-tip":"Fast-forward main to origin",onClick:()=>ci(h,u,{t:"pull-main",worktreeId:Yt.id}),children:"pull"})]})]})]})}function hT({children:e,className:t,tip:n,...r}){return d.jsxs("label",{className:Ke("check",t),"data-tip":n,children:[d.jsx("input",{type:"checkbox",className:"check-box",...r}),d.jsx("span",{children:e})]})}const nB=[1,2,3];function rB({draft:e,lead:t}){const n=ut(),r=L(c=>yi(c,t==null?void 0:t.repoId)),[o]=KN(r),i=L(c=>{var u;return((u=ol(c,t==null?void 0:t.repoId))==null?void 0:u.dirty)??0}),l=!e.batch&&e.variants===1;return d.jsxs("div",{className:"draft-intro",children:[d.jsxs("div",{className:"draft-row hint",children:[d.jsx(De,{variant:"ghost",tone:"chrome",on:e.batch,"data-tip":"An agent splits the prompt into a worktree per task",onClick:()=>n({a:"draft-batch",v:!e.batch}),children:"batch"}),d.jsxs("span",{className:"draft-variants",children:[nB.map(c=>d.jsx(De,{variant:"ghost",on:e.variants===c,disabled:e.batch,onClick:()=>n({a:"draft-variants",n:c}),children:c},c)),d.jsx("span",{"data-tip":"Run the same prompt in N parallel worktrees, keep the best",children:"variants"})]}),d.jsx("span",{className:"draft-runs",children:d.jsx(W8,{repo:r,value:e.profile??o,onChange:c=>n({a:"draft-profile",profile:c})})})]}),t&&r&&i>0&&d.jsx("div",{className:"draft-notes",children:d.jsxs(hT,{className:"hint draft-note",checked:_E(e),disabled:!l,tip:l?`Move the ${i} uncommitted ${i===1?"file":"files"} into the new worktree, leaving ${r.defaultBranch} clean`:"One set of changes can only go into one worktree",onChange:c=>n({a:"draft-carry",v:c.currentTarget.checked}),children:[d.jsxs("span",{className:"badge-dirty",children:["~",i]})," on ",r.defaultBranch," come along"]})})]})}function oB({row:e}){const t=pt(),n=L(l=>l.clientId),r=L(l=>l.home),o=r&&e.path.startsWith(`${r}/`)?`~${e.path.slice(r.length)}`:e.path,i=e.locked?"Toyon would be working in a directory something else is using, so taking it over waits for the lock to go.":"A message sent below takes over this branch.";return d.jsxs(Wr,{icon:e.locked?"lock":"branch",word:e.locked?"held":"discovered",tone:"quiet",below:d.jsx("div",{className:"daemon-below row-dim",children:i}),children:[d.jsxs("span",{className:"daemon-text",children:[e.locked&&`by ${e.lockReason??"another tool"}, at `,d.jsx("span",{className:"tool-hint",children:o})]}),!e.locked&&d.jsx(De,{variant:"inline",tone:"strong",onClick:()=>t==null?void 0:t.send({t:"adopt-worktree",worktreeId:e.id,clientId:n}),children:"take over"})]})}function Tc({placement:e,className:t,width:n,archived:r,found:o}){const i=ut(),l=Rs(),c=PL(),u=It(l==null?void 0:l.worktree.id,"sending"),h=pl(),p=e==="centre"&&!r&&(h!=null&&h.assumed)?h:null,m=L(y=>{var b;return((b=y.dragFiles)==null?void 0:b.at)==="chat"}),k=Zn(),g=_.useMemo(()=>L4(k),[k]);return d.jsxs("div",{className:Ke(e==="dock"?"chat-dock":e==="centre"?"chat-centre":"chat-screen",t,m&&"drop-over"),style:n===void 0?void 0:{width:n},...g,ref:y=>{var b;y?Sc.el=y:(b=Sc.el)!=null&&b.isConnected||(Sc.el=null)},children:[r?d.jsx(tm,{active:null,archived:r,tail:d.jsx(kz,{item:r})}):o?d.jsx(tm,{active:null,found:o,tail:d.jsx(oB,{row:o})}):d.jsx(tm,{active:l,lead:p&&d.jsxs("p",{className:"hint chat-centre-note",children:[p.name," has ",d.jsx("code",{children:p.assumed})," and no dev server, so it is chat only for now."," ",d.jsx(De,{variant:"inline",onClick:()=>i({a:"open",overlay:{kind:"setup",repoId:p.id}}),children:"add a dev server"})]})}),!r&&!o&&c&&!u&&d.jsx(rB,{draft:c,lead:l}),r?d.jsx(Nc,{active:null,archived:r,placement:e}):o?d.jsx(Nc,{active:null,found:o,placement:e}):d.jsx(Nc,{active:l,draft:c,placement:e})]})}const sB="modulepreload",iB=function(e){return"/"+e},Ox={},pg=function(t,n,r){let o=Promise.resolve();if(n&&n.length>0){let l=function(h){return Promise.all(h.map(p=>Promise.resolve(p).then(m=>({status:"fulfilled",value:m}),m=>({status:"rejected",reason:m}))))};document.getElementsByTagName("link");const c=document.querySelector("meta[property=csp-nonce]"),u=(c==null?void 0:c.nonce)||(c==null?void 0:c.getAttribute("nonce"));o=l(n.map(h=>{if(h=iB(h),h in Ox)return;Ox[h]=!0;const p=h.endsWith(".css"),m=p?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${h}"]${m}`))return;const k=document.createElement("link");if(k.rel=p?"stylesheet":sB,p||(k.as="script"),k.crossOrigin="",k.href=h,u&&k.setAttribute("nonce",u),document.head.appendChild(k),p)return new Promise((g,y)=>{k.addEventListener("load",g),k.addEventListener("error",()=>y(Error(`Unable to preload CSS for ${h}`)))})}))}function i(l){const c=new Event("vite:preloadError",{cancelable:!0});if(c.payload=l,window.dispatchEvent(c),!c.defaultPrevented)throw l}return o.then(l=>{for(const c of l||[])c.status==="rejected"&&i(c.reason);return t().catch(i)})},gw=800;function aB(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 Fo=e=>`${e.worktreeId}
|
|
240
|
+
${e.ref??""}
|
|
241
|
+
${e.since??""}
|
|
242
|
+
${e.path}`;class lB{constructor(t){zt(this,"files",new Map);zt(this,"looks",new Map);this.d=t}start(){var i,l;let t=this.d.store.getState();const n=this.d.store.subscribe(()=>{const c=this.d.store.getState(),u=t;t=c,this.follow(u,c)}),r=()=>{const c=this.d.store.getState().editor;c&&!c.loose&&this.refresh(Fo(c))};(i=this.d.win)==null||i.addEventListener("focus",r);const o=()=>{for(const[c,u]of this.files)u.timer!==void 0&&this.saveNow(c)};return(l=this.d.win)==null||l.addEventListener("pagehide",o),()=>{var c,u;n(),(c=this.d.win)==null||c.removeEventListener("focus",r),(u=this.d.win)==null||u.removeEventListener("pagehide",o)}}receive(t){const n=t.t==="file-read"?this.looks.get(t.seq):void 0;if(n&&t.t==="file-read"){this.looks.delete(t.seq),n(t.error||t.binary||t.tooLarge||t.version===null?null:t.after);return}const r=this.files.get(Fo(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=Zo();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=Fo(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(Fo(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(Fo(t)),r=n==null?void 0:n.conflict;!(n!=null&&n.buffer)||!r||(n.base={text:r.after,version:r.version},this.setConflict(n,null),n.pending=n.buffer.text(),this.next(n))}follow(t,n){var i,l;t.connected&&!n.connected&&this.dropped();const r=(i=n.editor)!=null&&i.loose?null:n.editor,o=(l=t.editor)!=null&&l.loose?null:t.editor;if(o&&(!r||Fo(o)!==Fo(r))&&this.closed(Fo(o)),r&&(!o||o.seq!==r.seq)&&this.opened(r),!t.connected&&n.connected)for(const c of this.files.values())c.reread=!0,this.next(c);else r&&o&&o.seq===r.seq&&Co(t,r.worktreeId).git!==Co(n,r.worktreeId).git&&this.refresh(Fo(r))}opened(t){const n=Fo(t);let r=this.files.get(n);r||(r={file:{worktreeId:t.worktreeId,path:t.path,...t.ref?{ref:t.ref}:{},...t.since?{since:t.since}:{}},open:!0,base:null,out:null,pending:null,reread:!1,writable:!1,conflict:null,buffer:null,timer:void 0,blame:null},this.files.set(n,r)),r.open=!0,r.reread=!0,r.conflict&&this.d.store.dispatch({a:"editor-conflict",file:r.file,theirs:r.conflict}),this.next(r)}closed(t){const n=this.files.get(t);n&&(n.open=!1,this.next(n))}refresh(t){const n=this.files.get(t);!n||n.file.ref||(n.reread=!0,this.next(n))}dropped(){for(const t of this.looks.values())t(null);this.looks.clear();for(const t of this.files.values())t.out&&(t.out.write!==void 0&&(t.pending??(t.pending=t.out.write)),t.out=null,t.reread=!0)}next(t){var l;if(t.out||!this.d.store.getState().connected)return;const{worktreeId:n,path:r,ref:o,since:i}=t.file;if(t.reread){t.reread=!1;const c=Zo();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=Zo();t.pending=null,t.out={seq:u,write:c},this.d.send({t:"write-file",worktreeId:n,path:r,content:c,base:((l=t.base)==null?void 0:l.version)??null,seq:u});return}!t.open&&!t.buffer&&t.pending===null&&!t.conflict&&this.files.delete(Fo(t.file))}read(t,n){var k,g;const{file:r}=t;if(n.error){t.open&&this.d.store.dispatch({a:"editor-read",file:r,disk:null,error:n.error});return}const{before:o,after:i,version:l,writable:c,binary:u,tooLarge:h}=n;t.writable=c,t.open&&(this.d.store.dispatch({a:"editor-read",file:r,disk:{before:o,after:i,version:l,writable:c,binary:u,tooLarge:h}}),!u&&!h&&(l!==null||r.ref)&&this.askBlame(t,l));const p={after:t.buffer?t.buffer.normalize(i):i,version:l};if(!t.base){t.base={text:p.after,version:l};return}const m=((k=t.buffer)==null?void 0:k.text())??t.pending??t.base.text;switch(aB(t.base,m,t.pending,p)){case"same":break;case"adopt":t.base={text:p.after,version:l};break;case"apply":(g=t.buffer)==null||g.replace(p.after),t.base={text:p.after,version:l};break;case"gone":t.base={text:"",version:null},t.open&&this.d.store.dispatch({a:"close-editor"});break;case"conflict":this.setConflict(t,p);return}this.setConflict(t,null)}askBlame(t,n){const r=Zo();t.blame={seq:r,version:n};const{worktreeId:o,path:i,ref:l}=t.file;this.d.send({t:"blame-file",worktreeId:o,path:i,ref:l,seq:r})}blamed(t,n){const r=t.blame;if(!r||r.seq!==n.seq||(t.blame=null,!t.open))return;const{commits:o,lines:i}=n;this.d.store.dispatch({a:"editor-blame",file:t.file,blame:{commits:o,lines:i,version:r.version}})}written(t,n,r){if(r.ok){t.base={text:n,version:r.version};return}if(r.reason==="changed"){t.pending??(t.pending=n),t.reread=!0;return}t.writable=!1,t.pending=null,this.d.store.dispatch({a:"editor-refused",file:t.file,message:r.message??`not saved: ${t.file.path}`})}setConflict(t,n){t.conflict===n||t.conflict&&n&&t.conflict.version===n.version||(t.conflict=n,t.open&&this.d.store.dispatch({a:"editor-conflict",file:t.file,theirs:n}))}attach(t,n){const r=this.files.get(t);if(r){if(n){r.buffer=n,r.base&&(r.base={...r.base,text:n.normalize(r.base.text)}),r.conflict&&r.pending!==null&&n.replace(r.pending);return}r.buffer&&((r.timer!==void 0||r.conflict)&&(r.pending=r.buffer.text()),this.cancelTimer(r),r.buffer=null,this.next(r))}}edited(t){const n=this.files.get(t);!(n!=null&&n.buffer)||!n.writable||n.file.ref||(this.cancelTimer(n),n.timer=this.d.timers.set(()=>{n.timer=void 0,this.saveNow(t)},gw))}saveNow(t){const n=this.files.get(t);if(!(n!=null&&n.buffer))return;this.cancelTimer(n);const r=n.buffer.text();r.length>Yd||(n.pending=r,this.next(n))}cancelTimer(t){t.timer!==void 0&&(this.d.timers.clear(t.timer),t.timer=void 0)}}const pT={attach:()=>{},edited:()=>{},saveNow:()=>{}},cB=e=>({timers:{set:(t,n)=>setTimeout(t,n),clear:t=>clearTimeout(t)},win:typeof window>"u"?null:window,send:e}),mg=new Map;function uB(e){const t=mg.get(e.seq);return t?(mg.delete(e.seq),t(e),!0):!1}function dB(e,t,n,r){if(e.kind==="bytes")return pT;if(e.kind==="grant")return fB(e,t,n,r);const o=e.handle;let i=null,l,c=null,u=Promise.resolve(),h=!1;const p=()=>(c??(c=(async()=>await o.queryPermission({mode:"readwrite"})==="granted"?!0:await o.requestPermission({mode:"readwrite"})==="granted")().catch(()=>!1)),c),m=()=>{l!==void 0&&r.timers.clear(l),l=void 0},k=()=>{h||(h=!0,m(),n(`read-only: the browser would not save ${t}`))},g=async S=>{if(!await p())return k();const j=await o.createWritable();await j.write(S),await j.close()},y=()=>{if(!i||h)return;m();const S=i.text();u=u.then(()=>g(S)).catch(k)},b=()=>{l!==void 0&&y()};return{attach(S){var j,E;if(S){i=S,(j=r.win)==null||j.addEventListener("pagehide",b);return}l!==void 0&&y(),i=null,(E=r.win)==null||E.removeEventListener("pagehide",b)},edited(){!i||h||(p().then(S=>{S||k()}),m(),l=r.timers.set(y,gw))},saveNow:y}}function fB(e,t,n,r){let o=null,i,l=e.version,c=!1,u=null,h=!1;const p=()=>{i!==void 0&&r.timers.clear(i),i=void 0},m=b=>{h||(h=!0,p(),u=null,n(b))},k=b=>{if(!r.send)return;const S=Zo();c=!0,mg.set(S,j=>{if(c=!1,j.ok?l=j.version:j.reason==="changed"?m(`read-only: ${t} changed on disk; open it again to edit`):m(j.message??`not saved: ${t}`),u!==null&&!h){const E=u;u=null,k(E)}}),r.send({t:"write-loose",id:e.id,content:b,base:l,seq:S})},g=()=>{if(!o||h)return;p();const b=o.text();b.length>Yd||(c?u=b:k(b))},y=()=>{i!==void 0&&g()};return{attach(b){var S,j;if(b){o=b,(S=r.win)==null||S.addEventListener("pagehide",y);return}i!==void 0&&g(),o=null,(j=r.win)==null||j.removeEventListener("pagehide",y)},edited(){!o||h||(p(),i=r.timers.set(g,gw))},saveNow:g}}function kw({kind:e,className:t,height:n,resizable:r=!0,onDragStart:o,title:i,tabs:l,actions:c,menu:u,full:h,onToggleFull:p,onClose:m,closeHint:k="esc",children:g}){const y=bn("pane"),b=p&&d.jsxs(De,{variant:"outline",tone:"quiet",mono:!0,className:"deep-link",onClick:p,"data-tip":h?"Split view: show the preview above":"Full height: hide the preview",children:[d.jsx(St,{name:h?"split":"full",className:"icon-inline"})," ",h?"split":"full"]}),S=d.jsx(Rt,{icon:"close",label:"Close",hint:k,onClick:m});return d.jsxs("div",{className:`pane ${t}`,"data-pane":e,tabIndex:-1,style:n===void 0?void 0:{height:n},children:[r&&d.jsx("div",{className:"pane-resize",onPointerDown:o}),d.jsx("div",{className:Ke("pane-head",l&&"pane-head-tabs"),...y.contextMenu(()=>(u==null?void 0:u())??[]),children:l?d.jsx(Zf,{...l,end:d.jsxs(d.Fragment,{children:[c,b,S]})}):d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"pane-title",children:i}),c,b,S]})}),g]})}function hB({src:e,path:t,full:n,onFull:r}){const o=bn("editor");return d.jsxs(d.Fragment,{children:[d.jsx("button",{type:"button",className:"editor-image",onClick:()=>r(!0),...o.contextMenu(()=>zc(e,{open:()=>r(!0)})),children:d.jsx("img",{src:e,alt:t})}),n&&d.jsx(Lk,{owner:"editor",onClose:()=>r(!1),menu:()=>zc(e),children:d.jsx("img",{src:e,alt:t})})]})}const pB={image:hB};function mB({kind:e,src:t,path:n,openSeq:r,focus:o,full:i,onFull:l}){const c=_.useRef(null);gt([r],()=>{var h;o&&((h=c.current)==null||h.focus())});const u=pB[e];return d.jsx("div",{ref:c,className:"editor-viewer",tabIndex:-1,children:d.jsx(u,{src:t,path:n,full:i,onFull:l})})}const gB="img[src], source[src], video[src], audio[src], video[poster], link[href], object[data]";function kB(e,t){if(!t)return e;const n=new DOMParser().parseFromString(e,"text/html");let r=!1;for(const o of n.querySelectorAll(gB))for(const i of["src","href","poster","data"]){const l=o.getAttribute(i),c=l===null?null:Dk(t.dir,l);c&&(o.setAttribute(i,t.urls.worktreeFile(t.worktreeId,c,t.version)),r=!0)}return r?`${n.doctype?`<!doctype html>
|
|
243
|
+
`:""}${n.documentElement.outerHTML}`:e}function wB({text:e,path:t,worktreeId:n,version:r,openSeq:o,focus:i}){const l=_.useRef(null);gt([o],()=>{var p;i&&((p=l.current)==null||p.focus())});const c=Lr(),u=x_(t),h=_.useMemo(()=>kB(e,r===void 0?null:{worktreeId:n,dir:u,version:r,urls:c}),[e,n,u,r,c]);return d.jsx("div",{ref:l,className:"editor-viewer",tabIndex:-1,children:d.jsx("iframe",{className:"editor-frame",title:t,sandbox:"",srcDoc:h})})}function yB(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 vB(e){const t=new Map,n=Array.from(e.querySelectorAll("h1, h2, h3, h4, h5, h6")),r=yB(n.map(o=>Number(o.tagName[1])));return n.map((o,i)=>{var u;const l=((u=o.textContent)==null?void 0:u.trim())??"",c=t.get(l)??0;return t.set(l,c+1),{id:`${c}
|
|
244
|
+
${l}`,level:Number(o.tagName[1]),depth:r[i],text:l,el:o}})}const bB=48,xB=16;function EB({text:e,path:t,worktreeId:n,version:r,openSeq:o,focus:i,onChat:l}){pt();const c=Lr(),u=ut(),h=x_(t),p=Qk(e,r===void 0?void 0:{base:{worktreeId:n,dir:h,version:r,urls:c}}),m=_.useRef(null),k=_.useRef(null),[g,y]=_.useState([]),[b,S]=_.useState(-1),[j,E]=_.useState(null),N=R=>{var T;if(E(null),R){const $=window.getSelection();$==null||$.removeAllRanges(),$==null||$.addRange(R)}(T=m.current)==null||T.focus()};gt([o],()=>{var R;i&&((R=m.current)==null||R.focus())}),gt([p],()=>{m.current&&y(vB(m.current))}),_.useLayoutEffect(()=>{const R=m.current;if(!R)return;let T=0;const $=()=>{if(T=0,R.scrollTop+R.clientHeight>=R.scrollHeight-1){S(g.length-1);return}const z=R.scrollTop+bB;let V=-1;for(let se=0;se<g.length;se++)g[se].el.offsetTop<=z&&(V=se);S(V)},D=()=>{T||(T=requestAnimationFrame($))};return $(),R.addEventListener("scroll",D),()=>{R.removeEventListener("scroll",D),T&&cancelAnimationFrame(T)}},[g]);const A=R=>{var $,D;const T=($=g[R])==null?void 0:$.el;(D=m.current)==null||D.scrollTo({top:Math.max(0,T?T.offsetTop-xB:0),behavior:"smooth"})},O=R=>{const T=R.target.closest("a"),$=T==null?void 0:T.getAttribute("href");if(!$||(T==null?void 0:T.target)==="_blank")return;R.preventDefault();const D=Dk(h,$);D&&tr({dispatch:u},{worktreeId:n,path:D,view:pi(D)})},P=R=>{var T;if(Pk(R)){R.preventDefault(),R.stopPropagation();const $=(k.current&&Zm(k.current))??"";E(D=>({seed:$||(D==null?void 0:D.seed)||"",seq:((D==null?void 0:D.seq)??0)+1}));return}if(R.key==="Escape"&&j){R.stopPropagation(),N(null);return}if(p_(R)&&k.current){R.preventDefault(),g_(k.current);return}if(((T=a1(R))==null?void 0:T.id)==="composer"&&k.current){const $=Zm(k.current);if(!$)return;R.preventDefault(),R.stopPropagation(),l($)}};return d.jsxs(d.Fragment,{children:[d.jsx("div",{ref:m,className:"editor-viewer editor-preview",tabIndex:-1,onClick:O,onKeyDown:P,children:d.jsx("div",{ref:k,className:"md md-preview",dangerouslySetInnerHTML:{__html:p}})}),j&&d.jsx(h_,{root:m,body:k,seed:j.seed,seq:j.seq,onClose:N}),d.jsx(SB,{heads:g,at:b,onJump:A})]})}function SB({heads:e,at:t,onJump:n}){const[r,o]=_.useState(!1),i=_.useRef(null);return e.length<2?null:d.jsxs(d.Fragment,{children:[d.jsx("div",{ref:i,className:"editor-outline","aria-hidden":!0,onPointerEnter:l=>{l.pointerType==="mouse"&&o(!0)},onClick:()=>o(l=>!l),children:e.map((l,c)=>d.jsx("span",{className:"editor-outline-tick","data-level":l.level,"data-state":vr({current:c===t})},l.id))}),r&&d.jsx($s,{className:"editor-outline-list",anchor:()=>{var l;return((l=i.current)==null?void 0:l.getBoundingClientRect())??null},placement:{side:"right",align:"center",cover:!0},trigger:i.current,onDismiss:()=>o(!1),onPointerLeave:l=>{l.pointerType==="mouse"&&o(!1)},children:e.map((l,c)=>d.jsx("button",{type:"button",className:"row editor-outline-row","data-level":l.level,"data-state":vr({current:c===t}),onClick:()=>n(c),children:d.jsx("span",{className:"editor-outline-label",style:{"--outline-depth":l.depth},children:l.text})},l.id))})]})}function _B({onReveal:e}){const{host:t}=Lr();return cS(t)?d.jsxs(De,{variant:"outline",tone:"quiet",mono:!0,className:"deep-link",onClick:e,"data-tip":"Reveal in Finder: show the file where it sits on disk",children:[d.jsx(St,{name:"folder",className:"icon-inline"})," reveal"]}):null}const NB=_.lazy(async()=>{const[e]=await Promise.all([pg(()=>import("./Editor-jjf6IGvI.js").then(t=>t.E),__vite__mapDeps([0,1,2])),pg(()=>import("./grammar-E8nWrhy3.js"),[]).then(t=>t.grammarsReady)]);return e});function Mx({what:e}){return GE(!0,3e3)?d.jsx("div",{className:"empty",children:d.jsxs("span",{className:"live-text",children:["loading ",e]})}):null}const TB=()=>{},jB={diff:"diff",file:"text",preview:"book"};function CB(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 mT({editor:e,height:t,full:n=!1,onToggleFull:r,onDragStart:o,placement:i="stack"}){const l=i==="screen",c=ut(),u=Zn(),h=pt(),p=Lr(),m=qE(),k=Df(),{worktreeId:g,path:y,ref:b,since:S}=e,j=e.loose,E=L(K=>{var B;return((B=Ao(K))==null?void 0:B.id)===g}),N=L(K=>{var ee,J;const B=(ee=pn(K,g))==null?void 0:ee.worktree;return B?B.path:(J=Ao(K))==null?void 0:J.path}),A=b!==void 0,O=_.useMemo(()=>j?dB(j.source,y,K=>c({a:"editor-refused",file:{worktreeId:g,path:y},message:K}),cB(h?K=>h.send(K):null)):(m==null?void 0:m.bind({worktreeId:g,path:y,...b?{ref:b}:{},...S?{since:S}:{}}))??pT,[m,g,y,b,S,j,c,h]),P=L(K=>Co(K,g).changedRanges[y]);_.useEffect(()=>{!P&&!A&&!E&&!j&&(h==null||h.send({t:"changed-ranges",worktreeId:g,path:y}))},[g,y,P,A,E,j,h]);const R=(P==null?void 0:P.offset)??0,T=e.disk,$=e.view??"diff",D=!!T&&(T.before===""||T.before===T.after),z=uS(y,D).filter(K=>K!==$&&!(j&&K==="diff")),V=(j==null?void 0:j.source.kind)==="grant"?j.source:null,se=A||E||j&&!V?null:RM(y),[I,ne]=_.useState(!1),we=e.line&&!e.line.fiber?e.line.n:void 0;return d.jsxs(kw,{kind:"editor",className:Ke("editor-pane",n&&"full"),height:n||l?void 0:t,resizable:!n&&!l,onDragStart:o??TB,title:A?`${y} at ${b==null?void 0:b.slice(0,7)}`:S?`${y}, last turn`:y,menu:()=>N&&!j?js({id:g,dir:N},y,{discard:!A&&!E,kept:E,ref:b,showing:e.view??void 0,noDiff:D},{sock:h,dispatch:c}):[],onClose:()=>c({a:"close-editor"}),full:n,onToggleFull:l?void 0:r,actions:d.jsxs(d.Fragment,{children:[!se&&z.map(K=>d.jsxs(De,{variant:"outline",tone:"quiet",mono:!0,className:"deep-link",onClick:()=>c({a:"editor-view",v:K}),"data-tip":CB(K,$),children:[d.jsx(St,{name:jB[K],className:"icon-inline"})," ",K]},K)),se==="image"&&d.jsxs(De,{variant:"outline",tone:"quiet",mono:!0,className:"deep-link",onClick:()=>ne(!0),"data-tip":"Full size: see the picture over the window",children:[d.jsx(St,{name:"zen",className:"icon-inline"})," full size"]}),!E&&!j&&d.jsx(_B,{onReveal:()=>h==null?void 0:h.send({t:"reveal",worktreeId:g,path:y})})]}),children:[T&&d.jsx(AB,{editor:e,disk:T,files:m}),d.jsx("div",{className:"editor-body",children:T?se?d.jsx(mB,{kind:se,src:V?p.loose(V.id,V.version):p.worktreeFile(g,y,T.version),path:y,openSeq:e.seq,focus:e.focus,full:I,onFull:ne}):T.binary?d.jsx("div",{className:"empty",children:"not a text file: open it in another editor"}):T.tooLarge?d.jsx("div",{className:"empty",children:"too large to open here: open it in another editor"}):$==="preview"&&Of(y)==="html"?d.jsx(wB,{text:T.after,path:y,worktreeId:g,version:A||E||j?void 0:T.version,openSeq:e.seq,focus:e.focus}):$==="preview"?d.jsx(EB,{text:T.after,path:y,worktreeId:g,version:A||E||j?void 0:T.version,openSeq:e.seq,focus:e.focus,onChat:K=>tb(u,{worktreeId:g,text:K,name:y})}):d.jsx(jk,{pane:!0,children:d.jsx(_.Suspense,{fallback:d.jsx(Mx,{what:$}),children:d.jsx(NB,{file:{worktreeId:g,path:y,...b?{ref:b}:{},...S?{since:S}:{}},disk:T,blame:e.blame,view:$,openSeq:e.seq,line:we,focus:e.focus,readOnly:A||!T.writable||l,numbers:!l,theme:k,sync:O,onCopy:j?void 0:(K,B,ee)=>GL(ee,{worktreeId:g,path:K,...B,...b?{ref:b}:{}}),onChat:(K,B)=>tb(u,B&&(j?{worktreeId:g,text:B.text,name:K}:{worktreeId:g,text:B.text,source:{path:K,startLine:B.startLine,endLine:B.endLine,...b?{ref:b}:{}}})),onNew:()=>u.dispatch({a:"open-draft"}),onLineHover:A||j?void 0:K=>{K==null?cn.post(g,{type:"highlight-clear"}):cn.post(g,{type:"highlight-file",path:y,ranges:[[K+R,K+R]]})}},`${g}
|
|
245
|
+
${j?"loose":b??S??""}
|
|
246
|
+
${y}`)})}):d.jsx(Mx,{what:y},y)})]})}function AB({editor:e,disk:t,files:n}){const{worktreeId:r,path:o,ref:i,since:l,conflict:c}=e,u={worktreeId:r,path:o,...i?{ref:i}:{},...l?{since:l}:{}};if(c){const h=c.version===null;return d.jsxs("div",{className:"editor-note",children:[d.jsx("span",{className:"editor-note-text",children:h?"deleted on disk; your edits are not saved":"changed on disk; your edits are not saved"}),d.jsx(De,{variant:"outline",onClick:()=>n==null?void 0:n.reload(u),"data-tip":h?"Close the file; your edits go with it":"Take the file as it is on disk; undo brings your edits back",children:h?"close":"reload"}),d.jsx(De,{variant:"outline",tone:"danger",onClick:()=>n==null?void 0:n.keepMine(u),"data-tip":h?"Save your edits as the file again":"Save your edits over the file on disk",children:"keep mine"})]})}return e.refused?d.jsx("div",{className:"editor-note",children:d.jsx("span",{className:"hint",children:e.refused})}):e.loose&&!t.writable&&!t.tooLarge&&!t.binary?d.jsx("div",{className:"editor-note",children:d.jsxs("span",{className:"hint",children:["read-only: ",o," is not in a project; drop it on a folder in files to add it"]})}):i===void 0&&!t.writable&&!t.binary&&!t.tooLarge?d.jsx("div",{className:"editor-note",children:d.jsx("span",{className:"hint",children:"read-only: Toyon does not run this worktree"})}):null}function gT(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 IB=(e,t)=>{const n=_m(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"}},wf="https://github.com/toyon-dev/toyon",RB=e=>`${wf}/releases/tag/v${e}`,$B=`${wf}/releases/latest`,OB=4e3;function MB(e,t,n,r){if(r==="asking")return{value:`${e} checking`,text:`Asking ${_m(n)} for the newest version`,act:"check",busy:!0};const o=_m(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(Wg(r.latest,e)){const l=t==="none"?"This copy runs from a checkout, so pull to get it":t==="npx"?`This copy runs with npx, so run npx toyon@${r.latest} to use it`:"It installs once no chat is replying";return{...i,value:`${r.latest} out`,text:`Toyon ${r.latest} is out. ${l}`}}return{...i,value:`${e} up to date`,text:`Toyon ${e} is the newest version ${o} lists. Press to ask again`,settles:!0}}function PB(e,t,n,r,o,i=!1,l=null,c=null){if(n){if(n.restarting){const h=n.installed??n.running,p=n.restarting.length>0?LS(n.restarting):"Toyon is restarting; this page reloads when it is back";return{value:`${h} restarting`,text:p,act:"restart",busy:!0}}if(n.installing){const h=n.latest??n.installed??n.running;return{value:`${h} installing`,text:`Installing Toyon ${h}`,act:"update",busy:!0}}if(n.failed){const h=n.failed.line.replace(/\.$/,"");return{value:`${n.running} update failed`,text:`Installing Toyon ${n.failed.version} stopped: ${h}. Press to try again, or run ${n.failed.command}`,act:"update",busy:!1}}if(n.installed)return{value:`${n.installed} ready`,text:`Toyon ${n.installed} is installed and ${n.running} is still running. It restarts onto the new one when nothing is busy; press to restart now`,act:"restart",busy:!1};if(n.latest)return{value:`${n.latest} out`,text:n.method==="npx"?`Toyon ${n.latest} is out. This copy runs with npx, so run npx toyon@${n.latest} to use it`:`Toyon ${n.latest} is out and installs when nothing is busy; press to install now`,act:"update",busy:!1}}const u=gT(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?MB(e,t,l,c):{value:e,text:`Toyon ${e}, ${IB(t,l)}`,act:"check",busy:!1}}function LB(e,t,n){const r=o=>()=>window.open(o,"_blank");return Ln([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(RB(e))},{id:"latest-release",label:"latest release",onClick:r($B)},{id:"repo",label:"Toyon on GitHub",onClick:r(wf)},{id:"report",label:"report a problem",onClick:r(`${wf}/issues/new`)}],[{id:"copy-version",label:"copy version",onClick:()=>Jt(e)}]])}const DB=EC.map(e=>({title:e,rows:NC(e).map(t=>[Lt(t),vc[t].label])}));function zB(){const e=ut(),t=pt(),n=bn("keys"),r=L(m=>m.themePrefs),o=L(m=>m.themes),i=L(m=>m.chatSide),l=L(m=>m.keepAwake),c=hk(),u=L(m=>m.agents),h=pl(),p=m=>{e({a:"palette-return",v:{mode:"keys",q:""}}),e(m)};return d.jsxs(Uc,{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(()=>Jf(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(UB,{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:()=>p({a:"open",overlay:{kind:"appearance"}}),children:uf[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:()=>p({a:"open",overlay:{kind:"theme",slot:"theme"}}),children:$f(r,o,c).name})]}),d.jsxs("div",{className:"keys-setting",children:[d.jsx("span",{className:"keys-d",children:"chat side"}),d.jsx(De,{variant:"field",mono:!0,onClick:()=>e({a:"toggle-chat-side"}),children:i})]}),d.jsx("div",{className:"section-title keys-h",children:"Toyon"}),l!==null&&d.jsxs("div",{className:"keys-setting",children:[d.jsx("span",{className:"keys-d",children:"keep awake"}),d.jsx(De,{variant:"field",mono:!0,onClick:()=>p({a:"open",overlay:{kind:"keep-awake"}}),children:df[l]})]}),d.jsx(FB,{}),d.jsx(BB,{})]})]}),d.jsx("div",{className:"keys-card",children:DB.map(m=>d.jsxs("div",{children:[d.jsx("div",{className:"section-title keys-h",children:m.title}),m.rows.map(([k,g])=>d.jsxs("div",{className:"keys-row",children:[d.jsx(qo,{k}),d.jsx("span",{className:"keys-d",children:g})]},k))]},m.title))})]})}function FB(){const e=pt(),t=ut(),n=bn("keys"),r=L(N=>N.version),o=L(N=>N.install),i=L(N=>N.registry),l=L(N=>N.update),c=L(N=>N.self),u=L(N=>N.rebuilt),h=L(N=>N.repos),p=L(N=>N.managed.updates),m=L(N=>N.updateCheck),k=L(N=>N.frame),g=L(N=>N.newProject!==null),y=PB(r,o,l,c,h,u,i,m),b=!p&&(y.act==="update"||y.act==="check"),S=y.settles&&m&&m!=="asking"?m:null;_.useEffect(()=>{if(!S)return;const N=()=>t({a:"update-check-settle",check:S}),A=setTimeout(N,OB);return()=>{clearTimeout(A),N()}},[S,t]);const j=()=>{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"}))},E=()=>LB(r,y.act==="check"&&!y.busy?{run:j,...b?{off:"managed by your organization"}:{}}:null,k==="phone"||g?void 0:()=>t({a:"open-release-notes"}));return d.jsxs("div",{className:"keys-setting",...n.contextMenu(E),children:[d.jsx("span",{className:"keys-d",children:"version"}),d.jsx(De,{variant:"field",mono:!0,busy:y.busy,disabled:b,onClick:j,...Ut(b?"updates are managed by your organization":y.text,void 0,{detail:y.detail}),children:y.value})]})}function BB(){const e=L(n=>n.managed);if(e.source===null)return null;const t=e.problem?"the policy file on this machine is invalid, so everything it governs is off; toyon doctor says why":`managed by your organization: ${w2(e).join(", ")||"nothing turned off"}`;return d.jsx("div",{className:"hint",children:t})}function kT(e){return e.available?e.auth?e.auth.kind==="none"?"not logged in":e.auth.label:"ready":e.installing?"installing":"not installed"}function wT(e){var n,r;return e.available?e.auth?[e.auth.detail,(n=e.auth.account)==null?void 0:n.email,(r=e.auth.account)==null?void 0:r.organization].filter(Boolean).join(" · ")||e.auth.label:"installed; it names the account it runs on the first time it runs":eh(e)}function UB({agent:e}){const t=ut(),n=pt(),r=bn("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":wT(e),...r.contextMenu(()=>uw(e,{sock:n})),onClick:()=>{t({a:"palette-return",v:{mode:"keys",q:""}}),t({a:"open",overlay:{kind:"agent-page",agent:e.id}})},children:kT(e)})]})}function HB({agentId:e}){const t=ut(),n=pt(),r=pl(),o=L(k=>k.home),i=L(k=>k.agents.find(g=>g.id===e)??null),l=L(k=>k.agentConfigs[e]??null),c=bn("keys");if(_.useEffect(()=>{n==null||n.send({t:"agent-config",agent:e,...r?{repoId:r.id}:{}})},[n,e,r]),!i)return null;const u=uw(i,{sock:n}),h=()=>t({a:"close",back:!0}),p=k=>o&&k.startsWith(`${o}/`)?`~${k.slice(o.length)}`:k,m=k=>n==null?void 0:n.send({t:"reveal-agent-file",agent:e,file:k.id,...r?{repoId:r.id}:{}});return d.jsx(Uc,{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":wT(i),disabled:u.length===0,...c.dropdown(()=>u,"right"),children:kT(i)})]}),d.jsxs("div",{className:"keys-setting",children:[d.jsx("span",{className:"keys-d",children:"commit messages"}),d.jsx("span",{className:"keys-d",children:i.quick?"its quick model writes one after each turn":"none: it has no quick model, so you write them in the changes panel; quickModel in agents.json names one"})]}),d.jsx("div",{className:"section-title keys-h",children:"MCP servers it will load"}),l===null?d.jsx("div",{className:"keys-setting",children:d.jsx("span",{className:"keys-d",children:"reading…"})}):l.servers.length===0?d.jsxs("div",{className:"keys-setting",children:[d.jsx("span",{className:"keys-d",children:"none configured"}),d.jsx("span",{className:"keys-d",children:"add one with the agent's own CLI, or a .mcp.json in the repo"})]}):l.servers.map(k=>d.jsx(WB,{s:k},`${k.scope}:${k.name}`)),l&&l.files.length>0&&d.jsxs(d.Fragment,{children:[d.jsx("div",{className:"section-title keys-h",children:"the files it reads"}),l.files.map(k=>d.jsxs("div",{className:"keys-setting",children:[d.jsx("span",{className:"keys-d",children:k.label}),k.exists?d.jsx(De,{variant:"field",mono:!0,"data-tip":`reveal ${p(k.path)} in Finder`,onClick:()=>m(k),children:p(k.path)}):d.jsxs("span",{className:"keys-d",children:["not present: ",p(k.path)]})]},k.id))]})]})})}function WB({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 KB(){const e=ut(),t=pt(),n=L(o=>o.agents),r=L(o=>o.defaultAgent);return d.jsx(Pr,{items:n,filter:(o,i)=>o.filter(l=>is(i,l.name,l.id)),rowClass:o=>o.available?"picker-row":"picker-row dim",keyOf:o=>o.id,initialIndex:o=>Math.max(0,o.findIndex(i=>i.id===r)),onPick:o=>{o.available&&(t==null||t.send({t:"set-default-agent",agent:o.id}),e({a:"close"}))},onBack:()=>e({a:"close",back:!0}),rowMenu:o=>uw(o,{sock:t}),placeholder:"default agent for new worktrees",keys:{pick:"sets",back:"closes"},row:o=>d.jsx(On,{label:o.name,current:o.id===r,hint:o.available?o.sandboxed?void 0:"unsandboxed":eh(o)})})}const ZB=["dark","light","system","daylight"],qB=new Intl.DateTimeFormat(void 0,{hour:"numeric",minute:"2-digit"});function GB(){const e=ut(),t=pt(),n=L(u=>u.themePrefs),r=L(u=>u.themes),o=hk(),i=L(u=>u.daylight),l=u=>{var h;return((h=r.find(p=>p.id===n[Hg({...n,mode:u},o)]))==null?void 0:h.name)??""},c=u=>{if(u==="system")return`${o.system?"dark":"light"} now · ${l(u)}`;if(u!=="daylight")return l(u);const h=i&&i.until>Date.now()?` · ${o.daylight?"light":"dark"} at ${qB.format(i.until)}`:"";return`${o.daylight?"dark":"light"} now${h} · ${l(u)}`};return d.jsx(Pr,{items:ZB,filter:(u,h)=>u.filter(p=>is(h,uf[p])),rowClass:()=>"picker-row",keyOf:u=>u,initialIndex:u=>u.indexOf(n.mode),onActive:u=>e({a:"preview-theme",theme:u?$f({...n,mode:u},r,o):null}),onPick:u=>{t==null||t.send({t:"set-theme",prefs:{...n,mode:u}}),e({a:"close"})},onBack:()=>e({a:"close",back:!0}),placeholder:"light/dark mode",keys:{nav:"preview",pick:"keeps",back:"reverts"},row:u=>d.jsx(On,{label:uf[u],current:u===n.mode,hint:c(u)})})}const VB=2,gg=e=>tE(e).join(" ").length<VB,YB=e=>({kind:"chat",id:e.id,name:e.name,hint:e.branch??"",fields:[e.name,e.branch??""]}),XB=e=>({kind:"chat",id:e.id,name:e.title,hint:a_(e),fields:[e.title,e.branch],prompt:e.prompt,archived:e});function QB(e,t,n){const r=tE(t),o=n==="all"&&!gg(t);return e.filter(i=>{if(i.kind==="hit")return o;const l=n==="names"&&i.prompt?[...i.fields,i.prompt]:i.fields;return r.every(c=>l.some(u=>u.toLowerCase().includes(c)))})}const JB=e=>e.flatMap(([t,n])=>Array.from({length:n},(r,o)=>t+o));function eU({repoId:e,scope:t}){const n=ut(),r=pt(),o=L(N=>N.clientId),i=L(N=>N.frame),l=L(N=>N.chats[e]),c=kk(),u=L(N=>N.archived[e]),[h,p]=_.useState(t),m=_.useCallback(()=>p(N=>N==="all"?"names":"all"),[]);_.useEffect(()=>{r==null||r.send({t:"list-archived",repoId:e})},[r,e]);const k=_.useMemo(()=>[...c.filter(N=>!yr(N.worktree)).map(YB),...(u??[]).map(XB)],[c,u]),g=_.useMemo(()=>new Map(k.map(N=>[N.id,N])),[k]),y=_.useMemo(()=>[...k,...((l==null?void 0:l.hits)??[]).map(N=>({kind:"hit",hit:N}))],[k,l]),b=_.useCallback((N,A)=>QB(N,A,h),[h]),S=_.useCallback(N=>{h==="all"&&!gg(N)&&(r==null||r.send({t:"search-chats",repoId:e,query:N.trim()}))},[r,e,h]),j=N=>!l||l.query!==N.trim(),E=N=>h==="all"&&!gg(N);return d.jsx(Pr,{items:y,filter:b,onQuery:S,onTab:m,trailing:d.jsx(De,{tone:"chrome",on:h==="names","aria-pressed":h==="names",onClick:m,children:"names only"}),keyOf:N=>N.kind==="hit"?`h:${N.hit.worktreeId}:${N.hit.seq}`:`w:${N.id}`,rowClass:N=>N.kind==="hit"?"chats-hit":Ke("picker-row",N.archived&&!N.archived.restorable&&"dim"),rowTitle:N=>{var A;return N.kind==="hit"?N.hit.text:((A=N.archived)==null?void 0:A.prompt)??N.name},groupOf:N=>N.kind==="hit"?`h:${N.hit.worktreeId}`:N.archived?"archived":"open",groupHead:(N,A)=>{if(!N.startsWith("h:"))return`${N} · ${A}`;const O=N.slice(2),P=g.get(O),R=l==null?void 0:l.asks[O];return d.jsxs(d.Fragment,{children:[d.jsxs("span",{children:[(P==null?void 0:P.name)??"a worktree",(P==null?void 0:P.archived)&&d.jsxs(d.Fragment,{children:[" ",d.jsx("span",{className:"row-dim",children:"archived"})]}),` · ${A}`]}),R&&d.jsx("span",{className:"picker-group-line",children:Vf(R)})]})},headAlone:!0,onPick:N=>{const A=N.kind==="hit"?N.hit.worktreeId:N.id,O=N.kind==="hit"?N.hit.archived:!!N.archived;n(O?{a:"open-archived",id:A}:{a:"activate",id:A}),N.kind==="hit"&&n({a:"reveal",id:A,seq:N.hit.seq}),n({a:"close"})},onBack:()=>n({a:"close"}),rowMenu:N=>N.kind==="chat"&&N.archived?zd(N.archived,{clientId:o,frame:i},{sock:r,dispatch:n}):[],placeholder:h==="names"?"find a chat by name…":"search in chats…",keys:N=>({nav:"moves",tab:h==="names"?"searches messages too":"searches names only",pick:N?N.kind==="hit"?"opens the chat there":"opens its chat":void 0,back:"closes"}),empty:N=>N.trim()?E(N)?j(N)?"searching…":"no chat says that":"no chat is named that":u?"no chats yet":"looking…",footer:(N,A)=>{const O=A.filter(P=>P.kind==="hit").length;return l!=null&&l.truncated&&!j(N)&&O>0?d.jsxs("div",{className:"empty",children:["showing the first ",O,"; narrow the search"]}):null},row:N=>N.kind==="chat"?d.jsx(On,{label:N.name,hint:N.hint}):d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"chats-text",children:Hc(N.hit.text,JB(N.hit.match),0)}),d.jsxs("span",{className:"chats-said row-dim",children:[N.hit.role==="user"?"you":"the agent",N.hit.ts>0?` · ${oo(N.hit.ts)}`:""]})]})})}const gl=function(e,t){let o=e;const i=wc[t];let l=null,c=0,u=null;const h=[],p={},m=function(R,T){c=o*4+17,l=(function($){const D=new Array($);for(let z=0;z<$;z+=1){D[z]=new Array($);for(let V=0;V<$;V+=1)D[z][V]=null}return D})(c),k(0,0),k(c-7,0),k(0,c-7),b(),y(),j(R,T),o>=7&&S(R),u==null&&(u=A(o,i,h)),E(u,T)},k=function(R,T){for(let $=-1;$<=7;$+=1)if(!(R+$<=-1||c<=R+$))for(let D=-1;D<=7;D+=1)T+D<=-1||c<=T+D||(0<=$&&$<=6&&(D==0||D==6)||0<=D&&D<=6&&($==0||$==6)||2<=$&&$<=4&&2<=D&&D<=4?l[R+$][T+D]=!0:l[R+$][T+D]=!1)},g=function(){let R=0,T=0;for(let $=0;$<8;$+=1){m(!0,$);const D=ri.getLostPoint(p);($==0||R>D)&&(R=D,T=$)}return T},y=function(){for(let R=8;R<c-8;R+=1)l[R][6]==null&&(l[R][6]=R%2==0);for(let R=8;R<c-8;R+=1)l[6][R]==null&&(l[6][R]=R%2==0)},b=function(){const R=ri.getPatternPosition(o);for(let T=0;T<R.length;T+=1)for(let $=0;$<R.length;$+=1){const D=R[T],z=R[$];if(l[D][z]==null)for(let V=-2;V<=2;V+=1)for(let se=-2;se<=2;se+=1)V==-2||V==2||se==-2||se==2||V==0&&se==0?l[D+V][z+se]=!0:l[D+V][z+se]=!1}},S=function(R){const T=ri.getBCHTypeNumber(o);for(let $=0;$<18;$+=1){const D=!R&&(T>>$&1)==1;l[Math.floor($/3)][$%3+c-8-3]=D}for(let $=0;$<18;$+=1){const D=!R&&(T>>$&1)==1;l[$%3+c-8-3][Math.floor($/3)]=D}},j=function(R,T){const $=i<<3|T,D=ri.getBCHTypeInfo($);for(let z=0;z<15;z+=1){const V=!R&&(D>>z&1)==1;z<6?l[z][8]=V:z<8?l[z+1][8]=V:l[c-15+z][8]=V}for(let z=0;z<15;z+=1){const V=!R&&(D>>z&1)==1;z<8?l[8][c-z-1]=V:z<9?l[8][15-z-1+1]=V:l[8][15-z-1]=V}l[c-8][8]=!R},E=function(R,T){let $=-1,D=c-1,z=7,V=0;const se=ri.getMaskFunction(T);for(let I=c-1;I>0;I-=2)for(I==6&&(I-=1);;){for(let ne=0;ne<2;ne+=1)if(l[D][I-ne]==null){let we=!1;V<R.length&&(we=(R[V]>>>z&1)==1),se(D,I-ne)&&(we=!we),l[D][I-ne]=we,z-=1,z==-1&&(V+=1,z=7)}if(D+=$,D<0||c<=D){D-=$,$=-$;break}}},N=function(R,T){let $=0,D=0,z=0;const V=new Array(T.length),se=new Array(T.length);for(let K=0;K<T.length;K+=1){const B=T[K].dataCount,ee=T[K].totalCount-B;D=Math.max(D,B),z=Math.max(z,ee),V[K]=new Array(B);for(let Te=0;Te<V[K].length;Te+=1)V[K][Te]=255&R.getBuffer()[Te+$];$+=B;const J=ri.getErrorCorrectPolynomial(ee),ie=Wc(V[K],J.getLength()-1).mod(J);se[K]=new Array(J.getLength()-1);for(let Te=0;Te<se[K].length;Te+=1){const Ce=Te+ie.getLength()-se[K].length;se[K][Te]=Ce>=0?ie.getAt(Ce):0}}let I=0;for(let K=0;K<T.length;K+=1)I+=T[K].totalCount;const ne=new Array(I);let we=0;for(let K=0;K<D;K+=1)for(let B=0;B<T.length;B+=1)K<V[B].length&&(ne[we]=V[B][K],we+=1);for(let K=0;K<z;K+=1)for(let B=0;B<T.length;B+=1)K<se[B].length&&(ne[we]=se[B][K],we+=1);return ne},A=function(R,T,$){const D=Px.getRSBlocks(R,T),z=Lx();for(let se=0;se<$.length;se+=1){const I=$[se];z.put(I.getMode(),4),z.put(I.getLength(),ri.getLengthInBits(I.getMode(),R)),I.write(z)}let V=0;for(let se=0;se<D.length;se+=1)V+=D[se].dataCount;if(z.getLengthInBits()>V*8)throw"code length overflow. ("+z.getLengthInBits()+">"+V*8+")";for(z.getLengthInBits()+4<=V*8&&z.put(0,4);z.getLengthInBits()%8!=0;)z.putBit(!1);for(;!(z.getLengthInBits()>=V*8||(z.put(236,8),z.getLengthInBits()>=V*8));)z.put(17,8);return N(z,D)};p.addData=function(R,T){T=T||"Byte";let $=null;switch(T){case"Numeric":$=tU(R);break;case"Alphanumeric":$=nU(R);break;case"Byte":$=rU(R);break;case"Kanji":$=oU(R);break;default:throw"mode:"+T}h.push($),u=null},p.isDark=function(R,T){if(R<0||c<=R||T<0||c<=T)throw R+","+T;return l[R][T]},p.getModuleCount=function(){return c},p.make=function(){if(o<1){let R=1;for(;R<40;R++){const T=Px.getRSBlocks(R,i),$=Lx();for(let z=0;z<h.length;z++){const V=h[z];$.put(V.getMode(),4),$.put(V.getLength(),ri.getLengthInBits(V.getMode(),R)),V.write($)}let D=0;for(let z=0;z<T.length;z++)D+=T[z].dataCount;if($.getLengthInBits()<=D*8)break}o=R}m(!1,g())},p.createTableTag=function(R,T){R=R||2,T=typeof T>"u"?R*4:T;let $="";$+='<table style="',$+=" border-width: 0px; border-style: none;",$+=" border-collapse: collapse;",$+=" padding: 0px; margin: "+T+"px;",$+='">',$+="<tbody>";for(let D=0;D<p.getModuleCount();D+=1){$+="<tr>";for(let z=0;z<p.getModuleCount();z+=1)$+='<td style="',$+=" border-width: 0px; border-style: none;",$+=" border-collapse: collapse;",$+=" padding: 0px; margin: 0px;",$+=" width: "+R+"px;",$+=" height: "+R+"px;",$+=" background-color: ",$+=p.isDark(D,z)?"#000000":"#ffffff",$+=";",$+='"/>';$+="</tr>"}return $+="</tbody>",$+="</table>",$},p.createSvgTag=function(R,T,$,D){let z={};typeof arguments[0]=="object"&&(z=arguments[0],R=z.cellSize,T=z.margin,$=z.alt,D=z.title),R=R||2,T=typeof T>"u"?R*4:T,$=typeof $=="string"?{text:$}:$||{},$.text=$.text||null,$.id=$.text?$.id||"qrcode-description":null,D=typeof D=="string"?{text:D}:D||{},D.text=D.text||null,D.id=D.text?D.id||"qrcode-title":null;const V=p.getModuleCount()*R+T*2;let se,I,ne,we,K="",B;for(B="l"+R+",0 0,"+R+" -"+R+",0 0,-"+R+"z ",K+='<svg version="1.1" xmlns="http://www.w3.org/2000/svg"',K+=z.scalable?"":' width="'+V+'px" height="'+V+'px"',K+=' viewBox="0 0 '+V+" "+V+'" ',K+=' preserveAspectRatio="xMinYMin meet"',K+=D.text||$.text?' role="img" aria-labelledby="'+O([D.id,$.id].join(" ").trim())+'"':"",K+=">",K+=D.text?'<title id="'+O(D.id)+'">'+O(D.text)+"</title>":"",K+=$.text?'<description id="'+O($.id)+'">'+O($.text)+"</description>":"",K+='<rect width="100%" height="100%" fill="white" cx="0" cy="0"/>',K+='<path d="',ne=0;ne<p.getModuleCount();ne+=1)for(we=ne*R+T,se=0;se<p.getModuleCount();se+=1)p.isDark(ne,se)&&(I=se*R+T,K+="M"+I+","+we+B);return K+='" stroke="transparent" fill="black"/>',K+="</svg>",K},p.createDataURL=function(R,T){R=R||2,T=typeof T>"u"?R*4:T;const $=p.getModuleCount()*R+T*2,D=T,z=$-T;return lU($,$,function(V,se){if(D<=V&&V<z&&D<=se&&se<z){const I=Math.floor((V-D)/R),ne=Math.floor((se-D)/R);return p.isDark(ne,I)?0:1}else return 1})},p.createImgTag=function(R,T,$){R=R||2,T=typeof T>"u"?R*4:T;const D=p.getModuleCount()*R+T*2;let z="";return z+="<img",z+=' src="',z+=p.createDataURL(R,T),z+='"',z+=' width="',z+=D,z+='"',z+=' height="',z+=D,z+='"',$&&(z+=' alt="',z+=O($),z+='"'),z+="/>",z};const O=function(R){let T="";for(let $=0;$<R.length;$+=1){const D=R.charAt($);switch(D){case"<":T+="<";break;case">":T+=">";break;case"&":T+="&";break;case'"':T+=""";break;default:T+=D;break}}return T},P=function(R){R=typeof R>"u"?2:R;const $=p.getModuleCount()*1+R*2,D=R,z=$-R;let V,se,I,ne,we;const K={"██":"█","█ ":"▀"," █":"▄"," ":" "},B={"██":"▀","█ ":"▀"," █":" "," ":" "};let ee="";for(V=0;V<$;V+=2){for(I=Math.floor((V-D)/1),ne=Math.floor((V+1-D)/1),se=0;se<$;se+=1)we="█",D<=se&&se<z&&D<=V&&V<z&&p.isDark(I,Math.floor((se-D)/1))&&(we=" "),D<=se&&se<z&&D<=V+1&&V+1<z&&p.isDark(ne,Math.floor((se-D)/1))?we+=" ":we+="█",ee+=R<1&&V+1>=z?B[we]:K[we];ee+=`
|
|
247
|
+
`}return $%2&&R>0?ee.substring(0,ee.length-$-1)+Array($+1).join("▀"):ee.substring(0,ee.length-1)};return p.createASCII=function(R,T){if(R=R||1,R<2)return P(T);R-=1,T=typeof T>"u"?R*2:T;const $=p.getModuleCount()*R+T*2,D=T,z=$-T;let V,se,I,ne;const we=Array(R+1).join("██"),K=Array(R+1).join(" ");let B="",ee="";for(V=0;V<$;V+=1){for(I=Math.floor((V-D)/R),ee="",se=0;se<$;se+=1)ne=1,D<=se&&se<z&&D<=V&&V<z&&p.isDark(I,Math.floor((se-D)/R))&&(ne=0),ee+=ne?we:K;for(I=0;I<R;I+=1)B+=ee+`
|
|
248
|
+
`}return B.substring(0,B.length-1)},p.renderTo2dContext=function(R,T){T=T||2;const $=p.getModuleCount();for(let D=0;D<$;D++)for(let z=0;z<$;z++)R.fillStyle=p.isDark(D,z)?"black":"white",R.fillRect(z*T,D*T,T,T)},p};gl.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};gl.createStringToBytes=function(e,t){const n=(function(){const o=iU(e),i=function(){const u=o.read();if(u==-1)throw"eof";return u};let l=0;const c={};for(;;){const u=o.read();if(u==-1)break;const h=i(),p=i(),m=i(),k=String.fromCharCode(u<<8|h),g=p<<8|m;c[k]=g,l+=1}if(l!=t)throw l+" != "+t;return c})(),r=63;return function(o){const i=[];for(let l=0;l<o.length;l+=1){const c=o.charCodeAt(l);if(c<128)i.push(c);else{const u=n[o.charAt(l)];typeof u=="number"?(u&255)==u?i.push(u):(i.push(u>>>8),i.push(u&255)):i.push(r)}}return i}};const Or={MODE_NUMBER:1,MODE_ALPHA_NUM:2,MODE_8BIT_BYTE:4,MODE_KANJI:8},wc={L:1,M:0,Q:3,H:2},ni={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7},ri=(function(){const e=[[],[6,18],[6,22],[6,26],[6,30],[6,34],[6,22,38],[6,24,42],[6,26,46],[6,28,50],[6,30,54],[6,32,58],[6,34,62],[6,26,46,66],[6,26,48,70],[6,26,50,74],[6,30,54,78],[6,30,56,82],[6,30,58,86],[6,34,62,90],[6,28,50,72,94],[6,26,50,74,98],[6,30,54,78,102],[6,28,54,80,106],[6,32,58,84,110],[6,30,58,86,114],[6,34,62,90,118],[6,26,50,74,98,122],[6,30,54,78,102,126],[6,26,52,78,104,130],[6,30,56,82,108,134],[6,34,60,86,112,138],[6,30,58,86,114,142],[6,34,62,90,118,146],[6,30,54,78,102,126,150],[6,24,50,76,102,128,154],[6,28,54,80,106,132,158],[6,32,58,84,110,136,162],[6,26,54,82,110,138,166],[6,30,58,86,114,142,170]],t=1335,n=7973,r=21522,o={},i=function(l){let c=0;for(;l!=0;)c+=1,l>>>=1;return c};return o.getBCHTypeInfo=function(l){let c=l<<10;for(;i(c)-i(t)>=0;)c^=t<<i(c)-i(t);return(l<<10|c)^r},o.getBCHTypeNumber=function(l){let c=l<<12;for(;i(c)-i(n)>=0;)c^=n<<i(c)-i(n);return l<<12|c},o.getPatternPosition=function(l){return e[l-1]},o.getMaskFunction=function(l){switch(l){case ni.PATTERN000:return function(c,u){return(c+u)%2==0};case ni.PATTERN001:return function(c,u){return c%2==0};case ni.PATTERN010:return function(c,u){return u%3==0};case ni.PATTERN011:return function(c,u){return(c+u)%3==0};case ni.PATTERN100:return function(c,u){return(Math.floor(c/2)+Math.floor(u/3))%2==0};case ni.PATTERN101:return function(c,u){return c*u%2+c*u%3==0};case ni.PATTERN110:return function(c,u){return(c*u%2+c*u%3)%2==0};case ni.PATTERN111:return function(c,u){return(c*u%3+(c+u)%2)%2==0};default:throw"bad maskPattern:"+l}},o.getErrorCorrectPolynomial=function(l){let c=Wc([1],0);for(let u=0;u<l;u+=1)c=c.multiply(Wc([1,si.gexp(u)],0));return c},o.getLengthInBits=function(l,c){if(1<=c&&c<10)switch(l){case Or.MODE_NUMBER:return 10;case Or.MODE_ALPHA_NUM:return 9;case Or.MODE_8BIT_BYTE:return 8;case Or.MODE_KANJI:return 8;default:throw"mode:"+l}else if(c<27)switch(l){case Or.MODE_NUMBER:return 12;case Or.MODE_ALPHA_NUM:return 11;case Or.MODE_8BIT_BYTE:return 16;case Or.MODE_KANJI:return 10;default:throw"mode:"+l}else if(c<41)switch(l){case Or.MODE_NUMBER:return 14;case Or.MODE_ALPHA_NUM:return 13;case Or.MODE_8BIT_BYTE:return 16;case Or.MODE_KANJI:return 12;default:throw"mode:"+l}else throw"type:"+c},o.getLostPoint=function(l){const c=l.getModuleCount();let u=0;for(let m=0;m<c;m+=1)for(let k=0;k<c;k+=1){let g=0;const y=l.isDark(m,k);for(let b=-1;b<=1;b+=1)if(!(m+b<0||c<=m+b))for(let S=-1;S<=1;S+=1)k+S<0||c<=k+S||b==0&&S==0||y==l.isDark(m+b,k+S)&&(g+=1);g>5&&(u+=3+g-5)}for(let m=0;m<c-1;m+=1)for(let k=0;k<c-1;k+=1){let g=0;l.isDark(m,k)&&(g+=1),l.isDark(m+1,k)&&(g+=1),l.isDark(m,k+1)&&(g+=1),l.isDark(m+1,k+1)&&(g+=1),(g==0||g==4)&&(u+=3)}for(let m=0;m<c;m+=1)for(let k=0;k<c-6;k+=1)l.isDark(m,k)&&!l.isDark(m,k+1)&&l.isDark(m,k+2)&&l.isDark(m,k+3)&&l.isDark(m,k+4)&&!l.isDark(m,k+5)&&l.isDark(m,k+6)&&(u+=40);for(let m=0;m<c;m+=1)for(let k=0;k<c-6;k+=1)l.isDark(k,m)&&!l.isDark(k+1,m)&&l.isDark(k+2,m)&&l.isDark(k+3,m)&&l.isDark(k+4,m)&&!l.isDark(k+5,m)&&l.isDark(k+6,m)&&(u+=40);let h=0;for(let m=0;m<c;m+=1)for(let k=0;k<c;k+=1)l.isDark(k,m)&&(h+=1);const p=Math.abs(100*h/c/c-50)/5;return u+=p*10,u},o})(),si=(function(){const e=new Array(256),t=new Array(256);for(let r=0;r<8;r+=1)e[r]=1<<r;for(let r=8;r<256;r+=1)e[r]=e[r-4]^e[r-5]^e[r-6]^e[r-8];for(let r=0;r<255;r+=1)t[e[r]]=r;const n={};return n.glog=function(r){if(r<1)throw"glog("+r+")";return t[r]},n.gexp=function(r){for(;r<0;)r+=255;for(;r>=256;)r-=255;return e[r]},n})(),Wc=function(e,t){if(typeof e.length>"u")throw e.length+"/"+t;const n=(function(){let o=0;for(;o<e.length&&e[o]==0;)o+=1;const i=new Array(e.length-o+t);for(let l=0;l<e.length-o;l+=1)i[l]=e[l+o];return i})(),r={};return r.getAt=function(o){return n[o]},r.getLength=function(){return n.length},r.multiply=function(o){const i=new Array(r.getLength()+o.getLength()-1);for(let l=0;l<r.getLength();l+=1)for(let c=0;c<o.getLength();c+=1)i[l+c]^=si.gexp(si.glog(r.getAt(l))+si.glog(o.getAt(c)));return Wc(i,0)},r.mod=function(o){if(r.getLength()-o.getLength()<0)return r;const i=si.glog(r.getAt(0))-si.glog(o.getAt(0)),l=new Array(r.getLength());for(let c=0;c<r.getLength();c+=1)l[c]=r.getAt(c);for(let c=0;c<o.getLength();c+=1)l[c]^=si.gexp(si.glog(o.getAt(c))+i);return Wc(l,0).mod(o)},r},Px=(function(){const e=[[1,26,19],[1,26,16],[1,26,13],[1,26,9],[1,44,34],[1,44,28],[1,44,22],[1,44,16],[1,70,55],[1,70,44],[2,35,17],[2,35,13],[1,100,80],[2,50,32],[2,50,24],[4,25,9],[1,134,108],[2,67,43],[2,33,15,2,34,16],[2,33,11,2,34,12],[2,86,68],[4,43,27],[4,43,19],[4,43,15],[2,98,78],[4,49,31],[2,32,14,4,33,15],[4,39,13,1,40,14],[2,121,97],[2,60,38,2,61,39],[4,40,18,2,41,19],[4,40,14,2,41,15],[2,146,116],[3,58,36,2,59,37],[4,36,16,4,37,17],[4,36,12,4,37,13],[2,86,68,2,87,69],[4,69,43,1,70,44],[6,43,19,2,44,20],[6,43,15,2,44,16],[4,101,81],[1,80,50,4,81,51],[4,50,22,4,51,23],[3,36,12,8,37,13],[2,116,92,2,117,93],[6,58,36,2,59,37],[4,46,20,6,47,21],[7,42,14,4,43,15],[4,133,107],[8,59,37,1,60,38],[8,44,20,4,45,21],[12,33,11,4,34,12],[3,145,115,1,146,116],[4,64,40,5,65,41],[11,36,16,5,37,17],[11,36,12,5,37,13],[5,109,87,1,110,88],[5,65,41,5,66,42],[5,54,24,7,55,25],[11,36,12,7,37,13],[5,122,98,1,123,99],[7,73,45,3,74,46],[15,43,19,2,44,20],[3,45,15,13,46,16],[1,135,107,5,136,108],[10,74,46,1,75,47],[1,50,22,15,51,23],[2,42,14,17,43,15],[5,150,120,1,151,121],[9,69,43,4,70,44],[17,50,22,1,51,23],[2,42,14,19,43,15],[3,141,113,4,142,114],[3,70,44,11,71,45],[17,47,21,4,48,22],[9,39,13,16,40,14],[3,135,107,5,136,108],[3,67,41,13,68,42],[15,54,24,5,55,25],[15,43,15,10,44,16],[4,144,116,4,145,117],[17,68,42],[17,50,22,6,51,23],[19,46,16,6,47,17],[2,139,111,7,140,112],[17,74,46],[7,54,24,16,55,25],[34,37,13],[4,151,121,5,152,122],[4,75,47,14,76,48],[11,54,24,14,55,25],[16,45,15,14,46,16],[6,147,117,4,148,118],[6,73,45,14,74,46],[11,54,24,16,55,25],[30,46,16,2,47,17],[8,132,106,4,133,107],[8,75,47,13,76,48],[7,54,24,22,55,25],[22,45,15,13,46,16],[10,142,114,2,143,115],[19,74,46,4,75,47],[28,50,22,6,51,23],[33,46,16,4,47,17],[8,152,122,4,153,123],[22,73,45,3,74,46],[8,53,23,26,54,24],[12,45,15,28,46,16],[3,147,117,10,148,118],[3,73,45,23,74,46],[4,54,24,31,55,25],[11,45,15,31,46,16],[7,146,116,7,147,117],[21,73,45,7,74,46],[1,53,23,37,54,24],[19,45,15,26,46,16],[5,145,115,10,146,116],[19,75,47,10,76,48],[15,54,24,25,55,25],[23,45,15,25,46,16],[13,145,115,3,146,116],[2,74,46,29,75,47],[42,54,24,1,55,25],[23,45,15,28,46,16],[17,145,115],[10,74,46,23,75,47],[10,54,24,35,55,25],[19,45,15,35,46,16],[17,145,115,1,146,116],[14,74,46,21,75,47],[29,54,24,19,55,25],[11,45,15,46,46,16],[13,145,115,6,146,116],[14,74,46,23,75,47],[44,54,24,7,55,25],[59,46,16,1,47,17],[12,151,121,7,152,122],[12,75,47,26,76,48],[39,54,24,14,55,25],[22,45,15,41,46,16],[6,151,121,14,152,122],[6,75,47,34,76,48],[46,54,24,10,55,25],[2,45,15,64,46,16],[17,152,122,4,153,123],[29,74,46,14,75,47],[49,54,24,10,55,25],[24,45,15,46,46,16],[4,152,122,18,153,123],[13,74,46,32,75,47],[48,54,24,14,55,25],[42,45,15,32,46,16],[20,147,117,4,148,118],[40,75,47,7,76,48],[43,54,24,22,55,25],[10,45,15,67,46,16],[19,148,118,6,149,119],[18,75,47,31,76,48],[34,54,24,34,55,25],[20,45,15,61,46,16]],t=function(o,i){const l={};return l.totalCount=o,l.dataCount=i,l},n={},r=function(o,i){switch(i){case 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 l=r(o,i);if(typeof l>"u")throw"bad rs block @ typeNumber:"+o+"/errorCorrectionLevel:"+i;const c=l.length/3,u=[];for(let h=0;h<c;h+=1){const p=l[h*3+0],m=l[h*3+1],k=l[h*3+2];for(let g=0;g<p;g+=1)u.push(t(m,k))}return u},n})(),Lx=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},tU=function(e){const t=Or.MODE_NUMBER,n=e,r={};r.getMode=function(){return t},r.getLength=function(l){return n.length},r.write=function(l){const c=n;let u=0;for(;u+2<c.length;)l.put(o(c.substring(u,u+3)),10),u+=3;u<c.length&&(c.length-u==1?l.put(o(c.substring(u,u+1)),4):c.length-u==2&&l.put(o(c.substring(u,u+2)),7))};const o=function(l){let c=0;for(let u=0;u<l.length;u+=1)c=c*10+i(l.charAt(u));return c},i=function(l){if("0"<=l&&l<="9")return l.charCodeAt(0)-48;throw"illegal char :"+l};return r},nU=function(e){const t=Or.MODE_ALPHA_NUM,n=e,r={};r.getMode=function(){return t},r.getLength=function(i){return n.length},r.write=function(i){const l=n;let c=0;for(;c+1<l.length;)i.put(o(l.charAt(c))*45+o(l.charAt(c+1)),11),c+=2;c<l.length&&i.put(o(l.charAt(c)),6)};const o=function(i){if("0"<=i&&i<="9")return i.charCodeAt(0)-48;if("A"<=i&&i<="Z")return i.charCodeAt(0)-65+10;switch(i){case" ":return 36;case"$":return 37;case"%":return 38;case"*":return 39;case"+":return 40;case"-":return 41;case".":return 42;case"/":return 43;case":":return 44;default:throw"illegal char :"+i}};return r},rU=function(e){const t=Or.MODE_8BIT_BYTE,n=gl.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},oU=function(e){const t=Or.MODE_KANJI,n=gl.stringToBytes;(function(i,l){const c=n(i);if(c.length!=2||(c[0]<<8|c[1])!=l)throw"sjis not supported."})("友",38726);const r=n(e),o={};return o.getMode=function(){return t},o.getLength=function(i){return~~(r.length/2)},o.write=function(i){const l=r;let c=0;for(;c+1<l.length;){let u=(255&l[c])<<8|255&l[c+1];if(33088<=u&&u<=40956)u-=33088;else if(57408<=u&&u<=60351)u-=49472;else throw"illegal char at "+(c+1)+"/"+u;u=(u>>>8&255)*192+(u&255),i.put(u,13),c+=2}if(c<l.length)throw"illegal char at "+(c+1)},o},yT=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},sU=function(){let e=0,t=0,n=0,r="";const o={},i=function(c){r+=String.fromCharCode(l(c&63))},l=function(c){if(c<0)throw"n:"+c;if(c<26)return 65+c;if(c<52)return 97+(c-26);if(c<62)return 48+(c-52);if(c==62)return 43;if(c==63)return 47;throw"n:"+c};return o.writeByte=function(c){for(e=e<<8|c&255,t+=8,n+=1;t>=6;)i(e>>>t-6),t-=6},o.flush=function(){if(t>0&&(i(e<<6-t),e=0,t=0),n%3!=0){const c=3-n%3;for(let u=0;u<c;u+=1)r+="="}},o.toString=function(){return r},o},iU=function(e){const t=e;let n=0,r=0,o=0;const i={};i.read=function(){for(;o<8;){if(n>=t.length){if(o==0)return-1;throw"unexpected end of file./"+o}const u=t.charAt(n);if(n+=1,u=="=")return o=0,-1;if(u.match(/^\s$/))continue;r=r<<6|l(u.charCodeAt(0)),o+=6}const c=r>>>o-8&255;return o-=8,c};const l=function(c){if(65<=c&&c<=90)return c-65;if(97<=c&&c<=122)return c-97+26;if(48<=c&&c<=57)return c-48+52;if(c==43)return 62;if(c==47)return 63;throw"c:"+c};return i},aU=function(e,t){const n=e,r=t,o=new Array(e*t),i={};i.setPixel=function(h,p,m){o[p*n+h]=m},i.write=function(h){h.writeString("GIF87a"),h.writeShort(n),h.writeShort(r),h.writeByte(128),h.writeByte(0),h.writeByte(0),h.writeByte(0),h.writeByte(0),h.writeByte(0),h.writeByte(255),h.writeByte(255),h.writeByte(255),h.writeString(","),h.writeShort(0),h.writeShort(0),h.writeShort(n),h.writeShort(r),h.writeByte(0);const p=2,m=c(p);h.writeByte(p);let k=0;for(;m.length-k>255;)h.writeByte(255),h.writeBytes(m,k,255),k+=255;h.writeByte(m.length-k),h.writeBytes(m,k,m.length-k),h.writeByte(0),h.writeString(";")};const l=function(h){const p=h;let m=0,k=0;const g={};return g.write=function(y,b){if(y>>>b)throw"length over";for(;m+b>=8;)p.writeByte(255&(y<<m|k)),b-=8-m,y>>>=8-m,k=0,m=0;k=y<<m|k,m=m+b},g.flush=function(){m>0&&p.writeByte(k)},g},c=function(h){const p=1<<h,m=(1<<h)+1;let k=h+1;const g=u();for(let E=0;E<p;E+=1)g.add(String.fromCharCode(E));g.add(String.fromCharCode(p)),g.add(String.fromCharCode(m));const y=yT(),b=l(y);b.write(p,k);let S=0,j=String.fromCharCode(o[S]);for(S+=1;S<o.length;){const E=String.fromCharCode(o[S]);S+=1,g.contains(j+E)?j=j+E:(b.write(g.indexOf(j),k),g.size()<4095&&(g.size()==1<<k&&(k+=1),g.add(j+E)),j=E)}return b.write(g.indexOf(j),k),b.write(m,k),b.flush(),y.toByteArray()},u=function(){const h={};let p=0;const m={};return m.add=function(k){if(m.contains(k))throw"dup key:"+k;h[k]=p,p+=1},m.size=function(){return p},m.indexOf=function(k){return h[k]},m.contains=function(k){return typeof h[k]<"u"},m};return i},lU=function(e,t,n){const r=aU(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=yT();r.write(o);const i=sU(),l=o.toByteArray();for(let c=0;c<l.length;c+=1)i.writeByte(l[c]);return i.flush(),"data:image/gif;base64,"+i};gl.stringToBytes;function cU(e){const t=gl(0,"M");t.addData(e,"Byte"),t.make();const n=t.getModuleCount();return Array.from({length:n},(r,o)=>Array.from({length:n},(i,l)=>t.isDark(o,l)))}const ir={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 ${yf(e)}.`,waiting:(e,t)=>`Toyon on ${yf(e)} is asking whether to let ${t} in.`,added:e=>`Added ${e}.`,notKept:e=>`Let in, but not listed: ${e}`,add:"add"};function uU(e,t){return e.reached?e.toyon&&!e.toyon.answering?ir.notAnswering:t?ir.listed:e.toyon?null:ir.noToyon:ir.offline}function Dx(e){var t;return(t=e.toyon)!=null&&t.answering?0:e.toyon?1:e.reached?2:3}function yf(e){try{return new URL(e).host}catch{return e}}function vT(e,t,n){const r=yf(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 dU(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",ir.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 fU=e=>e==="phone"?"phone":"laptop";function zx({rows:e}){return d.jsx("div",{className:"tailnet-list",children:e.map(t=>d.jsxs("div",{className:"tailnet-row",children:[d.jsxs("div",{className:"tailnet-peer",children:[d.jsx("span",{className:Ke("dot tailnet-dot",t.reached===null?"tailnet-asking":t.reached?"tailnet-reached":"tailnet-unreached"),role:"img","aria-label":t.reached===null?"asking":t.reached?"connected":"not connected"}),d.jsx(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:Ke("tailnet-right",typeof t.right=="string"&&"hint"),children:t.right})]},t.key))})}const Fx=(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:fU(e.kind),right:t}},sm=4;function hU({text:e}){const{size:t,d:n}=_.useMemo(()=>{const r=cU(e);let o="";return r.forEach((i,l)=>{i.forEach((c,u)=>{c&&(o+=`M${u+sm} ${l+sm}h1v1h-1z`)})}),{size:r.length+sm*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 pU=5e3;function mU(e){return e.from===null?"A device that opened this address":`A Toyon page at ${yf(e.from)}`}function gU({knock:e,letIn:t,onAnswer:n}){return d.jsxs("div",{className:Ke("devices-knock",t!==null&&"devices-knock-done"),children:[d.jsxs("div",{className:"devices-knock-line",children:[d.jsx("span",{className:"knock-word",children:e.word}),d.jsx("span",{className:"devices-from",children:t===null?`${mU(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 kU({host:e,noPhone:t}){return d.jsxs("div",{className:"devices-address",children:[d.jsx("div",{className:"devices-frame",children:d.jsx(hU,{text:OC(e)})}),d.jsxs("div",{className:"devices-about",children:[d.jsx("p",{className:"devices-line",children:ir.scan}),t&&d.jsx("p",{className:"devices-note",children:ir.noPhone})]})]})}function wU(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)=>Dx(r.d)-Dx(o.d)||r.i-o.i).map(({d:r})=>r);return[...t,...n]}function yU(){const e=ut(),t=Vo(),n=Lr(),r=L(re=>re.frame==="desk"),o=L(re=>{var Le;return((Le=re.remote)==null?void 0:Le.host)??null}),i=L(re=>re.machine),l=L(re=>re.tailscale),c=L(re=>re.knocks),[u,h]=_.useState(""),[p,m]=_.useState({kind:"idle"}),[k,g]=_.useState([]),y=()=>e({a:"close"}),b=p.kind==="asking"||p.kind==="waiting",S=NL(()=>HM(n),pU,!b),j=_.useRef(new AbortController);_.useEffect(()=>()=>j.current.abort(),[]);const E=async re=>{if(b)return;const Le=j.current.signal;m({kind:"asking",origin:re});const Ue=await pE(re,Le,Ne=>m({kind:"waiting",origin:re,word:Ne}));if(Le.aborted)return;if(typeof Ue=="string"){m({kind:"failed",line:vT(Ue,re,"this page")});return}const _e=t.serving(),je=await GM(Zg(_e.origin,_e.token),re,Ue.token);m(je?{kind:"failed",line:ir.notKept(je)}:{kind:"added",name:t.displayName(re)})},N=()=>{const re=MC(u);re?E(re):m({kind:"failed",line:ir.notAnAddress})},A=()=>{j.current.abort(),j.current=new AbortController,m({kind:"idle"})},O=(re,Le)=>{g(Ue=>Ue.some(_e=>_e.knock.id===re.id)?Ue:[...Ue,{knock:re,letIn:Le}]),VM(n,re.id,Le)},P=c.filter(re=>!k.some(Le=>Le.knock.id===re.id)),R=[...k,...P.map(re=>({knock:re,letIn:null}))],[T,$]=_.useState(!1),[D,z]=_.useState(null),V=async re=>{$(!0),z(null);const Le=await(re?WM(n):KM(n));$(!1),Le&&z(Le)},se=(S==null?void 0:S.here)===!0,I=dU(S,l,o),ne=o!==null,we=r&&(se||S===void 0)?d.jsx(De,{variant:"outline",size:"sm",on:ne,"aria-pressed":ne,busy:T,disabled:!ne&&(l==null?void 0:l.state)!=="ready",onClick:()=>void V(!ne),...Ut(ne?"Take this machine's name off your tailnet":"Give this machine a name on your tailnet"),children:ne?"on":"off"}):null,[K,B]=_.useState(!1),[ee,J]=_.useState(null),W=re=>{window.open(re,"_blank","noopener")===null?J(re):J(null)},ie=async re=>{if(B(!0),z(null),re==="connect"){const Le=await ZM(n);Le&&z(Le)}else{const Le=await qM(n);"url"in Le?W(Le.url):z(Le.why)}B(!1)},Te=r&&I.offer!==null?ee!==null?d.jsx(De,{variant:"outline",size:"sm",onClick:()=>W(ee),children:"open the sign-in page"}):d.jsx(De,{variant:"outline",size:"sm",busy:K,onClick:()=>void ie(I.offer??"connect"),...I.note?Ut(I.note):{},children:I.offer==="connect"?"connect":"sign in"}):null,Ce=I.word===null&&we===null&&Te===null?"this machine":d.jsxs(d.Fragment,{children:[I.word&&d.jsx("span",{className:"hint",children:I.word}),we??Te]}),de=[{key:"self",name:i??"This machine",host:o??void 0,reached:S===void 0?null:se,icon:"laptop",right:Ce}],be=S?wU(S).map(re=>{if(re.kind==="phone"||re.host==="")return Fx(re,re.reached?void 0:"not answering");const Le=`https://${re.host}`,Ue=uU(re,t.get(Le)!==null);return Fx(re,Ue??d.jsx(De,{variant:"outline",size:"sm",disabled:b,onClick:()=>void E(Le),children:ir.request}))}):[],le=r&&o!==null&&S!==null&&(S===void 0||S.here),G=S==null?void 0:S.devices.some(re=>re.kind==="machine"&&re.host!==""&&re.reached&&re.toyon===null),ce=le&&S!==void 0&&!S.devices.some(re=>re.kind==="phone"),oe=(()=>{switch(p.kind){case"asking":return ir.asking(p.origin);case"waiting":return ir.waiting(p.origin,p.word);case"added":return ir.added(p.name);case"failed":return p.line;case"idle":return null}})();return d.jsxs(Uc,{boxClass:"devices-card",onClose:y,children:[d.jsx("div",{className:"devices-title",children:ir.title}),d.jsx(zx,{rows:de}),I.note&&I.offer===null&&d.jsx("p",{className:"devices-note",children:I.note}),D&&d.jsx("p",{className:"devices-note",children:D}),r&&!ne&&(l==null?void 0:l.state)==="ready"&&d.jsx("p",{className:"devices-note",children:ir.turnOn}),le&&o!==null&&d.jsx(kU,{host:o,noPhone:ce}),p.kind==="waiting"&&d.jsx("div",{className:"knock-word devices-word",children:p.word}),oe&&d.jsx("p",{className:Ke("devices-line",p.kind==="failed"&&"devices-failed"),children:oe}),S!==void 0&&d.jsxs(d.Fragment,{children:[be.length>0&&d.jsx("div",{className:"devices-others",children:d.jsx(zx,{rows:be})}),(S==null?void 0:S.devices.length)===0&&d.jsx("p",{className:"devices-note",children:ir.noneOnTailnet}),G&&d.jsx("p",{className:"devices-note",children:ir.missing})]}),!b&&d.jsxs("form",{className:"devices-form",onSubmit:re=>{re.preventDefault(),N()},children:[d.jsx(jo,{size:"md",font:"ui",value:u,placeholder:ir.placeholder,"aria-label":"Address of the other machine",onChange:re=>h(re.target.value),className:"devices-field"}),d.jsx(De,{type:"submit",variant:"outline",disabled:!u.trim(),children:ir.add})]}),b&&d.jsx("div",{className:"devices-actions",children:d.jsx(De,{tone:"quiet",onClick:A,children:"cancel"})}),P.length>0&&d.jsx("p",{className:"devices-line devices-centred",children:ir.knocking}),R.map(re=>d.jsx(gU,{knock:re.knock,letIn:re.letIn,onAnswer:Le=>O(re.knock,Le)},re.knock.id))]})}function vU({worktreeId:e,hits:t}){const n=ut(),r=pt(),o=L(c=>c.layout.changes),i=L(c=>{var h;const u=(h=pn(c,e))==null?void 0:h.worktree;return u?u.path:null}),l=_.useCallback((c,u)=>{const h=u.trim().toLowerCase();return h?c.filter(p=>`${p.path}:${p.line} ${p.text}`.toLowerCase().includes(h)):c},[]);return d.jsx(Pr,{items:t,filter:l,keyOf:c=>`${c.path}:${c.line}`,rowClass:()=>"search-hit",rowTitle:c=>`${c.path}:${c.line}`,onPick:c=>{tr({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?js({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 bU({project:e}){const t=ut(),n=pt(),r=L(h=>h.paths),o=L(h=>h.home),i=_.useCallback(h=>{Qf(h)&&(n==null||n.send({t:"browse-path",path:h}))},[n]),l=_.useCallback((h,p)=>CF({query:p,entries:r.entries,target:r.target,answered:r.query,home:o}),[r,o]),c=$c(e.name)?null:e.name.trim(),u=h=>`${h.replace(/\/+$/,"")}/`;return d.jsx(Pr,{initialQuery:u(e.parent),lead:d.jsx("span",{className:"picker-chip",children:c??"new project"}),items:[],filter:l,keyOf:h=>h.kind==="dir"?`d:${h.entry.path}`:`${h.kind}:${h.path}`,rowClass:()=>"picker-row folder-row",onQuery:i,completionOf:h=>h.kind==="dir"?u(h.entry.path):null,narrowTo:h=>h.kind==="dir"?u(h.entry.path):h.kind==="up"?u(h.path):null,onPick:h=>{h.kind==="here"&&(t({a:"new-project-set",v:{mode:e.mode==="init"?"create":e.mode,parent:h.path}}),t({a:"close"}))},onBack:()=>t({a:"close"}),placeholder:"type a folder path",keys:h=>({complete:"completes the path",pick:(h==null?void 0:h.kind)==="here"?"chooses it":(h==null?void 0:h.kind)==="up"?"goes up":"opens it",back:"goes back"}),empty:"no such folder",row:h=>h.kind==="here"?d.jsx(On,{label:`put ${c??"it"} in ${rg(h.path,o)}`,hint:d.jsx("bdi",{children:c?bN(h.path,c):h.path})}):h.kind==="up"?d.jsx(On,{label:`up to ${rg(h.path,o)}`,hint:d.jsx("bdi",{children:h.path})}):d.jsx(On,{label:h.entry.name})})}function xU({worktreeId:e}){const t=ut(),n=pt(),r=L(m=>m.clientId),o=L(m=>pn(m,e)),i=L(m=>m.repos),c=It(e,"draft").trim(),u=_.useMemo(()=>i.filter(m=>m.id!==(o==null?void 0:o.worktree.repoId)),[i,o]),h=()=>t({a:"close"}),p=m=>{if(!o)return h();n==null||n.send({t:"handoff-ask",worktreeId:e,repoId:m.id,...c?{text:c}:{}}),c&&(n==null||n.send({t:"set-draft",boxId:e,text:"",clientId:r}),t({a:"set-draft",id:e,text:""})),h()};return d.jsx(Pr,{lead:d.jsx("span",{className:"picker-chip",children:(o==null?void 0:o.worktree.title)??"worktree"}),items:u,filter:(m,k)=>m.filter(g=>is(k,g.name,g.path)),keyOf:m=>m.id,row:m=>d.jsx(On,{label:m.name,hint:m.path}),onPick:p,onBack:()=>t({a:"close",back:!0}),placeholder:"continue in which project?",empty:"no other project is open",keys:{pick:"continues there",back:"closes"},footer:c?()=>d.jsxs("div",{className:"empty",children:["with your message: ",c.split(`
|
|
249
|
+
`)[0]]}):void 0})}const EU={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 SU(){const e=ut(),t=pt(),n=L(r=>r.keepAwake);return d.jsx(Pr,{items:[...iC],filter:(r,o)=>r.filter(i=>is(o,df[i])),rowClass:()=>"picker-row",keyOf:r=>r,initialIndex:r=>Math.max(0,n?r.indexOf(n):0),onPick:r=>{t==null||t.send({t:"set-keep-awake",mode:r}),e({a:"close"})},onBack:()=>e({a:"close",back:!0}),placeholder:"keep awake",keys:{pick:"sets",back:"closes"},row:r=>d.jsx(On,{label:df[r],current:r===n,hint:EU[r]})})}function _U(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=Tm(t.rows,null);return n?`${n.n} ${n.tier==="waiting"?"waiting":"unread"}`:"all quiet"}function kg(e){try{return PC(new URL(e).hostname)}catch{return!1}}function NU(e){const t=new Set,n=e.build({...e.serving,serving:!0}),r=[];let o=n,i=[n];const l=()=>{i=[n,...r];for(const y of t)y()},c=new Map,u=y=>{var S;if(y.serving)return;(((S=y.store.getState().remote)==null?void 0:S.front)==="edge"||kg(y.origin))&&y!==o?y.sock.suspend():y.sock.resume()},h=y=>{var S;let b=(S=y.store.getState().remote)==null?void 0:S.front;c.set(y.origin,y.store.subscribe(()=>{var E;const j=(E=y.store.getState().remote)==null?void 0:E.front;j!==b&&(b=j,u(y))}))},p=()=>i,m={list:p,active:()=>o,serving:()=>n,get:y=>p().find(b=>b.origin===y)??null,displayName(y){const b=p().find(j=>j.origin===y);return b?p().filter(j=>j.name===b.name).length>1?`${b.name} (${new URL(b.origin).host})`:b.name:y},activate(y){const b=p().find(j=>j.origin===y);if(!b||b===o)return;const S=o;o=b,u(S),u(b),l()},add(y){var j;const b=r.find(E=>E.origin===y.origin);if(y.origin===n.origin)return n;if(b){if(b.token===y.token)return b;(j=c.get(b.origin))==null||j(),b.dispose(),r.splice(r.indexOf(b),1),o===b&&(o=n)}const S=e.build({...y,serving:!1});return r.push(S),h(S),kg(S.origin)&&S.sock.suspend(),l(),S},remove(y){var S;const b=r.find(j=>j.origin===y);b&&((S=c.get(y))==null||S(),c.delete(y),b.dispose(),b.storage.clear(),r.splice(r.indexOf(b),1),o===b&&(o=n),l())},broadcast(y){for(const b of p())b.store.dispatch(y)},subscribe(y){return t.add(y),()=>t.delete(y)}},k=y=>{for(const b of y)m.add(b);for(const b of[...r])y.some(S=>S.origin===b.origin)||m.remove(b.origin)};let g=n.store.getState().handed;return n.store.subscribe(()=>{const y=n.store.getState().handed;y!==g&&(g=y,k(g))}),k(g),m}function ww({form:e,anchored:t}){var se;const n=ut(),r=pt(),o=Vo(),i=lo(),l=o.displayName(i.origin),c=L(I=>I.repos),u=L(I=>I.newProject?null:I.activeRepoId),h=L(I=>I.rows),p=L(I=>I.paths),m=L(I=>I.home),k=L(I=>I.pending),g=_.useMemo(()=>jv(c,h),[c,h]),y=KE(),b=ZE(),S=_.useMemo(()=>y.map(I=>{var ne;return{...I,repos:jv(I.repos,((ne=b.find(we=>we.origin===I.origin))==null?void 0:ne.rows)??[])}}),[y,b]),j=_.useCallback(I=>{Qf(I)&&(r==null||r.send({t:"browse-path",path:I}))},[r]),E=_.useCallback((I,ne)=>jF({query:ne,repos:g,pending:k,entries:[...p.entries].sort((we,K)=>Number(K.isRepo)-Number(we.isRepo)),target:p.target,answered:p.query,home:m,others:S,current:u}),[g,p,k,m,S,u]),N=I=>bT(h,I),A=()=>n({a:"close"}),O=()=>n({a:"close",back:!0}),P={sock:r,dispatch:n},R=I=>Bc(P,{t:"register-repo",path:I}),T=(I,ne)=>Bc(P,{t:"create-repo",mode:"create",parent:I,name:ne}),$=(I,ne,we)=>n({a:"new-project",v:ik({mode:I,name:ne,parent:TF(c,u,m),...we?{url:we}:{}})}),D=()=>n({a:"open",overlay:{kind:"projects",form:"disk"}}),z=()=>n({a:"open",overlay:{kind:"devices"}}),V=(I,ne)=>{const we=o.get(I);we&&(we.store.dispatch({a:"activate-repo",id:ne}),o.activate(I))};return d.jsx(Pr,{anchored:e==="pill"&&(t??!0),initialQuery:e==="disk"?"~/":"",lead:e==="disk"?void 0:d.jsx("span",{className:"picker-chip",children:((se=c.find(I=>I.id===u))==null?void 0:se.name)??"no project"}),trailing:e==="disk"?void 0:d.jsx(Rt,{icon:"folder",label:"Find a project on disk",onClick:D}),items:[],filter:E,initialIndex:I=>I.findIndex(ne=>ne.kind==="repo"&&!ne.machine&&ne.repo.id===u),groupOf:I=>I.kind==="machine"||I.kind==="repo"&&I.machine?I.machine.origin:i.origin,groupHead:I=>I===i.origin?l:d.jsx(TU,{origin:I}),keyOf:I=>I.kind==="repo"?I.machine?`${I.machine.origin}:${I.repo.id}`:I.repo.id:I.kind==="dir"?`d:${I.entry.path}`:I.kind==="open"?`open:${I.path}`:I.kind==="init"?`init:${I.path}`:I.kind==="pending"?`p:${I.pending.id}`:I.kind==="clone"?`clone:${I.url}`:I.kind==="new"?"new-project":I.kind==="disk"?"open-folder":I.kind==="add-machine"?"add-machine":I.kind==="machine"?`machine:${I.machine.origin}`:`new:${I.parent??""}/${I.name}`,rowClass:I=>Ke("picker-row",(I.kind==="new"||I.kind==="disk"||I.kind==="add-machine")&&"new-project-row"),onQuery:j,completionOf:I=>I.kind==="dir"?I.entry.isRepo?I.entry.path:`${I.entry.path}/`:null,narrowTo:I=>I.kind==="dir"&&!I.entry.isRepo?`${I.entry.path}/`:null,onPick:I=>{if(I.kind==="clone")return $("clone",I.name,I.url);if(I.kind==="create"&&!I.parent)return $("create",I.name);if(I.kind==="new")return $("create","");if(I.kind==="disk")return D();if(I.kind==="add-machine")return z();I.kind==="machine"?o.activate(I.machine.origin):I.kind==="pending"?n({a:"watch-import",id:I.pending.id}):I.kind==="repo"&&I.machine?V(I.machine.origin,I.repo.id):I.kind==="repo"?n({a:"activate-repo",id:I.repo.id}):I.kind==="open"?R(I.path):I.kind==="init"?EN(P,I.path):I.kind==="dir"?R(I.entry.path):I.parent&&T(I.parent,I.name),A()},onBack:O,rowMenu:I=>I.kind==="machine"||I.kind==="repo"&&I.machine?ng(o,I.machine.origin):I.kind==="repo"?Jf(I.repo,u,P):I.kind==="pending"?AF(I.pending,P):[],placeholder:c.length>1?"switch project, or type a name or path":"type a name or a path to start",keys:I=>({complete:"completes the path",pick:(I==null?void 0:I.kind)==="dir"&&!I.entry.isRepo?"descends":(I==null?void 0:I.kind)==="pending"?"watches it":(I==null?void 0:I.kind)==="create"?I.parent?"creates it":"names it":(I==null?void 0:I.kind)==="clone"?"clones it":(I==null?void 0:I.kind)==="new"?"starts one":(I==null?void 0:I.kind)==="disk"?"browses":(I==null?void 0:I.kind)==="add-machine"?"adds one":(I==null?void 0:I.kind)==="machine"||(I==null?void 0:I.kind)==="repo"&&I.machine?"switches machine":"opens",back:"closes"}),empty:"nothing here; keep typing a path (~/… or /…)",row:I=>I.kind==="repo"&&I.machine?d.jsx(On,{label:I.repo.name,hint:d.jsx(jU,{origin:I.machine.origin,repo:I.repo})}):I.kind==="repo"?d.jsx(On,{label:I.repo.name,current:I.repo.id===u,hint:N(I.repo)}):I.kind==="pending"?d.jsx(On,{label:I.pending.name,hint:I.pending.error?"import failed":"importing…"}):I.kind==="dir"?d.jsx(On,{label:I.entry.name,hint:I.entry.isRepo?"git repo":void 0}):I.kind==="open"?d.jsx(On,{label:`open ${I.path}`,hint:"register with this daemon"}):I.kind==="init"?d.jsx(On,{label:`open ${I.path}`,hint:"no git yet; starts it here with the files in it"}):I.kind==="clone"?d.jsx(On,{label:`clone ${I.name}`,hint:CU(I.url)}):I.kind==="new"?d.jsx(On,{label:d.jsxs(d.Fragment,{children:[d.jsx(St,{name:"plus",className:"icon-inline"}),"new project"]})}):I.kind==="disk"?d.jsx(On,{label:d.jsxs(d.Fragment,{children:[d.jsx(St,{name:"folder",className:"icon-inline"}),"open folder"]})}):I.kind==="add-machine"?d.jsx(On,{label:d.jsxs(d.Fragment,{children:[d.jsx(St,{name:"devices",className:"icon-inline"}),"add a machine"]})}):I.kind==="machine"?d.jsx(On,{label:`switch to ${o.displayName(I.machine.origin)}`}):d.jsx(On,{label:`create ${I.name}`,hint:I.parent?`in ${I.parent}`:"new project"})})}function bT(e,t){const n=e.filter(u=>u.repoId===t.id),r=n.filter(vn).filter(u=>u.worktree.kind!=="spare"),o=r.filter(Vc).length,i=r.length-1,l=n.length-n.filter(vn).length;return[i>0?`${i} worktree${i===1?"":"s"}`:null,o>0?`${o} working`:null,l>0?`${l} discovered`:null].filter(Boolean).join(" · ")||void 0}function TU({origin:e}){const t=Vo(),n=t.get(e)??t.active(),r=Da(n,m=>m.rows),o=Da(n,m=>m.connected),i=Da(n,m=>m.connectFailure),l=Da(n,m=>m.incompatible),c=Da(n,m=>{var k;return(k=m.remote)==null?void 0:k.front}),u=t.displayName(e),h=_U(u,{rows:r.filter(vn),connected:o,connectFailure:i,incompatible:l,suspended:(c==="edge"||kg(e))&&!o}),p=/^\d+ /.test(h);return d.jsxs(d.Fragment,{children:[u,d.jsx("span",{className:Ke("picker-group-tail",p&&"picker-group-owed"),children:h})]})}function jU({origin:e,repo:t}){const n=Vo(),r=n.get(e),o=Da(r??n.active(),i=>i.rows);return d.jsx(d.Fragment,{children:r?bT(o,t):null})}function CU(e){const t=e.match(/^[a-z+]+:\/\/(?:[^@/]*@)?([^/:]+)/i)??e.match(/^[^@]+@([^:]+):/);return(t==null?void 0:t[1])??"git remote"}function AU(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:()=>Jt(r)})}const n=[{id:"copy-ref",label:e.kind==="pr"?"copy PR number":"copy branch name",onClick:()=>Jt(e.ref)}];return Ln([t,n])}const IU=[],RU={branch:"branch",remote:"globe",pr:"pr"},Bx={pr:0,branch:1,remote:2},$U={pr:"pull requests",branch:"branches",remote:"remote branches"};function OU({repoId:e}){const t=ut(),n=pt(),r=L(m=>m.clientId),o=L(m=>m.refs[e]),i=L(m=>m.rows),l=m=>{var k;return((k=i.find(g=>g.id===m))==null?void 0:k.name)??"a worktree"},c=_.useCallback(m=>[...m].sort((k,g)=>Bx[k.kind]-Bx[g.kind]),[]),u=_.useCallback(m=>n==null?void 0:n.send({t:"search-refs",repoId:e,query:m.trim()}),[n,e]),h=m=>!o||o.query!==m.trim(),p=m=>m.openIn?`open in ${l(m.openIn)}`:m.merged?"merged":m.pr?`${m.pr.author}${m.pr.draft?" · draft":""}${m.pr.fork?" · fork":""}`:m.subject??"";return d.jsx(Pr,{items:(o==null?void 0:o.refs)??IU,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:AU,groupOf:m=>m.kind,groupHead:(m,k)=>`${$U[m]} · ${k}`,placeholder:"open a branch or PR…",keys:m=>({nav:"moves",pick:m!=null&&m.openIn?"switches to it":"opens it as a worktree",back:"closes"}),empty:m=>h(m)?"looking…":m.trim()?"no branch or PR matches":"no unmerged branches or open PRs",row:m=>d.jsx(On,{label:d.jsxs(d.Fragment,{children:[d.jsx(St,{name:RU[m.kind],className:"icon-inline"}),d.jsx("span",{className:"ref-name",children:m.name})]}),hint:p(m)})})}const Ux=[],im=2;function MU({worktreeId:e}){const t=ut(),n=pt(),r=eS(e).search,o=L(h=>h.layout.changes),i=L(h=>{var m;const p=(m=pn(h,e))==null?void 0:m.worktree;return p?p.path:null}),l=_.useCallback((h,p)=>p.trim().length>=im?h:Ux,[]),c=_.useCallback(h=>{const p=h.trim();p.length>=im&&(n==null||n.send({t:"search",worktreeId:e,query:p}))},[n,e]),u=h=>!r||r.query.trim()!==h.trim();return d.jsx(Pr,{items:(r==null?void 0:r.hits)??Ux,filter:l,onQuery:c,keyOf:h=>`${h.path}:${h.line}`,rowClass:()=>"search-hit",rowTitle:h=>`${h.path}:${h.line}`,onPick:h=>{tr({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?js({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<im?"type at least two characters":u(h)?"searching…":"no matches",footer:(h,p)=>r!=null&&r.truncated&&!u(h)&&p.length>0?d.jsxs("div",{className:"empty",children:["showing the first ",p.length,"; narrow the search"]}):null,row:h=>d.jsxs(d.Fragment,{children:[d.jsxs("span",{className:"search-loc",children:[h.path,":",h.line]}),d.jsx("span",{className:"search-text",children:h.text})]})})}const Hx=e=>e.source==="file"?"~/.toyon/themes":e.source==="vscode"?"VS Code":"";function PU({slot:e}){const t=ut(),n=pt(),r=L(E=>E.themePrefs),o=L(E=>E.themes),i=hk(),l=Hg(r,i),c=r[e==="theme"?l:e],u=()=>t({a:"close"}),h=()=>t({a:"close",back:!0}),p=E=>t({a:"preview-theme",theme:E}),[m,k]=_.useState(null),[g,y]=_.useState(null),b=(E,N)=>E[N??l]??E.dark??E.light??null,S=_.useMemo(()=>NM(o),[o]),j=_.useMemo(()=>o.filter(E=>E.kind===e),[o,e]);return gt([m,g],()=>{e==="theme"&&p(m?b(m,g):null)}),e!=="theme"?d.jsx(Pr,{items:j,filter:(E,N)=>E.filter(A=>is(N,A.name,A.id)),rowClass:()=>"picker-row",keyOf:E=>E.id,initialIndex:E=>E.findIndex(N=>N.id===c),onActive:p,onPick:E=>{n==null||n.send({t:"set-theme",prefs:{...r,[e]:E.id}}),u()},onBack:h,placeholder:`${e} slot override`,keys:{nav:"preview",pick:"keeps",back:"reverts"},empty:"no matching theme",row:E=>d.jsx(On,{label:E.name,current:E.id===c,hint:Hx(E)})}):d.jsx(Pr,{items:S,filter:(E,N)=>E.filter(A=>{var O,P;return is(N,A.name,(O=A.dark)==null?void 0:O.name,(P=A.light)==null?void 0:P.name)}),rowClass:()=>"picker-row",keyOf:E=>{var N,A;return E.name+(((N=E.dark)==null?void 0:N.id)??((A=E.light)==null?void 0:A.id))},initialIndex:E=>E.findIndex(N=>{var A,O;return((A=N.dark)==null?void 0:A.id)===c||((O=N.light)==null?void 0:O.id)===c}),onActive:k,onSide:E=>{var N;E.dark&&E.light&&y((((N=b(E,g))==null?void 0:N.kind)??l)==="dark"?"light":"dark")},onPick:E=>{n==null||n.send({t:"set-theme",prefs:TM(r,E)}),u()},onBack:h,placeholder:"theme",keys:{nav:"preview",side:"dark/light",pick:"keeps",back:"reverts"},empty:"no matching theme",row:(E,N)=>{var R,T;const A=b(E,N?g:null),O=Hx(E.dark??E.light),P=((R=E.dark)==null?void 0:R.id)===c||((T=E.light)==null?void 0:T.id)===c;return d.jsx(On,{label:E.name,current:P,hint:d.jsxs("span",{className:"theme-kinds",children:[O&&d.jsx("span",{children:O}),d.jsx("span",{className:"kind","data-state":vr({current:N&&(A==null?void 0:A.kind)==="dark"}),children:E.dark?"dark":""}),d.jsx("span",{className:"kind","data-state":vr({current:N&&(A==null?void 0:A.kind)==="light"}),children:E.light?"light":""})]})})}})}function xT(){const e=OL(),t=L(i=>i.frame==="phone"),n=hl(),r=L(i=>i.activeRepoId),o=L(i=>i.newProject);return d.jsxs(d.Fragment,{children:[(e==null?void 0:e.kind)==="quick-open"&&n&&d.jsx(x9,{worktreeId:n}),(e==null?void 0:e.kind)==="search"&&n&&d.jsx(MU,{worktreeId:n}),(e==null?void 0:e.kind)==="element-sources"&&d.jsx(vU,{worktreeId:e.worktreeId,hits:e.hits}),(e==null?void 0:e.kind)==="refs"&&r&&d.jsx(OU,{repoId:r}),(e==null?void 0:e.kind)==="chats"&&r&&d.jsx(eU,{repoId:r,scope:e.names?"names":"all"}),(e==null?void 0:e.kind)==="keys"&&d.jsx(zB,{}),(e==null?void 0:e.kind)==="devices"&&d.jsx(yU,{}),(e==null?void 0:e.kind)==="theme"&&d.jsx(PU,{slot:e.slot}),(e==null?void 0:e.kind)==="appearance"&&d.jsx(GB,{}),(e==null?void 0:e.kind)==="keep-awake"&&d.jsx(SU,{}),(e==null?void 0:e.kind)==="agent"&&d.jsx(KB,{}),(e==null?void 0:e.kind)==="agent-page"&&d.jsx(HB,{agentId:e.agent}),(e==null?void 0:e.kind)==="handoff"&&d.jsx(xU,{worktreeId:e.worktreeId}),(e==null?void 0:e.kind)==="commands"&&!t&&d.jsx(oT,{}),(e==null?void 0:e.kind)==="projects"&&e.form!=="pill"&&d.jsx(ww,{form:e.form},e.form),(e==null?void 0:e.kind)==="choose-folder"&&o&&d.jsx(bU,{project:o})]})}const jc="Lost the daemon; retrying",LU="Not run by Toyon",ET="new worktree",DU=(e,t)=>`in ${e}, started from ${t}`,zU=e=>`in ${e}, here while it needs you`,FU=new Set(["waiting","working","starting","failed","crashed"]);function wg(e,t){if(t.offline)return jc;if(!vn(e))return e.locked?`Held by ${e.lockReason??"another tool"}`:t.path;if(t.op)return Jg(t.op);if(yr(e.worktree))return ET;const n=Qg(e,t.needsSetup),r=e.worktree.lastTurn;return!FU.has(fi(e))&&r?Ok(r):t.at&&t.at!=="now"?`${n} · ${t.at}`:n}function BU(e,t){if(!vn(e)||t)return!1;const n=fi(e);return(n==="idle"||n==="asleep")&&!e.unseen}function UU(e){const t=e.worktree.lastTurn,n=e.worktree.landed?Ik(e.worktree.lands):[],r=t?(Vc(e)?zD:Ok)(t):void 0,o=e.worktree.pr&&!e.worktree.landed?Ns(e.worktree.pr):void 0;return[...n,r,o].filter(i=>!!i)}function HU(e,t,n,r){let o;const i=(p,m)=>{const k=m==null?void 0:m[m.length-1];k&&(!o||k.at>o.mark.at)&&(o={title:p,mark:k})};for(const p of e)p.worktree&&i(p.worktree.title,p.worktree.lands);for(const p of t)i(p.title,p.lands);const l=o&&Ak(o.mark),c=o?`Landed ${o.title} ${Ho(oo(o.mark.at))}${l?`: ${Kr(l)}`:"."}`:void 0,u=n?qS(r,n):null,h=u?Kr(`${u.charAt(0).toUpperCase()}${u.slice(1)}`):n!=null&&n.fetchedAt?`Level with origin, fetched ${Ho(oo(n.fetchedAt))}.`:void 0;return[c,h].filter(p=>!!p)}function WU(e){const t=e.prompt?Vf(e.prompt):"";return[...t?[t]:[],...Ik(e.lands)]}function KU(e){const n=[e.auto&&ZU(e.auto,!!e.landed),e.cost!==void 0?eu(e.cost):void 0].filter(r=>!!r);return n.length?n:void 0}function ZU(e,t){const{what:n,idle:r}=dC(e);return r?`${t?"":`${n}, `}${r} idle`:n}const Wx=25;function qU(e,t){if(e.length<=Wx+1)return{shown:e,rest:0};const n=e.slice(0,Wx),r=t?e.find(o=>o.id===t):void 0;return r&&!n.includes(r)&&n.push(r),{shown:n,rest:e.length-n.length}}const GU=.5;function VU(e){const t=e.usage,n=t&&t.size>0?t.used/t.size:0,r=[n>=GU?`${Math.round(100*n)}% of context`:void 0,e.queued?`${e.queued} queued`:void 0,(t==null?void 0:t.cost)!==void 0?eu(t.cost):void 0].filter(o=>!!o);return r.length?r:void 0}function YU(e){const t=o=>e.filter(cs).find(i=>i.id===o)??null,n=t("archive"),r=t("land");return[{id:"archive",label:(n==null?void 0:n.label)??"archive",icon:"archive",item:n},{id:"land",label:(r==null?void 0:r.label)??"land",icon:"land",item:r},{id:"more",label:"more",icon:"more",item:null}]}function XU(e){return e.altKey?"Alt":e.ctrlKey?"Control":e.metaKey?"Meta":null}function QU(e,t){return t==="Alt"?e.altKey:t==="Control"?e.ctrlKey:e.metaKey}const JU=200,ST={set:(e,t)=>setTimeout(e,t),clear:e=>clearTimeout(e)};function e7(e,t=ST){let n=null,r=!1,o=null;const i=()=>{r||(r=!0,e(!0))},l=()=>{o!==null&&(t.clear(o),o=null)},c=()=>{l(),n=null,r&&(r=!1,e(!1))};return{press(u){const h=n!==null;n=XU(u),l(),n&&(h?i():o=t.set(()=>{o=null,i()},JU))},keyup(u){n&&u===n&&c()},mods(u){n&&!QU(u,n)&&c()},end:c}}const t7=350,n7=80,r7=2e3;function o7(e,t=ST){let n=!1,r=null,o=null,i=null,l=null;const c=()=>{r&&(t.clear(r.pending),r=null)},u=()=>{i!==null&&t.clear(i),l!==null&&t.clear(l),i=null,l=null},h=()=>{c(),u(),o=null,n&&(n=!1,e(!1))};return{over(p){u(),l=t.set(h,r7),n||(n=!0,e(!0)),(r==null?void 0:r.id)!==(p==null?void 0:p.id)&&(c(),!(!p||p.id===o)&&(o=null,r={id:p.id,pending:t.set(()=>{r=null,o=p.id,p.land()},t7)}))},leave(){n&&(i!==null&&t.clear(i),i=t.set(h,n7))},end:h}}const Td=e=>e>999?"1k+":String(e);function _T({width:e,placement:t="strip"}){const n=t==="screen",r=vi(),o=L(Y=>Y.chatSide)==="left"?"right":"left",i=ut(),l=pt(),{host:c}=Lr(),u=kk(),h=u[0]&&yr(u[0].worktree)?u[0]:null,p=h?u.slice(1):u,m=L(Y=>ol(Y,Y.activeRepoId)),k=Y=>h&&Y.id===h.id&&m?{behind:m.behind,dirty:m.dirty}:Y,[,g]=_.useState(0);_.useEffect(()=>{const Y=setInterval(()=>g(pe=>pe+1),6e4);return()=>clearInterval(Y)},[]);const y=TL(),b=jL(),S=CL(),j=AL(),E=(Y,pe,nt)=>{Y.key!=="ArrowLeft"&&Y.key!=="ArrowRight"||Y.shiftKey||Y.altKey||Y.metaKey||Y.ctrlKey||(Y.preventDefault(),qf([{depth:0,open:pe}],0,Y.key)&&i({a:nt}))},N=ia(),A=L(Y=>Y.notesPage),O=L(Y=>Y.clientId),P=L(Y=>Y.frame),R=L(Y=>Y.activeRepoId),T=L(Y=>Y.connected);_.useEffect(()=>{l&&T&&R&&l.send({t:"list-archived",repoId:R})},[l,T,R]);const $=hl(),D=QE(),z=L(Y=>Y.layout),V=L(Y=>Y.railOpen),se=L(Y=>Y.railPeek),I=_.useRef(null),[ne,we]=_.useState(!1);gt([se],()=>{var Y;se&&!n&&!r&&!((Y=I.current)!=null&&Y.matches(":hover"))&&we(!0)}),_.useEffect(()=>{if(!ne)return;let Y=null;const pe=nt=>{if(!Y){Y={x:nt.clientX,y:nt.clientY};return}Math.abs(nt.clientX-Y.x)+Math.abs(nt.clientY-Y.y)<3||we(!1)};return window.addEventListener("pointermove",pe),()=>window.removeEventListener("pointermove",pe)},[ne]);const[K,B]=_.useState(!1),ee=_.useMemo(()=>o7(B),[]);_.useEffect(()=>()=>ee.end(),[ee]);const J=L(Y=>{var pe;return((pe=Y.dragFiles)==null?void 0:pe.at)==="rail"?Y.dragFiles.worktreeId:null}),W=L(Y=>Y.focusRail),ie=_.useRef(W),Te=_.useRef(null);gt([W],()=>{if(W===ie.current)return;ie.current=W;const Y=requestAnimationFrame(()=>{var pe,nt;return(nt=(pe=Te.current)==null?void 0:pe.querySelector('[data-state~="current"]'))==null?void 0:nt.focus()});return()=>cancelAnimationFrame(Y)});const Ce=L(Y=>Y.repos),de=L(Y=>Y.shipping),be=L(Y=>Y.rows),le=Y=>Ce.find(pe=>pe.id===Y.repoId)??null,G=Y=>R?uk(Y,R,be):null,ce=Y=>R&&Y.repoId!==R?le(Y):null,oe=bn("rail"),re=vk(),Le=L(Y=>Y.home),Ue=Y=>{const pe=Y.worktree?Y.worktree.path:Y.path;return Le&&pe.startsWith(`${Le}/`)?`~${pe.slice(Le.length)}`:pe},[_e,je]=_.useState(!1),[Ne,qe]=_.useState([]),Ft=Y=>{!Id(Y.worktree)||ce(Y)||(je(!0),qe(pe=>pe.includes(Y.worktree.id)?pe.filter(nt=>nt!==Y.worktree.id):[...pe,Y.worktree.id]))},qt=()=>{je(!1),qe([])};gt([_e],()=>{const Y=pe=>pe.key==="Escape"&&qt();return _e&&window.addEventListener("keydown",Y),()=>window.removeEventListener("keydown",Y)});const jt=Ck(l,i),Ht={sock:l,dispatch:i},sn=Y=>{je(!0),qe(pe=>Y===$||pe.includes(Y)?pe:[...pe,Y])},Ct=Y=>vn(Y)?WS(Y,le(Y),{layout:z,shipping:de,frame:P,repos:Ce},Ht,{...ce(Y)?{}:{graft:sn},hostname:c}):CD(Y,{clientId:O,frame:P},Ht,c),[He,Ze]=_.useState(null),At=Y=>vn(Y)?YU(Ct(Y)):[];dT(Te,{rowOf:Y=>{if(!n||_e)return null;const pe=Y.closest(".slide"),nt=pe==null?void 0:pe.dataset.row,dt=nt?u.find(Bt=>Bt.id===nt):void 0;return pe&&nt&&dt?{el:pe,key:nt,rungs:At(dt).length}:null},onSlide:Ze,onPick:(Y,pe)=>{var Bt;const nt=u.find(Ot=>Ot.id===Y),dt=nt?At(nt)[pe-1]:void 0;if(!(!nt||!dt)){if(dt.id==="more"){const Ot=(Bt=Te.current)==null?void 0:Bt.querySelector(`.slide[data-row="${Y}"]`);Ot&&oe.openUnder(Ot,()=>Ct(nt),Y)}else if(dt.item&&!dt.item.disabled){const Ot=dt.item.onClick;window.setTimeout(Ot,uT)}}}});const _t=qU(S,(N==null?void 0:N.id)??null),kt=_t.shown.some(Y=>(Y.dirty??0)>0),Fn=Y=>d.jsxs("button",{type:"button",className:Ke("row row-edge row-quiet rail-disc-item rail-arch-item",(re==null?void 0:re.owner)==="rail"&&re.key===Y.id&&"menu-open"),"data-state":vr({current:!n&&(N==null?void 0:N.id)===Y.id}),...Ut(mz(Y),void 0,{placement:o,card:!0,detail:WU(Y),aside:KU(Y)}),onClick:()=>i({a:"open-archived",id:Y.id}),...oe.contextMenu(()=>zd(Y,{clientId:O,frame:P},Ht),Y.id),children:[d.jsxs("span",{className:"rail-gut",onClick:r?pe=>{pe.stopPropagation(),oe.openUnder(pe.currentTarget,()=>zd(Y,{clientId:O,frame:P},Ht),Y.id)}:void 0,children:[d.jsx("span",{className:"rail-at row-dim",children:oo(Y.archivedAt)}),d.jsx("span",{className:"rail-more",...Ut("Actions"),onClick:pe=>{pe.stopPropagation(),oe.openUnder(pe.currentTarget,()=>zd(Y,{clientId:O,frame:P},Ht),Y.id)},children:d.jsx(St,{name:"more"})})]}),d.jsx("span",{className:"branch",children:Y.title}),kt&&d.jsx("span",{className:"rail-counts",children:d.jsx("span",{className:"rail-count row-dim","data-tip":Y.dirty?`${Y.dirty} uncommitted, kept`:void 0,children:Y.dirty?`~${Td(Y.dirty)}`:""})}),Y.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:oo(Y.archivedAt)})]},Y.id),un=[...u,...y].map(k),xn=["ahead","dirty","behind"].filter(Y=>un.some(pe=>(pe[Y]??0)>0)),$t=Y=>{const pe=xn.findIndex(nt=>(Y[nt]??0)>0);return new Set(pe<0?[]:xn.slice(pe))},Tn=Y=>{var Kt;const pe=vn(Y)?Y:null,nt=!!pe&&yr(pe.worktree),dt=k(Y),Bt=Ce.find(Qe=>Qe.id===Y.repoId)??null,Ot=Bt?Ef(Bt):"main",Ee=Bt&&YC(Bt)&&(m!=null&&m.fetchedAt)?` as of ${ZS(m.fetchedAt)}`:"",$e=$t(dt),Wt=!!dt.ahead&&!dt.dirty,ft=Y.id,Z=(re==null?void 0:re.owner)==="rail"&&re.key===ft,ge=pe?G(pe):null,Oe=pe?ce(pe):null,st=pe&&!Oe&&_e&&Id(pe.worktree)&&ft!==$,Et=yE(Y,(Kt=de[ft])==null?void 0:Kt.op),Mt=d.jsxs("button",{type:"button",className:Ke("row row-edge",pe?"rail-item":"row-quiet rail-disc-item",n&&BU(Y,Et)&&"row-quiet",Z&&"menu-open",J===ft&&"drop-over"),"data-state":vr({current:!n&&ft===$&&!N&&!A,checked:Ne.includes(ft)}),...pe?Ut(D?jc:Et?Jg(Et):Qg(Y,ef(le(pe))),void 0,{placement:o,card:!0,aside:VU(Y),detail:yr(pe.worktree)?HU(u,S,m,Ot):[...Oe?[ge?DU(Oe.name,ge.worktree.title):zU(Oe.name)]:[],...UU(pe)],dot:D?void 0:Et?"spinner":fi(Y)}):Ut(D?jc:Y.locked?`Held by ${Y.lockReason??"another tool"}`:LU,void 0,{placement:o,card:!0,detail:Ue(Y),dot:D||Y.locked?void 0:"discovered"}),"data-wt":ft,onKeyDown:Qe=>{var qn,an;if(!pe||_e||Qe.key!=="ArrowUp"&&Qe.key!=="ArrowDown"||Qe.altKey||Qe.ctrlKey||Qe.metaKey)return;Qe.preventDefault();const mn=Qe.key==="ArrowDown",Yt=u.findIndex(wn=>wn.id===ft),En=u[Yt+(mn?1:-1)];En&&(i({a:"activate",id:En.id}),(an=(qn=Te.current)==null?void 0:qn.querySelector(`[data-wt="${En.id}"]`))==null||an.focus())},onClick:Qe=>{pe&&!Oe&&(_e||Qe.shiftKey)?ft===$?je(!0):Ft(pe):nt&&!n?i({a:"open-draft"}):(i({a:"activate",id:ft}),pe&&!r&&i({a:"walked"}))},...oe.contextMenu(()=>Ct(Y),ft),children:[d.jsx("span",{className:"rail-gut",onClick:r&&!_e?Qe=>{Qe.stopPropagation(),oe.openUnder(Qe.currentTarget,()=>Ct(Y),ft)}:void 0,children:st?d.jsx("input",{type:"checkbox",className:"rail-graft-check",checked:Ne.includes(ft),readOnly:!0,tabIndex:-1}):!_e&&d.jsxs(d.Fragment,{children:[pe&&!nt&&d.jsx("span",{className:"rail-at row-dim",children:oo(Ja(pe.worktree))}),d.jsx("span",{className:"rail-more",...Ut("Actions"),onClick:Qe=>{Qe.stopPropagation(),oe.openUnder(Qe.currentTarget,()=>Ct(Y),ft)},children:d.jsx(St,{name:"more"})})]})}),nt?d.jsxs("span",{className:"branch rail-main-label",children:[d.jsx(St,{name:"plus",className:"icon-inline"}),"new worktree"]}):d.jsx("span",{className:Ke("branch",(pe==null?void 0:pe.worktree.unnamed)&&"row-dim"),children:jm(Y,pe?le(pe):null)}),(pe==null?void 0:pe.worktree.mode)&&pe.worktree.mode!=="auto"&&d.jsx("span",{className:"rail-badge badge-mode","data-tip":`${pe.worktree.mode} mode: the agent waits for you`,children:pe.worktree.mode}),pe&&(()=>{const Qe=le(pe),mn=BS(pe.worktree,Qe);return mn&&mn!==(Qe==null?void 0:Qe.config.defaultProfile)?d.jsx("span",{className:"rail-badge badge-profile","data-tip":`runs the ${mn} profile`,children:mn}):null})(),(pe==null?void 0:pe.worktree.variant)&&d.jsxs("span",{className:"rail-badge badge-variant clickable","data-tip":"Keep this variant, archive the others",onClick:Qe=>{Qe.stopPropagation(),jt.pickVariant(pe)},children:[d.jsxs("span",{className:"num",children:["v",pe.worktree.variant.index,"/",pe.worktree.variant.of]}),d.jsx("span",{className:"act",children:"pick"})]}),Oe&&d.jsx("span",{className:"rail-guest row-dim",children:Oe.name}),d.jsxs("span",{className:"rail-counts",children:[$e.has("ahead")&&d.jsx("span",{className:"rail-count badge-ahead","data-tip":dt.ahead?`${dt.ahead} ahead of ${Ot}`:void 0,children:dt.ahead?`+${Td(dt.ahead)}`:""}),$e.has("dirty")&&!Wt&&d.jsx("span",{className:"rail-count badge-dirty","data-tip":dt.dirty?`${dt.dirty} uncommitted${nt?" on main":""}`:void 0,children:dt.dirty?`~${Td(dt.dirty)}`:""}),$e.has("behind")&&d.jsx("span",{className:"rail-count rail-behind row-dim","data-tip":dt.behind?`${dt.behind} behind ${nt?"origin":Ot}${nt?"":Ee}`:void 0,children:dt.behind?Td(dt.behind):""}),n&&pe&&d.jsx("span",{className:"rail-at row-dim",children:nt?"":oo(Ja(pe.worktree))})]}),(()=>{if(Et)return d.jsx(il,{size:"dot"});if(Y.locked)return d.jsx("span",{className:"rail-glyph rail-lock row-dim",children:d.jsx(St,{name:"lock",className:"icon-inline"})});if(!pe)return d.jsx("span",{className:"dot discovered"});const Qe=_e||D?null:vE(Y.procs),mn=Y.unseen?" unseen":"",Yt=fi(Y);return nt&&!Qe&&Yt!=="crashed"&&!D?d.jsxs(d.Fragment,{children:[d.jsx("span",{className:`dot ${Yt} rail-main-dot`}),d.jsx("span",{className:"rail-glyph rail-main-strip",children:d.jsx(St,{name:"plus"})})]}):!Qe||Yt!=="crashed"?d.jsx("span",{className:`dot ${Yt}${mn}`}):d.jsx("span",{className:`dot crashed clickable${mn}`,...Ut(Qe.tip),onClick:En=>{En.stopPropagation(),i({a:"activate",id:ft}),i({a:"term-stream",id:ft,stream:Qe.stream})}})})(),n&&d.jsx("span",{className:"rail-say row-dim",children:wg(Y,{offline:D,needsSetup:ef(pe?le(pe):null),path:Ue(Y),op:Et})})]},ft);if(!n||!pe)return Mt;const ze=(He==null?void 0:He.key)===ft?He.step:null,Se=ze===null?null:At(Y)[Math.max(0,ze-1)],Ge=!!Se&&ze!==null&&ze>0&&(Se.id==="more"||!!Se.item&&!Se.item.disabled);return d.jsxs("div",{className:"slide","data-row":ft,children:[Mt,Se&&d.jsxs("span",{className:"slide-verb","data-rung":Ge?Se.id:void 0,"aria-hidden":"true",children:[d.jsx("span",{className:"slide-word",children:Se.label}),d.jsx(St,{name:Se.icon})]})]},ft)};return d.jsx("div",{ref:I,className:Ke("rail",n&&"rail-screen",!n&&(_e||(re==null?void 0:re.owner)==="rail"||se||K)&&"hold",ne&&"quiet",(n||V)&&"pinned",D&&"offline"),style:e!==void 0&&!n?{"--rail-width":`${e}px`}:void 0,onClick:r&&!n&&!V?Y=>{Y.target instanceof Element&&Y.target.closest("button, .rail-gut")||i({a:"toggle-rail"})}:void 0,onDragOver:Y=>{var Bt;if(!zm(Y.dataTransfer))return;const pe=Y.target instanceof Element?(Bt=Y.target.closest("[data-wt]"))==null?void 0:Bt.dataset.wt:void 0,nt=pe?[...u,...y].find(Ot=>Ot.id===pe):void 0;if(!nt||_e||nt.id===$)return ee.over(null);const dt=!n&&vn(nt)&&yr(nt.worktree);ee.over({id:nt.id,land:()=>i(dt?{a:"open-draft"}:{a:"activate",id:nt.id})})},onDragLeave:ee.leave,onDrop:ee.end,children:d.jsxs("div",{className:"rail-panel","data-tip":D?jc:void 0,"data-tip-placement":"follow",children:[d.jsxs("div",{className:"rail-list",ref:Te,children:[h&&!n&&Tn(h),p.map(Tn),_e&&d.jsxs("div",{className:"rail-graft",children:[(()=>{const Y=u.find(dt=>dt.worktree.id===$&&Id(dt.worktree)&&!ce(dt)),pe=Ne.filter(dt=>dt!==(Y==null?void 0:Y.worktree.id)),nt=pe.map(dt=>{var Bt;return((Bt=u.find(Ot=>Ot.worktree.id===dt))==null?void 0:Bt.worktree.title)??dt}).join(", ");return d.jsxs(De,{size:"md",tone:"primary",disabled:!Y||pe.length===0,"data-tip":Y?`Merge the checked worktrees into ${Y.worktree.title} and remove them`:"Select a worktree to graft onto",onClick:()=>{Y&&window.confirm(`Graft ${nt} onto ${Y.worktree.title}?
|
|
250
|
+
|
|
251
|
+
Their branches are merged in, then their directories and branches are removed.`)&&(l==null||l.send({t:"graft",targetId:Y.worktree.id,sourceIds:pe}),qt())},children:["graft ",pe.length]})})(),d.jsxs(De,{size:"md",disabled:!Ne.some(Y=>{var pe;return(((pe=u.find(nt=>nt.worktree.id===Y))==null?void 0:pe.behind)??0)>0}),"data-tip":"Pull main into every selected worktree that's behind",onClick:()=>{for(const Y of Ne){const pe=u.find(nt=>nt.worktree.id===Y);((pe==null?void 0:pe.behind)??0)>0&&ci(l,i,{t:"sync-main",worktreeId:Y})}qt()},children:[d.jsx(St,{name:"pull",className:"icon-inline"})," sync"]}),d.jsx(De,{size:"md",tone:"danger",disabled:Ne.length===0,"data-tip":"Archive all selected worktrees; their chats and work are kept",onClick:()=>{window.confirm(`Archive ${Ne.length} worktree(s)?
|
|
252
|
+
|
|
253
|
+
Their directories and branches go. The chats, commits and any uncommitted changes are kept, and each can be restored.`)&&(Ji(l,i,Ne),qt())},children:"archive…"}),d.jsx(Rt,{icon:"close",label:"Cancel",hint:"esc",onClick:qt})]}),!_e&&y.length>0&&d.jsxs(d.Fragment,{children:[d.jsxs("button",{className:"section-title section-row section-fold rail-disc-head","aria-expanded":b,...Ut(`${y.length} worktree${y.length===1?"":"s"} here that Toyon did not make`,void 0,{placement:o}),onClick:()=>i({a:"toggle-discovered"}),onKeyDown:Y=>E(Y,b,"toggle-discovered"),children:[d.jsx("span",{className:"rail-gut",children:d.jsx(St,{name:"caret",className:Ke("icon-inline disc-caret",!b&&"shut")})}),d.jsx("span",{className:"rail-label",children:"discovered"})]}),b&&y.map(Tn)]}),!_e&&S.length>0&&d.jsxs(d.Fragment,{children:[d.jsxs("button",{type:"button",className:"section-title section-row section-fold rail-disc-head","aria-expanded":j,...Ut(`${S.length} archived worktree${S.length===1?"":"s"}, kept with ${S.length===1?"its chat":"their chats"}`,void 0,{placement:o}),onClick:()=>i({a:"toggle-archived"}),onKeyDown:Y=>E(Y,j,"toggle-archived"),children:[d.jsx("span",{className:"rail-gut",children:d.jsx(St,{name:"caret",className:Ke("icon-inline disc-caret",!j&&"shut")})}),d.jsx("span",{className:"rail-label",children:"archived"})]}),j&&_t.shown.map(Fn),j&&_t.rest>0&&R&&d.jsxs("button",{type:"button",className:"row row-quiet rail-disc-item rail-arch-item",...Ut("Find an older one by its name, branch or first message",void 0,{placement:o}),onClick:()=>i({a:"open",overlay:{kind:"chats",names:!0}}),children:[d.jsx("span",{className:"rail-gut"}),d.jsxs("span",{className:"branch row-dim",children:[_t.rest," more"]}),d.jsx("span",{className:"dot"})]})]})]}),!n&&d.jsx("div",{className:"rail-foot",children:d.jsx(Rt,{icon:"worktrees",label:"Worktree panel",hint:Lt("rail"),tone:"chrome",on:V,onClick:()=>i({a:"toggle-rail"})})})]})})}function s7({screen:e,tabs:t,fold:n}){const r=ut(),o=Vo(),i=lo(),l=L(K=>K.reading),c=$L(),u=pl(),h=L(K=>K.repos),p=Rs(),m=hl(),k=ia(),g=wk(),y=kk(),b=QE(),S=ZE(),j=rP(y,m,S),E=y.find(K=>yr(K.worktree)),N=e==="home",A=!N&&!k&&!!p&&yr(p.worktree),O=L(K=>{var B;return A&&p?yE(p,(B=K.shipping[p.id])==null?void 0:B.op):null}),P=fk().length,R=o.displayName(i.origin),T=N?(c==null?void 0:c.name)??R:A?ET:(k==null?void 0:k.title)??(p==null?void 0:p.worktree.title)??(g==null?void 0:g.name)??null,$=y.filter(K=>!yr(K.worktree)).length,D=$===0?"no worktrees yet":`${$} ${$===1?"worktree":"worktrees"}`,z=N?c&&P>1?`${R} · ${D}`:D:k?a_(k):A?b?jc:O?Jg(O):(c==null?void 0:c.name)??null:p?wg(p,{offline:b,needsSetup:ef(u),path:p.worktree.path,at:oo(Ja(p.worktree))}):g?wg(g,{offline:b,needsSetup:!1,path:g.path}):null,V=!N&&!k&&!!p&&fi(p)==="waiting",se=L(K=>{var B;return((B=K.overlay)==null?void 0:B.kind)==="projects"&&K.overlay.form==="pill"}),I=L(K=>{var B;return((B=K.overlay)==null?void 0:B.kind)==="commands"}),ne=d.jsxs("div",{className:"phone-title",children:[N&&(h.length>1||P>1)?d.jsxs("span",{className:"phone-drop phone-switch",children:[d.jsxs(De,{tone:"chrome",on:se,onClick:()=>r({a:"toggle",overlay:{kind:"projects",form:"pill"}}),children:[d.jsx("span",{className:"phone-name",children:T}),d.jsx(St,{name:"caret",className:"icon-inline"})]}),se&&d.jsx(ww,{form:"pill",anchored:{margin:6}})]}):d.jsx("span",{className:"phone-name",children:T}),z&&d.jsx("span",{className:Ke("phone-sub",V&&"phone-sub-asks"),children:z})]}),we=j&&d.jsxs(De,{size:"md",tone:"primary",onClick:()=>{const K=oP(y,m,S);if(!K)return;if(K.origin===null)return r({a:"activate",id:K.activate});const B=o.get(K.origin);B&&(B.store.dispatch({a:"activate",id:K.activate}),o.activate(K.origin))},children:[j.n," ",j.tier]});return d.jsxs("div",{className:"phone-bar",children:[d.jsxs("div",{className:"phone-bar-row",children:[!N&&d.jsx(Rt,{icon:"back",label:"Worktrees",tone:"chrome",onClick:()=>r({a:"screen",to:"home"})}),t?d.jsx("div",{className:"phone-tabs",children:t}):ne,!t&&we,N&&E&&d.jsx(Rt,{icon:"plus",label:"New worktree",tone:"chrome",onClick:()=>r({a:"activate",id:E.id})}),d.jsxs("span",{className:"phone-drop",children:[d.jsx(Rt,{icon:"more",label:"Menu",tone:"chrome",on:I,onClick:()=>r({a:"toggle",overlay:{kind:"commands"}})}),I&&d.jsx(oT,{anchored:{flip:"align",margin:6},trailing:d.jsx(Rt,{icon:"close",label:"Close",tone:"chrome",onClick:()=>r({a:"close"})})})]})]}),t&&!n&&d.jsx("div",{className:"phone-title-seat","data-away":l||void 0,children:d.jsxs("div",{className:"phone-title-strip",children:[ne,we]})})]})}const Ud="toyonDepth",NT="toyonOver",am=-1;function lm(e){if(e.frame!=="phone"||!e.heard)return null;if(!(e.screen!=="home"&&(ko(e,e.activeId)!==null||Ao(e)!==null)))return 0;const n=pn(e,e.activeId)!==null&&!To(e)&&Ao(e)===null;return 1+(e.screen==="changes"||e.screen==="preview"&&n?1:0)+(e.editor?1:0)}const TT=(()=>{const e=new Set;return{watch(t){return e.add(t),()=>e.delete(t)},tell(t){for(const n of e)n(t)}}})(),cm=e=>{const t=e&&typeof e=="object"?e[Ud]:void 0;return typeof t=="number"?t:null},i7=e=>!!e&&typeof e=="object"&&e[NT]===!0;function jT(e,t=window,n=nf,r=TT){const o=t.history;let i=cm(o.state)??am,l=cm(o.state)!==null,c=null;const u=()=>{const N=n.open();c&&!N.includes(c)&&(c=null);for(let A=N.length-1;A>=0;A--){const O=N[A];if(O!=null&&O.dismiss&&O!==c)return O}return null};let h=!1;const p=()=>{const N=lm(e.getState());if(N===null||h)return;l||(o.replaceState({[Ud]:am},""),l=!0);const A=N+(u()?1:0);if(A!==i)if(A>i){for(let O=i+1;O<=A;O++)o.pushState({[Ud]:O,[NT]:O>N},"");i=A}else o.go(-1),h=!0};let m=!1;const k=()=>{m||(m=!0,queueMicrotask(()=>{m=!1,p()}))},g=(N,A,O)=>{const P=u();if(P){c=P,n.shut(P);return}const R=O===0?"home":N.editor&&O===A-1?N.screen:"chat";e.dispatch({a:"screen",to:R})},y=N=>{const A=h;h=!1,i=cm(N.state)??am;const O=e.getState(),P=lm(O);if(P===null)return;if(i<0){o.pushState({[Ud]:0},""),i=0,p();return}if(A){p();return}const R=P+(u()?1:0);R!==i&&(R>i?g(O,P,i):R===0&&O.activeId&&!i7(N.state)&&e.dispatch({a:"screen",to:"chat"}),p())},b=N=>{if(h){h=!1,p();return}const A=e.getState(),O=lm(A);O===null||O===0||A.screen==="preview"&&!A.editor&&O===2||N.dir==="forward"||g(A,O,O+(u()?1:0)-1)};t.addEventListener("popstate",y);const S=e.subscribe(p),j=n.watch(k),E=r.watch(b);return p(),()=>{t.removeEventListener("popstate",y),S(),j(),E()}}function a7({gated:e,active:t,url:n,hidden:r}){const o=ck(t),i=V4(lo(),o?n:null,e),l=_.useRef(null);return _.useEffect(()=>{if(!i)return;const c=new URL(i,location.href).origin,u=h=>{var m,k;if(h.source!==((m=l.current)==null?void 0:m.contentWindow)||h.origin!==c||!((k=h.data)!=null&&k.__toyon))return;const p=eE(h.data);(p==null?void 0:p.type)==="traversed"&&TT.tell({dir:p.dir??null})};return window.addEventListener("message",u),()=>window.removeEventListener("message",u)},[i]),d.jsx("div",{className:"phone-preview",hidden:r,children:o&&i?d.jsx("iframe",{ref:l,className:"phone-preview-frame",src:i,title:t.worktree.title}):d.jsx(fs,{wide:!0,children:d.jsx("p",{className:"status-line",children:Qg(t)})})})}const l7=Kg();function c7(){const e=_.useRef(null);EL(e),SL(e);const t=ut(),n=L(R=>R.screen),r=Rs(),o=ia(),i=wk(),l=L(R=>R.editor),c=L(R=>R.remote),u=Xc(),h=L(R=>R.connected),p=L(R=>R.heard),m=L(R=>R.connectFailure),k=vi(),g=lo(),y=Vo(),b=L(R=>R.incompatible),S=zS({connected:h,heard:p,connectFailure:m,hasToken:g.serving?l7:!0,projectChord:Lt("project"),title:(r==null?void 0:r.worktree.title)??null,machine:g.serving?null:y.displayName(g.origin)}),j=n!=="home"&&(r!==null||o!==null||i!==null),E=j&&!u&&!o?r:null,{host:N}=Lr(),A=E?Pd(E.worktree.id,E.worktree.proxyPort,c,N):null,O=n==="preview"&&!E?"chat":n,P=[{id:"chat",label:"chat"},...E&&A?[{id:"preview",label:"preview",trail:d.jsx(Rt,{icon:"external",label:"Open in browser",tone:"chrome",onClick:()=>Y4(g,A,Fm(g,c))})}]:[],{id:"changes",label:"code"}];return d.jsxs("div",{ref:e,className:"app phone","data-chat-side":"left","data-touch":k||void 0,"data-hover":!k||void 0,children:[d.jsx(RS,{}),d.jsx(PS,{}),d.jsx(s7,{screen:j?"chat":"home",fold:O!=="chat"||l!==null,tabs:j&&S===null&&d.jsx(Zf,{fill:!0,segmented:!0,owner:"phone-tabs",label:"worktree",items:P,current:O,onPick:R=>t({a:"screen",to:R})})}),d.jsx("div",{className:"phone-screen",children:d.jsxs("div",{className:"center-root",children:[b&&!g.serving?d.jsx(DS,{foreign:y.displayName(g.origin)}):S!==null?d.jsx(fs,{wide:!0,children:d.jsx("p",{className:"status-line",children:S})}):j?l?d.jsx(mT,{editor:l,placement:"screen"}):O==="chat"?d.jsx(Tc,{placement:"screen",archived:o,found:i}):O==="changes"?d.jsx(o_,{placement:"screen"}):null:d.jsx(_T,{placement:"screen"}),E&&A&&d.jsx(a7,{gated:Fm(g,c),active:E,url:A,hidden:O!=="preview"||l!==null},E.worktree.id),d.jsx(xT,{})]})})]})}const u7=640,d7=1e3,CT=`(max-width: ${u7}px), ((hover: none) and (max-width: ${d7}px))`,AT="(hover: none)",IT=()=>{var e;return(e=window.matchMedia)!=null&&e.call(window,CT).matches?"phone":"desk"},f7=()=>{var e;return((e=window.matchMedia)==null?void 0:e.call(window,AT).matches)??!1};function h7(e){const t=(o,i)=>{var u;const l=(u=window.matchMedia)==null?void 0:u.call(window,o);if(!l)return()=>{};const c=h=>i(h.matches);return l.addEventListener("change",c),()=>l.removeEventListener("change",c)},n=t(CT,o=>e.dispatch({a:"frame",v:o?"phone":"desk"})),r=t(AT,o=>e.dispatch({a:"touch",v:o}));return()=>{n(),r()}}function p7(){try{const e=localStorage.getItem(Xe.theme);if(e){const t=JSON.parse(e);if(t!=null&&t.colors&&typeof t.colors.surface0=="string")return t}}catch{}return Gc}function RT(e,t={}){var o;const n=document.documentElement;for(const[i,l]of Object.entries(xM(e)))n.style.setProperty(i,l);n.style.colorScheme=e.kind,n.dataset.theme=e.kind;const r=IT()==="phone"?e.colors.surface0:e.colors.surface1;if((o=document.querySelector('meta[name="theme-color"]'))==null||o.setAttribute("content",r),t.remember!==!1)try{localStorage.setItem(Xe.theme,JSON.stringify(e))}catch{}}function $T(e){const t=Ug(e);return{type:"theme",accent:t,accentFg:AM(t)}}function m7(){var e;return((e=window.matchMedia)==null?void 0:e.call(window,"(prefers-color-scheme: dark)").matches)??!0}const g7=12*36e5;function k7(){try{const e=localStorage.getItem(Xe.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<g7?{dark:!t.dark,until:0}:null}catch{return null}}function w7(e){try{localStorage.setItem(Xe.daylight,JSON.stringify(e))}catch{}}function y7(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 v7(e,t){return{word:`what's new in ${t}`,text:`Toyon updated from ${e} to ${t} since this browser last opened it. Press to read what changed`}}function b7(e,t,n){return n==="reading"?"Reading the release notes":n==="missing"?"No release notes could be read from this Toyon.":e!==null&&Wg(t,e)?`Toyon ${t} is running. This browser last opened ${e}; everything since is at the top.`:`Toyon ${t} is running. Every release, newest first.`}function x7(){const e=Lr(),t=ut(),n=L(u=>u.version),r=L(u=>u.ranBefore),[o,i]=_.useState(void 0);_.useEffect(()=>{let u=!0;return BM(e).then(h=>{u&&i(h)}),()=>{u=!1}},[e]);const l=_.useMemo(()=>o?ta(o.slice(Math.max(0,o.search(/^## /m)))):"",[o]),c=o===void 0?"reading":o===null?"missing":"ready";return d.jsxs(fs,{wide:!0,children:[d.jsx("p",{className:"status-line",children:b7(r,n,c)}),d.jsx("div",{className:"status-actions",children:d.jsx(De,{variant:"outline",size:"lg",onClick:()=>t({a:"close-release-notes"}),children:"close"})}),l&&d.jsx("div",{className:"md notes-md",onClick:u=>{const h=u.target.closest("a");h&&h.target!=="_blank"&&u.preventDefault()},dangerouslySetInnerHTML:{__html:l}})]})}function yg(e,t){return[{id:"copy-name",label:"copy name",detail:e,onClick:()=>Jt(e)},{id:"copy-value",label:"copy value",detail:t,onClick:()=>Jt(t)}]}function vg(e){return[{id:"copy-value",label:"copy value",detail:e,onClick:()=>Jt(e)}]}function E7(e,t,{sock:n},r){return t?Ln([[{id:"source",label:"open source",onClick:r}],ds(()=>n==null?void 0:n.send({t:"reveal",worktreeId:e.id,path:t}),Is(n)),[{id:"copy-path",label:"copy path",onClick:()=>Jt(t)}]]):[]}function Kc(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 S7(e){const t=/^#([0-9a-f]{3,8})$/i.exec(e.trim());return t?t[1].length===4||t[1].length===8:!1}function Kx([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 OT(e,t){if(S7(e))return null;const n=Kc(e);if(!n)return null;const r=Kc(t);if(!r)return null;const[o,i]=[Kx(n),Kx(r)];return`${((Math.max(o,i)+.05)/(Math.min(o,i)+.05)).toFixed(2)}:1`}function _7({worktreeId:e,height:t,full:n,onToggleFull:r,onDragStart:o}){const i=ut(),l=pt(),c=L(h=>Co(h,e).design);_.useEffect(()=>{c||l==null||l.send({t:"design-scan",worktreeId:e})},[c,e,l]),_.useEffect(()=>()=>cn.post(e,{type:"highlight-clear"}),[e]);const u={outline:h=>cn.post(e,h),clear:()=>cn.post(e,{type:"highlight-clear"}),open:h=>tr({dispatch:i},{worktreeId:e,path:h})};return d.jsx(kw,{kind:"design",className:Ke("design-pane",n&&"full"),height:n?void 0:t,resizable:!n,onDragStart:o,title:c?d.jsx("span",{children:C7(c)}):void 0,onClose:()=>i({a:"toggle-design"}),closeHint:Lt("design"),full:n,onToggleFull:r,actions:d.jsxs(De,{variant:"outline",onClick:()=>l==null?void 0:l.send({t:"design-scan",worktreeId:e}),"data-tip":"Scan this worktree again",children:[d.jsx(St,{name:"reload",className:"icon-inline"})," rescan"]}),children:c?d.jsxs("div",{className:"design-body",style:j7,onMouseLeave:u.clear,children:[c.tokens.length===0&&c.literals.length>0?d.jsx(M7,{literals:c.literals,outline:u.outline,clear:u.clear}):d.jsx($7,{tokens:c.tokens,coverage:c.coverage,outline:u.outline,clear:u.clear}),d.jsx(W7,{index:c,outline:u.outline,clear:u.clear,onOpen:u.open}),d.jsx(K7,{index:c,outline:u.outline,clear:u.clear,onOpen:u.open})]}):d.jsx("div",{className:"empty",children:"reading the design system…"})})}const N7=720,T7=132,j7={"--design-column":`${N7}px`,"--design-cell":`${T7}px`};function C7(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 Ka=e=>`${e} use${e===1?"":"s"}`;function th({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 vf({children:e}){return d.jsx("p",{className:"design-gap",children:e})}const A7=[{kind:"font",label:"type"},{kind:"color",label:"color"},{kind:"length",label:"size & radius"},{kind:"shadow",label:"shadow"},{kind:"other",label:"computed"}];function I7(e){return e.find(t=>t.kind==="color"&&Kc(t.resolved??t.value)!==null)}function R7(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 $7({tokens:e,coverage:t,outline:n,clear:r}){const o=I7(e),i=o&&(o.resolved??o.value),l=new Map;for(const u of e){const h=(u.resolved??u.value).trim().toLowerCase();l.set(h,[...l.get(h)??[],u.name])}const c=u=>(l.get((u.resolved??u.value).trim().toLowerCase())??[]).filter(h=>h!==u.name);return d.jsx(th,{title:"Tokens",children:e.length===0?d.jsx(vf,{children:R7(t)}):A7.map(({kind:u,label:h})=>{const p=e.filter(k=>k.kind===u);if(p.length===0)return null;const m=PT(p.map(k=>k.value));return d.jsxs("div",{className:"design-group",children:[u!=="font"&&d.jsx("span",{className:"design-group-name",children:h}),u==="font"?d.jsx(LT,{groups:F7(p),outline:n,clear:r}):d.jsx("div",{className:"design-breakout",style:MT(p.length),children:d.jsx("div",{className:"design-grid",children:p.map(k=>{const g=k.resolved??k.value,y=k.kind==="color"&&i?OT(g,i):null;return d.jsx(DT,{kind:k.kind,name:k.name,lines:k.resolved?[k.value,k.resolved]:[k.value],actual:g,ratio:y,largest:m,tipText:U7(k,y,o,c(k)),menu:()=>yg(k.name,g),outline:n,clear:r},k.name)})})})]},u)})})}const O7=[{role:"color",kind:"color",label:"color"},{role:"radius",kind:"length",label:"radius"},{role:"shadow",kind:"shadow",label:"shadow"}];function M7({literals:e,outline:t,clear:n}){const r=e.find(i=>i.ground&&Kc(i.value)!==null),o=B7(e);return d.jsxs(th,{title:"Values",note:"written out in the rules; no custom properties",children:[o.length>0&&d.jsx("div",{className:"design-group",children:d.jsx(LT,{groups:o,outline:t,clear:n})}),O7.map(({role:i,kind:l,label:c})=>{const u=e.filter(p=>p.role===i);if(u.length===0)return null;const h=PT(u.map(p=>p.value));return d.jsxs("div",{className:"design-group",children:[d.jsx("span",{className:"design-group-name",children:c}),d.jsx("div",{className:"design-breakout",style:MT(u.length),children:d.jsx("div",{className:"design-grid",children:u.map(p=>{const m=l==="color"&&r?OT(p.value,r.value):null;return d.jsx(DT,{kind:l,name:p.value,lines:[Ka(p.uses)],actual:p.value,ratio:m,largest:h,tipText:H7(p,m,r),menu:()=>vg(p.value),outline:t,clear:n},p.value)})})})]},i)})]})}function MT(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 PT(e){return e.reduce((t,n)=>Math.max(t,Math.abs(Number.parseFloat(n))||0),0)}const P7=["color","background-color","border-top-color","border-right-color","border-bottom-color","border-left-color","outline-color"];function L7(e,t){if(!e)return[];const n=getComputedStyle(e);return t.map(r=>[r,n.getPropertyValue(r)])}const bg=e=>(e.split(",")[0]??e).replace(/["']/g,"").trim();function D7(e){const t=/^[1-9]00\s+([\d.]+)px(?:\s*\/\s*([\d.]+)(px)?)?\s+(.+)$/.exec(e.trim());if(!t)return{family:bg(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:bg(t[4]??""),size:n,lead:o}}function um(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 z7(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 F7(e){const t=e.map(n=>({token:n,actual:n.resolved??n.value,...D7(n.resolved??n.value)}));return[...new Set(t.map(n=>n.family))].map(n=>{const r=t.filter(i=>i.family===n),o=r.find(i=>i.size===null);return{family:n,stack:o?o.actual:n,name:o==null?void 0:o.token.name,label:o?o.token.name:n,tipText:o?`${o.token.name}
|
|
254
|
+
${o.actual}`:void 0,menu:()=>o?yg(o.token.name,o.actual):[],rows:r.filter(i=>i.size!==null).sort((i,l)=>(l.size??0)-(i.size??0)).map(i=>({key:i.token.name,sample:`${i.family} ${i.size}${i.lead===null?"":`/${i.lead}`}`,style:{font:i.actual},name:i.token.name,label:i.token.name,tipText:`${i.token.name}
|
|
255
|
+
${i.actual}`,menu:()=>yg(i.token.name,i.actual)}))}})}function B7(e){const t=e.filter(o=>o.role==="family"),n=e.filter(o=>o.role==="size");return[...new Set([...t.map(o=>o.value),...n.map(o=>o.family??"initial")])].map(o=>{const i=t.find(c=>c.value===o),l=o==="initial"?"default face":bg(o);return{family:l,stack:o,name:i?Ka(i.uses):void 0,label:l,tipText:i?`${i.value}
|
|
256
|
+
${Ka(i.uses)}: ${i.selectors.join(", ")}`:void 0,menu:()=>i?vg(i.value):[],rows:n.filter(c=>(c.family??"initial")===o).sort((c,u)=>um(u.value)-um(c.value)).map(c=>{const u=um(c.value),h=z7(c.lead,u),p=c.value.endsWith("px")?`${u}`:c.value;return{key:`${c.value}/${c.lead??""}`,sample:`${l} ${p}${h===null?"":`/${h}`}`,style:{fontFamily:o,fontSize:c.value,lineHeight:c.lead},name:Ka(c.uses),label:c.value,tipText:`${c.value}${c.lead?` / ${c.lead}`:""}
|
|
257
|
+
${Ka(c.uses)}: ${c.selectors.join(", ")}`,menu:()=>vg(c.value)}})}})}function LT({groups:e,outline:t,clear:n}){const r=(i,l,c)=>t({type:"highlight-computed",props:L7(i.currentTarget.querySelector(".design-face-sample"),l?["font-family","font-size","line-height"]:["font-family"]),match:"all",label:c}),o=bn("design");return d.jsx("div",{className:"design-faces",children:e.map(i=>d.jsxs("div",{className:"design-face-group",children:[d.jsxs("div",{className:"design-face-head row-edge",onMouseEnter:l=>r(l,!1,i.label),onMouseLeave:n,...o.contextMenu(i.menu),...i.tipText?Ut(i.tipText,void 0,{placement:"follow"}):{},children:[d.jsx("span",{className:"design-face-sample design-face-family",style:{fontFamily:i.stack},children:i.family}),i.name&&d.jsx("span",{className:"design-face-name row-dim",children:i.name})]}),i.rows.map(l=>d.jsxs("div",{className:"design-face row-edge",onMouseEnter:c=>r(c,!0,l.label),onMouseLeave:n,...o.contextMenu(l.menu),...Ut(l.tipText,void 0,{placement:"follow"}),children:[d.jsx("span",{className:"design-face-sample",style:l.style,children:l.sample}),d.jsx("span",{className:"design-face-name row-dim",children:l.name})]},l.key))]},i.stack))})}function DT({kind:e,name:t,lines:n,actual:r,ratio:o,largest:i,tipText:l,menu:c,outline:u,clear:h}){const p=e==="color"&&Kc(r)!==null,m=e==="length"?Number.parseFloat(r):Number.NaN,k=bn("design");return d.jsxs("div",{className:"design-cell","data-kind":e,...k.contextMenu(c),onMouseEnter:p?g=>{const y=g.currentTarget.querySelector(".design-fill"),b=y?getComputedStyle(y).backgroundColor:"";u({type:"highlight-computed",props:P7.map(S=>[S,b]),match:"any",label:t})}:void 0,onMouseLeave:p?h:void 0,...Ut(l),children:[e==="color"&&d.jsx("div",{className:"design-sample",children:p&&d.jsx("span",{className:"design-fill",style:{background:r}})}),d.jsxs("div",{className:"design-plate",children:[d.jsx("span",{className:"design-cell-name",children:t}),n.map((g,y)=>d.jsxs("span",{className:"design-cell-line",children:[d.jsx("span",{className:"design-cell-value",children:g}),y===0&&o&&d.jsx("span",{className:"design-cell-note",children:o})]},g)),Number.isFinite(m)&&i>0&&d.jsx("span",{className:"design-scale",style:{width:`${Math.max(2,Math.abs(m)/i*100)}%`}})]})]})}function U7(e,t,n,r=[]){const o=[e.name,e.resolved?`${e.value} resolves to ${e.resolved}`:e.value];if(r.length>0&&o.push(`same value as ${r.join(", ")}`),t&&n){const i=e.name===n.name;o.push(i?"the ground these ratios are measured against":`${t} against ${n.name}`)}return o.join(`
|
|
258
|
+
`)}function H7(e,t,n){const r=[e.value,`${Ka(e.uses)}: ${e.selectors.join(", ")}`];return t&&n&&r.push(e===n?"the page background these ratios are measured against":`${t} against the page background`),r.join(`
|
|
259
|
+
`)}function zT({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 W7({index:e,outline:t,clear:n,onOpen:r}){const{components:o,typed:i}=e;if(o.length===0)return null;const l=o.filter(h=>h.imports>=2),c=o.filter(h=>h.imports<2),u=h=>d.jsx(FT,{count:h.imports,name:h.name,path:h.path,onEnter:()=>t({type:"highlight-file",path:h.path,ranges:null}),onLeave:n,onOpen:()=>r(h.path),children:h.variants.length>0&&d.jsx("span",{className:"design-variants",children:h.variants.map(p=>d.jsxs("span",{className:"design-variant",children:[p.prop,": ",p.values.join(" · ")]},p.prop))})},`${h.path}:${h.name}`);return d.jsxs(th,{title:"Components",note:`${l.length} reused of ${o.length}`,children:[!i&&d.jsx(vf,{children:"No TypeScript in this project, so the values each prop allows are not listed."}),d.jsx(zT,{shared:l.map(u),rest:c.map(u)})]})}function K7({index:e,outline:t,clear:n,onOpen:r}){const{classes:o,coverage:i}=e,l=o.filter(k=>k.uses>0),c=o.filter(k=>k.uses>=2),u=o.filter(k=>k.uses<2),h=c.filter(k=>k.unwrapped).length,p=o.length?`${c.length} reused of ${o.length}`+(h?`, ${h} with no component of their name`:""):void 0,m=k=>d.jsx(Z7,{cls:k,outline:t,clear:n,onOpen:r},k.name);return d.jsx(th,{title:"Classes",note:p,children:o.length===0?d.jsx(vf,{children:"No stylesheet in this project defines a class. Utility-first CSS generates its own."}):l.length===0?d.jsx(vf,{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(zT,{shared:c.map(m),rest:u.map(m)})})}function Z7({cls:e,outline:t,clear:n,onOpen:r}){return d.jsx(FT,{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 FT({count:e,name:t,path:n,onEnter:r,onLeave:o,onOpen:i,children:l}){const c=Rs(),u=pt();ut();const h=bn("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?E7({id:c.worktree.id},n,{sock:u},i):[]),children:[d.jsx("span",{className:"design-count row-dim",children:e}),d.jsx("span",{className:"design-name",children:t}),d.jsx("span",{className:"design-path row-dim",children:n}),l]})})}function q7({worktreeId:e,procs:t,borrowed:n,login:r,current:o,onRestart:i}){const l=pt();ut();const c={sock:l},u=(p,m)=>d.jsx(Rt,{icon:"reload",label:m,onClick:()=>i(p)}),h={id:Cs,label:"login",tip:Ut("The agent's login; it closes once you are in",void 0,{placement:"top"}),trail:u(Cs,"Run the login again")};return r&&o===Cs?[h]:[{id:_o,label:"shell",tip:Ut("A shell in this worktree",void 0,{placement:"top"}),menu:()=>yN(e,c),trail:u(_o,"Restart the shell")},...r?[h]:[],...t.map(p=>({id:p.name,label:p.name,lead:d.jsx("span",{className:`dot ${p.status}`}),tip:Ut(vP(p.status),void 0,{placement:"top",dot:p.status,name:p.name,detail:p.command,aside:[`:${p.port}`]}),menu:()=>ow(p,e,c),trail:u(p.name,`Restart ${p.name}`)})),...n.map(p=>({id:p,label:p,lead:d.jsx("span",{className:"dot borrowed"}),tip:Ut(`${p} runs on main for every worktree; this one reaches it at its usual address`,void 0,{placement:"top"})}))]}const G7=_.lazy(()=>pg(()=>import("./XTerm-ClBPMY5e.js"),__vite__mapDeps([3,4]))),V7=[];function Y7({worktreeId:e,opened:t,height:n,onDragStart:r}){const o=ut(),i=pt(),l=Df(),c=L(z=>z.connected),u=L(z=>z.focusTerm),h=Rs(),p=(h==null?void 0:h.procs)??[],m=(h==null?void 0:h.borrowed)??V7,k=(h==null?void 0:h.login)??!1,g=It(e,"termStream"),y=L(z=>{var V;return((V=z.termRun)==null?void 0:V.id)===e&&g===_o?z.termRun.command:null}),[b,S]=_.useState(null),j=m.includes(g);_.useEffect(()=>{g===_o||(g===Cs?k:p.some(V=>V.name===g)||m.includes(g))||o({a:"term-stream",id:e,stream:_o})},[p,m,k,g,e,o]);const E=z=>{z!==g&&(S(null),o({a:"term-stream",id:e,stream:z}))},N=_.useRef(!1),[A,O]=_.useState(0),P=z=>{z===_o&&z===g&&(N.current=!0),i==null||i.send({t:"term-restart",worktreeId:e,stream:z}),z===Cs&&z===g&&(S(null),O(V=>V+1))},R=(z,V)=>{if(z)return S(null);if(N.current){N.current=!1,O(se=>se+1);return}S({code:V})},T=q7({worktreeId:e,procs:p,borrowed:m,login:k,current:g,onRestart:P}),$=_.useRef(!t),D=!$.current;return _.useEffect(()=>{$.current=!1},[]),d.jsxs(kw,{kind:"terminal",className:"term-pane",height:n,onDragStart:r,tabs:{items:T,current:g,onPick:E,font:"mono",owner:"terminal",label:"terminal streams"},onClose:()=>o({a:"toggle-terminal"}),closeHint:Lt("terminal"),children:[d.jsxs("div",{className:"term-body",children:[j&&d.jsx(Mc,{pane:!0,title:`${g} 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:[g]}),children:"run it here"})}),d.jsx(jk,{pane:!0,children:d.jsx(_.Suspense,{fallback:d.jsx("div",{className:"empty",children:"loading terminal…"}),children:d.jsx(G7,{worktreeId:e,stream:g,theme:l,sock:i,connected:c,focusOnMount:D,focusReq:u,onAlive:R,run:y,onRan:()=>o({a:"term-ran"}),onEscape:()=>o({a:"toggle-terminal"})},`${g}:${A}`)})})]}),b!==null&&!j&&d.jsx(Mc,{pane:!0,title:g===_o?"the shell exited":g===Cs?"the login did not finish":`${g} exited`,body:b.code===void 0?void 0:`exit code ${b.code}`,action:d.jsx(De,{variant:"outline",onClick:()=>P(g),children:"restart"})})]})}function X7(e){return e==="reserved"?"checking out a fresh worktree…":e==="warming"?"copying dependencies and running setup…":"starting dev servers…"}const Q7="preview off; it starts when the agent writes a file";function J7({worktree:e,log:t}){const n=pt(),r=ut(),o=e.procs,i=b=>n==null?void 0:n.send({t:"term-restart",worktreeId:e.id,stream:b.name}),l=o.some(b=>b.status==="crashed"||b.status==="unreachable"),c=L(b=>b.clientId),u=Dc(e,"setup"),h=u&&u.status!=="terminated"?u:null,p=Qi(Mk(h??void 0)?h==null?void 0:h.since:void 0),m=!!e.worktree.parked&&o.length===0,k=()=>n==null?void 0:n.send({t:"preview-start",worktreeId:e.id}),g=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(fs,{wide:!0,children:[o.length===0?d.jsx("div",{className:"status-line",children:h?d.jsx("span",{className:"live-text","data-tip":e_[h.status],children:Hm("setup",h,p)}):m?Q7:X7(e.worktree.phase)}):d.jsx("ul",{className:"boot-procs",children:o.map(b=>d.jsxs("li",{className:Ke("boot-proc",(b.status==="crashed"||b.status==="unreachable")&&"boot-bad"),children:[d.jsx("span",{className:"boot-name",children:b.name}),d.jsx("span",{className:"boot-status",children:eH(b)}),(b.status==="crashed"||b.status==="unreachable")&&d.jsx(De,{variant:"outline",onClick:()=>i(b),children:"restart"}),b.detail&&b.status!=="asleep"&&d.jsx("div",{className:"boot-detail",children:b.detail})]},b.name))}),m&&d.jsx("div",{className:"status-actions",children:d.jsx(De,{variant:"outline",size:"lg",onClick:k,children:"start preview"})}),g&&d.jsx("div",{className:"status-actions",children:d.jsx(De,{variant:"outline","data-tip":t_("setup"),onClick:()=>n==null?void 0:n.send({t:"run-stop",worktreeId:e.id,kind:"setup"}),children:"stop setup"})}),l&&d.jsxs("div",{className:"status-actions",children:[e.agent==="idle"&&d.jsx(De,{variant:"outline",size:"lg",onClick:y,children:"ask the agent to fix it"}),d.jsx(De,{onClick:()=>r({a:"open",overlay:{kind:"setup",repoId:e.repoId}}),children:"edit setup"})]}),t.length>0&&d.jsx("pre",{className:"status-tail",children:t.slice(-30).map(b=>`[${b.proc}] ${b.line}`).join(`
|
|
260
|
+
`)})]})}function eH(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 tH(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 nH(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 rH({active:e}){const t=ut(),n=pt(),r=pl(),o=L(c=>c.home),i=e.worktree.title,l=()=>{r!=null&&r.made&&(t({a:"new-project",v:{...ik({mode:r.made==="git"?"init":"create",name:r.name,parent:xN(r.path,o)??r.path}),phase:"unmaking",repoId:r.id}}),t({a:"move-box",from:e.worktree.id,to:rl}),n==null||n.send({t:"unmake-repo",repoId:r.id}))};return d.jsx(fs,{anchor:"line",foot:d.jsx("div",{className:"composer view-foot",children:d.jsx(Nc,{active:e,greenfield:!0})}),children:d.jsx("p",{className:"form-title",children:r!=null&&r.made?d.jsx(De,{variant:"inline",onClick:l,...Ut("Rename or move this project"),children:i}):i})})}function oH({pending:e}){const t=ut(),n=pt(),r=!!e.error,o=()=>{n==null||n.send({t:"cancel-import",id:e.id}),t({a:"watch-import",id:null})},i=_.useRef(null);return _.useEffect(()=>{var l;return(l=i.current)==null?void 0:l.scrollTo({top:i.current.scrollHeight})},[e.lines.length]),d.jsxs(fs,{wide:!0,children:[d.jsxs("p",{className:"status-line",children:[r?"could not import":"importing"," ",e.name]}),d.jsxs("p",{children:["from ",d.jsx("code",{children:e.url})," into ",d.jsx("code",{children:e.parent})]}),r?d.jsx("p",{className:"import-error",children:e.error}):d.jsx("p",{className:"hint",children:"the whole history is cloned, so worktrees, land and graft all work on it straight away."}),d.jsx("div",{className:"status-tail",ref:i,children:e.lines.length===0&&!r?d.jsx("span",{className:"import-idle",children:"starting git…"}):e.lines.map((l,c)=>d.jsx("div",{children:l},c))}),d.jsx("div",{className:"status-actions",children:d.jsx(De,{variant:"outline",size:"lg",onClick:o,children:r?"dismiss":"stop"})})]})}const sH=150,iH=/^[^\s@]+@[^\s@]+$/,aH=14;function lH({project:e}){var ee;const t=ut(),n=pt(),r=L(J=>J.repos),o=L(J=>J.home),i=L(J=>J.folderDialog),l=L(J=>J.gitIdentity),c=L(J=>J.choosingFolder),u=L(J=>J.chosenFolder),h=L(J=>J.paths),[p,m]=_.useState({name:"",email:""}),[k,g]=_.useState(null),y=_.useRef(null),{mode:b,name:S,parent:j}=e,E=b==="clone",N=b==="init",A=e.phase==="editing",O=S.trim(),P=N||!O?null:$c(S),R=!N&&O&&!P?bN(j,O):null,T=rg(j,o),$=R!==null&&h.query===R&&((ee=h.target)==null?void 0:ee.exists)===!0,D=!l&&!E,z=!D||p.name.trim()!==""&&iH.test(p.email.trim()),V=A?k?"the folder you chose is already a project: open it, or choose another":!N&&!O?"name the project first":P??($?`${T} already has a folder called ${O}`:z?null:"git needs your name and email first"):null;_.useEffect(()=>{if(!R)return;const J=setTimeout(()=>n==null?void 0:n.send({t:"browse-path",path:R}),sH);return()=>clearTimeout(J)},[R,n]),gt([e.phase],()=>{var J;e.phase==="editing"&&((J=y.current)==null||J.focus())}),gt([e.error],()=>{e.error&&t({a:"notice",id:rl,text:e.error})});const se={sock:n,dispatch:t},I=()=>{V||!A||(t({a:"new-project-set",v:{phase:"creating"}}),Bc(se,{t:"create-repo",mode:b,parent:j.trim(),name:O,...E&&e.url?{url:e.url}:{},...D?{identity:{name:p.name.trim(),email:p.email.trim()}}:{}}))},ne=J=>{const W=r.find(ie=>ie.path===ll(J,o));W?t({a:"activate-repo",id:W.id}):Bc(se,{t:"register-repo",path:J})},we=J=>{const W=sw(J);t({a:"new-project-set",v:{mode:"init",parent:W.parent,name:W.name}})},K=J=>{i?(t({a:"choosing-folder",v:J}),n==null||n.send({t:"choose-folder",start:j,purpose:J})):t(J==="location"?{a:"open",overlay:{kind:"choose-folder"}}:{a:"open",overlay:{kind:"projects",form:"disk"}})};gt([u==null?void 0:u.seq],()=>{var W,ie;if(!c||!u)return;t({a:"choosing-folder",v:!1});const J=u.folder;if(!J){(W=y.current)==null||W.focus();return}if(c==="open"){J.kind==="project"?ne(J.path):D?we(J.path):EN(se,J.path);return}if(g(J.kind==="project"?J.path:null),J.kind!=="project"){if(J.kind==="empty"&&!E){we(J.path);return}t({a:"new-project-set",v:{mode:E?"clone":"create",parent:J.path}}),(ie=y.current)==null||ie.focus()}});const B=N?"the folder you chose becomes the project":k?null:$?`${T} already has a folder called ${O}`:P;return d.jsxs(fs,{anchor:"line",foot:d.jsx("div",{className:"composer view-foot",children:d.jsx(Nc,{active:null,project:{name:O,why:V,busy:!A,create:I}})}),children:[E&&d.jsx("p",{className:"new-project-url",children:e.url}),d.jsxs("div",{className:"form-head",children:[N?d.jsx("p",{className:"form-title",children:S}):d.jsx(jo,{ref:y,bare:!0,font:"lead",className:"new-project-field",autoFocus:!0,spellCheck:!1,autoComplete:"off",value:S,placeholder:"Project name",disabled:!A,style:{width:`${Math.max(S.length+1,aH)}ch`},onChange:J=>t({a:"new-project-set",v:{name:J.target.value}}),onKeyDown:J=>{J.key==="Enter"&&(J.preventDefault(),t({a:"focus-chat"}))}}),d.jsxs("span",{className:"new-project-where",children:[d.jsx("span",{className:"hint",children:"in"}),d.jsx("span",{className:"new-project-parent",...Ut(j),children:T}),d.jsx(Rt,{icon:"folder",label:i?"Choose in Finder":"Choose a folder",className:"new-project-folder",on:c==="location",disabled:!A,onClick:()=>K("location")})]})]}),B&&d.jsx("p",{className:"hint",children:B}),k&&d.jsxs("p",{className:"hint",children:["the folder you chose is already a project:"," ",d.jsx(De,{variant:"inline",autoFocus:!0,onClick:()=>ne(k),children:"open it"}),", or choose another"]}),D&&d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"new-project-identity",children:[d.jsx(jo,{size:"md",font:"ui",rule:!0,value:p.name,placeholder:"Your name",autoComplete:"name",disabled:!A,onChange:J=>m({...p,name:J.target.value})}),d.jsx(jo,{size:"md",font:"ui",rule:!0,type:"email",value:p.email,placeholder:"Email",autoComplete:"email",disabled:!A,onChange:J=>m({...p,email:J.target.value})})]}),d.jsx("p",{className:"hint",children:"git labels the work you save with these, and asks only once"})]}),!E&&A&&d.jsx(De,{tone:"quiet",className:"new-project-open",onClick:()=>K("open"),children:"or open a folder you already have"})]})}function La({label:e,hint:t,children:n}){return d.jsxs("label",{className:"form-row",children:[d.jsx("span",{className:"form-label",children:e}),d.jsxs("div",{className:"form-control",children:[n,t&&d.jsx("span",{className:"hint",children:t})]})]})}function cH(e,t,n){const r=[n.envUrl?`\`${n.envUrl.name}\` in \`${n.envUrl.file}\``:null,n.compose?`the compose stack in \`${n.compose}\``:null].filter(Boolean).join(" and ");return[`Toyon runs several worktrees of this repo (${e.name}) at once, each with its own copy of the code, and right now they would all share ${r}: a migration run in one worktree changes the database every other worktree is using.`,"",`Give each worktree its own. Every command Toyon runs gets \`TOYON_WORKTREE\` (the worktree's id, empty in the main checkout, which never runs setup) and \`TOYON_ROOT\` (the main checkout). Edit \`${t}\` so that:`,'- `setup` makes the worktree\'s own database with the same schema and seed data. Postgres refuses to copy a database with connections open, so copy from a template nothing serves: `createdb -T <db>_template "<db>_$TOYON_WORKTREE"`, making `<db>_template` once from the seed if it does not exist. Keep it seed-sized, since every worktree copies it. A hosted database that branches (the repo already uses one, or its README says so) gets a branch named for the worktree instead. A compose stack: bring it up under `-p "<name>_$TOYON_WORKTREE"` and seed it the way the README does.',"- `teardown` drops it again (`dropdb --if-exists ...`, the branch deleted, or `docker compose -p ... down -v`).","- the running commands point at it, with the base database in the main checkout: put the URL in front of the command in `run`, or in a profile's `env`, named `<db>${TOYON_WORKTREE:+_$TOYON_WORKTREE}`. `setup` does not see what `run` sets, so a migration step in `setup` needs the URL in front of it too.",'- a database container the worktrees share (each with its own database inside it) is marked `{ "cmd": ..., "from": "trunk", "paths": [] }` in `run`, so the main checkout runs it once for everyone.',"","Read the README and the existing env files for the database's name and credentials. Do not run any migration yourself, and do not start any server; Toyon picks the file up as soon as it is written."].join(`
|
|
261
|
+
`)}function uH(e,t){return[`This repo (${e.name}) has no Toyon settings yet, so Toyon does not know how to install its dependencies or start its dev server.`,"",`Work it out from the repo itself (package manager, scripts, framework, a README) and write \`${t}\` in this shape:`,"```json",'{ "setup": ["<install command>"], "run": { "web": "<start command>" } }',"```",'`setup` runs once in each new worktree. A worktree starts with the branch\'s files only: `node_modules` and the `.env` files are copied in for it, but any other gitignored file the project needs (a local database, a test cache such as `.testmondata`) is not, so add a `cp` from `$TOYON_ROOT`, the main checkout, when you find one in `.gitignore`. Never copy a virtualenv or another dependency tree that holds absolute paths; reinstall it instead. Every command in `run` must run in the foreground and listen on the port in the PORT environment variable, which Toyon sets per worktree; a tool that takes its port from a flag needs the flag (Vite: `--port $PORT --strictPort`, and with npm the `--` before it). Name one entry per server if there are several. If the project has nothing to run (a library, a CLI), write `"run": {}` and say so. Do not start any server yourself; toyon picks the file up as soon as it is written.'].join(`
|
|
262
|
+
`)}let dH=1;const dm=(e,t,n=!1)=>({id:dH++,name:e,cmd:t,shared:n}),fH=[{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 hH({repo:e,onClose:t}){const n=pt(),r=Zn(),o=L(le=>le.clientId),i=L(le=>le.rows.find(G=>{var ce;return vn(G)&&G.id===((ce=ol(le,e.id))==null?void 0:ce.id)})??null),l=L(le=>{var G;return((G=ol(le,e.id))==null?void 0:G.id)??null});_.useEffect(()=>{if(!t)return;const le=G=>G.key==="Escape"&&t();return window.addEventListener("keydown",le),()=>window.removeEventListener("keydown",le)},[t]);const[c]=_.useState(()=>Object.keys(e.config.run).length>0),[u,h]=_.useState(()=>{const le=Object.entries(e.config.run).map(([G,ce])=>dm(G,c1(ce),CC(ce)));return le.length>0?le:[dm("web","")]}),[p,m]=_.useState(()=>(e.config.setup??[]).join(`
|
|
263
|
+
`)),[k,g]=_.useState(()=>(e.config.teardown??[]).join(`
|
|
264
|
+
`)),[y,b]=_.useState(()=>e.config.check??""),[S,j]=_.useState(()=>ai(e.config).land),[E,N]=_.useState(()=>ai(e.config).automerge),[A,O]=_.useState(()=>ai(e.config).merge??"default"),[P,R]=_.useState(()=>RC(e.configFile)),T=$C(e.configFile,P),$=!!e.remote&&S==="pr",D=u.length>1,z=u.some(le=>le.name.trim()&&le.cmd.trim()),se=!!i&&!t&&!c&&!z,I=(le,G)=>h(u.map((ce,oe)=>oe===le?{...ce,...G}:ce)),ne=le=>le.split(`
|
|
265
|
+
`).map(G=>G.trim()).filter(Boolean),we=()=>ne(p),K=()=>ne(k),B=()=>{const{check:le,land:G,teardown:ce,...oe}=e.config,re=e.remote?S:gm,Le=A==="default"||re!=="pr"&&A===km?void 0:A,Ue={...re!==gm?{route:re}:{},...re==="pr"&&E?{automerge:!0}:{},...Le?{method:Le}:{}};return{...oe,setup:we(),...K().length>0?{teardown:K()}:{},...y.trim()?{check:y.trim()}:{},...Object.keys(Ue).length>0?{land:Ue}:{}}},ee=()=>{n==null||n.send({t:"confirm-config",repoId:e.id,config:{...B(),run:Object.fromEntries(u.filter(le=>le.name.trim()&&le.cmd.trim()).map((le,G)=>[le.name.trim(),le.shared&&G>0?{cmd:le.cmd.trim(),from:"trunk"}:le.cmd.trim()]))},kind:P}),t==null||t()},J=()=>{n==null||n.send({t:"confirm-config",repoId:e.id,config:{...B(),run:{}},kind:P}),t==null||t()},W=()=>n==null?void 0:n.send({t:"create-worktree",clientId:o,repoId:e.id,prompt:uH(e,T)}),ie=e.services,Te=[p,k,...u.map(le=>le.cmd)].some(le=>le.includes("TOYON_WORKTREE"))||AC(e.config),Ce=ie?[ie.envUrl?`the database at ${ie.envUrl.name} in ${ie.envUrl.file}`:null,ie.compose?`the stack in ${ie.compose}`:null].filter(Boolean).join(" and "):"",de=()=>ie&&(n==null?void 0:n.send({t:"create-worktree",clientId:o,repoId:e.id,prompt:cH(e,T,ie)})),be=(le,G)=>d.jsxs("div",{className:"setup-proc",children:[D&&d.jsx(jo,{size:"md",rule:!0,className:"setup-name",value:le.name,placeholder:"name",...Ut("Process name, shown in the status bar"),onChange:ce=>I(G,{name:ce.target.value})}),d.jsx(jo,{size:"md",rule:!0,className:"setup-cmd",value:le.cmd,placeholder:"npm run dev",onChange:ce=>I(G,{cmd:ce.target.value})}),D&&d.jsx(Rt,{icon:"close",label:"Remove",onClick:()=>h(u.filter((ce,oe)=>oe!==G))}),D&&G>0&&d.jsx(hT,{className:"setup-shared",checked:le.shared,onChange:ce=>I(G,{shared:ce.target.checked}),tip:"Main runs it once for every worktree; a worktree whose changes touch it runs its own",children:"shared from main"})]},le.id);return d.jsxs(fs,{children:[d.jsxs("p",{className:"form-title",children:["how does ",e.name," start?"]}),ie&&!Te&&d.jsxs("p",{className:"hint setup-shared-note",children:["Worktrees will share ",Ce,", migrations included."," ",d.jsx(De,{tone:"quiet",disabled:!i,onClick:de,children:"ask the agent to keep them apart"})]}),d.jsx(La,{label:"install",hint:"once per new worktree; one command per line",children:d.jsx(Lc,{size:"md",rule:!0,rows:Math.max(1,p.split(`
|
|
266
|
+
`).length),value:p,placeholder:"bun install",onChange:le=>m(le.target.value)})}),d.jsx(La,{label:"remove",hint:"once when a worktree goes, before its directory does; one command per line",children:d.jsx(Lc,{size:"md",rule:!0,rows:Math.max(1,k.split(`
|
|
267
|
+
`).length),value:k,placeholder:'dropdb --if-exists "app_$TOYON_WORKTREE"',onChange:le=>g(le.target.value)})}),d.jsx(La,{label:"check",hint:"runs after each of the agent's turns; the work lands only when it passes",children:d.jsx(jo,{size:"md",rule:!0,value:y,placeholder:"bun run check",onChange:le=>b(le.target.value)})}),e.remote&&d.jsx(La,{label:"land",hint:"where a worktree's finished work goes; one way per repo",children:d.jsxs("div",{className:"setup-land",children:[d.jsx(ii,{value:S,options:qC.map(le=>({id:le.id,label:le.name,description:le.description})),onChange:j,hint:"where the work goes",placeholder:"where work lands"}),$&&d.jsx(ii,{value:E?"github":"you",options:VC.map(le=>({id:le.id,label:le.name,description:le.description})),onChange:le=>N(le==="github"),hint:"who merges the pull request",placeholder:"who merges it"})]})}),d.jsx(La,{label:"merge",hint:$?"how GitHub merges the pull request; only what the repo allows":"how the commits arrive on main",children:d.jsx(ii,{value:A==="default"&&!$?km:A,options:[...$?[{id:"default",label:"what the repo allows",description:"the repo's allowed methods on GitHub: squash, else a merge commit, else rebase"}]:[],...GC.map(le=>({id:le.id,label:le.name,description:le.description}))],onChange:O,hint:"how the commits arrive on main",placeholder:"how the commits arrive"})}),d.jsx(La,{label:"start",hint:d.jsxs(d.Fragment,{children:["must listen on ",d.jsx("code",{...Ut("Toyon sets a different port for each worktree"),children:"$PORT"}),e.guess&&l&&d.jsxs(d.Fragment,{children:[" · from ",d.jsx(De,{mono:!0,tone:"quiet",...Ut(`open ${e.guess} in the editor pane`),onClick:()=>ea(r,n,l,e.guess??"",1),children:e.guess})]})]}),children:u[0]&&be(u[0],0)}),u.slice(1).map((le,G)=>d.jsxs("div",{className:"form-row",children:[d.jsx("span",{className:"form-label"}),d.jsx("div",{className:"form-control",children:be(le,G+1)})]},le.id)),d.jsxs("div",{className:"form-row",children:[d.jsx("span",{className:"form-label"}),d.jsxs(De,{tone:"quiet",onClick:()=>h([...u,dm("","")]),children:[d.jsx(St,{name:"plus",className:"icon-inline"})," another process"]})]}),d.jsxs("div",{className:"form-knobs",children:[d.jsx(ii,{value:P,options:fH,onChange:R,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:T}),t&&d.jsx(De,{onClick:t,children:"cancel"}),(!c||t)&&d.jsx(De,{...Ut("This project has no dev server: chat, changes and the terminal work, the preview stays empty"),onClick:J,children:"no dev server"}),se&&i?d.jsx(De,{variant:"outline",size:"lg",disabled:i.agent!=="idle",...Ut("The agent reads the repo and writes the settings file; the daemon picks it up as soon as it lands"),onClick:W,children:"let the agent work it out"}):d.jsxs(De,{variant:"outline",size:"lg",disabled:!z,...t?Ut("Restarts every worktree of this repo. Profiles and other keys in the file are kept."):{},onClick:ee,children:[t?"save + restart":"start"," ",d.jsx(St,{name:"forward",className:"icon-inline"})]})]})]})}function pH(e){return`${Math.round(e.w)} × ${Math.round(e.h)}`}function mH(e){return e.w>0&&e.h>0}function gH(e,t,n){_.useEffect(()=>{if(!e||!t){n(null);return}const r=new ResizeObserver(o=>{var c;const i=(c=o[o.length-1])==null?void 0:c.contentRect;if(!i)return;const l={w:i.width,h:i.height};n(mH(l)?pH(l):null)});return r.observe(e),()=>{r.disconnect(),n(null)}},[e,t,n])}const kH=1500,wH={set:(e,t)=>setTimeout(e,t),clear:e=>clearTimeout(e)};class yH{constructor(t,n,r=wH){zt(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=w0(r));const i=If(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)},kH)}title(t,n){const r=this.frame(t);r.title=w0(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 vH=Kg(),bH=2*6e4;function Zx(e){e==null||e.setAttribute("src",e.src)}const xH=8e3,jd="render:",EH=6e3,SH=1500;function qx(e,t){try{const n=new URL(e,t);return n.origin===new URL(t).origin?n.href:null}catch{return null}}function _H({onRoot:e}){const t=_.useRef(null),n=_.useCallback(Q=>{t.current=Q,e(Q)},[e]),r=ut(),o=Zn(),i=pt(),l=_.useRef(i);l.current=i;const[c]=_.useState(()=>new yH((Q,ke,tt)=>{var at,dn;(at=l.current)==null||at.send({t:"visit",worktreeId:Q,path:ke,title:tt}),EE((dn=o.getState().local[Q])==null?void 0:dn.pages)&&cn.post(Q,{type:"links"})},(Q,ke,tt)=>{var at;return(at=l.current)==null?void 0:at.send({t:"page-title",worktreeId:Q,path:ke,title:tt})}));_.useEffect(()=>()=>c.dispose(),[c]);const u=JE(),h=hl(),p=Rs(),m=L(Q=>Q.connected),k=L(Q=>Q.heard),g=L(Q=>Q.connectFailure),y=L(Q=>Q.remote),{host:b}=Lr(),S=lo(),j=Vo(),E=L(Q=>Q.editor),N=tS(),A=ML(),O=L(Q=>Q.notesPage),P=Yc(),R=L(Q=>Q.layout.term)&&!P,T=L(Q=>Q.focusTerm),$=_.useRef(!1),D=_.useRef(T),z=!$.current||T!==D.current;_.useEffect(()=>{$.current=R&&!!h,D.current=T});const V=Xc(),se=L(Q=>Q.layout.design)&&!P&&!V,I=L(Q=>Q.reloadReq),ne=Df(),we=_.useRef(ne);we.current=ne;const K=L(Q=>Q.zen),B=L(Q=>{var ke;return((ke=Q.dragFiles)==null?void 0:ke.at)==="centre"}),ee=_.useRef(K);ee.current=K;const J=It(h,"log"),W=L(Q=>Q.incompatible),ie=LL(),Te=L(Q=>{var ke;return((ke=Q.overlay)==null?void 0:ke.kind)==="setup"?Q.repos.find(tt=>tt.id===Q.overlay.repoId)??null:null}),Ce=(p==null?void 0:p.worktree.empty)===!0,de=!!p&&Vc(p),be=ie&&!Ce&&!de?ie:null,le=be??Te,G=L(Q=>Q.pending.find(ke=>ke.id===Q.activeImportId)??null),[ce,oe]=_.useState([]),re=L(Q=>Q.renders),Le=_.useRef(new Map),Ue=_.useCallback((Q,ke,tt)=>{var at;clearTimeout(ke.timer),Le.current.delete(Q),(at=l.current)==null||at.send({t:"rendered",worktreeId:ke.worktreeId,id:Q,errors:ke.errors.slice(0,x2),...ke.url?{url:ke.url.slice(0,E2)}:{},...ke.title?{title:ke.title.slice(0,b2)}:{},...tt}),r({a:"render-done",id:Q})},[r]),_e=_.useRef((Q,ke)=>{});_e.current=(Q,ke)=>{const tt=Le.current.get(Q);if(tt)switch(ke.type){case"frame-load":clearTimeout(tt.timer),tt.timer=setTimeout(()=>Ue(Q,tt,{ok:!0}),SH);break;case"loaded":tt.url=ke.url,tt.title=ke.title;break;case"navigated":tt.url=ke.url,ke.title!==void 0&&(tt.title=ke.title);break;case"title":tt.title=ke.title;break;case"page-error":tt.errors.push(C0(ke));break}},_.useEffect(()=>{for(const Q of re){if(Le.current.has(Q.id))continue;const ke={worktreeId:Q.worktreeId,errors:[]};Le.current.set(Q.id,ke);const tt=u.find(at=>at.id===Q.worktreeId);if(!tt||!vn(tt)){Ue(Q.id,ke,{ok:!1,reason:"this tab has no preview for that worktree"});continue}if(!qx(Q.path,Pd(tt.worktree.id,tt.worktree.proxyPort,y,b))){Ue(Q.id,ke,{ok:!1,reason:"not a route of the preview"});continue}ke.timer=setTimeout(()=>Ue(Q.id,ke,{ok:!1,reason:"the page did not load"}),EH)}},[re,u,y,b,Ue]),_.useEffect(()=>()=>{for(const Q of Le.current.values())clearTimeout(Q.timer)},[]);const je=_.useRef(new Map),Ne=_.useRef(new Map),[qe,Ft]=_.useState([]),qt=_.useRef(new Set),jt=_.useRef(new Set),Ht=_.useRef(Q=>Zx(je.current.get(Q)));_.useEffect(()=>{cn.post=(Q,ke)=>{var tt,at;if(ke.type==="reload"&&qt.current.has(Q))return Ht.current(Q);(at=(tt=je.current.get(Q))==null?void 0:tt.contentWindow)==null||at.postMessage({__toyon:!0,...ke},Ne.current.get(Q)??"*")},cn.broadcast=Q=>{var ke;for(const[tt,at]of je.current)(ke=at.contentWindow)==null||ke.postMessage({__toyon:!0,...Q},Ne.current.get(tt)??"*")}},[]),_.useEffect(()=>{let Q=null;const ke=dn=>{dn.target instanceof HTMLElement&&dn.target.tagName!=="IFRAME"&&(Q=dn.target)},tt=dn=>{dn.relatedTarget===null&&setTimeout(()=>{document.activeElement===document.body&&(Q=null)},0)},at=dn=>{var Gt,Tr,Vn,Cn,rn;if((Gt=dn.data)!=null&&Gt.__toyon)for(const[ve,Ve]of je.current){if(Ve.contentWindow!==dn.source)continue;if(dn.origin!==Ne.current.get(ve))return;const We=eE(dn.data);if(!We)return;if(ve.startsWith(jd)){_e.current(ve.slice(jd.length),We);return}switch(We.type){case"key":window.dispatchEvent(new KeyboardEvent(We.up?"keyup":"keydown",{key:We.key,code:We.code,metaKey:We.meta,ctrlKey:!!We.ctrl,shiftKey:!!We.shift,altKey:!!We.alt}));break;case"hmr":r({a:"hmr",id:ve}),(Tr=l.current)==null||Tr.send({t:"page-loaded",worktreeId:ve});break;case"loaded":qt.current.delete(ve),jt.current.add(ve),Ft(mt=>mt.includes(ve)?mt:[...mt,ve]),cn.post(ve,$T(we.current)),cn.post(ve,{type:"zen",on:ee.current}),r({a:"hmr",id:ve}),r({a:"page",id:ve,url:We.url,title:We.title}),(Vn=l.current)==null||Vn.send({t:"page-loaded",worktreeId:ve}),c.note(ve,We.url,We.title);break;case"navigated":r({a:"page",id:ve,url:We.url,...We.title!==void 0?{title:We.title}:{}}),c.note(ve,We.url,We.title);break;case"title":r({a:"page",id:ve,title:We.title}),c.title(ve,We.title);break;case"links":r({a:"links",id:ve,links:We.links});break;case"page-error":{const mt=C0(We);mt&&((Cn=l.current)==null||Cn.send({t:"page-error",worktreeId:ve,message:mt}));break}case"picked":{const{type:mt,verb:ln,site:yn,...H}=We,me=yn==="call"?{file:H.callFile,line:H.callLine}:{file:H.file,line:H.line};if(ln==="code"){r({a:"set-picking",v:!1});const Be=(rn=pn(o.getState(),ve))==null?void 0:rn.worktree;me.file?ea(o,i,ve,wE(me.file,Be==null?void 0:Be.path),me.line??1):i==null||i.send({t:"find-element",worktreeId:ve,seq:Zo(),element:H.element})}else k4(o,ve,H);break}case"pick-cancel":r({a:"set-picking",v:!1});break;case"drag-files":We.over?Nk(o,o.getState().activeId?{at:"centre"}:null):vS(o);break;case"drop-files":TS(o,i,o.getState().activeId?{at:"centre"}:null,U4(We.files));break;case"focus":We.gesture?Q=null:document.activeElement===Ve&&(Q!=null&&Q.isConnected)&&Q!==document.body&&Q.focus();break;case"highlight-miss":console.warn(`[toyon] highlight miss on ${We.path}: ${We.fileMatched} elements from this file, ${We.withSource} elements with source info on page, ranges=${JSON.stringify(We.ranges)}`);break}return}};return window.addEventListener("message",at),document.addEventListener("focusin",ke),document.addEventListener("focusout",tt),()=>{window.removeEventListener("message",at),document.removeEventListener("focusin",ke),document.removeEventListener("focusout",tt)}},[r,o,i,c]),_.useEffect(()=>{cn.broadcast({type:"zen",on:K})},[K]);const sn=_.useRef(new Map);gt([I==null?void 0:I.id,I==null?void 0:I.n],()=>{if(!I)return;const{id:Q}=I;clearTimeout(sn.current.get(Q)),sn.current.set(Q,setTimeout(()=>{sn.current.delete(Q),cn.post(Q,{type:"reload"})},1200))});const Ct=gk(),He=Ct&&!vn(Ct)?Ct:null,Ze=ia(),At=!!p&&p.procs.some(Q=>Q.status==="running"),_t=yk(),kt=_t!==null&&_t===h&&At;_.useEffect(()=>{_t&&kt&&!ce.includes(_t)&&oe(Q=>[...Q,_t])},[_t,kt,ce]);const Fn=u.filter(Q=>vn(Q)&&Q.procs.some(ke=>ke.status==="asleep")).map(Q=>Q.id).join(" ");_.useEffect(()=>{const Q=new Set(Fn.split(" ").filter(Boolean));ce.some(ke=>Q.has(ke))&&oe(ke=>ke.filter(tt=>!Q.has(tt)))},[Fn,ce]),_.useEffect(()=>{const Q=ce.filter(ke=>ke!==_t).map(ke=>setTimeout(()=>oe(tt=>tt.filter(at=>at!==ke)),bH));return()=>{for(const ke of Q)clearTimeout(ke)}},[ce,_t]),_.useEffect(()=>{Ft(Q=>Q.every(ke=>ce.includes(ke))?Q:Q.filter(ke=>ce.includes(ke)))},[ce]);const un=_.useMemo(()=>u.filter(vn).filter(Q=>ce.includes(Q.id)).map(Q=>({id:Q.worktree.id,port:Q.worktree.proxyPort,title:Q.worktree.title,url:Pd(Q.worktree.id,Q.worktree.proxyPort,y,b)})),[u,ce,y,b]),xn=_.useMemo(()=>re.flatMap(Q=>{const ke=u.find(at=>at.id===Q.worktreeId);if(!ke||!vn(ke))return[];const tt=qx(Q.path,Pd(ke.worktree.id,ke.worktree.proxyPort,y,b));return tt?[{id:`${jd}${Q.id}`,path:Q.path,url:tt}]:[]}),[re,u,y,b]),$t=Fm(S,y),Tn=_.useMemo(()=>[...un,...xn],[un,xn]),Y=AS(S,Tn,$t);Ht.current=Q=>$t?Y.renew(Q):Zx(je.current.get(Q));const pe=un.filter(Q=>{var ke;return(ke=u.find(tt=>tt.id===Q.id))==null?void 0:ke.procs.some(tt=>tt.status==="running")}).map(Q=>Q.id).join(" ");gt([pe],()=>{for(const Q of pe.split(" "))qt.current.has(Q)&&Ht.current(Q)});const nt=L(Q=>Q.carryTo),[dt,Bt]=_.useState(null),[Ot,Ee]=_.useState(_t),$e=_.useRef(null);Ot!==_t&&(Ee(_t),Bt(tH({leaving:$e.current,arriving:_t,carryTo:nt,repoOf:Q=>{var ke;return((ke=u.find(tt=>tt.id===Q))==null?void 0:ke.repoId)??null}}))),_.useEffect(()=>{if(!dt)return;const Q=setTimeout(()=>Bt(null),xH);return()=>clearTimeout(Q)},[dt]);const Wt=_t!==null&&qe.includes(_t),ft=nH({previewId:_t,painted:Wt,ready:kt,carry:dt,mounted:ce}),Z=ft!==null&&ft!==_t;_.useEffect(()=>{$e.current=ft});const ge=ft!==null&&!le&&!G&&!O&&!P&&!V,[Oe,st]=_.useState(null),Et=_.useCallback(Q=>r({a:"preview-size",text:Q}),[r]);gH(Oe,ge,Et);const[Mt,ze]=No(Xe.editorHeight,0,Q=>{const ke=Number(Q);return Number.isFinite(ke)&&ke>=120?ke:0}),[Se,Ge]=No(Xe.designHeight,0,Q=>{const ke=Number(Q);return Number.isFinite(ke)&&ke>0?ke:0}),[Kt,Qe]=No(Xe.designFull,!1,Q=>Q===null?void 0:Q==="1"),[mn,Yt]=No(Xe.editorFull,!1,Q=>Q===null?void 0:Q==="1"),[En,qn]=No(Xe.termHeight,240,Q=>{const ke=Number(Q);return Number.isFinite(ke)&&ke>=140?ke:void 0}),an=L(Q=>Q.termTall);gt([an],()=>{const Q=t.current;an&&Q&&qn(Math.max(En,Math.round(Q.clientHeight/2)))});const wn=Q=>(ke,tt)=>{const at=tt.parentElement,dn=t.current;if(!at||!dn)return null;let Gt=0;for(const Vn of Array.from(dn.querySelectorAll(":scope > .pane")))Vn!==at&&!Vn.classList.contains("full")&&(Gt+=Vn.offsetHeight);const Tr=Math.max(dn.clientHeight-Gt-80,Q);return Math.min(Math.max(at.getBoundingClientRect().bottom-ke.clientY,Q),Tr)},mr=Xa(wn(120),Q=>ze(Math.round(Q))),Mn=Xa(wn(160),Q=>Ge(Math.round(Q))),tn=Xa(wn(140),Q=>qn(Math.round(Q))),Gn=L(Q=>{var ke,tt;return p&&yr(p.worktree)?((tt=(ke=Q.rows.find(at=>{var dn;return at.repoId===p.worktree.repoId&&((dn=at.worktree)==null?void 0:dn.kind)==="worktree"}))==null?void 0:ke.worktree)==null?void 0:tt.title)??null:null}),nn=TD({connected:m,heard:k,connectFailure:g,hasToken:S.serving?vH:!0,projectChord:Lt("project"),title:(p==null?void 0:p.worktree.title)??null,machine:S.serving?null:j.displayName(S.origin),needsSetup:!!ie,busy:de,treeEmpty:Ce,landsFrom:Gn});return d.jsxs("div",{className:"center-root",ref:n,children:[d.jsx("div",{className:Ke("center-area",B&&"drop-over"),style:{display:!(K&&!V)&&!Ze&&!O&&(E&&mn||se&&Kt)?"none":void 0},children:d.jsxs("div",{className:"frames-wrap",ref:st,children:[un.map(Q=>d.jsx("iframe",{ref:ke=>{ke?(je.current.set(Q.id,ke),Ne.current.set(Q.id,new URL(Q.url).origin)):(je.current.delete(Q.id),Ne.current.delete(Q.id),qt.current.delete(Q.id),jt.current.delete(Q.id))},onLoad:()=>{jt.current.delete(Q.id)?qt.current.delete(Q.id):qt.current.add(Q.id)},src:Y.urlOf(Q.id)??void 0,title:Q.title,style:{display:ge&&Q.id===ft?"block":"none"}},Q.id)),xn.map(Q=>d.jsx("iframe",{ref:ke=>{ke?(je.current.set(Q.id,ke),Ne.current.set(Q.id,new URL(Q.url).origin)):(je.current.delete(Q.id),Ne.current.delete(Q.id))},onLoad:()=>_e.current(Q.id.slice(jd.length),{type:"frame-load"}),src:Y.urlOf(Q.id)??void 0,title:`checking ${Q.path}`,style:{display:"none"}},Q.id)),A?d.jsx(lH,{project:A}):O?d.jsx(x7,{}):d.jsxs(d.Fragment,{children:[G&&d.jsx(oH,{pending:G},G.id),N&&p&&!G&&d.jsx(rH,{active:p},p.worktree.id),le&&!G&&!N&&d.jsx(hH,{repo:le,onClose:be?void 0:()=>r({a:"close"})},`${le.id}:${JSON.stringify(le.config)}`),He&&!le&&!G&&!Ze&&d.jsx(Tc,{placement:"centre",found:He},He.id),Ze&&!le&&!G&&d.jsx(Tc,{placement:"centre",archived:Ze},Ze.id),!At&&!He&&!Ze&&!le&&!G&&!N&&W&&d.jsx(DS,{foreign:S.serving?void 0:j.displayName(S.origin)}),!At&&!He&&!Ze&&!le&&!G&&!N&&!W&&(nn!==null?d.jsx(fs,{wide:!0,children:d.jsx("p",{className:"status-line",children:nn})}):V?d.jsx(Tc,{placement:"centre"}):Z?null:p&&d.jsx(J7,{worktree:p,log:J}))]})]})}),E&&d.jsx(mT,{editor:E,height:mn?"100%":Mt>0?Mt:"45%",full:mn,onToggleFull:()=>Yt(!mn),onDragStart:mr}),se&&h&&!Ze&&!O&&d.jsx(_7,{worktreeId:h,height:Kt?"100%":Se>0?Se:"55%",full:Kt,onToggleFull:()=>Qe(!Kt),onDragStart:Mn},`design:${h}`),R&&h&&!Ze&&!O&&d.jsx(Y7,{worktreeId:h,opened:z,height:En,onDragStart:tn},`term:${h}`),d.jsx(xT,{})]})}function NH({width:e}){const t=L(r=>r.layout.chat),n=Yc();return d.jsx(Tc,{placement:"dock",className:!t||n?"collapsed":void 0,width:e})}function TH(e,t){const n=[];return e&&(n.push(aS(e)),n.push({id:"copy-url",label:"copy URL",onClick:()=>Jt(e)})),Ln([n,[{id:"reload",label:"reload preview",key:Lt("reload"),onClick:t.reload}]])}const jH=520,fm=8;function CH({winW:e,centre:t,leadRight:n,toolsLeft:r}){const o=t.right-t.left,i=Math.max(0,Math.min(jH,Math.floor(e*.4),o-2*fm)),l=t.left+(o-i)/2,c=n+fm,u=r-fm-i,h=Math.max(Math.min(l,u),c);return{left:Math.round(h),width:i}}function AH({center:e}){const t=wL(),n=XE(e),r=_.useRef(null);_L(r);const[o,i]=Z0(),[l,c]=Z0(),u=CH({winW:t,centre:n,leadRight:i.right,toolsLeft:c.left}),h=ut(),p=pt(),m=Zn(),k=bn("bar"),g=Rs(),y=Xc(),b=L(V=>V.zen)&&!y,S=L(V=>V.layout.changes),j=L(V=>V.layout.chat),E=Yc(),N=L(V=>V.layout.design),A=L(V=>{var se;return((se=V.overlay)==null?void 0:se.kind)==="keys"}),O=zN(),P=(g==null?void 0:g.worktree.id)??null,R=L(V=>V.archivedPage!==null||V.notesPage),T=!!g&&ck(g)&&!R,$=L(V=>V.chatSide)==="left",D=!E&&d.jsx(Rt,{icon:"branch",label:"Changes panel",hint:Lt("changes"),tone:"chrome",on:S,onClick:()=>h({a:"toggle-changes"})}),z=!E&&!y&&d.jsx(Rt,{icon:"chat",label:"Chat panel",hint:Lt("composer"),tone:"chrome",on:j,onClick:()=>h({a:"toggle-chat"})});return d.jsxs("div",{className:"top-bar",ref:r,children:[b&&d.jsx("span",{className:"bar-zen-title",children:(g==null?void 0:g.worktree.title)??"Toyon"}),d.jsxs("span",{className:"bar-lead",ref:o,children:[$?z:D,d.jsx(IH,{}),O&&d.jsx(ru,{icon:"download","data-tip":"Install Toyon as an app (own window, dock icon)",onClick:()=>void O.prompt(),children:"install app"}),d.jsx($H,{}),d.jsx(OH,{}),d.jsx(MH,{})]}),!y&&d.jsx(RH,{worktreeId:P,repoId:(g==null?void 0:g.repoId)??null,ready:T,left:u.left,width:u.width}),d.jsx("span",{className:"bar-grow"}),d.jsxs("span",{className:"bar-tools",ref:l,children:[d.jsx(PH,{}),d.jsx(Rt,{icon:"settings",label:"Settings & shortcuts",hint:Lt("keys"),tone:"chrome",on:A,"aria-controls":"keys-help","aria-expanded":A,onClick:()=>h({a:"toggle",overlay:{kind:"keys"}}),...k.contextMenu(()=>SN(m.getState(),{sock:p,dispatch:h}))}),!E&&!y&&d.jsx(Rt,{icon:"palette",label:"Design system",hint:Lt("design"),tone:"chrome",on:N,onClick:()=>h({a:"toggle-design"})}),$?D:z,!y&&d.jsx(Rt,{icon:"zen",className:"bar-zen",label:"Full-bleed preview",hint:Lt("zen"),tone:"chrome",on:b,onClick:()=>h({a:"toggle-zen"})})]})]})}function IH(){const e=ut(),t=pt(),n=pl(),r=L(p=>p.activeRepoId),o=L(p=>p.repos),i=bn("bar"),l=()=>Ln([[{id:"project",label:o.length>1?"switch project…":"open project…",key:Lt("project"),onClick:()=>e({a:"open",overlay:{kind:"projects",form:"pill"}})},{id:"project-disk",label:"find a project on disk…",onClick:()=>e({a:"open",overlay:{kind:"projects",form:"disk"}})}],n?Jf(n,r,{sock:t,dispatch:e}):[]]),c=L(p=>{var m;return((m=p.overlay)==null?void 0:m.kind)==="projects"&&p.overlay.form==="pill"}),u=L(p=>p.heard),h=L(p=>p.newProject!==null);return d.jsxs("span",{className:"bar-project",children:[d.jsx(De,{tone:"chrome",className:"bar-pill",on:c,...Ut(o.length>1?"Switch project":"Open a project",Lt("project")),onClick:()=>e({a:"toggle",overlay:{kind:"projects",form:"pill"}}),...i.contextMenu(l),children:d.jsx("span",{className:"bar-project-name",children:h?"new project":(n==null?void 0:n.name)??(u?"open project":"")})}),c&&d.jsx(ww,{form:"pill"})]})}function RH({worktreeId:e,repoId:t,ready:n,left:r,width:o}){const i=It(e,"page").url,l=ut(),c=L(g=>{var y;return((y=g.overlay)==null?void 0:y.kind)==="routes"}),u=L(g=>g.previewSize);gt([e,n],()=>{c&&l({a:"close"})});const p=bn("bar").contextMenu(()=>n?TH(i,{reload:()=>e&&cn.post(e,{type:"reload"})}):[]),m=L(g=>g.picking),k=yk();return d.jsxs("div",{className:"bar-center",style:{left:r,width:o},children:[d.jsx(Rt,{icon:"back",label:"Back",hint:Lt("back"),disabled:!n,onClick:()=>e&&cn.post(e,{type:"back"}),...p}),d.jsx(Rt,{icon:"forward",label:"Forward",hint:Lt("forward"),disabled:!n,onClick:()=>e&&cn.post(e,{type:"forward"}),...p}),d.jsx(Rt,{icon:"reload",label:"Reload preview",hint:Lt("reload"),disabled:!n,onClick:()=>e&&cn.post(e,{type:"reload"}),...p}),d.jsxs("span",{className:"bar-route",children:[n&&e&&t?d.jsx(g9,{worktreeId:e,repoId:t,url:i,open:c},e):d.jsx(jo,{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:Lt("inspect"),also:{text:"Add an element to chat",key:Lt("pick")},on:m==="code",disabled:!n||!k,onClick:()=>k&&Pc(k,m,l,"code")})]})}function ru({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:Ke(t&&"live-text"),children:n})]})}function $H(){const e=L(u=>u.self),t=L(u=>u.rebuilt),n=L(u=>u.repos),r=pt(),o=L(u=>{var h;return((h=u.update)==null?void 0:h.restarting)!=null}),i=gT(e,n,t);if(!i||o)return null;const l=i.busy?"rebuilding":i.reload?"reload Toyon":i.build==="rebuild"?"rebuild Toyon":i.build??"restart Toyon",c=()=>{i.reload?window.location.reload():e&&(r==null||r.send(i.build?{t:"run-after-land",repoId:e.repoId}:{t:"restart-daemon"}))};return d.jsx(ru,{icon:"reload",busy:i.busy,onClick:c,...Ut(i.text,void 0,{detail:i.detail}),children:l})}function OH(){const e=L(o=>o.update),t=L(o=>o.managed.updates),n=pt(),r=vD(e);return!r||!t?null:d.jsx(ru,{icon:"reload",busy:r.busy,onClick:()=>{r.retry&&(n==null||n.send({t:"update-now"}))},...Ut(r.text),children:r.word})}function MH(){const e=ut(),t=L(WP),n=L(l=>l.ranBefore),r=L(l=>l.newProject!==null);if(!t||!n||r)return null;const{word:o,text:i}=v7(n,t);return d.jsx(ru,{icon:"book",onClick:()=>e({a:"open-release-notes"}),...Ut(i),children:o})}function PH(){const e=ut(),t=L(nL),n=L(i=>i.letIn),r=L(i=>{var l;return((l=i.overlay)==null?void 0:l.kind)==="devices"});if(!t)return null;const o=()=>e({a:"toggle",overlay:{kind:"devices"}});return n?d.jsx(Rt,{icon:"devices",label:"Your devices",tone:"chrome",on:r,"aria-expanded":r,onClick:o}):d.jsx(ru,{icon:"devices","aria-expanded":r,onClick:o,...Ut("Open this machine on your phone, and let it in"),children:"open on phone"})}function LH(e,t,n){return t==="left"?n-e.left:e.right-n}const DH="input, textarea, [contenteditable], .monaco-editor, .xterm, iframe";function zH(){const e=Zn(),t=ut(),n=pt(),r=Yc(),o=vi(),i=Xc(),l=L(ee=>ee.zen)&&!i,c=ia(),u=L(ee=>ee.notesPage),h=!!wk()||!!c||u,p=L(ee=>ee.layout.changes)&&!r,m=L(ee=>ee.layout.chat)&&!r&&!i&&!h,k=L(ee=>ee.chatSide),g=L(ee=>ee.railOpen),[y,b]=No(Xe.changesWidth,220,ee=>ee?kd(Number(ee),220):void 0),[S,j]=No(Xe.chatWidth,380,ee=>ee?kd(Number(ee),380):void 0),[E,N]=No(Xe.railWidth,280,ee=>ee?kd(Number(ee),280):void 0),A=(ee,J,W)=>{const ie=J.classList.contains("left")?"left":"right",Te=ie==="left"?J.previousElementSibling:J.nextElementSibling;return Te?kd(LH(Te.getBoundingClientRect(),ie,ee.clientX),W):null},O=Xa((ee,J)=>A(ee,J,220),b),P=Xa((ee,J)=>A(ee,J,380),j),R=Xa((ee,J)=>A(ee,J,280),N),[T,$]=_.useState(null),z=bn("app").contextMenu(()=>wN(e.getState(),{sock:n,dispatch:t})),V=d.jsx(o_,{width:y}),se=!i&&!h&&d.jsx(NH,{width:S}),I=!r&&d.jsx(_T,{width:E}),ne=ee=>!r&&g&&d.jsx("div",{className:`dock-resize ${ee}`,onPointerDown:R}),we=k==="left",K=we?{dock:se,open:m,drag:P}:{dock:V,open:p,drag:O},B=we?{dock:V,open:p,drag:O}:{dock:se,open:m,drag:P};return d.jsxs("div",{className:Ke("app",l&&"zen"),"data-chat-side":k,"data-touch":o||void 0,"data-hover":!o||void 0,onContextMenu:ee=>{ee.defaultPrevented||ee.target instanceof Element&&ee.target.closest(DH)||z.onContextMenu(ee)},children:[d.jsx(RS,{}),d.jsx(PS,{}),d.jsx(AH,{center:T}),d.jsxs("div",{className:"docks",children:[we&&I,we&&ne("left"),K.dock,K.open&&d.jsx("div",{className:"dock-resize left",onPointerDown:K.drag}),d.jsx(_H,{onRoot:$}),B.open&&d.jsx("div",{className:"dock-resize right",onPointerDown:B.drag}),B.dock,!we&&ne("right"),!we&&I]})]})}function FH(e,t,n,r){if(!n)return null;const o=e.findIndex(u=>u.id===n);if(o>=0){const u=e[(o+r+e.length)%e.length];return u&&u.id!==n?{activate:u.id}:null}const i=t.findIndex(u=>u.id===n);if(i<0)return null;const l=t[i+r];if(l)return{activate:l.id};const c=e[e.length-1];return r<0&&c?{activate:c.id}:null}const BH=new Set(["design","chats"]),UH=new Set(["reload","back","forward"]),HH=new Set(["project","commands","keys","zen"]);function WH(){const e=Zn(),t=pt();_.useEffect(()=>{const n=e7(p=>e.dispatch({a:"rail-peek",on:p})),r=n.end,o=p=>{e.getState().railOpen||n.press(p)},i=p=>n.keyup(p.key),l=p=>n.mods(p),c=()=>{var g,y;const p=e.getState(),k=((y=(g=document.activeElement)==null?void 0:g.closest("[data-pane]"))==null?void 0:y.dataset.pane)??(p.layout.term?"terminal":p.editor?"editor":p.layout.design?"design":null);k==="terminal"?e.dispatch({a:"toggle-terminal"}):k==="editor"?e.dispatch({a:"close-editor"}):k==="design"&&e.dispatch({a:"toggle-design"})},u=p=>{p.key!=="Escape"||!e.getState().choosingFolder||(p.stopImmediatePropagation(),t==null||t.send({t:"cancel-folder"}),e.dispatch({a:"choosing-folder",v:!1}))},h=p=>{var S,j,E,N;l(p),kC(p)&&!p.defaultPrevented&&p.preventDefault();const m=e.getState(),{dispatch:k}=e,g=A=>{const O=document.activeElement,P=!O||O===document.body||!!O.closest(".rail, .chat-input");k({a:"activate",id:A}),P&&k({a:"walked"})},y=a1(p,{guest:!!((S=document.activeElement)!=null&&S.closest(".xterm"))});if(!(m.zen&&!To(m)&&!m.overlay&&!m.picking&&!(y&&gC.has(y.id))||(y==null?void 0:y.id)==="close"&&!nk()||(j=document.activeElement)!=null&&j.closest(".monaco-editor")&&y&&BH.has(y.id))&&!(y&&xC(y.id,document.activeElement))&&!(y&&UH.has(y.id)&&!(pc(m)&&tf(m)))){if(y){const A=p.defaultPrevented;if(p.preventDefault(),m.newProject&&!HH.has(y.id))return;switch(y.id){case"worktree":{const O=yC(y.digit,m.visible.length),P=O===null?void 0:m.visible[O];P&&g(P.id);break}case"wt-prev":case"wt-next":{const O=FH(m.visible,m.visibleDiscovered,m.activeId,y.id==="wt-next"?1:-1);O&&g(O.activate),o(p);break}case"wt-unseen-prev":case"wt-unseen-next":{const O=Gg(m.visible,m.activeId,y.id==="wt-unseen-next"?1:-1);O&&g(O.activate),o(p);break}case"mark-unread":m.activeId&&!m.draft&&m.visible.some(O=>O.id===m.activeId)&&HS(t,k,m.activeId);break;case"wt-archive":{if(p.repeat||A)break;const O=m.draft||m.archivedPage?void 0:m.visible.find(P=>P.id===m.activeId);O&&Ck(t,k).archive(O);break}case"new":k({a:"open-draft"});break;case"project":k({a:"toggle",overlay:{kind:"projects",form:"center"}});break;case"quick-open":((E=m.overlay)==null?void 0:E.kind)==="quick-open"?k({a:"close"}):m.activeId&&k({a:"open",overlay:{kind:"quick-open"}});break;case"routes":((N=m.overlay)==null?void 0:N.kind)==="routes"?k({a:"close"}):tf(m)&&k({a:"open",overlay:{kind:"routes"}});break;case"reload":case"back":case"forward":{const O=pc(m);O&&cn.post(O,{type:y.id});break}case"pick":case"inspect":{const O=pc(m);O&&Pc(O,m.picking,k,y.id==="pick"?"chat":"code");break}case"search":m.activeId&&k({a:"toggle",overlay:{kind:"search"}});break;case"refs":m.activeRepoId&&k({a:"toggle",overlay:{kind:"refs"}});break;case"chats":m.activeRepoId&&k({a:"toggle",overlay:{kind:"chats"}});break;case"commands":k({a:"toggle",overlay:{kind:"commands"}});break;case"zen":k({a:"toggle-zen"});break;case"close":!(m.zen&&!To(m))&&!m.overlay&&c();break;case"changes":k(m.layout.changes&&(sl(m)==="changes"||Ao(m)!==null)?{a:"toggle-changes"}:{a:"focus-changes",tab:"changes"});break;case"files":k(m.layout.changes&&sl(m)==="files"?{a:"toggle-changes"}:{a:"focus-changes",tab:"files"});break;case"panel-tab-prev":case"panel-tab-next":if(Pf(m))break;k(m.layout.changes?{a:"focus-changes",tab:HP(m,y.id==="panel-tab-next"?1:-1)}:{a:"focus-changes"});break;case"composer":k(CE(m));break;case"rail":k(m.railOpen?{a:"toggle-rail"}:{a:"focus-rail"});break;case"keys":k({a:"toggle",overlay:{kind:"keys"}});break;case"terminal":k(m.layout.term?{a:"toggle-terminal"}:{a:"focus-terminal"});break;case"design":k({a:"toggle-design"});break;case"term-tab":{const O=m.rows.find($=>$.id===m.activeId);if(!O)break;const P=Co(m,m.activeId).termStream;if(O.login&&P===Cs)break;const R=[_o,...O.login?[Cs]:[],...O.procs.map($=>$.name)],T=R.indexOf(P);k({a:"term-stream",id:O.id,stream:R[(T+1)%R.length]??_o});break}}}else if(p.key==="Escape")if(m.newProject)m.newProject.phase==="editing"&&k({a:"close-new-project"});else if(m.picking){const A=pc(m);A&&cn.post(A,{type:"pick-cancel"}),k({a:"set-picking",v:!1})}else m.notesPage?k({a:"close-release-notes"}):m.archivedPage?k({a:"close-archived"}):m.activeImportId?k({a:"watch-import",id:null}):c()}};return window.addEventListener("keydown",u,!0),window.addEventListener("keydown",h),window.addEventListener("keyup",i),window.addEventListener("pointermove",l),window.addEventListener("pointerdown",l),window.addEventListener("blur",r),()=>{window.removeEventListener("keydown",u,!0),window.removeEventListener("keydown",h),window.removeEventListener("keyup",i),window.removeEventListener("pointermove",l),window.removeEventListener("pointerdown",l),window.removeEventListener("blur",r),r()}},[e,t]),_.useEffect(()=>{const n=r=>{if(r.key!=="Alt"&&r.key!=="Shift")return;const o=e.getState();o.picking&&o.activeId&&cn.post(o.activeId,{type:"pick-mods",alt:r.altKey,shift:r.shiftKey})};return window.addEventListener("keydown",n),window.addEventListener("keyup",n),()=>{window.removeEventListener("keydown",n),window.removeEventListener("keyup",n)}},[e])}const KH=3,ZH=2e3,qH=200,GH=5e3;function VH(){const e=Zn(),t=ut(),n=pt(),{storage:r}=lo(),o=hl(),i=L(de=>de.activeRepoId),l=Rs(),c=gk(),u=L(de=>de.connected),h=L(de=>de.daylight),p=L(de=>{var be;return((be=de.daylight)==null?void 0:be.until)??0}),m=ia(),k=L(de=>de.notesPage),g=L(de=>de.version),y=L(de=>de.railOpen),b=L(de=>de.chatSide),S=L(de=>de.layouts),j=L(de=>de.lastActive),E=L(de=>de.discoveredOpen),N=L(de=>de.archivedOpen),A=L(de=>de.committedShut),O=L(de=>de.turnOpen),P=L(de=>de.treeOpen),R=Df(),T=L(de=>de.previewTheme!==null),$=L(de=>de.openUrl),D=JE();_.useEffect(()=>nf.install(window),[]);const z=_.useRef([]);_.useEffect(()=>{if(!n||!u||!o)return;const de=[o,...z.current.filter(be=>be!==o)];for(const be of de.splice(KH))n.send({t:"unsubscribe",worktreeId:be});z.current.includes(o)||n.send({t:"subscribe",worktreeId:o}),z.current=de},[o,u,n]),_.useEffect(()=>{if(!(!n||!u))for(const de of z.current)n.send({t:"subscribe",worktreeId:de})},[u,n]);const V=_.useRef(void 0);_.useEffect(()=>{if(!n||!u)return;let de;const be=()=>{const ce=document.visibilityState==="visible"?o:null;n.send({t:"view",worktreeId:ce}),V.current=ce},le=()=>{clearTimeout(de),de=setTimeout(be,qH)};V.current===void 0||V.current===o||document.visibilityState!=="visible"?be():le();const G=()=>document.visibilityState==="visible"?le():be();return document.addEventListener("visibilitychange",G),()=>{clearTimeout(de),document.removeEventListener("visibilitychange",G)}},[o,u,n]);const se=(m==null?void 0:m.id)??null;_.useEffect(()=>{if(!(!n||!u||!se))return n.send({t:"subscribe",worktreeId:se}),()=>n.send({t:"unsubscribe",worktreeId:se})},[se,u,n]),_.useEffect(()=>{const de=new Set(D.map(le=>le.id)),be=z.current.filter(le=>!de.has(le));if(be.length!==0&&(z.current=z.current.filter(le=>de.has(le)),!(!n||!u)))for(const le of be)n.send({t:"unsubscribe",worktreeId:le})},[D,u,n]);const I=k?"Release notes":(m==null?void 0:m.title)??(c==null?void 0:c.name)??null;_.useEffect(()=>{document.title=I?`${I} · Toyon`:"Toyon"},[I]);const ne=!!(l!=null&&l.unseen),we=L(de=>de.unreadHold!==null&&de.unreadHold===de.activeId);_.useEffect(()=>{if(!n||!o||!ne||we)return;let de;const be=()=>document.visibilityState==="visible"&&document.hasFocus(),le=()=>{clearTimeout(de),be()&&(de=setTimeout(()=>{be()&&n.send({t:"seen",worktreeId:o})},ZH))},G=()=>clearTimeout(de);return le(),window.addEventListener("focus",le),window.addEventListener("blur",G),()=>{G(),window.removeEventListener("focus",le),window.removeEventListener("blur",G)}},[n,o,ne,we]);const K=_.useRef(0),B=L(de=>lk(de));_.useEffect(()=>{if(!n||!u||!i)return;const de=()=>{Date.now()-K.current<GH||(K.current=Date.now(),n.send({t:"refresh-git",repoId:i}),B&&B!==i&&n.send({t:"refresh-git",repoId:B}))};return window.addEventListener("focus",de),()=>window.removeEventListener("focus",de)},[n,u,i,B]),_.useEffect(()=>{RT(R,{remember:!T}),cn.broadcast($T(R))},[R,T]);const ee=_.useCallback(()=>{n==null||n.send({t:"zone",tz:Intl.DateTimeFormat().resolvedOptions().timeZone})},[n]);_.useEffect(()=>{if(!u)return;ee();const de=()=>{document.visibilityState==="visible"&&ee()};return document.addEventListener("visibilitychange",de),()=>document.removeEventListener("visibilitychange",de)},[u,ee]),_.useEffect(()=>{if(!u||p<=Date.now())return;const de=setTimeout(ee,p-Date.now()+1e3);return()=>clearTimeout(de)},[u,p,ee]),_.useEffect(()=>{h&&h.until>0&&w7(h)},[h]),_.useEffect(()=>{o&&r.set(Xe.active,o)},[o,r]),_.useEffect(()=>{g&&r.set(Xe.version,g)},[g,r]);const J=L(de=>de.frame==="phone"?de.screen!=="home":null);_.useEffect(()=>{J!==null&&r.session.set(Xe.phoneRow,J?"1":"0")},[J,r]);const W=L(de=>de.frame==="phone"&&de.screen==="home"?"surface1":"surface0");_.useEffect(()=>{try{sessionStorage.setItem(Xe.ground,W)}catch{}},[W]),_.useEffect(()=>{i&&r.set(Xe.repo,i)},[i,r]),_.useEffect(()=>{try{localStorage.setItem(Xe.rail,y?"1":"0")}catch{}},[y]),_.useEffect(()=>{try{localStorage.setItem(Xe.chatSide,b)}catch{}},[b]),_.useEffect(()=>{try{localStorage.setItem(Xe.layouts,JSON.stringify(S))}catch{}},[S]),_.useEffect(()=>{r.set(Xe.lastActive,JSON.stringify(j))},[j,r]),_.useEffect(()=>{r.set(Xe.discoveredOpen,JSON.stringify(E))},[E,r]),_.useEffect(()=>{r.set(Xe.archivedOpen,JSON.stringify(N))},[N,r]),_.useEffect(()=>{r.set(Xe.committedShut,JSON.stringify(A))},[A,r]),_.useEffect(()=>{r.set(Xe.turnOpen,JSON.stringify(O))},[O,r]),_.useEffect(()=>{r.set(Xe.treeOpen,JSON.stringify(P))},[P,r]),WH(),q4();const ie=_.useRef(null);_.useEffect(()=>{!$||ie.current===$||(ie.current=$,window.open($,"_blank"),t({a:"opened-url"}))},[$,t]);const Te=_.useRef(null);return gt([o],()=>{var Le,Ue,_e,je;const de=Te.current;if(Te.current=o,!de||!o||de===o)return;const be=e.getState(),le=D.find(Ne=>Ne.id===de),G=D.find(Ne=>Ne.id===o),ce=(Ue=(Le=le==null?void 0:le.worktree)==null?void 0:Le.variant)==null?void 0:Ue.group;if(!ce||((je=(_e=G==null?void 0:G.worktree)==null?void 0:_e.variant)==null?void 0:je.group)!==ce)return;const oe=Ne=>{var qe;try{const Ft=(qe=be.local[Ne])==null?void 0:qe.page.url;return Ft?new URL(Ft).pathname+new URL(Ft).search:"/"}catch{return"/"}},re=oe(de);re!==oe(o)&&cn.post(o,{type:"navigate",path:re})}),L(de=>de.frame)==="phone"?d.jsx(c7,{}):d.jsx(zH,{})}function YH({origin:e,machine:t,onToken:n}){const[r,o]=_.useState({kind:"asking"}),[i,l]=_.useState(0);return gt([i],()=>{const c=new AbortController;return o({kind:"asking"}),pE(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(fs,{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.":vT(r.failure,e,"this device")}),r.kind==="failed"&&d.jsx("div",{className:"status-actions",children:d.jsx(De,{variant:"outline",onClick:()=>l(c=>c+1),children:"ask again"})})]})}function XH(){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(oC(t.worktreeId,t.stream))??[])n(t)}}}function QH(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 JH(e){const t={};try{const n=JSON.parse(e??"{}");if(!n||typeof n!="object")return t;for(const[r,o]of Object.entries(n))OP(o)&&(t[r]=o)}catch{}return t}function eW(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 Cd(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 tW(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 nW=400,rW=2e3;function BT(){const e=new Map;return{another(t,n=0){return(e.get(t)??0)===n?!1:(e.set(t,n),!0)}}}function UT(e,t,n){const r=e.getState(),o=[];for(const[i,l]of t){if(l===n||r.local[i])continue;const c=ls(i);c&&c.clientId!==r.clientId||o.push(i)}return o}function oW(e,t){const n=new Map,r=new Map,o=BT(),i=u=>{var p,m;clearTimeout((p=r.get(u))==null?void 0:p.timer),r.delete(u);const h=e.getState().local[u];!h||((m=h.mark)==null?void 0:m.by)==="walk"||(n.get(u)??"")!==h.draft&&(n.set(u,h.draft),t.send({t:"set-draft",boxId:u,text:h.draft,clientId:e.getState().clientId}))},l=()=>{for(const u of[...r.keys()])i(u)},c=e.subscribe(()=>{var u,h,p;for(const[m,k]of Object.entries(e.getState().local)){if(o.another(m,k.sent)&&(clearTimeout((u=r.get(m))==null?void 0:u.timer),r.delete(m),n.set(m,"")),((h=k.mark)==null?void 0:h.by)==="walk"||(n.get(m)??"")===k.draft)continue;if(!k.draft){i(m);continue}const g=r.get(m);if((g==null?void 0:g.text)===k.draft)continue;clearTimeout(g==null?void 0:g.timer);const y=(g==null?void 0:g.since)??Date.now(),b=Math.max(0,Math.min(nW,y+rW-Date.now()));r.set(m,{text:k.draft,timer:setTimeout(i,b,m),since:y})}for(const m of UT(e,n,""))clearTimeout((p=r.get(m))==null?void 0:p.timer),r.delete(m),n.set(m,""),t.send({t:"set-draft",boxId:m,text:"",clientId:e.getState().clientId})});return window.addEventListener("focusout",l),window.addEventListener("pagehide",l),{hello(u){n.clear();for(const[h,p]of Object.entries(u))n.set(h,p)},heard(u,h){return r.has(u)?!1:(n.set(u,h),!0)},dispose(){c();for(const u of r.values())clearTimeout(u.timer);r.clear(),window.removeEventListener("focusout",l),window.removeEventListener("pagehide",l)}}}function sW(e,t){const n=new Map,r=new Map,o=BT(),i=e.subscribe(()=>{const l=[];for(const[c,u]of Object.entries(e.getState().local)){if(o.another(c,u.sent)&&r.set(c,"[]"),n.get(c)===u.attachments)continue;n.set(c,u.attachments);const h=sk(u.attachments),p=JSON.stringify(h),m=r.get(c)??"[]";m!==p&&(r.set(c,p),l.push({id:c,items:h,before:SE(JSON.parse(m))}))}for(const c of UT(e,r,"[]"))r.set(c,"[]"),l.push({id:c,items:[],before:[]});for(const c of IP(l))t.send({t:"set-attachments",boxId:c.id,items:c.items,clientId:e.getState().clientId})});return{hello(l){r.clear(),n.clear();for(const[c,u]of Object.entries(l))r.set(c,JSON.stringify(u))},heard(l,c){r.set(l,JSON.stringify(c))},dispose:i}}function iW(e,t){return e.subscribe(()=>{for(const n of AP(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(hc(o.outgoing.frame,n,o.draft,o.attachments)),e.dispatch({a:"sent-out",id:n}))}})}const Gx="not sent: the page reloaded while an upload was on its way; attach it again and send";function Vx(e,t,n){var l;const r=e.getState(),o=new Set([...Object.keys(n.drafts),...Object.keys(n.attachments)]),i=[];for(const c of o){const u=ls(c);if((u==null?void 0:u.clientId)!==r.clientId||(l=r.local[c])!=null&&l.outgoing)continue;const h=n.drafts[c]??"",p=n.attachments[c]??[],m=n.drafts[u.source]??"",k=[...p,...n.attachments[u.source]??[]],g=m||h,y=r.clientId;k.length&&t.send({t:"set-attachments",boxId:u.source,items:k,clientId:y}),g!==m&&t.send({t:"set-draft",boxId:u.source,text:g,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],g&&(n.drafts[u.source]=g),k.length&&(n.attachments[u.source]=k),i.push(u.source)}return i}function aW(e,t){const n=(t.storage??PM)(e.origin),r=hL(PP({cached:t.cached,systemDark:t.systemDark,daylight:t.daylight,storedActive:n.get(Xe.active),storedPhoneRow:n.session.get(Xe.phoneRow)==="1",storedRepo:n.get(Xe.repo),storedVersion:n.get(Xe.version),storedRailOpen:hm(Xe.rail)==="1",storedChatSide:hm(Xe.chatSide)==="right"?"right":"left",storedLayouts:JH(hm(Xe.layouts)),storedLastActive:eW(n.get(Xe.lastActive)),storedDiscoveredOpen:Cd(n.get(Xe.discoveredOpen)),storedArchivedOpen:Cd(n.get(Xe.archivedOpen)),storedCommittedShut:Cd(n.get(Xe.committedShut)),storedTurnOpen:Cd(n.get(Xe.turnOpen)),storedTreeOpen:tW(n.get(Xe.treeOpen)),clientId:t.clientId,frame:t.frame,touch:t.touch})),o=XH(),i={version:null,protocol:null},l=$5(y=>r.dispatch({a:"server",msg:y}));let c,u,h,p=[];const m=new nP(e,y=>{if(y.t==="hello"){if(i.protocol=y.protocol,e.serving){const{rebuilt:S,update:j}=r.getState(),E=S&&(j==null?void 0:j.restarting)!=null;if(i.version!==null&&(E||y.version!==i.version||y.protocol!==md)){m.dispose(),t.reload();return}if(y.protocol!==md){r.dispatch({a:"incompatible"}),m.dispose();return}}else if(y.protocol!==md){r.dispatch({a:"incompatible"}),m.suspend();return}else r.getState().incompatible&&r.dispatch({a:"incompatible",v:!1});i.version=y.version;const b=new Set(m.sentWhileDown());if(b.size){const S=j=>Object.fromEntries(Object.entries(j).filter(([E])=>!b.has(E)));y.drafts=S(y.drafts),y.attachments=S(y.attachments)}p=Vx(r,m,y),c.hello(y.drafts),u.hello(y.attachments)}if(y.t==="attachments"&&y.clientId!==r.getState().clientId&&u.heard(y.boxId,y.items),!(y.t==="draft"&&y.clientId!==r.getState().clientId&&!c.heard(y.boxId,y.text))){if(C2(y)){o.deliver(y);return}if(A2(y)){if(y.t==="file-written"&&c4(y))return;h.receive(y);return}if(y.t==="loose-written"){uB(y);return}if(Iz(y)){Oz(r,m,y);return}if(y.t==="open-refused"){$z(r,y);return}l(y);for(const b of p.splice(0))r.dispatch({a:"notice",id:b,text:Gx})}},(y,b)=>r.dispatch({a:"connected",v:y,failure:b}));h4(r,m.urls),h=new lB({store:r,send:y=>m.send(y),timers:{set:(y,b)=>setTimeout(y,b),clear:y=>clearTimeout(y)},win:window});const k=h.start();c=oW(r,m),u=sW(r,m);const g=iW(r,m);return{origin:e.origin,serving:e.serving,token:e.token,get name(){return r.getState().machine??QH(e.origin)},store:r,sock:m,files:h,terminals:o,storage:n,heard:i,boot(y){if(y.t!=="hello"||y.protocol!==md)return;i.version??(i.version=y.version);const b=Vx(r,m,y);u.hello(y.attachments),r.dispatch({a:"server",msg:y});for(const S of b)r.dispatch({a:"notice",id:S,text:Gx})},dispose(){m.dispose(),k(),c.dispose(),u.dispose(),g()}}}function hm(e){try{return localStorage.getItem(e)}catch{return null}}window.__toyonShell=!0;window.top!==window&&(document.documentElement.dataset.framed="");DM(location.origin);const HT=p7();RT(HT);function lW(e,t){try{return e.getItem(t)}catch{return null}}function cW(){const e=lW(sessionStorage,Xe.client);if(e)return e;const t=Math.random().toString(36).slice(2,10);try{sessionStorage.setItem(Xe.client,t)}catch{}return t}const uW={cached:HT,systemDark:m7(),daylight:k7(),clientId:cW(),frame:IT(),touch:f7(),reload:()=>window.location.reload()},mi=NU({serving:{origin:location.origin,token:lE()},build:e=>aW(e,uW)});h7({dispatch:e=>mi.broadcast(e)});y7(e=>mi.broadcast({a:"system-dark",v:e}));let Yx=jT(mi.active().store),Xx=mi.active();mi.subscribe(()=>{const e=mi.active();e!==Xx&&(Xx=e,Yx(),e.store.getState().frame==="phone"&&e.store.dispatch({a:"screen",to:"home"}),Yx=jT(e.store))});window.addEventListener("vite:preloadError",bD);const dW=(window.toyonBoot??Promise.resolve(null)).then(e=>{const t=e;t&&typeof t=="object"&&t.t==="hello"&&mi.active().boot(t)});function fW(e){cE(e),window.location.reload()}const hW=Jj.createRoot(document.getElementById("root"));dW.then(()=>{Xj.flushSync(()=>hW.render(d.jsx(qj.StrictMode,{children:d.jsx(jk,{children:Kg()?d.jsx(mL,{machines:mi,children:d.jsx(VH,{})}):d.jsx(YH,{origin:location.origin,machine:location.host,onToken:fW})})}))),document.documentElement.style.removeProperty("background")});"serviceWorker"in navigator&&navigator.serviceWorker.register("/sw.js").catch(()=>{});export{$s as F,pg as _,oo as a,Ug as b,wW as c,gW as d,l1 as e,oC as f,xz as g,jM as h,Pk as i,d as j,mW as k,a1 as m,kW as p,_ as r,bM as s,Gc as t,gt as u,b0 as w};
|